0.1.8 • Published 5 years ago
sentry-miniprogram v0.1.8
Sentry Miniprogram
安装和使用
使用npm/yarn安装及使用微信开发工具构建包
# npm
npm install sentry-miniprogram -S
# yarn
yarn add sentry-miniprogram -S使用
import Sentry from 'sentry-miniprogram'
Sentry.init({
dsn: '__DSN__'
})
Sentry.captureMessage('Hello, world!');API
在追寻官方API规范中,完成了以下功能(若已有的方法实现有差异或期望实现未实现的功能欢迎提出或PR)
Sentry.init(options)options.dsn: string:: 项目DSNoptions.enabled?: boolean:是否启用Sentry,禁用后所有方法可调用但不会有上报功能,默认启用options.environment?: string: 环境,自定义字符串,默认productionoptions.maxBreadcrumbs?: number:最大保存的breadcrumb数量,超过指定数值后,先加入的会被丢弃,默认为20个options.getErrorStacktrace?: (err: Error) => Promise<Stacktrace>:提供自定义获取错误对象的源码信息来上报更加丰富的错误信息,返回值Stacktrace参考文档
Sentry.captureMessage(message: string, level: string = 'info'): voidSentry.captureException(error: Error): voidSentry.configureScope(callback: (scope): void)scope.setUser(user): void:scope.addBreadcrumb(breadcrumb | string): void: 支持传递字符串和Breadcrumb对象,如传递字符串则作为Breadcrumb象的message字段保存,其中timestamp默认值为当前调用方法秒时间戳scope.clearBreadcrumbs(): voidscope.setTag(key: string, val: any): voidscope.removeTag(key: string): voidscope.setTags(tags: { [props: string]: any }): void
Sentry.(...scope):对于scope的方法映射,如Sentry.setUser(user)