diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index d6f45df09d5..b2674ccd8bc 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -387,8 +387,6 @@ 7B68D93625FF5F1A0082D139 /* SentryAppState+Equality.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B68D93525FF5F1A0082D139 /* SentryAppState+Equality.m */; }; 7B6ADFCF26A02CAE0076C206 /* SentryCrashReportTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6ADFCE26A02CAE0076C206 /* SentryCrashReportTests.swift */; }; 7B6C5ED6264E62CA0010D138 /* SentryTransactionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6C5ED5264E62CA0010D138 /* SentryTransactionTests.swift */; }; - 7B6C5EDA264E8D860010D138 /* SentryFramesTrackingIntegration.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6C5ED9264E8D860010D138 /* SentryFramesTrackingIntegration.h */; }; - 7B6C5EDC264E8DA80010D138 /* SentryFramesTrackingIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B6C5EDB264E8DA80010D138 /* SentryFramesTrackingIntegration.m */; }; 7B6C5F8126034354007F7DFF /* SentryWatchdogTerminationLogic.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B6C5F8026034354007F7DFF /* SentryWatchdogTerminationLogic.h */; }; 7B6C5F8726034395007F7DFF /* SentryWatchdogTerminationLogic.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B6C5F8626034395007F7DFF /* SentryWatchdogTerminationLogic.m */; }; 7B6CC50224EE5A42001816D7 /* SentryHubTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6CC50124EE5A42001816D7 /* SentryHubTests.swift */; }; @@ -1017,6 +1015,7 @@ F4EF69232E95ABE800B6B46A /* SentryCrashMachineContextTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4EF69222E95ABE800B6B46A /* SentryCrashMachineContextTests.m */; }; F4FE86BD2EECAC31003D845F /* SentryScreenshotOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE86BB2EECAC31003D845F /* SentryScreenshotOptions.swift */; }; F4FE86BE2EECAC31003D845F /* SentryScreenshotIntegration.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE86BA2EECAC31003D845F /* SentryScreenshotIntegration.swift */; }; + F4FE86C72EECBEBA003D845F /* SentryFramesTrackingIntegration.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE86C52EECBEBA003D845F /* SentryFramesTrackingIntegration.swift */; }; F4FE9DBD2E621F100014FED5 /* SentryRandom.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */; }; F4FE9DFD2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DFB2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift */; }; F4FE9DFE2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DFC2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift */; }; @@ -1701,8 +1700,6 @@ 7B68D93525FF5F1A0082D139 /* SentryAppState+Equality.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SentryAppState+Equality.m"; sourceTree = ""; }; 7B6ADFCE26A02CAE0076C206 /* SentryCrashReportTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashReportTests.swift; sourceTree = ""; }; 7B6C5ED5264E62CA0010D138 /* SentryTransactionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTransactionTests.swift; sourceTree = ""; }; - 7B6C5ED9264E8D860010D138 /* SentryFramesTrackingIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryFramesTrackingIntegration.h; path = include/SentryFramesTrackingIntegration.h; sourceTree = ""; }; - 7B6C5EDB264E8DA80010D138 /* SentryFramesTrackingIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryFramesTrackingIntegration.m; sourceTree = ""; }; 7B6C5F8026034354007F7DFF /* SentryWatchdogTerminationLogic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryWatchdogTerminationLogic.h; path = include/SentryWatchdogTerminationLogic.h; sourceTree = ""; }; 7B6C5F8626034395007F7DFF /* SentryWatchdogTerminationLogic.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryWatchdogTerminationLogic.m; sourceTree = ""; }; 7B6CC50124EE5A42001816D7 /* SentryHubTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryHubTests.swift; sourceTree = ""; }; @@ -2404,6 +2401,7 @@ F4EF69222E95ABE800B6B46A /* SentryCrashMachineContextTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashMachineContextTests.m; sourceTree = ""; }; F4FE86BA2EECAC31003D845F /* SentryScreenshotIntegration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenshotIntegration.swift; sourceTree = ""; }; F4FE86BB2EECAC31003D845F /* SentryScreenshotOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenshotOptions.swift; sourceTree = ""; }; + F4FE86C52EECBEBA003D845F /* SentryFramesTrackingIntegration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryFramesTrackingIntegration.swift; sourceTree = ""; }; F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRandom.swift; sourceTree = ""; }; F4FE9DFB2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryDefaultObjCRuntimeWrapper.swift; sourceTree = ""; }; F4FE9DFC2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryObjCRuntimeWrapper.swift; sourceTree = ""; }; @@ -3729,8 +3727,6 @@ 7BE0DC38272AE874004FA8B7 /* FramesTracking */ = { isa = PBXGroup; children = ( - 7B6C5ED9264E8D860010D138 /* SentryFramesTrackingIntegration.h */, - 7B6C5EDB264E8DA80010D138 /* SentryFramesTrackingIntegration.m */, 62862B1B2B1DDBC8009B16E3 /* SentryDelayedFrame.h */, 62862B1D2B1DDC35009B16E3 /* SentryDelayedFrame.m */, 62C316802B1F2E93000D7031 /* SentryDelayedFramesTracker.h */, @@ -4708,6 +4704,7 @@ D8739CF72BECFF92007D2F66 /* Performance */ = { isa = PBXGroup; children = ( + F4FE86C62EECBEBA003D845F /* FramesTracking */, FAB007302E9EF8CB001C806A /* SentryUIViewControllerPerformanceTracker.swift */, FAE57BF12E83049900B710F9 /* SentryDisplayLinkWrapper.swift */, D468C0602D36699700964230 /* IO */, @@ -4951,6 +4948,14 @@ path = Screenshot; sourceTree = ""; }; + F4FE86C62EECBEBA003D845F /* FramesTracking */ = { + isa = PBXGroup; + children = ( + F4FE86C52EECBEBA003D845F /* SentryFramesTrackingIntegration.swift */, + ); + path = FramesTracking; + sourceTree = ""; + }; F4FE9E062E6248BB0014FED5 /* SentryCrash */ = { isa = PBXGroup; children = ( @@ -5339,7 +5344,6 @@ D865892F29D6ECA7000BE151 /* SentryCrashBinaryImageCache.h in Headers */, 6344DDB41EC309E000D9160D /* SentryCrashReportSink.h in Headers */, D867063F27C3BC2400048851 /* SentryCoreDataTracker.h in Headers */, - 7B6C5EDA264E8D860010D138 /* SentryFramesTrackingIntegration.h in Headers */, 7B0DC72F288698F70039995F /* NSMutableDictionary+Sentry.h in Headers */, 63FE713920DA4C1100CDBAE8 /* SentryCrashMach.h in Headers */, 7BD86EC5264A63F6005439DB /* SentrySysctlObjC.h in Headers */, @@ -5966,9 +5970,9 @@ 63FE70D520DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.m in Sources */, 62F70E952D423BCD00634054 /* SentryMechanismCodable.swift in Sources */, 6283085F2D50AA8C00EAEF77 /* SentryMessage.swift in Sources */, + F4FE86C72EECBEBA003D845F /* SentryFramesTrackingIntegration.swift in Sources */, 7BC63F0A28081288009D9E37 /* SentrySwizzleWrapperHelper.m in Sources */, 6276350C2D59FACC00F7CEF6 /* SentryEventDecoder.swift in Sources */, - 7B6C5EDC264E8DA80010D138 /* SentryFramesTrackingIntegration.m in Sources */, F4FE9E082E6248E40014FED5 /* SentryCrashWrapper.swift in Sources */, FA914E592ECF968500C54BDD /* UserFeedbackIntegration.swift in Sources */, 849B8F9A2C6E906900148E1F /* SentryUserFeedbackConfiguration.swift in Sources */, diff --git a/Sources/Sentry/SentryBaseIntegration.m b/Sources/Sentry/SentryBaseIntegration.m index 88ebfab3bb9..25555e929b4 100644 --- a/Sources/Sentry/SentryBaseIntegration.m +++ b/Sources/Sentry/SentryBaseIntegration.m @@ -154,42 +154,6 @@ - (BOOL)shouldBeEnabledWithOptions:(SentryOptions *)options } #endif - if (integrationOptions & kIntegrationOptionStartFramesTracker) { - -#if SENTRY_HAS_UIKIT - BOOL performanceDisabled - = !options.enableAutoPerformanceTracing || !options.isTracingEnabled; - BOOL appHangsDisabled = options.isAppHangTrackingDisabled; - - // The watchdog tracker uses the frames tracker, so frame tracking - // must be enabled if watchdog tracking is enabled. - BOOL watchdogDisabled = !options.enableWatchdogTerminationTracking; - - if (performanceDisabled && appHangsDisabled && watchdogDisabled) { - if (appHangsDisabled) { - SENTRY_LOG_DEBUG(@"Not going to enable %@ because enableAppHangTracking is " - @"disabled or the appHangTimeoutInterval is 0.", - self.integrationName); - } - - if (performanceDisabled) { - SENTRY_LOG_DEBUG(@"Not going to enable %@ because enableAutoPerformanceTracing and " - @"isTracingEnabled are disabled.", - self.integrationName); - } - - if (watchdogDisabled) { - SENTRY_LOG_DEBUG( - @"Not going to enable %@ because enableWatchdogTerminationTracking " - @"is disabled.", - self.integrationName); - } - - return NO; - } -#endif // SENTRY_HAS_UIKIT - } - return YES; } diff --git a/Sources/Sentry/SentryFramesTrackingIntegration.m b/Sources/Sentry/SentryFramesTrackingIntegration.m deleted file mode 100644 index 78c1b95e91e..00000000000 --- a/Sources/Sentry/SentryFramesTrackingIntegration.m +++ /dev/null @@ -1,47 +0,0 @@ -#import "SentryFramesTrackingIntegration.h" - -#if SENTRY_HAS_UIKIT - -# import "PrivateSentrySDKOnly.h" -# import "SentrySwift.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface SentryFramesTrackingIntegration () - -@property (nonatomic, strong) SentryFramesTracker *tracker; - -@end - -@implementation SentryFramesTrackingIntegration - -- (BOOL)installWithOptions:(SentryOptions *)options -{ - if (!PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode - && ![super installWithOptions:options]) { - return NO; - } - - self.tracker = SentryDependencyContainer.sharedInstance.framesTracker; - [self.tracker start]; - - return YES; -} - -- (SentryIntegrationOption)integrationOptions -{ - return kIntegrationOptionStartFramesTracker; -} - -- (void)uninstall -{ - if (nil != self.tracker) { - [self.tracker stop]; - } -} - -@end - -NS_ASSUME_NONNULL_END - -#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Sentry/SentrySDKInternal.m b/Sources/Sentry/SentrySDKInternal.m index 2c81fc7d4ae..7b34af68ea7 100644 --- a/Sources/Sentry/SentrySDKInternal.m +++ b/Sources/Sentry/SentrySDKInternal.m @@ -26,7 +26,6 @@ #if SENTRY_HAS_UIKIT # import "SentryAppStartTrackingIntegration.h" -# import "SentryFramesTrackingIntegration.h" # import "SentryPerformanceTrackingIntegration.h" # import "SentryUIEventTrackingIntegration.h" # import "SentryViewHierarchyIntegration.h" @@ -512,9 +511,8 @@ + (void)endSession #endif // SENTRY_TARGET_REPLAY_SUPPORTED [SentryCrashIntegration class], #if SENTRY_HAS_UIKIT - [SentryAppStartTrackingIntegration class], [SentryFramesTrackingIntegration class], - [SentryPerformanceTrackingIntegration class], [SentryUIEventTrackingIntegration class], - [SentryViewHierarchyIntegration class], + [SentryAppStartTrackingIntegration class], [SentryPerformanceTrackingIntegration class], + [SentryUIEventTrackingIntegration class], [SentryViewHierarchyIntegration class], [SentryWatchdogTerminationTrackingIntegration class], #endif // SENTRY_HAS_UIKIT [SentryAutoBreadcrumbTrackingIntegration class], [SentryCoreDataTrackingIntegration class], diff --git a/Sources/Sentry/include/SentryBaseIntegration.h b/Sources/Sentry/include/SentryBaseIntegration.h index 1789082d366..3554acb8a53 100644 --- a/Sources/Sentry/include/SentryBaseIntegration.h +++ b/Sources/Sentry/include/SentryBaseIntegration.h @@ -28,7 +28,6 @@ typedef NS_OPTIONS(NSUInteger, SentryIntegrationOption) { kIntegrationOptionEnableCrashHandler = 1 << 16, kIntegrationOptionEnableMetricKit = 1 << 17, kIntegrationOptionEnableReplay = 1 << 18, - kIntegrationOptionStartFramesTracker = 1 << 19, }; @class SentryOptions; diff --git a/Sources/Sentry/include/SentryFramesTrackingIntegration.h b/Sources/Sentry/include/SentryFramesTrackingIntegration.h deleted file mode 100644 index 68f7fea6ccd..00000000000 --- a/Sources/Sentry/include/SentryFramesTrackingIntegration.h +++ /dev/null @@ -1,15 +0,0 @@ -#import "SentryDefines.h" - -#if SENTRY_HAS_UIKIT - -# import "SentryBaseIntegration.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface SentryFramesTrackingIntegration : SentryBaseIntegration - -@end - -NS_ASSUME_NONNULL_END - -#endif // SENTRY_HAS_UIKIT diff --git a/Sources/Swift/Core/Integrations/Integrations.swift b/Sources/Swift/Core/Integrations/Integrations.swift index 108c4685533..9112e6e7812 100644 --- a/Sources/Swift/Core/Integrations/Integrations.swift +++ b/Sources/Swift/Core/Integrations/Integrations.swift @@ -40,7 +40,11 @@ private struct AnyIntegration { .init(SentryAutoSessionTrackingIntegration.self), .init(SentryHangTrackerIntegrationObjC.self) ] - + + #if (os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) || os(visionOS)) && !SENTRY_NO_UIKIT + integrations.append(.init(SentryFramesTrackingIntegration.self)) + #endif + #if os(iOS) && !SENTRY_NO_UIKIT integrations.append(.init(UserFeedbackIntegration.self)) #endif diff --git a/Sources/Swift/Integrations/Performance/FramesTracking/SentryFramesTrackingIntegration.swift b/Sources/Swift/Integrations/Performance/FramesTracking/SentryFramesTrackingIntegration.swift new file mode 100644 index 00000000000..356b3e73abd --- /dev/null +++ b/Sources/Swift/Integrations/Performance/FramesTracking/SentryFramesTrackingIntegration.swift @@ -0,0 +1,49 @@ +@_implementationOnly import _SentryPrivate + +#if (os(iOS) || os(tvOS) || os(visionOS)) && !SENTRY_NO_UIKIT + +final class SentryFramesTrackingIntegration: NSObject, SwiftIntegration { + let tracker: SentryFramesTracker + + init?(with options: Options, dependencies: Dependencies) { + // Check hybrid SDK mode first - if enabled, always start frames tracking + if !PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode { + + // Check if frames tracking should be enabled based on options + let performanceDisabled = !options.enableAutoPerformanceTracing || !options.isTracingEnabled + let appHangsDisabled = options.isAppHangTrackingDisabled() + let watchdogDisabled = !options.enableWatchdogTerminationTracking + + // The watchdog tracker uses the frames tracker, so frame tracking + // must be enabled if watchdog tracking is enabled. + if performanceDisabled && appHangsDisabled && watchdogDisabled { + if appHangsDisabled { + SentrySDKLog.debug("Not going to enable \(Self.name) because enableAppHangTracking is disabled or the appHangTimeoutInterval is 0.") + } + + if performanceDisabled { + SentrySDKLog.debug("Not going to enable \(Self.name) because enableAutoPerformanceTracing and isTracingEnabled are disabled.") + } + + if watchdogDisabled { + SentrySDKLog.debug("Not going to enable \(Self.name) because enableWatchdogTerminationTracking is disabled.") + } + + return nil + } + } + + tracker = dependencies.framesTracker + tracker.start() + } + + func uninstall() { + tracker.stop() + } + + static var name: String { + "SentryFramesTrackingIntegration" + } +} + +#endif diff --git a/Sources/Swift/SentryDependencyContainer.swift b/Sources/Swift/SentryDependencyContainer.swift index bdb098e3542..cec3f131e5e 100644 --- a/Sources/Swift/SentryDependencyContainer.swift +++ b/Sources/Swift/SentryDependencyContainer.swift @@ -245,6 +245,14 @@ extension SentryDependencyContainer: ScreenshotSourceProvider { } extension SentryDependencyContainer: AutoSessionTrackingProvider { } +#if (os(iOS) || os(tvOS) || os(visionOS)) && !SENTRY_NO_UIKIT +protocol FramesTrackingProvider { + var framesTracker: SentryFramesTracker { get } +} + +extension SentryDependencyContainer: FramesTrackingProvider { } +#endif + #if ((os(iOS) || os(tvOS) || os(visionOS)) && !SENTRY_NO_UIKIT) || os(macOS) extension SentryDependencyContainer: NotificationCenterProvider { } #endif diff --git a/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTrackingIntegrationTests.swift b/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTrackingIntegrationTests.swift index a5b8cfca495..18e710fcc8d 100644 --- a/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTrackingIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/Performance/FramesTracking/SentryFramesTrackingIntegrationTests.swift @@ -2,28 +2,31 @@ @_spi(Private) import SentryTestUtils import XCTest -#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) +#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) || os(visionOS) class SentryFramesTrackingIntegrationTests: XCTestCase { + private struct MockFramesTrackingProvider: FramesTrackingProvider { + var framesTracker: SentryFramesTracker + } + private class Fixture { let options = Options() let displayLink = TestDisplayLinkWrapper() - + let framesTracker = SentryDependencyContainer.sharedInstance().framesTracker + init() { options.dsn = TestConstants.dsnAsString(username: "SentryFramesTrackingIntegrationTests") } - - var sut: SentryFramesTrackingIntegration { - return SentryFramesTrackingIntegration() + + var dependencies: MockFramesTrackingProvider { + MockFramesTrackingProvider(framesTracker: framesTracker) } } - + private let fixture = Fixture() - private var sut: SentryFramesTrackingIntegration! - + override func setUp() { super.setUp() - sut = fixture.sut } override func tearDown() { @@ -35,33 +38,48 @@ class SentryFramesTrackingIntegrationTests: XCTestCase { func testTracesSampleRateSet_MeasuresFrames() { let options = fixture.options options.tracesSampleRate = 0.1 - sut.install(with: options) - - XCTAssertNotNil(Dynamic(sut).tracker.asObject) + let sut = SentryFramesTrackingIntegration(with: options, dependencies: fixture.dependencies) + defer { + sut?.uninstall() + } + + XCTAssertNotNil(sut) + XCTAssertNotNil(sut?.tracker) } - + func testTracesSamplerSet_MeasuresFrames() { let options = fixture.options options.tracesSampler = { _ in return 0 } - sut.install(with: options) - - XCTAssertNotNil(Dynamic(sut).tracker.asObject) + let sut = SentryFramesTrackingIntegration(with: options, dependencies: fixture.dependencies) + defer { + sut?.uninstall() + } + + XCTAssertNotNil(sut) + XCTAssertNotNil(sut?.tracker) } func testAppHangEnabled_MeasuresFrames() { let options = fixture.options - sut.install(with: options) + let sut = SentryFramesTrackingIntegration(with: options, dependencies: fixture.dependencies) + defer { + sut?.uninstall() + } - XCTAssertNotNil(Dynamic(sut).tracker.asObject) + XCTAssertNotNil(sut) + XCTAssertNotNil(sut?.tracker) } func testAppHangEnabled_ButIntervalZero_DoestNotMeasuresFrames() { let options = fixture.options options.appHangTimeoutInterval = 0.0 options.enableWatchdogTerminationTracking = false - sut.install(with: options) + let sut = SentryFramesTrackingIntegration(with: options, dependencies: fixture.dependencies) + defer { + sut?.uninstall() + } - XCTAssertNil(Dynamic(sut).tracker.asObject) + XCTAssertNil(sut) } func testZeroTracesSampleRate_DoesNotMeasureFrames() { @@ -69,39 +87,49 @@ class SentryFramesTrackingIntegrationTests: XCTestCase { options.tracesSampleRate = 0.0 options.appHangTimeoutInterval = 0.0 options.enableWatchdogTerminationTracking = false - sut.install(with: options) - - XCTAssertNil(Dynamic(sut).tracker.asObject) + let sut = SentryFramesTrackingIntegration(with: options, dependencies: fixture.dependencies) + defer { + sut?.uninstall() + } + + XCTAssertNil(sut) } - + func testAutoPerformanceTrackingDisabled_DoesNotMeasureFrames() { let options = fixture.options options.tracesSampleRate = 0.1 options.enableAutoPerformanceTracing = false options.enableAppHangTracking = false options.enableWatchdogTerminationTracking = false - sut.install(with: options) - - XCTAssertNil(Dynamic(sut).tracker.asObject) + let sut = SentryFramesTrackingIntegration(with: options, dependencies: fixture.dependencies) + defer { + sut?.uninstall() + } + + XCTAssertNil(sut) } - + func test_HybridSDKEnables_MeasureFrames() { PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = true - + let options = fixture.options options.enableAutoPerformanceTracing = false - sut.install(with: options) - - XCTAssertNotNil(Dynamic(sut).tracker.asObject) + let sut = SentryFramesTrackingIntegration(with: options, dependencies: fixture.dependencies) + defer { + sut?.uninstall() + } + + XCTAssertNotNil(sut) + XCTAssertNotNil(sut?.tracker) } - - func testUninstall() { - sut.install(with: fixture.options) - + + func testUninstall() throws { + let sut = try XCTUnwrap(SentryFramesTrackingIntegration(with: fixture.options, dependencies: fixture.dependencies)) + SentryDependencyContainer.sharedInstance().framesTracker.setDisplayLinkWrapper(fixture.displayLink) - + sut.uninstall() - + XCTAssertNil(fixture.displayLink.target) XCTAssertNil(fixture.displayLink.selector) } diff --git a/Tests/SentryTests/Integrations/SentrySwiftIntegrationInstallerTests.swift b/Tests/SentryTests/Integrations/SentrySwiftIntegrationInstallerTests.swift index 74ed9e9f365..92042aedbdc 100644 --- a/Tests/SentryTests/Integrations/SentrySwiftIntegrationInstallerTests.swift +++ b/Tests/SentryTests/Integrations/SentrySwiftIntegrationInstallerTests.swift @@ -17,7 +17,13 @@ final class SentrySwiftIntegrationInstallerTests: XCTestCase { options.dsn = TestConstants.dsnAsString(username: "SentrySwiftIntegrationInstallerTests") options.debug = true options.swiftAsyncStacktraces = true + + // Disable other integrations options.enableAutoSessionTracking = false + options.enableAutoPerformanceTracing = false + options.tracesSampleRate = 0 + options.enableAppHangTracking = false + options.enableWatchdogTerminationTracking = false let testHub = TestHub(client: nil, andScope: nil) SentrySDKInternal.setCurrentHub(testHub) @@ -37,7 +43,13 @@ final class SentrySwiftIntegrationInstallerTests: XCTestCase { options.dsn = TestConstants.dsnAsString(username: "SentrySwiftIntegrationInstallerTests") options.debug = true options.swiftAsyncStacktraces = false + + // Disable other integrations options.enableAutoSessionTracking = false + options.enableAutoPerformanceTracing = false + options.tracesSampleRate = 0 + options.enableAppHangTracking = false + options.enableWatchdogTerminationTracking = false let testHub = TestHub(client: nil, andScope: nil) SentrySDKInternal.setCurrentHub(testHub) diff --git a/Tests/SentryTests/SentryTests-Bridging-Header.h b/Tests/SentryTests/SentryTests-Bridging-Header.h index 172d4266ec9..293db5bb5ad 100644 --- a/Tests/SentryTests/SentryTests-Bridging-Header.h +++ b/Tests/SentryTests/SentryTests-Bridging-Header.h @@ -107,7 +107,6 @@ #import "SentryFileManagerHelper.h" #import "SentryFormatter.h" #import "SentryFrame.h" -#import "SentryFramesTrackingIntegration.h" #import "SentryHttpStatusCodeRange+Private.h" #import "SentryHttpTransport.h" #import "SentryHub+Private.h"