Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions SentryTestUtils/TestOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@ import Foundation
import Sentry

public extension Options {
@available(*, deprecated)
func setIntegrations(_ integrations: [AnyClass]) {
self.integrations = integrations.map {
NSStringFromClass($0)
}
}

@available(*, deprecated)
func removeAllIntegrations() {
self.integrations = []
enableAutoSessionTracking = false
enableWatchdogTerminationTracking = false
enableAutoPerformanceTracing = false
enableCrashHandler = false
swiftAsyncStacktraces = false
enableAppHangTracking = false
enableNetworkTracking = false
enableNetworkBreadcrumbs = false
enableCaptureFailedRequests = false
enableAutoBreadcrumbTracking = false
#if (os(iOS) || os(tvOS) || (swift(>=5.9) && os(visionOS))) && !SENTRY_NO_UIKIT
attachViewHierarchy = false
enableUIViewControllerTracing = false
#endif
}

@available(*, deprecated)

static func noIntegrations() -> Options {
let options = Options()
options.removeAllIntegrations()
Expand Down
9 changes: 0 additions & 9 deletions Sources/Sentry/Public/SentryOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,6 @@ NS_SWIFT_NAME(Options)
@property (nullable, nonatomic, copy)
SentryOnCrashedLastRunCallback onCrashedLastRun NS_SWIFT_SENDABLE;

#if !SDK_V9
/**
* Array of integrations to install.
*/
@property (nullable, nonatomic, copy) NSArray<NSString *> *integrations DEPRECATED_MSG_ATTRIBUTE(
"Setting `SentryOptions.integrations` is deprecated. Integrations should be enabled or "
"disabled using their respective `SentryOptions.enable*` property.");
#endif // !SDK_V9

/**
* Array of default integrations. Will be used if @c integrations is @c nil .
*/
Expand Down
10 changes: 0 additions & 10 deletions Sources/Sentry/SentryOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ - (instancetype)init
self.debug = NO;
self.maxBreadcrumbs = defaultMaxBreadcrumbs;
self.maxCacheItems = 30;
#if !SDK_V9
_integrations = [SentryOptions defaultIntegrations];
#endif // !SDK_V9
self.sampleRate = SENTRY_DEFAULT_SAMPLE_RATE;
self.enableAutoSessionTracking = YES;
self.enableGraphQLOperationTracking = NO;
Expand Down Expand Up @@ -220,13 +217,6 @@ - (void)setFailedRequestTargets:(NSArray *)failedRequestTargets
_failedRequestTargets = failedRequestTargets;
}

#if !SDK_V9
- (void)setIntegrations:(NSArray<NSString *> *)integrations
{
_integrations = integrations.mutableCopy;
}
#endif // !SDK_V9

- (void)setDsn:(NSString *)dsn
{
NSError *error = nil;
Expand Down
8 changes: 0 additions & 8 deletions Sources/Sentry/SentrySDKInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,7 @@ + (void)installIntegrations
return;
}
SentryOptions *options = [SentrySDKInternal.currentHub getClient].options;
#if SDK_V9
NSMutableArray<NSString *> *integrationNames = [SentryOptions defaultIntegrations].mutableCopy;
#else
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSMutableArray<NSString *> *integrationNames =
[SentrySDKInternal.currentHub getClient].options.integrations.mutableCopy;
# pragma clang diagnostic pop
#endif // SDK_V9

NSArray<Class> *defaultIntegrations = SentryOptionsInternal.defaultIntegrationClasses;

Expand Down
10 changes: 0 additions & 10 deletions Sources/Sentry/SentyOptionsInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,6 @@ + (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
sentryOptions.onCrashedLastRun = options[@"onCrashedLastRun"];
}

#if !SDK_V9
if ([options[@"integrations"] isKindOfClass:[NSArray class]]) {
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
sentryOptions.integrations =
[[options[@"integrations"] filteredArrayUsingPredicate:isNSString] mutableCopy];
# pragma clang diagnstic pop
}
#endif // !SDK_V9

if ([options[@"sampleRate"] isKindOfClass:[NSNumber class]]) {
sentryOptions.sampleRate = options[@"sampleRate"];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SentryProfilingPublicAPITests: XCTestCase {
private class Fixture {
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
let options: Options = {
let options = Options.noIntegrations()
let options = Options()
options.dsn = TestConstants.dsnAsString(username: "SentrySDKTests")
options.releaseName = "1.0.0"
return options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class SentryCoreDataTrackingIntegrationTests: XCTestCase {
options = Options()
options.enableCoreDataTracing = true
options.tracesSampleRate = 1
options.setIntegrations([SentryCoreDataTrackingIntegration.self])
}

func getSut() -> SentryCoreDataTrackingIntegration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class DataSentryTracingIntegrationTests: XCTestCase {
options.dsn = TestConstants.dsnAsString(username: testName)
options.removeAllIntegrations()

options.removeAllIntegrations()
// Configure options required by File I/O tracking integration
options.enableAutoPerformanceTracing = true
options.enableFileIOTracing = isEnabled
options.setIntegrations(isEnabled ? [SentryFileIOTrackingIntegration.self] : [])

// Configure the tracing sample rate to record all traces
options.tracesSampleRate = 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class FileManagerSentryTracingIntegrationTests: XCTestCase {
options.dsn = TestConstants.dsnAsString(username: "FileManagerSentryTracingIntegrationTests")
options.removeAllIntegrations()

options.removeAllIntegrations()
// Configure options required by File I/O tracking integration
options.enableAutoPerformanceTracing = true
options.enableFileIOTracing = isEnabled
options.setIntegrations(isEnabled ? [SentryFileIOTrackingIntegration.self] : [])

// Configure the tracing sample rate to record all traces
options.tracesSampleRate = 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class SentryFileIOTrackingIntegrationTests: XCTestCase {
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func getOptions(enableAutoPerformanceTracing: Bool = true, enableFileIOTracing: Bool = true, enableSwizzling: Bool = true, enableDataSwizzling: Bool = true, enableFileManagerSwizzling: Bool = true, tracesSampleRate: NSNumber = 1) -> Options {
let result = Options()
result.removeAllIntegrations()
result.enableAutoPerformanceTracing = enableAutoPerformanceTracing
result.enableFileIOTracing = enableFileIOTracing
result.enableSwizzling = enableSwizzling
result.tracesSampleRate = tracesSampleRate
result.experimental.enableDataSwizzling = enableDataSwizzling
result.experimental.enableFileManagerSwizzling = enableFileManagerSwizzling
result.setIntegrations([SentryFileIOTrackingIntegration.self])
return result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ class SentryNetworkTrackerIntegrationTests: XCTestCase {
options = Options()
options.dsn = SentryNetworkTrackerIntegrationTests.dsnAsString
options.tracesSampleRate = 1.0
options.setIntegrations([SentryNetworkTrackingIntegration.self])
options.removeAllIntegrations()
options.enableNetworkTracking = true
options.enableNetworkBreadcrumbs = true
options.enableCaptureFailedRequests = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class SentryScreenshotIntegrationTests: XCTestCase {
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func test_attachScreenshot_disabled() {
SentrySDK.start {
$0.removeAllIntegrations()
$0.attachScreenshot = false
$0.setIntegrations([SentryScreenshotIntegration.self])
}
XCTAssertEqual(SentrySDKInternal.currentHub().getClient()?.attachmentProcessors.count, 0)
XCTAssertFalse(sentrycrash_hasSaveScreenshotCallback())
Expand All @@ -54,8 +54,8 @@ class SentryScreenshotIntegrationTests: XCTestCase {
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func test_attachScreenshot_enabled() {
SentrySDK.start {
$0.removeAllIntegrations()
$0.attachScreenshot = true
$0.setIntegrations([SentryScreenshotIntegration.self])
}
XCTAssertEqual(SentrySDKInternal.currentHub().getClient()?.attachmentProcessors.count, 1)
XCTAssertTrue(sentrycrash_hasSaveScreenshotCallback())
Expand All @@ -64,8 +64,8 @@ class SentryScreenshotIntegrationTests: XCTestCase {
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func test_uninstall() {
SentrySDK.start {
$0.removeAllIntegrations()
$0.attachScreenshot = true
$0.setIntegrations([SentryScreenshotIntegration.self])
}
SentrySDK.close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class SentryCrashIntegrationTests: NotificationCenterTestCase {
options.dsn = SentryCrashIntegrationTests.dsnAsString
options.releaseName = releaseName
options.dist = dist
options.setIntegrations([SentryCrashIntegration.self])
options.removeAllIntegrations()
options.enableCrashHandler = true
}

// To test this properly we need SentryCrash and SentryCrashIntegration installed and registered on the current hub of the SDK.
Expand All @@ -114,7 +115,8 @@ class SentryCrashIntegrationTests: NotificationCenterTestCase {
func testContext_IsPassedToSentryCrash() throws {
SentrySDK.start { options in
options.dsn = SentryCrashIntegrationTests.dsnAsString
options.setIntegrations([SentryCrashIntegration.self])
options.removeAllIntegrations()
options.enableCrashHandler = true
}

let userInfo = try XCTUnwrap(SentryDependencyContainer.sharedInstance().crashReporter.userInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SentrySessionGeneratorTests: NotificationCenterTestCase {
override func setUp() {
super.setUp()

options = Options.noIntegrations()
options = Options()
options.dsn = TestConstants.realDSN

options.releaseName = "Release Health"
Expand All @@ -35,9 +35,7 @@ class SentrySessionGeneratorTests: NotificationCenterTestCase {
options.sessionTrackingIntervalMillis = 1

// We want to start and stop the SentryAutoSessionTrackingIntegration ourselves so we can send crashed and abnormal sessions.
options.integrations = Options.defaultIntegrations().filter { (name) -> Bool in
return name != "SentryAutoSessionTrackingIntegration"
}
options.enableAutoSessionTracking = false

fileManager = try! SentryFileManager(
options: options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import XCTest

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

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
class SentrySessionReplayIntegrationTests: XCTestCase {

private var uiApplication: TestSentryUIApplication!
Expand Down Expand Up @@ -54,8 +53,10 @@ class SentrySessionReplayIntegrationTests: XCTestCase {
private func startSDK(sessionSampleRate: Float, errorSampleRate: Float, enableSwizzling: Bool = true, noIntegrations: Bool = false, configure: ((Options) -> Void)? = nil) {
SentrySDK.start {
$0.dsn = "https://[email protected]/test"
$0.sessionReplay = SentryReplayOptions(sessionSampleRate: sessionSampleRate, onErrorSampleRate: errorSampleRate)
$0.setIntegrations(noIntegrations ? [] : [SentrySessionReplayIntegration.self])
$0.removeAllIntegrations()
if !noIntegrations {
$0.sessionReplay = SentryReplayOptions(sessionSampleRate: sessionSampleRate, onErrorSampleRate: errorSampleRate)
}
$0.enableSwizzling = enableSwizzling
$0.cacheDirectoryPath = FileManager.default.temporaryDirectory.path
configure?($0)
Expand Down Expand Up @@ -115,7 +116,6 @@ class SentrySessionReplayIntegrationTests: XCTestCase {

func testInstallErrorReplay() {
startSDK(sessionSampleRate: 0, errorSampleRate: 0.1)

XCTAssertEqual(SentrySDKInternal.currentHub().trimmedInstalledIntegrationNames().count, 1)
XCTAssertEqual(globalEventProcessor.processors.count, 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,38 @@ class SentryViewHierarchyIntegrationTests: XCTestCase {
clearTestState()
}

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func test_attachViewHierarchy() {
SentrySDK.start {
$0.removeAllIntegrations()
$0.attachViewHierarchy = false
$0.setIntegrations([SentryViewHierarchyIntegration.self])
}
XCTAssertEqual(SentrySDKInternal.currentHub().getClient()?.attachmentProcessors.count, 0)
XCTAssertFalse(sentrycrash_hasSaveViewHierarchyCallback())
}

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func test_attachViewHierarchy_enabled() {
SentrySDK.start {
$0.removeAllIntegrations()
$0.attachViewHierarchy = true
$0.setIntegrations([SentryViewHierarchyIntegration.self])
}
XCTAssertEqual(SentrySDKInternal.currentHub().getClient()?.attachmentProcessors.count, 1)
XCTAssertTrue(sentrycrash_hasSaveViewHierarchyCallback())
}

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func test_uninstall() {
SentrySDK.start {
$0.removeAllIntegrations()
$0.attachViewHierarchy = true
$0.setIntegrations([SentryViewHierarchyIntegration.self])
}
SentrySDK.close()
XCTAssertNil(SentrySDKInternal.currentHub().getClient()?.attachmentProcessors)
XCTAssertFalse(sentrycrash_hasSaveViewHierarchyCallback())
}

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func test_integrationAddFileName() {
SentrySDK.start {
$0.removeAllIntegrations()
$0.attachViewHierarchy = true
$0.setIntegrations([SentryViewHierarchyIntegration.self])
}
saveViewHierarchy("/test/path")
XCTAssertEqual("/test/path/view-hierarchy.json", fixture.viewHierarchyProvider.saveFilePathUsed)
Expand Down Expand Up @@ -173,21 +169,19 @@ class SentryViewHierarchyIntegrationTests: XCTestCase {
wait(for: [ex], timeout: 1)
}

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func testReportAccessibilityIdentifierTrue() {
SentrySDK.start {
$0.removeAllIntegrations()
$0.attachViewHierarchy = true
$0.setIntegrations([SentryViewHierarchyIntegration.self])
}
XCTAssertTrue(SentryDependencyContainer.sharedInstance().viewHierarchyProvider.reportAccessibilityIdentifier)
}

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
func testReportAccessibilityIdentifierFalse() {
SentrySDK.start {
$0.removeAllIntegrations()
$0.attachViewHierarchy = true
$0.reportAccessibilityIdentifier = false
$0.setIntegrations([SentryViewHierarchyIntegration.self])
}
XCTAssertFalse(SentryDependencyContainer.sharedInstance().viewHierarchyProvider.reportAccessibilityIdentifier)
}
Expand Down
18 changes: 3 additions & 15 deletions Tests/SentryTests/SentryClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import XCTest
// swiftlint:disable file_length
// We are aware that the client has a lot of logic and we should maybe
// move some of it to other classes.
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
class SentryClientTests: XCTestCase {

private static let dsn = TestConstants.dsnAsString(username: "SentryClientTest")
Expand Down Expand Up @@ -1728,7 +1727,9 @@ class SentryClientTests: XCTestCase {
}

func testSetSDKFeatures() throws {
let sut = fixture.getSut()
let sut = fixture.getSut { options in
options.enableCaptureFailedRequests = true
}

sut.capture(message: "message")

Expand All @@ -1737,18 +1738,6 @@ class SentryClientTests: XCTestCase {
XCTAssert(features.contains("captureFailedRequests"))
}

func testSetSDKIntegrations_NoIntegrations() throws {
let expected: [String] = []

let eventId = fixture.getSut(configureOptions: { options in
options.integrations = expected
}).capture(message: fixture.messageAsString)

eventId.assertIsNotEmpty()
let actual = try lastSentEvent()
assertArrayEquals(expected: expected, actual: actual.sdk?["integrations"] as? [String])
}

func testFileManagerCantBeInit() throws {
try SentryFileManager.prepareInitError()
defer {
Expand Down Expand Up @@ -2243,7 +2232,6 @@ class SentryClientTests: XCTestCase {
}
}

@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
private extension SentryClientTests {
private func givenEventWithDebugMeta() -> Event {
let event = Event(level: SentryLevel.fatal)
Expand Down
Loading
Loading