Skip to content

Commit 3b450bc

Browse files
committed
Improve defaults
1 parent 0dff05e commit 3b450bc

File tree

6 files changed

+105
-155
lines changed

6 files changed

+105
-155
lines changed

Samples/iOS-Swift/iOS-Swift/Tools/SentryExposure.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
1515

1616
@interface SentryClientInternal : NSObject
1717

18-
@property (nonatomic) SentryOptionsInternal *options;
18+
@property (nonatomic) SentryOptions *options;
1919

2020
@end
2121

Sources/Sentry/SentryOptionsInternal.m

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ - (instancetype)init
7070
{
7171
if (self = [super init]) {
7272
self.enabled = YES;
73-
self.shutdownTimeInterval = 2.0;
7473
self.enableCrashHandler = YES;
7574
#if TARGET_OS_OSX
7675
self.enableUncaughtNSExceptionReporting = NO;
@@ -81,16 +80,10 @@ - (instancetype)init
8180
self.diagnosticLevel = kSentryLevelDebug;
8281
self.debug = NO;
8382
self.maxBreadcrumbs = defaultMaxBreadcrumbs;
84-
self.maxCacheItems = 30;
85-
self.sampleRate = SENTRY_DEFAULT_SAMPLE_RATE;
8683
self.enableAutoSessionTracking = YES;
8784
self.enableGraphQLOperationTracking = NO;
8885
self.enableWatchdogTerminationTracking = YES;
89-
self.sessionTrackingIntervalMillis = [@30000 unsignedIntValue];
9086
self.attachStacktrace = YES;
91-
// Maximum attachment size is 100 MiB, matches Relay's limit:
92-
// https://develop.sentry.dev/sdk/data-model/envelopes/#size-limits
93-
self.maxAttachmentSize = 100 * 1024 * 1024;
9487
self.sendDefaultPii = NO;
9588
self.enableAutoPerformanceTracing = YES;
9689
self.enablePersistingTracesWhenCrashing = NO;
@@ -133,59 +126,6 @@ - (instancetype)init
133126
self.sendClientReports = YES;
134127
self.swiftAsyncStacktraces = NO;
135128
self.enableSpotlight = NO;
136-
self.spotlightUrl = @"http://localhost:8969/stream";
137-
138-
#if TARGET_OS_OSX
139-
NSString *dsn = [[[NSProcessInfo processInfo] environment] objectForKey:@"SENTRY_DSN"];
140-
if (dsn.length > 0) {
141-
self.dsn = dsn;
142-
}
143-
#endif // TARGET_OS_OSX
144-
145-
// Use the name of the bundle's executable file as inAppInclude, so SentryInAppLogic
146-
// marks frames coming from there as inApp. With this approach, the SDK marks public
147-
// frameworks such as UIKitCore, CoreFoundation, GraphicsServices, and so forth, as not
148-
// inApp. For private frameworks, such as Sentry, dynamic and static frameworks differ.
149-
// Suppose you use dynamic frameworks inside your app. In that case, the SDK marks these as
150-
// not inApp as these frameworks are located in the application bundle, but their location
151-
// is different from the main executable. In case you have a private framework that should
152-
// be inApp you can add it to inAppInclude. When using static frameworks, the frameworks end
153-
// up in the main executable. Therefore, the SDK currently can't detect if a frame of the
154-
// main executable originates from the application or a private framework and marks all of
155-
// them as inApp. To fix this, the user can use stack trace rules on Sentry.
156-
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
157-
NSString *bundleExecutable = infoDict[@"CFBundleExecutable"];
158-
if (bundleExecutable == nil) {
159-
_inAppIncludes = [NSArray new];
160-
} else {
161-
_inAppIncludes = @[ bundleExecutable ];
162-
}
163-
164-
_inAppExcludes = [NSArray new];
165-
166-
// Set default release name
167-
if (infoDict != nil) {
168-
self.releaseName =
169-
[NSString stringWithFormat:@"%@@%@+%@", infoDict[@"CFBundleIdentifier"],
170-
infoDict[@"CFBundleShortVersionString"], infoDict[@"CFBundleVersion"]];
171-
}
172-
173-
NSRegularExpression *everythingAllowedRegex =
174-
[NSRegularExpression regularExpressionWithPattern:@".*"
175-
options:NSRegularExpressionCaseInsensitive
176-
error:NULL];
177-
self.tracePropagationTargets = @[ everythingAllowedRegex ];
178-
self.failedRequestTargets = @[ everythingAllowedRegex ];
179-
180-
// defaults to 500 to 599
181-
SentryHttpStatusCodeRange *defaultHttpStatusCodeRange =
182-
[[SentryHttpStatusCodeRange alloc] initWithMin:500 max:599];
183-
self.failedRequestStatusCodes = @[ defaultHttpStatusCodeRange ];
184-
185-
self.cacheDirectoryPath
186-
= NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)
187-
.firstObject
188-
?: @"";
189129

190130
#if SENTRY_HAS_METRIC_KIT
191131
self.enableMetricKit = NO;
@@ -195,77 +135,6 @@ - (instancetype)init
195135
return self;
196136
}
197137

