From eef05e7e356e4d2b87e5fdc8dc48aaa1e587c567 Mon Sep 17 00:00:00 2001 From: Jenn Mueng Date: Thu, 28 May 2020 21:24:36 +0700 Subject: [PATCH 1/5] meta: added changlog entry for option filter --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 043da07b31..69461aff73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,7 +134,7 @@ New way to import and init the SDK: import * as Sentry from "@sentry/react-native"; Sentry.init({ - dsn: "DSN", + dsn: "DSN" }); ``` @@ -370,7 +370,7 @@ To activate it set: ```js Sentry.config("___DSN___", { - deactivateStacktraceMerging: false, + deactivateStacktraceMerging: false }); ``` From a83ac4a8c5f4a0383c8e7b785f7631608020b3e2 Mon Sep 17 00:00:00 2001 From: Jenn Mueng Date: Fri, 29 May 2020 19:34:45 +0700 Subject: [PATCH 2/5] feat: Added event.origin tags to determine where the event originated. The event.origin tag is added to the RN SDK Scope on init. On Android, we have a switch in the native beforeSend that determines where the event originated to set the tag. On iOS, the 'ios' tag is added in the native beforeSend if the event originated in the sentry-cocoa sdk Addresses #881 --- .../main/java/io/sentry/RNSentryModule.java | 25 +++++++++++++++++++ ios/RNSentry.m | 8 ++++++ src/js/sdk.ts | 3 +++ 3 files changed, 36 insertions(+) diff --git a/android/src/main/java/io/sentry/RNSentryModule.java b/android/src/main/java/io/sentry/RNSentryModule.java index 0a699a5505..a92689ce20 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,29 @@ 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) { + switch (sdkName) { + case "sentry.javascript.react-native": + event.setTag("event.origin", "javascript"); + break; + case "sentry.native": + event.setTag("event.origin", "ndk"); + break; + case "sentry.java.android": + event.setTag("event.origin", "android"); + break; + default: + break; + } + } + } + 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/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"); From 3e7ffc69703db0a4f55a38482dce850a552962ac Mon Sep 17 00:00:00 2001 From: Jenn Mueng Date: Mon, 1 Jun 2020 13:40:24 +0700 Subject: [PATCH 3/5] build: bump sentry-cocoa to 1.5.1 --- RNSentry.podspec | 2 +- sample/ios/Podfile.lock | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) 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/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 From e19e318504546612748286b5e405e54fbe3161ed Mon Sep 17 00:00:00 2001 From: Jenn Mueng Date: Mon, 1 Jun 2020 14:53:56 +0700 Subject: [PATCH 4/5] feat: Added event.environment tag to Android events --- .../main/java/io/sentry/RNSentryModule.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/android/src/main/java/io/sentry/RNSentryModule.java b/android/src/main/java/io/sentry/RNSentryModule.java index a92689ce20..904dfc0074 100644 --- a/android/src/main/java/io/sentry/RNSentryModule.java +++ b/android/src/main/java/io/sentry/RNSentryModule.java @@ -117,18 +117,16 @@ public void startWithOptions(final ReadableMap rnOptions, Promise promise) { if (sdkVersion != null) { String sdkName = sdkVersion.getName(); if (sdkName != null) { - switch (sdkName) { - case "sentry.javascript.react-native": - event.setTag("event.origin", "javascript"); - break; - case "sentry.native": - event.setTag("event.origin", "ndk"); - break; - case "sentry.java.android": - event.setTag("event.origin", "android"); - break; - default: - break; + 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"); + } } } } From 3e0ed4b5c56f395929497e3562018095c5b45dd1 Mon Sep 17 00:00:00 2001 From: Jenn Mueng Date: Mon, 1 Jun 2020 15:02:59 +0700 Subject: [PATCH 5/5] meta: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69461aff73..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