Skip to content

Commit

Permalink
fix: initializing MetricsReporter and CrashReporter only if it's enab…
Browse files Browse the repository at this point in the history
…led for a customer (#491)
  • Loading branch information
desusai7 authored Mar 28, 2024
1 parent a07b5d5 commit 48c4ae1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Sources/Classes/RSMetricsReporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ + (instancetype)initiateWithWriteKey:(NSString *)writeKey preferenceManager:(RSP
- (instancetype)initWithWriteKey:(NSString *)writeKey preferenceManager:(RSPreferenceManager *)preferenceManager andConfig:(RSConfig *)config {
self = [super init];
if (self) {
RSMetricConfiguration *configuration = [[RSMetricConfiguration alloc] initWithLogLevel:config.logLevel writeKey:writeKey sdkVersion:RS_VERSION];
[configuration dbCountThreshold:config.dbCountThreshold];
_metricsClient = [[RSMetricsClient alloc] initWithConfiguration:configuration];
_metricsClient.isMetricsCollectionEnabled = preferenceManager.isMetricsCollectionEnabled;
_metricsClient.isErrorsCollectionEnabled = preferenceManager.isErrorsCollectionEnabled;
if (preferenceManager.isMetricsCollectionEnabled || preferenceManager.isErrorsCollectionEnabled) {
RSMetricConfiguration *configuration = [[RSMetricConfiguration alloc] initWithLogLevel:config.logLevel writeKey:writeKey sdkVersion:RS_VERSION];
[configuration dbCountThreshold:config.dbCountThreshold];
_metricsClient = [[RSMetricsClient alloc] initWithConfiguration:configuration];
_metricsClient.isMetricsCollectionEnabled = preferenceManager.isMetricsCollectionEnabled;
_metricsClient.isErrorsCollectionEnabled = preferenceManager.isErrorsCollectionEnabled;
} else {
[RSLogger logWarn:@"RSMetricsReporter: Metrics and Errors collection is disabled."];
}
}
return self;
}
Expand Down

0 comments on commit 48c4ae1

Please sign in to comment.