@@ -22,7 +22,12 @@ @implementation RNSentry
2222
2323- (dispatch_queue_t )methodQueue
2424{
25- return dispatch_queue_create (" io.sentry.RNSentry" , DISPATCH_QUEUE_SERIAL);
25+ static dispatch_queue_t sentryMethodQueue;
26+ static dispatch_once_t onceQueueToken;
27+ dispatch_once (&onceQueueToken, ^{
28+ sentryMethodQueue = dispatch_queue_create (" io.sentry.RNSentry" , DISPATCH_QUEUE_SERIAL);
29+ });
30+ return sentryMethodQueue;
2631}
2732
2833+ (void )installWithBridge : (RCTBridge *)bridge {
@@ -135,7 +140,7 @@ - (NSInteger)indexOfReactNativeCallFrame:(NSArray<SentryFrame *> *)frames native
135140}
136141
137142- (void )injectReactNativeFrames : (SentryEvent *)event {
138- NSString *address = [event.extra valueForKey :@" __sentry_address" ];
143+ NSString *address = [[ NSUserDefaults standardUserDefaults ] objectForKey :@" RNSentry. __sentry_address" ];
139144 if (nil == address) {
140145 // We bail out here since __sentry_address is not set
141146 return ;
@@ -156,7 +161,8 @@ - (void)injectReactNativeFrames:(SentryEvent *)event {
156161
157162 NSMutableArray <SentryFrame *> *finalFrames = [NSMutableArray new ];
158163
159- NSArray <SentryFrame *> *reactFrames = [self convertReactNativeStacktrace: SentryParseJavaScriptStacktrace (event.extra[@" __sentry_stack" ])];
164+ NSString *stacktrace = [[NSUserDefaults standardUserDefaults ] objectForKey: @" RNSentry.__sentry_stack" ];
165+ NSArray <SentryFrame *> *reactFrames = [self convertReactNativeStacktrace: SentryParseJavaScriptStacktrace (stacktrace)];
160166 for (NSInteger i = 0 ; i < frames.count ; i++) {
161167 [finalFrames addObject: [frames objectAtIndex: i]];
162168 if (i == indexOfReactFrames) {
@@ -245,12 +251,9 @@ - (void)swizzleInvokeWithBridge:(Class)class {
245251 if (arguments != nil && arguments.count > 0 ) {
246252 for (id param in arguments) {
247253 if ([param isKindOfClass: NSDictionary .class] && param[@" __sentry_stack" ]) {
248- @synchronized (SentryClient.sharedClient ) {
249- NSMutableDictionary *prevExtra = SentryClient.sharedClient .extra .mutableCopy ;
250- [prevExtra setValue: [NSNumber numberWithUnsignedInteger: callNativeModuleAddress] forKey: @" __sentry_address" ];
251- [prevExtra setValue: [RCTConvert NSString: param[@" __sentry_stack" ]] forKey: @" __sentry_stack" ];
252- SentryClient.sharedClient .extra = prevExtra;
253- }
254+ [[NSUserDefaults standardUserDefaults ] setObject: [NSNumber numberWithUnsignedInteger: callNativeModuleAddress] forKey: @" RNSentry.__sentry_address" ];
255+ [[NSUserDefaults standardUserDefaults ] setObject: [RCTConvert NSString: param[@" __sentry_stack" ]] forKey: @" RNSentry.__sentry_stack" ];
256+ [[NSUserDefaults standardUserDefaults ] synchronize ];
254257 } else {
255258 if (param != nil ) {
256259 [newParams addObject: param];
@@ -277,12 +280,9 @@ - (void)swizzleCallNativeModule:(Class)class {
277280 if (params != nil && params.count > 0 ) {
278281 for (id param in params) {
279282 if ([param isKindOfClass: NSDictionary .class] && param[@" __sentry_stack" ]) {
280- @synchronized (SentryClient.sharedClient ) {
281- NSMutableDictionary *prevExtra = SentryClient.sharedClient .extra .mutableCopy ;
282- [prevExtra setValue: [NSNumber numberWithUnsignedInteger: callNativeModuleAddress] forKey: @" __sentry_address" ];
283- [prevExtra setValue: [RCTConvert NSString: param[@" __sentry_stack" ]] forKey: @" __sentry_stack" ];
284- SentryClient.sharedClient .extra = prevExtra;
285- }
283+ [[NSUserDefaults standardUserDefaults ] setObject: [NSNumber numberWithUnsignedInteger: callNativeModuleAddress] forKey: @" RNSentry.__sentry_address" ];
284+ [[NSUserDefaults standardUserDefaults ] setObject: [RCTConvert NSString: param[@" __sentry_stack" ]] forKey: @" RNSentry.__sentry_stack" ];
285+ [[NSUserDefaults standardUserDefaults ] synchronize ];
286286 } else {
287287 if (param != nil ) {
288288 [newParams addObject: param];
0 commit comments