@blueking/open-telemetry 0.0.4 → 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.
@@ -0,0 +1,3 @@
1
+ import type { BkOTRumConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ export declare const createBlankScreenPlugin: (option: BkOTRumConfig["blankScreen"]) => BkOTPlugin;
@@ -0,0 +1,3 @@
1
+ import type { BkOTInstrumentationsConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ export declare const createCommonInstrumentationsPlugin: (option: BkOTInstrumentationsConfig) => BkOTPlugin;
@@ -0,0 +1,19 @@
1
+ import type { BkOTRumConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ /**
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。
18
+ */
19
+ export declare const createCspViolationPlugin: (option: BkOTRumConfig["cspViolation"]) => BkOTPlugin;
@@ -0,0 +1,23 @@
1
+ import type { BkOTRumConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ /**
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 有过期与续期(连续访问语义)。
22
+ */
23
+ export declare const createDevicePlugin: (option: BkOTRumConfig["device"]) => BkOTPlugin;
@@ -0,0 +1,3 @@
1
+ import type { BkOTRumConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ export declare const createErrorPlugin: (option: BkOTRumConfig["error"]) => BkOTPlugin;
@@ -0,0 +1,3 @@
1
+ import type { BkOTHttpBodyConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ export declare const createHttpBodyPlugin: (option: false | Required<BkOTHttpBodyConfig>) => BkOTPlugin;
@@ -0,0 +1,15 @@
1
+ import type { BkOTRumConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ /**
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,会自动跳过。
14
+ */
15
+ export declare const createLongTaskPlugin: (option: BkOTRumConfig["longTask"]) => BkOTPlugin;
@@ -0,0 +1,3 @@
1
+ import type { BkOTRumConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ export declare const createPageViewPlugin: (option: BkOTRumConfig["pageView"]) => BkOTPlugin;
@@ -0,0 +1,3 @@
1
+ import type { BkOTRumConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ export declare const createRouteTimingPlugin: (option: BkOTRumConfig["routeTiming"]) => BkOTPlugin;
@@ -0,0 +1,3 @@
1
+ import type { BkOTRumConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ export declare const createSessionPlugin: (option: BkOTRumConfig["session"]) => BkOTPlugin;
@@ -0,0 +1,3 @@
1
+ import type { BkOTRumConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
3
+ export declare const createWebVitalsPlugin: (option: BkOTRumConfig["webVitals"]) => BkOTPlugin;
@@ -0,0 +1,3 @@
1
+ import type { BkOTRumConfig } from '../core/config';
2
+ import type { BkOTPlugin } from '../core/plugin';
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.4",
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",
@@ -11,10 +11,12 @@
11
11
  "dist"
12
12
  ],
13
13
  "scripts": {
14
+ "prepublishOnly": "pnpm build && pnpm dts",
14
15
  "build": "vite build && vite build --mode cdn",
15
16
  "build:cdn": "vite build --mode cdn",
16
17
  "build:esm": "vite build",
17
- "dev": "vite dev"
18
+ "dev": "vite dev",
19
+ "dts": "vue-tsc --project tsconfig.dts.json"
18
20
  },
19
21
  "dependencies": {
20
22
  "@opentelemetry/api": "^1.9.1",
@@ -45,7 +47,7 @@
45
47
  "vite": "^8.0.2",
46
48
  "vite-bundle-analyzer": "^1.3.2",
47
49
  "vue": "^3.5.34",
48
- "vue-router": "^4.5.0",
50
+ "vue-router": "^5.0.6",
49
51
  "vue-tsc": "^3.1.4"
50
52
  }
51
53
  }