sentry-react-native
sentry-react-native copied to clipboard
Getting auth.token from .env
So right now I have sentry.properties file with auth.token filled in, in order to upload the source map. I understand that we can add this file to .gitignore not to expose the token to the remote repo. But we are using appcenter which also does build the release application so it needs to upload the sentry source map as well, but there is no option to get the auth.token from the specific file which is not in the repo, but we can set the env variables. So I was wondering if we could get the auth.token from .env instead or leave the default to get the variable from the sentry.properties file but in case it is not configured there, get it from .env something like:
"--auth-token", sentryProps.get("auth.token") ?: project.env.get("SENTRY_AUTH_TOKEN")
kinda related to https://github.com/getsentry/sentry-react-native/issues/831
ideally, we'd patch https://github.com/getsentry/sentry-react-native/blob/master/sentry.gradle#L108-L124 to not add the args in case they don't have a value, so sentry-cli would be able to read the env. var.
"--auth-token", sentryProps.get("auth.token") ?: project.env.get("SENTRY_AUTH_TOKEN")
would be a solution but sentry-cli already looks up into SENTRY_AUTH_TOKEN in case there's no --auth-token set, so in that case, we should just not add --auth-token if sentryProps.get("auth.token") returns nothing.
the same for url (SENTRY_URL), org (SENTRY_ORG) and project (SENTRY_PROJECT)
@marandaneto that sounds much better indeed, any plans on doing that in the near future?
@fragilehm we didn't define priorities yet, but it should not be super hard, what's about submitting a PR? would you be interested? I can guide with reviews
Has anyone made any progress on this or is there another way to use env variables over sentry.properties?
In the current version of RN SDK https://github.com/getsentry/sentry-react-native/releases/tag/5.6.0 and bundled Sentry CLI https://github.com/getsentry/sentry-cli/releases/tag/2.18.1 this works.
If auth token is present in sentry.properties it's used from the file. If not .env file is loaded and SENTRY_AUTH_TOKEN env is used.