@cloudcare/browser-rum 3.2.18 → 3.2.22
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 +128 -190
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +2 -3
- package/cjs/boot/buildEnv.js.map +1 -1
- package/cjs/boot/perStartRum.js +9 -2
- package/cjs/boot/perStartRum.js.map +1 -1
- package/cjs/boot/recorderApi.js +1 -1
- package/cjs/boot/recorderApi.js.map +1 -1
- package/cjs/boot/rum.entry.js +1 -2
- package/cjs/boot/rum.entry.js.map +1 -1
- package/cjs/boot/rum.js +1 -1
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/boot/rumPublicApi.js +1 -1
- package/cjs/boot/rumPublicApi.js.map +1 -1
- package/cjs/boot/startRecording.js +57 -8
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/constants.js +13 -26
- package/cjs/constants.js.map +1 -1
- package/cjs/domain/assembly.js +16 -8
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/configuration.js +13 -3
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/contexts/displayContext.js.map +1 -1
- package/cjs/domain/contexts/foregroundContexts.js +2 -4
- package/cjs/domain/contexts/foregroundContexts.js.map +1 -1
- package/cjs/domain/contexts/internalContext.js.map +1 -1
- package/cjs/domain/contexts/pageStateHistory.js +4 -8
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
- package/cjs/domain/contexts/urlContexts.js +1 -2
- package/cjs/domain/contexts/urlContexts.js.map +1 -1
- package/cjs/domain/contexts/viewContexts.js +1 -2
- package/cjs/domain/contexts/viewContexts.js.map +1 -1
- package/cjs/domain/deflate/deflateEncoder.js +1 -2
- package/cjs/domain/deflate/deflateEncoder.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +3 -5
- package/cjs/domain/deflate/deflateWorker.js.map +1 -1
- package/cjs/domain/firstInputPolyfill.js.map +1 -1
- package/cjs/domain/locationChangeObservable.js.map +1 -1
- package/cjs/domain/performanceObservable.js +3 -3
- package/cjs/domain/performanceObservable.js.map +1 -1
- package/cjs/domain/performanceUtils.js.map +1 -1
- package/cjs/domain/replay/record/elementsScrollPositions.js.map +1 -1
- package/cjs/domain/replay/record/mutationBatch.js +1 -2
- package/cjs/domain/replay/record/mutationBatch.js.map +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +2 -2
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
- package/cjs/domain/replay/record/observers.js +31 -32
- package/cjs/domain/replay/record/observers.js.map +1 -1
- package/cjs/domain/replay/record/privacy.js +6 -7
- package/cjs/domain/replay/record/privacy.js.map +1 -1
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/record/serializationUtils.js +5 -8
- package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
- package/cjs/domain/replay/record/serialize.js +8 -10
- package/cjs/domain/replay/record/serialize.js.map +1 -1
- package/cjs/domain/replay/record/shadowRootsController.js +2 -3
- package/cjs/domain/replay/record/shadowRootsController.js.map +1 -1
- package/cjs/domain/replay/record/viewports.js +2 -4
- package/cjs/domain/replay/record/viewports.js.map +1 -1
- package/cjs/domain/replay/replayStats.js +2 -2
- package/cjs/domain/replay/replayStats.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segment.js +3 -3
- package/cjs/domain/replay/segmentCollection/segment.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +42 -17
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/replay/startRecordBridge.js +19 -0
- package/cjs/domain/replay/startRecordBridge.js.map +1 -0
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/clickChain.js +2 -4
- package/cjs/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +1 -2
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +1 -2
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js +2 -4
- package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +2 -2
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/errorCollection.js +12 -1
- package/cjs/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +2 -5
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js +1 -2
- package/cjs/domain/rumEventsCollection/view/interactionCountPolyfill.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackFirstContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js +27 -10
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js +1 -2
- package/cjs/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +18 -12
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumSessionManager.js +92 -32
- package/cjs/domain/rumSessionManager.js.map +1 -1
- package/cjs/domain/tracing/ddtraceTracer.js.map +1 -1
- package/cjs/domain/tracing/getDocumentTraceId.js +1 -2
- package/cjs/domain/tracing/getDocumentTraceId.js.map +1 -1
- package/cjs/domain/tracing/jaegerTracer.js.map +1 -1
- package/cjs/domain/tracing/sampler.js +69 -0
- package/cjs/domain/tracing/sampler.js.map +1 -0
- package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
- package/cjs/domain/tracing/traceIdentifier.js.map +1 -1
- package/cjs/domain/tracing/tracer.js +8 -2
- package/cjs/domain/tracing/tracer.js.map +1 -1
- package/cjs/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/cjs/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/cjs/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/cjs/domain/trackEventCounts.js.map +1 -1
- package/cjs/domain/usr/index.js +3 -6
- package/cjs/domain/usr/index.js.map +1 -1
- package/cjs/domain/waitPageActivityEnd.js +2 -4
- package/cjs/domain/waitPageActivityEnd.js.map +1 -1
- package/cjs/types/sessionReplayConstants.js +5 -10
- package/cjs/types/sessionReplayConstants.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/perStartRum.js +10 -3
- package/esm/boot/perStartRum.js.map +1 -1
- package/esm/boot/recorderApi.js +2 -2
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/rum.js +1 -1
- package/esm/boot/rum.js.map +1 -1
- package/esm/boot/rumPublicApi.js +1 -1
- package/esm/boot/rumPublicApi.js.map +1 -1
- package/esm/boot/startRecording.js +57 -9
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/domain/assembly.js +16 -8
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/configuration.js +13 -3
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/contexts/displayContext.js.map +1 -1
- package/esm/domain/contexts/foregroundContexts.js.map +1 -1
- package/esm/domain/contexts/internalContext.js.map +1 -1
- package/esm/domain/contexts/pageStateHistory.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/deflate/deflateEncoder.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/firstInputPolyfill.js.map +1 -1
- package/esm/domain/locationChangeObservable.js.map +1 -1
- package/esm/domain/performanceObservable.js +2 -1
- package/esm/domain/performanceObservable.js.map +1 -1
- package/esm/domain/performanceUtils.js.map +1 -1
- package/esm/domain/replay/record/elementsScrollPositions.js.map +1 -1
- package/esm/domain/replay/record/mutationBatch.js.map +1 -1
- package/esm/domain/replay/record/mutationObserver.js +2 -2
- package/esm/domain/replay/record/mutationObserver.js.map +1 -1
- package/esm/domain/replay/record/observers.js +31 -32
- package/esm/domain/replay/record/observers.js.map +1 -1
- package/esm/domain/replay/record/privacy.js +4 -3
- package/esm/domain/replay/record/privacy.js.map +1 -1
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serializationUtils.js +2 -2
- package/esm/domain/replay/record/serializationUtils.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +7 -8
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/replay/record/shadowRootsController.js +1 -1
- package/esm/domain/replay/record/shadowRootsController.js.map +1 -1
- package/esm/domain/replay/replayStats.js +1 -1
- package/esm/domain/replay/replayStats.js.map +1 -1
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +39 -13
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/replay/startRecordBridge.js +13 -0
- package/esm/domain/replay/startRecordBridge.js.map +1 -0
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/actionCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js +12 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +0 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js +28 -11
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackFirstInput.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLargestContentfulPaint.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackNavigationTimings.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackScrollMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +15 -6
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumSessionManager.js +89 -26
- package/esm/domain/rumSessionManager.js.map +1 -1
- package/esm/domain/tracing/ddtraceTracer.js.map +1 -1
- package/esm/domain/tracing/jaegerTracer.js.map +1 -1
- package/esm/domain/tracing/sampler.js +61 -0
- package/esm/domain/tracing/sampler.js.map +1 -0
- package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
- package/esm/domain/tracing/traceIdentifier.js.map +1 -1
- package/esm/domain/tracing/tracer.js +8 -2
- package/esm/domain/tracing/tracer.js.map +1 -1
- package/esm/domain/tracing/w3cTraceParentTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -1
- package/esm/domain/trackEventCounts.js.map +1 -1
- package/esm/domain/usr/index.js.map +1 -1
- package/esm/types/sessionReplayConstants.js +0 -1
- package/esm/types/sessionReplayConstants.js.map +1 -1
- package/package.json +35 -35
- package/src/boot/perStartRum.js +13 -4
- package/src/boot/recorderApi.js +6 -2
- package/src/boot/rum.js +1 -0
- package/src/boot/rumPublicApi.js +0 -1
- package/src/boot/startRecording.js +69 -17
- package/src/domain/assembly.js +20 -3
- package/src/domain/configuration.js +36 -3
- package/src/domain/performanceObservable.js +2 -1
- package/src/domain/replay/record/mutationObserver.js +12 -2
- package/src/domain/replay/record/observers.js +43 -28
- package/src/domain/replay/record/privacy.js +8 -2
- package/src/domain/replay/record/serializationUtils.js +2 -2
- package/src/domain/replay/record/serialize.js +9 -2
- package/src/domain/replay/record/shadowRootsController.js +1 -1
- package/src/domain/replay/replayStats.js +1 -1
- package/src/domain/replay/segmentCollection/segmentCollection.js +47 -20
- package/src/domain/replay/startRecordBridge.js +14 -0
- package/src/domain/rumEventsCollection/error/errorCollection.js +12 -0
- package/src/domain/rumEventsCollection/view/trackFirstHidden.js +31 -22
- package/src/domain/rumEventsCollection/view/trackViews.js +18 -9
- package/src/domain/rumSessionManager.js +129 -34
- package/src/domain/tracing/sampler.js +65 -0
- package/src/domain/tracing/tracer.js +11 -5
package/README.md
CHANGED
|
@@ -1,204 +1,142 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
## 简介
|
|
4
|
-
|
|
5
|
-
DataFlux RUM 能够通过收集各个应用的指标数据,以可视化的方式分析各个应用端的性能
|
|
6
|
-
|
|
7
|
-
### 你可以从下面几种方式中选择一种接入到你的 Web 应用中
|
|
8
|
-
|
|
9
|
-
| 接入方式 | 简介 |
|
|
10
|
-
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
11
|
-
| NPM | 通过把 SDK 代码一起打包到你的前端项目中,此方式可以确保对前端页面的性能不会有任何影响,不过可能会错过 SDK 初始化之前的的请求、错误的收集。 |
|
|
12
|
-
| CDN 异步加载 | 通过 CDN 加速缓存,以异步脚本引入的方式,引入 SDK 脚本,此方式可以确保 SDK 脚本的下载不会影响页面的加载性能,不过可能会错过 SDK 初始化之前的的请求、错误的收集。 |
|
|
13
|
-
| CDN 同步加载 | 通过 CDN 加速缓存,以同步脚本引入的方式,引入 SDK 脚本,此方式可以确保能够收集到所有的错误,资源,请求,性能指标。不过可能会影响页面的加载性能。 |
|
|
14
|
-
|
|
15
|
-
### NPM
|
|
16
|
-
|
|
17
|
-
```javascript
|
|
18
|
-
import { datafluxRum } from '@cloudcare/browser-rum'
|
|
19
|
-
|
|
20
|
-
datafluxRum.init({
|
|
21
|
-
applicationId: '<DATAFLUX_APPLICATION_ID>',
|
|
22
|
-
datakitOrigin: '<DATAKIT ORIGIN>'
|
|
23
|
-
// env: 'production',
|
|
24
|
-
// version: '1.0.0',
|
|
25
|
-
})
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### CDN 异步加载
|
|
29
|
-
|
|
30
|
-
```html
|
|
31
|
-
<script>
|
|
32
|
-
;(function (h, o, u, n, d) {
|
|
33
|
-
h = h[d] = h[d] || {
|
|
34
|
-
q: [],
|
|
35
|
-
onReady: function (c) {
|
|
36
|
-
h.q.push(c)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
d = o.createElement(u)
|
|
40
|
-
d.async = 1
|
|
41
|
-
d.src = n
|
|
42
|
-
n = o.getElementsByTagName(u)[0]
|
|
43
|
-
n.parentNode.insertBefore(d, n)
|
|
44
|
-
})(
|
|
45
|
-
window,
|
|
46
|
-
document,
|
|
47
|
-
'script',
|
|
48
|
-
'https://static.dataflux.cn/browser-sdk/v2/dataflux-rum.js',
|
|
49
|
-
'DATAFLUX_RUM'
|
|
50
|
-
)
|
|
51
|
-
DATAFLUX_RUM.onReady(function () {
|
|
52
|
-
DATAFLUX_RUM.init({
|
|
53
|
-
applicationId: '<DATAFLUX_APPLICATION_ID>',
|
|
54
|
-
datakitOrigin: '<DATAKIT ORIGIN>'
|
|
55
|
-
// env: 'production',
|
|
56
|
-
// version: '1.0.0',
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
</script>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### CDN 同步加载
|
|
63
|
-
|
|
64
|
-
```html
|
|
65
|
-
<script
|
|
66
|
-
src="https://static.dataflux.cn/browser-sdk/v2/dataflux-rum.js"
|
|
67
|
-
type="text/javascript"
|
|
68
|
-
></script>
|
|
69
|
-
<script>
|
|
70
|
-
window.DATAFLUX_RUM &&
|
|
71
|
-
window.DATAFLUX_RUM.init({
|
|
72
|
-
applicationId: '<DATAFLUX_APPLICATION_ID>',
|
|
73
|
-
datakitOrigin: '<DATAKIT ORIGIN>'
|
|
74
|
-
// env: 'production',
|
|
75
|
-
// version: '1.0.0',
|
|
76
|
-
})
|
|
77
|
-
</script>
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## 配置
|
|
81
|
-
|
|
82
|
-
### 初始化参数
|
|
83
|
-
|
|
84
|
-
| 参数 | 类型 | 是否必须 | 默认值 | 描述 |
|
|
85
|
-
| ------------------------------------------------- | -------- | -------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
86
|
-
| `applicationId` | String | 是 | | 从 dataflux 创建的应用 ID |
|
|
87
|
-
| `datakitOrigin` | String | 是 | | datakit 数据上报 Origin 注释: `协议(包括://),域名(或IP地址)[和端口号]` 例如:https://www.datakit.com, http://100.20.34.3:8088 |
|
|
88
|
-
| `env` | String | 是 | | web 应用当前环境, 如 prod:线上环境;gray:灰度环境;pre:预发布环境 common:日常环境;local:本地环 |
|
|
89
|
-
| `service` | String | 否 | | web 应用对应的服务名称,可以用于关联 APM 服务相关 tag |
|
|
90
|
-
| `version` | String | 是 | | web 应用的版本号 |
|
|
91
|
-
| `sessionSampleRate` | Number | 否 | `100` | 指标数据收集百分比: `100`表示全收集,`0`表示不收集 |
|
|
92
|
-
| `trackSessionAcrossSubdomains` | Boolean | 否 | `false` | 同一个域名下面的子域名共享缓存 |
|
|
93
|
-
| `traceType` $\color{#FF0000}{新增}$ | Enum | 否 | `ddtrace` | 与 APM 采集工具连接的请求 header 类型,目前兼容的类型包括:`ddtrace`、`zipkin`、`skywalking_v3`、`jaeger`、`zipkin_single_header`、`w3c_traceparent`。_注: opentelemetry 支持 `zipkin_single_header`,`w3c_traceparent`,`zipkin`三种类型_ |
|
|
94
|
-
| `traceId128Bit` $\color{#FF0000}{新增}$ | Boolean | 否 | `false` | 是否以 128 位的方式生成 `traceID`,与`traceType` 对应,目前支持类型 `zipkin`、`jaeger` |
|
|
95
|
-
| `allowedDDTracingOrigins` $\color{#FF0000}{废弃}$ | Array | 否 | `[]` | 允许注入`ddtrace` 采集器所需 header 头部的所有请求列表。可以是请求的 origin,也可以是是正则,origin: `协议(包括://),域名(或IP地址)[和端口号]` 例如:`["https://api.example.com", /https:\/\/.*\.my-api-domain\.com/]` _该参数 旧的配置在新版本中做了兼容, 推荐使用`allowedTracingOrigins`_ |
|
|
96
|
-
| `allowedTracingOrigins` $\color{#FF0000}{新增}$ | Array | 否 | `[]` | 允许注入 `trace` 采集器所需 header 头部的所有请求列表。可以是请求的 origin,也可以是是正则,origin: `协议(包括://),域名(或IP地址)[和端口号]` 例如:`["https://api.example.com", /https:\/\/.*\.my-api-domain\.com/]` |
|
|
97
|
-
| `tracingSampleRate` | Number | 否 | `100` | 链路数据收集百分比: `100`表示全收集,`0`表示不收集 |
|
|
98
|
-
| `trackInteractions` | Boolean | 否 | `false` | 是否开启用户行为采集 |
|
|
99
|
-
| `isServerError` | Function | 否 | `function(request) {return false}` | 默认情况下,请求如果 `status code`>= 500 则定义为错误请求,会相应的采集为 `error` 指标数据。为满足部分场景可能并非是通过 `status code` 来判断业务请求的错误情况,提供可通过用户自定义的方式来判断请求是否为 error 请求,callback 参数为请求对应的相关返回参数: `{ isAborted: false, method:"get",response: "{...}",status: 200,url: "xxxx" }`, 如果方法返回为 true,则该请求相关数据会被采集为 `error` 指标, _该参数 方法返回结果必须为 Boolean 类型, 否则认为是无效参数_ |
|
|
100
|
-
| `isIntakeUrl` | Function | 否 | `function(url) {return false}` | 自定义方法根据请求资源 url 判断是否需要采集对应资源数据,默认都采集。 返回:`false` 表示要采集,`true` 表示不需要采集 _该参数 方法返回结果必须为 Boolean 类型, 否则认为是无效参数_ |
|
|
101
|
-
| `compressIntakeRequests` | Boolean | 否 | | 压缩 RUM 数据请求内容,以减少发送大量数据时的带宽使用量。压缩在 Worker 线程中完成。版本要求`>= 3.2.0` |
|
|
102
|
-
| `workerUrl` | Sring | 否 | | sessionReplay 和 compressIntakeRequests 数据压缩都是在 webwork 线程中完成,所以默认情况下,在开启 csp 安全访问的情况下,需要允许 worker-src blob:; 该配置允许添加自行托管 worker 地址。版本要求`>= 3.2.0` |
|
|
103
|
-
|
|
104
|
-
## 问题
|
|
105
|
-
|
|
106
|
-
### 产生 Script error 消息的原因
|
|
107
|
-
|
|
108
|
-
在使用 DataFlux Web Rum Sdk 进行 Web 端错误收集的时候,经常会在`js_error`中看到 Script error. 这样的错误信息,同时并没有包含任何详细信息。
|
|
109
|
-
|
|
110
|
-
### 可能出现上面问题的原因
|
|
111
|
-
|
|
112
|
-
1. 用户使用的浏览器不支持错误的捕获 (概率极小)。
|
|
113
|
-
2. 出错的脚本文件是跨域加载到页面的。
|
|
114
|
-
对于用户浏览器不支持的情况,这种我们是无法处理的;这里主要解决跨域脚本错误无法收集的原因和解决方案。
|
|
115
|
-
|
|
116
|
-
### 原因
|
|
117
|
-
|
|
118
|
-
一般情况下脚本文件是使用 `<script>` 标签加载,对于同源脚本出错,在使用浏览器的 `GlobalEventHandlers API` 时,收集到的错误信息会包含详细的错误信息;当不同源脚本出错时,收集到的错误信息只有 `Script error.` 文本,这是由浏览器的同源策略控制的,也是正常的情况。对于非同源脚本我们只需要进行非同源资源共享(也称 HTTP 访问控制 / CORS)的操作即可。
|
|
119
|
-
|
|
120
|
-
### 解决方法
|
|
121
|
-
|
|
122
|
-
#### 1.脚本文件直接存放在服务器
|
|
123
|
-
|
|
124
|
-
在服务器上静态文件输出时添加 Header
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
Access-Control-Allow-Origin: *
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
在非同源脚本所在的 Script 标签上添加属 crossorigin="anonymous"
|
|
1
|
+
# Web Application Integration
|
|
131
2
|
|
|
132
|
-
|
|
133
|
-
<script type="text/javascript" src="path/to/your/script.js" crossorigin="anonymous"></script>
|
|
134
|
-
```
|
|
3
|
+
---
|
|
135
4
|
|
|
136
|
-
|
|
5
|
+
Guance application monitoring can collect metrics data from various web applications and analyze the performance of each web application endpoint in a visual manner.
|
|
137
6
|
|
|
138
|
-
|
|
7
|
+
## Prerequisites
|
|
139
8
|
|
|
140
|
-
|
|
141
|
-
Access-Control-Allow-Origin: *
|
|
142
|
-
```
|
|
9
|
+
**Note**: If you have enabled the RUM Headless service, the prerequisites have been automatically configured for you, and you can directly integrate the application.
|
|
143
10
|
|
|
144
|
-
|
|
11
|
+
- Install DataKit
|
|
12
|
+
- Configure the RUM Collector
|
|
13
|
+
- Ensure DataKit is accessible over the public network and has the IP geolocation database installed
|
|
145
14
|
|
|
146
|
-
|
|
147
|
-
<script type="text/javascript" src="path/to/your/script.js" crossorigin="anonymous"></script>
|
|
148
|
-
```
|
|
15
|
+
## Application Integration {#access}
|
|
149
16
|
|
|
150
|
-
|
|
17
|
+
Log in to the Guance console, go to the **Synthetic Tests** page, click on the top-left corner **Create Application** to start creating a new application.
|
|
151
18
|
|
|
152
|
-
|
|
19
|
+
- Guance provides **Public DataWay** to directly receive RUM data without installing the DataKit collector. Configuring `site` and `clientToken` parameters is sufficient. It supports uploading SourceMap directly from the console, allowing multiple files to be uploaded based on different versions and environments.
|
|
153
20
|
|
|
154
|
-
|
|
155
|
-
<script type="text/javascript" src="path/to/your/script.js" crossorigin="anonymous"></script>
|
|
156
|
-
```
|
|
21
|
+
- Guance also supports receiving RUM data via **local environment deployment**, which requires meeting the prerequisites.
|
|
157
22
|
|
|
158
|
-
|
|
23
|
+
Web application integration can be done in three ways: NPM integration, asynchronous loading, and synchronous loading.
|
|
159
24
|
|
|
160
|
-
|
|
25
|
+
| Integration Method | Description |
|
|
26
|
+
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
27
|
+
| NPM | By bundling the SDK code into the frontend project, this method ensures no impact on the frontend page performance but may miss requests and errors before SDK initialization. |
|
|
28
|
+
| CDN Asynchronous | Through CDN caching and asynchronous script introduction, it ensures that the SDK script download does not affect page load performance but may miss requests and errors before SDK initialization. |
|
|
29
|
+
| CDN Synchronous | Through CDN caching and synchronous script introduction, it ensures capturing all errors, resources, requests, and performance metrics. However, it may impact page load performance. |
|
|
161
30
|
|
|
162
|
-
|
|
31
|
+
=== "NPM"
|
|
163
32
|
|
|
164
|
-
|
|
33
|
+
```javascript
|
|
34
|
+
import { datafluxRum } from '@cloudcare/browser-rum'
|
|
165
35
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
36
|
+
datafluxRum.init({
|
|
37
|
+
applicationId: 'guance',
|
|
38
|
+
datakitOrigin: '<DataKit domain or IP>', // Required for DK integration
|
|
39
|
+
clientToken: 'clientToken', // Required for public OpenWay integration
|
|
40
|
+
site: 'public OpenWay address', // Required for public OpenWay integration
|
|
41
|
+
env: 'production',
|
|
42
|
+
version: '1.0.0',
|
|
43
|
+
sessionSampleRate: 100,
|
|
44
|
+
sessionReplaySampleRate: 70,
|
|
45
|
+
trackInteractions: true,
|
|
46
|
+
traceType: 'ddtrace', // Optional, default is ddtrace. Currently supports ddtrace, zipkin, skywalking_v3, jaeger, zipkin_single_header, w3c_traceparent
|
|
47
|
+
allowedTracingOrigins: ['https://api.example.com', /https:\/\/.*\.my-api-domain\.com/], // Optional, list of origins or regex patterns allowed to inject tracing headers
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
=== "CDN Asynchronous Loading"
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
<script>
|
|
55
|
+
(function (h, o, u, n, d) {
|
|
56
|
+
h = h[d] = h[d] || {
|
|
57
|
+
q: [],
|
|
58
|
+
onReady: function (c) {
|
|
59
|
+
h.q.push(c)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
d = o.createElement(u)
|
|
63
|
+
d.async = 1
|
|
64
|
+
d.src = n
|
|
65
|
+
n = o.getElementsByTagName(u)[0]
|
|
66
|
+
n.parentNode.insertBefore(d, n)
|
|
67
|
+
})(
|
|
68
|
+
window,
|
|
69
|
+
document,
|
|
70
|
+
'script',
|
|
71
|
+
'https://static.guance.com/browser-sdk/v3/dataflux-rum.js',
|
|
72
|
+
'DATAFLUX_RUM'
|
|
73
|
+
)
|
|
74
|
+
DATAFLUX_RUM.onReady(function () {
|
|
75
|
+
DATAFLUX_RUM.init({
|
|
76
|
+
applicationId: 'guance',
|
|
77
|
+
datakitOrigin: '<DataKit domain or IP>', // Required for DK integration
|
|
78
|
+
clientToken: 'clientToken', // Required for public OpenWay integration
|
|
79
|
+
site: 'public OpenWay address', // Required for public OpenWay integration
|
|
80
|
+
env: 'production',
|
|
81
|
+
version: '1.0.0',
|
|
82
|
+
sessionSampleRate: 100,
|
|
83
|
+
sessionReplaySampleRate: 70,
|
|
84
|
+
trackInteractions: true,
|
|
85
|
+
traceType: 'ddtrace', // Optional, default is ddtrace. Currently supports ddtrace, zipkin, skywalking_v3, jaeger, zipkin_single_header, w3c_traceparent
|
|
86
|
+
allowedTracingOrigins: ['https://api.example.com', /https:\/\/.*\.my-api-domain\.com/], // Optional, list of origins or regex patterns allowed to inject tracing headers
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
</script>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
=== "CDN Synchronous Loading"
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
<script src="https://static.guance.com/browser-sdk/v3/dataflux-rum.js" type="text/javascript"></script>
|
|
96
|
+
<script>
|
|
97
|
+
window.DATAFLUX_RUM &&
|
|
98
|
+
window.DATAFLUX_RUM.init({
|
|
99
|
+
applicationId: 'guance',
|
|
100
|
+
datakitOrigin: '<DataKit domain or IP>', // Required for DK integration
|
|
101
|
+
clientToken: 'clientToken', // Required for public OpenWay integration
|
|
102
|
+
site: 'public OpenWay address', // Required for public OpenWay integration
|
|
103
|
+
env: 'production',
|
|
104
|
+
version: '1.0.0',
|
|
105
|
+
sessionSampleRate: 100,
|
|
106
|
+
sessionReplaySampleRate: 70,
|
|
107
|
+
trackInteractions: true,
|
|
108
|
+
traceType: 'ddtrace', // Optional, default is ddtrace. Currently supports ddtrace, zipkin, skywalking_v3, jaeger, zipkin_single_header, w3c_traceparent
|
|
109
|
+
allowedTracingOrigins: ['https://api.example.com', /https:\/\/.*\.my-api-domain\.com/], // Optional, list of origins or regex patterns allowed to inject tracing headers
|
|
110
|
+
})
|
|
111
|
+
</script>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Configuration {#config}
|
|
115
|
+
|
|
116
|
+
### Initialization Parameters
|
|
117
|
+
|
|
118
|
+
| Parameter | Type | Required | Default Value | Description |
|
|
119
|
+
| -------------------------------------- | -------------------------------- | -------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
120
|
+
| `applicationId` | String | Yes | | The application ID created in Guance. |
|
|
121
|
+
| `datakitOrigin` | String | Yes | | DataKit data reporting Origin. Format: `protocol (including: //), domain name (or IP address) [and port number]`. Example: [https://www.datakit.com](https://www.datakit.com); [http://100.20.34.3:8088](http://100.20.34.3:8088). |
|
|
122
|
+
| `clientToken` | String | Yes | | The data reporting token for openway access, obtained from the Guance console (required for public openway integration). |
|
|
123
|
+
| `site` | String | Yes | | The data reporting address for public openway access, obtained from the Guance console (required for public openway integration). |
|
|
124
|
+
| `env` | String | No | | The current environment of the web application, such as prod: production; gray: gray release; pre: pre-release; common: daily; local: local. |
|
|
125
|
+
| `version` | String | No | | The version number of the web application. |
|
|
126
|
+
| `service` | String | No | `browser` | The service name of the current application, defaults to `browser`, supports custom configuration. |
|
|
127
|
+
| `sessionSampleRate` | Number | No | `100` | Percentage of metric data collection:<br>`100` means full collection; `0` means no collection. |
|
|
128
|
+
| `sessionReplaySampleRate` | Number | No | `100` | Percentage of [Session Replay](../../docs/replay.md) data collection: <br>`100` means full collection; `0` means no collection. |
|
|
129
|
+
| `trackSessionAcrossSubdomains` | Boolean | No | `false` | Subdomains under the same domain share cache. |
|
|
130
|
+
| `usePartitionedCrossSiteSessionCookie` | Boolean | No | `false` | Whether to enable partitioned secure cross-site session cookie [more details](https://developers.google.com/privacy-sandbox/3pcd/chips?hl=en) |
|
|
131
|
+
| `useSecureSessionCookie` | Boolean | No | `false` | Use secure session cookies. This will disable RUM events sent over insecure (non-HTTPS) connections. |
|
|
132
|
+
| `traceType` | Enum | No | `ddtrace` | Configure the tracing tool type. Defaults to `ddtrace` if not set. Currently supports `ddtrace`, `zipkin`, `skywalking_v3`, `jaeger`, `zipkin_single_header`, `w3c_traceparent`.<br><br>:warning: <br>1. `opentelemetry` supports `zipkin_single_header`, `w3c_traceparent`, `zipkin`, `jaeger`.<br>2. This setting depends on `allowedTracingOrigins`.<br>3. Setting the corresponding `traceType` requires configuring the appropriate `Access-Control-Allow-Headers` for the API services. |
|
|
133
|
+
| `traceId128Bit` | Boolean | No | `false` | Whether to generate `traceID` using 128-bit format, corresponding to `traceType`, currently supports `zipkin`, `jaeger`. |
|
|
134
|
+
| `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
|
+
| `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. |
|
|
136
|
+
| `trackUserInteractions` | Boolean | No | `false` | Whether to enable user interaction tracking. |
|
|
137
|
+
| `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
|
+
| `beforeSend` | Function(event, context):Boolean | No | | Version requirement:`>3.1.2`. Intercept and modify data, refer to [Data Interception](../../docs/rum/before-send.md) |
|
|
139
|
+
| `storeContextsToLocal` | Boolean | No | | Version requirement:`>3.1.2`. Whether to cache custom user data locally in localStorage, e.g., data added via `setUser`, `addGlobalContext` APIs. |
|
|
140
|
+
| `storeContextsKey` | String | No | | Version requirement:`>3.1.18`. Define the key used to store data in localStorage, defaults to auto-generated if not specified. This parameter helps differentiate storage across different subpaths within the same domain. |
|
|
141
|
+
| `compressIntakeRequests` | Boolean | No | | Compress RUM data request content to reduce bandwidth usage when sending large amounts of data, reducing the number of data requests. Compression occurs in the WebWorker thread. For CSP security policy, refer to [CSP Security](../../docs/rum/content-security-policy.md#webwork). SDK version requirement `>= 3.2.0`. DataKit version requirement `>=1.60`. Deployment Plan version requirement `>= 1.96.178`. |
|
|
142
|
+
| `workerUrl` | String | No | | Both sessionReplay and compressIntakeRequests data compression occur in the WebWorker thread, so by default, in CSP secure access scenarios, you need to allow worker-src blob:. This configuration allows adding a self-hosted worker URL. For CSP security policy, refer to [CSP Security](../../docs/rum/content-security-policy.md#webwork). SDK version requirement `>= 3.2.0`. |
|