Skip to content

Commit ecf1c33

Browse files
authored
Merge e69797c into 5eaadc5
2 parents 5eaadc5 + e69797c commit ecf1c33

File tree

11 files changed

+76
-16
lines changed

11 files changed

+76
-16
lines changed

Samples/iOS-ObjectiveC/iOS-ObjectiveC/AppDelegate.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#import "AppDelegate.h"
22
@import CoreData;
33
@import Sentry;
4-
54
@interface
65
AppDelegate ()
76

Sentry.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,6 @@
883883
D8AFC03D2BDA79BF00118BE1 /* SentryReplayVideoMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AFC03C2BDA79BF00118BE1 /* SentryReplayVideoMaker.swift */; };
884884
D8AFC0572BDA895400118BE1 /* UIRedactBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AFC0562BDA895400118BE1 /* UIRedactBuilder.swift */; };
885885
D8AFC05A2BDA89C100118BE1 /* RedactRegionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AFC0582BDA899A00118BE1 /* RedactRegionTests.swift */; };
886-
D8AFC0622BDBEE4200118BE1 /* SentrySessionReplayIntegration+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D8AFC0612BDBEDF100118BE1 /* SentrySessionReplayIntegration+Private.h */; };
887886
D8B0542E2A7D2C720056BAF6 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = D8B0542D2A7D2C720056BAF6 /* PrivacyInfo.xcprivacy */; };
888887
D8B088B629C9E3FF00213258 /* SentryTracerConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = D8B088B429C9E3FF00213258 /* SentryTracerConfiguration.h */; };
889888
D8B088B729C9E3FF00213258 /* SentryTracerConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = D8B088B529C9E3FF00213258 /* SentryTracerConfiguration.m */; };
@@ -1839,6 +1838,7 @@
18391838
D801990F286B089000C277F0 /* SentryCrashReportSinkTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashReportSinkTests.swift; sourceTree = "<group>"; };
18401839
D802994D2BA836EF000F0081 /* SentryOnDemandReplay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryOnDemandReplay.swift; sourceTree = "<group>"; };
18411840
D802994F2BA83A88000F0081 /* SentryPixelBuffer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryPixelBuffer.swift; sourceTree = "<group>"; };
1841+
D80382BE2C09C6FD0090E048 /* SentrySessionReplayIntegration-Hybrid.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentrySessionReplayIntegration-Hybrid.h"; path = "include/HybridPublic/SentrySessionReplayIntegration-Hybrid.h"; sourceTree = "<group>"; };
18421842
D80694C22B7CC86E00B820E6 /* SentryReplayEventTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryReplayEventTests.swift; sourceTree = "<group>"; };
18431843
D80694C52B7CCFA100B820E6 /* SentryReplayRecordingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryReplayRecordingTests.swift; sourceTree = "<group>"; };
18441844
D80694CB2B7E0A3E00B820E6 /* SentryReplayType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryReplayType.h; path = include/SentryReplayType.h; sourceTree = "<group>"; };
@@ -3625,6 +3625,7 @@
36253625
D820CDB52BB1895F00BA339D /* SentrySessionReplayIntegration.h */,
36263626
D8AFC0612BDBEDF100118BE1 /* SentrySessionReplayIntegration+Private.h */,
36273627
D820CDB62BB1895F00BA339D /* SentrySessionReplayIntegration.m */,
3628+
D80382BE2C09C6FD0090E048 /* SentrySessionReplayIntegration-Hybrid.h */,
36283629
);
36293630
name = SessionReplay;
36303631
sourceTree = "<group>";
@@ -4067,7 +4068,6 @@
40674068
6383953623ABA42C000C1594 /* SentryHttpTransport.h in Headers */,
40684069
84A8891C28DBD28900C51DFD /* SentryDevice.h in Headers */,
40694070
8E564AEF267AF24400FE117D /* SentryNetworkTracker.h in Headers */,
4070-
D8AFC0622BDBEE4200118BE1 /* SentrySessionReplayIntegration+Private.h in Headers */,
40714071
63FE715120DA4C1100CDBAE8 /* SentryCrashDebug.h in Headers */,
40724072
63FE70F520DA4C1000CDBAE8 /* SentryCrashMonitor_System.h in Headers */,
40734073
7B31C291277B04A000337126 /* SentryCrashPlatformSpecificDefines.h in Headers */,

