@arena-materials/sentry
v1.0.2
Published
arena materials for sentry
Downloads
11
Readme
Sentry
@arena-materials/sentry for arena
安装
yarn add @arena-materials/sentry -S
使用
import Sentry from '@arena-materials/sentry'
Vue.use(Sentry, {
dsn: 'you dsn'
})
Vue 中使用
<template>
// TODO
</template>
<script>
export default {
methods: {
onClick () {
// Set user information, as well as tags and further extras
this.$sentry.configureScope(scope => {
scope.setExtra('battery', 0.7)
scope.setTag('user_mode', 'admin')
scope.setUser({ id: '4711' })
// scope.clear();
})
// Add a breadcrumb for future events
this.$sentry.addBreadcrumb({
message: 'My Breadcrumb',
// ...
})
// Capture exceptions, messages or manual events
this.$sentry.captureMessage('Hello, world!')
this.$sentry.captureException(new Error('Good bye'))
this.$sentry.captureEvent({
message: 'Manual',
stacktrace: [
// ...
],
})
}
}
}
</script>
JS 中使用
原型链
import Vue from 'vue'
Vue.sentry.captureMessage('Hello, world!')
Vue.sentry.captureException(new Error('Good bye'))
// TODO more api ...
直接调用
import MSentry from '@arena-materials/sentry'
MSentry.Sentry.captureMessage('Hello, world!')
MSentry.Sentry.captureException(new Error('Good bye'))
捕获 Http 错误
这里只针对 使用 我们提供的模板生成的项目
src/base/http.base.js
新增 HttpError
import Http from '@arena-materials/http'
import HttpConfig from '@/config/http.config'
+ import HttpError from '@arena-materials/sentry/src/http.error'
Http.use(HttpConfig)
+ Http.use(HttpError)
const http = new Http({
baseURL: '/api'
})
export default http
API 文档
@see http://getsentry.github.io/sentry-javascript/modules/browser.html