Skip to content

Commit f525749

Browse files
fix: Address review feedback for standalone app start tracing
- Fix trailing slash typo in changelog entry - Restore enableUncaughtNSExceptionReporting in sample app - Make StandaloneAppStartTransactionHelper final - Add test for unknown app start type in StandaloneTransactionStrategy - Restore visionOS platform guard in measurement provider tests - Rename tests to follow test_when_should convention - Remove extra blank line in sentryBuildAppStartSpansInternal
1 parent d0d815e commit f525749

File tree

6 files changed

+33
-19
lines changed

6 files changed

+33
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Features
66

7-
- Add standalone app start tracing as an experimental option (#7660), enable it via `options.experimental.enableStandaloneAppStartTracing = true`/
7+
- Add standalone app start tracing as an experimental option (#7660), enable it via `options.experimental.enableStandaloneAppStartTracing = true`
88

99
## 9.7.0
1010

Samples/SentrySampleShared/SentrySampleShared/SentrySDKWrapper.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ public struct SentrySDKWrapper {
182182
options.enableFileManagerSwizzling = !SentrySDKOverrides.Other.disableFileManagerSwizzling.boolValue
183183
options.experimental.enableUnhandledCPPExceptionsV2 = true
184184
options.experimental.enableStandaloneAppStartTracing = true
185+
186+
#if os(macOS) && !SENTRY_NO_UI_FRAMEWORK
187+
options.enableUncaughtNSExceptionReporting = true
188+
#endif
185189
}
186190

187191
func configureInitialScope(scope: Scope, options: Options) -> Scope {

Sources/Sentry/SentryBuildAppStartSpans.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
sentryBuildAppStartSpansInternal(SentryTracer *tracer,
4040
SentryAppStartMeasurement *_Nullable appStartMeasurement, BOOL isStandalone)
4141
{
42-
4342
if (appStartMeasurement == nil) {
4443
return @[];
4544
}

Sources/Swift/Integrations/AppStartTracking/AppStartReportingStrategy.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#if (os(iOS) || os(tvOS) || os(visionOS)) && !SENTRY_NO_UI_FRAMEWORK
44

5+
/// Determines how a completed app start measurement is reported to Sentry.
56
protocol AppStartReportingStrategy {
67
func report(_ measurement: SentryAppStartMeasurement)
78
}
@@ -61,7 +62,7 @@ struct StandaloneTransactionStrategy: AppStartReportingStrategy {
6162
}
6263

6364
/// Helper to identify standalone app start transactions from ObjC code.
64-
@_spi(Private) @objc public class StandaloneAppStartTransactionHelper: NSObject {
65+
@_spi(Private) @objc public final class StandaloneAppStartTransactionHelper: NSObject {
6566
/// Returns `true` when the operation and origin match a standalone app start transaction.
6667
@objc public static func isStandaloneAppStartTransaction(operation: String, origin: String) -> Bool {
6768
return (operation == SentrySpanOperationAppStartCold

Tests/SentryTests/Integrations/Performance/AppStartTracking/AppStartReportingStrategyTests.swift

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class AppStartReportingStrategyTests: XCTestCase {
3939

4040
// MARK: - AttachToTransactionStrategy
4141

42-
func testAttach_SetsMeasurementOnGlobalStatic() throws {
42+
func testReport_whenColdStart_shouldSetMeasurementOnGlobalStatic() throws {
4343
let measurement = createMeasurement(type: .cold)
4444

4545
AttachToTransactionStrategy().report(measurement)
@@ -49,7 +49,7 @@ class AppStartReportingStrategyTests: XCTestCase {
4949
XCTAssertEqual(stored.duration, measurement.duration)
5050
}
5151

52-
func testAttach_WarmStart_SetsMeasurementOnGlobalStatic() throws {
52+
func testReport_whenWarmStart_shouldSetMeasurementOnGlobalStatic() throws {
5353
let measurement = createMeasurement(type: .warm)
5454

5555
AttachToTransactionStrategy().report(measurement)
@@ -60,7 +60,7 @@ class AppStartReportingStrategyTests: XCTestCase {
6060

6161
// MARK: - StandaloneTransactionStrategy
6262

63-
func testSendStandalone_SDKNotEnabled_DoesNotCaptureTransaction() {
63+
func testReport_whenSDKNotEnabled_shouldNotCaptureTransaction() {
6464
let hub = createHub()
6565
// Don't set hub on SDK — isEnabled returns false
6666
let measurement = createMeasurement(type: .cold)
@@ -70,7 +70,7 @@ class AppStartReportingStrategyTests: XCTestCase {
7070
XCTAssertTrue(hub.capturedEventsWithScopes.invocations.isEmpty)
7171
}
7272

73-
func testSendStandalone_ColdStart_CapturesTransaction() throws {
73+
func testReport_whenColdStart_shouldCaptureTransaction() throws {
7474
let hub = createHub()
7575
SentrySDKInternal.setCurrentHub(hub)
7676
let measurement = createMeasurement(type: .cold)
@@ -86,7 +86,7 @@ class AppStartReportingStrategyTests: XCTestCase {
8686
XCTAssertEqual(traceContext["origin"] as? String, "auto.app.start")
8787
}
8888

89-
func testSendStandalone_WarmStart_CapturesTransaction() throws {
89+
func testReport_whenWarmStart_shouldCaptureTransaction() throws {
9090
let hub = createHub()
9191
SentrySDKInternal.setCurrentHub(hub)
9292
let measurement = createMeasurement(type: .warm)
@@ -101,7 +101,17 @@ class AppStartReportingStrategyTests: XCTestCase {
101101
XCTAssertEqual(traceContext["op"] as? String, "app.start.warm")
102102
}
103103

104-
func testSendStandalone_DoesNotSetGlobalStatic() {
104+
func testReport_whenUnknownStartType_shouldNotCaptureTransaction() {
105+
let hub = createHub()
106+
SentrySDKInternal.setCurrentHub(hub)
107+
let measurement = createMeasurement(type: .unknown)
108+
109+
StandaloneTransactionStrategy().report(measurement)
110+
111+
XCTAssertTrue(hub.capturedTransactionsWithScope.invocations.isEmpty)
112+
}
113+
114+
func testReport_whenColdStart_shouldNotSetGlobalStatic() {
105115
let hub = createHub()
106116
SentrySDKInternal.setCurrentHub(hub)
107117
let measurement = createMeasurement(type: .cold)
@@ -135,7 +145,7 @@ class AppStartReportingStrategyTests: XCTestCase {
135145
return hub
136146
}
137147

138-
func testSendStandalone_ColdStart_AddsAppStartMeasurement() throws {
148+
func testReport_whenColdStart_shouldAddAppStartMeasurement() throws {
139149
let hub = setUpIntegrationHub()
140150
let measurement = createMeasurement(type: .cold, duration: 0.5)
141151

@@ -147,7 +157,7 @@ class AppStartReportingStrategyTests: XCTestCase {
147157
XCTAssertEqual(appStartCold["value"] as? Double, 500)
148158
}
149159

150-
func testSendStandalone_WarmStart_AddsAppStartMeasurement() throws {
160+
func testReport_whenWarmStart_shouldAddAppStartMeasurement() throws {
151161
let hub = setUpIntegrationHub()
152162
let measurement = createMeasurement(type: .warm, duration: 0.3)
153163

@@ -159,7 +169,7 @@ class AppStartReportingStrategyTests: XCTestCase {
159169
XCTAssertEqual(appStartWarm["value"] as? Double, 300)
160170
}
161171

162-
func testSendStandalone_AddsDebugMeta() throws {
172+
func testReport_whenColdStart_shouldAddDebugMeta() throws {
163173
let hub = setUpIntegrationHub()
164174
let measurement = createMeasurement(type: .cold)
165175

@@ -175,7 +185,7 @@ class AppStartReportingStrategyTests: XCTestCase {
175185
XCTAssertEqual(image["image_vmaddr"] as? String, expectedImage.imageVmAddress)
176186
}
177187

178-
func testSendStandalone_SetsStartTimeToAppStartTimestamp() throws {
188+
func testReport_whenColdStart_shouldSetStartTimeToAppStartTimestamp() throws {
179189
let hub = setUpIntegrationHub()
180190
let measurement = createMeasurement(type: .cold)
181191

@@ -192,7 +202,7 @@ class AppStartReportingStrategyTests: XCTestCase {
192202

193203
/// Verifies the full span tree for a warm non-prewarmed standalone app start transaction.
194204
/// More span edge cases (cold, prewarmed, grouping span) are covered in SentryBuildAppStartSpansTests.
195-
func testSendStandalone_WarmNotPrewarmed_ContainsCorrectSpans() throws {
205+
func testReport_whenWarmNotPrewarmed_shouldContainCorrectSpans() throws {
196206
let hub = setUpIntegrationHub()
197207
let dateProvider = TestCurrentDateProvider()
198208
let appStart = dateProvider.date()
@@ -254,28 +264,28 @@ class AppStartReportingStrategyTests: XCTestCase {
254264

255265
// MARK: - StandaloneAppStartTransactionHelper
256266

257-
func testHelper_ColdStartWithAutoOrigin_ReturnsTrue() {
267+
func testIsStandaloneAppStartTransaction_whenColdStartWithAutoOrigin_shouldReturnTrue() {
258268
XCTAssertTrue(StandaloneAppStartTransactionHelper.isStandaloneAppStartTransaction(
259269
operation: "app.start.cold",
260270
origin: "auto.app.start"
261271
))
262272
}
263273

264-
func testHelper_WarmStartWithAutoOrigin_ReturnsTrue() {
274+
func testIsStandaloneAppStartTransaction_whenWarmStartWithAutoOrigin_shouldReturnTrue() {
265275
XCTAssertTrue(StandaloneAppStartTransactionHelper.isStandaloneAppStartTransaction(
266276
operation: "app.start.warm",
267277
origin: "auto.app.start"
268278
))
269279
}
270280

271-
func testHelper_UILoadWithAutoOrigin_ReturnsFalse() {
281+
func testIsStandaloneAppStartTransaction_whenUILoadWithAutoOrigin_shouldReturnFalse() {
272282
XCTAssertFalse(StandaloneAppStartTransactionHelper.isStandaloneAppStartTransaction(
273283
operation: "ui.load",
274284
origin: "auto.app.start"
275285
))
276286
}
277287

278-
func testHelper_ColdStartWithManualOrigin_ReturnsFalse() {
288+
func testIsStandaloneAppStartTransaction_whenColdStartWithManualOrigin_shouldReturnFalse() {
279289
XCTAssertFalse(StandaloneAppStartTransactionHelper.isStandaloneAppStartTransaction(
280290
operation: "app.start.cold",
281291
origin: "manual"

Tests/SentryTests/Integrations/Performance/AppStartTracking/SentryAppStartMeasurementProviderTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@_spi(Private) @testable import Sentry
22
import XCTest
33

4-
#if os(iOS) || os(tvOS)
4+
#if os(iOS) || os(tvOS) || os(visionOS)
55

66
class SentryAppStartMeasurementProviderTests: XCTestCase {
77

0 commit comments

Comments
 (0)