Options

Options can be passed using either:

  • environment variables
  • sentry object in nuxt.config.js
  • when registering the module: modules: [['@nuxtjs/sentry', {/*options*/}]]

The config, serverConfig and clientConfig options can also be configured using Runtime Config.

Normally, just setting DSN would be enough.

dsn

  • Type: String
  • Default: process.env.SENTRY_DSN || ''
  • If no dsn is provided, Sentry will be initialised, but errors will not be logged. See #47 for more information about this.

lazy

  • Type: Boolean or Object
  • Default: false
  • Load Sentry lazily so it's not included in your main bundle
  • If true then the default options will be used:
  {
    injectMock: true,
    injectLoadHook: false,
    mockApiMethods: true,
    chunkName: 'sentry',
    webpackPrefetch: false,
    webpackPreload: false
  }
  • Options:
    • injectMock

      • Type: Boolean
      • Default: true
      • Whether a Sentry mock needs to be injected that captures any calls to $sentry API methods while Sentry has not yet loaded. Captured API method calls are executed once Sentry is loaded

      When injectMock: true this module will also add a window.onerror listener. If errors are captured before Sentry has loaded then these will be reported once Sentry has loaded using sentry.captureException

      pages/index.vue
      beforeMount() {
        // onNuxtReady is called _after_ the Nuxt.js app is fully mounted,
        // so Sentry is not yet loaded when beforeMount is called
        // But when you set injectMock: true this call will be captured
        // and executed after Sentry has loaded
        this.$sentry.captureMessage('Hello!')
      },
      
    • injectLoadHook

      • Type: Boolean
      • Default: false
      • By default Sentry will be lazy loaded once window.onNuxtReady is called. If you want to explicitly control when Sentry will be loaded you can set injectLoadHook: true. The module will inject a $sentryLoad method into the Nuxt.js context which you need to call once you are ready to load Sentry
      layouts/default.vue
      ...
      mounted() {
        // Only load Sentry after initial page has fully loaded
        // (this example should behave similar to using window.onNuxtReady though)
        this.$nextTick(() => this.$sentryLoad())
      }
      
    • mockApiMethods

      • Type: Boolean or Array
      • Default true
      • Which API methods from @sentry/browser should be mocked. You can use this to only mock methods you really use.
      • This option is ignored when injectMock: false
      • If mockApiMethods: true then all available API methods will be mocked

      If injectMock: true then captureException will always be mocked for use with the window.onerror listener

      nuxt.config.js
      sentry: {
        lazy: {
          mockApiMethods: ['captureMessage']
        }
      }
      
      pages/index.vue
      mounted() {
        this.$sentry.captureMessage('This works!')
      
        this.$sentry.captureEvent({
          message: `
            This will throw an error because
            captureEvent doesn't exists on the mock
          `
        })
      
        // To circumvent this problem you could use $sentryReady
        (await this.$sentryReady()).captureEvent({
          message: `
            This will not throw an error because
            captureEvent is only executed after
            Sentry has been loaded
          `
        })
      }
      
    • chunkName

    • webpackPrefetch

      • Type: Boolean
      • Default: false
      • Whether the Sentry chunk should be prefetched
    • webpackPreload

      • Type: Boolean
      • Default: false
      • Whether the Sentry chunk should be preloaded

runtimeConfigKey

disabled

  • Type: Boolean
  • Default: process.env.SENTRY_DISABLED || false
  • Sentry will not be initialised if set to true.

disableClientSide

  • Type: Boolean
  • Default: process.env.SENTRY_DISABLE_CLIENT_SIDE || false

disableServerSide

  • Type: Boolean
  • Default: process.env.SENTRY_DISABLE_SERVER_SIDE || false

initialize

  • Type: Boolean
  • Default: process.env.SENTRY_INITIALIZE || true
  • Can be used to add the $sentry object without initializing it, which will result in not reporting errors to Sentry when they happen but not crashing on calling the Sentry APIs.

logMockCalls

  • Type: Boolean
  • Default: true
  • Whether to log calls to the mocked $sentry object in the console
  • Only applies when mocked instance is used (when disabled, disableClientSide or disableServerSide is true)

