@cloudcare/browser-rum 3.3.14 → 3.3.16
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 +60 -0
- package/README.zh.md +48 -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 +4 -4
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/constants.js +8 -8
- package/cjs/constants.js.map +1 -1
- package/cjs/domain/assembly.js +14 -1
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/configuration.js +62 -0
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/encoderStreamId.js +2 -1
- package/cjs/domain/encoderStreamId.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/cjs/domain/replay/record/record.js +2 -3
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/record/serializationUtils.js +8 -15
- package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
- package/cjs/domain/replay/record/serialize.js +14 -6
- package/cjs/domain/replay/record/serialize.js.map +1 -1
- package/cjs/domain/requestCollection.js +3 -1
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/errorCollection.js +6 -8
- package/cjs/domain/rumEventsCollection/error/errorCollection.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/rumSessionManager.js +3 -3
- 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 +417 -0
- package/cjs/domain/visitorId/index.js.map +1 -0
- package/cjs/index.js +7 -0
- package/cjs/index.js.map +1 -1
- package/cjs/transport/startRumBatch.js +44 -3
- package/cjs/transport/startRumBatch.js.map +1 -1
- 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 +4 -4
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/constants.js +1 -8
- package/esm/constants.js.map +1 -1
- package/esm/domain/assembly.js +15 -2
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/configuration.js +62 -1
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/encoderStreamId.js +2 -1
- package/esm/domain/encoderStreamId.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/esm/domain/replay/record/record.js +1 -2
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serializationUtils.js +8 -15
- package/esm/domain/replay/record/serializationUtils.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +13 -5
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/requestCollection.js +4 -2
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js +6 -8
- package/esm/domain/rumEventsCollection/error/errorCollection.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/rumSessionManager.js +3 -3
- 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 +406 -0
- package/esm/domain/visitorId/index.js.map +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/transport/startRumBatch.js +45 -4
- package/esm/transport/startRumBatch.js.map +1 -1
- 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 +7 -3
- package/src/constants.js +1 -8
- package/src/domain/assembly.js +28 -2
- package/src/domain/configuration.js +154 -0
- package/src/domain/encoderStreamId.js +2 -2
- package/src/domain/replay/record/record.js +1 -2
- package/src/domain/replay/record/serializationUtils.js +10 -24
- package/src/domain/replay/record/serialize.js +25 -5
- package/src/domain/requestCollection.js +4 -1
- package/src/domain/rumEventsCollection/error/errorCollection.js +10 -8
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +3 -0
- package/src/domain/rumSessionManager.js +8 -7
- package/src/domain/tracing/tracer.js +15 -2
- package/src/domain/visitorId/index.js +571 -0
- package/src/index.js +1 -0
- package/src/transport/startRumBatch.js +61 -3
- package/types/index.d.ts +23 -1
|
@@ -396,7 +396,7 @@ export function switchToAbsoluteUrl(cssText, cssHref) {
|
|
|
396
396
|
}
|
|
397
397
|
)
|
|
398
398
|
}
|
|
399
|
-
export function getCssRulesString(cssStyleSheet) {
|
|
399
|
+
export function getCssRulesString(cssStyleSheet, maxCharacterCount) {
|
|
400
400
|
if (!cssStyleSheet) {
|
|
401
401
|
return null
|
|
402
402
|
}
|
|
@@ -407,13 +407,9 @@ export function getCssRulesString(cssStyleSheet) {
|
|
|
407
407
|
var serializationState = {
|
|
408
408
|
parts: [],
|
|
409
409
|
visitedStyleSheets: new Set(),
|
|
410
|
-
ruleCount: 0,
|
|
411
410
|
characterCount: 0,
|
|
412
411
|
characterLimit:
|
|
413
|
-
|
|
414
|
-
deadline:
|
|
415
|
-
getSerializationTime() + STYLESHEET_SERIALIZATION_MAX_DURATION_MS,
|
|
416
|
-
exceeded: false
|
|
412
|
+
typeof maxCharacterCount === 'number' ? maxCharacterCount : Infinity
|
|
417
413
|
}
|
|
418
414
|
var completed = appendStyleSheetRules(
|
|
419
415
|
cssStyleSheet,
|
|
@@ -421,9 +417,9 @@ export function getCssRulesString(cssStyleSheet) {
|
|
|
421
417
|
cssStyleSheet.href,
|
|
422
418
|
rootRules
|
|
423
419
|
)
|
|
424
|
-
// `_cssText` replaces the stylesheet in the player, so
|
|
425
|
-
//
|
|
426
|
-
//
|
|
420
|
+
// `_cssText` replaces the stylesheet in the player, so never publish a
|
|
421
|
+
// prefix. The caller may bound allocations by the entire snapshot capacity;
|
|
422
|
+
// CSS has no separate rule-count, character-count, or elapsed-time cutoff.
|
|
427
423
|
if (!completed) {
|
|
428
424
|
return null
|
|
429
425
|
}
|
|
@@ -432,7 +428,7 @@ export function getCssRulesString(cssStyleSheet) {
|
|
|
432
428
|
)
|
|
433
429
|
if (
|
|
434
430
|
styleSheetCssText.length >
|
|
435
|
-
|
|
431
|
+
serializationState.characterLimit
|
|
436
432
|
) {
|
|
437
433
|
return null
|
|
438
434
|
}
|
|
@@ -451,9 +447,6 @@ function appendStyleSheetRules(
|
|
|
451
447
|
) {
|
|
452
448
|
return true
|
|
453
449
|
}
|
|
454
|
-
if (!hasStyleSheetSerializationBudget(serializationState)) {
|
|
455
|
-
return false
|
|
456
|
-
}
|
|
457
450
|
serializationState.visitedStyleSheets.add(cssStyleSheet)
|
|
458
451
|
var styleSheetHref = cssStyleSheet.href || inheritedHref
|
|
459
452
|
var rules = knownRules || getReadableStyleSheetRules(cssStyleSheet)
|
|
@@ -530,10 +523,8 @@ function appendStyleSheetRuleText(
|
|
|
530
523
|
return true
|
|
531
524
|
}
|
|
532
525
|
if (
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
rawRuleText.length
|
|
536
|
-
)
|
|
526
|
+
serializationState.characterCount + rawRuleText.length >
|
|
527
|
+
serializationState.characterLimit
|
|
537
528
|
) {
|
|
538
529
|
return false
|
|
539
530
|
}
|
|
@@ -543,16 +534,11 @@ function appendStyleSheetRuleText(
|
|
|
543
534
|
: rawRuleText
|
|
544
535
|
ruleText = switchToAbsoluteUrl(ruleText, styleSheetHref)
|
|
545
536
|
if (
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
serializationState,
|
|
549
|
-
ruleText.length - rawRuleText.length,
|
|
550
|
-
false
|
|
551
|
-
)
|
|
537
|
+
serializationState.characterCount + ruleText.length >
|
|
538
|
+
serializationState.characterLimit
|
|
552
539
|
) {
|
|
553
540
|
return false
|
|
554
541
|
}
|
|
555
|
-
serializationState.ruleCount += 1
|
|
556
542
|
serializationState.characterCount += ruleText.length
|
|
557
543
|
serializationState.parts.push(ruleText)
|
|
558
544
|
return true
|
|
@@ -64,6 +64,9 @@ export var SERIALIZATION_TRUNCATION_MARK = '…'
|
|
|
64
64
|
// enters the asynchronous encoder. Keep that unavoidable main-thread step
|
|
65
65
|
// well below the segment collection's 4 MiB backlog watermark.
|
|
66
66
|
export var SERIALIZATION_MAX_APPROX_BYTES = 1024 * 1024
|
|
67
|
+
// Reserve segment metadata below the existing 4 MiB pending-raw budget.
|
|
68
|
+
export var FULL_SNAPSHOT_SERIALIZATION_MAX_APPROX_BYTES =
|
|
69
|
+
SERIALIZATION_MAX_APPROX_BYTES * 4 - 64 * 1024
|
|
67
70
|
var serializedNodeApproxBytes = new WeakMap()
|
|
68
71
|
|
|
69
72
|
export function serializeDocument(
|
|
@@ -677,7 +680,18 @@ function estimateSerializedNodeShallowBytes(serializedNode) {
|
|
|
677
680
|
return
|
|
678
681
|
}
|
|
679
682
|
approxBytes += estimateJsonStringBytes(key) + 2
|
|
680
|
-
|
|
683
|
+
if (
|
|
684
|
+
value === serializedNode.attributes &&
|
|
685
|
+
(serializedNode.tagName === 'link' || serializedNode.tagName === 'style') &&
|
|
686
|
+
key === '_cssText' &&
|
|
687
|
+
typeof value[key] === 'string'
|
|
688
|
+
) {
|
|
689
|
+
// Inline CSS belongs to the whole snapshot budget, not the
|
|
690
|
+
// ordinary attribute-string limit. Count JSON escapes as usual.
|
|
691
|
+
approxBytes += estimateJsonStringBytes(value[key], true)
|
|
692
|
+
} else {
|
|
693
|
+
pendingValues.push(value[key])
|
|
694
|
+
}
|
|
681
695
|
})
|
|
682
696
|
}
|
|
683
697
|
} else {
|
|
@@ -687,8 +701,8 @@ function estimateSerializedNodeShallowBytes(serializedNode) {
|
|
|
687
701
|
return approxBytes
|
|
688
702
|
}
|
|
689
703
|
|
|
690
|
-
function estimateJsonStringBytes(value) {
|
|
691
|
-
if (value.length > SERIALIZATION_MAX_STRING_LENGTH) {
|
|
704
|
+
function estimateJsonStringBytes(value, isCssText) {
|
|
705
|
+
if (!isCssText && value.length > SERIALIZATION_MAX_STRING_LENGTH) {
|
|
692
706
|
return SERIALIZATION_MAX_APPROX_BYTES + 1
|
|
693
707
|
}
|
|
694
708
|
var bytes = 4
|
|
@@ -941,7 +955,10 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
941
955
|
doc,
|
|
942
956
|
element.href
|
|
943
957
|
)
|
|
944
|
-
var cssText = getCssRulesString(
|
|
958
|
+
var cssText = getCssRulesString(
|
|
959
|
+
stylesheet,
|
|
960
|
+
FULL_SNAPSHOT_SERIALIZATION_MAX_APPROX_BYTES / 2
|
|
961
|
+
)
|
|
945
962
|
if (cssText && stylesheet) {
|
|
946
963
|
safeAttrs._cssText = cssText
|
|
947
964
|
}
|
|
@@ -949,7 +966,10 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
949
966
|
|
|
950
967
|
// dynamic stylesheet
|
|
951
968
|
if (tagName === 'style' && element.sheet) {
|
|
952
|
-
var cssText = getCssRulesString(
|
|
969
|
+
var cssText = getCssRulesString(
|
|
970
|
+
element.sheet,
|
|
971
|
+
FULL_SNAPSHOT_SERIALIZATION_MAX_APPROX_BYTES / 2
|
|
972
|
+
)
|
|
953
973
|
if (cssText) {
|
|
954
974
|
safeAttrs._cssText = cssText
|
|
955
975
|
}
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
RequestType,
|
|
3
3
|
initFetchObservable,
|
|
4
4
|
initXhrObservable,
|
|
5
|
+
isRequest,
|
|
5
6
|
LifeCycleEventType,
|
|
6
7
|
tryToClone,
|
|
7
8
|
readBytesFromStream,
|
|
@@ -51,6 +52,7 @@ export function trackXhr(lifeCycle, configuration, tracer) {
|
|
|
51
52
|
status: context.status,
|
|
52
53
|
traceId: context.traceId,
|
|
53
54
|
traceSampled: context.traceSampled,
|
|
55
|
+
visitorId: context.visitorId,
|
|
54
56
|
type: RequestType.XHR,
|
|
55
57
|
url: context.url,
|
|
56
58
|
xhr: context.xhr,
|
|
@@ -99,9 +101,10 @@ export function trackFetch(lifeCycle, configuration, tracer) {
|
|
|
99
101
|
status: context.status,
|
|
100
102
|
traceId: context.traceId,
|
|
101
103
|
traceSampled: context.traceSampled,
|
|
104
|
+
visitorId: context.visitorId,
|
|
102
105
|
requestHeaderContexts:
|
|
103
106
|
context.init?.headers ||
|
|
104
|
-
(context.input
|
|
107
|
+
(isRequest(context.input)
|
|
105
108
|
? context.input.headers
|
|
106
109
|
: undefined),
|
|
107
110
|
type: RequestType.FETCH,
|
|
@@ -26,15 +26,17 @@ export function startErrorCollection(
|
|
|
26
26
|
trackConsoleError(errorObservable)
|
|
27
27
|
trackRuntimeError(errorObservable)
|
|
28
28
|
trackReportError(configuration, errorObservable)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
hasError = false
|
|
34
|
-
})
|
|
35
|
-
}
|
|
29
|
+
let hasError = false
|
|
30
|
+
lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function () {
|
|
31
|
+
hasError = false
|
|
32
|
+
})
|
|
36
33
|
var markSessionOnError = function () {
|
|
37
|
-
|
|
34
|
+
const session = sessionManager.findTrackedSession()
|
|
35
|
+
if (
|
|
36
|
+
shouldMarkSessionOnError(session) &&
|
|
37
|
+
!hasError &&
|
|
38
|
+
!session.sessionHasError
|
|
39
|
+
) {
|
|
38
40
|
sessionManager.setErrorForSession()
|
|
39
41
|
hasError = true
|
|
40
42
|
}
|
|
@@ -243,6 +243,9 @@ function processRequest(request, pageStateHistory, requestResourceEntryMatcher)
|
|
|
243
243
|
tracingInfo,
|
|
244
244
|
correspondingTimingOverrides
|
|
245
245
|
)
|
|
246
|
+
if (request.visitorId) {
|
|
247
|
+
resourceEvent.context = { visitor_id: request.visitorId }
|
|
248
|
+
}
|
|
246
249
|
return {
|
|
247
250
|
startTime: startClocks.relative,
|
|
248
251
|
rawRumEvent: resourceEvent,
|
|
@@ -78,15 +78,17 @@ export function startRumSessionManager(configuration, lifeCycle) {
|
|
|
78
78
|
return
|
|
79
79
|
}
|
|
80
80
|
const isErrorSession =
|
|
81
|
-
session.
|
|
81
|
+
!session.isSessionForced &&
|
|
82
|
+
(session.trackingType ===
|
|
82
83
|
RumTrackingType.TRACKED_WITH_ERROR_SESSION_AND_WITHOUT_SESSION_REPLAY ||
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
session.trackingType ===
|
|
85
|
+
RumTrackingType.TRACKED_WITH_ERROR_SESSION_AND_WITH_SESSION_REPLAY ||
|
|
86
|
+
session.trackingType ===
|
|
87
|
+
RumTrackingType.TRACKED_WITH_ERROR_SESSION_AND_WITH_ERROR_SESSION_REPLAY)
|
|
87
88
|
|
|
88
89
|
let plan = RumSessionPlan.WITHOUT_SESSION_REPLAY
|
|
89
90
|
if (
|
|
91
|
+
session.isSessionForced ||
|
|
90
92
|
session.trackingType ===
|
|
91
93
|
RumTrackingType.TRACKED_WITH_SESSION_AND_WITH_SESSION_REPLAY ||
|
|
92
94
|
session.trackingType ===
|
|
@@ -113,8 +115,7 @@ export function startRumSessionManager(configuration, lifeCycle) {
|
|
|
113
115
|
isSessionForced: session.isSessionForced,
|
|
114
116
|
sessionReplayAllowed:
|
|
115
117
|
plan === RumSessionPlan.WITH_SESSION_REPLAY ||
|
|
116
|
-
plan === RumSessionPlan.WITH_ERROR_SESSION_REPLAY
|
|
117
|
-
session.isSessionForced
|
|
118
|
+
plan === RumSessionPlan.WITH_ERROR_SESSION_REPLAY
|
|
118
119
|
}
|
|
119
120
|
},
|
|
120
121
|
expire: sessionManager.expire,
|
|
@@ -10,7 +10,9 @@ import {
|
|
|
10
10
|
find,
|
|
11
11
|
isMatchOption,
|
|
12
12
|
matchList,
|
|
13
|
-
isString
|
|
13
|
+
isString,
|
|
14
|
+
isRequest,
|
|
15
|
+
display
|
|
14
16
|
} from '@cloudcare/browser-core'
|
|
15
17
|
import { DDtraceTracer } from './ddtraceTracer'
|
|
16
18
|
import { SkyWalkingTracer } from './skywalkingTracer'
|
|
@@ -45,7 +47,7 @@ export function startTracer(configuration, sessionManager) {
|
|
|
45
47
|
sessionManager,
|
|
46
48
|
function (tracingHeaders) {
|
|
47
49
|
if (
|
|
48
|
-
context.input
|
|
50
|
+
isRequest(context.input) &&
|
|
49
51
|
(!context.init || !context.init.headers)
|
|
50
52
|
) {
|
|
51
53
|
context.input = new Request(context.input)
|
|
@@ -160,6 +162,17 @@ export function injectHeadersIfTracingAllowed(
|
|
|
160
162
|
if (getType(result) === 'object') {
|
|
161
163
|
each(result, function (value, key) {
|
|
162
164
|
if (getType(value) === 'string') {
|
|
165
|
+
if (
|
|
166
|
+
context.visitorId &&
|
|
167
|
+
configuration.visitorId &&
|
|
168
|
+
configuration.visitorId.enabled &&
|
|
169
|
+
key.toLowerCase() === configuration.visitorId.header
|
|
170
|
+
) {
|
|
171
|
+
display.warn(
|
|
172
|
+
'injectTraceHeader cannot overwrite the SDK-managed Visitor ID header.'
|
|
173
|
+
)
|
|
174
|
+
return
|
|
175
|
+
}
|
|
163
176
|
headers[key] = value
|
|
164
177
|
}
|
|
165
178
|
})
|