From a6899a2eedf80ea2bef30989de1ec840d0a5566d Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Tue, 8 Nov 2022 11:04:00 +0100 Subject: [PATCH] feat: Track usage of the enableCaptureFailedRequests option (#2368) --- CHANGELOG.md | 4 ++++ Sources/Sentry/Public/SentryOptions.h | 2 +- Sources/Sentry/SentryClient.m | 4 ++++ Tests/SentryTests/SentryClientTests.swift | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44bff4d10aa..d9d0f986f3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Report usage of enableCaptureFailedRequests (#2368) + ### Fixes - Fix issue with invalid profiles uploading (#2358 and #2359) diff --git a/Sources/Sentry/Public/SentryOptions.h b/Sources/Sentry/Public/SentryOptions.h index efa1537d230..b33eae0e5d7 100644 --- a/Sources/Sentry/Public/SentryOptions.h +++ b/Sources/Sentry/Public/SentryOptions.h @@ -416,7 +416,7 @@ NS_SWIFT_NAME(Options) /** * When enabled, the SDK captures HTTP Client errors. Default value is NO. - * This feature requires enableSwizzling enabled as well, Default value is YES. + * This feature requires enableSwizzling enabled as well, default value is YES. */ @property (nonatomic, assign) BOOL enableCaptureFailedRequests; diff --git a/Sources/Sentry/SentryClient.m b/Sources/Sentry/SentryClient.m index 3f916aa5ba7..6165f843403 100644 --- a/Sources/Sentry/SentryClient.m +++ b/Sources/Sentry/SentryClient.m @@ -654,6 +654,10 @@ - (void)setSdk:(SentryEvent *)event if (self.options.stitchAsyncCode) { [integrations addObject:@"StitchAsyncCode"]; } + + if (self.options.enableCaptureFailedRequests) { + [integrations addObject:@"CaptureFailedRequests"]; + } } event.sdk = @{ diff --git a/Tests/SentryTests/SentryClientTests.swift b/Tests/SentryTests/SentryClientTests.swift index c3e0f5359f2..181ff8d14b5 100644 --- a/Tests/SentryTests/SentryClientTests.swift +++ b/Tests/SentryTests/SentryClientTests.swift @@ -1047,6 +1047,22 @@ class SentryClientTest: XCTestCase { ) } } + + func testTrackEnableCaptureFailedRequests() { + SentrySDK.start(options: Options()) + + let eventId = fixture.getSut(configureOptions: { options in + options.enableCaptureFailedRequests = true + }).capture(message: fixture.messageAsString) + + eventId.assertIsNotEmpty() + assertLastSentEvent { actual in + assertArrayEquals( + expected: ["AutoBreadcrumbTracking", "AutoSessionTracking", "Crash", "NetworkTracking", "CaptureFailedRequests"], + actual: actual.sdk?["integrations"] as? [String] + ) + } + } func testSetSDKIntegrations_NoIntegrations() { let expected: [String] = []