diff --git a/CHANGELOG.md b/CHANGELOG.md index 043da07b31..710526575d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Expose session timeout. #887 +- Added `event.origin` and `event.environment` tags to determine where events originate from. #890 ## 1.4.1 @@ -134,7 +135,7 @@ New way to import and init the SDK: import * as Sentry from "@sentry/react-native"; Sentry.init({ - dsn: "DSN", + dsn: "DSN" }); ``` @@ -370,7 +371,7 @@ To activate it set: ```js Sentry.config("___DSN___", { - deactivateStacktraceMerging: false, + deactivateStacktraceMerging: false }); ``` diff --git a/RNSentry.podspec b/RNSentry.podspec index 1879ec9e81..d36892e92b 100644 --- a/RNSentry.podspec +++ b/RNSentry.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| s.preserve_paths = '*.js' s.dependency 'React' - s.dependency 'Sentry', '~> 5.1.0' + s.dependency 'Sentry', '~> 5.1.1' s.source_files = 'ios/RNSentry.{h,m}' s.public_header_files = 'ios/RNSentry.h' diff --git a/android/src/main/java/io/sentry/RNSentryModule.java b/android/src/main/java/io/sentry/RNSentryModule.java index 0a699a5505..904dfc0074 100644 --- a/android/src/main/java/io/sentry/RNSentryModule.java +++ b/android/src/main/java/io/sentry/RNSentryModule.java @@ -28,9 +28,11 @@ import io.sentry.android.core.AnrIntegration; import io.sentry.android.core.NdkIntegration; import io.sentry.android.core.SentryAndroid; +import io.sentry.core.Sentry; import io.sentry.core.Integration; import io.sentry.core.SentryOptions; import io.sentry.core.UncaughtExceptionHandlerIntegration; +import io.sentry.core.protocol.SdkVersion; import io.sentry.core.protocol.SentryException; @ReactModule(name = RNSentryModule.NAME) @@ -108,6 +110,27 @@ public void startWithOptions(final ReadableMap rnOptions, Promise promise) { } catch (Exception e) { // We do nothing } + + // Add on the correct event.origin tag. + // it needs to be here so we can determine where it originated from. + SdkVersion sdkVersion = event.getSdk(); + if (sdkVersion != null) { + String sdkName = sdkVersion.getName(); + if (sdkName != null) { + if (sdkName.equals("sentry.javascript.react-native")) { + event.setTag("event.origin", "javascript"); + } else if (sdkName.equals("sentry.java.android") || sdkName.equals("sentry.native")) { + event.setTag("event.origin", "android"); + + if (sdkName.equals("sentry.native")) { + event.setTag("event.environment", "native"); + } else { + event.setTag("event.environment", "java"); + } + } + } + } + return event; }); diff --git a/ios/RNSentry.m b/ios/RNSentry.m index 19ff93bc12..fba04a5564 100644 --- a/ios/RNSentry.m +++ b/ios/RNSentry.m @@ -46,6 +46,14 @@ + (BOOL)requiresMainQueueSetup { return nil; } + // set the event.origin tag to be ios if the event originated from the sentry-cocoa sdk. + if (event.sdk && [event.sdk[@"name"] isEqualToString:@"sentry.cocoa"]) { + NSMutableDictionary *newTags = [NSMutableDictionary new]; + [newTags addEntriesFromDictionary:event.tags]; + [newTags setValue:@"ios" forKey:@"event.origin"]; + event.tags = newTags; + } + return event; }; diff --git a/sample/ios/Podfile.lock b/sample/ios/Podfile.lock index f3d732a9e6..f875cd2a9b 100644 --- a/sample/ios/Podfile.lock +++ b/sample/ios/Podfile.lock @@ -292,12 +292,12 @@ PODS: - React-cxxreact (= 0.62.2) - React-jsi (= 0.62.2) - ReactCommon/callinvoker (= 0.62.2) - - RNSentry (1.3.9): + - RNSentry (1.4.1): - React - - Sentry (~> 5.1.0) - - Sentry (5.1.0): - - Sentry/Core (= 5.1.0) - - Sentry/Core (5.1.0) + - Sentry (~> 5.1.1) + - Sentry (5.1.1): + - Sentry/Core (= 5.1.1) + - Sentry/Core (5.1.1) - Yoga (1.14.0) - YogaKit (1.18.1): - Yoga (~> 1.14) @@ -458,11 +458,11 @@ SPEC CHECKSUMS: React-RCTText: fae545b10cfdb3d247c36c56f61a94cfd6dba41d React-RCTVibration: 4356114dbcba4ce66991096e51a66e61eda51256 ReactCommon: ed4e11d27609d571e7eee8b65548efc191116eb3 - RNSentry: 20f609597e89e7a47a553e1e8a82abc0207a6bd9 - Sentry: 01008d590825eb1c02a796cbdced2cd3625f61e4 + RNSentry: 451cb0e69830a682d8ca33ead8e9953688a9eff8 + Sentry: a8e37dc33aedb8a53540e36607fc2eaef7c31b4f Yoga: 3ebccbdd559724312790e7742142d062476b698e YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 37ff82402d037e0662e07ec778dac86a7460fd84 +PODFILE CHECKSUM: 7d26d6f146f06216129da20c128ed24b666d4bb5 COCOAPODS: 1.9.2 diff --git a/src/js/sdk.ts b/src/js/sdk.ts index 4b04d612a9..9d20f82ece 100644 --- a/src/js/sdk.ts +++ b/src/js/sdk.ts @@ -90,6 +90,9 @@ export function init( // }); // } + // set the event.origin tag. + getCurrentHub().setTag("event.origin", "javascript"); + // tslint:disable-next-line: no-unsafe-any if (getGlobalObject().HermesInternal) { getCurrentHub().setTag("hermes", "true");