Skip to content

Commit

Permalink
feat: Enable AppHang Tracking by default (#2600)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipphofmann authored Jan 16, 2023
1 parent 23e1220 commit f128c16
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This version adds a dependency on Swift.
- Change view hierarchy attachment format to JSON (#2491)
- SwiftUI performance tracking (#2271)
- Enable [File I/O Tracking](https://docs.sentry.io/platforms/apple/performance/instrumentation/automatic-instrumentation/#file-io-tracking) by default (#2497)
- Enable [AppHang Tracking](https://docs.sentry.io/platforms/apple/configuration/app-hangs/) by default (#2600)
- Enable [Core Data Tracing](https://docs.sentry.io/platforms/apple/performance/instrumentation/automatic-instrumentation/#core-data-tracking) by default (#2598)
- [User Interaction Tracing](https://docs.sentry.io/platforms/apple/performance/instrumentation/automatic-instrumentation/#user-interaction-tracing) is stable and enabled by default(#2503)
- Add synthetic for mechanism (#2501)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ NS_SWIFT_NAME(Options)
/**
* When enabled, the SDK tracks when the application stops responding for a specific amount of
* time defined by the `appHangsTimeoutInterval` option. The default is
* <code>NO</code>
* <code>YES</code>
*/
@property (nonatomic, assign) BOOL enableAppHangTracking;

Expand Down
12 changes: 6 additions & 6 deletions Sources/Sentry/SentryOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ - (void)setMeasurement:(SentryMeasurementValue *)measurement
@[
@"SentryCrashIntegration",
#if SENTRY_HAS_UIKIT
@"SentryANRTrackingIntegration", @"SentryScreenshotIntegration",
@"SentryUIEventTrackingIntegration", @"SentryViewHierarchyIntegration",
@"SentryScreenshotIntegration", @"SentryUIEventTrackingIntegration",
@"SentryViewHierarchyIntegration",
#endif
@"SentryFramesTrackingIntegration", @"SentryAutoBreadcrumbTrackingIntegration",
@"SentryAutoSessionTrackingIntegration", @"SentryAppStartTrackingIntegration",
@"SentryWatchdogTerminationTrackingIntegration",
@"SentryANRTrackingIntegration", @"SentryFramesTrackingIntegration",
@"SentryAutoBreadcrumbTrackingIntegration", @"SentryAutoSessionTrackingIntegration",
@"SentryAppStartTrackingIntegration", @"SentryWatchdogTerminationTrackingIntegration",
@"SentryPerformanceTrackingIntegration", @"SentryNetworkTrackingIntegration",
@"SentryFileIOTrackingIntegration", @"SentryCoreDataTrackingIntegration"
]
Expand Down Expand Up @@ -82,7 +82,7 @@ - (instancetype)init
self.idleTimeout = 3.0;
self.enablePreWarmedAppStartTracing = NO;
#endif
self.enableAppHangTracking = NO;
self.enableAppHangTracking = YES;
self.appHangTimeoutInterval = 2.0;
self.enableAutoBreadcrumbTracking = YES;
self.enableNetworkTracking = YES;
Expand Down
15 changes: 13 additions & 2 deletions Tests/SentryTests/SentryClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1037,9 +1037,15 @@ class SentryClientTest: XCTestCase {
let eventId = fixture.getSut().capture(message: fixture.messageAsString)

eventId.assertIsNotEmpty()

var expectedIntegrations = ["AutoBreadcrumbTracking", "AutoSessionTracking", "Crash", "NetworkTracking"]
if !SentryDependencyContainer.sharedInstance().crashWrapper.isBeingTraced() {
expectedIntegrations = ["ANRTracking"] + expectedIntegrations
}

assertLastSentEvent { actual in
assertArrayEquals(
expected: ["AutoBreadcrumbTracking", "AutoSessionTracking", "Crash", "NetworkTracking"],
expected: expectedIntegrations,
actual: actual.sdk?["integrations"] as? [String]
)
}
Expand Down Expand Up @@ -1068,8 +1074,13 @@ class SentryClientTest: XCTestCase {

eventId.assertIsNotEmpty()
assertLastSentEvent { actual in
var expectedIntegrations = ["AutoBreadcrumbTracking", "AutoSessionTracking", "Crash", "NetworkTracking", integrationName]
if !SentryDependencyContainer.sharedInstance().crashWrapper.isBeingTraced() {
expectedIntegrations = ["ANRTracking"] + expectedIntegrations
}

assertArrayEquals(
expected: ["AutoBreadcrumbTracking", "AutoSessionTracking", "Crash", "NetworkTracking", integrationName],
expected: expectedIntegrations,
actual: actual.sdk?["integrations"] as? [String]
)
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/SentryTests/SentryOptionsTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ - (void)assertDefaultValues:(SentryOptions *)options
XCTAssertEqual(options.enablePreWarmedAppStartTracing, NO);
XCTAssertEqual(options.attachViewHierarchy, NO);
#endif
XCTAssertFalse(options.enableAppHangTracking);
XCTAssertTrue(options.enableAppHangTracking);
XCTAssertEqual(options.appHangTimeoutInterval, 2);
XCTAssertEqual(YES, options.enableNetworkTracking);
XCTAssertNil(options.tracesSampleRate);
Expand Down Expand Up @@ -744,7 +744,7 @@ - (void)testEnablePreWarmedAppStartTracking

- (void)testEnableAppHangTracking
{
[self testBooleanField:@"enableAppHangTracking" defaultValue:NO];
[self testBooleanField:@"enableAppHangTracking" defaultValue:YES];
}

- (void)testDefaultAppHangsTimeout
Expand Down
11 changes: 8 additions & 3 deletions Tests/SentryTests/SentrySDKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,18 @@ class SentrySDKTests: XCTestCase {
XCTAssertEqual(SentryLevel.debug, options?.diagnosticLevel)
XCTAssertEqual(true, options?.attachStacktrace)
XCTAssertEqual(true, options?.enableAutoSessionTracking)

assertIntegrationsInstalled(integrations: [
var expectedIntegrations = [
"SentryCrashIntegration",
"SentryAutoBreadcrumbTrackingIntegration",
"SentryAutoSessionTrackingIntegration",
"SentryNetworkTrackingIntegration"
])
]
if !SentryDependencyContainer.sharedInstance().crashWrapper.isBeingTraced() {
expectedIntegrations.append("SentryANRTrackingIntegration")
}

assertIntegrationsInstalled(integrations: expectedIntegrations)
}

func testStartWithConfigureOptions_NoDsn() throws {
Expand Down

0 comments on commit f128c16

Please sign in to comment.