I have a React Native application created with Expo and use Expo EAS Build for my preview and production builds.
I have three environment variables:
EXPO_PUBLIC_API_URL
: This changes based on whether the build is for preview or production.- Two secret keys, one of which is
SENTRY_AUTH_TOKEN
.
Locally, I use a .env
file for environment variables when working in development, but I don’t include SENTRY_AUTH_TOKEN
there because Sentry isn’t needed in development.
For EAS Build, I have added EXPO_PUBLIC_API_URL
to eas.json as follows:
{
"preview": {
"channel": "preview",
"distribution": "internal",
"env": {
"APP_VARIANT": "preview",
"EXPO_PUBLIC_API_URL": "https://my-staging-url.com"
}
},
"production": {
"channel": "production",
"autoIncrement": true,
"env": {
"APP_VARIANT": "production",
"EXPO_PUBLIC_API_URL": "https://my-prod-url.com"
}
}
}
The other two environment variables have been added as secrets in the Expo dashboard. So far, everything works perfectly.
I’m now setting up Expo EAS Update based on the documentation:
https://docs.expo.dev/guides/using-sentry/#app-configuration
When I run the command eas update --branch preview
, I noticed that EAS Update takes the environment variables from my local .env file. However, it doesn’t have access to the secrets from the Expo dashboard.
As a result, when I make an update, the app doesn’t report errors to Sentry because SENTRY_AUTH_TOKEN
is undefined. I also run the command npx sentry-expo-upload-sourcemaps dist
but get the same result.
How can I ensure that EAS Update has access to the secrets from the Expo dashboard, specifically for SENTRY_AUTH_TOKEN
, to properly report errors to Sentry?
I understand that Expo environment variables need to start with EXPO_PUBLIC_
to be recognised, so that’s why I can’t add it to my local .env file as I do with the other two.
Any ideas or suggestions?