Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event tags so users can easily determine and filter where events originate from. #890

Merged
merged 5 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
});
```

Expand Down Expand Up @@ -370,7 +371,7 @@ To activate it set:

```js
Sentry.config("___DSN___", {
deactivateStacktraceMerging: false,
deactivateStacktraceMerging: false
});
```

Expand Down
2 changes: 1 addition & 1 deletion RNSentry.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
23 changes: 23 additions & 0 deletions android/src/main/java/io/sentry/RNSentryModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
});

Expand Down
8 changes: 8 additions & 0 deletions ios/RNSentry.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
16 changes: 8 additions & 8 deletions sample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions src/js/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>().HermesInternal) {
getCurrentHub().setTag("hermes", "true");
Expand Down