nuxt-community / sentry-module

Sentry module for Nuxt 2
https://sentry.nuxtjs.org
MIT License
501 stars 114 forks source link

Unsure how this module is suppose to work #588

Closed naglalakk closed 1 year ago

naglalakk commented 1 year ago

Hi. I'm out of ideas on how to make this module work. I've followed the documentation and rearranged things couple of times and it's not working. My nuxt config

  sentry: {
    tracing: true,
    sourceMapStyle: 'source-map',
    dsn: process.env.SENTRY_DSN,
    publishRelease: {
      authToken: process.env.SENTRY_AUTH_TOKEN,
      org: 'igloo-ag',
      project: 'igloo-rent-frontend',
      setCommits: { auto: true }
    },
    config: {
      environment: process.env.ENVIRONMENT
        ? process.env.ENVIRONMENT
        : 'default',
      release: process.env.COMMIT_SHA
    }
  },

Note that this makes the build fail because of config -> release. When I include this sentry-cli complains that I haven't provided an org. But I do provide an org in the publishRelease config (I don't know how to declare this any other way except using env variables). With this config the environment is still wrong (it says production, suppose to be development). I think in fact it's not reading this config at all (except for the sentry.config clause for some reason), it's simply taking the env variables available (SENTRY_DSN, SENTRY_AUTH_TOKEN).

I'm using nuxt: 2.16.3 with @nuxtjs/sentry: 4.5.0

rchl commented 1 year ago

You can set publishRelease.debug: true and config.debug: true and see if that provides any clue.

Otherwise you should provide more concrete info (exact error message) as otherwise it's just a guessing game.

It could be that your envs are defined but empty and Sentry prefers those over values specified in the config.

naglalakk commented 1 year ago

Thanks. What seems to work is to declare SENTRY_ORG and SENTRY_PROJECT environment variables. But if I don't declare them they are not present and the configuration is not read. This seems to upload a release to sentry but that's it. Public runtime does not seem to work, environment is not used, release sha is not used. I set debug: true on both configs. I'm not sure where it's suppose to output this debug?

In terms of error message. I'm not sure what more I can provide. There is not a certain error message. The issue is simply that I don't get correct environment or release sent with the sentry error message. It always ends up in the production environment. This is my current config

  sentry: {
    tracing: true,
    sourceMapStyle: 'source-map',
    dsn: process.env.SENTRY_DSN,
    publishRelease: {
      debug: true,
      authToken: process.env.SENTRY_AUTH_TOKEN,
      org: process.env.SENTRY_ORG, //'igloo-ag',
      project: process.env.SENTRY_PROJECT, // 'igloo-rent-frontend',
      setCommits: { auto: true }
    },
    config: {
      debug: true,
      environment: process.env.ENVIRONMENT
        ? process.env.ENVIRONMENT
        : 'default',
      release: process.env.COMMIT_SHA
    }
  },

and publicRuntimeConfig

  publicRuntimeConfig: {
    sentry: {
      config: {
        debug: true,
        environment: process.env.ENVIRONMENT
          ? process.env.ENVIRONMENT
          : 'default',
        release: process.env.COMMIT_SHA
      }
    }
  },

This is a nuxt application where ssr:false and target:static

naglalakk commented 1 year ago

perhaps related: https://github.com/nuxt-community/sentry-module/issues/202 I'm going to test updating the version of this package

rchl commented 1 year ago

Missed it before... You are using version 4.5.0 and expect everything to work per latest documentation? :)

naglalakk commented 1 year ago

You are correct. It was an older version. It wasn't until I saw the version number on the documentation page that I noticed I am way behind. I will close this now and I apologize for wasting your time on this.