-
-
Notifications
You must be signed in to change notification settings - Fork 344
/
Copy pathRNSentryBreadcrumb.m
58 lines (48 loc) · 1.67 KB
/
RNSentryBreadcrumb.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#import "RNSentryBreadcrumb.h"
@import Sentry;
@implementation RNSentryBreadcrumb
+(SentryBreadcrumb*) from: (NSDictionary *) dict
{
SentryBreadcrumb* crumb = [[SentryBreadcrumb alloc] init];
NSString * levelString = dict[@"level"];
SentryLevel sentryLevel;
if ([levelString isEqualToString:@"fatal"]) {
sentryLevel = kSentryLevelFatal;
} else if ([levelString isEqualToString:@"warning"]) {
sentryLevel = kSentryLevelWarning;
} else if ([levelString isEqualToString:@"error"]) {
sentryLevel = kSentryLevelError;
} else if ([levelString isEqualToString:@"debug"]) {
sentryLevel = kSentryLevelDebug;
} else {
sentryLevel = kSentryLevelInfo;
}
[crumb setLevel:sentryLevel];
[crumb setCategory:dict[@"category"]];
id origin = dict[@"origin"];
if (origin != nil) {
[crumb setOrigin:origin];
} else {
[crumb setOrigin:@"react-native"];
}
[crumb setType:dict[@"type"]];
[crumb setMessage:dict[@"message"]];
[crumb setData:dict[@"data"]];
return crumb;
}
+ (NSString *_Nullable) getCurrentScreenFrom: (NSDictionary<NSString*, id> *_Nonnull) dict {
NSString *_Nullable maybeCategory = [dict valueForKey:@"category"];
if (![maybeCategory isEqualToString:@"navigation"]) {
return nil;
}
NSDictionary<NSString*, id> *_Nullable maybeData = [dict valueForKey:@"data"];
if (![maybeData isKindOfClass:[NSDictionary class]]) {
return nil;
}
NSString *_Nullable maybeCurrentScreen = [maybeData valueForKey:@"to"];
if (![maybeCurrentScreen isKindOfClass:[NSString class]]) {
return nil;
}
return maybeCurrentScreen;
}
@end