import { ICollectorConfig } from '@arms/rum-core'; import { IConfiguration } from '@arms/rum-core'; import { ITracingOption } from '@arms/rum-core'; import { ResourceStatus } from '@arms/rum-core'; import { Shell } from '@arms/rum-core'; /** * 对外导出 shell 层, 所有 shell 层模型的 API 设计约定: * 1. API 命名空间按照 variables / functions / events 来组织 * 2. 事件(events)的命名格式为:on[Will|Did]VerbNoun?,参考 https://code.visualstudio.com/api/references/vscode-api#events * 3. 基于 Disposable 模式,对于事件的绑定、快捷键的绑定函数,返回值则是解绑函数 */ export declare class ArmsRum extends Shell { version: string; private configManager; private rpcCollector; private reporter; /** * 初始化 */ init(initConfig: IElectronConfig): Promise; /** * 为使用自定义 partition 的 BrowserWindow 注册 RUM preload 脚本。 * 在 init() 之后调用。建议在创建对应 BrowserWindow 之前调用,以确保首次页面加载即生效。 * @example * await armsRum.init({ ... }); * await armsRum.registerSession('persist:main'); * // 之后创建的使用该 partition 的窗口将自动注入 ArmsEventBridge */ registerSession(partition: string): Promise; sendEvent(event: any): void; /** * 处理渲染进程通过 IPC 上报的事件,附加 view 信息和渲染进程容器标识 * 方案一:per-event os.container='chromium' 标记渲染进程来源 * 方案二:各事件 source 字段天然区分进程语义(如 exception.source、resource.type) */ private processEvents; /** * 处理渲染进程通过 preload ArmsRum 门面上报的自定义事件。 * 复用 rum-core Shell 原生方法完成校验与组装,保证与主进程 API 语义一致; * 与 IPC bridge 路径一致,附加 view 信息和渲染进程容器标识。 */ private processCustomReport; getConfig(): IConfiguration; /** * set config */ setConfig(key: T, value: IElectronConfig[T]): void; setConfig(value: IElectronConfig): void; /** * 一行接入 tRPC 监控:包装 initTRPC.create() 返回值, * 之后 t.procedure 自动带监控 middleware,业务侧 procedure 定义无需修改 * * 如需对部分 procedure 跳过采集,使用 `collectors.rpc.filters` 配置 path 规则 * * @example * import { initTRPC } from '@trpc/server'; * import armsRum from '@arms/rum-electron'; * * const t = armsRum.instrumentTRPC(initTRPC.create()); * * export const appRouter = t.router({ * greeting: t.procedure.input(...).query(...), // 自动带监控 * }); */ instrumentTRPC(t: T): T; /** * 销毁 SDK,释放所有内部资源和监听器 */ destroy(): void; } declare const _default: ArmsRum; export default _default; declare interface IApiBaseAttr { name?: string; message?: string; success?: ResourceStatus; duration?: number; size?: number; status_code?: number | string; snapshots?: string; } declare interface IElectronConfig extends IConfiguration { /** * tracing 配置 'tracecontext' | 'b3' | 'b3multi' | 'jaeger'; */ tracing?: boolean | ITracingOption; /** * 离线队列配置 * 网络请求失败时将事件持久化到磁盘,应用重启或网络恢复时自动重发 * 默认启用 */ offlineQueue?: IOfflineQueueConfig; /** * request 自定义解析; */ evaluateApi?(request: any, response: any, error?: Error): Promise; /** * 自定义解析页面名称 */ parseViewName?(url: string): string; /** * 自定义解析 api 资源 name(对齐 browser SDK 的 parseResourceName) * 未提供时默认取 URL 的 pathname */ parseResourceName?(url: string): string; /** * SPA 路由模式 * - false: 禁用 SPA 路由追踪(默认行为,仅追踪完整页面加载) * - true/'auto': 自动检测,优先 hash 后 pathname * - 'hash': Hash 路由模式(如 React HashRouter) * - 'history': History API 路由模式(如 React BrowserRouter) */ spaMode?: SpaMode; /** * 是否自动注入 browser SDK 到渲染进程 * - true(默认): 自动注入,无需手动引入 * - false: 不自动注入,需要用户在渲染进程中手动 import 并初始化 * 例如: import armsRum from '@arms/rum-electron/browser'; armsRum.init({...}) */ autoInject?: boolean; /** * 浏览器 SDK 采集器配置 * 用于自动注入模式下控制渲染进程中 browser SDK 的采集器启用/禁用 * 未配置时默认启用所有采集器 */ browserCollectors?: { [key: string]: boolean | ICollectorConfig; }; /** * 自定义 session partition,若 BrowserWindow 使用了 partition 配置则需要指定 */ partition?: string; } declare interface IOfflineQueueConfig { /** 是否启用离线队列,默认 true */ enable?: boolean; /** 最大保留天数,默认 30 */ maxAgeDays?: number; /** 最大条数,默认 200 */ maxQueueSize?: number; } /** * URL 工具模块 * 提供 URL 解析和 SpaMode 路径提取等功能 */ declare type SpaMode = false | true | 'hash' | 'history' | 'auto'; export declare const VERSION: string; export { }