|
38 | 38 | #import "RNSentryEvents.h" |
39 | 39 | #import "RNSentryDependencyContainer.h" |
40 | 40 |
|
| 41 | +#if SENTRY_TARGET_REPLAY_SUPPORTED |
| 42 | +#import "RNSentrySessionReplay.h" |
| 43 | +#endif |
| 44 | + |
41 | 45 | #if SENTRY_HAS_UIKIT |
42 | 46 | #import "RNSentryRNSScreen.h" |
43 | 47 | #import "RNSentryFramesTrackerListener.h" |
@@ -106,6 +110,10 @@ + (BOOL)requiresMainQueueSetup { |
106 | 110 | sentHybridSdkDidBecomeActive = true; |
107 | 111 | } |
108 | 112 |
|
| 113 | +#if SENTRY_TARGET_REPLAY_SUPPORTED |
| 114 | + [RNSentrySessionReplay postInit]; |
| 115 | +#endif |
| 116 | + |
109 | 117 | resolve(@YES); |
110 | 118 | } |
111 | 119 |
|
@@ -135,27 +143,9 @@ - (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull) |
135 | 143 | [mutableOptions removeObjectForKey:@"tracesSampler"]; |
136 | 144 | [mutableOptions removeObjectForKey:@"enableTracing"]; |
137 | 145 |
|
138 | | - if ([mutableOptions valueForKey:@"_experiments"] != nil) { |
139 | | - NSDictionary *experiments = mutableOptions[@"_experiments"]; |
140 | | - if (experiments[@"replaysSessionSampleRate"] != nil || experiments[@"replaysOnErrorSampleRate"] != nil) { |
141 | | - [mutableOptions setValue:@{ |
142 | | - @"sessionReplay": @{ |
143 | | - @"sessionSampleRate": experiments[@"replaysSessionSampleRate"] ?: [NSNull null], |
144 | | - @"errorSampleRate": experiments[@"replaysOnErrorSampleRate"] ?: [NSNull null], |
145 | | - @"redactAllImages": mutableOptions[@"mobileReplayOptions"] != nil && |
146 | | - mutableOptions[@"mobileReplayOptions"][@"maskAllImages"] != nil |
147 | | - ? mutableOptions[@"mobileReplayOptions"][@"maskAllImages"] |
148 | | - : [NSNull null], |
149 | | - @"redactAllText": mutableOptions[@"mobileReplayOptions"] != nil && |
150 | | - mutableOptions[@"mobileReplayOptions"][@"maskAllText"] != nil |
151 | | - ? mutableOptions[@"mobileReplayOptions"][@"maskAllText"] |
152 | | - : [NSNull null], |
153 | | - } |
154 | | - } forKey:@"experimental"]; |
155 | | - [self addReplayRNRedactClasses: mutableOptions[@"mobileReplayOptions"]]; |
156 | | - } |
157 | | - [mutableOptions removeObjectForKey:@"_experiments"]; |
158 | | - } |
| 146 | +#if SENTRY_TARGET_REPLAY_SUPPORTED |
| 147 | + [RNSentrySessionReplay updateOptions:mutableOptions]; |
| 148 | +#endif |
159 | 149 |
|
160 | 150 | SentryOptions *sentryOptions = [[SentryOptions alloc] initWithDict:mutableOptions didFailWithError:errorPointer]; |
161 | 151 | if (*errorPointer != nil) { |
@@ -635,25 +625,21 @@ - (NSDictionary*) fetchNativeStackFramesBy: (NSArray<NSNumber*>*)instructionsAdd |
635 | 625 | resolver:(RCTPromiseResolveBlock)resolve |
636 | 626 | rejecter:(RCTPromiseRejectBlock)reject) |
637 | 627 | { |
| 628 | +#if SENTRY_TARGET_REPLAY_SUPPORTED |
638 | 629 | [PrivateSentrySDKOnly captureReplay]; |
639 | 630 | resolve([PrivateSentrySDKOnly getReplayId]); |
| 631 | +#else |
| 632 | + resolve(nil); |
| 633 | +#endif |
640 | 634 | } |
641 | 635 |
|
642 | 636 | RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getCurrentReplayId) |
643 | 637 | { |
| 638 | +#if SENTRY_TARGET_REPLAY_SUPPORTED |
644 | 639 | return [PrivateSentrySDKOnly getReplayId]; |
645 | | -} |
646 | | - |
647 | | -- (void) addReplayRNRedactClasses: (NSDictionary *_Nullable)replayOptions |
648 | | -{ |
649 | | - NSMutableArray *_Nonnull classesToRedact = [[NSMutableArray alloc] init]; |
650 | | - if ([replayOptions[@"maskAllImages"] boolValue] == YES) { |
651 | | - [classesToRedact addObject: NSClassFromString(@"RCTImageView")]; |
652 | | - } |
653 | | - if ([replayOptions[@"maskAllText"] boolValue] == YES) { |
654 | | - [classesToRedact addObject: NSClassFromString(@"RCTTextView")]; |
655 | | - } |
656 | | - [PrivateSentrySDKOnly addReplayRedactClasses: classesToRedact]; |
| 640 | +#else |
| 641 | + return nil; |
| 642 | +#endif |
657 | 643 | } |
658 | 644 |
|
659 | 645 | static NSString* const enabledProfilingMessage = @"Enable Hermes to use Sentry Profiling."; |
|
0 commit comments