publishRelease

  • Type: Boolean or WebpackPluginOptions
  • Default: process.env.SENTRY_PUBLISH_RELEASE || false
  • Enables Sentry releases for better debugging using source maps. Uses @sentry/webpack-plugin.
  • Publishing releases requires the organization slug, project name and the Sentry authentication token to be provided. Those can be provided either via the WebpackPluginOptions object or environment variables or a properties file. So for example, when using the options object, you'd set authToken, org and project options, and when using the environment variables you'd set SENTRY_AUTH_TOKEN, SENTRY_ORG and SENTRY_PROJECT.
  • It's recommended to pass a configuration object to this option rather than using the boolean true. When using the boolean, you have to provide the required options through other means mentioned above.
  • The releases are only published when this option is enabled and at the same time you are NOT running in development (nuxt dev) mode.
  • See https://docs.sentry.io/workflow/releases for more information. Note that the Sentry CLI options mentioned in the documentation typically have a @sentry/webpack-plugin equivalent.

Example configuration:

sentry: {
  // ...
  publishRelease: {
    authToken: '<token>',
    org: 'MyCompany',
    project: 'my-project',
    // Attach commits to the release (requires that the build triggered within a git repository).
    setCommits: {
      auto: true
    }
  }
}

sourceMapStyle

  • Type: String
  • Default: source-map
  • Only has effect when publishRelease = true
  • The type of source maps generated when publishing release to Sentry. See https://webpack.js.org/configuration/devtool for a list of available options
  • Note: Consider using hidden-source-map instead. For most people, that should be a better option but due to it being a breaking change, it won't be set as the default until next major release

attachCommits

  • Deprecated - Set publishRelease.setCommits.auto = true instead.
  • Type: Boolean
  • Default: process.env.SENTRY_AUTO_ATTACH_COMMITS || false
  • Only has effect when publishRelease = true

repo

  • Deprecated - use publishRelease.setCommmits.repo instead.
  • Type: String
  • Default: process.env.SENTRY_RELEASE_REPO || ''
  • Only has effect when publishRelease = true && attachCommits = true
  • Alternatively this can be set using publishRelease.setCommmits.repo option.

disableServerRelease

disableClientRelease

clientIntegrations

  • Type: Object
  • Default:
 {
    Dedupe: {},
    ExtraErrorData: {},
    ReportingObserver: {},
    RewriteFrames: {},
    Vue: {attachProps: true, logErrors: this.options.dev}
 }

serverIntegrations

  • Type: Object
  • Default:
  {
    Dedupe: {},
    ExtraErrorData: {},
    RewriteFrames: {},
    Transaction: {}
  }

tracing

  • Type: Boolean or Object

@sentry/tracing should be installed manually when using this option (it is currently a dependency of @sentry/node)

  • Default: false
  • Enables the BrowserTracing integration for client performance monitoring
  • Takes the following object configuration format (default values shown):
  {
    tracesSampleRate: 1.0,
    vueOptions: {
      tracing: true,
      tracingOptions: {
        hooks: [ 'mount', 'update' ],
        timeout: 2000,
        trackComponents: true
      }
    },
    browserOptions: {}
  }

config

  • Type: Object
  • Default:
  {
    environment: this.options.dev ? 'development' : 'production'
  }
  • Sentry options common to the server and client that are passed to Sentry.init(options). See Sentry documentation at https://docs.sentry.io/platforms/javascript/guides/vue/configuration/options/
  • Note that config.dsn is automatically set based on the root dsn option
  • The value for config.release is automatically inferred from the local repo unless specified manually
  • Do not use config.integrations, use clientIntegrations or serverIntegrations

serverConfig

  • Type: Object
  • Default: {}
  • Specified key will override common Sentry options for server sentry plugin

clientConfig

  • Type: Object
  • Default: {}
  • Specified keys will override common Sentry options for client sentry plugin

webpackConfig

requestHandlerConfig

Edit this page on GitHub Updated at Wed, Nov 24, 2021