Skip to content

Commit 68094b3

Browse files
ref: Remove - [SentryOptions initWithDict:didFailWithError:] (#2404)
1 parent dcac8ad commit 68094b3

File tree

15 files changed

+55
-1178
lines changed

15 files changed

+55
-1178
lines changed

CHANGELOG.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
This version adds a dependency on Swift.
66

7-
### Breaking Changes
8-
9-
- Mark `- [SpanProtocol setExtraValue:forKey:]` as deprecated (#2413)
10-
117
### Features
128

139
- Properly demangle Swift class name (#2162)
1410

11+
### Breaking Changes
12+
13+
- Remove `- [SentryOptions initWithDict:didFailWithError:]` (#2404)
14+
- Rename `- [SentrySDK startWithOptionsObject:]` to `- [SentrySDK startWithOptions:]` (#2404)
15+
- Remove `- [SentryOptions sdkInfo]` (#2404)
16+
- Mark `- [SpanProtocol setExtraValue:forKey:]` as deprecated (#2413)
17+
1518
## 7.31.2
1619

1720
### Fixes

Sentry.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
03F84D3827DD4191008FE43F /* SentryBacktrace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F84D3127DD4191008FE43F /* SentryBacktrace.cpp */; };
3939
03F9D37C2819A65C00602916 /* SentryProfilerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03F9D37B2819A65C00602916 /* SentryProfilerTests.mm */; };
4040
0A1B497328E597DD00D7BFA3 /* TestLogOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1B497228E597DD00D7BFA3 /* TestLogOutput.swift */; };
41-
0A1C3592287D7107007D01E3 /* SentryMetaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1C3591287D7107007D01E3 /* SentryMetaTests.swift */; };
4241
0A2690B72885C2E000E4432D /* TestSentryPermissionsObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AABE2EF2885C2120057ED69 /* TestSentryPermissionsObserver.swift */; };
4342
0A283E79291A67E000EF4126 /* SentryUIDeviceWrapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A283E78291A67E000EF4126 /* SentryUIDeviceWrapperTests.swift */; };
4443
0A2D7BBA29152CBF008727AF /* SentryOutOfMemoryScopeObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A2D7BB929152CBF008727AF /* SentryOutOfMemoryScopeObserverTests.swift */; };
@@ -789,7 +788,6 @@
789788
03F84D3127DD4191008FE43F /* SentryBacktrace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SentryBacktrace.cpp; path = Sources/Sentry/SentryBacktrace.cpp; sourceTree = SOURCE_ROOT; };
790789
03F9D37B2819A65C00602916 /* SentryProfilerTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryProfilerTests.mm; sourceTree = "<group>"; };
791790
0A1B497228E597DD00D7BFA3 /* TestLogOutput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestLogOutput.swift; sourceTree = "<group>"; };
792-
0A1C3591287D7107007D01E3 /* SentryMetaTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMetaTests.swift; sourceTree = "<group>"; };
793791
0A283E78291A67E000EF4126 /* SentryUIDeviceWrapperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIDeviceWrapperTests.swift; sourceTree = "<group>"; };
794792
0A2D7BB929152CBF008727AF /* SentryOutOfMemoryScopeObserverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryOutOfMemoryScopeObserverTests.swift; sourceTree = "<group>"; };
795793
0A2D8D5A289815C0008720F6 /* SentryBaseIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryBaseIntegration.m; sourceTree = "<group>"; };
@@ -1971,7 +1969,6 @@
19711969
630C01931EC3402C00C52CEF /* SentryKSCrashReportConverterTests.m */,
19721970
63B819131EC352A7002FDF4C /* SentryInterfacesTests.m */,
19731971
63EED6C22237989300E02400 /* SentryOptionsTest.m */,
1974-
0A1C3591287D7107007D01E3 /* SentryMetaTests.swift */,
19751972
632331F52404FFA8008D91D6 /* SentryScopeTests.m */,
19761973
7B569DFE2590EEF600B653FC /* SentryScope+Equality.h */,
19771974
7B569DFF2590EEF600B653FC /* SentryScope+Equality.m */,
@@ -3737,7 +3734,6 @@
37373734
7BBD18992449DE9D00427C76 /* TestRateLimits.swift in Sources */,
37383735
8E4A038625F76A7600000D77 /* TypeMapping.swift in Sources */,
37393736
7B04A9AB24EA5F8D00E710B1 /* SentryUserTests.swift in Sources */,
3740-
0A1C3592287D7107007D01E3 /* SentryMetaTests.swift in Sources */,
37413737
7BA61CCF247EB59500C130A8 /* SentryCrashUUIDConversionTests.swift in Sources */,
37423738
7BBD188D2448453600427C76 /* SentryHttpDateParserTests.swift in Sources */,
37433739
7B72D23A28D074BC0014798A /* TestExtensions.swift in Sources */,

