From fde25e8880e9d59968ca16cf92c3dca56c9efdc5 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Fri, 11 Aug 2017 15:25:26 +0200 Subject: [PATCH 1/2] Use userdefaults instead of sentry extra for stacktrace merging --- ios/RNSentry.m | 30 +++++++++++++++--------------- ios/Sentry | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ios/RNSentry.m b/ios/RNSentry.m index 4cf7131a37..91f84e8f2c 100644 --- a/ios/RNSentry.m +++ b/ios/RNSentry.m @@ -22,7 +22,12 @@ @implementation RNSentry - (dispatch_queue_t)methodQueue { - return dispatch_queue_create("io.sentry.RNSentry", DISPATCH_QUEUE_SERIAL); + static dispatch_queue_t sentryMethodQueue; + static dispatch_once_t onceQueueToken; + dispatch_once(&onceQueueToken, ^{ + sentryMethodQueue = dispatch_queue_create("io.sentry.RNSentry", DISPATCH_QUEUE_SERIAL); + }); + return sentryMethodQueue; } + (void)installWithBridge:(RCTBridge *)bridge { @@ -135,7 +140,7 @@ - (NSInteger)indexOfReactNativeCallFrame:(NSArray *)frames native } - (void)injectReactNativeFrames:(SentryEvent *)event { - NSString *address = [event.extra valueForKey:@"__sentry_address"]; + NSString *address = [[NSUserDefaults standardUserDefaults] objectForKey:@"RNSentry.__sentry_address"]; if (nil == address) { // We bail out here since __sentry_address is not set return; @@ -156,7 +161,8 @@ - (void)injectReactNativeFrames:(SentryEvent *)event { NSMutableArray *finalFrames = [NSMutableArray new]; - NSArray *reactFrames = [self convertReactNativeStacktrace:SentryParseJavaScriptStacktrace(event.extra[@"__sentry_stack"])]; + NSString *stacktrace = [[NSUserDefaults standardUserDefaults] objectForKey:@"RNSentry.__sentry_stack"]; + NSArray *reactFrames = [self convertReactNativeStacktrace:SentryParseJavaScriptStacktrace(stacktrace)]; for (NSInteger i = 0; i < frames.count; i++) { [finalFrames addObject:[frames objectAtIndex:i]]; if (i == indexOfReactFrames) { @@ -245,12 +251,9 @@ - (void)swizzleInvokeWithBridge:(Class)class { if (arguments != nil && arguments.count > 0) { for (id param in arguments) { if ([param isKindOfClass:NSDictionary.class] && param[@"__sentry_stack"]) { - @synchronized (SentryClient.sharedClient) { - NSMutableDictionary *prevExtra = SentryClient.sharedClient.extra.mutableCopy; - [prevExtra setValue:[NSNumber numberWithUnsignedInteger:callNativeModuleAddress] forKey:@"__sentry_address"]; - [prevExtra setValue:[RCTConvert NSString:param[@"__sentry_stack"]] forKey:@"__sentry_stack"]; - SentryClient.sharedClient.extra = prevExtra; - } + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInteger:callNativeModuleAddress] forKey:@"RNSentry.__sentry_address"]; + [[NSUserDefaults standardUserDefaults] setObject:[RCTConvert NSString:param[@"__sentry_stack"]] forKey:@"RNSentry.__sentry_stack"]; + [[NSUserDefaults standardUserDefaults] synchronize]; } else { if (param != nil) { [newParams addObject:param]; @@ -277,12 +280,9 @@ - (void)swizzleCallNativeModule:(Class)class { if (params != nil && params.count > 0) { for (id param in params) { if ([param isKindOfClass:NSDictionary.class] && param[@"__sentry_stack"]) { - @synchronized (SentryClient.sharedClient) { - NSMutableDictionary *prevExtra = SentryClient.sharedClient.extra.mutableCopy; - [prevExtra setValue:[NSNumber numberWithUnsignedInteger:callNativeModuleAddress] forKey:@"__sentry_address"]; - [prevExtra setValue:[RCTConvert NSString:param[@"__sentry_stack"]] forKey:@"__sentry_stack"]; - SentryClient.sharedClient.extra = prevExtra; - } + [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInteger:callNativeModuleAddress] forKey:@"RNSentry.__sentry_address"]; + [[NSUserDefaults standardUserDefaults] setObject:[RCTConvert NSString:param[@"__sentry_stack"]] forKey:@"RNSentry.__sentry_stack"]; + [[NSUserDefaults standardUserDefaults] synchronize]; } else { if (param != nil) { [newParams addObject:param]; diff --git a/ios/Sentry b/ios/Sentry index a81b84001a..eeaf1b62a1 160000 --- a/ios/Sentry +++ b/ios/Sentry @@ -1 +1 @@ -Subproject commit a81b84001ab0b13765b7c4168c070beda45f9966 +Subproject commit eeaf1b62a12d566ff1983635844f4f8d4069612e From 85369631910717cfc0cd34fe7f1150adb6a12207 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Fri, 11 Aug 2017 16:03:29 +0200 Subject: [PATCH 2/2] Bump sentry-cocoa to 3.4.3 --- ios/Sentry | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Sentry b/ios/Sentry index eeaf1b62a1..d01701423d 160000 --- a/ios/Sentry +++ b/ios/Sentry @@ -1 +1 @@ -Subproject commit eeaf1b62a12d566ff1983635844f4f8d4069612e +Subproject commit d01701423ddaf9ab0bff739afb9c21eb222ee56c