@fz-firefly/shared 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1583 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * 全局硬性限制。
4
+ *
5
+ * 这组数字同时被三方使用:
6
+ * - SDK 在采集阶段就按上限裁剪,避免把超大报文发出去;
7
+ * - 服务端用同一组值做二次校验,防止客户端绕过;
8
+ * - 后台据此提示「已被截断」。
9
+ *
10
+ * 集中定义可以保证三端不会各说各话。修改这里的值等于修改协议,
11
+ * 必须同时评估已接入的旧版 SDK。
12
+ */
13
+ export declare const LIMITS: {
14
+ /** 单个上报信封的最大字节数(256 KB)。服务端超限直接返回 413。 */
15
+ readonly MAX_BODY_BYTES: number;
16
+ /** 一个信封最多携带的 item 数(50)。SDK 超限时自动拆成多个信封。 */
17
+ readonly MAX_ITEMS: 50;
18
+ /** 单条异常最多保留的堆栈帧数(100)。超出时保留首尾各 50 帧,中间的丢掉。 */
19
+ readonly MAX_FRAMES: 100;
20
+ /** 单条事件最多保留的面包屑条数(50)。超出时丢最旧的,保证最近的现场还在。 */
21
+ readonly MAX_BREADCRUMBS: 50;
22
+ /** 单个字符串字段的最大长度(16384 字符)。超出截断并打标记。 */
23
+ readonly MAX_FIELD_CHARS: 16384;
24
+ /** URL 类字段的最大长度(2048 字符)。 */
25
+ readonly MAX_URL_CHARS: 2048;
26
+ /** 原始错误事件的保留天数(90 天)。过期分区整月 DROP,不做逐行删除。 */
27
+ readonly EVENT_RETENTION_DAYS: 90;
28
+ /** 每个项目每分钟允许的上报请求数(300)。超出返回 429 + Retry-After。 */
29
+ readonly INGEST_RATE_LIMIT: 300;
30
+ /** occurred_at 允许比服务器时间早多少毫秒(7 天)。用于容忍离线补报。 */
31
+ readonly OCCURRED_AT_PAST_MS: number;
32
+ /** occurred_at 允许比服务器时间晚多少毫秒(5 分钟)。用于容忍设备时钟漂移。 */
33
+ readonly OCCURRED_AT_FUTURE_MS: number;
34
+ };
35
+ /**
36
+ * 错误分类。
37
+ *
38
+ * - code:代码错误,包含运行时异常、Promise 拒绝、框架错误等;
39
+ * - interface:接口错误,包含 HTTP 失败、网络错误、超时和静态资源加载失败。
40
+ *
41
+ * 分类由 SDK 在捕获点写入,服务端按上报值存储,不再推断。
42
+ */
43
+ export declare const ERROR_CATEGORIES: readonly ["code", "interface"];
44
+ /**
45
+ * 接口错误的来源。
46
+ *
47
+ * 代码错误不需要 source;接口错误用它区分 HTTP 失败、静态资源失败和手动消息。
48
+ */
49
+ export declare const ERROR_SOURCES: readonly ["http", "resource", "message"];
50
+ /**
51
+ * 事件级别,按严重程度从高到低排列。
52
+ * 聚合 issue 时取范围内最严重的一级(fatal > error > warning > info),
53
+ * 所以这个数组的顺序本身就是语义,不能随意调整。
54
+ */
55
+ export declare const LEVELS: readonly ["fatal", "error", "warning", "info"];
56
+ /**
57
+ * 运行时平台标识,会写进每条事件,供后台筛选。
58
+ *
59
+ * 注意:这是「代码跑在哪」,不是「你用什么写的」。
60
+ * 一个 uni-app 项目同一份源码在 H5 下是 web,在微信里是 mp-weixin,
61
+ * 由 SDK 运行时用 uni.getSystemInfoSync().uniPlatform 判定。
62
+ */
63
+ export declare const PLATFORMS: readonly ["web", "mp-weixin", "mp-alipay", "app"];
64
+ /**
65
+ * 环境标识。issue 的唯一键是 (项目, 环境, 指纹),
66
+ * 所以生产与测试的同类错误会各自聚合成独立 issue,计数互不污染。
67
+ * 如需新增环境(例如 pre),必须同步服务端 issue 的唯一键与后台筛选项。
68
+ */
69
+ export declare const ENVIRONMENTS: readonly ["production", "staging", "development"];
70
+ /** 事件级别:fatal | error | warning | info */
71
+ export type Level = (typeof LEVELS)[number];
72
+ /** 运行时平台:web | mp-weixin | mp-alipay | app */
73
+ export type Platform = (typeof PLATFORMS)[number];
74
+ /** 运行环境:production | staging | development */
75
+ export type Environment = (typeof ENVIRONMENTS)[number];
76
+ /** 错误分类:code | interface */
77
+ export type ErrorCategory = (typeof ERROR_CATEGORIES)[number];
78
+ /** 接口错误来源:http | resource | message */
79
+ export type ErrorSource = (typeof ERROR_SOURCES)[number];
80
+ /** 单个堆栈帧。 */
81
+ export type StackFrame = z.infer<typeof StackFrameSchema>;
82
+ /** 异常本体:类型、消息、堆栈。 */
83
+ export type Exception = z.infer<typeof ExceptionSchema>;
84
+ /** 一条面包屑。 */
85
+ export type Breadcrumb = z.infer<typeof BreadcrumbSchema>;
86
+ /** 用户标识(仅 id 与匿名 id)。 */
87
+ export type UserContext = z.infer<typeof UserContextSchema>;
88
+ /** 错误事件。 */
89
+ export type ErrorItem = z.infer<typeof ErrorItemSchema>;
90
+ /** 消息事件。 */
91
+ export type MessageItem = z.infer<typeof MessageItemSchema>;
92
+ /** 业务埋点事件。 */
93
+ export type TrackItem = z.infer<typeof TrackItemSchema>;
94
+ /** 任意一种事件(error | message | track 的联合类型)。 */
95
+ export type EventItem = z.infer<typeof EventItemSchema>;
96
+ /**
97
+ * 单个堆栈帧。
98
+ *
99
+ * 生产构建后的帧来自压缩代码:filename 是构建产物 URL,lineno/colno 是压缩位置。
100
+ * 服务端拿到 sourcemap 后会把它们改写成源码位置,并保留原始值在 raw_exception 里。
101
+ */
102
+ export declare const StackFrameSchema: z.ZodObject<{
103
+ /** 帧所属文件。H5 通常是完整 URL 或 /assets/xxx.js 路径。 */
104
+ filename: z.ZodString;
105
+ /** 绝对路径。浏览器给不出时与 filename 相同;用于匹配 sourcemap 时更可靠。 */
106
+ abs_path: z.ZodOptional<z.ZodString>;
107
+ /** 函数名。压缩后可能只是一个字母,还原后才是真实函数名。 */
108
+ function: z.ZodOptional<z.ZodString>;
109
+ /** 行号(从 1 开始)。压缩代码里通常都是 1。 */
110
+ lineno: z.ZodOptional<z.ZodNumber>;
111
+ /** 列号(从 0 开始)。sourcemap 还原靠它定位到具体字符。 */
112
+ colno: z.ZodOptional<z.ZodNumber>;
113
+ /**
114
+ * 该帧是否属于业务代码。
115
+ * 依赖与框架内部(node_modules、框架运行时)为 false,参与指纹计算时只取 true 的帧。
116
+ */
117
+ in_app: z.ZodDefault<z.ZodBoolean>;
118
+ }, "strip", z.ZodTypeAny, {
119
+ filename: string;
120
+ in_app: boolean;
121
+ function?: string | undefined;
122
+ abs_path?: string | undefined;
123
+ lineno?: number | undefined;
124
+ colno?: number | undefined;
125
+ }, {
126
+ filename: string;
127
+ function?: string | undefined;
128
+ abs_path?: string | undefined;
129
+ lineno?: number | undefined;
130
+ colno?: number | undefined;
131
+ in_app?: boolean | undefined;
132
+ }>;
133
+ /**
134
+ * 异常本体。
135
+ * type/value 用于展示与指纹,stacktrace 用于源码定位。
136
+ */
137
+ export declare const ExceptionSchema: z.ZodObject<{
138
+ /** 异常类型,例如 TypeError、ReferenceError。缺省时调用方应回退为 'Error'。 */
139
+ type: z.ZodString;
140
+ /** 异常消息原文。展示前会被归一化(数字、UUID、URL 等替换为占位符)。 */
141
+ value: z.ZodOptional<z.ZodString>;
142
+ /** 调用栈。没有时无法做源码还原,只能按消息聚合。 */
143
+ stacktrace: z.ZodOptional<z.ZodObject<{
144
+ /** 帧数组,顺序为「调用处在前、根因在后」,与 V8 的 stack 字符串顺序一致。 */
145
+ frames: z.ZodArray<z.ZodObject<{
146
+ /** 帧所属文件。H5 通常是完整 URL 或 /assets/xxx.js 路径。 */
147
+ filename: z.ZodString;
148
+ /** 绝对路径。浏览器给不出时与 filename 相同;用于匹配 sourcemap 时更可靠。 */
149
+ abs_path: z.ZodOptional<z.ZodString>;
150
+ /** 函数名。压缩后可能只是一个字母,还原后才是真实函数名。 */
151
+ function: z.ZodOptional<z.ZodString>;
152
+ /** 行号(从 1 开始)。压缩代码里通常都是 1。 */
153
+ lineno: z.ZodOptional<z.ZodNumber>;
154
+ /** 列号(从 0 开始)。sourcemap 还原靠它定位到具体字符。 */
155
+ colno: z.ZodOptional<z.ZodNumber>;
156
+ /**
157
+ * 该帧是否属于业务代码。
158
+ * 依赖与框架内部(node_modules、框架运行时)为 false,参与指纹计算时只取 true 的帧。
159
+ */
160
+ in_app: z.ZodDefault<z.ZodBoolean>;
161
+ }, "strip", z.ZodTypeAny, {
162
+ filename: string;
163
+ in_app: boolean;
164
+ function?: string | undefined;
165
+ abs_path?: string | undefined;
166
+ lineno?: number | undefined;
167
+ colno?: number | undefined;
168
+ }, {
169
+ filename: string;
170
+ function?: string | undefined;
171
+ abs_path?: string | undefined;
172
+ lineno?: number | undefined;
173
+ colno?: number | undefined;
174
+ in_app?: boolean | undefined;
175
+ }>, "many">;
176
+ }, "strip", z.ZodTypeAny, {
177
+ frames: {
178
+ filename: string;
179
+ in_app: boolean;
180
+ function?: string | undefined;
181
+ abs_path?: string | undefined;
182
+ lineno?: number | undefined;
183
+ colno?: number | undefined;
184
+ }[];
185
+ }, {
186
+ frames: {
187
+ filename: string;
188
+ function?: string | undefined;
189
+ abs_path?: string | undefined;
190
+ lineno?: number | undefined;
191
+ colno?: number | undefined;
192
+ in_app?: boolean | undefined;
193
+ }[];
194
+ }>>;
195
+ }, "strip", z.ZodTypeAny, {
196
+ type: string;
197
+ value?: string | undefined;
198
+ stacktrace?: {
199
+ frames: {
200
+ filename: string;
201
+ in_app: boolean;
202
+ function?: string | undefined;
203
+ abs_path?: string | undefined;
204
+ lineno?: number | undefined;
205
+ colno?: number | undefined;
206
+ }[];
207
+ } | undefined;
208
+ }, {
209
+ type: string;
210
+ value?: string | undefined;
211
+ stacktrace?: {
212
+ frames: {
213
+ filename: string;
214
+ function?: string | undefined;
215
+ abs_path?: string | undefined;
216
+ lineno?: number | undefined;
217
+ colno?: number | undefined;
218
+ in_app?: boolean | undefined;
219
+ }[];
220
+ } | undefined;
221
+ }>;
222
+ /**
223
+ * 面包屑:错误发生前的关键动作。
224
+ * 用来回答「用户点了什么、发了什么请求、跳了哪个页面」,是定位白屏类问题的核心线索。
225
+ */
226
+ export declare const BreadcrumbSchema: z.ZodObject<{
227
+ /** 类别,例如 http / navigation / ui / console。决定后台时间线如何渲染。 */
228
+ type: z.ZodString;
229
+ /** 更细的分类,例如 fetch / xhr / route / click。可选。 */
230
+ category: z.ZodOptional<z.ZodString>;
231
+ /** 该面包屑自身的级别,用于在时间线上高亮异常项。 */
232
+ level: z.ZodOptional<z.ZodEnum<["fatal", "error", "warning", "info"]>>;
233
+ /** 事件发生时间,Unix 毫秒时间戳。面包屑按它升序展示。 */
234
+ timestamp: z.ZodNumber;
235
+ /**
236
+ * 页面会话 id。
237
+ *
238
+ * 同一次页面进入(包括 SPA 路由切换)产生的面包屑共享一个 id,
239
+ * 后台可以据此把「进入页面 → 发请求 → 点击 → 报错」串成一条时间线。
240
+ */
241
+ session_id: z.ZodOptional<z.ZodString>;
242
+ /** 页面会话内的单调递增序号。时间戳相同毫秒时仍能保持稳定顺序。 */
243
+ seq: z.ZodOptional<z.ZodNumber>;
244
+ /** 相对页面进入时刻的毫秒数。后台展示为 +1.2s 更容易判断现场。 */
245
+ t_rel_ms: z.ZodOptional<z.ZodNumber>;
246
+ /** 简短描述,例如「提交订单」。后台直接展示这一行。 */
247
+ message: z.ZodOptional<z.ZodString>;
248
+ /** 结构化细节,例如 { method, url, status_code, duration_ms }。 */
249
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
250
+ }, "strip", z.ZodTypeAny, {
251
+ type: string;
252
+ timestamp: number;
253
+ message?: string | undefined;
254
+ category?: string | undefined;
255
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
256
+ session_id?: string | undefined;
257
+ seq?: number | undefined;
258
+ t_rel_ms?: number | undefined;
259
+ data?: Record<string, unknown> | undefined;
260
+ }, {
261
+ type: string;
262
+ timestamp: number;
263
+ message?: string | undefined;
264
+ category?: string | undefined;
265
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
266
+ session_id?: string | undefined;
267
+ seq?: number | undefined;
268
+ t_rel_ms?: number | undefined;
269
+ data?: Record<string, unknown> | undefined;
270
+ }>;
271
+ /**
272
+ * 用户标识。
273
+ * 只允许放 id 与匿名 id,手机号、姓名等 PII 一律不允许上报。
274
+ */
275
+ export declare const UserContextSchema: z.ZodObject<{
276
+ /** 业务系统里的用户 id。登录后由 setUser 注入。 */
277
+ id: z.ZodOptional<z.ZodString>;
278
+ /** SDK 首次启动生成的持久匿名 id,用于未登录用户的影响面统计。 */
279
+ anonymous_id: z.ZodOptional<z.ZodString>;
280
+ }, "strip", z.ZodTypeAny, {
281
+ id?: string | undefined;
282
+ anonymous_id?: string | undefined;
283
+ }, {
284
+ id?: string | undefined;
285
+ anonymous_id?: string | undefined;
286
+ }>;
287
+ /**
288
+ * 运行环境上下文,按类别分组:device / os / browser / network / app。
289
+ * 每个类别的字段由平台适配层自行决定,服务端只做透传与展示。
290
+ */
291
+ export declare const ContextsSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
292
+ /**
293
+ * 自定义标签。键值都必须是标量,便于后台做聚合与筛选。
294
+ * 与 contexts 的区别:tags 用于索引与分组,contexts 用于展示完整现场。
295
+ */
296
+ export declare const TagsSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
297
+ /**
298
+ * 错误事件。
299
+ * SDK 捕获未处理异常或手动 captureException 时产生。
300
+ */
301
+ export declare const ErrorItemSchema: z.ZodObject<{
302
+ /**
303
+ * 客户端生成的事件 uuid,是服务端的幂等键。
304
+ * 同一条事件重试多次时,服务端靠它去重,不会重复计数。
305
+ */
306
+ event_id: z.ZodString;
307
+ /**
308
+ * 客户端节流窗口内的累计次数。
309
+ *
310
+ * 例如同一签名错误在 5 秒内触发 100 次,SDK 只发一个包,
311
+ * occurrences 就是 100。issue 的 event_count 按它累加,
312
+ * 否则「报错 100 次」会被记成 1 次。
313
+ */
314
+ occurrences: z.ZodDefault<z.ZodNumber>;
315
+ /** 事件发生时间,ISO8601 UTC 字符串。服务端会把它钳制到允许窗口内。 */
316
+ timestamp: z.ZodString;
317
+ /** 运行时平台。见 constants.ts 中 PLATFORMS 的说明。 */
318
+ platform: z.ZodEnum<["web", "mp-weixin", "mp-alipay", "app"]>;
319
+ /** 运行环境。issue 按环境隔离聚合。 */
320
+ environment: z.ZodEnum<["production", "staging", "development"]>;
321
+ /** 版本号,必须与上传 sourcemap 时的 release 完全一致,否则无法还原。 */
322
+ release: z.ZodOptional<z.ZodString>;
323
+ /** 分发标识,用于同一版本多包场景(例如 h5 / mp-weixin / app)。 */
324
+ dist: z.ZodOptional<z.ZodString>;
325
+ /** 错误发生前的面包屑,最多 50 条,按时间升序。 */
326
+ breadcrumbs: z.ZodDefault<z.ZodArray<z.ZodObject<{
327
+ /** 类别,例如 http / navigation / ui / console。决定后台时间线如何渲染。 */
328
+ type: z.ZodString;
329
+ /** 更细的分类,例如 fetch / xhr / route / click。可选。 */
330
+ category: z.ZodOptional<z.ZodString>;
331
+ /** 该面包屑自身的级别,用于在时间线上高亮异常项。 */
332
+ level: z.ZodOptional<z.ZodEnum<["fatal", "error", "warning", "info"]>>;
333
+ /** 事件发生时间,Unix 毫秒时间戳。面包屑按它升序展示。 */
334
+ timestamp: z.ZodNumber;
335
+ /**
336
+ * 页面会话 id。
337
+ *
338
+ * 同一次页面进入(包括 SPA 路由切换)产生的面包屑共享一个 id,
339
+ * 后台可以据此把「进入页面 → 发请求 → 点击 → 报错」串成一条时间线。
340
+ */
341
+ session_id: z.ZodOptional<z.ZodString>;
342
+ /** 页面会话内的单调递增序号。时间戳相同毫秒时仍能保持稳定顺序。 */
343
+ seq: z.ZodOptional<z.ZodNumber>;
344
+ /** 相对页面进入时刻的毫秒数。后台展示为 +1.2s 更容易判断现场。 */
345
+ t_rel_ms: z.ZodOptional<z.ZodNumber>;
346
+ /** 简短描述,例如「提交订单」。后台直接展示这一行。 */
347
+ message: z.ZodOptional<z.ZodString>;
348
+ /** 结构化细节,例如 { method, url, status_code, duration_ms }。 */
349
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
350
+ }, "strip", z.ZodTypeAny, {
351
+ type: string;
352
+ timestamp: number;
353
+ message?: string | undefined;
354
+ category?: string | undefined;
355
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
356
+ session_id?: string | undefined;
357
+ seq?: number | undefined;
358
+ t_rel_ms?: number | undefined;
359
+ data?: Record<string, unknown> | undefined;
360
+ }, {
361
+ type: string;
362
+ timestamp: number;
363
+ message?: string | undefined;
364
+ category?: string | undefined;
365
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
366
+ session_id?: string | undefined;
367
+ seq?: number | undefined;
368
+ t_rel_ms?: number | undefined;
369
+ data?: Record<string, unknown> | undefined;
370
+ }>, "many">>;
371
+ /** 设备、系统、浏览器、网络等上下文。 */
372
+ contexts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
373
+ /** 自定义标签。 */
374
+ tags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
375
+ /** 用户标识。不传时服务端按匿名 id 统计影响用户。 */
376
+ user: z.ZodOptional<z.ZodObject<{
377
+ /** 业务系统里的用户 id。登录后由 setUser 注入。 */
378
+ id: z.ZodOptional<z.ZodString>;
379
+ /** SDK 首次启动生成的持久匿名 id,用于未登录用户的影响面统计。 */
380
+ anonymous_id: z.ZodOptional<z.ZodString>;
381
+ }, "strip", z.ZodTypeAny, {
382
+ id?: string | undefined;
383
+ anonymous_id?: string | undefined;
384
+ }, {
385
+ id?: string | undefined;
386
+ anonymous_id?: string | undefined;
387
+ }>>;
388
+ /** 出错页面的完整 URL。 */
389
+ url: z.ZodOptional<z.ZodString>;
390
+ /** 出错页面的路由路径,例如 /order/detail。用于按页面聚合。 */
391
+ route: z.ZodOptional<z.ZodString>;
392
+ /** 事件类型判别字段。 */
393
+ type: z.ZodLiteral<"error">;
394
+ /** 代码错误固定为 code。 */
395
+ category: z.ZodLiteral<"code">;
396
+ /** 严重级别。 */
397
+ level: z.ZodEnum<["fatal", "error", "warning", "info"]>;
398
+ /** 冗余的异常消息,便于不解析 exception 时直接展示。 */
399
+ message: z.ZodOptional<z.ZodString>;
400
+ /** 异常本体,包含类型、消息与堆栈。 */
401
+ exception: z.ZodObject<{
402
+ /** 异常类型,例如 TypeError、ReferenceError。缺省时调用方应回退为 'Error'。 */
403
+ type: z.ZodString;
404
+ /** 异常消息原文。展示前会被归一化(数字、UUID、URL 等替换为占位符)。 */
405
+ value: z.ZodOptional<z.ZodString>;
406
+ /** 调用栈。没有时无法做源码还原,只能按消息聚合。 */
407
+ stacktrace: z.ZodOptional<z.ZodObject<{
408
+ /** 帧数组,顺序为「调用处在前、根因在后」,与 V8 的 stack 字符串顺序一致。 */
409
+ frames: z.ZodArray<z.ZodObject<{
410
+ /** 帧所属文件。H5 通常是完整 URL 或 /assets/xxx.js 路径。 */
411
+ filename: z.ZodString;
412
+ /** 绝对路径。浏览器给不出时与 filename 相同;用于匹配 sourcemap 时更可靠。 */
413
+ abs_path: z.ZodOptional<z.ZodString>;
414
+ /** 函数名。压缩后可能只是一个字母,还原后才是真实函数名。 */
415
+ function: z.ZodOptional<z.ZodString>;
416
+ /** 行号(从 1 开始)。压缩代码里通常都是 1。 */
417
+ lineno: z.ZodOptional<z.ZodNumber>;
418
+ /** 列号(从 0 开始)。sourcemap 还原靠它定位到具体字符。 */
419
+ colno: z.ZodOptional<z.ZodNumber>;
420
+ /**
421
+ * 该帧是否属于业务代码。
422
+ * 依赖与框架内部(node_modules、框架运行时)为 false,参与指纹计算时只取 true 的帧。
423
+ */
424
+ in_app: z.ZodDefault<z.ZodBoolean>;
425
+ }, "strip", z.ZodTypeAny, {
426
+ filename: string;
427
+ in_app: boolean;
428
+ function?: string | undefined;
429
+ abs_path?: string | undefined;
430
+ lineno?: number | undefined;
431
+ colno?: number | undefined;
432
+ }, {
433
+ filename: string;
434
+ function?: string | undefined;
435
+ abs_path?: string | undefined;
436
+ lineno?: number | undefined;
437
+ colno?: number | undefined;
438
+ in_app?: boolean | undefined;
439
+ }>, "many">;
440
+ }, "strip", z.ZodTypeAny, {
441
+ frames: {
442
+ filename: string;
443
+ in_app: boolean;
444
+ function?: string | undefined;
445
+ abs_path?: string | undefined;
446
+ lineno?: number | undefined;
447
+ colno?: number | undefined;
448
+ }[];
449
+ }, {
450
+ frames: {
451
+ filename: string;
452
+ function?: string | undefined;
453
+ abs_path?: string | undefined;
454
+ lineno?: number | undefined;
455
+ colno?: number | undefined;
456
+ in_app?: boolean | undefined;
457
+ }[];
458
+ }>>;
459
+ }, "strip", z.ZodTypeAny, {
460
+ type: string;
461
+ value?: string | undefined;
462
+ stacktrace?: {
463
+ frames: {
464
+ filename: string;
465
+ in_app: boolean;
466
+ function?: string | undefined;
467
+ abs_path?: string | undefined;
468
+ lineno?: number | undefined;
469
+ colno?: number | undefined;
470
+ }[];
471
+ } | undefined;
472
+ }, {
473
+ type: string;
474
+ value?: string | undefined;
475
+ stacktrace?: {
476
+ frames: {
477
+ filename: string;
478
+ function?: string | undefined;
479
+ abs_path?: string | undefined;
480
+ lineno?: number | undefined;
481
+ colno?: number | undefined;
482
+ in_app?: boolean | undefined;
483
+ }[];
484
+ } | undefined;
485
+ }>;
486
+ }, "strip", z.ZodTypeAny, {
487
+ type: "error";
488
+ category: "code";
489
+ level: "fatal" | "error" | "warning" | "info";
490
+ timestamp: string;
491
+ exception: {
492
+ type: string;
493
+ value?: string | undefined;
494
+ stacktrace?: {
495
+ frames: {
496
+ filename: string;
497
+ in_app: boolean;
498
+ function?: string | undefined;
499
+ abs_path?: string | undefined;
500
+ lineno?: number | undefined;
501
+ colno?: number | undefined;
502
+ }[];
503
+ } | undefined;
504
+ };
505
+ event_id: string;
506
+ occurrences: number;
507
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
508
+ environment: "production" | "staging" | "development";
509
+ breadcrumbs: {
510
+ type: string;
511
+ timestamp: number;
512
+ message?: string | undefined;
513
+ category?: string | undefined;
514
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
515
+ session_id?: string | undefined;
516
+ seq?: number | undefined;
517
+ t_rel_ms?: number | undefined;
518
+ data?: Record<string, unknown> | undefined;
519
+ }[];
520
+ contexts: Record<string, Record<string, unknown>>;
521
+ tags: Record<string, string | number | boolean>;
522
+ message?: string | undefined;
523
+ release?: string | undefined;
524
+ dist?: string | undefined;
525
+ user?: {
526
+ id?: string | undefined;
527
+ anonymous_id?: string | undefined;
528
+ } | undefined;
529
+ url?: string | undefined;
530
+ route?: string | undefined;
531
+ }, {
532
+ type: "error";
533
+ category: "code";
534
+ level: "fatal" | "error" | "warning" | "info";
535
+ timestamp: string;
536
+ exception: {
537
+ type: string;
538
+ value?: string | undefined;
539
+ stacktrace?: {
540
+ frames: {
541
+ filename: string;
542
+ function?: string | undefined;
543
+ abs_path?: string | undefined;
544
+ lineno?: number | undefined;
545
+ colno?: number | undefined;
546
+ in_app?: boolean | undefined;
547
+ }[];
548
+ } | undefined;
549
+ };
550
+ event_id: string;
551
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
552
+ environment: "production" | "staging" | "development";
553
+ message?: string | undefined;
554
+ occurrences?: number | undefined;
555
+ release?: string | undefined;
556
+ dist?: string | undefined;
557
+ breadcrumbs?: {
558
+ type: string;
559
+ timestamp: number;
560
+ message?: string | undefined;
561
+ category?: string | undefined;
562
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
563
+ session_id?: string | undefined;
564
+ seq?: number | undefined;
565
+ t_rel_ms?: number | undefined;
566
+ data?: Record<string, unknown> | undefined;
567
+ }[] | undefined;
568
+ contexts?: Record<string, Record<string, unknown>> | undefined;
569
+ tags?: Record<string, string | number | boolean> | undefined;
570
+ user?: {
571
+ id?: string | undefined;
572
+ anonymous_id?: string | undefined;
573
+ } | undefined;
574
+ url?: string | undefined;
575
+ route?: string | undefined;
576
+ }>;
577
+ /**
578
+ * 消息事件。
579
+ * 用于 captureMessage 上报「不是异常但需要记录」的信息。
580
+ */
581
+ export declare const MessageItemSchema: z.ZodObject<{
582
+ /**
583
+ * 客户端生成的事件 uuid,是服务端的幂等键。
584
+ * 同一条事件重试多次时,服务端靠它去重,不会重复计数。
585
+ */
586
+ event_id: z.ZodString;
587
+ /**
588
+ * 客户端节流窗口内的累计次数。
589
+ *
590
+ * 例如同一签名错误在 5 秒内触发 100 次,SDK 只发一个包,
591
+ * occurrences 就是 100。issue 的 event_count 按它累加,
592
+ * 否则「报错 100 次」会被记成 1 次。
593
+ */
594
+ occurrences: z.ZodDefault<z.ZodNumber>;
595
+ /** 事件发生时间,ISO8601 UTC 字符串。服务端会把它钳制到允许窗口内。 */
596
+ timestamp: z.ZodString;
597
+ /** 运行时平台。见 constants.ts 中 PLATFORMS 的说明。 */
598
+ platform: z.ZodEnum<["web", "mp-weixin", "mp-alipay", "app"]>;
599
+ /** 运行环境。issue 按环境隔离聚合。 */
600
+ environment: z.ZodEnum<["production", "staging", "development"]>;
601
+ /** 版本号,必须与上传 sourcemap 时的 release 完全一致,否则无法还原。 */
602
+ release: z.ZodOptional<z.ZodString>;
603
+ /** 分发标识,用于同一版本多包场景(例如 h5 / mp-weixin / app)。 */
604
+ dist: z.ZodOptional<z.ZodString>;
605
+ /** 错误发生前的面包屑,最多 50 条,按时间升序。 */
606
+ breadcrumbs: z.ZodDefault<z.ZodArray<z.ZodObject<{
607
+ /** 类别,例如 http / navigation / ui / console。决定后台时间线如何渲染。 */
608
+ type: z.ZodString;
609
+ /** 更细的分类,例如 fetch / xhr / route / click。可选。 */
610
+ category: z.ZodOptional<z.ZodString>;
611
+ /** 该面包屑自身的级别,用于在时间线上高亮异常项。 */
612
+ level: z.ZodOptional<z.ZodEnum<["fatal", "error", "warning", "info"]>>;
613
+ /** 事件发生时间,Unix 毫秒时间戳。面包屑按它升序展示。 */
614
+ timestamp: z.ZodNumber;
615
+ /**
616
+ * 页面会话 id。
617
+ *
618
+ * 同一次页面进入(包括 SPA 路由切换)产生的面包屑共享一个 id,
619
+ * 后台可以据此把「进入页面 → 发请求 → 点击 → 报错」串成一条时间线。
620
+ */
621
+ session_id: z.ZodOptional<z.ZodString>;
622
+ /** 页面会话内的单调递增序号。时间戳相同毫秒时仍能保持稳定顺序。 */
623
+ seq: z.ZodOptional<z.ZodNumber>;
624
+ /** 相对页面进入时刻的毫秒数。后台展示为 +1.2s 更容易判断现场。 */
625
+ t_rel_ms: z.ZodOptional<z.ZodNumber>;
626
+ /** 简短描述,例如「提交订单」。后台直接展示这一行。 */
627
+ message: z.ZodOptional<z.ZodString>;
628
+ /** 结构化细节,例如 { method, url, status_code, duration_ms }。 */
629
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
630
+ }, "strip", z.ZodTypeAny, {
631
+ type: string;
632
+ timestamp: number;
633
+ message?: string | undefined;
634
+ category?: string | undefined;
635
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
636
+ session_id?: string | undefined;
637
+ seq?: number | undefined;
638
+ t_rel_ms?: number | undefined;
639
+ data?: Record<string, unknown> | undefined;
640
+ }, {
641
+ type: string;
642
+ timestamp: number;
643
+ message?: string | undefined;
644
+ category?: string | undefined;
645
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
646
+ session_id?: string | undefined;
647
+ seq?: number | undefined;
648
+ t_rel_ms?: number | undefined;
649
+ data?: Record<string, unknown> | undefined;
650
+ }>, "many">>;
651
+ /** 设备、系统、浏览器、网络等上下文。 */
652
+ contexts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
653
+ /** 自定义标签。 */
654
+ tags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
655
+ /** 用户标识。不传时服务端按匿名 id 统计影响用户。 */
656
+ user: z.ZodOptional<z.ZodObject<{
657
+ /** 业务系统里的用户 id。登录后由 setUser 注入。 */
658
+ id: z.ZodOptional<z.ZodString>;
659
+ /** SDK 首次启动生成的持久匿名 id,用于未登录用户的影响面统计。 */
660
+ anonymous_id: z.ZodOptional<z.ZodString>;
661
+ }, "strip", z.ZodTypeAny, {
662
+ id?: string | undefined;
663
+ anonymous_id?: string | undefined;
664
+ }, {
665
+ id?: string | undefined;
666
+ anonymous_id?: string | undefined;
667
+ }>>;
668
+ /** 出错页面的完整 URL。 */
669
+ url: z.ZodOptional<z.ZodString>;
670
+ /** 出错页面的路由路径,例如 /order/detail。用于按页面聚合。 */
671
+ route: z.ZodOptional<z.ZodString>;
672
+ /** 事件类型判别字段。 */
673
+ type: z.ZodLiteral<"message">;
674
+ /** 接口错误固定为 interface。 */
675
+ category: z.ZodLiteral<"interface">;
676
+ /** 接口错误来源,必须显式上报。 */
677
+ source: z.ZodEnum<["http", "resource", "message"]>;
678
+ /** 严重级别。 */
679
+ level: z.ZodEnum<["fatal", "error", "warning", "info"]>;
680
+ /** 消息正文,必填。 */
681
+ message: z.ZodString;
682
+ }, "strip", z.ZodTypeAny, {
683
+ message: string;
684
+ type: "message";
685
+ category: "interface";
686
+ level: "fatal" | "error" | "warning" | "info";
687
+ timestamp: string;
688
+ event_id: string;
689
+ occurrences: number;
690
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
691
+ environment: "production" | "staging" | "development";
692
+ breadcrumbs: {
693
+ type: string;
694
+ timestamp: number;
695
+ message?: string | undefined;
696
+ category?: string | undefined;
697
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
698
+ session_id?: string | undefined;
699
+ seq?: number | undefined;
700
+ t_rel_ms?: number | undefined;
701
+ data?: Record<string, unknown> | undefined;
702
+ }[];
703
+ contexts: Record<string, Record<string, unknown>>;
704
+ tags: Record<string, string | number | boolean>;
705
+ source: "http" | "resource" | "message";
706
+ release?: string | undefined;
707
+ dist?: string | undefined;
708
+ user?: {
709
+ id?: string | undefined;
710
+ anonymous_id?: string | undefined;
711
+ } | undefined;
712
+ url?: string | undefined;
713
+ route?: string | undefined;
714
+ }, {
715
+ message: string;
716
+ type: "message";
717
+ category: "interface";
718
+ level: "fatal" | "error" | "warning" | "info";
719
+ timestamp: string;
720
+ event_id: string;
721
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
722
+ environment: "production" | "staging" | "development";
723
+ source: "http" | "resource" | "message";
724
+ occurrences?: number | undefined;
725
+ release?: string | undefined;
726
+ dist?: string | undefined;
727
+ breadcrumbs?: {
728
+ type: string;
729
+ timestamp: number;
730
+ message?: string | undefined;
731
+ category?: string | undefined;
732
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
733
+ session_id?: string | undefined;
734
+ seq?: number | undefined;
735
+ t_rel_ms?: number | undefined;
736
+ data?: Record<string, unknown> | undefined;
737
+ }[] | undefined;
738
+ contexts?: Record<string, Record<string, unknown>> | undefined;
739
+ tags?: Record<string, string | number | boolean> | undefined;
740
+ user?: {
741
+ id?: string | undefined;
742
+ anonymous_id?: string | undefined;
743
+ } | undefined;
744
+ url?: string | undefined;
745
+ route?: string | undefined;
746
+ }>;
747
+ /**
748
+ * 业务埋点事件。
749
+ *
750
+ * 与错误事件走同一个信封、同一个 ingest 接口,但服务端写入独立的 track_events 表,
751
+ * 不参与指纹聚合,也不占用 issue 的计数。
752
+ */
753
+ export declare const TrackItemSchema: z.ZodObject<{
754
+ /**
755
+ * 客户端生成的事件 uuid,是服务端的幂等键。
756
+ * 同一条事件重试多次时,服务端靠它去重,不会重复计数。
757
+ */
758
+ event_id: z.ZodString;
759
+ /**
760
+ * 客户端节流窗口内的累计次数。
761
+ *
762
+ * 例如同一签名错误在 5 秒内触发 100 次,SDK 只发一个包,
763
+ * occurrences 就是 100。issue 的 event_count 按它累加,
764
+ * 否则「报错 100 次」会被记成 1 次。
765
+ */
766
+ occurrences: z.ZodDefault<z.ZodNumber>;
767
+ /** 事件发生时间,ISO8601 UTC 字符串。服务端会把它钳制到允许窗口内。 */
768
+ timestamp: z.ZodString;
769
+ /** 运行时平台。见 constants.ts 中 PLATFORMS 的说明。 */
770
+ platform: z.ZodEnum<["web", "mp-weixin", "mp-alipay", "app"]>;
771
+ /** 运行环境。issue 按环境隔离聚合。 */
772
+ environment: z.ZodEnum<["production", "staging", "development"]>;
773
+ /** 版本号,必须与上传 sourcemap 时的 release 完全一致,否则无法还原。 */
774
+ release: z.ZodOptional<z.ZodString>;
775
+ /** 分发标识,用于同一版本多包场景(例如 h5 / mp-weixin / app)。 */
776
+ dist: z.ZodOptional<z.ZodString>;
777
+ /** 错误发生前的面包屑,最多 50 条,按时间升序。 */
778
+ breadcrumbs: z.ZodDefault<z.ZodArray<z.ZodObject<{
779
+ /** 类别,例如 http / navigation / ui / console。决定后台时间线如何渲染。 */
780
+ type: z.ZodString;
781
+ /** 更细的分类,例如 fetch / xhr / route / click。可选。 */
782
+ category: z.ZodOptional<z.ZodString>;
783
+ /** 该面包屑自身的级别,用于在时间线上高亮异常项。 */
784
+ level: z.ZodOptional<z.ZodEnum<["fatal", "error", "warning", "info"]>>;
785
+ /** 事件发生时间,Unix 毫秒时间戳。面包屑按它升序展示。 */
786
+ timestamp: z.ZodNumber;
787
+ /**
788
+ * 页面会话 id。
789
+ *
790
+ * 同一次页面进入(包括 SPA 路由切换)产生的面包屑共享一个 id,
791
+ * 后台可以据此把「进入页面 → 发请求 → 点击 → 报错」串成一条时间线。
792
+ */
793
+ session_id: z.ZodOptional<z.ZodString>;
794
+ /** 页面会话内的单调递增序号。时间戳相同毫秒时仍能保持稳定顺序。 */
795
+ seq: z.ZodOptional<z.ZodNumber>;
796
+ /** 相对页面进入时刻的毫秒数。后台展示为 +1.2s 更容易判断现场。 */
797
+ t_rel_ms: z.ZodOptional<z.ZodNumber>;
798
+ /** 简短描述,例如「提交订单」。后台直接展示这一行。 */
799
+ message: z.ZodOptional<z.ZodString>;
800
+ /** 结构化细节,例如 { method, url, status_code, duration_ms }。 */
801
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
802
+ }, "strip", z.ZodTypeAny, {
803
+ type: string;
804
+ timestamp: number;
805
+ message?: string | undefined;
806
+ category?: string | undefined;
807
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
808
+ session_id?: string | undefined;
809
+ seq?: number | undefined;
810
+ t_rel_ms?: number | undefined;
811
+ data?: Record<string, unknown> | undefined;
812
+ }, {
813
+ type: string;
814
+ timestamp: number;
815
+ message?: string | undefined;
816
+ category?: string | undefined;
817
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
818
+ session_id?: string | undefined;
819
+ seq?: number | undefined;
820
+ t_rel_ms?: number | undefined;
821
+ data?: Record<string, unknown> | undefined;
822
+ }>, "many">>;
823
+ /** 设备、系统、浏览器、网络等上下文。 */
824
+ contexts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
825
+ /** 自定义标签。 */
826
+ tags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
827
+ /** 用户标识。不传时服务端按匿名 id 统计影响用户。 */
828
+ user: z.ZodOptional<z.ZodObject<{
829
+ /** 业务系统里的用户 id。登录后由 setUser 注入。 */
830
+ id: z.ZodOptional<z.ZodString>;
831
+ /** SDK 首次启动生成的持久匿名 id,用于未登录用户的影响面统计。 */
832
+ anonymous_id: z.ZodOptional<z.ZodString>;
833
+ }, "strip", z.ZodTypeAny, {
834
+ id?: string | undefined;
835
+ anonymous_id?: string | undefined;
836
+ }, {
837
+ id?: string | undefined;
838
+ anonymous_id?: string | undefined;
839
+ }>>;
840
+ /** 出错页面的完整 URL。 */
841
+ url: z.ZodOptional<z.ZodString>;
842
+ /** 出错页面的路由路径,例如 /order/detail。用于按页面聚合。 */
843
+ route: z.ZodOptional<z.ZodString>;
844
+ /** 事件类型判别字段。 */
845
+ type: z.ZodLiteral<"track">;
846
+ /** 埋点事件名,例如 pay_click。是后台查询的主要筛选条件。 */
847
+ event_name: z.ZodString;
848
+ /** 事件属性,任意 JSON 对象。例如 { amount: 99, sku: 'A-1024' }。 */
849
+ properties: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
850
+ }, "strip", z.ZodTypeAny, {
851
+ type: "track";
852
+ timestamp: string;
853
+ event_id: string;
854
+ occurrences: number;
855
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
856
+ environment: "production" | "staging" | "development";
857
+ breadcrumbs: {
858
+ type: string;
859
+ timestamp: number;
860
+ message?: string | undefined;
861
+ category?: string | undefined;
862
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
863
+ session_id?: string | undefined;
864
+ seq?: number | undefined;
865
+ t_rel_ms?: number | undefined;
866
+ data?: Record<string, unknown> | undefined;
867
+ }[];
868
+ contexts: Record<string, Record<string, unknown>>;
869
+ tags: Record<string, string | number | boolean>;
870
+ event_name: string;
871
+ properties: Record<string, unknown>;
872
+ release?: string | undefined;
873
+ dist?: string | undefined;
874
+ user?: {
875
+ id?: string | undefined;
876
+ anonymous_id?: string | undefined;
877
+ } | undefined;
878
+ url?: string | undefined;
879
+ route?: string | undefined;
880
+ }, {
881
+ type: "track";
882
+ timestamp: string;
883
+ event_id: string;
884
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
885
+ environment: "production" | "staging" | "development";
886
+ event_name: string;
887
+ occurrences?: number | undefined;
888
+ release?: string | undefined;
889
+ dist?: string | undefined;
890
+ breadcrumbs?: {
891
+ type: string;
892
+ timestamp: number;
893
+ message?: string | undefined;
894
+ category?: string | undefined;
895
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
896
+ session_id?: string | undefined;
897
+ seq?: number | undefined;
898
+ t_rel_ms?: number | undefined;
899
+ data?: Record<string, unknown> | undefined;
900
+ }[] | undefined;
901
+ contexts?: Record<string, Record<string, unknown>> | undefined;
902
+ tags?: Record<string, string | number | boolean> | undefined;
903
+ user?: {
904
+ id?: string | undefined;
905
+ anonymous_id?: string | undefined;
906
+ } | undefined;
907
+ url?: string | undefined;
908
+ route?: string | undefined;
909
+ properties?: Record<string, unknown> | undefined;
910
+ }>;
911
+ /**
912
+ * 单条事件。按 type 判别为 error / message / track。
913
+ */
914
+ export declare const EventItemSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
915
+ /**
916
+ * 客户端生成的事件 uuid,是服务端的幂等键。
917
+ * 同一条事件重试多次时,服务端靠它去重,不会重复计数。
918
+ */
919
+ event_id: z.ZodString;
920
+ /**
921
+ * 客户端节流窗口内的累计次数。
922
+ *
923
+ * 例如同一签名错误在 5 秒内触发 100 次,SDK 只发一个包,
924
+ * occurrences 就是 100。issue 的 event_count 按它累加,
925
+ * 否则「报错 100 次」会被记成 1 次。
926
+ */
927
+ occurrences: z.ZodDefault<z.ZodNumber>;
928
+ /** 事件发生时间,ISO8601 UTC 字符串。服务端会把它钳制到允许窗口内。 */
929
+ timestamp: z.ZodString;
930
+ /** 运行时平台。见 constants.ts 中 PLATFORMS 的说明。 */
931
+ platform: z.ZodEnum<["web", "mp-weixin", "mp-alipay", "app"]>;
932
+ /** 运行环境。issue 按环境隔离聚合。 */
933
+ environment: z.ZodEnum<["production", "staging", "development"]>;
934
+ /** 版本号,必须与上传 sourcemap 时的 release 完全一致,否则无法还原。 */
935
+ release: z.ZodOptional<z.ZodString>;
936
+ /** 分发标识,用于同一版本多包场景(例如 h5 / mp-weixin / app)。 */
937
+ dist: z.ZodOptional<z.ZodString>;
938
+ /** 错误发生前的面包屑,最多 50 条,按时间升序。 */
939
+ breadcrumbs: z.ZodDefault<z.ZodArray<z.ZodObject<{
940
+ /** 类别,例如 http / navigation / ui / console。决定后台时间线如何渲染。 */
941
+ type: z.ZodString;
942
+ /** 更细的分类,例如 fetch / xhr / route / click。可选。 */
943
+ category: z.ZodOptional<z.ZodString>;
944
+ /** 该面包屑自身的级别,用于在时间线上高亮异常项。 */
945
+ level: z.ZodOptional<z.ZodEnum<["fatal", "error", "warning", "info"]>>;
946
+ /** 事件发生时间,Unix 毫秒时间戳。面包屑按它升序展示。 */
947
+ timestamp: z.ZodNumber;
948
+ /**
949
+ * 页面会话 id。
950
+ *
951
+ * 同一次页面进入(包括 SPA 路由切换)产生的面包屑共享一个 id,
952
+ * 后台可以据此把「进入页面 → 发请求 → 点击 → 报错」串成一条时间线。
953
+ */
954
+ session_id: z.ZodOptional<z.ZodString>;
955
+ /** 页面会话内的单调递增序号。时间戳相同毫秒时仍能保持稳定顺序。 */
956
+ seq: z.ZodOptional<z.ZodNumber>;
957
+ /** 相对页面进入时刻的毫秒数。后台展示为 +1.2s 更容易判断现场。 */
958
+ t_rel_ms: z.ZodOptional<z.ZodNumber>;
959
+ /** 简短描述,例如「提交订单」。后台直接展示这一行。 */
960
+ message: z.ZodOptional<z.ZodString>;
961
+ /** 结构化细节,例如 { method, url, status_code, duration_ms }。 */
962
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
963
+ }, "strip", z.ZodTypeAny, {
964
+ type: string;
965
+ timestamp: number;
966
+ message?: string | undefined;
967
+ category?: string | undefined;
968
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
969
+ session_id?: string | undefined;
970
+ seq?: number | undefined;
971
+ t_rel_ms?: number | undefined;
972
+ data?: Record<string, unknown> | undefined;
973
+ }, {
974
+ type: string;
975
+ timestamp: number;
976
+ message?: string | undefined;
977
+ category?: string | undefined;
978
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
979
+ session_id?: string | undefined;
980
+ seq?: number | undefined;
981
+ t_rel_ms?: number | undefined;
982
+ data?: Record<string, unknown> | undefined;
983
+ }>, "many">>;
984
+ /** 设备、系统、浏览器、网络等上下文。 */
985
+ contexts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
986
+ /** 自定义标签。 */
987
+ tags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
988
+ /** 用户标识。不传时服务端按匿名 id 统计影响用户。 */
989
+ user: z.ZodOptional<z.ZodObject<{
990
+ /** 业务系统里的用户 id。登录后由 setUser 注入。 */
991
+ id: z.ZodOptional<z.ZodString>;
992
+ /** SDK 首次启动生成的持久匿名 id,用于未登录用户的影响面统计。 */
993
+ anonymous_id: z.ZodOptional<z.ZodString>;
994
+ }, "strip", z.ZodTypeAny, {
995
+ id?: string | undefined;
996
+ anonymous_id?: string | undefined;
997
+ }, {
998
+ id?: string | undefined;
999
+ anonymous_id?: string | undefined;
1000
+ }>>;
1001
+ /** 出错页面的完整 URL。 */
1002
+ url: z.ZodOptional<z.ZodString>;
1003
+ /** 出错页面的路由路径,例如 /order/detail。用于按页面聚合。 */
1004
+ route: z.ZodOptional<z.ZodString>;
1005
+ /** 事件类型判别字段。 */
1006
+ type: z.ZodLiteral<"error">;
1007
+ /** 代码错误固定为 code。 */
1008
+ category: z.ZodLiteral<"code">;
1009
+ /** 严重级别。 */
1010
+ level: z.ZodEnum<["fatal", "error", "warning", "info"]>;
1011
+ /** 冗余的异常消息,便于不解析 exception 时直接展示。 */
1012
+ message: z.ZodOptional<z.ZodString>;
1013
+ /** 异常本体,包含类型、消息与堆栈。 */
1014
+ exception: z.ZodObject<{
1015
+ /** 异常类型,例如 TypeError、ReferenceError。缺省时调用方应回退为 'Error'。 */
1016
+ type: z.ZodString;
1017
+ /** 异常消息原文。展示前会被归一化(数字、UUID、URL 等替换为占位符)。 */
1018
+ value: z.ZodOptional<z.ZodString>;
1019
+ /** 调用栈。没有时无法做源码还原,只能按消息聚合。 */
1020
+ stacktrace: z.ZodOptional<z.ZodObject<{
1021
+ /** 帧数组,顺序为「调用处在前、根因在后」,与 V8 的 stack 字符串顺序一致。 */
1022
+ frames: z.ZodArray<z.ZodObject<{
1023
+ /** 帧所属文件。H5 通常是完整 URL 或 /assets/xxx.js 路径。 */
1024
+ filename: z.ZodString;
1025
+ /** 绝对路径。浏览器给不出时与 filename 相同;用于匹配 sourcemap 时更可靠。 */
1026
+ abs_path: z.ZodOptional<z.ZodString>;
1027
+ /** 函数名。压缩后可能只是一个字母,还原后才是真实函数名。 */
1028
+ function: z.ZodOptional<z.ZodString>;
1029
+ /** 行号(从 1 开始)。压缩代码里通常都是 1。 */
1030
+ lineno: z.ZodOptional<z.ZodNumber>;
1031
+ /** 列号(从 0 开始)。sourcemap 还原靠它定位到具体字符。 */
1032
+ colno: z.ZodOptional<z.ZodNumber>;
1033
+ /**
1034
+ * 该帧是否属于业务代码。
1035
+ * 依赖与框架内部(node_modules、框架运行时)为 false,参与指纹计算时只取 true 的帧。
1036
+ */
1037
+ in_app: z.ZodDefault<z.ZodBoolean>;
1038
+ }, "strip", z.ZodTypeAny, {
1039
+ filename: string;
1040
+ in_app: boolean;
1041
+ function?: string | undefined;
1042
+ abs_path?: string | undefined;
1043
+ lineno?: number | undefined;
1044
+ colno?: number | undefined;
1045
+ }, {
1046
+ filename: string;
1047
+ function?: string | undefined;
1048
+ abs_path?: string | undefined;
1049
+ lineno?: number | undefined;
1050
+ colno?: number | undefined;
1051
+ in_app?: boolean | undefined;
1052
+ }>, "many">;
1053
+ }, "strip", z.ZodTypeAny, {
1054
+ frames: {
1055
+ filename: string;
1056
+ in_app: boolean;
1057
+ function?: string | undefined;
1058
+ abs_path?: string | undefined;
1059
+ lineno?: number | undefined;
1060
+ colno?: number | undefined;
1061
+ }[];
1062
+ }, {
1063
+ frames: {
1064
+ filename: string;
1065
+ function?: string | undefined;
1066
+ abs_path?: string | undefined;
1067
+ lineno?: number | undefined;
1068
+ colno?: number | undefined;
1069
+ in_app?: boolean | undefined;
1070
+ }[];
1071
+ }>>;
1072
+ }, "strip", z.ZodTypeAny, {
1073
+ type: string;
1074
+ value?: string | undefined;
1075
+ stacktrace?: {
1076
+ frames: {
1077
+ filename: string;
1078
+ in_app: boolean;
1079
+ function?: string | undefined;
1080
+ abs_path?: string | undefined;
1081
+ lineno?: number | undefined;
1082
+ colno?: number | undefined;
1083
+ }[];
1084
+ } | undefined;
1085
+ }, {
1086
+ type: string;
1087
+ value?: string | undefined;
1088
+ stacktrace?: {
1089
+ frames: {
1090
+ filename: string;
1091
+ function?: string | undefined;
1092
+ abs_path?: string | undefined;
1093
+ lineno?: number | undefined;
1094
+ colno?: number | undefined;
1095
+ in_app?: boolean | undefined;
1096
+ }[];
1097
+ } | undefined;
1098
+ }>;
1099
+ }, "strip", z.ZodTypeAny, {
1100
+ type: "error";
1101
+ category: "code";
1102
+ level: "fatal" | "error" | "warning" | "info";
1103
+ timestamp: string;
1104
+ exception: {
1105
+ type: string;
1106
+ value?: string | undefined;
1107
+ stacktrace?: {
1108
+ frames: {
1109
+ filename: string;
1110
+ in_app: boolean;
1111
+ function?: string | undefined;
1112
+ abs_path?: string | undefined;
1113
+ lineno?: number | undefined;
1114
+ colno?: number | undefined;
1115
+ }[];
1116
+ } | undefined;
1117
+ };
1118
+ event_id: string;
1119
+ occurrences: number;
1120
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
1121
+ environment: "production" | "staging" | "development";
1122
+ breadcrumbs: {
1123
+ type: string;
1124
+ timestamp: number;
1125
+ message?: string | undefined;
1126
+ category?: string | undefined;
1127
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
1128
+ session_id?: string | undefined;
1129
+ seq?: number | undefined;
1130
+ t_rel_ms?: number | undefined;
1131
+ data?: Record<string, unknown> | undefined;
1132
+ }[];
1133
+ contexts: Record<string, Record<string, unknown>>;
1134
+ tags: Record<string, string | number | boolean>;
1135
+ message?: string | undefined;
1136
+ release?: string | undefined;
1137
+ dist?: string | undefined;
1138
+ user?: {
1139
+ id?: string | undefined;
1140
+ anonymous_id?: string | undefined;
1141
+ } | undefined;
1142
+ url?: string | undefined;
1143
+ route?: string | undefined;
1144
+ }, {
1145
+ type: "error";
1146
+ category: "code";
1147
+ level: "fatal" | "error" | "warning" | "info";
1148
+ timestamp: string;
1149
+ exception: {
1150
+ type: string;
1151
+ value?: string | undefined;
1152
+ stacktrace?: {
1153
+ frames: {
1154
+ filename: string;
1155
+ function?: string | undefined;
1156
+ abs_path?: string | undefined;
1157
+ lineno?: number | undefined;
1158
+ colno?: number | undefined;
1159
+ in_app?: boolean | undefined;
1160
+ }[];
1161
+ } | undefined;
1162
+ };
1163
+ event_id: string;
1164
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
1165
+ environment: "production" | "staging" | "development";
1166
+ message?: string | undefined;
1167
+ occurrences?: number | undefined;
1168
+ release?: string | undefined;
1169
+ dist?: string | undefined;
1170
+ breadcrumbs?: {
1171
+ type: string;
1172
+ timestamp: number;
1173
+ message?: string | undefined;
1174
+ category?: string | undefined;
1175
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
1176
+ session_id?: string | undefined;
1177
+ seq?: number | undefined;
1178
+ t_rel_ms?: number | undefined;
1179
+ data?: Record<string, unknown> | undefined;
1180
+ }[] | undefined;
1181
+ contexts?: Record<string, Record<string, unknown>> | undefined;
1182
+ tags?: Record<string, string | number | boolean> | undefined;
1183
+ user?: {
1184
+ id?: string | undefined;
1185
+ anonymous_id?: string | undefined;
1186
+ } | undefined;
1187
+ url?: string | undefined;
1188
+ route?: string | undefined;
1189
+ }>, z.ZodObject<{
1190
+ /**
1191
+ * 客户端生成的事件 uuid,是服务端的幂等键。
1192
+ * 同一条事件重试多次时,服务端靠它去重,不会重复计数。
1193
+ */
1194
+ event_id: z.ZodString;
1195
+ /**
1196
+ * 客户端节流窗口内的累计次数。
1197
+ *
1198
+ * 例如同一签名错误在 5 秒内触发 100 次,SDK 只发一个包,
1199
+ * occurrences 就是 100。issue 的 event_count 按它累加,
1200
+ * 否则「报错 100 次」会被记成 1 次。
1201
+ */
1202
+ occurrences: z.ZodDefault<z.ZodNumber>;
1203
+ /** 事件发生时间,ISO8601 UTC 字符串。服务端会把它钳制到允许窗口内。 */
1204
+ timestamp: z.ZodString;
1205
+ /** 运行时平台。见 constants.ts 中 PLATFORMS 的说明。 */
1206
+ platform: z.ZodEnum<["web", "mp-weixin", "mp-alipay", "app"]>;
1207
+ /** 运行环境。issue 按环境隔离聚合。 */
1208
+ environment: z.ZodEnum<["production", "staging", "development"]>;
1209
+ /** 版本号,必须与上传 sourcemap 时的 release 完全一致,否则无法还原。 */
1210
+ release: z.ZodOptional<z.ZodString>;
1211
+ /** 分发标识,用于同一版本多包场景(例如 h5 / mp-weixin / app)。 */
1212
+ dist: z.ZodOptional<z.ZodString>;
1213
+ /** 错误发生前的面包屑,最多 50 条,按时间升序。 */
1214
+ breadcrumbs: z.ZodDefault<z.ZodArray<z.ZodObject<{
1215
+ /** 类别,例如 http / navigation / ui / console。决定后台时间线如何渲染。 */
1216
+ type: z.ZodString;
1217
+ /** 更细的分类,例如 fetch / xhr / route / click。可选。 */
1218
+ category: z.ZodOptional<z.ZodString>;
1219
+ /** 该面包屑自身的级别,用于在时间线上高亮异常项。 */
1220
+ level: z.ZodOptional<z.ZodEnum<["fatal", "error", "warning", "info"]>>;
1221
+ /** 事件发生时间,Unix 毫秒时间戳。面包屑按它升序展示。 */
1222
+ timestamp: z.ZodNumber;
1223
+ /**
1224
+ * 页面会话 id。
1225
+ *
1226
+ * 同一次页面进入(包括 SPA 路由切换)产生的面包屑共享一个 id,
1227
+ * 后台可以据此把「进入页面 → 发请求 → 点击 → 报错」串成一条时间线。
1228
+ */
1229
+ session_id: z.ZodOptional<z.ZodString>;
1230
+ /** 页面会话内的单调递增序号。时间戳相同毫秒时仍能保持稳定顺序。 */
1231
+ seq: z.ZodOptional<z.ZodNumber>;
1232
+ /** 相对页面进入时刻的毫秒数。后台展示为 +1.2s 更容易判断现场。 */
1233
+ t_rel_ms: z.ZodOptional<z.ZodNumber>;
1234
+ /** 简短描述,例如「提交订单」。后台直接展示这一行。 */
1235
+ message: z.ZodOptional<z.ZodString>;
1236
+ /** 结构化细节,例如 { method, url, status_code, duration_ms }。 */
1237
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1238
+ }, "strip", z.ZodTypeAny, {
1239
+ type: string;
1240
+ timestamp: number;
1241
+ message?: string | undefined;
1242
+ category?: string | undefined;
1243
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
1244
+ session_id?: string | undefined;
1245
+ seq?: number | undefined;
1246
+ t_rel_ms?: number | undefined;
1247
+ data?: Record<string, unknown> | undefined;
1248
+ }, {
1249
+ type: string;
1250
+ timestamp: number;
1251
+ message?: string | undefined;
1252
+ category?: string | undefined;
1253
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
1254
+ session_id?: string | undefined;
1255
+ seq?: number | undefined;
1256
+ t_rel_ms?: number | undefined;
1257
+ data?: Record<string, unknown> | undefined;
1258
+ }>, "many">>;
1259
+ /** 设备、系统、浏览器、网络等上下文。 */
1260
+ contexts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1261
+ /** 自定义标签。 */
1262
+ tags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
1263
+ /** 用户标识。不传时服务端按匿名 id 统计影响用户。 */
1264
+ user: z.ZodOptional<z.ZodObject<{
1265
+ /** 业务系统里的用户 id。登录后由 setUser 注入。 */
1266
+ id: z.ZodOptional<z.ZodString>;
1267
+ /** SDK 首次启动生成的持久匿名 id,用于未登录用户的影响面统计。 */
1268
+ anonymous_id: z.ZodOptional<z.ZodString>;
1269
+ }, "strip", z.ZodTypeAny, {
1270
+ id?: string | undefined;
1271
+ anonymous_id?: string | undefined;
1272
+ }, {
1273
+ id?: string | undefined;
1274
+ anonymous_id?: string | undefined;
1275
+ }>>;
1276
+ /** 出错页面的完整 URL。 */
1277
+ url: z.ZodOptional<z.ZodString>;
1278
+ /** 出错页面的路由路径,例如 /order/detail。用于按页面聚合。 */
1279
+ route: z.ZodOptional<z.ZodString>;
1280
+ /** 事件类型判别字段。 */
1281
+ type: z.ZodLiteral<"message">;
1282
+ /** 接口错误固定为 interface。 */
1283
+ category: z.ZodLiteral<"interface">;
1284
+ /** 接口错误来源,必须显式上报。 */
1285
+ source: z.ZodEnum<["http", "resource", "message"]>;
1286
+ /** 严重级别。 */
1287
+ level: z.ZodEnum<["fatal", "error", "warning", "info"]>;
1288
+ /** 消息正文,必填。 */
1289
+ message: z.ZodString;
1290
+ }, "strip", z.ZodTypeAny, {
1291
+ message: string;
1292
+ type: "message";
1293
+ category: "interface";
1294
+ level: "fatal" | "error" | "warning" | "info";
1295
+ timestamp: string;
1296
+ event_id: string;
1297
+ occurrences: number;
1298
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
1299
+ environment: "production" | "staging" | "development";
1300
+ breadcrumbs: {
1301
+ type: string;
1302
+ timestamp: number;
1303
+ message?: string | undefined;
1304
+ category?: string | undefined;
1305
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
1306
+ session_id?: string | undefined;
1307
+ seq?: number | undefined;
1308
+ t_rel_ms?: number | undefined;
1309
+ data?: Record<string, unknown> | undefined;
1310
+ }[];
1311
+ contexts: Record<string, Record<string, unknown>>;
1312
+ tags: Record<string, string | number | boolean>;
1313
+ source: "http" | "resource" | "message";
1314
+ release?: string | undefined;
1315
+ dist?: string | undefined;
1316
+ user?: {
1317
+ id?: string | undefined;
1318
+ anonymous_id?: string | undefined;
1319
+ } | undefined;
1320
+ url?: string | undefined;
1321
+ route?: string | undefined;
1322
+ }, {
1323
+ message: string;
1324
+ type: "message";
1325
+ category: "interface";
1326
+ level: "fatal" | "error" | "warning" | "info";
1327
+ timestamp: string;
1328
+ event_id: string;
1329
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
1330
+ environment: "production" | "staging" | "development";
1331
+ source: "http" | "resource" | "message";
1332
+ occurrences?: number | undefined;
1333
+ release?: string | undefined;
1334
+ dist?: string | undefined;
1335
+ breadcrumbs?: {
1336
+ type: string;
1337
+ timestamp: number;
1338
+ message?: string | undefined;
1339
+ category?: string | undefined;
1340
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
1341
+ session_id?: string | undefined;
1342
+ seq?: number | undefined;
1343
+ t_rel_ms?: number | undefined;
1344
+ data?: Record<string, unknown> | undefined;
1345
+ }[] | undefined;
1346
+ contexts?: Record<string, Record<string, unknown>> | undefined;
1347
+ tags?: Record<string, string | number | boolean> | undefined;
1348
+ user?: {
1349
+ id?: string | undefined;
1350
+ anonymous_id?: string | undefined;
1351
+ } | undefined;
1352
+ url?: string | undefined;
1353
+ route?: string | undefined;
1354
+ }>, z.ZodObject<{
1355
+ /**
1356
+ * 客户端生成的事件 uuid,是服务端的幂等键。
1357
+ * 同一条事件重试多次时,服务端靠它去重,不会重复计数。
1358
+ */
1359
+ event_id: z.ZodString;
1360
+ /**
1361
+ * 客户端节流窗口内的累计次数。
1362
+ *
1363
+ * 例如同一签名错误在 5 秒内触发 100 次,SDK 只发一个包,
1364
+ * occurrences 就是 100。issue 的 event_count 按它累加,
1365
+ * 否则「报错 100 次」会被记成 1 次。
1366
+ */
1367
+ occurrences: z.ZodDefault<z.ZodNumber>;
1368
+ /** 事件发生时间,ISO8601 UTC 字符串。服务端会把它钳制到允许窗口内。 */
1369
+ timestamp: z.ZodString;
1370
+ /** 运行时平台。见 constants.ts 中 PLATFORMS 的说明。 */
1371
+ platform: z.ZodEnum<["web", "mp-weixin", "mp-alipay", "app"]>;
1372
+ /** 运行环境。issue 按环境隔离聚合。 */
1373
+ environment: z.ZodEnum<["production", "staging", "development"]>;
1374
+ /** 版本号,必须与上传 sourcemap 时的 release 完全一致,否则无法还原。 */
1375
+ release: z.ZodOptional<z.ZodString>;
1376
+ /** 分发标识,用于同一版本多包场景(例如 h5 / mp-weixin / app)。 */
1377
+ dist: z.ZodOptional<z.ZodString>;
1378
+ /** 错误发生前的面包屑,最多 50 条,按时间升序。 */
1379
+ breadcrumbs: z.ZodDefault<z.ZodArray<z.ZodObject<{
1380
+ /** 类别,例如 http / navigation / ui / console。决定后台时间线如何渲染。 */
1381
+ type: z.ZodString;
1382
+ /** 更细的分类,例如 fetch / xhr / route / click。可选。 */
1383
+ category: z.ZodOptional<z.ZodString>;
1384
+ /** 该面包屑自身的级别,用于在时间线上高亮异常项。 */
1385
+ level: z.ZodOptional<z.ZodEnum<["fatal", "error", "warning", "info"]>>;
1386
+ /** 事件发生时间,Unix 毫秒时间戳。面包屑按它升序展示。 */
1387
+ timestamp: z.ZodNumber;
1388
+ /**
1389
+ * 页面会话 id。
1390
+ *
1391
+ * 同一次页面进入(包括 SPA 路由切换)产生的面包屑共享一个 id,
1392
+ * 后台可以据此把「进入页面 → 发请求 → 点击 → 报错」串成一条时间线。
1393
+ */
1394
+ session_id: z.ZodOptional<z.ZodString>;
1395
+ /** 页面会话内的单调递增序号。时间戳相同毫秒时仍能保持稳定顺序。 */
1396
+ seq: z.ZodOptional<z.ZodNumber>;
1397
+ /** 相对页面进入时刻的毫秒数。后台展示为 +1.2s 更容易判断现场。 */
1398
+ t_rel_ms: z.ZodOptional<z.ZodNumber>;
1399
+ /** 简短描述,例如「提交订单」。后台直接展示这一行。 */
1400
+ message: z.ZodOptional<z.ZodString>;
1401
+ /** 结构化细节,例如 { method, url, status_code, duration_ms }。 */
1402
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1403
+ }, "strip", z.ZodTypeAny, {
1404
+ type: string;
1405
+ timestamp: number;
1406
+ message?: string | undefined;
1407
+ category?: string | undefined;
1408
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
1409
+ session_id?: string | undefined;
1410
+ seq?: number | undefined;
1411
+ t_rel_ms?: number | undefined;
1412
+ data?: Record<string, unknown> | undefined;
1413
+ }, {
1414
+ type: string;
1415
+ timestamp: number;
1416
+ message?: string | undefined;
1417
+ category?: string | undefined;
1418
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
1419
+ session_id?: string | undefined;
1420
+ seq?: number | undefined;
1421
+ t_rel_ms?: number | undefined;
1422
+ data?: Record<string, unknown> | undefined;
1423
+ }>, "many">>;
1424
+ /** 设备、系统、浏览器、网络等上下文。 */
1425
+ contexts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1426
+ /** 自定义标签。 */
1427
+ tags: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
1428
+ /** 用户标识。不传时服务端按匿名 id 统计影响用户。 */
1429
+ user: z.ZodOptional<z.ZodObject<{
1430
+ /** 业务系统里的用户 id。登录后由 setUser 注入。 */
1431
+ id: z.ZodOptional<z.ZodString>;
1432
+ /** SDK 首次启动生成的持久匿名 id,用于未登录用户的影响面统计。 */
1433
+ anonymous_id: z.ZodOptional<z.ZodString>;
1434
+ }, "strip", z.ZodTypeAny, {
1435
+ id?: string | undefined;
1436
+ anonymous_id?: string | undefined;
1437
+ }, {
1438
+ id?: string | undefined;
1439
+ anonymous_id?: string | undefined;
1440
+ }>>;
1441
+ /** 出错页面的完整 URL。 */
1442
+ url: z.ZodOptional<z.ZodString>;
1443
+ /** 出错页面的路由路径,例如 /order/detail。用于按页面聚合。 */
1444
+ route: z.ZodOptional<z.ZodString>;
1445
+ /** 事件类型判别字段。 */
1446
+ type: z.ZodLiteral<"track">;
1447
+ /** 埋点事件名,例如 pay_click。是后台查询的主要筛选条件。 */
1448
+ event_name: z.ZodString;
1449
+ /** 事件属性,任意 JSON 对象。例如 { amount: 99, sku: 'A-1024' }。 */
1450
+ properties: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1451
+ }, "strip", z.ZodTypeAny, {
1452
+ type: "track";
1453
+ timestamp: string;
1454
+ event_id: string;
1455
+ occurrences: number;
1456
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
1457
+ environment: "production" | "staging" | "development";
1458
+ breadcrumbs: {
1459
+ type: string;
1460
+ timestamp: number;
1461
+ message?: string | undefined;
1462
+ category?: string | undefined;
1463
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
1464
+ session_id?: string | undefined;
1465
+ seq?: number | undefined;
1466
+ t_rel_ms?: number | undefined;
1467
+ data?: Record<string, unknown> | undefined;
1468
+ }[];
1469
+ contexts: Record<string, Record<string, unknown>>;
1470
+ tags: Record<string, string | number | boolean>;
1471
+ event_name: string;
1472
+ properties: Record<string, unknown>;
1473
+ release?: string | undefined;
1474
+ dist?: string | undefined;
1475
+ user?: {
1476
+ id?: string | undefined;
1477
+ anonymous_id?: string | undefined;
1478
+ } | undefined;
1479
+ url?: string | undefined;
1480
+ route?: string | undefined;
1481
+ }, {
1482
+ type: "track";
1483
+ timestamp: string;
1484
+ event_id: string;
1485
+ platform: "web" | "mp-weixin" | "mp-alipay" | "app";
1486
+ environment: "production" | "staging" | "development";
1487
+ event_name: string;
1488
+ occurrences?: number | undefined;
1489
+ release?: string | undefined;
1490
+ dist?: string | undefined;
1491
+ breadcrumbs?: {
1492
+ type: string;
1493
+ timestamp: number;
1494
+ message?: string | undefined;
1495
+ category?: string | undefined;
1496
+ level?: "fatal" | "error" | "warning" | "info" | undefined;
1497
+ session_id?: string | undefined;
1498
+ seq?: number | undefined;
1499
+ t_rel_ms?: number | undefined;
1500
+ data?: Record<string, unknown> | undefined;
1501
+ }[] | undefined;
1502
+ contexts?: Record<string, Record<string, unknown>> | undefined;
1503
+ tags?: Record<string, string | number | boolean> | undefined;
1504
+ user?: {
1505
+ id?: string | undefined;
1506
+ anonymous_id?: string | undefined;
1507
+ } | undefined;
1508
+ url?: string | undefined;
1509
+ route?: string | undefined;
1510
+ properties?: Record<string, unknown> | undefined;
1511
+ }>]>;
1512
+ /**
1513
+ * 信封级字段。
1514
+ *
1515
+ * 这里刻意把 items 定义为 unknown[]:单个 item 非法时只丢弃它并计数,
1516
+ * 不能因为一条脏数据把整包有效数据一起拒绝。
1517
+ */
1518
+ export declare const EnvelopeSchema: z.ZodObject<{
1519
+ /** 上报方 SDK 的名称与版本,用于排查协议兼容问题。 */
1520
+ sdk: z.ZodObject<{
1521
+ /** 包名,例如 @fz-firefly/web。 */
1522
+ name: z.ZodString;
1523
+ /** SDK 版本号,例如 0.2.0。 */
1524
+ version: z.ZodString;
1525
+ }, "strip", z.ZodTypeAny, {
1526
+ name: string;
1527
+ version: string;
1528
+ }, {
1529
+ name: string;
1530
+ version: string;
1531
+ }>;
1532
+ /** 客户端发送时间,ISO8601 UTC。服务端用它判断离线补报的延迟。 */
1533
+ sent_at: z.ZodString;
1534
+ /** 事件数组,至少 1 条、最多 50 条。 */
1535
+ items: z.ZodArray<z.ZodUnknown, "many">;
1536
+ }, "strip", z.ZodTypeAny, {
1537
+ sdk: {
1538
+ name: string;
1539
+ version: string;
1540
+ };
1541
+ sent_at: string;
1542
+ items: unknown[];
1543
+ }, {
1544
+ sdk: {
1545
+ name: string;
1546
+ version: string;
1547
+ };
1548
+ sent_at: string;
1549
+ items: unknown[];
1550
+ }>;
1551
+ /** parseEnvelope 的返回值。成功时带解析后的事件与丢弃数量,失败时带可读原因。 */
1552
+ export type ParseEnvelopeResult = {
1553
+ ok: true;
1554
+ value: {
1555
+ /** 透传的信封元信息。 */
1556
+ sdk: {
1557
+ name: string;
1558
+ version: string;
1559
+ };
1560
+ /** 透传的发送时间。 */
1561
+ sent_at: string;
1562
+ /** 逐条解析成功的事件。 */
1563
+ items: EventItem[];
1564
+ /** 因字段非法被丢弃的 item 数量。 */
1565
+ dropped: number;
1566
+ };
1567
+ } | {
1568
+ ok: false;
1569
+ error: string;
1570
+ };
1571
+ /**
1572
+ * 解析一个上报信封。
1573
+ *
1574
+ * 规则:
1575
+ * - 信封级字段(sdk / sent_at / items 数量)非法 → 整体失败;
1576
+ * - 单个 item 非法 → 只丢这一条,`dropped` 计数,其余照常返回。
1577
+ *
1578
+ * 这样一条脏数据不会拖垮整包,同时调用方能从 `dropped` 看出客户端协议是否需要升级。
1579
+ */
1580
+ export declare function parseEnvelope(raw: unknown): ParseEnvelopeResult;
1581
+ /** 包名,用于日志与协议兼容性排查。 */
1582
+ export declare const PACKAGE_NAME = "@fz-firefly/shared";
1583
+ //# sourceMappingURL=index.d.cts.map