@@ -53,7 +53,6 @@ - (void)newSceneActivate;
5353@implementation SentrySessionReplayIntegration {
5454 BOOL _startedAsFullSession;
5555 SentryReplayOptions *_replayOptions;
56- SentryExperimentalOptions *_experimentalOptions;
5756 id <SentryNSNotificationCenterWrapper> _notificationCenter;
5857 id <SentryRateLimits> _rateLimits;
5958 id <SentryViewScreenshotProvider> _currentScreenshotProvider;
@@ -65,7 +64,14 @@ @implementation SentrySessionReplayIntegration {
6564 // replay absolutely needs segment 0 to make replay work.
6665 BOOL _rateLimited;
6766 id <SentryCurrentDateProvider> _dateProvider;
68- id <SentrySessionReplayEnvironmentCheckerProvider> _environmentChecker;
67+ }
68+
69+ + (BOOL )shouldEnableForOptions : (SentryOptions *)options
70+ {
71+ return [SentrySessionReplay
72+ shouldEnableSessionReplayWithEnvironmentChecker: SentryDependencyContainer.sharedInstance
73+ .sessionReplayEnvironmentChecker
74+ experimentalOptions: options.experimental];
6975}
7076
7177- (instancetype )init
@@ -78,39 +84,34 @@ - (instancetype)initForManualUse:(nonnull SentryOptions *)options
7884{
7985 if (self = [super init ]) {
8086 [self setupWith: options.sessionReplay
81- experimentalOptions: options.experimental
8287 enableTouchTracker: options.enableSwizzling
8388 enableViewRendererV2: options.sessionReplay.enableViewRendererV2
8489 enableFastViewRendering: options.sessionReplay.enableFastViewRendering];
85- [self startWithOptions: options.sessionReplay
86- experimentalOptions: options.experimental
87- fullSession: YES ];
90+ [self startWithOptions: options.sessionReplay fullSession: YES ];
8891 }
8992 return self;
9093}
9194
9295- (BOOL )installWithOptions : (nonnull SentryOptions *)options
9396{
94- if ([super installWithOptions: options] == NO ) {
97+ if ([super installWithOptions: options] == NO ||
98+ [SentrySessionReplayIntegration shouldEnableForOptions: options] == NO ) {
9599 return NO ;
96100 }
97101
98102 [self setupWith: options.sessionReplay
99- experimentalOptions: options.experimental
100103 enableTouchTracker: options.enableSwizzling
101104 enableViewRendererV2: options.sessionReplay.enableViewRendererV2
102105 enableFastViewRendering: options.sessionReplay.enableFastViewRendering];
103106 return YES ;
104107}
105108
106109- (void )setupWith : (SentryReplayOptions *)replayOptions
107- experimentalOptions : (SentryExperimentalOptions *)experimentalOptions
108110 enableTouchTracker : (BOOL )touchTracker
109111 enableViewRendererV2 : (BOOL )enableViewRendererV2
110112 enableFastViewRendering : (BOOL )enableFastViewRendering
111113{
112114 _replayOptions = replayOptions;
113- _experimentalOptions = experimentalOptions;
114115 _rateLimits = SentryDependencyContainer.sharedInstance .rateLimits ;
115116 _dateProvider = SentryDependencyContainer.sharedInstance .dateProvider ;
116117
@@ -141,7 +142,6 @@ - (void)setupWith:(SentryReplayOptions *)replayOptions
141142
142143 _notificationCenter = SentryDependencyContainer.sharedInstance .notificationCenterWrapper ;
143144 _dateProvider = SentryDependencyContainer.sharedInstance .dateProvider ;
144- _environmentChecker = SentryDependencyContainer.sharedInstance .sessionReplayEnvironmentChecker ;
145145
146146 // We use the dispatch queue provider as a factory to create the queues, but store the queues
147147 // directly in this instance, so they get deallocated when the integration is deallocated.
@@ -354,9 +354,7 @@ - (void)runReplayForAvailableWindow
354354 if ([SentryDependencyContainer.sharedInstance.application getWindows ].count > 0 ) {
355355 SENTRY_LOG_DEBUG (@" [Session Replay] Running replay for available window" );
356356 // If a window its already available start replay right away
357- [self startWithOptions: _replayOptions
358- experimentalOptions: _experimentalOptions
359- fullSession: _startedAsFullSession];
357+ [self startWithOptions: _replayOptions fullSession: _startedAsFullSession];
360358 } else if (@available (iOS 13.0 , tvOS 13.0 , *)) {
361359 SENTRY_LOG_DEBUG (
362360 @" [Session Replay] Waiting for a scene to be available to started the replay" );
@@ -376,27 +374,22 @@ - (void)newSceneActivate
376374 removeObserver: self
377375 name: UISceneDidActivateNotification
378376 object: nil ];
379- [self startWithOptions: _replayOptions
380- experimentalOptions: _experimentalOptions
381- fullSession: _startedAsFullSession];
377+ [self startWithOptions: _replayOptions fullSession: _startedAsFullSession];
382378 }
383379}
384380
385381- (void )startWithOptions : (SentryReplayOptions *)replayOptions
386- experimentalOptions : (SentryExperimentalOptions *)experimentalOptions
387382 fullSession : (BOOL )shouldReplayFullSession
388383{
389384 SENTRY_LOG_DEBUG (@" [Session Replay] Starting session" );
390385 [self startWithOptions: replayOptions
391- experimentalOptions: experimentalOptions
392386 screenshotProvider: _currentScreenshotProvider ?: _viewPhotographer
393387 breadcrumbConverter: _currentBreadcrumbConverter
394388 ?: [[SentrySRDefaultBreadcrumbConverter alloc ] init ]
395389 fullSession: shouldReplayFullSession];
396390}
397391
398392- (void )startWithOptions : (SentryReplayOptions *)replayOptions
399- experimentalOptions : (SentryExperimentalOptions *)experimentalOptions
400393 screenshotProvider : (id <SentryViewScreenshotProvider>)screenshotProvider
401394 breadcrumbConverter : (id <SentryReplayBreadcrumbConverter>)breadcrumbConverter
402395 fullSession : (BOOL )shouldReplayFullSession
@@ -431,16 +424,14 @@ - (void)startWithOptions:(SentryReplayOptions *)replayOptions
431424
432425 SentryDisplayLinkWrapper *displayLinkWrapper = [[SentryDisplayLinkWrapper alloc ] init ];
433426 self.sessionReplay = [[SentrySessionReplay alloc ] initWithReplayOptions: replayOptions
434- experimentalOptions: experimentalOptions
435427 replayFolderPath: docs
436428 screenshotProvider: screenshotProvider
437429 replayMaker: replayMaker
438430 breadcrumbConverter: breadcrumbConverter
439431 touchTracker: _touchTracker
440432 dateProvider: _dateProvider
441433 delegate: self
442- displayLinkWrapper: displayLinkWrapper
443- environmentChecker: _environmentChecker];
434+ displayLinkWrapper: displayLinkWrapper];
444435
445436 [self .sessionReplay
446437 startWithRootView: [SentryDependencyContainer.sharedInstance.application getWindows ]
@@ -472,15 +463,19 @@ - (nullable NSURL *)replayDirectory
472463 return [dir URLByAppendingPathComponent: SENTRY_REPLAY_FOLDER];
473464}
474465
475- - (void )saveCurrentSessionInfo : (SentryId *)sessionId
466+ - (void )saveCurrentSessionInfo : (SentryId *_Nullable )sessionId
476467 path : (NSString *)path
477468 options : (SentryReplayOptions *)options
478469{
479470 SENTRY_LOG_DEBUG (@" [Session Replay] Saving current session info for session: %@ to path: %@ " ,
480471 sessionId, path);
481- NSDictionary *info =
482- [[NSDictionary alloc ] initWithObjectsAndKeys: sessionId.sentryIdString, @" replayId" ,
483- path.lastPathComponent, @" path" , @(options.onErrorSampleRate), @" errorSampleRate" , nil ];
472+ NSMutableDictionary *info = [NSMutableDictionary new ];
473+ if (sessionId != nil ) {
474+ [info setObject: SENTRY_UNWRAP_NULLABLE (SentryId, sessionId).sentryIdString
475+ forKey: @" replayId" ];
476+ }
477+ [info setObject: path.lastPathComponent forKey: @" path" ];
478+ [info setObject: @(options.onErrorSampleRate) forKey: @" errorSampleRate" ];
484479
485480 NSData *data = [SentrySerializationSwift dataWithJSONObject: info];
486481
0 commit comments