Skip to content

Commit d0d815e

Browse files
ref: Rename AppStartMeasurementHandler to AppStartReportingStrategy
- Protocol: AppStartMeasurementHandler → AppStartReportingStrategy - AttachAppStartMeasurementHandler → AttachToTransactionStrategy - SendStandaloneAppStartTransaction → StandaloneTransactionStrategy - Method: handle() → report() - Variable: measurementHandler → reportingStrategy
1 parent 4819275 commit d0d815e

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

Sources/Swift/Integrations/AppStartTracking/AppStartMeasurementHandler.swift renamed to Sources/Swift/Integrations/AppStartTracking/AppStartReportingStrategy.swift

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

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

5-
protocol AppStartMeasurementHandler {
6-
func handle(_ measurement: SentryAppStartMeasurement)
5+
protocol AppStartReportingStrategy {
6+
func report(_ measurement: SentryAppStartMeasurement)
77
}
88

99
/// Attaches app start data to the first UIViewController transaction (default behavior).
10-
struct AttachAppStartMeasurementHandler: AppStartMeasurementHandler {
11-
func handle(_ measurement: SentryAppStartMeasurement) {
10+
struct AttachToTransactionStrategy: AppStartReportingStrategy {
11+
func report(_ measurement: SentryAppStartMeasurement) {
1212
SentrySDKInternal.setAppStartMeasurement(measurement)
1313
}
1414
}
1515

1616
/// Sends a standalone app start transaction by passing the measurement directly via the tracer
1717
/// configuration. The existing tracer pipeline then handles span building, measurements, context,
1818
/// debug images, and profiling.
19-
struct SendStandaloneAppStartTransaction: AppStartMeasurementHandler {
20-
func handle(_ measurement: SentryAppStartMeasurement) {
19+
struct StandaloneTransactionStrategy: AppStartReportingStrategy {
20+
func report(_ measurement: SentryAppStartMeasurement) {
2121
guard SentrySDK.isEnabled else {
2222
SentrySDKLog.warning("SDK is not enabled, dropping standalone app start transaction")
2323
return

Sources/Swift/Integrations/AppStartTracking/SentryAppStartTracker.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public final class SentryAppStartTracker: NSObject, SentryFramesTrackerListener
3333
let appStateManager: SentryAppStateManager
3434
private let framesTracker: SentryFramesTracker
3535
private let enablePreWarmedAppStartTracing: Bool
36-
private let measurementHandler: AppStartMeasurementHandler
36+
private let reportingStrategy: AppStartReportingStrategy
3737

3838
private var previousAppState: SentryAppState?
3939
private var wasInBackground = false
@@ -62,9 +62,9 @@ public final class SentryAppStartTracker: NSObject, SentryFramesTrackerListener
6262
self.appStateManager = appStateManager
6363
self.framesTracker = framesTracker
6464
self.enablePreWarmedAppStartTracing = enablePreWarmedAppStartTracing
65-
self.measurementHandler = enableStandaloneAppStartTracing
66-
? SendStandaloneAppStartTransaction()
67-
: AttachAppStartMeasurementHandler()
65+
self.reportingStrategy = enableStandaloneAppStartTracing
66+
? StandaloneTransactionStrategy()
67+
: AttachToTransactionStrategy()
6868
self.previousAppState = appStateManager.loadPreviousAppState()
6969
self.dateProvider = dateProvider
7070
self.didFinishLaunchingTimestamp = dateProvider.date()
@@ -235,7 +235,7 @@ public final class SentryAppStartTracker: NSObject, SentryFramesTrackerListener
235235
didFinishLaunchingTimestamp: finalDidFinishLaunchingTimestamp
236236
)
237237

238-
self.measurementHandler.handle(appStartMeasurement)
238+
self.reportingStrategy.report(appStartMeasurement)
239239
}
240240

241241
// With only running this once we know that the process is a new one when the following

Tests/SentryTests/Integrations/Performance/AppStartTracking/AppStartMeasurementHandlerTests.swift renamed to Tests/SentryTests/Integrations/Performance/AppStartTracking/AppStartReportingStrategyTests.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import XCTest
44

55
#if os(iOS) || os(tvOS)
66

7-
class AppStartMeasurementHandlerTests: XCTestCase {
7+
class AppStartReportingStrategyTests: XCTestCase {
88

99
override func tearDown() {
1010
super.tearDown()
@@ -31,18 +31,18 @@ class AppStartMeasurementHandlerTests: XCTestCase {
3131

3232
private func createHub() -> TestHub {
3333
let options = Options()
34-
options.dsn = TestConstants.dsnAsString(username: "AppStartMeasurementHandlerTests")
34+
options.dsn = TestConstants.dsnAsString(username: "AppStartReportingStrategyTests")
3535
options.tracesSampleRate = 1
3636
let client = TestClient(options: options)
3737
return TestHub(client: client, andScope: Scope())
3838
}
3939

40-
// MARK: - AttachAppStartMeasurementHandler
40+
// MARK: - AttachToTransactionStrategy
4141

4242
func testAttach_SetsMeasurementOnGlobalStatic() throws {
4343
let measurement = createMeasurement(type: .cold)
4444

45-
AttachAppStartMeasurementHandler().handle(measurement)
45+
AttachToTransactionStrategy().report(measurement)
4646

4747
let stored = try XCTUnwrap(SentrySDKInternal.getAppStartMeasurement())
4848
XCTAssertEqual(stored.type, .cold)
@@ -52,20 +52,20 @@ class AppStartMeasurementHandlerTests: XCTestCase {
5252
func testAttach_WarmStart_SetsMeasurementOnGlobalStatic() throws {
5353
let measurement = createMeasurement(type: .warm)
5454

55-
AttachAppStartMeasurementHandler().handle(measurement)
55+
AttachToTransactionStrategy().report(measurement)
5656

5757
let stored = try XCTUnwrap(SentrySDKInternal.getAppStartMeasurement())
5858
XCTAssertEqual(stored.type, .warm)
5959
}
6060

61-
// MARK: - SendStandaloneAppStartTransaction
61+
// MARK: - StandaloneTransactionStrategy
6262

6363
func testSendStandalone_SDKNotEnabled_DoesNotCaptureTransaction() {
6464
let hub = createHub()
6565
// Don't set hub on SDK — isEnabled returns false
6666
let measurement = createMeasurement(type: .cold)
6767

68-
SendStandaloneAppStartTransaction().handle(measurement)
68+
StandaloneTransactionStrategy().report(measurement)
6969

7070
XCTAssertTrue(hub.capturedEventsWithScopes.invocations.isEmpty)
7171
}
@@ -75,7 +75,7 @@ class AppStartMeasurementHandlerTests: XCTestCase {
7575
SentrySDKInternal.setCurrentHub(hub)
7676
let measurement = createMeasurement(type: .cold)
7777

78-
SendStandaloneAppStartTransaction().handle(measurement)
78+
StandaloneTransactionStrategy().report(measurement)
7979

8080
let serialized = try XCTUnwrap(hub.capturedTransactionsWithScope.invocations.first?.transaction)
8181
XCTAssertEqual(serialized["transaction"] as? String, "App Start Cold")
@@ -91,7 +91,7 @@ class AppStartMeasurementHandlerTests: XCTestCase {
9191
SentrySDKInternal.setCurrentHub(hub)
9292
let measurement = createMeasurement(type: .warm)
9393

94-
SendStandaloneAppStartTransaction().handle(measurement)
94+
StandaloneTransactionStrategy().report(measurement)
9595

9696
let serialized = try XCTUnwrap(hub.capturedTransactionsWithScope.invocations.first?.transaction)
9797
XCTAssertEqual(serialized["transaction"] as? String, "App Start Warm")
@@ -106,12 +106,12 @@ class AppStartMeasurementHandlerTests: XCTestCase {
106106
SentrySDKInternal.setCurrentHub(hub)
107107
let measurement = createMeasurement(type: .cold)
108108

109-
SendStandaloneAppStartTransaction().handle(measurement)
109+
StandaloneTransactionStrategy().report(measurement)
110110

111111
XCTAssertNil(SentrySDKInternal.getAppStartMeasurement())
112112
}
113113

114-
// MARK: - SendStandaloneAppStartTransaction Integration Tests
114+
// MARK: - StandaloneTransactionStrategy Integration Tests
115115

116116
private func setUpIntegrationHub() -> TestHub {
117117
let dateProvider = TestCurrentDateProvider()
@@ -127,7 +127,7 @@ class AppStartMeasurementHandlerTests: XCTestCase {
127127
displayLinkWrapper.call()
128128

129129
let options = Options()
130-
options.dsn = TestConstants.dsnAsString(username: "AppStartMeasurementHandlerTests")
130+
options.dsn = TestConstants.dsnAsString(username: "AppStartReportingStrategyTests")
131131
options.tracesSampleRate = 1
132132
let client = TestClient(options: options)
133133
let hub = TestHub(client: client, andScope: Scope())
@@ -139,7 +139,7 @@ class AppStartMeasurementHandlerTests: XCTestCase {
139139
let hub = setUpIntegrationHub()
140140
let measurement = createMeasurement(type: .cold, duration: 0.5)
141141

142-
SendStandaloneAppStartTransaction().handle(measurement)
142+
StandaloneTransactionStrategy().report(measurement)
143143

144144
let serialized = try XCTUnwrap(hub.capturedTransactionsWithScope.invocations.first?.transaction)
145145
let measurements = try XCTUnwrap(serialized["measurements"] as? [String: Any])
@@ -151,7 +151,7 @@ class AppStartMeasurementHandlerTests: XCTestCase {
151151
let hub = setUpIntegrationHub()
152152
let measurement = createMeasurement(type: .warm, duration: 0.3)
153153

154-
SendStandaloneAppStartTransaction().handle(measurement)
154+
StandaloneTransactionStrategy().report(measurement)
155155

156156
let serialized = try XCTUnwrap(hub.capturedTransactionsWithScope.invocations.first?.transaction)
157157
let measurements = try XCTUnwrap(serialized["measurements"] as? [String: Any])
@@ -163,7 +163,7 @@ class AppStartMeasurementHandlerTests: XCTestCase {
163163
let hub = setUpIntegrationHub()
164164
let measurement = createMeasurement(type: .cold)
165165

166-
SendStandaloneAppStartTransaction().handle(measurement)
166+
StandaloneTransactionStrategy().report(measurement)
167167

168168
let serialized = try XCTUnwrap(hub.capturedTransactionsWithScope.invocations.first?.transaction)
169169
let debugMeta = try XCTUnwrap(serialized["debug_meta"] as? [String: Any])
@@ -179,7 +179,7 @@ class AppStartMeasurementHandlerTests: XCTestCase {
179179
let hub = setUpIntegrationHub()
180180
let measurement = createMeasurement(type: .cold)
181181

182-
SendStandaloneAppStartTransaction().handle(measurement)
182+
StandaloneTransactionStrategy().report(measurement)
183183

184184
let serialized = try XCTUnwrap(hub.capturedTransactionsWithScope.invocations.first?.transaction)
185185
let startTimestamp = try XCTUnwrap(serialized["start_timestamp"] as? TimeInterval)
@@ -208,7 +208,7 @@ class AppStartMeasurementHandlerTests: XCTestCase {
208208
didFinishLaunchingTimestamp: appStart.addingTimeInterval(0.3)
209209
)
210210

211-
SendStandaloneAppStartTransaction().handle(measurement)
211+
StandaloneTransactionStrategy().report(measurement)
212212

213213
let serialized = try XCTUnwrap(hub.capturedTransactionsWithScope.invocations.first?.transaction)
214214
let spans = try XCTUnwrap(serialized["spans"] as? [[String: Any]])

0 commit comments

Comments
 (0)