sentry-module

Sentry module for NuxtJS

Github星跟踪图

@nuxtjs/sentry

npm version
npm downloads
Circle CI
Codecov
Dependencies
Standard JS

Sentry module for Nuxt.js

Features

The module enables error logging through Sentry.

  • Please note that version 2.2.0 of this package removed the older public_key and private_key options, since the updated Sentry packages don't support these anymore.
  • Please note that version 2.0.0 of this package introduces a breaking change. See #30 for more information.

Setup

  • Add @nuxtjs/sentry dependency using yarn or npm to your project
  • Add @nuxtjs/sentry to modules section of nuxt.config.js
{
  modules: [
    '@nuxtjs/sentry',
  ],

  sentry: {
    dsn: '', // Enter your project's DSN here
    config: {}, // Additional config
  }
}

Nuxt compatibility

Versions of NuxtJS before v2.4.0 are not supported by this package.

Usage

Enter your DSN in the NuxtJS config file. Additional config settings can be found here.

Usage in Vue component

In a Vue component, Sentry is available as this.$sentry, so we can call functions like

this.$sentry.captureException(new Error('example'))

where this is a Vue instance.

Usage in asyncData

While using Nuxt's asyncData method, there's $sentry object in the context:

async asyncData ({ params, $sentry }) {
  try {
    let { data } = await axios.get(`https://my-api/posts/${params.id}`)
    return { title: data.title }
  } catch (error) {
    $sentry.captureException(error)
  }
}

Usage in other lifecycle areas

For the other special Nuxt lifecycle areas like plugins, middleware, and nuxtServerInit, the $sentry object is also accessible through the context object like so:

async nuxtServerInit({ commit }, { $sentry }) {
  try {
    let { data } = await axios.get(`https://my-api/timestamp`)
    commit('setTimeStamp', data)
  } catch (error) {
    $sentry.captureException(error)
  }
}

Options

Options can be passed using either environment variables or sentry section in nuxt.config.js.
Normally, setting required DSN information would be enough.

dsn

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

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

publishRelease

sourceMapStyle

  • Type: Boolean
    • 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 braking change, it won't be set as the default until next major release

attachCommits

  • Type: Boolean
    • Default: process.env.SENTRY_AUTO_ATTACH_COMMITS, false
    • Only has effect when publishRelease = true

repo

  • Type: String
    • Default: process.env.SENTRY_RELEASE_REPO, false
    • Only has effect when publishRelease = true && attachCommits = true

disableServerRelease

disableClientRelease

clientIntegrations

serverIntegrations

config

  • Type: Object
    • Default: { environment: this.options.dev ? 'development' : 'production' }

serverConfig

  • Type: Object
    • Default: { }
    • If specified, values will override config values for server sentry plugin

clientConfig

  • Type: Object
    • Default: { }
    • If specified, values will override config values for client sentry plugin

webpackConfig

Submitting releases to Sentry

Support for the sentry-webpack-plugin was introduced #a6cd8d3. This can be used to send releases to Sentry. Use the publishRelease option to enable this feature.

Note that releases are only submitted to Sentry when (options.publishRelease && !isDev) is true.

License

MIT License

Copyright (c) Diederik van den Burger diederik@glue.group

主要指标

概览
名称与所有者nuxt-community/sentry-module
主编程语言TypeScript
编程语言JavaScript (语言数: 4)
平台
许可证MIT License
所有者活动
创建于2017-10-17 09:48:56
推送于2025-07-15 18:38:06
最后一次提交
发布数124
最新版本名称v8.0.8 (发布于 2024-09-13 10:49:19)
第一版名称v0.0.1 (发布于 2017-10-17 11:52:49)
用户参与
星数502
关注者数7
派生数112
提交数664
已启用问题?
问题数223
打开的问题数10
拉请求数361
打开的拉请求数10
关闭的拉请求数98
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?