Skip to content

Commit 466e905

Browse files
authored
ref: Convert SessionTracker to Swift (#6427)
1 parent 8800ba1 commit 466e905

12 files changed

+264
-306
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
0A9BF4EB28A127120068D266 /* SentryViewHierarchyIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9BF4EA28A127120068D266 /* SentryViewHierarchyIntegrationTests.swift */; };
5050
0A9E917128DC7E7000FB4182 /* SentryInternalCDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A9E917028DC7E7000FB4182 /* SentryInternalCDefines.h */; };
5151
0ADC33F128D9BE940078D980 /* TestSentryUIDeviceWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ADC33EF28D9BE690078D980 /* TestSentryUIDeviceWrapper.swift */; };
52-
15360CCF2432777500112302 /* SentrySessionTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 15360CCE2432777400112302 /* SentrySessionTracker.m */; };
53-
15360CD2243277A000112302 /* SentrySessionTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 15360CD12432779F00112302 /* SentrySessionTracker.h */; };
5452
15360CD62432832400112302 /* SentryAutoSessionTrackingIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 15360CD52432832400112302 /* SentryAutoSessionTrackingIntegration.m */; };
5553
15360CD92432835400112302 /* SentryAutoSessionTrackingIntegration.h in Headers */ = {isa = PBXBuildFile; fileRef = 15360CD82432835400112302 /* SentryAutoSessionTrackingIntegration.h */; settings = {ATTRIBUTES = (Private, ); }; };
5654
15360CED2433A15500112302 /* SentryInstallation.m in Sources */ = {isa = PBXBuildFile; fileRef = 15360CEC2433A15500112302 /* SentryInstallation.m */; };
@@ -1114,6 +1112,7 @@
11141112
FAAB2EE02E4BE97500FE8B7E /* TestSentryNSApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB2EDF2E4BE96F00FE8B7E /* TestSentryNSApplication.swift */; };
11151113
FAAB2F972E4D345800FE8B7E /* SentryUIDeviceWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB2F962E4D344F00FE8B7E /* SentryUIDeviceWrapper.swift */; };
11161114
FAAB30F32E4E8F2C00FE8B7E /* SentryInAppLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB30F22E4E8F2C00FE8B7E /* SentryInAppLogic.swift */; };
1115+
FAB007432E9F47E8001C806A /* SessionTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAB007422E9F47E4001C806A /* SessionTracker.swift */; };
11171116
FAB007362E9EF8D3001C806A /* SentryUIViewControllerPerformanceTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAB007302E9EF8CB001C806A /* SentryUIViewControllerPerformanceTracker.swift */; };
11181117
FAB007522E9FE2FF001C806A /* SentrySwizzleWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAB0074C2E9FE2FA001C806A /* SentrySwizzleWrapper.swift */; };
11191118
FAB359982E05D7E90083D5E3 /* SentryEventSwiftHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = FAB359972E05D7E90083D5E3 /* SentryEventSwiftHelper.h */; };
@@ -1304,8 +1303,6 @@
13041303
0A9BF4EA28A127120068D266 /* SentryViewHierarchyIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryViewHierarchyIntegrationTests.swift; sourceTree = "<group>"; };
13051304
0A9E917028DC7E7000FB4182 /* SentryInternalCDefines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryInternalCDefines.h; path = include/SentryInternalCDefines.h; sourceTree = "<group>"; };
13061305
0ADC33EF28D9BE690078D980 /* TestSentryUIDeviceWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryUIDeviceWrapper.swift; sourceTree = "<group>"; };
1307-
15360CCE2432777400112302 /* SentrySessionTracker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySessionTracker.m; sourceTree = "<group>"; };
1308-
15360CD12432779F00112302 /* SentrySessionTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentrySessionTracker.h; path = include/SentrySessionTracker.h; sourceTree = "<group>"; };
13091306
15360CD52432832400112302 /* SentryAutoSessionTrackingIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryAutoSessionTrackingIntegration.m; sourceTree = "<group>"; };
13101307
15360CD82432835400112302 /* SentryAutoSessionTrackingIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryAutoSessionTrackingIntegration.h; path = include/SentryAutoSessionTrackingIntegration.h; sourceTree = "<group>"; };
13111308
15360CEC2433A15500112302 /* SentryInstallation.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryInstallation.m; sourceTree = "<group>"; };
@@ -2478,6 +2475,7 @@
24782475
FAAB2EDF2E4BE96F00FE8B7E /* TestSentryNSApplication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryNSApplication.swift; sourceTree = "<group>"; };
24792476
FAAB2F962E4D344F00FE8B7E /* SentryUIDeviceWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIDeviceWrapper.swift; sourceTree = "<group>"; };
24802477
FAAB30F22E4E8F2C00FE8B7E /* SentryInAppLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryInAppLogic.swift; sourceTree = "<group>"; };
2478+
FAB007422E9F47E4001C806A /* SessionTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionTracker.swift; sourceTree = "<group>"; };
24812479
FAB007302E9EF8CB001C806A /* SentryUIViewControllerPerformanceTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIViewControllerPerformanceTracker.swift; sourceTree = "<group>"; };
24822480
FAB0074C2E9FE2FA001C806A /* SentrySwizzleWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySwizzleWrapper.swift; sourceTree = "<group>"; };
24832481
FAB359972E05D7E90083D5E3 /* SentryEventSwiftHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryEventSwiftHelper.h; path = include/SentryEventSwiftHelper.h; sourceTree = "<group>"; };
@@ -3688,8 +3686,6 @@
36883686
15360CD52432832400112302 /* SentryAutoSessionTrackingIntegration.m */,
36893687
7B4E23BD251A2BD500060D68 /* SentryCrashIntegrationSessionHandler.h */,
36903688
7B4E23C1251A2C2B00060D68 /* SentryCrashIntegrationSessionHandler.m */,
3691-
15360CD12432779F00112302 /* SentrySessionTracker.h */,
3692-
15360CCE2432777400112302 /* SentrySessionTracker.m */,
36933689
);
36943690
name = Session;
36953691
sourceTree = "<group>";
@@ -4753,6 +4749,7 @@
47534749
D8CAC02D2BA0663E00E38F34 /* Integrations */ = {
47544750
isa = PBXGroup;
47554751
children = (
4752+
FAB0073C2E9F47DE001C806A /* Session */,
47564753
FAE579B42E7DBE9400B710F9 /* SentryGlobalEventProcessor.swift */,
47574754
D49064862DFAE1B700555785 /* Screenshot */,
47584755
D8739CF72BECFF92007D2F66 /* Performance */,
@@ -4972,6 +4969,14 @@
49724969
path = Core;
49734970
sourceTree = "<group>";
49744971
};
4972+
FAB0073C2E9F47DE001C806A /* Session */ = {
4973+
isa = PBXGroup;
4974+
children = (
4975+
FAB007422E9F47E4001C806A /* SessionTracker.swift */,
4976+
);
4977+
path = Session;
4978+
sourceTree = "<group>";
4979+
};
49754980
FABB48B22E59310D0071397E /* Transaction */ = {
49764981
isa = PBXGroup;
49774982
children = (
@@ -5150,7 +5155,6 @@
51505155
63FE715720DA4C1100CDBAE8 /* SentryCrashThread.h in Headers */,
51515156
62E59A532E8FB70000DB7A7B /* SentryTracePropagation.h in Headers */,
51525157
7BF9EF862722D10600B5BBEF /* SentryTestObjCRuntimeWrapper.h in Headers */,
5153-
15360CD2243277A000112302 /* SentrySessionTracker.h in Headers */,
51545158
63FE718B20DA4C1100CDBAE8 /* SentryCrashReport.h in Headers */,
51555159
7D0FCFB22379B915004DD83A /* SentryHub.h in Headers */,
51565160
92F6726B29C8B7B100BFD34D /* SentryUser+Private.h in Headers */,
@@ -5683,6 +5687,7 @@
56835687
7B7D873624864C9D00D2ECFF /* SentryCrashDefaultMachineContextWrapper.m in Sources */,
56845688
63FE712F20DA4C1100CDBAE8 /* SentryCrashSysCtl.c in Sources */,
56855689
62212B872D520CB00062C2FA /* SentryEventCodable.swift in Sources */,
5690+
FAB007432E9F47E8001C806A /* SessionTracker.swift in Sources */,
56865691
7B3B473825D6CC7E00D01640 /* SentryNSError.m in Sources */,
56875692
621AE74D2C626C510012E730 /* SentryANRTrackerV2.m in Sources */,
56885693
84CFA4CA2C9DF884008DA5F4 /* SentryUserFeedbackWidget.swift in Sources */,
@@ -5910,7 +5915,6 @@
59105915
7B127B0F27CF6F4700A71ED2 /* SentryANRTrackingIntegration.m in Sources */,
59115916
62C316832B1F2EA1000D7031 /* SentryDelayedFramesTracker.m in Sources */,
59125917
D8BFE37329A3782F002E73F3 /* SentryTimeToDisplayTracker.m in Sources */,
5913-
15360CCF2432777500112302 /* SentrySessionTracker.m in Sources */,
59145918
6334314320AD9AE40077E581 /* SentryMechanism.m in Sources */,
59155919
849B8F9C2C6E906900148E1F /* SentryUserFeedbackThemeConfiguration.swift in Sources */,
59165920
F452437E2DE60B71003E8F50 /* SentryUseNSExceptionCallstackWrapper.m in Sources */,

Sources/Sentry/Public/SentryClient.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
@class SentryEvent;
1010
@class SentryFeedback;
11-
@class SentryFileManager;
1211
@class SentryId;
1312
@class SentryOptions;
1413
@class SentryScope;

Sources/Sentry/SentryAutoSessionTrackingIntegration.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#import "SentryLogC.h"
44
#import "SentryOptions.h"
55
#import "SentrySDKInternal.h"
6-
#import "SentrySessionTracker.h"
6+
#import "SentrySwift.h"
77

88
NS_ASSUME_NONNULL_BEGIN
99

Sources/Sentry/SentryDependencyContainer.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#import "SentryLogC.h"
88
#import "SentryOptions+Private.h"
99
#import "SentrySDK+Private.h"
10-
#import "SentrySessionTracker.h"
1110
#import "SentrySwift.h"
1211
#import "SentrySystemWrapper.h"
1312
#import <SentryCrash.h>

Sources/Sentry/SentryDependencyContainerSwiftHelper.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#import "SentryDependencyContainerSwiftHelper.h"
2+
#import "SentryClient+Private.h"
23
#import "SentryDependencyContainer.h"
4+
#import "SentryHub+Private.h"
5+
#import "SentryOptions+Private.h"
36
#import "SentrySDK+Private.h"
47
#import "SentrySwift.h"
58

@@ -34,4 +37,29 @@ + (SentryCrash *)crashReporter
3437
return SentryDependencyContainer.sharedInstance.crashReporter;
3538
}
3639

40+
+ (nullable NSDate *)readTimestampLastInForeground
41+
{
42+
SentryHub *hub = [SentrySDKInternal currentHub];
43+
return [[[hub getClient] fileManager] readTimestampLastInForeground];
44+
}
45+
46+
+ (void)deleteTimestampLastInForeground
47+
{
48+
SentryHub *hub = [SentrySDKInternal currentHub];
49+
[[[hub getClient] fileManager] deleteTimestampLastInForeground];
50+
}
51+
52+
+ (void)storeTimestampLastInForeground:(NSDate *)timestamp
53+
{
54+
SentryHub *hub = [SentrySDKInternal currentHub];
55+
[[[hub getClient] fileManager] storeTimestampLastInForeground:timestamp];
56+
}
57+
58+
#if SENTRY_TARGET_PROFILING_SUPPORTED
59+
+ (BOOL)hasProfilingOptions
60+
{
61+
return SentrySDKInternal.currentHub.client.options.profiling != nil;
62+
}
63+
#endif
64+
3765
@end

0 commit comments

Comments
 (0)