@blueking/open-telemetry 0.0.5 → 0.0.6

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.
@@ -1,6 +1,19 @@
1
1
  import type { BkOTRumConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
3
  /**
4
- * 监听 CSP 违规事件并以 log 形式上报,便于排查脚本/资源被 CSP 拦截的问题。
4
+ * CSP 违规事件采集插件,通过监听 `securitypolicyviolation` 事件捕获被 CSP 策略拦截的脚本/资源,
5
+ * 以 WARN 级别 log 上报,便于排查 CSP 配置错误或潜在的注入攻击信号。
6
+ *
7
+ * 节流策略:
8
+ * - 同 fingerprint(`violatedDirective + blockedURI + sourceFile + lineNumber`)
9
+ * 在 60s 窗口内最多上报 5 条,避免风暴打爆 collector(如某段被拦截的 inline 脚本被反复渲染)。
10
+ * - 每条 attribute 带 `csp.window_count`,反映当前窗口内同 fingerprint 的总触发次数(含被丢弃的)。
11
+ *
12
+ * 体积优化:
13
+ * - `csp.original_policy`(完整 CSP 策略,可能数 KB)仅在窗口首条上报,后续同 fingerprint 不再重复携带。
14
+ *
15
+ * URL 处理:
16
+ * - `blockedURI` / `sourceFile` 中的 URL 类值会经 `redactUrl` 脱敏。
17
+ * - `blockedURI` 是 'inline' / 'eval' 等 CSP 关键字时直接保留,不调用 redactUrl。
5
18
  */
6
- export declare const createCspViolationPlugin: (enabled: BkOTRumConfig["cspViolation"]) => BkOTPlugin;
19
+ export declare const createCspViolationPlugin: (option: BkOTRumConfig["cspViolation"]) => BkOTPlugin;
@@ -1,7 +1,23 @@
1
1
  import type { BkOTRumConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
3
  /**
4
- * 设备级永久标识 + 视口 / 网络元数据。
5
- * session 插件区分:device 跨会话持久,session 有过期与续期。
4
+ * 设备元数据采集插件,把"设备级"信息写入 SDK runtimeAttributes,
5
+ * 让所有 log/span 都自动带上这些维度。
6
+ *
7
+ * 上报字段:
8
+ * - `device.id`:设备级永久标识,存于 localStorage(默认 key 复用旧 session 插件以保留现网用户)。
9
+ * - `device.memory` / `device.cpu_cores` / `device.platform` / `device.mobile`:硬件能力快照(运行期不变)。
10
+ * - `browser.viewport.*` / `browser.screen.*`:视口与屏幕尺寸。
11
+ * - `network.effective_type` / `network.connection_type` / `network.downlink` / `network.rtt` / `network.save_data`:
12
+ * 网络信息。
13
+ *
14
+ * 实时更新:
15
+ * - viewport 监听 `resize` / `orientationchange`,并经 250ms debounce 合并,避免拖窗口时高频触发;
16
+ * 静默期结束后用最终值刷新 runtimeAttributes。
17
+ * - network 监听 `connection.change`(本身低频,不需要 throttle)。
18
+ * - 二者只更新 in-memory 的 runtimeAttributes,不会主动产生新的 span/log,cardinality 安全;
19
+ * 但更新后续生成的 log/span 会带最新值。
20
+ *
21
+ * 与 session 插件的关系:device 跨会话持久(终身),session 有过期与续期(连续访问语义)。
6
22
  */
7
23
  export declare const createDevicePlugin: (option: BkOTRumConfig["device"]) => BkOTPlugin;
@@ -1,20 +1,3 @@
1
1
  import type { BkOTHttpBodyConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- interface BodySnapshot {
4
- body: string;
5
- contentType?: string;
6
- truncated: boolean;
7
- }
8
3
  export declare const createHttpBodyPlugin: (option: false | Required<BkOTHttpBodyConfig>) => BkOTPlugin;
9
- declare global {
10
- interface XMLHttpRequest {
11
- __bkOtHttpBodyRequest__?: BodySnapshot;
12
- __bkOtHttpBodyRequestHeaders__?: Record<string, string>;
13
- __bkOtHttpBodyMeta__?: {
14
- method: string;
15
- startTime: number;
16
- url: string;
17
- };
18
- }
19
- }
20
- export {};
@@ -1,7 +1,15 @@
1
1
  import type { BkOTRumConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
3
  /**
4
- * Long Task 监控:通过 PerformanceObserver type=longtask 捕获 >= threshold 的主线程长任务。
5
- * 默认关闭,建议在性能敏感模块按需开启。
4
+ * Long Task 监控插件,通过 PerformanceObserver 捕获主线程上 >= threshold(默认 50ms)的长任务,
5
+ * 上报为 metric(counter + duration histogram),用于评估页面卡顿趋势。
6
+ *
7
+ * 使用建议:
8
+ * - 默认关闭,建议在性能敏感模块按需开启。
9
+ * - PerformanceObserver 使用 `buffered: true`,能拿到 observer 创建之前已发生的 longtask,避免漏掉早期阶段。
10
+ *
11
+ * 兼容性:
12
+ * - 仅在 PerformanceObserver 与 `supportedEntryTypes` 包含 `longtask` 的浏览器上启用,否则 init 直接 return;
13
+ * Firefox 当前不支持 longtask,会自动跳过。
6
14
  */
7
15
  export declare const createLongTaskPlugin: (option: BkOTRumConfig["longTask"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
1
  import type { BkOTRumConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createPageViewPlugin: (enabled: BkOTRumConfig["pageView"]) => BkOTPlugin;
3
+ export declare const createPageViewPlugin: (option: BkOTRumConfig["pageView"]) => BkOTPlugin;
@@ -1,7 +1,3 @@
1
1
  import type { BkOTRumConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- /**
4
- * 估算 SPA 路由切换耗时:路由变更 → 双 raf + 一个宏任务后视为"渲染完成"。
5
- * 不依赖具体框架,但仅是粗粒度估算;如需精确,业务可走自定义 plugin 在框架钩子内 startSpan/end。
6
- */
7
- export declare const createRouteTimingPlugin: (enabled: BkOTRumConfig["routeTiming"]) => BkOTPlugin;
3
+ export declare const createRouteTimingPlugin: (option: BkOTRumConfig["routeTiming"]) => BkOTPlugin;
@@ -1,7 +1,3 @@
1
1
  import type { BkOTRumConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- /**
4
- * 会话级标识:带不活跃过期时间,超过 inactivityMs 视为新会话。
5
- * 与 device 插件互补:device 是设备终身标识,session 反映"用户连续访问"语义。
6
- */
7
3
  export declare const createSessionPlugin: (option: BkOTRumConfig["session"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
1
  import type { BkOTRumConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createWebVitalsPlugin: (enabled: BkOTRumConfig["webVitals"]) => BkOTPlugin;
3
+ export declare const createWebVitalsPlugin: (option: BkOTRumConfig["webVitals"]) => BkOTPlugin;
@@ -1,3 +1,3 @@
1
1
  import type { BkOTRumConfig } from '../core/config';
2
2
  import type { BkOTPlugin } from '../core/plugin';
3
- export declare const createWebSocketPlugin: (enabled: BkOTRumConfig["websocket"]) => BkOTPlugin;
3
+ export declare const createWebSocketPlugin: (option: BkOTRumConfig["websocket"]) => BkOTPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/open-telemetry",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "OpenTelemetry browser SDK for BK RUM",
5
5
  "author": "TencentCloud Real User Monitoring",
6
6
  "main": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  "vite": "^8.0.2",
48
48
  "vite-bundle-analyzer": "^1.3.2",
49
49
  "vue": "^3.5.34",
50
- "vue-router": "^4.5.0",
50
+ "vue-router": "^5.0.6",
51
51
  "vue-tsc": "^3.1.4"
52
52
  }
53
53
  }