diff --git a/Sources/Sentry/SentryClient.m b/Sources/Sentry/SentryClient.m index e4e481a3b20..b1ac1aa6b72 100644 --- a/Sources/Sentry/SentryClient.m +++ b/Sources/Sentry/SentryClient.m @@ -28,6 +28,7 @@ #import "SentryOutOfMemoryTracker.h" #import "SentrySDK+Private.h" #import "SentryScope+Private.h" +#import "SentrySdkInfo.h" #import "SentryStacktraceBuilder.h" #import "SentryThreadInspector.h" #import "SentryTraceState.h" @@ -568,30 +569,29 @@ - (SentryEvent *_Nullable)callEventProcessors:(SentryEvent *)event - (void)setSdk:(SentryEvent *)event { - // Every integration starts with "Sentry" and ends with "Integration". To keep the payload of - // the event small we remove both. - NSMutableArray *integrations = [NSMutableArray new]; - for (NSString *integration in self.options.enabledIntegrations) { - NSString *withoutSentry = [integration stringByReplacingOccurrencesOfString:@"Sentry" - withString:@""]; - NSString *trimmed = [withoutSentry stringByReplacingOccurrencesOfString:@"Integration" - withString:@""]; - [integrations addObject:trimmed]; - } - - NSMutableDictionary *sdk = @{ - @"name" : SentryMeta.sdkName, - @"version" : SentryMeta.versionString, - @"integrations" : integrations + if (event.sdk) { + return; } - .mutableCopy; - if (nil == event.sdk) { - if (event.extra[@"__sentry_sdk_integrations"]) { - [sdk setValue:event.extra[@"__sentry_sdk_integrations"] forKey:@"integrations"]; + id integrations = event.extra[@"__sentry_sdk_integrations"]; + if (!integrations) { + integrations = [NSMutableArray new]; + for (NSString *integration in self.options.enabledIntegrations) { + // Every integration starts with "Sentry" and ends with "Integration". To keep the + // payload of the event small we remove both. + NSString *withoutSentry = [integration stringByReplacingOccurrencesOfString:@"Sentry" + withString:@""]; + NSString *trimmed = [withoutSentry stringByReplacingOccurrencesOfString:@"Integration" + withString:@""]; + [integrations addObject:trimmed]; } - event.sdk = sdk; } + + event.sdk = @{ + @"name" : self.options.sdkInfo.name, + @"version" : self.options.sdkInfo.version, + @"integrations" : integrations + }; } - (void)setUserInfo:(NSDictionary *)userInfo withEvent:(SentryEvent *)event