Sources/Sentry/Public/SentryOptions.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@
33

44
NS_ASSUME_NONNULL_BEGIN
55

6-
@class SentryDsn, SentrySdkInfo, SentryMeasurementValue, SentryHttpStatusCodeRange;
6+
@class SentryDsn, SentryMeasurementValue, SentryHttpStatusCodeRange;
77

88
NS_SWIFT_NAME(Options)
99
@interface SentryOptions : NSObject
1010

11-
/**
12-
* Init SentryOptions.
13-
* @param options Options dictionary
14-
* @return SentryOptions
15-
*/
16-
- (_Nullable instancetype)initWithDict:(NSDictionary<NSString *, id> *)options
17-
didFailWithError:(NSError *_Nullable *_Nullable)error;
11+
- (_Nullable instancetype)initWithDsn:(NSString *)dsn
12+
didFailWithError:(NSError *_Nullable *_Nullable)error;
1813

1914
/**
2015
* The DSN tells the SDK where to send the events to. If this value is not provided, the SDK will
@@ -164,13 +159,6 @@ NS_SWIFT_NAME(Options)
164159
*/
165160
@property (nonatomic, assign) BOOL stitchAsyncCode;
166161

167-
/**
168-
* Describes the Sentry SDK and its configuration used to capture and transmit an event.
169-
* This is reserved for internal use, and will be removed in a future version of the SDK.
170-
*/
171-
@property (nonatomic, readonly, strong) SentrySdkInfo *sdkInfo DEPRECATED_MSG_ATTRIBUTE(
172-
"This property will be removed in a future version of the SDK");
173-
174162
/**
175163
* The maximum size for each attachment in bytes. Default is 20 MiB / 20 * 1024 * 1024 bytes.
176164
*

Sources/Sentry/Public/SentrySDK.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,10 @@ SENTRY_NO_INIT
2626
@property (class, nonatomic, readonly) BOOL isEnabled;
2727

2828
/**
29-
* Inits and configures Sentry (SentryHub, SentryClient) and sets up all integrations.
30-
*/
31-
+ (void)startWithOptions:(NSDictionary<NSString *, id> *)optionsDict NS_SWIFT_NAME(start(options:));
32-
33-
/**
34-
* Inits and configures Sentry (SentryHub, SentryClient) and sets up all integrations.
29+
* Inits and configures Sentry (SentryHub, SentryClient) and sets up all integrations. Make sure to
30+
* set a valid DSN.
3531
*/
36-
+ (void)startWithOptionsObject:(SentryOptions *)options NS_SWIFT_NAME(start(options:));
32+
+ (void)startWithOptions:(SentryOptions *)options NS_SWIFT_NAME(start(options:));
3733