Sources/Sentry/PrivateSentrySDKOnly.mm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "SentryOptions.h"
1212
#import "SentrySDK+Private.h"
1313
#import "SentrySerialization.h"
14+
#import "SentrySessionReplayIntegration.h"
1415
#import "SentrySwift.h"
1516
#import "SentryThreadHandle.hpp"
1617
#import "SentryUser+Private.h"
@@ -306,4 +307,16 @@ + (void)addReplayRedactClasses:(NSArray<Class> *_Nonnull)classes
306307
#endif
307308
}
308309

310+
+ (SentrySessionReplayIntegration *)createReplayIntegration
311+
{
312+
#if SENTRY_HAS_UIKIT && !TARGET_OS_VISION
313+
return [[SentrySessionReplayIntegration alloc] init];
314+
#else
315+
SENTRY_LOG_DEBUG(
316+
@"PrivateSentrySDKOnly.captureViewHierarchy only works with UIKit enabled. Ensure you're "
317+
@"using the right configuration of Sentry that links UIKit.");
318+
return nil;
319+
#endif // SENTRY_HAS_UIKIT
320+
}
321+
309322
@end

Sources/Sentry/SentrySessionReplay.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ @implementation SentrySessionReplay {
4343
int _currentSegmentId;
4444
BOOL _processingScreenshot;
4545
BOOL _reachedMaximumDuration;
46-
SentryReplayBreadcrumbConverter *_breadcrumbConverter;
46+
id<SentryReplayBreadcrumbConverter> _breadcrumbConverter;
4747
}
4848

4949
- (instancetype)initWithSettings:(SentryReplayOptions *)replayOptions
5050
replayFolderPath:(NSURL *)folderPath
5151
screenshotProvider:(id<SentryViewScreenshotProvider>)screenshotProvider
5252
replayMaker:(id<SentryReplayVideoMaker>)replayMaker
53+
breadcrumbConverter:(id<SentryReplayBreadcrumbConverter>)breadcrumbConverter
5354
dateProvider:(SentryCurrentDateProvider *)dateProvider
5455
random:(id<SentryRandom>)random
5556
displayLinkWrapper:(SentryDisplayLinkWrapper *)displayLinkWrapper;
@@ -64,7 +65,7 @@ - (instancetype)initWithSettings:(SentryReplayOptions *)replayOptions
6465
_urlToCache = folderPath;
6566
_replayMaker = replayMaker;
6667
_reachedMaximumDuration = NO;
67-
_breadcrumbConverter = [[SentryReplayBreadcrumbConverter alloc] init];
68+
_breadcrumbConverter = breadcrumbConverter;
6869
}
6970
return self;
7071
}

Sources/Sentry/SentrySessionReplayIntegration.m

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ - (void)newSceneActivate
7373

