sentry-netlify-build-plugin icon indicating copy to clipboard operation
sentry-netlify-build-plugin copied to clipboard

SENTRY_RELEASE and SENTRY_ENVIRONMENT undefined

Open nidhi-tandon opened this issue 2 years ago • 3 comments

Environment

React app with Netlify deployments

Steps to Reproduce

  1. While setting up Sentry.init with the following params, SENTRY_RELEASE and SENTRY_ENVIRONMENT is undefined.
Sentry.init({
    dsn: 'dsn-value',
    integrations: [new BrowserTracing()],
    tracesSampleRate: 1.0,
    release: process.env.SENTRY_RELEASE,
    environment: process.env.SENTRY_ENVIRONMENT,
  });

In webpack.config.js

plugins: [
      new SentryWebpackPlugin({
        org: 'some-org',
        project: 'some-project',
        include: './build',
        ignoreFile: '.sentrycliignore',
        ignore: ['node_modules', 'webpack.config.js'],
        authToken: process.env.SENTRY_AUTH_TOKEN,
        release: process.env.SENTRY_RELEASE,
      }),
    ],

The Releases tab in sentry is showing the release and no related issue. Also the environment is available.

Screenshot 2023-03-16 at 1 52 26 PM Screenshot 2023-03-16 at 1 54 59 PM

But the issue/errors has no release or environment data.

I also looked at the previous resolved issues

  • https://github.com/getsentry/sentry-netlify-build-plugin/issues/11
  • https://cra.mr/instrumenting-gatsbyjs-with-sentry/ and tried by setting release: process.env.COMMIT_REF but still undefined.

I also tried using netlify.toml file to set env variables but I specifically need the release which Netlify is sending to sentry (the default value) and it is dynamic every time based on the build, so I am not sure how to set dynamic env vars in netlify.toml

Expected Result

process.env.SENTRY_RELEASE should not be undefined process.env.SENTRY_ENVIRONMENT should not be undefined

Actual Result

What actually happened. Maybe a screenshot/recording? Maybe some logs?

process.env.SENTRY_RELEASE is undefined/ N/a process.env.SENTRY_ENVIRONMENT is undefined/ N/a

Please let me know if I have missed anything. Thanks in advance.

nidhi-tandon avatar Mar 16 '23 08:03 nidhi-tandon

Hi @nidhi-tandon Have you followed the steps in here? https://github.com/getsentry/sentry-netlify-build-plugin#installation

In the official documentation I read this:

Register the package as a plugin in gatsby-config.js. Options will be passed directly to Sentry.init.

It makes me think that configuration via webpack.config.js is not the preferred way. You may also want to pass debug: true, to the initializer while investigating.

How are you deploying your app to Netlify? Are using Github Actions as part of it? Are you using Docker as part of the build and release process?

armenzg avatar Mar 16 '23 14:03 armenzg

The application is using react, so I checked sentry's react guide and webpack guide. And it is being directly deployed via Netlify without docker or Github actions.

nidhi-tandon avatar Mar 16 '23 14:03 nidhi-tandon

I will check with passing debug: true

You may also want to pass debug: true, to the initializer while investigating.

nidhi-tandon avatar Mar 16 '23 14:03 nidhi-tandon