From de59d3a18e282982e656cedc399b67a5ebda7cc8 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:15:29 +0100 Subject: [PATCH 1/2] feat: Add RN SDK package to `sdk.packages` on Android (#4380) --- CHANGELOG.md | 1 + .../java/io/sentry/react/RNSentryModuleImpl.java | 15 ++++++++------- .../java/io/sentry/react/RNSentryVersion.java | 8 ++++++++ scripts/version-bump.js | 5 ++++- 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b5e179645..e7707e7c72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ ``` - Export `Span` type from `@sentry/types` ([#4345](https://github.com/getsentry/sentry-react-native/pull/4345)) +- Add RN SDK package to `sdk.packages` on Android ([#4380](https://github.com/getsentry/sentry-react-native/pull/4380)) ### Fixes diff --git a/packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java b/packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java index 6fd2247002..b39261aca7 100644 --- a/packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +++ b/packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java @@ -93,8 +93,6 @@ public class RNSentryModuleImpl { public static final String NAME = "RNSentry"; - private static final String NATIVE_SDK_NAME = "sentry.native.android.react-native"; - private static final String ANDROID_SDK_NAME = "sentry.java.android.react-native"; private static final ILogger logger = new AndroidLogger(NAME); private static final BuildInfoProvider buildInfo = new BuildInfoProvider(logger); private static final String modulesPath = "modules.json"; @@ -191,13 +189,16 @@ protected void getSentryAndroidOptions( @NotNull SentryAndroidOptions options, @NotNull ReadableMap rnOptions, ILogger logger) { @Nullable SdkVersion sdkVersion = options.getSdkVersion(); if (sdkVersion == null) { - sdkVersion = new SdkVersion(ANDROID_SDK_NAME, BuildConfig.VERSION_NAME); + sdkVersion = new SdkVersion(RNSentryVersion.ANDROID_SDK_NAME, BuildConfig.VERSION_NAME); } else { - sdkVersion.setName(ANDROID_SDK_NAME); + sdkVersion.setName(RNSentryVersion.ANDROID_SDK_NAME); } + sdkVersion.addPackage( + RNSentryVersion.REACT_NATIVE_SDK_PACKAGE_NAME, + RNSentryVersion.REACT_NATIVE_SDK_PACKAGE_VERSION); options.setSentryClientName(sdkVersion.getName() + "/" + sdkVersion.getVersion()); - options.setNativeSdkName(NATIVE_SDK_NAME); + options.setNativeSdkName(RNSentryVersion.NATIVE_SDK_NAME); options.setSdkVersion(sdkVersion); if (rnOptions.hasKey("debug") && rnOptions.getBoolean("debug")) { @@ -970,10 +971,10 @@ private void setEventOriginTag(SentryEvent event) { SdkVersion sdk = event.getSdk(); if (sdk != null) { switch (sdk.getName()) { - case NATIVE_SDK_NAME: + case RNSentryVersion.NATIVE_SDK_NAME: setEventEnvironmentTag(event, "native"); break; - case ANDROID_SDK_NAME: + case RNSentryVersion.ANDROID_SDK_NAME: setEventEnvironmentTag(event, "java"); break; default: diff --git a/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java b/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java new file mode 100644 index 0000000000..4660c838e4 --- /dev/null +++ b/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java @@ -0,0 +1,8 @@ +package io.sentry.react; + +class RNSentryVersion { + static final String REACT_NATIVE_SDK_PACKAGE_NAME = "npm:@sentry/react-native"; + static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "6.4.0"; + static final String NATIVE_SDK_NAME = "sentry.native.android.react-native"; + static final String ANDROID_SDK_NAME = "sentry.java.android.react-native"; +} diff --git a/scripts/version-bump.js b/scripts/version-bump.js index 3bb74987a4..ff1a68f6b2 100644 --- a/scripts/version-bump.js +++ b/scripts/version-bump.js @@ -4,7 +4,10 @@ const replace = require('replace-in-file'); const pjson = require('../packages/core/package.json'); replace({ - files: ['packages/core/src/js/version.ts'], + files: [ + 'packages/core/src/js/version.ts', + 'packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java', + ], from: /\d+\.\d+.\d+(?:-\w+(?:\.\w+)?)?/g, to: pjson.version, }) From d00f9ea105aa47cc992b2101226144a718cccf84 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:15:57 +0100 Subject: [PATCH 2/2] chore: Update `captureFeedback` changelog entry (#4386) --- CHANGELOG.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7707e7c72..d38c474a10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,19 +22,11 @@ email: "john@doe.com", message: "Hello World!", associatedEventId: eventId, // optional - }, { - captureContext: { - tags: { "tag-key": "tag-value" }, - }, - attachments: [ - { - filename: 'hello.txt', - data: 'Hello, World!', - }, - ], }); ``` + To learn how to attach context data to the feedback vistit [the documentation](https://docs.sentry.io/platforms/react-native/user-feedback/). + - Export `Span` type from `@sentry/types` ([#4345](https://github.com/getsentry/sentry-react-native/pull/4345)) - Add RN SDK package to `sdk.packages` on Android ([#4380](https://github.com/getsentry/sentry-react-native/pull/4380))