getsentry / sentry-react-native

Official Sentry SDK for React Native
https://sentry.io
MIT License
1.57k stars 337 forks source link

reading versionCode and versionName fails when set by function call #4051

Closed jektvik closed 3 weeks ago

jektvik commented 2 months ago

Bare react native:

https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/

Is there an equivalent for the ios argument: SENTRY_CLI_EXTRA_ARGS

For android ?

I'm currently unable to install sentry in my react-native app because my version in build.gradle is calculated by a function, like so:

android {
...

    namespace "com.yrweather"
    defaultConfig {
         ...
        versionCode getVersionCode()
        versionName getVersionName()

This breaks the build at the sentry-cli command step because sentry isn't evaluating these functions and crashes. Potentially providing the version through a cli arg could help with this, but maybe the root cause should be fixed i.e. the function should be evaluated. Whatever workaround is available now I'd also take it, (even if sentry becomes unaware of the version number)

krystofwoldrich commented 2 months ago

Hi @jektvik, thank you for the message,

yes you can use SENTRY_DIST and SENTRY_RELEASE envs to manually specify the values.

Could you share the error you are getting and example impl of the fucntions?

I've tried the following and the values were resolved.

def getVersionCode = { ->
    return 22
}

def getVersionName = { ->
    return "6.0.0-alpha.0"
}
jektvik commented 2 months ago

@krystofwoldrich the issue is more/also about: "where do i inject these env vars?" i.e. there isn't any obvious cli invokation line for the android edition where these parameters can be passed.

Wrt evaluation of getVersionName and getVersionCode, once I've managed to remove and clean up Sentry (which doesn't really seem fully possible btw as I've been still getting errors after the cleanup!) the issue persisted so I've traced it down to apparent overload conflict of these same function names i.e. had to change the names for these functions and it started working. Am therefore surprised it worked for you, but one way or another this isn't the issue anymore.

krystofwoldrich commented 1 month ago

Hi @jektvik, thank you for the details.

You can add the envs before starting the Android build.

export SENTRY_DIST=custom_dist
export SENTRY_RELEASE=custom_release
./gradlew bundleRelease

I've managed to remove and clean up Sentry

To remove the source maps upload you can use export SENTRY_DISABLE_AUTO_UPLOAD=true -> https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#enable-gradle-integration

Or remove sentry.grale from your app/build.gradle.

getsantry[bot] commented 1 month ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