sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Ability to disable autoUpload source maps

Open trangcongthanh opened this issue 4 years ago • 7 comments

OS:

  • [x] Windows
  • [ ] MacOS
  • [ ] Linux

Platform:

  • [ ] iOS
  • [x] Android

SDK:

  • [x] @sentry/react-native (>= 1.7.1)
  • [ ] react-native-sentry (<= 0.43.2)

react-native version: 0.63.2 with hermes

Are you using Expo?

  • [ ] Yes
  • [x] No

Are you using sentry.io or on-premise?

  • [x] sentry.io (SaaS)
  • [ ] on-premise

I have following issue:

Look like source maps got uploaded everytime I run react-native run-android event with debug mode. It take alot of time to start to dev my app. If it upload my local source maps, will it affect to our production? And I don't want to use sentry for local dev.

Looking around documents but not found any where mention How to disable autoUpload source maps.

trangcongthanh avatar Aug 25 '20 13:08 trangcongthanh

Could this be an added feature? Now that Release builds automatically try to upload assets, team members don't even have creds to upload it - thus it fails. I mean Release builds are uncommon locally, but they have to happen for certain things to test.

I thought there would be some simple environment variable or even property file, but the only way I've found out to patch this is overriding our gradle file with something like:

gradle.projectsEvaluated {
    def tasksToSkip = project.tasks.matching {
        it.name.contains("SentryUpload")
    }
    tasksToSkip.all { enabled = false }
}

iBotPeaches avatar Sep 25 '20 18:09 iBotPeaches

I agree with this, we will investigate adding this in the near future.

jennmueng avatar Sep 27 '20 15:09 jennmueng

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 label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


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

github-actions[bot] avatar Nov 05 '21 09:11 github-actions[bot]

you can tho https://docs.sentry.io/platforms/react-native/sourcemaps/#2-disable-the-automatic-source-maps-upload-script a boolean would be nicer, so I'd rather keep it open

marandaneto avatar Nov 05 '21 13:11 marandaneto

So we should offer this flag to be flipped via the Sentry configuration on your Gradle file, we should also document that on our debug symbols docs.

marandaneto avatar Mar 04 '22 13:03 marandaneto

It would be really great to just have an environment setting to achieve this, e.g. disable it for local development.

sreuter avatar May 23 '22 02:05 sreuter

@sreuter it's in our backlog, but PRs are also welcome :) I'd be happy to review it.

marandaneto avatar May 23 '22 06:05 marandaneto

Its already possible to do some sort of config with project.ext.sentryCli on Gradle, so this one can fit in there.

marandaneto avatar Dec 07 '22 08:12 marandaneto

And for iOS, it could be ENV.

krystofwoldrich avatar Dec 07 '22 09:12 krystofwoldrich

And for iOS, it could be ENV.

Maybe ENV for both of them then? so its less confusing.

marandaneto avatar Dec 07 '22 09:12 marandaneto

It would be really great to just have an environment setting to achieve this, e.g. disable it for local development.

100%

Its already possible to do some sort of config with project.ext.sentryCli on Gradle, so this one can fit in there.

There's not much info https://docs.sentry.io/clients/react-native/manual-setup/

@sreuter it's in our backlog, but PRs are also welcome :) I'd be happy to review it.

Any hint on where we could start? [EDIT] Possibly from here https://github.com/getsentry/sentry-react-native/blob/main/sentry.gradle, I see

vibern0 avatar Mar 03 '23 12:03 vibern0

@obernardovieira We are happy to hear that you are interested.

Yes, https://github.com/getsentry/sentry-react-native/blob/main/sentry.gradle#L9 would be a good start, we don't want the code after this line to be executed, therefore the upload task won't be added. Or another option is to disable the created task.

For iOS, the changes would need to be added to the https://github.com/getsentry/sentry-wizard/blob/master/lib/Steps/Integrations/ReactNative.ts#L261. As the Build Phase shell code is created by the Wizard.

krystofwoldrich avatar Mar 06 '23 09:03 krystofwoldrich

In practice this oneliner in sentry.gradle should solve it for android right?

` //Disable upload if DISABLE_UPLOAD_SOURCEMAP_SENTRY env is set

      cliTask.onlyIf { !System.getenv("DISABLE_UPLOAD_SOURCEMAP_SENTRY") }`

Tobbb avatar May 02 '23 15:05 Tobbb

@Tobbb Yes, this would work for Android.

krystofwoldrich avatar May 03 '23 09:05 krystofwoldrich

My patch isn't generic enough for a PR, but maybe this helps a little anyway:

diff --git a/node_modules/@sentry/react-native/sentry.gradle b/node_modules/@sentry/react-native/sentry.gradle
index a023126..353c2ff 100644
--- a/node_modules/@sentry/react-native/sentry.gradle
+++ b/node_modules/@sentry/react-native/sentry.gradle
@@ -156,6 +156,8 @@ gradle.projectsEvaluated {
 
               enabled true
           }
+          // patched to run this only if the env var exist
+          cliTask.onlyIf { System.getenv("SENTRY_TOKEN_SECRET") }
 
           modulesTask = tasks.create(nameModulesTask, Exec) {
               description = "collect javascript modules from bundle source map"

This is based on 4.12.0, latest might look different.

jzaefferer avatar Aug 22 '23 10:08 jzaefferer

Just additional note here, to avoid hours of frustration for somebody like me. 🤪

The command from your cli should look like this SENTRY_DISABLE_AUTO_UPLOAD=true ./gradlew bundleRelease (+ flavour if you use them). Otherwise Gradle will not recognise it.

Or don't forget to clean all caches around Gradle and Android builds and then source again your .env file, but direct set of env variable is much safer :D.

cervebar avatar Feb 09 '24 18:02 cervebar