Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Are system environment variables accessible in Sentry client configuration - NextJS? #13436

Answered by lforst
alamenai asked this question in Q&A
Discussion options

Hi,

We define our environment and our DSN variables in Azure environments or App Settings:

image

Then we access them from sentry.config.ts file:

import * as Sentry from "@sentry/nextjs"
Sentry.init({
 environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
 dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
 // Adjust this value in production, or use tracesSampler for greater control
 tracesSampleRate: 1,
 // Setting this option to true will print useful information to the console while you're setting up Sentry.
 debug: false,
 replaysOnErrorSampleRate: 1.0,
 // This sets the sample rate to be 10%. You may want this to be 100% while
 // In development and sample at a lower rate in production
 replaysSessionSampleRate: 0.1,
})

and in our .env.production:

NEXT_PUBLIC_SENTRY_DSN=
NEXT_PUBLIC_SENTRY_ENVIRONMENT=

However, as we know Next.js bundle these variables during the build process and inject them, I expect that they will not be accessible if we define them in Azure Environment from Sentry client configuration file because the initial value was empty, and we have to define them in the environment files.

You must be logged in to vote

Any env variables prefixed with NEXT_PUBLIC_ should be available in your sentry.client.config.ts file.

Replies: 1 comment 1 reply

Comment options

Any env variables prefixed with NEXT_PUBLIC_ should be available in your sentry.client.config.ts file.

You must be logged in to vote
1 reply
Comment options

Thank you @lforst , however, we can not define them in App Settings (System Variables) but only from the pipeline environments.variables.

Answer selected by alamenai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /