@cloudcare/browser-rum 3.2.24 → 3.2.26
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/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/domain/contexts/pageStateHistory.js +24 -20
- package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/tracing/zipkinMultiTracer.js +2 -2
- package/cjs/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/contexts/pageStateHistory.js +24 -21
- package/esm/domain/contexts/pageStateHistory.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/tracing/zipkinMultiTracer.js +2 -2
- package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -1
- package/package.json +4 -4
- package/src/domain/contexts/pageStateHistory.js +38 -30
- package/src/domain/tracing/zipkinMultiTracer.js +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zipkinMultiTracer.js","names":["TraceIdentifier","getCrypto","getType","ZipkinMultiTracer","configuration","traceSampled","_traceId","_spanId","_traceSampled","is128Bit","traceId128Bit","generateTraceId","customTraceId","prototype","isTracingSupported","undefined","getSpanId","toPaddedHexadecimalString","getTraceId","makeTracingHeaders"],"sources":["../../../src/domain/tracing/zipkinMultiTracer.js"],"sourcesContent":["import { TraceIdentifier, getCrypto } from './traceIdentifier'\nimport { getType } from '@cloudcare/browser-core'\n/**\n *\n * @param {*} configuration 配置信息\n */\nexport function ZipkinMultiTracer(configuration, traceSampled) {\n this._traceId = new TraceIdentifier()\n this._spanId = new TraceIdentifier()\n this._traceSampled = traceSampled\n this.is128Bit = configuration.traceId128Bit\n if (\n configuration.generateTraceId &&\n getType(configuration.generateTraceId) === 'function'\n ) {\n const customTraceId = configuration.generateTraceId()\n if (getType(customTraceId) === 'string') {\n this.customTraceId = customTraceId\n }\n }\n}\nZipkinMultiTracer.prototype = {\n isTracingSupported: function () {\n return getCrypto() !== undefined\n },\n getSpanId: function () {\n return this._spanId.toPaddedHexadecimalString()\n },\n getTraceId: function () {\n if (this.customTraceId) {\n return this.customTraceId\n }\n return this.is128Bit\n ? '0000000000000000' + this._traceId.toPaddedHexadecimalString()\n : this._traceId.toPaddedHexadecimalString()\n },\n\n makeTracingHeaders: function () {\n return {\n 'X-B3-TraceId': this.
|
|
1
|
+
{"version":3,"file":"zipkinMultiTracer.js","names":["TraceIdentifier","getCrypto","getType","ZipkinMultiTracer","configuration","traceSampled","_traceId","_spanId","_traceSampled","is128Bit","traceId128Bit","generateTraceId","customTraceId","prototype","isTracingSupported","undefined","getSpanId","toPaddedHexadecimalString","getTraceId","makeTracingHeaders"],"sources":["../../../src/domain/tracing/zipkinMultiTracer.js"],"sourcesContent":["import { TraceIdentifier, getCrypto } from './traceIdentifier'\nimport { getType } from '@cloudcare/browser-core'\n/**\n *\n * @param {*} configuration 配置信息\n */\nexport function ZipkinMultiTracer(configuration, traceSampled) {\n this._traceId = new TraceIdentifier()\n this._spanId = new TraceIdentifier()\n this._traceSampled = traceSampled\n this.is128Bit = configuration.traceId128Bit\n if (\n configuration.generateTraceId &&\n getType(configuration.generateTraceId) === 'function'\n ) {\n const customTraceId = configuration.generateTraceId()\n if (getType(customTraceId) === 'string') {\n this.customTraceId = customTraceId\n }\n }\n}\nZipkinMultiTracer.prototype = {\n isTracingSupported: function () {\n return getCrypto() !== undefined\n },\n getSpanId: function () {\n return this._spanId.toPaddedHexadecimalString()\n },\n getTraceId: function () {\n if (this.customTraceId) {\n return this.customTraceId\n }\n return this.is128Bit\n ? '0000000000000000' + this._traceId.toPaddedHexadecimalString()\n : this._traceId.toPaddedHexadecimalString()\n },\n\n makeTracingHeaders: function () {\n return {\n 'X-B3-TraceId': this.getTraceId(),\n 'X-B3-SpanId': this.getSpanId(),\n // 'X-B3-ParentSpanId': '',\n 'X-B3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kBAAkB,EAAE,SAApBA,kBAAkBA,CAAA,EAAc;IAC9B,OAAO;MACL,cAAc,EAAE,IAAI,CAACD,UAAU,CAAC,CAAC;MACjC,aAAa,EAAE,IAAI,CAACF,SAAS,CAAC,CAAC;MAC/B;MACA,cAAc,EAAE,IAAI,CAACR,aAAa,GAAG,GAAG,GAAG;MAC3C;IACF,CAAC;EACH;AACF,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcare/browser-rum",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.26",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@cloudcare/browser-core": "3.2.
|
|
9
|
-
"@cloudcare/browser-worker": "3.2.
|
|
8
|
+
"@cloudcare/browser-core": "3.2.26",
|
|
9
|
+
"@cloudcare/browser-worker": "3.2.26"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
12
|
"dev": "webpack serve --open --mode=development",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"homepage": "https://github.com/CloudCare/dataflux-rum-sdk-javascript/blob/master/packages/rum/README.md",
|
|
35
35
|
"description": "DataFlux RUM Web 端数据指标监控",
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "47b153d6be140f8570f3ec597831f09b1a164dd2"
|
|
37
37
|
}
|
|
@@ -7,7 +7,10 @@ import {
|
|
|
7
7
|
relativeNow,
|
|
8
8
|
DOM_EVENT
|
|
9
9
|
} from '@cloudcare/browser-core'
|
|
10
|
-
|
|
10
|
+
import {
|
|
11
|
+
RumPerformanceEntryType,
|
|
12
|
+
supportPerformanceTimingEvent
|
|
13
|
+
} from '../performanceObservable'
|
|
11
14
|
// Arbitrary value to cap number of element for memory consumption in the browser
|
|
12
15
|
export var MAX_PAGE_STATE_ENTRIES = 4000
|
|
13
16
|
// Arbitrary value to cap number of element for backend & to save bandwidth
|
|
@@ -33,6 +36,17 @@ export function startPageStateHistory(maxPageStateEntriesSelectable) {
|
|
|
33
36
|
})
|
|
34
37
|
|
|
35
38
|
var currentPageState
|
|
39
|
+
if (supportPerformanceTimingEvent(RumPerformanceEntryType.VISIBILITY_STATE)) {
|
|
40
|
+
const visibilityEntries = performance.getEntriesByType(
|
|
41
|
+
RumPerformanceEntryType.VISIBILITY_STATE
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
visibilityEntries.forEach((entry) => {
|
|
45
|
+
const state =
|
|
46
|
+
entry.name === 'hidden' ? PageState.HIDDEN : PageState.ACTIVE
|
|
47
|
+
addPageState(state, entry.startTime)
|
|
48
|
+
})
|
|
49
|
+
}
|
|
36
50
|
addPageState(getPageState(), relativeNow())
|
|
37
51
|
|
|
38
52
|
var _addEventListeners = addEventListeners(
|
|
@@ -71,36 +85,13 @@ export function startPageStateHistory(maxPageStateEntriesSelectable) {
|
|
|
71
85
|
}
|
|
72
86
|
|
|
73
87
|
const pageStateHistory = {
|
|
74
|
-
findAll: function (
|
|
75
|
-
var pageStateEntries = pageStateEntryHistory.findAll(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (pageStateEntries.length === 0) {
|
|
81
|
-
return
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
var pageStateServerEntries = []
|
|
85
|
-
// limit the number of entries to return
|
|
86
|
-
var limit = Math.max(
|
|
87
|
-
0,
|
|
88
|
-
pageStateEntries.length - maxPageStateEntriesSelectable
|
|
88
|
+
findAll: function (startTime, duration) {
|
|
89
|
+
var pageStateEntries = pageStateEntryHistory.findAll(startTime, duration)
|
|
90
|
+
return processPageStates(
|
|
91
|
+
pageStateEntries,
|
|
92
|
+
startTime,
|
|
93
|
+
maxPageStateEntriesSelectable
|
|
89
94
|
)
|
|
90
|
-
|
|
91
|
-
// loop page state entries backward to return the selected ones in desc order
|
|
92
|
-
for (var index = pageStateEntries.length - 1; index >= limit; index--) {
|
|
93
|
-
var pageState = pageStateEntries[index]
|
|
94
|
-
// compute the start time relative to the event start time (ex: to be relative to the view start time)
|
|
95
|
-
var relativeStartTime = elapsed(eventStartTime, pageState.startTime)
|
|
96
|
-
|
|
97
|
-
pageStateServerEntries.push({
|
|
98
|
-
state: pageState.state,
|
|
99
|
-
start: toServerDuration(relativeStartTime)
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return pageStateServerEntries
|
|
104
95
|
},
|
|
105
96
|
|
|
106
97
|
wasInPageStateAt: function (state, startTime) {
|
|
@@ -123,6 +114,23 @@ export function startPageStateHistory(maxPageStateEntriesSelectable) {
|
|
|
123
114
|
}
|
|
124
115
|
return pageStateHistory
|
|
125
116
|
}
|
|
117
|
+
function processPageStates(
|
|
118
|
+
pageStateEntries,
|
|
119
|
+
eventStartTime,
|
|
120
|
+
maxPageStateEntriesSelectable
|
|
121
|
+
) {
|
|
122
|
+
if (pageStateEntries.length === 0) {
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return pageStateEntries
|
|
127
|
+
.slice(-maxPageStateEntriesSelectable)
|
|
128
|
+
.reverse()
|
|
129
|
+
.map(({ state, startTime }) => ({
|
|
130
|
+
state,
|
|
131
|
+
start: toServerDuration(elapsed(eventStartTime, startTime))
|
|
132
|
+
}))
|
|
133
|
+
}
|
|
126
134
|
|
|
127
135
|
function computePageState(event) {
|
|
128
136
|
if (event.type === DOM_EVENT.FREEZE) {
|
|
@@ -37,8 +37,8 @@ ZipkinMultiTracer.prototype = {
|
|
|
37
37
|
|
|
38
38
|
makeTracingHeaders: function () {
|
|
39
39
|
return {
|
|
40
|
-
'X-B3-TraceId': this.
|
|
41
|
-
'X-B3-SpanId': this.
|
|
40
|
+
'X-B3-TraceId': this.getTraceId(),
|
|
41
|
+
'X-B3-SpanId': this.getSpanId(),
|
|
42
42
|
// 'X-B3-ParentSpanId': '',
|
|
43
43
|
'X-B3-Sampled': this._traceSampled ? '1' : '0'
|
|
44
44
|
// 'X-B3-Flags': '0'
|