Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions ios/RNSentry.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -135,7 +140,7 @@ - (NSInteger)indexOfReactNativeCallFrame:(NSArray<SentryFrame *> *)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;
Expand All @@ -156,7 +161,8 @@ - (void)injectReactNativeFrames:(SentryEvent *)event {

NSMutableArray<SentryFrame *> *finalFrames = [NSMutableArray new];

NSArray<SentryFrame *> *reactFrames = [self convertReactNativeStacktrace:SentryParseJavaScriptStacktrace(event.extra[@"__sentry_stack"])];
NSString *stacktrace = [[NSUserDefaults standardUserDefaults] objectForKey:@"RNSentry.__sentry_stack"];
NSArray<SentryFrame *> *reactFrames = [self convertReactNativeStacktrace:SentryParseJavaScriptStacktrace(stacktrace)];
for (NSInteger i = 0; i < frames.count; i++) {
[finalFrames addObject:[frames objectAtIndex:i]];
if (i == indexOfReactFrames) {
Expand Down Expand Up @@ -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];
Expand All @@ -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];
Expand Down