-
-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
impr: Send Cocoa SDK features (#3948)
Send enabled SDK features with the event payload, so we can track their adoption in Looker.
- Loading branch information
1 parent
7bdf989
commit 1267cb0
Showing
7 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import Foundation | ||
|
||
@objcMembers class SentryEnabledFeaturesBuilder: NSObject { | ||
|
||
static func getEnabledFeatures(options: Options) -> [String] { | ||
|
||
var features: [String] = [] | ||
|
||
if options.enableCaptureFailedRequests { | ||
features.append("captureFailedRequests") | ||
} | ||
|
||
if options.enablePerformanceV2 { | ||
features.append("performanceV2") | ||
} | ||
|
||
if options.enableTimeToFullDisplayTracing { | ||
features.append("timeToFullDisplayTracing") | ||
} | ||
|
||
#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) | ||
if options.enableAppLaunchProfiling { | ||
features.append("appLaunchProfiling") | ||
} | ||
#endif // os(iOS) || os(macOS) || targetEnvironment(macCatalyst) | ||
|
||
#if os(iOS) || os(tvOS) | ||
#if canImport(UIKit) && !SENTRY_NO_UIKIT | ||
if options.enablePreWarmedAppStartTracing { | ||
features.append("preWarmedAppStartTracing") | ||
} | ||
#endif // canImport(UIKit) | ||
#endif // os(iOS) || os(tvOS) | ||
|
||
if options.swiftAsyncStacktraces { | ||
features.append("swiftAsyncStacktraces") | ||
} | ||
|
||
if options.enableMetrics { | ||
features.append("metrics") | ||
} | ||
|
||
return features | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
Tests/SentryTests/Helper/SentryEnabledFeaturesBuilderTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import Nimble | ||
@testable import Sentry | ||
import XCTest | ||
|
||
final class SentryEnabledFeaturesBuilderTests: XCTestCase { | ||
|
||
func testDefaultFeatures() throws { | ||
let features = SentryEnabledFeaturesBuilder.getEnabledFeatures(options: Options()) | ||
|
||
expect(features) == ["captureFailedRequests"] | ||
} | ||
|
||
func testEnableAllFeatures() throws { | ||
|
||
let options = Options() | ||
options.enablePerformanceV2 = true | ||
options.enableTimeToFullDisplayTracing = true | ||
options.swiftAsyncStacktraces = true | ||
options.enableMetrics = true | ||
|
||
#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) | ||
options.enableAppLaunchProfiling = true | ||
#endif // os(iOS) || os(macOS) || targetEnvironment(macCatalyst) | ||
|
||
#if os(iOS) || os(tvOS) | ||
#if canImport(UIKit) && !SENTRY_NO_UIKIT | ||
options.enablePreWarmedAppStartTracing = true | ||
#endif // canImport(UIKit) | ||
#endif // os(iOS) || os(tvOS) | ||
|
||
let features = SentryEnabledFeaturesBuilder.getEnabledFeatures(options: options) | ||
|
||
expect(features).to(contain([ | ||
"captureFailedRequests", | ||
"performanceV2", | ||
"timeToFullDisplayTracing", | ||
"swiftAsyncStacktraces", | ||
"metrics" | ||
])) | ||
|
||
#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst) | ||
expect(features).to(contain(["appLaunchProfiling"])) | ||
#endif // os(iOS) || os(macOS) || targetEnvironment(macCatalyst) | ||
|
||
#if os(iOS) || os(tvOS) | ||
#if canImport(UIKit) && !SENTRY_NO_UIKIT | ||
expect(features).to(contain([ | ||
"preWarmedAppStartTracing" | ||
])) | ||
#endif // canImport(UIKit) | ||
#endif // os(iOS) || os(tvOS) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters