Skip to content

Commit 879fb28

Browse files
authored
ref: move SentryDateProvider to SentryDependencyContainer (#3163)
and remove the dedicated static interface that used to deliver it
1 parent 4946815 commit 879fb28

File tree

92 files changed

+338
-480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+338
-480
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,7 @@
542542
7BE1E33224F7E3B6009D3AD0 /* SentryMigrateSessionInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BE1E33124F7E3B6009D3AD0 /* SentryMigrateSessionInit.h */; };
543543
7BE1E33424F7E3CB009D3AD0 /* SentryMigrateSessionInit.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BE1E33324F7E3CB009D3AD0 /* SentryMigrateSessionInit.m */; };
544544
7BE2C7F8257000A4003B66C7 /* SentryTestIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BE2C7F72570009F003B66C7 /* SentryTestIntegration.m */; };
545-
7BE3C7672445C0CA00A38442 /* SentryCurrentDate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BE3C7662445C0CA00A38442 /* SentryCurrentDate.h */; };
546-
7BE3C7692445C1A800A38442 /* SentryCurrentDate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BE3C7682445C1A800A38442 /* SentryCurrentDate.m */; };
547545
7BE3C76B2445C27A00A38442 /* SentryCurrentDateProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BE3C76A2445C27A00A38442 /* SentryCurrentDateProvider.h */; };
548-
7BE3C76F2445C2F800A38442 /* SentryDefaultCurrentDateProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BE3C76E2445C2F800A38442 /* SentryDefaultCurrentDateProvider.h */; };
549-
7BE3C7712445C30D00A38442 /* SentryDefaultCurrentDateProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BE3C7702445C30D00A38442 /* SentryDefaultCurrentDateProvider.m */; };
550546
7BE3C7752445C82300A38442 /* SentryCurrentDateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BE3C7742445C82300A38442 /* SentryCurrentDateTests.swift */; };
551547
7BE3C77B2446111500A38442 /* SentryRateLimitParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BE3C77A2446111500A38442 /* SentryRateLimitParser.h */; };
552548
7BE3C77D2446112C00A38442 /* SentryRateLimitParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BE3C77C2446112C00A38442 /* SentryRateLimitParser.m */; };
@@ -668,6 +664,7 @@
668664
84B7FA4429B2924000AD93B1 /* TestRandom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E25C97425F8511A00DC215B /* TestRandom.swift */; };
669665
84B7FA4529B2926900AD93B1 /* TestDisplayLinkWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B30B68126527C55006B2752 /* TestDisplayLinkWrapper.swift */; };
670666
84B7FA4629B2935F00AD93B1 /* ClearTestState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BD47B4C268F0B080076A663 /* ClearTestState.swift */; };
667+
84F993C42A62A74000EC0190 /* SentryCurrentDateProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 84F993C32A62A74000EC0190 /* SentryCurrentDateProvider.m */; };
671668
861265F92404EC1500C4AFDE /* NSArray+SentrySanitize.h in Headers */ = {isa = PBXBuildFile; fileRef = 861265F72404EC1500C4AFDE /* NSArray+SentrySanitize.h */; };
672669
861265FA2404EC1500C4AFDE /* NSArray+SentrySanitize.m in Sources */ = {isa = PBXBuildFile; fileRef = 861265F82404EC1500C4AFDE /* NSArray+SentrySanitize.m */; };
673670
8E0551E026A7A63C00400526 /* TestProtocolClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E0551DF26A7A63C00400526 /* TestProtocolClient.swift */; };
@@ -1460,11 +1457,7 @@
14601457
7BE1E33324F7E3CB009D3AD0 /* SentryMigrateSessionInit.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryMigrateSessionInit.m; sourceTree = "<group>"; };
14611458
7BE2C7F625700093003B66C7 /* SentryTestIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryTestIntegration.h; sourceTree = "<group>"; };
14621459
7BE2C7F72570009F003B66C7 /* SentryTestIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryTestIntegration.m; sourceTree = "<group>"; };
1463-
7BE3C7662445C0CA00A38442 /* SentryCurrentDate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryCurrentDate.h; path = include/SentryCurrentDate.h; sourceTree = "<group>"; };
1464-
7BE3C7682445C1A800A38442 /* SentryCurrentDate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCurrentDate.m; sourceTree = "<group>"; };
14651460
7BE3C76A2445C27A00A38442 /* SentryCurrentDateProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryCurrentDateProvider.h; path = include/SentryCurrentDateProvider.h; sourceTree = "<group>"; };
1466-
7BE3C76E2445C2F800A38442 /* SentryDefaultCurrentDateProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDefaultCurrentDateProvider.h; path = include/SentryDefaultCurrentDateProvider.h; sourceTree = "<group>"; };
1467-
7BE3C7702445C30D00A38442 /* SentryDefaultCurrentDateProvider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDefaultCurrentDateProvider.m; sourceTree = "<group>"; };
14681461
7BE3C7742445C82300A38442 /* SentryCurrentDateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCurrentDateTests.swift; sourceTree = "<group>"; };
14691462
7BE3C7762445E50A00A38442 /* TestCurrentDateProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestCurrentDateProvider.swift; sourceTree = "<group>"; };
14701463
7BE3C77A2446111500A38442 /* SentryRateLimitParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryRateLimitParser.h; path = include/SentryRateLimitParser.h; sourceTree = "<group>"; };
@@ -1603,6 +1596,7 @@
16031596
84B7FA4729B2995A00AD93B1 /* DeploymentTargets.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DeploymentTargets.xcconfig; sourceTree = "<group>"; };
16041597
84C47B2B2A09239100DAEB8A /* .codecov.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .codecov.yml; sourceTree = "<group>"; };
16051598
84E4F5692914F020004C7358 /* Brewfile */ = {isa = PBXFileReference; indentWidth = 2; lastKnownFileType = text; path = Brewfile; sourceTree = "<group>"; tabWidth = 2; };
1599+
84F993C32A62A74000EC0190 /* SentryCurrentDateProvider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCurrentDateProvider.m; sourceTree = "<group>"; };
16061600
861265F72404EC1500C4AFDE /* NSArray+SentrySanitize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "NSArray+SentrySanitize.h"; path = "include/NSArray+SentrySanitize.h"; sourceTree = "<group>"; };
16071601
861265F82404EC1500C4AFDE /* NSArray+SentrySanitize.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSArray+SentrySanitize.m"; sourceTree = "<group>"; };
16081602
8E0551DF26A7A63C00400526 /* TestProtocolClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestProtocolClient.swift; sourceTree = "<group>"; };
@@ -2161,11 +2155,8 @@
21612155
7BC63F0928081288009D9E37 /* SentrySwizzleWrapper.m */,
21622156
632F434E1F581D5400A18A36 /* SentryCrashExceptionApplication.h */,
21632157
632F434F1F581D5400A18A36 /* SentryCrashExceptionApplication.m */,
2164-
7BE3C7662445C0CA00A38442 /* SentryCurrentDate.h */,
2165-
7BE3C7682445C1A800A38442 /* SentryCurrentDate.m */,
21662158
7BE3C76A2445C27A00A38442 /* SentryCurrentDateProvider.h */,
2167-
7BE3C76E2445C2F800A38442 /* SentryDefaultCurrentDateProvider.h */,
2168-
7BE3C7702445C30D00A38442 /* SentryDefaultCurrentDateProvider.m */,
2159+
84F993C32A62A74000EC0190 /* SentryCurrentDateProvider.m */,
21692160
7BD729952463E83300EA3610 /* SentryDateUtil.h */,
21702161
7BD729972463E93500EA3610 /* SentryDateUtil.m */,
21712162
7B98D7E325FB7A7200C5A389 /* SentryAppState.h */,
@@ -3571,11 +3562,9 @@
35713562
8E564AEF267AF24400FE117D /* SentryNetworkTracker.h in Headers */,
35723563
63FE715120DA4C1100CDBAE8 /* SentryCrashDebug.h in Headers */,
35733564
63FE70F520DA4C1000CDBAE8 /* SentryCrashMonitor_System.h in Headers */,
3574-
7BE3C7672445C0CA00A38442 /* SentryCurrentDate.h in Headers */,
35753565
7B31C291277B04A000337126 /* SentryCrashPlatformSpecificDefines.h in Headers */,
35763566
7B77BE3527EC8445003C9020 /* SentryDiscardReasonMapper.h in Headers */,
35773567
7B610D602512390E00B0B5D9 /* SentrySDK+Private.h in Headers */,
3578-
7BE3C76F2445C2F800A38442 /* SentryDefaultCurrentDateProvider.h in Headers */,
35793568
03F84D2327DD414C008FE43F /* SentryThreadHandle.hpp in Headers */,
35803569
7B6C5EE0264E8E050010D138 /* SentryFramesTracker.h in Headers */,
35813570
63FE715720DA4C1100CDBAE8 /* SentryCrashThread.h in Headers */,
@@ -4017,7 +4006,6 @@
40174006
15360CD62432832400112302 /* SentryAutoSessionTrackingIntegration.m in Sources */,
40184007
7B63459F280EBA7200CFA05A /* SentryUIEventTracker.m in Sources */,
40194008
7BF9EF782722B35D00B5BBEF /* SentrySubClassFinder.m in Sources */,
4020-
7BE3C7692445C1A800A38442 /* SentryCurrentDate.m in Sources */,
40214009
7BCFA71627D0BB50008C662C /* SentryANRTracker.m in Sources */,
40224010
63EED6C02237923600E02400 /* SentryOptions.m in Sources */,
40234011
D8CB741B2947286500A5F964 /* SentryEnvelopeItemHeader.m in Sources */,
@@ -4122,7 +4110,6 @@
41224110
03F84D3227DD4191008FE43F /* SentryProfiler.mm in Sources */,
41234111
635B3F391EBC6E2500A6176D /* SentryAsynchronousOperation.m in Sources */,
41244112
63FE717520DA4C1100CDBAE8 /* SentryCrash.m in Sources */,
4125-
7BE3C7712445C30D00A38442 /* SentryDefaultCurrentDateProvider.m in Sources */,
41264113
6344DDB11EC308E400D9160D /* SentryCrashInstallationReporter.m in Sources */,
41274114
D85596F3280580F10041FF8B /* SentryScreenshotIntegration.m in Sources */,
41284115
7BAF3DCE243DCBFE008A5414 /* SentryTransportFactory.m in Sources */,
@@ -4181,6 +4168,7 @@
41814168
D8603DD6284F8497000E1227 /* SentryBaggage.m in Sources */,
41824169
63FE711520DA4C1000CDBAE8 /* SentryCrashJSONCodec.c in Sources */,
41834170
03F84D3327DD4191008FE43F /* SentryMachLogging.cpp in Sources */,
4171+
84F993C42A62A74000EC0190 /* SentryCurrentDateProvider.m in Sources */,
41844172
D85852BA27EDDC5900C6D8AE /* SentryUIApplication.m in Sources */,
41854173
7B4E375F258231FC00059C93 /* SentryAttachment.m in Sources */,
41864174
636085141ED47BE600E8599E /* SentryFileManager.m in Sources */,

