/** * 面包屑配置,控制 breadcrumbsIntegration 的行为 */ export interface BreadcrumbsConfig { /** 是否记录 console 输出,默认 true */ console?: boolean; /** 是否记录 DOM 交互事件,默认 true */ dom?: boolean; /** 是否记录 fetch 请求,默认 true */ fetch?: boolean; /** 是否记录 XMLHttpRequest 请求,默认 true */ xhr?: boolean; /** 是否记录浏览器导航历史,默认 true */ history?: boolean; } /** * 所有框架通用的基础配置 */ export interface SentryBaseOptions { /** Sentry DSN,必填 */ dsn: string; /** 运行环境,默认 'production' */ environment?: string; /** 是否启用 Sentry,默认 true */ enabled?: boolean; /** 性能追踪采样率,默认 0.1(10%) */ tracesSampleRate?: number; /** 会话回放采样率,默认 0.1(10%) */ replaysSessionSampleRate?: number; /** 错误回放采样率,默认 1.0(100%) */ replaysOnErrorSampleRate?: number; /** * 是否启用 browserTracingIntegration,默认 true * 简化配置参数,优先级高于 integrations 数组 */ enableTracing?: boolean; /** * 是否启用 replayIntegration,默认 true * 简化配置参数,优先级高于 integrations 数组 */ enableReplay?: boolean; /** * 面包屑配置,传入时会使用该配置创建 breadcrumbsIntegration 并覆盖默认面包屑行为 * 简化配置参数,优先级高于 integrations 数组 */ breadcrumbs?: BreadcrumbsConfig; /** 事件上报前的回调,可用于过滤或修改事件 */ beforeSend?: (event: unknown) => unknown | null; /** 自定义 integrations 数组,与默认 integrations 合并 */ integrations?: unknown[]; /** 其他 Sentry 原生 init 配置项(透传) */ [key: string]: unknown; } /** Vue 3 专用配置 */ export interface Vue3SentryOptions extends SentryBaseOptions { /** Vue 3 应用实例,必填 */ app: unknown; /** Vue Router 实例,可选;提供时配置路由级别性能追踪 */ router?: unknown; } /** Vue 2 专用配置 */ export interface Vue2SentryOptions extends SentryBaseOptions { /** Vue 2 构造函数,必填 */ Vue: unknown; /** Vue Router 实例,可选;提供时配置路由级别性能追踪 */ router?: unknown; } /** React 专用配置 */ export interface ReactSentryOptions extends SentryBaseOptions { /** React Router 相关配置,可选;提供时配置路由级别性能追踪 */ reactRouter?: unknown; } /** 纯浏览器配置(使用 @sentry/browser,无框架依赖) */ export interface BrowserSentryOptions extends SentryBaseOptions { } /** * Sentry 初始化返回值 * 当 DSN 无效或 enabled=false 时,所有方法均为安全的空操作 */ export interface SentrySetupReturn { /** Sentry 是否已成功初始化 */ isInitialized: boolean; /** 手动上报异常,返回 event ID */ captureException: (error: unknown) => string | undefined; /** 手动上报消息,返回 event ID */ captureMessage: (message: string) => string | undefined; /** 设置/清除当前用户信息 */ setUser: (user: { id?: string; email?: string; username?: string; } | null) => void; } /** Source Map Vite 插件配置(用于 @sentry/vite-plugin) */ export interface SentryViteConfig { /** Sentry 组织 slug */ org: string; /** Sentry 项目 slug */ project: string; /** Sentry Auth Token */ authToken: string; /** Source Map 配置 */ sourcemaps?: { /** 构建后自动删除的文件 glob,默认 ['./dist/\*\*\/*.map'] */ filesToDeleteAfterUpload?: string[]; }; /** 其他自定义配置 */ [key: string]: unknown; } export declare const SENTRY_DEFAULTS: { readonly environment: "production"; readonly tracesSampleRate: 0.1; readonly replaysSessionSampleRate: 0.1; readonly replaysOnErrorSampleRate: 1; readonly enableTracing: true; readonly enableReplay: true; }; /** * 验证 DSN 是否有效(非空字符串且非 undefined) */ export declare function isValidDsn(dsn: string | undefined): dsn is string; /** * 创建未初始化状态的返回值 * 用于 DSN 无效或 enabled=false 时返回 */ export declare function createUninitializedReturn(): SentrySetupReturn; /** * 根据 Simplified_Config 和用户 integrations 构建最终的 integrations 列表 * * 优先级:Simplified_Config 参数 > integrations 数组 > 默认配置 * * @param options - 用户配置 * @param frameworkIntegrations - 框架特定的集成(如 Vue Router 路由追踪),已根据 options 构建 * @param sentry - Sentry SDK 对象(包含 browserTracingIntegration、replayIntegration、breadcrumbsIntegration) */ export declare function buildIntegrations(options: SentryBaseOptions, frameworkIntegrations: unknown[], sentry: { browserTracingIntegration: (opts?: unknown) => unknown; replayIntegration: (opts?: unknown) => unknown; breadcrumbsIntegration: (opts?: unknown) => unknown; }): unknown[]; /** * 合并用户配置与默认配置 * 提取 Simplified_Config 参数(enableTracing、enableReplay、breadcrumbs), * 返回干净的 Sentry init 配置对象 */ export declare function mergeConfig(userConfig: T): Omit; /** * 生成 @sentry/vite-plugin 的配置对象 * 注意:该函数仅生成配置对象,不依赖 @sentry/vite-plugin(由用户自行安装为 devDependency) * * @param config - 包含 org、project、authToken 和可选 sourcemaps 配置 * @returns 完整的 Vite 插件配置对象 */ export declare function getSentryViteConfig(config: SentryViteConfig): SentryViteConfig; //# sourceMappingURL=core.d.ts.map