Skip to content

Commit

Permalink
fix: event SDK info should depend on the configured options
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed May 25, 2022
1 parent 8ce3f93 commit c53b221
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions Sources/Sentry/SentryClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -568,30 +569,30 @@ - (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<NSString *> *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] initWithCapacity:self.options.enabledIntegrations.count];
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
Expand Down

0 comments on commit c53b221

Please sign in to comment.