SentryTestUtils/ClearTestState.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class TestCleanup: NSObject {
1717
SentrySDK.crashedLastRunCalled = false
1818
SentrySDK.startInvocations = 0
1919
PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = false
20-
CurrentDate.setCurrentDateProvider(nil)
2120
SentryNetworkTracker.sharedInstance.disable()
2221

2322
setTestDefaultLogLevel()

SentryTestUtils/SentryProfilerMocksSwiftCompatible.mm

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

33
#if SENTRY_TARGET_PROFILING_SUPPORTED
44

5-
# import "SentryCurrentDate.h"
5+
# import "SentryCurrentDateProvider.h"
6+
# import "SentryDependencyContainer.h"
67
# import "SentryProfilerMocks.h"
78
# import "SentryProfilerState+ObjCpp.h"
89
# include <vector>
@@ -28,7 +29,7 @@ + (void)appendMockBacktraceToState:(SentryProfilerState *)state
2829
auto backtrace = mockBacktrace(threadID, threadPriority,
2930
[threadName cStringUsingEncoding:NSUTF8StringEncoding], queueAddress,
3031
[queueLabel cStringUsingEncoding:NSUTF8StringEncoding], backtraceAddresses);
31-
backtrace.absoluteTimestamp = SentryCurrentDate.getCurrentDateProvider.systemTime;
32+
backtrace.absoluteTimestamp = SentryDependencyContainer.sharedInstance.dateProvider.systemTime;
3233
[state appendBacktrace:backtrace];
3334
}
3435

SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#import "SentryClient+Private.h"
1414
#import "SentryClient+TestInit.h"
1515
#import "SentryCrashWrapper.h"
16-
#import "SentryCurrentDate.h"
1716
#import "SentryCurrentDateProvider.h"
1817
#import "SentryDependencyContainer.h"
1918
#import "SentryDispatchFactory.h"

SentryTestUtils/TestClient.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,7 @@ public class TestFileManager: SentryFileManager {
140140
var deleteTimestampLastInForegroundInvocations: Int = 0
141141

142142
public init(options: Options) throws {
143-
try super.init(options: options, andCurrentDateProvider: TestCurrentDateProvider(), dispatchQueueWrapper: TestSentryDispatchQueueWrapper())
144-
}
145-
146-
public init(options: Options, andCurrentDateProvider currentDateProvider: CurrentDateProvider) throws {
147-
try super.init(options: options, andCurrentDateProvider: currentDateProvider, dispatchQueueWrapper: TestSentryDispatchQueueWrapper())
143+
try super.init(options: options, dispatchQueueWrapper: TestSentryDispatchQueueWrapper())
148144
}
149145

150146
public var deleteOldEnvelopeItemsInvocations = Invocations<Void>()

SentryTestUtils/TestCurrentDateProvider.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import Foundation
22

33
@objc
4-
public class TestCurrentDateProvider: NSObject, CurrentDateProvider {
4+
public class TestCurrentDateProvider: CurrentDateProvider {
55
public static let defaultStartingDate = Date(timeIntervalSinceReferenceDate: 0)
66
private var internalDate = defaultStartingDate
77
private var internalSystemTime: UInt64 = 0
88
public var driftTimeForEveryRead = false
99

10-
public func date() -> Date {
10+
public override func date() -> Date {
1111

1212
defer {
1313
if driftTimeForEveryRead {
@@ -40,16 +40,16 @@ public class TestCurrentDateProvider: NSObject, CurrentDateProvider {
4040
}
4141

4242
public var internalDispatchNow = DispatchTime.now()
43-
public func dispatchTimeNow() -> dispatch_time_t {
43+
public override func dispatchTimeNow() -> dispatch_time_t {
4444
return internalDispatchNow.rawValue
4545
}
4646

4747
public var timezoneOffsetValue = 0
48-
public func timezoneOffset() -> Int {
48+
public override func timezoneOffset() -> Int {
4949
return timezoneOffsetValue
5050
}
5151

52-
public func systemTime() -> UInt64 {
52+
public override func systemTime() -> UInt64 {
5353
return internalSystemTime
5454
}
5555
}

Sources/Sentry/SentryANRTracker.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#import "SentryANRTracker.h"
22
#import "SentryCrashWrapper.h"
3+
#import "SentryCurrentDateProvider.h"
4+
#import "SentryDependencyContainer.h"
35
#import "SentryDispatchQueueWrapper.h"
46
#import "SentryLog.h"
57
#import "SentryThreadWrapper.h"
@@ -16,7 +18,6 @@ typedef NS_ENUM(NSInteger, SentryANRTrackerState) {
1618
@interface
1719
SentryANRTracker ()
1820

19-
@property (nonatomic, strong) id<SentryCurrentDateProvider> currentDate;
2021
@property (nonatomic, strong) SentryCrashWrapper *crashWrapper;
2122
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueueWrapper;
2223
@property (nonatomic, strong) SentryThreadWrapper *threadWrapper;
@@ -31,14 +32,12 @@ @implementation SentryANRTracker {
3132
}
3233

3334
- (instancetype)initWithTimeoutInterval:(NSTimeInterval)timeoutInterval
34-
currentDateProvider:(id<SentryCurrentDateProvider>)currentDateProvider
3535
crashWrapper:(SentryCrashWrapper *)crashWrapper
3636
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
3737
threadWrapper:(SentryThreadWrapper *)threadWrapper
3838
{
3939
if (self = [super init]) {
4040
self.timeoutInterval = timeoutInterval;
41-
self.currentDate = currentDateProvider;
4241
self.crashWrapper = crashWrapper;
4342
self.dispatchQueueWrapper = dispatchQueueWrapper;
4443
self.threadWrapper = threadWrapper;
@@ -79,8 +78,8 @@ - (void)detectANRs
7978
}
8079
}
8180

82-
NSDate *blockDeadline =
83-
[[self.currentDate date] dateByAddingTimeInterval:self.timeoutInterval];
81+
NSDate *blockDeadline = [[SentryDependencyContainer.sharedInstance.dateProvider date]
82+
dateByAddingTimeInterval:self.timeoutInterval];
8483

8584
ticksSinceUiUpdate++;
8685

@@ -107,7 +106,8 @@ - (void)detectANRs
107106
// an ANR. If the app gets suspended this thread could sleep and wake up again. To avoid
108107
// false positives, we don't report ANRs if the delta is too big.
109108
NSTimeInterval deltaFromNowToBlockDeadline =
110-
[[self.currentDate date] timeIntervalSinceDate:blockDeadline];
109+
[[SentryDependencyContainer.sharedInstance.dateProvider date]
110+
timeIntervalSinceDate:blockDeadline];
111111

112112
if (deltaFromNowToBlockDeadline >= self.timeoutInterval) {
113113
SENTRY_LOG_DEBUG(

Sources/Sentry/SentryANRTrackingIntegration.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#import "SentryClient+Private.h"
44
#import "SentryCrashMachineContext.h"
55
#import "SentryCrashWrapper.h"
6-
#import "SentryDefaultCurrentDateProvider.h"
76
#import "SentryDispatchQueueWrapper.h"
87
#import "SentryEvent.h"
98
#import "SentryException.h"

Sources/Sentry/SentryAppStartTracker.m

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# import <PrivateSentrySDKOnly.h>
1111
# import <SentryAppState.h>
1212
# import <SentryCurrentDateProvider.h>
13+
# import <SentryDependencyContainer.h>
1314
# import <SentryDispatchQueueWrapper.h>
1415
# import <SentryInternalNotificationNames.h>
1516
# import <SentryLog.h>
@@ -28,7 +29,6 @@
2829
@interface
2930
SentryAppStartTracker ()
3031

31-
@property (nonatomic, strong) id<SentryCurrentDateProvider> currentDate;
3232
@property (nonatomic, strong) SentryAppState *previousAppState;
3333
@property (nonatomic, strong) SentryDispatchQueueWrapper *dispatchQueue;
3434
@property (nonatomic, strong) SentryAppStateManager *appStateManager;
@@ -53,20 +53,19 @@ + (void)load
5353
[[NSProcessInfo processInfo].environment[@"ActivePrewarm"] isEqualToString:@"1"];
5454
}
5555

56-
- (instancetype)initWithCurrentDateProvider:(id<SentryCurrentDateProvider>)currentDateProvider
57-
dispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
58-
appStateManager:(SentryAppStateManager *)appStateManager
59-
sysctl:(SentrySysctl *)sysctl
60-
enablePreWarmedAppStartTracing:(BOOL)enablePreWarmedAppStartTracing
56+
- (instancetype)initWithDispatchQueueWrapper:(SentryDispatchQueueWrapper *)dispatchQueueWrapper
57+
appStateManager:(SentryAppStateManager *)appStateManager
58+
sysctl:(SentrySysctl *)sysctl
59+
enablePreWarmedAppStartTracing:(BOOL)enablePreWarmedAppStartTracing
6160
{
6261
if (self = [super init]) {
63-
self.currentDate = currentDateProvider;
6462
self.dispatchQueue = dispatchQueueWrapper;
6563
self.appStateManager = appStateManager;
6664
self.sysctl = sysctl;
6765
self.previousAppState = [self.appStateManager loadPreviousAppState];
6866
self.wasInBackground = NO;
69-
self.didFinishLaunchingTimestamp = [currentDateProvider date];
67+
self.didFinishLaunchingTimestamp =
68+
[SentryDependencyContainer.sharedInstance.dateProvider date];
7069
self.enablePreWarmedAppStartTracing = enablePreWarmedAppStartTracing;
7170
self.isRunning = NO;
7271
}
@@ -94,7 +93,7 @@ - (void)start
9493
// or we just don't receive it. In this case the didFinishLaunchingTimestamp would be nil. As
9594
// the SDK should be initialized in application:didFinishLaunchingWithOptions: or in the init of
9695
// @main of a SwiftUI we set the timestamp here.
97-
self.didFinishLaunchingTimestamp = [self.currentDate date];
96+
self.didFinishLaunchingTimestamp = [SentryDependencyContainer.sharedInstance.dateProvider date];
9897

9998
[NSNotificationCenter.defaultCenter addObserver:self
10099
selector:@selector(didFinishLaunching)
@@ -172,12 +171,12 @@ - (void)buildAppStartMeasurement
172171
NSTimeInterval appStartDuration = 0.0;
173172
NSDate *appStartTimestamp;
174173
if (isPreWarmed) {
175-
appStartDuration = [[self.currentDate date]
174+
appStartDuration = [[SentryDependencyContainer.sharedInstance.dateProvider date]
176175
timeIntervalSinceDate:self.sysctl.moduleInitializationTimestamp];
177176
appStartTimestamp = self.sysctl.moduleInitializationTimestamp;
178177
} else {
179-
appStartDuration =
180-
[[self.currentDate date] timeIntervalSinceDate:self.sysctl.processStartTimestamp];
178+
appStartDuration = [[SentryDependencyContainer.sharedInstance.dateProvider date]
179+
timeIntervalSinceDate:self.sysctl.processStartTimestamp];
181180
appStartTimestamp = self.sysctl.processStartTimestamp;
182181
}
183182

@@ -266,7 +265,7 @@ - (SentryAppStartType)getStartType
266265

267266
- (void)didFinishLaunching
268267
{
269-
self.didFinishLaunchingTimestamp = [self.currentDate date];
268+
self.didFinishLaunchingTimestamp = [SentryDependencyContainer.sharedInstance.dateProvider date];
270269
}
271270

272271
- (void)didEnterBackground

0 commit comments

Comments
 (0)