React Native on Android creates new release for already mapped release

A release with artifacts was created with gradle assembleRelease.
When the app crashes and create an issue a new release, with the same name as the existing one, is created and linked to the issue.

Why is a new release created with the same name instead of linking to the existing one?

The created release.
https://sentry.io/syb/react-native-app/releases/com.soundtrackyourbrand.soundtrack.player-34.12-2-g3dd8f6a/artifacts/

The created issue
https://sentry.io/syb/react-native-app/issues/409007344/

Hey, so it looks like that the native part for Android isn’t working.
You can see this because the last section of the event (SDK) says raven-js instead of sentry-react-native.
So there must be something wrong with the linking process of the native part, did you call react-native link react-native-sentry?

Make sure Sentry gets called in your java code, debug it and check the log output you should see something about Sentry.

Our app uses react native in just one of our Activities.

So we start it with:

reactRootView = (ReactRootView) findViewById(R.id.reactRootView);

reactInstanceManager = ReactInstanceManager.builder()
        .setApplication(getApplication())
        .setBundleAssetName("index.android.bundle")
        .setJSMainModulePath("index.android")
        .addPackage(new MainReactPackage())
        .setUseDeveloperSupport(BuildConfig.DEBUG)
        .setInitialLifecycleState(LifecycleState.RESUMED)
        .build();
                               
reactRootView.startReactApplication(reactInstanceManager, "ReactNativeBusiness", initialProperties);

As our project structure is different I can not simply run react-native link react-native-sentry.
How would I add the necessary configuration by hand?
Is this documented somewhere?

The gradle part is partially documented here: https://docs.sentry.io/clients/react-native/manual-setup/#android

But not how to integrate it into the code, I would checkout the example project and check all reference of Sentry.

Got it working. My application implements ReactApplication and I added RNSentryPackage to the react instance in my activity:

  reactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("index.android.bundle")
                .setJSMainModulePath("index.android")
                .addPackages(Arrays.<ReactPackage>asList(
                        new MainReactPackage(),
                        new RNSentryPackage(App.getInstance())
                ))
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();

The issue no resolves to the correct release in sentry. The only problem now is that when the issue is sent from the app, distribution is set to 0 and the artifact in the created release has the correct distribution of 34017002.

Can I configure the RNSentryPackage in some way so that the correct distribution is used?

You can call Sentry.setDist('dist'); this should do what you want.

In javascript or in Java?
If you mean in javascript, do you know how I can query for the distribution?

So this call has to be in Javascript, we haven’t exposed any Java API.

You either need to set a variable somewhere in your build process so it can be fetched in JS
or
use another react-native plugin which is able to retrieve the dist you set in Java at runtime.

Usually, this wouldn’t be necessary because our scripts handle this if you use it with a “clean” react-native app, but since I don’t know how much you diverged from the standard build process it’s hard to say.

Awesome, this fixes it. Thanks.

I do not think that my case is totally uncommon though. I know about more companies that are trying out react by using it in one activity in an existing app. It would be nice if it was clear how to integrate sentry in a case like this.

I guess you are right, I will add a section in the docs for this.

Can you please tell me which way you went to set the dist?

We used RNDeviceInfo in the ReactInstanceManager builder in our Activity.

.addPackages(Arrays.<ReactPackage>asList(
                         new MainReactPackage(),
                         new RNDeviceInfo(),
                         new RNSentryPackage(App.getInstance())
                 ))

And then

import DeviceInfo from 'react-native-device-info'
 ....
Sentry.config(config).install()
Sentry.setDist(DeviceInfo.getBuildNumber())

In our java script code.