sentry-react-native
sentry-react-native copied to clipboard
Ability to disable autoUpload source maps
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.
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 }
}
I agree with this, we will investigate adding this in the near future.
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 🥀
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
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.
It would be really great to just have an environment setting to achieve this, e.g. disable it for local development.
@sreuter it's in our backlog, but PRs are also welcome :) I'd be happy to review it.
Its already possible to do some sort of config with project.ext.sentryCli
on Gradle, so this one can fit in there.
And for iOS, it could be ENV.
And for iOS, it could be ENV.
Maybe ENV for both of them then? so its less confusing.
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
@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.
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 Yes, this would work for Android.
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.
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.