3834
/**
3935
* Inits and configures Sentry (SentryHub, SentryClient) and sets up all integrations. Make sure to

Sources/Sentry/SentryClient.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#import "SentryPermissionsObserver.h"
3434
#import "SentrySDK+Private.h"
3535
#import "SentryScope+Private.h"
36-
#import "SentrySdkInfo.h"
3736
#import "SentryStacktraceBuilder.h"
3837
#import "SentryThreadInspector.h"
3938
#import "SentryTraceContext.h"

Sources/Sentry/SentryOptions.m

Lines changed: 6 additions & 238 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#import "SentryLog.h"
77
#import "SentryMeta.h"
88
#import "SentrySDK.h"
9-
#import "SentrySdkInfo.h"
109

1110
@interface
1211
SentryOptions ()
@@ -131,14 +130,14 @@ - (instancetype)init
131130
return self;
132131
}
133132

134-
- (_Nullable instancetype)initWithDict:(NSDictionary<NSString *, id> *)options
135-
didFailWithError:(NSError *_Nullable *_Nullable)error
133+
- (_Nullable instancetype)initWithDsn:(NSString *)dsn
134+
didFailWithError:(NSError *_Nullable *_Nullable)error
136135
{
137136
if (self = [self init]) {
138-
if (![self validateOptions:options didFailWithError:error]) {
139-
[SentryLog
140-
logWithMessage:[NSString stringWithFormat:@"Failed to initialize: %@", *error]
141-
andLevel:kSentryLevelError];
137+
self.parsedDsn = [[SentryDsn alloc] initWithString:dsn didFailWithError:error];
138+
self.dsn = dsn;
139+
140+
if (error != nil && *error != nil) {
142141
return nil;
143142
}
144143
}
@@ -191,237 +190,6 @@ - (void)setDsn:(NSString *)dsn
191190
}
192191
}
193192

194-
/**
195-
* Populates all `SentryOptions` values from `options` dict using fallbacks/defaults if needed.
196-
*/
197-
- (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
198-
didFailWithError:(NSError *_Nullable *_Nullable)error
199-
{
200-
NSPredicate *isNSString = [NSPredicate predicateWithBlock:^BOOL(
201-
id object, NSDictionary *bindings) { return [object isKindOfClass:[NSString class]]; }];
202-
203-
[self setBool:options[@"debug"] block:^(BOOL value) { self->_debug = value; }];
204-
205-
if ([options[@"diagnosticLevel"] isKindOfClass:[NSString class]]) {
206-
for (SentryLevel level = 0; level <= kSentryLevelFatal; level++) {
207-
if ([nameForSentryLevel(level) isEqualToString:options[@"diagnosticLevel"]]) {
208-
self.diagnosticLevel = level;
209-
break;
210-
}
211-
}
212-
}
213-
214-
NSString *dsn = @"";
215-
if (nil != options[@"dsn"] && [options[@"dsn"] isKindOfClass:[NSString class]]) {
216-
dsn = options[@"dsn"];
217-
}
218-
219-
self.parsedDsn = [[SentryDsn alloc] initWithString:dsn didFailWithError:error];
220-
221-
if ([options[@"release"] isKindOfClass:[NSString class]]) {
222-
self.releaseName = options[@"release"];
223-
}
224-
225-
if ([options[@"environment"] isKindOfClass:[NSString class]]) {
226-
self.environment = options[@"environment"];
227-
}
228-
229-
if ([options[@"dist"] isKindOfClass:[NSString class]]) {
230-
self.dist = options[@"dist"];
231-
}
232-
233-
[self setBool:options[@"enabled"] block:^(BOOL value) { self->_enabled = value; }];
234-
235-
[self setBool:options[@"enableCrashHandler"]
236-
block:^(BOOL value) { self->_enableCrashHandler = value; }];
237-
238-
if ([options[@"maxBreadcrumbs"] isKindOfClass:[NSNumber class]]) {
239-
self.maxBreadcrumbs = [options[@"maxBreadcrumbs"] unsignedIntValue];
240-
}
241-
242-
[self setBool:options[@"enableNetworkBreadcrumbs"]
243-
block:^(BOOL value) { self->_enableNetworkBreadcrumbs = value; }];
244-
245-
if ([options[@"maxCacheItems"] isKindOfClass:[NSNumber class]]) {
246-
self.maxCacheItems = [options[@"maxCacheItems"] unsignedIntValue];
247-
}
248-
249-
if ([self isBlock:options[@"beforeSend"]]) {
250-
self.beforeSend = options[@"beforeSend"];
251-
}
252-
253-
if ([self isBlock:options[@"beforeBreadcrumb"]]) {
254-
self.beforeBreadcrumb = options[@"beforeBreadcrumb"];
255-
}
256-
257-
if ([self isBlock:options[@"onCrashedLastRun"]]) {
258-
self.onCrashedLastRun = options[@"onCrashedLastRun"];
259-
}
260-
261-
if ([options[@"integrations"] isKindOfClass:[NSArray class]]) {
262-
self.integrations = [options[@"integrations"] filteredArrayUsingPredicate:isNSString];
263-
}
264-
265-
if ([options[@"sampleRate"] isKindOfClass:[NSNumber class]]) {
266-
self.sampleRate = options[@"sampleRate"];
267-
}
268-
269-
[self setBool:options[@"enableAutoSessionTracking"]
270-
block:^(BOOL value) { self->_enableAutoSessionTracking = value; }];
271-
272-
[self setBool:options[@"enableOutOfMemoryTracking"]
273-
block:^(BOOL value) { self->_enableOutOfMemoryTracking = value; }];
274-
275-
if ([options[@"sessionTrackingIntervalMillis"] isKindOfClass:[NSNumber class]]) {
276-
self.sessionTrackingIntervalMillis =
277-
[options[@"sessionTrackingIntervalMillis"] unsignedIntValue];
278-
}
279-
280-
[self setBool:options[@"attachStacktrace"]
281-
block:^(BOOL value) { self->_attachStacktrace = value; }];
282-
283-
[self setBool:options[@"stitchAsyncCode"]
284-
block:^(BOOL value) { self->_stitchAsyncCode = value; }];
285-
286-
if ([options[@"maxAttachmentSize"] isKindOfClass:[NSNumber class]]) {
287-
self.maxAttachmentSize = [options[@"maxAttachmentSize"] unsignedIntValue];
288-
}
289-
290-
[self setBool:options[@"sendDefaultPii"]
291-
block:^(BOOL value) { self->_sendDefaultPii = value; }];
292-
293-
[self setBool:options[@"enableAutoPerformanceTracking"]
294-
block:^(BOOL value) { self->_enableAutoPerformanceTracking = value; }];
295-
296-
[self setBool:options[@"enableCaptureFailedRequests"]
297-
block:^(BOOL value) { self->_enableCaptureFailedRequests = value; }];
298-
299-
#if SENTRY_HAS_UIKIT
300-
[self setBool:options[@"enableUIViewControllerTracking"]
301-
block:^(BOOL value) { self->_enableUIViewControllerTracking = value; }];
302-
303-
[self setBool:options[@"attachScreenshot"]
304-
block:^(BOOL value) { self->_attachScreenshot = value; }];
305-
306-
[self setBool:options[@"attachViewHierarchy"]
307-
block:^(BOOL value) { self->_attachViewHierarchy = value; }];
308-
309-
[self setBool:options[@"enableUserInteractionTracing"]
310-
block:^(BOOL value) { self->_enableUserInteractionTracing = value; }];
311-
312-
if ([options[@"idleTimeout"] isKindOfClass:[NSNumber class]]) {
313-
self.idleTimeout = [options[@"idleTimeout"] doubleValue];
314-
}
315-
316-
[self setBool:options[@"enablePreWarmedAppStartTracking"]
317-
block:^(BOOL value) { self->_enablePreWarmedAppStartTracking = value; }];
318-
#endif
319-
320-
[self setBool:options[@"enableAppHangTracking"]
321-
block:^(BOOL value) { self->_enableAppHangTracking = value; }];
322-
323-
if ([options[@"appHangTimeoutInterval"] isKindOfClass:[NSNumber class]]) {
324-
self.appHangTimeoutInterval = [options[@"appHangTimeoutInterval"] doubleValue];
325-
}
326-
327-
[self setBool:options[@"enableNetworkTracking"]
328-
block:^(BOOL value) { self->_enableNetworkTracking = value; }];
329-
330-
[self setBool:options[@"enableFileIOTracking"]
331-
block:^(BOOL value) { self->_enableFileIOTracking = value; }];
332-
333-
if ([options[@"tracesSampleRate"] isKindOfClass:[NSNumber class]]) {
334-
self.tracesSampleRate = options[@"tracesSampleRate"];
335-
}
336-
337-
if ([self isBlock:options[@"tracesSampler"]]) {
338-
self.tracesSampler = options[@"tracesSampler"];
339-
}
340-
341-
if ([options[@"inAppIncludes"] isKindOfClass:[NSArray class]]) {
342-
NSArray<NSString *> *inAppIncludes =
343-
[options[@"inAppIncludes"] filteredArrayUsingPredicate:isNSString];
344-
_inAppIncludes = [_inAppIncludes arrayByAddingObjectsFromArray:inAppIncludes];
345-
}
346-
347-
if ([options[@"inAppExcludes"] isKindOfClass:[NSArray class]]) {
348-
_inAppExcludes = [options[@"inAppExcludes"] filteredArrayUsingPredicate:isNSString];
349-
}
350-
351-
if ([options[@"urlSessionDelegate"] conformsToProtocol:@protocol(NSURLSessionDelegate)]) {
352-
self.urlSessionDelegate = options[@"urlSessionDelegate"];
353-
}
354-
355-
[self setBool:options[@"enableSwizzling"]
356-
block:^(BOOL value) { self->_enableSwizzling = value; }];
357-
358-
[self setBool:options[@"enableCoreDataTracking"]
359-
block:^(BOOL value) { self->_enableCoreDataTracking = value; }];
360-
361-
#if SENTRY_TARGET_PROFILING_SUPPORTED
362-
if ([options[@"profilesSampleRate"] isKindOfClass:[NSNumber class]]) {
363-
self.profilesSampleRate = options[@"profilesSampleRate"];
364-
}
365-
366-
if ([self isBlock:options[@"profilesSampler"]]) {
367-
self.profilesSampler = options[@"profilesSampler"];
368-
}
369-
370-
[self setBool:options[@"enableProfiling"]
371-
block:^(BOOL value) { self->_enableProfiling = value; }];
372-
#endif
373-
374-
[self setBool:options[@"sendClientReports"]
375-
block:^(BOOL value) { self->_sendClientReports = value; }];
376-
377-
[self setBool:options[@"enableAutoBreadcrumbTracking"]
378-
block:^(BOOL value) { self->_enableAutoBreadcrumbTracking = value; }];
379-
380-
if ([options[@"tracePropagationTargets"] isKindOfClass:[NSArray class]]) {
381-
self.tracePropagationTargets = options[@"tracePropagationTargets"];
382-
}
383-
384-
if ([options[@"failedRequestStatusCodes"] isKindOfClass:[NSArray class]]) {
385-
self.failedRequestStatusCodes = options[@"failedRequestStatusCodes"];
386-
}
387-
388-
if ([options[@"failedRequestTargets"] isKindOfClass:[NSArray class]]) {
389-
self.failedRequestTargets = options[@"failedRequestTargets"];
390-
}
391-
392-
// SentrySdkInfo already expects a dictionary with {"sdk": {"name": ..., "value": ...}}
393-
// so we're passing the whole options object.
394-
// Note: we should remove this code once the hybrid SDKs move over to the new
395-
// PrivateSentrySDKOnly setter functions.
396-
if ([options[@"sdk"] isKindOfClass:[NSDictionary class]]) {
397-
SentrySdkInfo *defaults = [[SentrySdkInfo alloc] initWithName:SentryMeta.sdkName
398-
andVersion:SentryMeta.versionString];
399-
SentrySdkInfo *sdkInfo = [[SentrySdkInfo alloc] initWithDict:options orDefaults:defaults];
400-
SentryMeta.versionString = sdkInfo.version;
401-
SentryMeta.sdkName = sdkInfo.name;
402-
}
403-
404-
if (nil != error && nil != *error) {
405-
return NO;
406-
} else {
407-
return YES;
408-
}
409-
}
410-
411-
- (SentrySdkInfo *)sdkInfo
412-
{
413-
return [[SentrySdkInfo alloc] initWithName:SentryMeta.sdkName
414-
andVersion:SentryMeta.versionString];
415-
}
416-
417-
- (void)setBool:(id)value block:(void (^)(BOOL))block
418-
{
419-
// Entries in the dictionary can be NSNull. Especially, on React-Native, this can happen.
420-
if (value != nil && ![value isEqual:[NSNull null]]) {
421-
block([value boolValue]);
422-
}
423-
}
424-
425193
- (void)addInAppInclude:(NSString *)inAppInclude
426194
{
427195
_inAppIncludes = [self.inAppIncludes arrayByAddingObject:inAppInclude];

0 commit comments

Comments
 (0)