7474
- (void)startWithOptions:(SentryReplayOptions *)replayOptions
7575
fullSession:(BOOL)shouldReplayFullSession
76+
{
77+
[self startWithOptions:replayOptions
78+
screenshotProvider:SentryViewPhotographer.shared
79+
breadcrumbConverter:[[SentryReplayBreadcrumbConverter alloc] init]
80+
fullSession:shouldReplayFullSession];
81+
}
82+
83+
- (void)startWithOptions:(SentryReplayOptions *)replayOptions
84+
screenshotProvider:(id<SentryViewScreenshotProvider>)screenshotProvider
85+
breadcrumbConverter:(id<SentryReplayBreadcrumbConverter>)breadcrumbConverter
86+
fullSession:(BOOL)shouldReplayFullSession
7687
{
7788
if (@available(iOS 16.0, tvOS 16.0, *)) {
7889
NSURL *docs = [NSURL
@@ -96,14 +107,14 @@ - (void)startWithOptions:(SentryReplayOptions *)replayOptions
96107
: replayOptions.errorReplayDuration);
97108

98109
self.sessionReplay = [[SentrySessionReplay alloc]
99-
initWithSettings:replayOptions
100-
replayFolderPath:docs
101-
screenshotProvider:SentryViewPhotographer.shared
102-
replayMaker:replayMaker
103-
dateProvider:SentryDependencyContainer.sharedInstance.dateProvider
104-
random:SentryDependencyContainer.sharedInstance.random
105-
106-
displayLinkWrapper:[[SentryDisplayLinkWrapper alloc] init]];
110+
initWithSettings:replayOptions
111+
replayFolderPath:docs
112+
screenshotProvider:screenshotProvider
113+
replayMaker:replayMaker
114+
breadcrumbConverter:breadcrumbConverter
115+
dateProvider:SentryDependencyContainer.sharedInstance.dateProvider
116+
random:SentryDependencyContainer.sharedInstance.random
117+
displayLinkWrapper:[[SentryDisplayLinkWrapper alloc] init]];
107118

108119
[self.sessionReplay
109120
start:SentryDependencyContainer.sharedInstance.application.windows.firstObject

Sources/Sentry/include/HybridPublic/PrivateSentrySDKOnly.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@class SentryUser;
1010
@class SentryEnvelope;
1111
@class SentryId;
12+
@class SentrySessionReplayIntegration;
1213

1314
NS_ASSUME_NONNULL_BEGIN
1415

@@ -156,8 +157,16 @@ typedef void (^SentryOnAppStartMeasurementAvailable)(
156157
* configurations even when targeting iOS or tvOS platforms.
157158
*/
158159
+ (NSData *)captureViewHierarchy;
160+
159161
#endif // SENTRY_UIKIT_AVAILABLE
160162

163+
#if SENTRY_HAS_UIKIT && !TARGET_OS_VISION
164+
/**
165+
* This is how hybrid SDKs can control session replay.
166+
*/
167+
+ (nullable SentrySessionReplayIntegration *)createReplayIntegration;
168+
#endif
169+
161170
+ (SentryUser *)userWithDictionary:(NSDictionary *)dictionary;
162171

163172
+ (SentryBreadcrumb *)breadcrumbWithDictionary:(NSDictionary *)dictionary;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#import <Foundation/Foundation.h>
2+
#import <Sentry/SentryDefines.h>
3+
4+
#if SENTRY_UIKIT_AVAILABLE
5+
@class SentryReplayOptions;
6+
7+
@protocol SentryViewScreenshotProvider;
8+
@protocol SentryReplayBreadcrumbConverter;
9+
10+
@interface SentrySessionReplayIntegration : NSObject
11+
12+
- (void)startWithOptions:(SentryReplayOptions *)replayOptions
13+
screenshotProvider:(id<SentryViewScreenshotProvider>)screenshotProvider
14+
breadcrumbConverter:(id<SentryReplayBreadcrumbConverter>)breadcrumbConverter
15+
fullSession:(BOOL)shouldReplayFullSession;
16+
17+
@end
18+
#endif

Sources/Sentry/include/SentrySessionReplay.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
@protocol SentryRedactOptions;
1616
@protocol SentryViewScreenshotProvider;
1717
@protocol SentryReplayVideoMaker;
18+
@protocol SentryReplayBreadcrumbConverter;
1819

1920
NS_ASSUME_NONNULL_BEGIN
2021

@@ -26,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
2627
replayFolderPath:(NSURL *)folderPath
2728
screenshotProvider:(id<SentryViewScreenshotProvider>)photographer
2829
replayMaker:(id<SentryReplayVideoMaker>)replayMaker
30+
breadcrumbConverter:(id<SentryReplayBreadcrumbConverter>)breadcrumbConverter
2931
dateProvider:(SentryCurrentDateProvider *)dateProvider
3032
random:(id<SentryRandom>)random
3133
displayLinkWrapper:(SentryDisplayLinkWrapper *)displayLinkWrapper;

Sources/Swift/Helper/SentryCurrentDateProvider.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
@_implementationOnly import _SentryPrivate
22

3-
@objcMembers class SentryCurrentDateProvider: NSObject {
4-
3+
@objcMembers
4+
class SentryCurrentDateProvider: NSObject {
5+
56
func date() -> Date {
67
return Date()
78
}

Sources/Swift/Integrations/SessionReplay/SentryReplayBreadcrumbConverter.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
@_implementationOnly import _SentryPrivate
22
import Foundation
33

4+
@objc(SentryReplayBreadcrumbConverter)
5+
protocol SentryReplayBreadcrumbConverterProtocol: NSObjectProtocol {
6+
func convert(breadcrumbs: [Breadcrumb], from: Date, until: Date) -> [SentryRRWebEvent]
7+
}
8+
49
@objcMembers
5-
class SentryReplayBreadcrumbConverter: NSObject {
10+
class SentryReplayBreadcrumbConverter: NSObject, SentryReplayBreadcrumbConverterProtocol {
611

712
private let supportedNetworkData = Set<String>([
813
"status_code",

0 commit comments

Comments
 (0)