Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

vue-raven automatically reports uncaught JavaScript exceptions triggered from vue component

License

NotificationsYou must be signed in to change notification settings

anteriovieira/vue-raven

Repository files navigation

npm (scoped with tag)vue2npmCircleCICodecovdonate

VueRaven automatically reports uncaught JavaScript exceptions triggered from vue component, and provides a API for reporting your own errors. The captured errors will be reported to the sentry where you can get an overview of your application. If you do not already have aSentry account, creating your account will be the first step to using this package.

Installation

npm install --save vue-raven# oryarn add vue-raven

Usage

To get started, you need to configure VueRaven to use yourSentry DSN:

Bundler (Webpack, Rollup)

importVuefrom'vue'importVueRavenfrom'vue-raven'Vue.use(VueRaven,{dsn:'https://<key>@sentry.io/<project>'})

Browser

<!-- Include after Vue --><!-- Local files --><scriptsrc="vue-raven/dist/vue-raven.js"></script><!-- From CDN --><scriptsrc="https://unpkg.com/vue-raven"></script><script>Vue.use(VueRaven,{dsn:'https://<key>@sentry.io/<project>'})constapp=newVue({el:'#app',// ...})</script>

Only these settings allow VueRaven capture any uncaught exception.

Options

OptionTypeDefaultInfo
dsnStringnullThe Data Source Name
public_dsnStringnullIf value omitted it will be generated using dsn value, by removing private key part.
public_keyStringnullWill be ignored if dsn provided.
private_keyStringnullWill be ignored if dsn provided.
hostStringsentry.ioWill be ignored if dsn provided.
protocolStringhttpsWill be ignored if dsn provided.
project_IdStringnullWill be ignored if dsn provided.
pathStringnullWill be ignored if dsn provided.
disableReportBooleanfalseDisable all reports.
disableAutoReportBooleanfalseDisable auto report.
environmentStringproductionSentry's environment.

Reporting Errors

Disable auto report

By default vueraven will report the errors captured automatically, but you can disable using thedisableAutoReport option:

importVuefrom'vue'importVueRavenfrom'vue-raven'Vue.use(VueRaven,{dsn:'https://<key>@sentry.io/<project>'disableAutoReport:true,})

Report errors manually

In some cases you may want to report erros manually, for this you will have thereven-js api available at the instance of the component.

// my-componentexportdefault{methods:{// ...asyncsaveUser(){try{awaitUser.save(/* data */)}catch(err){this.$raven.captureException(err)}}}}

or

import{Raven}from'vue-raven';// my-componentexportdefault{methods:{// ...asyncsaveUser(){try{awaitUser.save(/* data */)}catch(err){Raven.captureException(err)}}}}

Live demo

We create a smallexample so you can see the plugin in action.

jsfiddle

error

License

MIT

About

vue-raven automatically reports uncaught JavaScript exceptions triggered from vue component

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp