UNPKG

sentry-configuration

Version:

sentry的公共配置文件

58 lines (52 loc) 1.91 kB
// index.d.ts import * as Sentry from '@sentry/vue'; import Vue from 'vue'; // 定义你的自定义Sentry配置类型 interface CustomSentryOptions { Vue: typeof Vue; router?: Vue.Router; sentryOptions?: SentryCustomOptions; } if(Object.prototype.toString.call(networkDetailAllowUrls) !== '[object Array]'){ sentryOptions.networkDetailAllowUrls = []; } if(Object.prototype.toString.call(networkRequestHeaders) !== '[object Array]'){ sentryOptions.networkRequestHeaders = []; } if(Object.prototype.toString.call(initialScope) !== '[object Object]'){ sentryOptions.initialScope = {}; } if(typeof(replaysSessionSampleRate) !== 'number'){ sentryOptions.replaysSessionSampleRate = 1; } if(typeof(debug) !== 'boolean'){ sentryOptions.debug = false; } if(typeof(beforeSend) !== 'function'){ sentryOptions.beforeSend = ()=>{}; } interface SentryCustomOptions { /** dsn地址 vue3版本必传 */ dsn?: string, /** 发布版本 vue3版本必传 */ release?: string, /** 运行环境 vue3版本必传 */ environment?: string, networkDetailAllowUrls?: string[]; networkRequestHeaders?: string[]; initialScope?: Object; replaysSessionSampleRate?: number; debug?: boolean; beforeSend?: (event: Sentry.Event, hint: Sentry.Hint) => Sentry.Event | null; } // 描述你的插件类型 declare module 'sentry-configuration' { export function install(Vue: typeof Vue, options: CustomSentryOptions): void; // 定义原型上的$sentry属性类型 export const $sentry: typeof Sentry; // 定义原型上的方法 export function httpSentryCaptureMessage(stack: object): Promise<void>; export function captureMessage(title: string, params: object, stack?: object): Promise<void>; } // 如果你希望在导入时直接使用默认导出的形式,可以这样定义 export default 'sentry-configuration';