getsentry / sentry-netlify-build-plugin

The Sentry Netlify build plugin automatically notifies Sentry of new releases being deployed to your site.
Apache License 2.0
46 stars 17 forks source link

SENTRY_RELEASE and SENTRY_ENVIRONMENT undefined #79

Open nidhi-tandon opened 1 year ago

nidhi-tandon commented 1 year ago

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. 

<img width="1182" alt="Screenshot 2023-03-16 at 1 52 26 PM" src="https://user-images.githubusercontent.com/6941627/225557623-c16ad947-32b9-4e3a-abb9-de01e7cb13d6.png">
<img width="312" alt="Screenshot 2023-03-16 at 1 54 59 PM" src="https://user-images.githubusercontent.com/6941627/225557846-c023fcb4-62c0-413e-93a7-6146a3df8a3e.png">

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.
armenzg commented 1 year ago

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?

nidhi-tandon commented 1 year ago

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 commented 1 year ago

I will check with passing debug: true

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