tdem-web-sdk 1.0.9 → 1.0.10

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.
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  TDEM 是腾讯云数字体验监控平台提供的前端监控 SDK,涵盖错误监控、接口测速、静态资源测速、页面性能、Web Vitals、用户行为等能力。无需侵入业务代码,引入 SDK 即可自动完成监控上报。
4
4
 
5
+ 协议入库字段权威源见仓库 `.specify/memory/architecture/event-contracts/web/`。Feature 045:`no_response` 的 `event_category` 为 `error`(`lag_detected` 仍为 `performance`);其余 Web 事件契约与 Electron 基线保持不变。
6
+
5
7
  ## 安装
6
8
 
7
9
  ```bash
@@ -1,5 +1,5 @@
1
1
  import { InterfaceEventEmitter } from './util';
2
- import { InternalConfig, Environment, SendOption, SendSuccess, SendFail, SpeedLog, BridgeLog, SendType, TDEMEvent, ReportFormSubmitResultParams, ReportStruggleParams, TrackOptions, MeasureOptions, CaptureOptions, SetPageOptions, ReportPageViewOptions, InternalSdkOptions, Transport, TransportRequest, TransportResult, TransportCallbacks, RetrySchedule } from './interface';
2
+ import { InternalConfig, Environment, SendOption, SendSuccess, SendFail, SpeedLog, BridgeLog, SendType, TDEMEvent, ReportFormSubmitResultParams, ReportStruggleParams, TrackOptions, TrackStruggleOptions, MeasureOptions, CaptureOptions, SetPageOptions, ReportPageViewOptions, InternalSdkOptions, Transport, TransportRequest, TransportResult, TransportCallbacks, RetrySchedule } from './interface';
3
3
  import Plugin from './plugin';
4
4
  import { Pipe } from './pipes';
5
5
  /**
@@ -74,6 +74,13 @@ export default class Core {
74
74
  sendSDKError(err: Error): void;
75
75
  sendPipeline(pipes: Pipe[], type: SendType): import("./pipes").Pipeline<any, any>;
76
76
  track(name: string, options?: TrackOptions): void;
77
+ /**
78
+ * Tracks a business-defined struggle event.
79
+ *
80
+ * Automatic struggle ownership and rule metadata are SDK implementation
81
+ * details and therefore are not accepted by this public API.
82
+ */
83
+ trackStruggle(name: string, options?: TrackStruggleOptions): void;
77
84
  /**
78
85
  * 上报 TDEM Event 标准事件。
79
86
  *
@@ -90,6 +97,10 @@ export default class Core {
90
97
  clearTags(): void;
91
98
  setUser(userId: string): void;
92
99
  clearUser(): void;
100
+ /**
101
+ * @deprecated External callers should use trackStruggle().
102
+ * @internal Used by automatic struggle detectors.
103
+ */
93
104
  reportStruggle(input: ReportStruggleParams): void;
94
105
  reportFormSubmitResult(input: ReportFormSubmitResultParams): void;
95
106
  reportPageView(pageUrl?: string, options?: ReportPageViewOptions): void;
@@ -103,7 +114,17 @@ export default class Core {
103
114
  private sanitizeStringMap;
104
115
  private sanitizeEventTags;
105
116
  private sanitizeEventProperties;
117
+ private sanitizeStruggleProperties;
106
118
  private sanitizeEventPayload;
119
+ /**
120
+ * 递归清洗单个 payload 值。
121
+ *
122
+ * 之前对纯对象(如 click_position: {x, y})直接 String(value),
123
+ * 会得到字面意义的 "[object Object]" 字符串——因为 typeof {} === 'object'
124
+ * 但 Object.prototype.toString 不做任何有意义的序列化。这里改为递归清洗
125
+ * 保留结构,只在超出嵌套深度时才兜底 JSON.stringify,避免无限递归/巨大对象。
126
+ */
127
+ private sanitizePayloadValue;
107
128
  private getPayloadAllowlist;
108
129
  private normalizeRelatedEventIds;
109
130
  ready(_options: SendOption, _success?: SendSuccess, _fail?: SendFail): void;
@@ -3,7 +3,7 @@ import Core from './core';
3
3
  import Plugin from './plugin';
4
4
  export { Plugin };
5
5
  export default Core;
6
- export { SpeedLog, BridgeLog, StaticAssetsLog, PagePerformanceLog, PagePerformanceLogForHippy3, HippyPagePerformanceLog, Config, InternalConfig, CoreApiConfig, SendOption, SendSuccess, SendFail, SendType, Transport, TransportRequest, TransportResult, TransportCallbacks, TransportMethod, TransportBody, RetryDelayResolver, RetrySchedule, DEFAULT_TRANSPORT_RETRY_SCHEDULE, InternalSdkOptions, PlatTypeNum, NetworkTypeNum, PagePerformanceStruct, EventType, EventCategory, BaseEvent, ExceptionStack, ExceptionFrame, FormSubmitStatus, NavigationType, StruggleStatus, StruggleOwnerType, StruggleEventName, JSErrorEvent, PromiseErrorEvent, ResourceErrorEvent, APIErrorEvent, PageLoadEvent, ResourceLoadEvent, APICallEvent, WebVitalsEvent, EventContextData, BehaviorContextData, FormEventData, ClickEvent, PageViewEvent, FormFocusEvent, FormBlurEvent, FormChangeEvent, FormSubmitEvent, FormSubmitResultEvent, StruggleEvent, CustomEvent, CustomTimeEvent, LogEvent, TDEMEvent, ReportStruggleParams, ReportFormSubmitResultParams, EventOptions, TrackOptions, MeasureOptions, CaptureOptions, SetPageOptions, ReportPageViewOptions, generateEventId, parseErrorStack, } from './interface';
6
+ export { SpeedLog, BridgeLog, StaticAssetsLog, PagePerformanceLog, PagePerformanceLogForHippy3, HippyPagePerformanceLog, Config, InternalConfig, CoreApiConfig, SendOption, SendSuccess, SendFail, SendType, Transport, TransportRequest, TransportResult, TransportCallbacks, TransportMethod, TransportBody, RetryDelayResolver, RetrySchedule, DEFAULT_TRANSPORT_RETRY_SCHEDULE, InternalSdkOptions, PlatTypeNum, NetworkTypeNum, PagePerformanceStruct, EventType, EventCategory, BaseEvent, ExceptionStack, ExceptionFrame, FormSubmitStatus, NavigationType, StruggleStatus, StruggleOwnerType, StruggleEventName, JSErrorEvent, PromiseErrorEvent, ResourceErrorEvent, APIErrorEvent, PageLoadEvent, ResourceLoadEvent, APICallEvent, WebVitalsEvent, LagEventMeasurements, LagEventProperties, LagEventData, LagDetectedEvent, NoResponseEvent, BlankScreenTriggerReason, BlankScreenTriggerType, BlankScreenDetectionMethod, BlankScreenMeasurements, BlankScreenEventProperties, BlankScreenEvent, MemoryEventMeasurements, WebMemoryEventMeasurements, AppMemoryEventMeasurements, WebMemoryEventData, AppMemoryEventData, MemoryEventData, MemoryUsageEvent, FileIoOperation, FileIoEventMeasurements, FileIoEventProperties, FileIoEventData, FileIoEvent, MemoryOOMEvent, EventContextData, BehaviorContextData, FormEventData, ClickEvent, ScrollEvent, LongPressEvent, PageViewEvent, FormFocusEvent, FormBlurEvent, FormChangeEvent, FormSubmitEvent, FormSubmitResultEvent, StruggleEvent, CustomEvent, CustomTimeEvent, LogEvent, TDEMEvent, ReportStruggleParams, StruggleSeverity, EventPropertyValue, EventProperties, ReportFormSubmitResultParams, EventOptions, TrackOptions, TrackStruggleOptions, MeasureOptions, CaptureOptions, SetPageOptions, ReportPageViewOptions, generateEventId, parseErrorStack, } from './interface';
7
7
  export { getDefaultConfig, setConfigUrl, globalAny, REPORT_TIMEOUT, MAX_FROM_LENGTH, ERROR_MSG_IGNORE, URL_SPEED_IGNORE, RESOURCE_TYPE_FETCH, RESOURCE_TYPE_STATIC, UNKNOWN, RESOURCE_TYPE, MAX_PROMISE_ERROR_MSG_LENGTH, } from './constant';
8
8
  export * from './pipes';
9
9
  export * from './util';
@@ -11,11 +11,19 @@ export declare enum EventType {
11
11
  PROMISE_ERROR = "promise_error",
12
12
  RESOURCE_ERROR = "resource_error",
13
13
  API_ERROR = "api_error",
14
+ BLANK_SCREEN = "blank_screen",
14
15
  PAGE_LOAD = "page_load",
15
16
  RESOURCE_LOAD = "resource_load",
16
17
  API_CALL = "api_call",
17
18
  WEB_VITALS = "web_vitals",
19
+ LAG_DETECTED = "lag_detected",
20
+ NO_RESPONSE = "no_response",
21
+ MEMORY_USAGE = "memory_usage",
22
+ MEMORY_OOM = "memory_oom",
23
+ FILE_IO = "file_io",
18
24
  CLICK = "click",
25
+ SCROLL = "scroll",
26
+ LONG_PRESS = "long_press",
19
27
  PAGE_VIEW = "page_view",
20
28
  TAB_HIDDEN = "tab_hidden",
21
29
  TAB_VISIBLE = "tab_visible",
@@ -45,7 +53,10 @@ export declare enum EventCategory {
45
53
  export declare type FormSubmitStatus = 'success' | 'fail';
46
54
  export declare type NavigationType = 'push' | 'replace' | 'back' | 'forward' | 'hashchange' | 'reload';
47
55
  export declare type StruggleStatus = 'detected' | 'confirmed' | 'merged';
48
- export declare type StruggleOwnerType = 'app' | 'session' | 'page' | 'form' | 'element' | 'field' | 'user';
56
+ export declare type StruggleSeverity = 'low' | 'medium' | 'high';
57
+ export declare type EventPropertyValue = string | number | boolean;
58
+ export declare type EventProperties = Record<string, EventPropertyValue>;
59
+ export declare type StruggleOwnerType = 'app' | 'session' | 'page' | 'form' | 'element' | 'field' | 'user' | 'business';
49
60
  export declare type StruggleEventName = 'rage_click' | 'dead_click' | 'error_click' | 'form_validation_error' | 'slow_page' | 'back_forward' | 'long_focus_time' | 'form_zigzag' | 'uncompleted_form' | 'custom_struggle';
50
61
  /**
51
62
  * 基础事件结构(完全对应API协议)
@@ -179,7 +190,14 @@ export interface APIErrorEvent extends BaseEvent {
179
190
  exception_stacks?: ExceptionStack[];
180
191
  replay_id?: string;
181
192
  tags?: Record<string, string>;
182
- event_properties?: Record<string, string>;
193
+ event_properties?: Record<string, string> & {
194
+ http_method?: string;
195
+ http_status?: string;
196
+ /** 失败结局:transport_error | http_error | business_error;不用 event_name 分子类 */
197
+ outcome?: 'transport_error' | 'http_error' | 'business_error';
198
+ /** outcome=business_error 时必填;具体码不可得时为 unknown */
199
+ business_code?: string;
200
+ };
183
201
  };
184
202
  }
185
203
  /**
@@ -250,11 +268,17 @@ export interface APICallEvent extends BaseEvent {
250
268
  request_size?: number;
251
269
  response_size?: number;
252
270
  };
271
+ /** @deprecated 可查询码写在 event_properties.business_code;顶层仅兼容旧包 */
253
272
  business_code?: string;
254
273
  business_message?: string;
255
274
  replay_id?: string;
256
275
  tags?: Record<string, string>;
257
- event_properties?: Record<string, string>;
276
+ event_properties?: Record<string, string> & {
277
+ http_method?: string;
278
+ http_status?: string;
279
+ /** 非空且非 unknown 的业务返回码;成功请求不写 outcome */
280
+ business_code?: string;
281
+ };
258
282
  };
259
283
  }
260
284
  /**
@@ -280,6 +304,127 @@ export interface WebVitalsEvent extends BaseEvent {
280
304
  tags?: Record<string, string>;
281
305
  };
282
306
  }
307
+ export interface LagEventMeasurements {
308
+ duration: number;
309
+ start_time_ms: number;
310
+ lag_threshold_ms: number;
311
+ no_response_threshold_ms: number;
312
+ }
313
+ export interface LagEventProperties {
314
+ entry_type: 'long-animation-frame';
315
+ source_url: string;
316
+ invoker: string;
317
+ }
318
+ export interface LagEventData {
319
+ measurements: LagEventMeasurements;
320
+ event_properties: LagEventProperties;
321
+ replay_id?: string;
322
+ tags?: Record<string, string>;
323
+ }
324
+ export interface LagDetectedEvent extends BaseEvent {
325
+ event_type: EventType.LAG_DETECTED;
326
+ event_category: EventCategory.PERFORMANCE;
327
+ data: LagEventData;
328
+ }
329
+ export interface NoResponseEvent extends BaseEvent {
330
+ event_type: EventType.NO_RESPONSE;
331
+ event_category: EventCategory.ERROR;
332
+ data: LagEventData;
333
+ }
334
+ export declare type BlankScreenTriggerReason = 'white_point' | 'same_element' | 'both' | 'custom';
335
+ export declare type BlankScreenTriggerType = 'initial_load' | 'dom_change' | 'error' | 'page_state';
336
+ export declare type BlankScreenDetectionMethod = 'viewport_sampling' | 'custom_detector';
337
+ export interface BlankScreenMeasurements {
338
+ white_point_count: number;
339
+ same_point_count: number;
340
+ total_sample_points: number;
341
+ white_point_threshold: number;
342
+ same_point_threshold: number;
343
+ white_point_ratio: number;
344
+ same_point_ratio: number;
345
+ viewport_width_px: number;
346
+ viewport_height_px: number;
347
+ }
348
+ export interface BlankScreenEventProperties {
349
+ trigger_reason: BlankScreenTriggerReason;
350
+ trigger_type: BlankScreenTriggerType;
351
+ detection_method: BlankScreenDetectionMethod;
352
+ same_elements_check_enabled: 'true' | 'false';
353
+ }
354
+ export interface BlankScreenEvent extends BaseEvent {
355
+ event_type: EventType.BLANK_SCREEN;
356
+ event_category: EventCategory.ERROR;
357
+ data: {
358
+ measurements: BlankScreenMeasurements;
359
+ event_properties: BlankScreenEventProperties;
360
+ replay_id?: string;
361
+ tags?: Record<string, string>;
362
+ };
363
+ }
364
+ export interface WebMemoryEventMeasurements {
365
+ used_js_heap_size_bytes: number;
366
+ total_js_heap_size_bytes: number;
367
+ js_heap_size_limit_bytes: number;
368
+ usage_ratio: number;
369
+ oom_threshold_mb?: number;
370
+ }
371
+ /** @deprecated Use WebMemoryEventMeasurements or AppMemoryEventMeasurements */
372
+ export declare type MemoryEventMeasurements = WebMemoryEventMeasurements;
373
+ export interface AppMemoryEventMeasurements {
374
+ app_memory: number;
375
+ memory_size: number;
376
+ free_memory: number;
377
+ }
378
+ export interface WebMemoryEventData {
379
+ measurements: WebMemoryEventMeasurements;
380
+ event_properties: {
381
+ detection_source: 'performance_memory';
382
+ };
383
+ replay_id?: string;
384
+ tags?: Record<string, string>;
385
+ }
386
+ export interface AppMemoryEventData {
387
+ measurements: AppMemoryEventMeasurements;
388
+ event_properties: {
389
+ detection_source: 'app_metrics';
390
+ };
391
+ replay_id?: string;
392
+ tags?: Record<string, string>;
393
+ }
394
+ export declare type MemoryEventData = WebMemoryEventData | AppMemoryEventData;
395
+ export interface MemoryUsageEvent extends BaseEvent {
396
+ event_type: EventType.MEMORY_USAGE;
397
+ event_category: EventCategory.PERFORMANCE;
398
+ data: MemoryEventData;
399
+ }
400
+ export declare type FileIoOperation = 'read' | 'write' | 'open';
401
+ export interface FileIoEventMeasurements {
402
+ duration: number;
403
+ size_bytes?: number;
404
+ }
405
+ export interface FileIoEventProperties {
406
+ operation: FileIoOperation;
407
+ success: string;
408
+ process_type: 'main' | 'renderer';
409
+ path?: string;
410
+ path_missing?: string;
411
+ }
412
+ export interface FileIoEventData {
413
+ measurements: FileIoEventMeasurements;
414
+ event_properties: FileIoEventProperties;
415
+ replay_id?: string;
416
+ tags?: Record<string, string>;
417
+ }
418
+ export interface FileIoEvent extends BaseEvent {
419
+ event_type: EventType.FILE_IO;
420
+ event_category: EventCategory.PERFORMANCE;
421
+ data: FileIoEventData;
422
+ }
423
+ export interface MemoryOOMEvent extends BaseEvent {
424
+ event_type: EventType.MEMORY_OOM;
425
+ event_category: EventCategory.PERFORMANCE;
426
+ data: WebMemoryEventData;
427
+ }
283
428
  export interface EventContextData {
284
429
  replay_id?: string;
285
430
  tags?: Record<string, string>;
@@ -316,6 +461,46 @@ export interface ClickEvent extends BaseEvent {
316
461
  };
317
462
  };
318
463
  }
464
+ /**
465
+ * 滑动事件。
466
+ * 与 ClickEvent 复用 click_position 表示手势结束位置;位移和耗时属于可聚合指标。
467
+ */
468
+ export interface ScrollEvent extends BaseEvent {
469
+ event_type: EventType.SCROLL;
470
+ event_category: EventCategory.BEHAVIOR;
471
+ data: BehaviorContextData & {
472
+ target_element: string;
473
+ target_text?: string;
474
+ click_position?: {
475
+ x: number;
476
+ y: number;
477
+ };
478
+ measurements?: {
479
+ duration_ms?: number;
480
+ distance_x_pt?: number;
481
+ distance_y_pt?: number;
482
+ };
483
+ };
484
+ }
485
+ /**
486
+ * 长按事件。
487
+ * 作为共享协议类型供 Web、iOS 等 SDK 使用,具体平台可按能力选择是否自动采集。
488
+ */
489
+ export interface LongPressEvent extends BaseEvent {
490
+ event_type: EventType.LONG_PRESS;
491
+ event_category: EventCategory.BEHAVIOR;
492
+ data: BehaviorContextData & {
493
+ target_element: string;
494
+ target_text?: string;
495
+ click_position?: {
496
+ x: number;
497
+ y: number;
498
+ };
499
+ measurements?: {
500
+ duration_ms?: number;
501
+ };
502
+ };
503
+ }
319
504
  /**
320
505
  * 页面浏览事件
321
506
  * 合并了原 NavigationEvent 的导航字段,每次路由变化只上报此一条事件。
@@ -444,7 +629,8 @@ export interface LogEvent extends BaseEvent {
444
629
  /**
445
630
  * 所有事件的联合类型
446
631
  */
447
- export declare type TDEMEvent = JSErrorEvent | PromiseErrorEvent | ResourceErrorEvent | APIErrorEvent | PageLoadEvent | ResourceLoadEvent | APICallEvent | WebVitalsEvent | ClickEvent | PageViewEvent | LifecycleEvent | FormFocusEvent | FormBlurEvent | FormChangeEvent | FormSubmitEvent | FormSubmitResultEvent | StruggleEvent | CustomEvent | CustomTimeEvent | LogEvent;
632
+ export declare type TDEMEvent = JSErrorEvent | PromiseErrorEvent | ResourceErrorEvent | APIErrorEvent | PageLoadEvent | ResourceLoadEvent | APICallEvent | WebVitalsEvent | LagDetectedEvent | NoResponseEvent | BlankScreenEvent | MemoryUsageEvent | MemoryOOMEvent | FileIoEvent | ClickEvent | ScrollEvent | LongPressEvent | PageViewEvent | LifecycleEvent | FormFocusEvent | FormBlurEvent | FormChangeEvent | FormSubmitEvent | FormSubmitResultEvent | StruggleEvent | CustomEvent | CustomTimeEvent | LogEvent;
633
+ /** @internal Protocol-level input used by automatic struggle detectors. */
448
634
  export interface ReportStruggleParams {
449
635
  type: StruggleEventName;
450
636
  ownerType: StruggleOwnerType;
@@ -463,6 +649,8 @@ export interface ReportStruggleParams {
463
649
  payload?: Record<string, any>;
464
650
  payloadAllowlist?: string[];
465
651
  tags?: Record<string, string>;
652
+ /** Business properties written flat into data.event_properties. */
653
+ properties?: EventProperties;
466
654
  }
467
655
  export interface ReportFormSubmitResultParams {
468
656
  status: FormSubmitStatus;
@@ -485,8 +673,17 @@ export interface EventOptions {
485
673
  pageUrl?: string;
486
674
  replayId?: string;
487
675
  }
488
- export interface TrackOptions extends EventOptions {
489
- payload?: Record<string, any>;
676
+ /** Options for a manually tracked custom event.
677
+ *
678
+ * Page and replay context are captured by the SDK, not supplied per event.
679
+ */
680
+ export interface TrackOptions {
681
+ tags?: Record<string, string>;
682
+ properties?: EventProperties;
683
+ }
684
+ /** Options for a manually tracked custom struggle event. */
685
+ export interface TrackStruggleOptions extends TrackOptions {
686
+ severity?: StruggleSeverity;
490
687
  }
491
688
  export interface MeasureOptions extends EventOptions {
492
689
  payload?: Record<string, any>;
@@ -3,4 +3,4 @@ export { SpeedLog, BridgeLog, StaticAssetsLog, PagePerformanceLog, PagePerforman
3
3
  export { SendOption, SendSuccess, SendFail, SendType, } from './send';
4
4
  export { Transport, TransportRequest, TransportResult, TransportCallbacks, TransportMethod, TransportBody, RetryDelayResolver, RetrySchedule, DEFAULT_TRANSPORT_RETRY_SCHEDULE, InternalSdkOptions, } from './transport';
5
5
  export { Environment, } from './env';
6
- export { EventType, EventCategory, BaseEvent, EventContext, SDKInfo, AppInfo, CollectEventsRequest, ExceptionStack, ExceptionFrame, FormSubmitStatus, NavigationType, StruggleStatus, StruggleOwnerType, StruggleEventName, JSErrorEvent, PromiseErrorEvent, ResourceErrorEvent, APIErrorEvent, PageLoadEvent, ResourceLoadEvent, APICallEvent, WebVitalsEvent, EventContextData, BehaviorContextData, FormEventData, ClickEvent, PageViewEvent, FormFocusEvent, FormBlurEvent, FormChangeEvent, FormSubmitEvent, FormSubmitResultEvent, StruggleEvent, CustomEvent, CustomTimeEvent, LogEvent, TDEMEvent, ReportStruggleParams, ReportFormSubmitResultParams, EventOptions, TrackOptions, MeasureOptions, CaptureOptions, SetPageOptions, ReportPageViewOptions, generateEventId, parseErrorStack, } from './event';
6
+ export { EventType, EventCategory, BaseEvent, EventContext, SDKInfo, AppInfo, CollectEventsRequest, ExceptionStack, ExceptionFrame, FormSubmitStatus, NavigationType, StruggleStatus, StruggleOwnerType, StruggleEventName, JSErrorEvent, PromiseErrorEvent, ResourceErrorEvent, APIErrorEvent, PageLoadEvent, ResourceLoadEvent, APICallEvent, WebVitalsEvent, LagEventMeasurements, LagEventProperties, LagEventData, LagDetectedEvent, NoResponseEvent, BlankScreenTriggerReason, BlankScreenTriggerType, BlankScreenDetectionMethod, BlankScreenMeasurements, BlankScreenEventProperties, BlankScreenEvent, MemoryEventMeasurements, WebMemoryEventMeasurements, AppMemoryEventMeasurements, WebMemoryEventData, AppMemoryEventData, MemoryEventData, MemoryUsageEvent, FileIoOperation, FileIoEventMeasurements, FileIoEventProperties, FileIoEventData, FileIoEvent, MemoryOOMEvent, EventContextData, BehaviorContextData, FormEventData, ClickEvent, ScrollEvent, LongPressEvent, PageViewEvent, FormFocusEvent, FormBlurEvent, FormChangeEvent, FormSubmitEvent, FormSubmitResultEvent, StruggleEvent, CustomEvent, CustomTimeEvent, LogEvent, TDEMEvent, ReportStruggleParams, StruggleSeverity, EventPropertyValue, EventProperties, ReportFormSubmitResultParams, EventOptions, TrackOptions, TrackStruggleOptions, MeasureOptions, CaptureOptions, SetPageOptions, ReportPageViewOptions, generateEventId, parseErrorStack, } from './event';
@@ -0,0 +1,20 @@
1
+ export declare type CgiRequestOutcome = 'transport_error' | 'http_error' | 'business_error';
2
+ export declare type CgiClassifyInput = {
3
+ aborted?: boolean;
4
+ httpStatus: number;
5
+ isTransportFailure?: boolean;
6
+ isBusinessError?: boolean;
7
+ businessCode?: string | number | null;
8
+ };
9
+ export declare type CgiClassifyResult = {
10
+ report: boolean;
11
+ eventType: 'api_error' | 'api_call' | null;
12
+ outcome?: CgiRequestOutcome;
13
+ businessCode?: string;
14
+ };
15
+ export declare function normalizeCgiBusinessCode(code: string | number | null | undefined): string | undefined;
16
+ /**
17
+ * FR-004 一条请求一条事件:传输失败 > HTTP ≥400 > 业务码失败 > 成功。
18
+ * Abort 不上报(FR-014),不记 cancelled。
19
+ */
20
+ export declare function classifyCgiRequest(input: CgiClassifyInput): CgiClassifyResult;
@@ -1,6 +1,8 @@
1
1
  import { SpeedLog, BridgeLog } from '../interface';
2
2
  export { EventEmitter, InterfaceEventEmitter, } from './event-emitter';
3
3
  export { safeGetItem, safeSetItem, safeRemoveItem, safeParseJSON, } from './storage';
4
+ export { classifyCgiRequest, normalizeCgiBusinessCode, } from './cgi-classify';
5
+ export type { CgiClassifyInput, CgiClassifyResult, CgiRequestOutcome, } from './cgi-classify';
4
6
  export declare const buildLogParam: (logs: any | any[]) => string;
5
7
  /**
6
8
  * 将上报数据统一成 json 格式
@@ -1,4 +1,4 @@
1
1
  import './polyfill';
2
2
  import TDEM from './tdem';
3
3
  export default TDEM;
4
- export { WebConfig } from './interface';
4
+ export { WebConfig, LagMonitorConfig, BlankScreenConfig, MemoryMonitorConfig, ElementMatcher, } from './interface';
@@ -43,6 +43,47 @@ export declare type WebSocketMonitorConfig = {
43
43
  export declare type WebVitalsConfig = {
44
44
  manualReport?: boolean;
45
45
  };
46
+ export interface LagMonitorConfig {
47
+ enabled?: boolean;
48
+ threshold?: number;
49
+ noResponseThreshold?: number;
50
+ sampleRate?: number;
51
+ }
52
+ export interface MemoryMonitorConfig {
53
+ enabled?: boolean;
54
+ enableMemoryReport?: boolean;
55
+ enableOOMReport?: boolean;
56
+ oomThreshold?: number;
57
+ memoryReportInterval?: number;
58
+ oomCheckInterval?: number;
59
+ monitorPages?: Array<string | RegExp>;
60
+ sampleRate?: number;
61
+ }
62
+ export interface ElementMatcher {
63
+ tagName?: string[];
64
+ id?: string[];
65
+ className?: string[];
66
+ }
67
+ export interface BlankScreenConfig {
68
+ enabled?: boolean;
69
+ containers?: string[];
70
+ ignoreContainers?: string[];
71
+ containerMatchers?: ElementMatcher;
72
+ ignoreMatchers?: ElementMatcher;
73
+ detectStartPosition?: {
74
+ x: number;
75
+ y: number;
76
+ };
77
+ emptyElementsPercent?: number;
78
+ sameElementsPercent?: number;
79
+ debounceDuration?: number;
80
+ everySideSampleNumber?: number;
81
+ disableSameElementsCheck?: boolean;
82
+ ignoreElesWhenDomChange?: string[];
83
+ reDetectInterval?: number;
84
+ samePointDepth?: number;
85
+ customBlankScreenDector?: (() => boolean) | null;
86
+ }
46
87
  export declare type IgnoreElements = ClickMonitorConfig;
47
88
  /**
48
89
  * TDEM Web SDK 对外公开配置。
@@ -64,6 +105,9 @@ export interface WebConfig extends Config {
64
105
  webVitals?: boolean | WebVitalsConfig;
65
106
  sessionReplay?: boolean | SessionReplayConfig;
66
107
  struggleMonitor?: boolean | StruggleMonitorConfig;
108
+ lagMonitor?: boolean | LagMonitorConfig;
109
+ blankScreen?: boolean | BlankScreenConfig;
110
+ memoryMonitor?: boolean | MemoryMonitorConfig;
67
111
  }
68
112
  /**
69
113
  * Web SDK 内部过渡配置。
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Detection-only adaptation of
3
+ * aegis-sdk/packages/web-sdk/src/plugins/blank-screen/constant.ts at
4
+ * c4660ccac28107ce4623af6d0f2f3644333d1d46.
5
+ * Screenshot types, callbacks, metadata, formats and defaults are excluded.
6
+ */
7
+ import { BlankScreenConfig, ElementMatcher } from '../../interface';
8
+ export { BlankScreenConfig, ElementMatcher };
9
+ export interface SelectorPointerInfo {
10
+ tagName: string;
11
+ id: string;
12
+ className: string;
13
+ selector: string;
14
+ }
15
+ export declare type NormalizedBlankScreenConfig = Required<BlankScreenConfig>;
16
+ export declare const defaultContainerMatchers: Required<ElementMatcher>;
17
+ export declare const defaultIgnoreMatchers: Required<ElementMatcher>;
18
+ export declare const defaultWhiteBlankConfig: NormalizedBlankScreenConfig;
19
+ export declare const ignoreLargeAreaEle: string[];
20
+ export declare enum TRIGGER_TYPE {
21
+ UNKNOWN = 0,
22
+ ERROR = 1,
23
+ DOM_CHANGE = 2
24
+ }
25
+ export declare const MAX_CHECK_BODY_WAIT_TIME = 10000;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Detection-only adaptation of
3
+ * aegis-sdk/packages/web-sdk/src/plugins/blank-screen/index.ts at
4
+ * c4660ccac28107ce4623af6d0f2f3644333d1d46.
5
+ * The viewport sampling and delayed confirmation flow is preserved. Aegis
6
+ * NormalLog and every screenshot path are replaced by TDEM structured events.
7
+ */
8
+ import Core, { Plugin } from "../../../../core/src";
9
+ declare const plugin: Plugin<Core>;
10
+ export default plugin;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Detection-only adaptation of
3
+ * aegis-sdk/packages/web-sdk/src/plugins/blank-screen/utils.ts at
4
+ * c4660ccac28107ce4623af6d0f2f3644333d1d46.
5
+ * Matcher, selector and Shadow DOM sampling behavior is retained; screenshot
6
+ * and diagnostic page-dump helpers are intentionally absent.
7
+ */
8
+ import { BlankScreenConfig, ElementMatcher, NormalizedBlankScreenConfig, SelectorPointerInfo } from './constant';
9
+ export declare type ConfigFallbackWarning = (path: string, reason: string) => void;
10
+ export declare const createConfigFallbackWarner: (tdem: {
11
+ config?: {
12
+ debug?: boolean;
13
+ };
14
+ }) => ConfigFallbackWarning;
15
+ export declare const getSelectorPointerInfo: (element: Element | SVGAElement) => SelectorPointerInfo;
16
+ export declare const getSamePointersMaximum: (pointers: string[][]) => {
17
+ samePointerMap: Record<string, number>;
18
+ maximumSamePointerClass: string;
19
+ maximumSamePointerCounter: number;
20
+ };
21
+ export interface SamplingPoint {
22
+ x: number;
23
+ y: number;
24
+ }
25
+ export declare const getSamplingPoints: (innerWidth: number, innerHeight: number, everySideSampleNumber: number, detectStartPosition: {
26
+ x: number;
27
+ y: number;
28
+ }) => SamplingPoint[];
29
+ export declare const getBlankScreenThresholds: (everySideSampleNumber: number, emptyElementsPercent: number, sameElementsPercent: number) => {
30
+ totalSamplePoints: number;
31
+ whitePointThreshold: number;
32
+ samePointThreshold: number;
33
+ };
34
+ export declare const isLargeAreaElementPath: (selectorPath: string) => boolean;
35
+ export declare const isContainer: (elements: Element[], containers: string[], ignoreContainers: string[], containerMatchers?: ElementMatcher | undefined, ignoreMatchers?: ElementMatcher | undefined) => {
36
+ isWhitePoint: boolean;
37
+ selectorPointers: string[];
38
+ };
39
+ export declare const getBlankScreenConfig: (raw: boolean | BlankScreenConfig | undefined, warn?: ConfigFallbackWarning) => NormalizedBlankScreenConfig;
40
+ export declare const elementsFromPoint: (x: number, y: number) => Element[];
@@ -14,4 +14,7 @@ import onClose from './on-close';
14
14
  import fingerId from './finger';
15
15
  import sessionReplay from './session-replay';
16
16
  import struggleMonitor from './struggle-monitor';
17
- export { aid, fingerId, assetSpeed, cgiSpeed, bridgeSpeed, device, onError, pagePerformance, webVitals, spa, ie, onClose, clickElementLog, consoleLog, sessionReplay, struggleMonitor, };
17
+ import lagMonitor from './lag-monitor';
18
+ import blankScreen from './blank-screen';
19
+ import memoryMonitor from './memory-monitor';
20
+ export { aid, fingerId, assetSpeed, cgiSpeed, bridgeSpeed, device, onError, pagePerformance, webVitals, spa, ie, onClose, clickElementLog, consoleLog, sessionReplay, struggleMonitor, lagMonitor, blankScreen, memoryMonitor, };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Adapted from aegis-sdk/packages/web-sdk/src/plugins/lag-monitor.ts at
3
+ * c4660ccac28107ce4623af6d0f2f3644333d1d46.
4
+ * The LoAF detection body is preserved; output and lifecycle use TDEM contracts.
5
+ */
6
+ import Core, { Plugin } from "../../../core/src";
7
+ import { LagMonitorConfig } from '../interface';
8
+ declare type ConfigFallbackWarning = (path: string, reason: string) => void;
9
+ export interface NormalizedLagMonitorConfig {
10
+ enabled: boolean;
11
+ threshold: number;
12
+ noResponseThreshold: number;
13
+ sampleRate: number;
14
+ }
15
+ export declare const canUseLagMonitor: () => boolean;
16
+ export declare const getLagMonitorConfig: (raw: boolean | LagMonitorConfig | undefined, warn?: ConfigFallbackWarning) => NormalizedLagMonitorConfig;
17
+ declare const plugin: Plugin<Core>;
18
+ export default plugin;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Adapted from aegis-sdk/packages/web-sdk/src/plugins/memory-monitor.ts at
3
+ * c4660ccac28107ce4623af6d0f2f3644333d1d46.
4
+ * Detection, page matching, intervals and cooldown are retained; reporting uses TDEM events.
5
+ */
6
+ import Core, { Plugin } from "../../../core/src";
7
+ import { MemoryMonitorConfig } from '../interface';
8
+ export interface NormalizedMemoryMonitorConfig {
9
+ enabled: boolean;
10
+ enableMemoryReport: boolean;
11
+ enableOOMReport: boolean;
12
+ oomThreshold: number;
13
+ memoryReportInterval: number;
14
+ oomCheckInterval: number;
15
+ monitorPages: Array<string | RegExp>;
16
+ sampleRate: number;
17
+ }
18
+ export declare const canUseMemoryMonitor: () => boolean;
19
+ export declare const getMemoryMonitorConfig: (raw: boolean | MemoryMonitorConfig | undefined, tdem?: Core | undefined) => NormalizedMemoryMonitorConfig;
20
+ declare const plugin: Plugin<Core>;
21
+ export default plugin;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * web-vitals CLS 在 sessionEntries 为空且 sessionValue 仍为真时
3
+ * 会读取 lastSessionEntry.startTime 抛 TypeError。
4
+ * 控制台打开 rrmp 回放时父页面 layout-shift 很密集,容易触发。
5
+ */
6
+ export declare function installStartTimeObserverGuard(globalObj?: {
7
+ PerformanceObserver?: typeof PerformanceObserver;
8
+ }): void;