Skip to content

Commit fae97e5

Browse files
authored
ref: Deprecate integrations option (#5749)
1 parent b57ee62 commit fae97e5

30 files changed

+190
-135
lines changed

CHANGELOG-v9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Removes segment property on SentryUser, SentryBaggage, and SentryTraceContext (#
1212
Removes public SentrySerializable conformance from many public models (#5636)
1313
Removes Decodable conformances from the public API of model classes (#5691)
1414
Removes enableTracing property from SentryOptions (#5694)
15+
Removes `integrations` property from `SentryOptions` (#5749)
1516

1617
### Fixes
1718

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Move continuous profiling payload serialization off of the main thread (#5613)
1919
- Improve video generation using apple recommended loop (#5612)
2020
- Use -OSize for release builds (#5721)
21+
- Mark The `integrations` parameter of `SentryOptions` as deprecated rather than printing a warning (#5749)
2122

2223
### Fixes
2324

SentryTestUtils/TestOptions.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ import Foundation
22
import Sentry
33

44
public extension Options {
5+
@available(*, deprecated)
56
func setIntegrations(_ integrations: [AnyClass]) {
67
self.integrations = integrations.map {
78
NSStringFromClass($0)
89
}
910
}
1011

12+
@available(*, deprecated)
1113
func removeAllIntegrations() {
1214
self.integrations = []
1315
}
1416

17+
@available(*, deprecated)
1518
static func noIntegrations() -> Options {
1619
let options = Options()
1720
options.removeAllIntegrations()

Sources/Sentry/Public/SentryOptions.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,14 @@ NS_SWIFT_NAME(Options)
191191
@property (nullable, nonatomic, copy)
192192
SentryOnCrashedLastRunCallback onCrashedLastRun NS_SWIFT_SENDABLE;
193193

194+
#if !SDK_V9
194195
/**
195196
* Array of integrations to install.
196197
*/
197-
@property (nullable, nonatomic, copy) NSArray<NSString *> *integrations;
198+
@property (nullable, nonatomic, copy) NSArray<NSString *> *integrations DEPRECATED_MSG_ATTRIBUTE(
199+
"Setting `SentryOptions.integrations` is deprecated. Integrations should be enabled or "
200+
"disabled using their respective `SentryOptions.enable*` property.");
201+
#endif // !SDK_V9
198202

199203
/**
200204
* Array of default integrations. Will be used if @c integrations is @c nil .

Sources/Sentry/SentryOptions.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ - (instancetype)init
5858
self.debug = NO;
5959
self.maxBreadcrumbs = defaultMaxBreadcrumbs;
6060
self.maxCacheItems = 30;
61+
#if !SDK_V9
6162
_integrations = [SentryOptions defaultIntegrations];
63+
#endif // !SDK_V9
6264
self.sampleRate = SENTRY_DEFAULT_SAMPLE_RATE;
6365
self.enableAutoSessionTracking = YES;
6466
self.enableGraphQLOperationTracking = NO;
@@ -210,13 +212,12 @@ - (void)setFailedRequestTargets:(NSArray *)failedRequestTargets
210212
_failedRequestTargets = failedRequestTargets;
211213
}
212214

215+
#if !SDK_V9
213216
- (void)setIntegrations:(NSArray<NSString *> *)integrations
214217
{
215-
SENTRY_LOG_WARN(
216-
@"Setting `SentryOptions.integrations` is deprecated. Integrations should be enabled or "
217-
@"disabled using their respective `SentryOptions.enable*` property.");
218218
_integrations = integrations.mutableCopy;
219219
}
220+
#endif // !SDK_V9
220221

221222
- (void)setDsn:(NSString *)dsn
222223
{

Sources/Sentry/SentrySDKInternal.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,15 @@ + (void)installIntegrations
560560
return;
561561
}
562562
SentryOptions *options = [SentrySDKInternal.currentHub getClient].options;
563+
#if SDK_V9
564+
NSMutableArray<NSString *> *integrationNames = [SentryOptions defaultIntegrations].mutableCopy;
565+
#else
566+
# pragma clang diagnostic push
567+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
563568
NSMutableArray<NSString *> *integrationNames =
564569
[SentrySDKInternal.currentHub getClient].options.integrations.mutableCopy;
570+
# pragma clang diagnostic pop
571+
#endif // SDK_V9
565572

566573
NSArray<Class> *defaultIntegrations = SentryOptionsInternal.defaultIntegrationClasses;
567574

Sources/Sentry/SentyOptionsInternal.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,15 @@ + (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
196196
sentryOptions.onCrashedLastRun = options[@"onCrashedLastRun"];
197197
}
198198

199+
#if !SDK_V9
199200
if ([options[@"integrations"] isKindOfClass:[NSArray class]]) {
201+
# pragma clang diagnostic push
202+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
200203
sentryOptions.integrations =
201204
[[options[@"integrations"] filteredArrayUsingPredicate:isNSString] mutableCopy];
205+
# pragma clang diagnstic pop
202206
}
207+
#endif // !SDK_V9
203208

204209
if ([options[@"sampleRate"] isKindOfClass:[NSNumber class]]) {
205210
sentryOptions.sampleRate = options[@"sampleRate"];

Tests/SentryProfilerTests/SentryProfilingPublicAPITests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import XCTest
77
// swiftlint:disable file_length
88
class SentryProfilingPublicAPITests: XCTestCase {
99
private class Fixture {
10+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
1011
let options: Options = {
1112
let options = Options.noIntegrations()
1213
options.dsn = TestConstants.dsnAsString(username: "SentrySDKTests")
@@ -35,7 +36,9 @@ class SentryProfilingPublicAPITests: XCTestCase {
3536

3637
let currentDate = TestCurrentDateProvider()
3738
lazy var timerFactory = TestSentryNSTimerFactory(currentDateProvider: currentDate)
39+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
3840
lazy var client = TestClient(options: options)!
41+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
3942
lazy var hub = SentryHub(client: client, andScope: scope)
4043
}
4144

@@ -52,6 +55,7 @@ class SentryProfilingPublicAPITests: XCTestCase {
5255
SentryDependencyContainer.sharedInstance().dateProvider = fixture.currentDate
5356
}
5457

58+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
5559
override func tearDown() {
5660
super.tearDown()
5761

@@ -668,12 +672,14 @@ extension SentryProfilingPublicAPITests {
668672
}
669673

670674
private extension SentryProfilingPublicAPITests {
675+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
671676
func givenSdkWithHub() {
672677
SentrySDKInternal.setCurrentHub(fixture.hub)
673678
SentrySDKInternal.setStart(with: fixture.options)
674679
sentry_sdkInitProfilerTasks(fixture.options, fixture.hub)
675680
}
676681

682+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
677683
func givenSdkWithHubButNoClient() {
678684
SentrySDKInternal.setCurrentHub(SentryHub(client: nil, andScope: nil))
679685
SentrySDKInternal.setStart(with: fixture.options)

Tests/SentryTests/Integrations/Performance/CoreData/SentryCoreDataTrackingIntegrationTest.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class SentryCoreDataTrackingIntegrationTests: XCTestCase {
99
let options: Options
1010
let coreDataStack: TestCoreDataStack
1111

12+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
1213
init(testName: String) {
1314
coreDataStack = TestCoreDataStack(databaseFilename: "db-\(testName.hashValue).sqlite")
1415
options = Options()
@@ -24,6 +25,7 @@ class SentryCoreDataTrackingIntegrationTests: XCTestCase {
2425

2526
private var fixture: Fixture!
2627

28+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
2729
override func setUp() {
2830
super.setUp()
2931
fixture = Fixture(testName: self.name)

Tests/SentryTests/Integrations/Performance/IO/DataSentryTracingIntegrationTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
2020

2121
init() {}
2222

23+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
2324
func getSut(testName: String, isSDKEnabled: Bool = true, isEnabled: Bool = true) throws -> Data {
2425
let fileManager = FileManager.default
2526
let tempDirUrl = URL(fileURLWithPath: NSTemporaryDirectory())
@@ -130,6 +131,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
130131

131132
// MARK: - Data.init(contentsOfWithSentryTracing:)
132133

134+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
133135
func testInitContentsOfWithSentryTracing_shouldTraceManually() throws {
134136
// -- Arrange --
135137
let expectedData = try fixture.getSut(testName: self.name)
@@ -159,6 +161,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
159161
XCTAssertGreaterThan(endTimestamp.timeIntervalSince1970, startTimestamp.timeIntervalSince1970)
160162
}
161163

164+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
162165
func testInitContentsOfWithSentryTracingWithOptions_shouldPassOptionsToSystemImplementation() throws {
163166
// -- Arrange --
164167
let expectedData = try fixture.getSut(testName: self.name)
@@ -186,6 +189,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
186189
XCTAssertEqual(mappedSentryData, expectedData)
187190
}
188191

192+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
189193
func testInitContentsOfWithSentryTracing_throwsError_shouldTraceManuallyWithErrorRethrow() throws {
190194
// -- Arrange --
191195
let _ = try fixture.getSut(testName: self.name)
@@ -212,6 +216,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
212216
XCTAssertGreaterThan(endTimestamp.timeIntervalSince1970, startTimestamp.timeIntervalSince1970)
213217
}
214218

219+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
215220
func testInitContentsOfWithSentryTracing_nonFileUrl_shouldNotTraceManually() throws {
216221
// -- Arrange --
217222
let _ = try fixture.getSut(testName: self.name)
@@ -225,6 +230,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
225230
XCTAssertEqual(parentTransaction.children.count, 0)
226231
}
227232

233+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
228234
func testInitContentsOfWithSentryTracing_trackerIsNotEnabled_shouldNotTraceManually() throws {
229235
// -- Arrange --
230236
let _ = try fixture.getSut(testName: self.name, isEnabled: false)
@@ -238,6 +244,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
238244
XCTAssertEqual(parentTransaction.children.count, 0)
239245
}
240246

247+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
241248
func testInitContentsOfWithSentryTracing_fileIsIgnored_shouldNotTraceManually() throws {
242249
// -- Arrange --
243250
let _ = try fixture.getSut(testName: self.name)
@@ -251,6 +258,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
251258
XCTAssertEqual(parentTransaction.children.count, 0)
252259
}
253260

261+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
254262
func testInitContentsOfWithSentryTracing_SDKIsNotStarted_shouldReadData() throws {
255263
// -- Arrange --
256264
let _ = try fixture.getSut(testName: self.name, isSDKEnabled: false)
@@ -263,6 +271,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
263271
XCTAssertEqual(data, fixture.data)
264272
}
265273

274+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
266275
func testInitContentsOfWithSentryTracing_SDKIsClosed_shouldReadData() throws {
267276
// -- Arrange --
268277
let _ = try fixture.getSut(testName: self.name)
@@ -278,6 +287,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
278287

279288
// MARK: - Data.writeWithSentryTracing(to:)
280289

290+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
281291
func testWriteWithSentryTracing_shouldTraceManuallyWithErrorRethrow() throws {
282292
// -- Arrange --
283293
let sut: Data = try fixture.getSut(testName: self.name)
@@ -313,6 +323,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
313323
XCTAssertGreaterThan(endTimestamp.timeIntervalSince1970, startTimestamp.timeIntervalSince1970)
314324
}
315325

326+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
316327
func testWriteWithSentryTracingWithOptions_shouldPassOptionsToSystemImplementation() throws {
317328
// -- Arrange --
318329
let sut: Data = try fixture.getSut(testName: self.name)
@@ -344,6 +355,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
344355
XCTAssertEqual(writtenData, sut)
345356
}
346357

358+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
347359
func testWriteWithSentryTracing_throwsError_shouldTraceManuallyWithErrorRethrow() throws {
348360
// -- Arrange --
349361
let sut: Data = try fixture.getSut(testName: self.name)
@@ -370,6 +382,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
370382
XCTAssertGreaterThan(endTimestamp.timeIntervalSince1970, startTimestamp.timeIntervalSince1970)
371383
}
372384

385+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
373386
func testWriteWithSentryTracing_nonFileUrl_shouldNotTraceManually() throws {
374387
// -- Arrange --
375388
let sut: Data = try fixture.getSut(testName: self.name)
@@ -382,6 +395,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
382395
XCTAssertEqual(parentTransaction.children.count, 0)
383396
}
384397

398+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
385399
func testWriteWithSentryTracing_trackerIsNotEnabled_shouldNotTraceManually() throws {
386400
// -- Arrange --
387401
let sut: Data = try fixture.getSut(testName: self.name, isEnabled: false)
@@ -394,6 +408,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
394408
XCTAssertEqual(parentTransaction.children.count, 0)
395409
}
396410

411+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
397412
func testWriteWithSentryTracing_fileIsIgnored_shouldNotTraceManually() throws {
398413
// -- Arrange --
399414
let sut: Data = try fixture.getSut(testName: self.name)
@@ -413,6 +428,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
413428
XCTAssertEqual(parentTransaction.children.count, 0)
414429
}
415430

431+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
416432
func testWriteWithSentryTracing_SDKIsNotStarted_shouldWriteFile() throws {
417433
// -- Arrange --
418434
let sut: Data = try fixture.getSut(testName: self.name, isSDKEnabled: false)
@@ -431,6 +447,7 @@ class DataSentryTracingIntegrationTests: XCTestCase {
431447
XCTAssertEqual(writtenData, fixture.data)
432448
}
433449

450+
@available(*, deprecated, message: "This is deprecated because SentryOptions integrations is deprecated")
434451
func testWriteWithSentryTracing_SDKIsClosed_shouldWriteFile() throws {
435452
// -- Arrange --
436453
let sut: Data = try fixture.getSut(testName: self.name)

0 commit comments

Comments
 (0)