@cloudcare/browser-rum 3.3.13 → 3.3.15
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 +48 -0
- package/README.zh.md +35 -0
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/perStartRum.js +3 -0
- package/cjs/boot/perStartRum.js.map +1 -1
- package/cjs/boot/recorderApi.js +72 -56
- package/cjs/boot/recorderApi.js.map +1 -1
- package/cjs/boot/rumPublicApi.js +35 -3
- package/cjs/boot/rumPublicApi.js.map +1 -1
- package/cjs/boot/startRecording.js +5 -2
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/domain/assembly.js +7 -1
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/configuration.js +63 -0
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/privacy.js +278 -0
- package/cjs/domain/privacy.js.map +1 -0
- package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/cjs/domain/replay/record/privacy.js +11 -272
- package/cjs/domain/replay/record/privacy.js.map +1 -1
- package/cjs/domain/replay/record/record.js +10 -1
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/requestCollection.js +3 -1
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +81 -19
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +11 -4
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +5 -0
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +16 -5
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumSessionManager.js +2 -2
- package/cjs/domain/rumSessionManager.js.map +1 -1
- package/cjs/domain/tracing/tracer.js +5 -1
- package/cjs/domain/tracing/tracer.js.map +1 -1
- package/cjs/domain/visitorId/index.js +379 -0
- package/cjs/domain/visitorId/index.js.map +1 -0
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/perStartRum.js +3 -0
- package/esm/boot/perStartRum.js.map +1 -1
- package/esm/boot/recorderApi.js +72 -56
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/rumPublicApi.js +36 -4
- package/esm/boot/rumPublicApi.js.map +1 -1
- package/esm/boot/startRecording.js +5 -2
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/domain/assembly.js +7 -1
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/configuration.js +63 -1
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/privacy.js +266 -0
- package/esm/domain/privacy.js.map +1 -0
- package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/esm/domain/replay/record/privacy.js +1 -266
- package/esm/domain/replay/record/privacy.js.map +1 -1
- package/esm/domain/replay/record/record.js +10 -1
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/requestCollection.js +4 -2
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +80 -18
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +11 -4
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +5 -0
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +17 -6
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumSessionManager.js +2 -2
- package/esm/domain/rumSessionManager.js.map +1 -1
- package/esm/domain/tracing/tracer.js +6 -2
- package/esm/domain/tracing/tracer.js.map +1 -1
- package/esm/domain/visitorId/index.js +368 -0
- package/esm/domain/visitorId/index.js.map +1 -0
- package/package.json +4 -4
- package/src/boot/perStartRum.js +4 -0
- package/src/boot/recorderApi.js +73 -59
- package/src/boot/rumPublicApi.js +38 -4
- package/src/boot/startRecording.js +11 -2
- package/src/domain/assembly.js +13 -1
- package/src/domain/configuration.js +158 -0
- package/src/domain/privacy.js +356 -0
- package/src/domain/replay/record/privacy.js +1 -356
- package/src/domain/replay/record/record.js +10 -1
- package/src/domain/requestCollection.js +4 -1
- package/src/domain/rumEventsCollection/actions/getActionNameFromElement.js +148 -21
- package/src/domain/rumEventsCollection/actions/trackClickActions.js +19 -5
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +3 -0
- package/src/domain/rumEventsCollection/view/trackViews.js +33 -6
- package/src/domain/rumSessionManager.js +2 -2
- package/src/domain/tracing/tracer.js +15 -2
- package/src/domain/visitorId/index.js +522 -0
- package/types/index.d.ts +2 -0
package/README.md
CHANGED
|
@@ -111,6 +111,53 @@ Web application integration can be done in three ways: NPM integration, asynchro
|
|
|
111
111
|
</script>
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
+
## Visitor ID request header
|
|
115
|
+
|
|
116
|
+
The SDK can inject a stable anonymous Visitor ID into matching XHR and Fetch
|
|
117
|
+
requests and expose the same value as RUM `context.visitor_id`:
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
datafluxRum.init({
|
|
121
|
+
// ...
|
|
122
|
+
visitorId: {
|
|
123
|
+
enabled: true,
|
|
124
|
+
header: 'x-rum-visitor-id',
|
|
125
|
+
match: [
|
|
126
|
+
'https://api.example.com/',
|
|
127
|
+
/^https:\/\/gateway\.example\.com\//,
|
|
128
|
+
function (url) {
|
|
129
|
+
return url.indexOf('/security/') !== -1
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
ttlHours: 24
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`header` must be a lowercase writable request header and cannot overlap an
|
|
138
|
+
authentication, CSRF, signature, tracing header, or the SDK resource correlation
|
|
139
|
+
header `x-rum-resource-id`. `match` supports URL-prefix
|
|
140
|
+
strings, `RegExp`, and `(url) => boolean` functions. String prefixes only match
|
|
141
|
+
within their declared origin, so similarly prefixed hostnames are not matched.
|
|
142
|
+
Requests outside `match` retain their existing headers, including headers supplied
|
|
143
|
+
by `injectTraceHeader`. The SDK reserves `context.visitor_id` across global, view,
|
|
144
|
+
and event contexts; a matching Resource event keeps the ID sent with its request,
|
|
145
|
+
even if the ID is reset while the request is in flight. `beforeSend` can still
|
|
146
|
+
modify or remove context fields.
|
|
147
|
+
The default TTL is 24 hours. When local storage is unavailable, the SDK falls
|
|
148
|
+
back to session storage and then current-page memory without generating a new
|
|
149
|
+
value for every request. When multiple valid storage records exist, the newest
|
|
150
|
+
record is used so a refresh cannot restore the value from before a rotation. Call
|
|
151
|
+
`datafluxRum.resetVisitorId()` only after a confirmed logout or account switch.
|
|
152
|
+
Do not call it from repeatable 401 or unauthenticated-request branches, which
|
|
153
|
+
would continually rotate the bucket and bypass the limit.
|
|
154
|
+
|
|
155
|
+
Cross-origin requests require the configured header in the API's CORS policy.
|
|
156
|
+
The ID is only a rate-limit bucket and observability correlation key, not an
|
|
157
|
+
authentication credential, tenant identity, or audit identity. Because clients
|
|
158
|
+
can forge the ID, keep any rate-limit mitigation period short to limit the
|
|
159
|
+
impact of one visitor reusing another visitor's ID.
|
|
160
|
+
|
|
114
161
|
## Configuration {#config}
|
|
115
162
|
|
|
116
163
|
### Initialization Parameters
|
|
@@ -133,6 +180,7 @@ Web application integration can be done in three ways: NPM integration, asynchro
|
|
|
133
180
|
| `traceId128Bit` | Boolean | No | `false` | Whether to generate `traceID` using 128-bit format, corresponding to `traceType`, currently supports `zipkin`, `jaeger`. |
|
|
134
181
|
| `allowedTracingOrigins` | Array | No | `[]` | List of origins or regex patterns allowed to inject tracing headers. Can be request origin or regex, origin format: `protocol (including: //), domain name (or IP address) [and port number]`. Example: <br>`["https://api.example.com", /https:\\/\\/._\\.my-api-domain\\.com/]`. |
|
|
135
182
|
| `allowedTracingUrls` | Array | No | `[]` | URL matching list for requests associated with APM. Can be request URLs, regex, or match function, example: `["https://api.example.com/xxx", /https:\/\/.*\.my-api-domain\.com\/xxx/, function(url) {if (url === 'xxx') { return false} else { return true }}]`. This parameter extends `allowedTracingOrigins`, configuring either one is sufficient. |
|
|
183
|
+
| `visitorId` | Object | No | `{ enabled: false }` | Inject a stable anonymous Visitor ID into matching XHR and Fetch requests and expose the same value as RUM `context.visitor_id`. When enabled, `header` and a non-empty String/RegExp/Function `match` list are required; `ttlHours` defaults to 24. |
|
|
136
184
|
| `trackUserInteractions` | Boolean | No | `false` | Whether to enable user interaction tracking. |
|
|
137
185
|
| `actionNameAttribute` | String | No | | Version requirement:`>3.1.2`. Add custom attributes to elements to specify action names. For more details, refer to [Tracking User Actions](../../docs/rum/tracking-user-actions.md) |
|
|
138
186
|
| `beforeSend` | Function(event, context):Boolean | No | | Version requirement:`>3.1.2`. Intercept and modify data, refer to [Data Interception](../../docs/rum/before-send.md) |
|
package/README.zh.md
CHANGED
|
@@ -20,6 +20,41 @@ datafluxRum.init({
|
|
|
20
20
|
datafluxRum.startSessionReplayRecording()
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
## 访客标识请求头
|
|
24
|
+
|
|
25
|
+
可以为命中的 XHR 和 Fetch 请求注入稳定、匿名且独立于链路追踪的访客标识,
|
|
26
|
+
同时将相同值写入 RUM 事件的 `context.visitor_id`:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
datafluxRum.init({
|
|
30
|
+
// ...
|
|
31
|
+
visitorId: {
|
|
32
|
+
enabled: true,
|
|
33
|
+
header: 'x-rum-visitor-id',
|
|
34
|
+
match: [
|
|
35
|
+
'https://api.example.com/',
|
|
36
|
+
/^https:\/\/gateway\.example\.com\//,
|
|
37
|
+
function (url) {
|
|
38
|
+
return url.indexOf('/security/') !== -1
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
ttlHours: 24
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- `header` 必须为合法的小写可写请求头,不能使用鉴权、CSRF、签名、链路追踪请求头或 SDK 资源关联头 `x-rum-resource-id`。
|
|
47
|
+
- `match` 支持 URL 前缀字符串、`RegExp` 和 `(url) => boolean` 函数;字符串只会在其声明的同一 Origin 内命中,不会匹配名称前缀相同的其他域名。
|
|
48
|
+
- 未命中 `match` 的请求保留原有请求头,包括 `injectTraceHeader` 提供的头。
|
|
49
|
+
- `context.visitor_id` 由 SDK 管理,全局、View 和事件自定义上下文中的同名字段不会覆盖它;匹配的 Resource 事件保留请求发起时的 ID。`beforeSend` 仍可修改或删除上下文字段。
|
|
50
|
+
- 默认有效期为 24 小时;优先持久化到 `localStorage`,不可用时依次降级到
|
|
51
|
+
`sessionStorage` 和当前页面内存,降级后也不会按请求重新生成;存在多级有效记录时使用最新记录,避免刷新后恢复轮转前的旧值。
|
|
52
|
+
- 用户成功退出登录或切换账户后调用 `datafluxRum.resetVisitorId()`;不要在 401、未认证请求等可能重复触发的失败分支调用,否则会持续换桶并绕过限流。
|
|
53
|
+
- 跨域请求会触发 CORS 预检,服务端必须允许该自定义请求头。
|
|
54
|
+
- 访客标识只能用于限流分桶和可观测性关联,不能用于鉴权、租户隔离或审计。
|
|
55
|
+
- 访客标识可被客户端伪造,限流处罚时间应保持较短,避免攻击者冒用其他访客 ID
|
|
56
|
+
造成长时间误封。
|
|
57
|
+
|
|
23
58
|
## Session Replay
|
|
24
59
|
|
|
25
60
|
启用 Session Replay 至少需要:
|