Hidding Sentry Auth fom app.json


#1

For anybody who wants to hide sentry auth token from app.json, you just need to make it and env variable.

I just created an bash script to inject it and changed the package.json scripts to run it before calling expo start, build, etc, and it seems to work…

example:

setEnv.sh

#!/usr/bin/env bash

export SENTRY_AUTH_TOKEN="token"

package.json

{
  ....
  "scripts": {
    "start": ". ./setEnv.sh && expo start",
    "build-android": ". ./setEnv.sh && expo build:android",
    ...
  },
... rest of the file ...

reference: https://github.com/expo/sentry-expo/issues/29


#2

Thanks for sharing this @naripok!


#3

Hey guys, I have a question…

Although the method described above seems to work for injecting the sentry token into app.json (sentry works fine, does it works even without the token?), when I try to access any env variables via process.env.VARIABLE_NAME from inside my app, I get undefined value…

Which method do you guys recommend for injecting env variables into an expo app, e.g. for alternating between dev and prod configs?

Thanks in advance!