Hidding Sentry Auth fom app.json

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

1 Like

Thanks for sharing this @naripok!

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!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.