From 8dee61fa2adeeb67dfe020a42cdc990e9c724a21 Mon Sep 17 00:00:00 2001 From: Philip Niedertscheider Date: Tue, 25 Feb 2025 14:09:47 +0100 Subject: [PATCH] add more docs, fix casting --- Sources/Swift/Transactions/SentrySpanDataKey.swift | 6 ++++-- .../Swift/Transactions/SentrySpanOperation.swift | 7 +++++-- Sources/Swift/Transactions/SentryTraceOrigin.swift | 13 +++++++++++++ .../SentryProfileTestFixture.swift | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Sources/Swift/Transactions/SentrySpanDataKey.swift b/Sources/Swift/Transactions/SentrySpanDataKey.swift index 0fb9bfd690..fb9694c3c0 100644 --- a/Sources/Swift/Transactions/SentrySpanDataKey.swift +++ b/Sources/Swift/Transactions/SentrySpanDataKey.swift @@ -11,8 +11,10 @@ import Foundation * - Use underscores for word separation * - Follow the format `.` (e.g. `file.size`) * - * See [Sentry SDK development documentation](https://develop.sentry.dev/sdk/telemetry/traces/span-data-conventions/) for - * more information. + * - Remark: As Swift `enum` are not available in Objective-C, it uses a `class` with static properties, marked with `@objc` and `@objcMembers` instead. + * To reduce casting between `String` to `NSString` when using from Objective-C, it uses `NSString` instead of `String`. + * Eventually this should be replaced with a Swift `enum` when Objective-C compatibility is not needed anymore. + * - Note: See [Sentry SDK development documentation](https://develop.sentry.dev/sdk/telemetry/traces/span-data-conventions/) for more information. */ @objcMembers @objc(SentrySpanDataKey) class SentrySpanDataKey: NSObject { diff --git a/Sources/Swift/Transactions/SentrySpanOperation.swift b/Sources/Swift/Transactions/SentrySpanOperation.swift index 98e94818d9..123daf0c69 100644 --- a/Sources/Swift/Transactions/SentrySpanOperation.swift +++ b/Sources/Swift/Transactions/SentrySpanOperation.swift @@ -3,10 +3,13 @@ import Foundation /** * Span operations are short string identifiers that categorize the type of operation a span is measuring. * - * They follow a hierarchical dot notation format (e.g. 'ui.load.initial_display') to group related operations. + * They follow a hierarchical dot notation format (e.g. `ui.load.initial_display`) to group related operations. * These identifiers help organize and analyze performance data across different types of operations. * - * See [Sentry SDK development documentation](https://develop.sentry.dev/sdk/telemetry/traces/span-operations/) for more information. + * - Remark: As Swift `enum` are not available in Objective-C, it uses a `class` with static properties, marked with `@objc` and `@objcMembers` instead. + * To reduce casting between `String` to `NSString` when using from Objective-C, it uses `NSString` instead of `String`. + * Eventually this should be replaced with a Swift `enum` when Objective-C compatibility is not needed anymore. + * - Note: See [Sentry SDK development documentation](https://develop.sentry.dev/sdk/telemetry/traces/span-operations/) for more information. */ @objcMembers @objc(SentrySpanOperation) class SentrySpanOperation: NSObject { diff --git a/Sources/Swift/Transactions/SentryTraceOrigin.swift b/Sources/Swift/Transactions/SentryTraceOrigin.swift index 88aa20b241..134e9be9fd 100644 --- a/Sources/Swift/Transactions/SentryTraceOrigin.swift +++ b/Sources/Swift/Transactions/SentryTraceOrigin.swift @@ -1,5 +1,18 @@ import Foundation +/** + * Trace origin indicates what created a trace or a span + * + * The origin is of type string and consists of four parts: `...`. + * + * Only the first is mandatory. The parts build upon each other, meaning it is forbidden to skip one part. + * For example, you may send parts one and two but aren't allowed to send parts one and three without part two. + * + * - Remark: As Swift `enum` are not available in Objective-C, it uses a `class` with static properties, marked with `@objc` and `@objcMembers` instead. + * To reduce casting between `String` to `NSString` when using from Objective-C, it uses `NSString` instead of `String`. + * Eventually this should be replaced with a Swift `enum` when Objective-C compatibility is not needed anymore. + * - Note: See [Sentry SDK development documenation](https://develop.sentry.dev/sdk/telemetry/traces/trace-origin/) for more information. +*/ @objcMembers @objc(SentryTraceOrigin) class SentryTraceOrigin: NSObject { static let autoAppStart: NSString = "auto.app.start" diff --git a/Tests/SentryProfilerTests/SentryProfileTestFixture.swift b/Tests/SentryProfilerTests/SentryProfileTestFixture.swift index 9d70983dc3..836e0db93e 100644 --- a/Tests/SentryProfilerTests/SentryProfileTestFixture.swift +++ b/Tests/SentryProfilerTests/SentryProfileTestFixture.swift @@ -96,7 +96,7 @@ class SentryProfileTestFixture { /// Advance the mock date provider, start a new transaction and return its handle. func newTransaction(testingAppLaunchSpans: Bool = false, automaticTransaction: Bool = false, idleTimeout: TimeInterval? = nil) throws -> SentryTracer { - let operation = testingAppLaunchSpans ? SentrySpanOperation.uiLoad : transactionOperation + let operation = testingAppLaunchSpans ? SentrySpanOperation.uiLoad as String : transactionOperation if automaticTransaction { return hub.startTransaction(