198-
- (void)setTracePropagationTargets:(NSArray *)tracePropagationTargets
199-
{
200-
for (id targetCheck in tracePropagationTargets) {
201-
if (![targetCheck isKindOfClass:[NSRegularExpression class]]
202-
&& ![targetCheck isKindOfClass:[NSString class]]) {
203-
SENTRY_LOG_WARN(@"Only instances of NSString and NSRegularExpression are supported "
204-
@"inside tracePropagationTargets.");
205-
}
206-
}
207-
208-
_tracePropagationTargets = tracePropagationTargets;
209-
}
210-
211-
- (void)setFailedRequestTargets:(NSArray *)failedRequestTargets
212-
{
213-
for (id targetCheck in failedRequestTargets) {
214-
if (![targetCheck isKindOfClass:[NSRegularExpression class]]
215-
&& ![targetCheck isKindOfClass:[NSString class]]) {
216-
SENTRY_LOG_WARN(@"Only instances of NSString and NSRegularExpression are supported "
217-
@"inside failedRequestTargets.");
218-
}
219-
}
220-
221-
_failedRequestTargets = failedRequestTargets;
222-
}
223-
224-
- (void)setDsn:(NSString *)dsn
225-
{
226-
NSError *error = nil;
227-
self.parsedDsn = [[SentryDsn alloc] initWithString:dsn didFailWithError:&error];
228-
229-
if (error == nil) {
230-
_dsn = dsn;
231-
} else {
232-
SENTRY_LOG_ERROR(@"Could not parse the DSN: %@.", error);
233-
}
234-
}
235-
236-
- (void)setSampleRate:(NSNumber *)sampleRate
237-
{
238-
if (sampleRate == nil) {
239-
_sampleRate = nil;
240-
} else if (sentry_isValidSampleRate(sampleRate)) {
241-
_sampleRate = sampleRate;
242-
} else {
243-
_sampleRate = SENTRY_DEFAULT_SAMPLE_RATE;
244-
}
245-
}
246-
247-
- (void)setTracesSampleRate:(NSNumber *)tracesSampleRate
248-
{
249-
if (tracesSampleRate == nil) {
250-
_tracesSampleRate = nil;
251-
} else if (sentry_isValidSampleRate(tracesSampleRate)) {
252-
_tracesSampleRate = tracesSampleRate;
253-
} else {
254-
_tracesSampleRate = SENTRY_DEFAULT_TRACES_SAMPLE_RATE;
255-
}
256-
}
257-
258-
- (void)setEnableSpotlight:(BOOL)value
259-
{
260-
_enableSpotlight = value;
261-
#if defined(RELEASE)
262-
if (value) {
263-
SENTRY_LOG_WARN(@"Enabling Spotlight for a release build. We recommend running Spotlight "
264-
@"only for local development.");
265-
}
266-
#endif // defined(RELEASE)
267-
}
268-
269138
#if defined(DEBUG) || defined(SENTRY_TEST) || defined(SENTRY_TEST_CI)
270139
- (NSString *)debugDescription
271140
{

Sources/Sentry/SentrySampling.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}
2525

2626
NSNumber *callbackRate = callback(context);
27-
if (!sentry_isValidSampleRate(callbackRate)) {
27+
if (![SentryOptions isValidSampleRate:callbackRate]) {
2828
return defaultSampleRate;
2929
}
3030

@@ -67,8 +67,7 @@
6767
withSampleRand:context.transactionContext.sampleRand];
6868
}
6969

70-
NSNumber *callbackRate = _sentry_samplerCallbackRate(
71-
options.tracesSampler, context, SENTRY_DEFAULT_TRACES_SAMPLE_RATE);
70+
NSNumber *callbackRate = _sentry_samplerCallbackRate(options.tracesSampler, context, 0);
7271
if (callbackRate != nil) {
7372
return _sentry_calcSample(callbackRate);
7473
}

Sources/Sentry/include/SentryInternalDefines.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
static NSString *const SentryDebugImageType = @"macho";
55
static NSString *const SentryPlatformName = @"cocoa";
66

7-
#define SENTRY_DEFAULT_SAMPLE_RATE @1
8-
#define SENTRY_DEFAULT_TRACES_SAMPLE_RATE @0
9-
107
/**
118
* The value we give when initializing the options object, and what it will be if a consumer never
129
* modifies it in their SDK config.

Sources/Sentry/include/SentryOptionsInternal+Private.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,8 @@ FOUNDATION_EXPORT NSString *const kSentryDefaultEnvironment;
1212
#if SENTRY_TARGET_PROFILING_SUPPORTED
1313
@property (nonatomic, assign) BOOL enableProfiling_DEPRECATED_TEST_ONLY;
1414

15-
/**
16-
* UI Profiling options set on SDK start.
17-
* @note Not for use with launch profiles. See functions in @c SentryLaunchProfiling .
18-
*/
19-
@property (nonatomic, nullable, strong) SentryProfileOptions *profiling;
2015
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
2116

22-
SENTRY_EXTERN BOOL sentry_isValidSampleRate(NSNumber *sampleRate);
23-
2417
@end
2518

2619
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)