@cloudcare/browser-rum 3.3.24 → 3.3.25
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 +33 -0
- package/README.zh.md +30 -0
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/disabledRumPublicApi.js +5 -0
- package/cjs/boot/disabledRumPublicApi.js.map +1 -1
- package/cjs/boot/initCallbacks.js +25 -0
- package/cjs/boot/initCallbacks.js.map +1 -0
- package/cjs/boot/perStartRum.js +99 -50
- package/cjs/boot/perStartRum.js.map +1 -1
- package/cjs/boot/rum.js +7 -4
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/boot/rumPublicApi.js +6 -7
- package/cjs/boot/rumPublicApi.js.map +1 -1
- package/cjs/boot/startRecording.js +2 -0
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/domain/configuration.js +15 -2
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/contexts/urlContexts.js +32 -21
- package/cjs/domain/contexts/urlContexts.js.map +1 -1
- package/cjs/domain/contexts/viewContexts.js +1 -1
- package/cjs/domain/contexts/viewContexts.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +39 -27
- package/cjs/domain/deflate/deflateWorker.js.map +1 -1
- package/cjs/domain/privacy.js +9 -6
- package/cjs/domain/privacy.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandCapture.js +91 -179
- package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandObserverStub.js +24 -0
- package/cjs/domain/replay/record/canvasCommandObserverStub.js.map +1 -0
- package/cjs/domain/replay/record/canvasCommandSerializeArgs.js +3 -2
- package/cjs/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
- package/cjs/domain/replay/record/canvasContext.js +25 -0
- package/cjs/domain/replay/record/canvasContext.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/cjs/domain/replay/record/canvasObserver.js +3 -0
- package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +3 -12
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
- package/cjs/domain/replay/record/record.js +1 -1
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/record/serialize.js +15 -13
- package/cjs/domain/replay/record/serialize.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +21 -6
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +91 -143
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/replayCanvasSupported.js +8 -0
- package/cjs/domain/replayCanvasSupported.js.map +1 -0
- package/cjs/domain/requestCollection.js +38 -39
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js +1 -1
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/fetchTimingRegistry.js +143 -0
- package/cjs/domain/rumEventsCollection/resource/fetchTimingRegistry.js.map +1 -0
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -2
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +77 -45
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js +11 -9
- package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +30 -40
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +7 -1
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +3 -0
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/tracing/skywalkingTracer.js +4 -50
- package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
- package/cjs/domain/tracing/tracer.js +26 -3
- package/cjs/domain/tracing/tracer.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/disabledRumPublicApi.js +1 -1
- package/esm/boot/disabledRumPublicApi.js.map +1 -1
- package/esm/boot/initCallbacks.js +2 -0
- package/esm/boot/initCallbacks.js.map +1 -0
- package/esm/boot/perStartRum.js +1 -1
- package/esm/boot/perStartRum.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 +1 -1
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/domain/configuration.js +1 -1
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js +1 -1
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/contexts/viewContexts.js +1 -1
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/deflate/deflateWorker.js.map +1 -1
- package/esm/domain/privacy.js +1 -1
- package/esm/domain/privacy.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandCapture.js +1 -1
- package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandObserverStub.js +2 -0
- package/esm/domain/replay/record/canvasCommandObserverStub.js.map +1 -0
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js +1 -1
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
- package/esm/domain/replay/record/canvasContext.js +1 -1
- package/esm/domain/replay/record/canvasContext.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/esm/domain/replay/record/canvasObserver.js +1 -1
- package/esm/domain/replay/record/canvasObserver.js.map +1 -1
- package/esm/domain/replay/record/mutationObserver.js +1 -1
- package/esm/domain/replay/record/mutationObserver.js.map +1 -1
- package/esm/domain/replay/record/record.js +1 -1
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +1 -1
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/replayCanvasSupported.js +2 -0
- package/esm/domain/replayCanvasSupported.js.map +1 -0
- package/esm/domain/requestCollection.js +1 -1
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +1 -1
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/fetchTimingRegistry.js +2 -0
- package/esm/domain/rumEventsCollection/resource/fetchTimingRegistry.js.map +1 -0
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +1 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/tracing/skywalkingTracer.js +1 -1
- package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
- package/esm/domain/tracing/tracer.js +1 -1
- package/esm/domain/tracing/tracer.js.map +1 -1
- package/package.json +7 -7
- package/src/boot/disabledRumPublicApi.js +5 -0
- package/src/boot/initCallbacks.js +16 -0
- package/src/boot/perStartRum.js +102 -59
- package/src/boot/rum.js +7 -4
- package/src/boot/rumPublicApi.js +6 -8
- package/src/boot/startRecording.js +2 -0
- package/src/domain/configuration.js +13 -2
- package/src/domain/contexts/urlContexts.js +34 -27
- package/src/domain/contexts/viewContexts.js +2 -2
- package/src/domain/deflate/deflateWorker.js +35 -21
- package/src/domain/privacy.js +13 -13
- package/src/domain/replay/record/canvasCommandCapture.js +105 -239
- package/src/domain/replay/record/canvasCommandObserverStub.js +11 -0
- package/src/domain/replay/record/canvasCommandSerializeArgs.js +2 -2
- package/src/domain/replay/record/canvasContext.js +32 -0
- package/src/domain/replay/record/canvasObserver.js +5 -1
- package/src/domain/replay/record/mutationObserver.js +6 -22
- package/src/domain/replay/record/record.js +1 -1
- package/src/domain/replay/record/serialize.js +24 -11
- package/src/domain/replay/segmentCollection/buildReplayPayload.js +24 -14
- package/src/domain/replay/segmentCollection/segmentCollection.js +97 -227
- package/src/domain/replayCanvasSupported.js +1 -0
- package/src/domain/requestCollection.js +39 -51
- package/src/domain/rumEventsCollection/actions/listenActionEvents.js +8 -2
- package/src/domain/rumEventsCollection/resource/fetchTimingRegistry.js +138 -0
- package/src/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -2
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +87 -64
- package/src/domain/rumEventsCollection/resource/resourceTrackerManager.js +10 -10
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +36 -59
- package/src/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +8 -2
- package/src/domain/rumEventsCollection/view/trackViews.js +3 -0
- package/src/domain/tracing/skywalkingTracer.js +14 -91
- package/src/domain/tracing/tracer.js +28 -4
- package/types/index.d.ts +9 -0
package/src/boot/perStartRum.js
CHANGED
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
createBoundedBuffer,
|
|
3
3
|
display,
|
|
4
4
|
canUseEventBridge,
|
|
5
|
-
|
|
5
|
+
catchUserErrors,
|
|
6
|
+
monitorError,
|
|
6
7
|
willSyntheticsInjectRum,
|
|
7
8
|
noop,
|
|
8
9
|
timeStampNow,
|
|
@@ -15,8 +16,9 @@ import {
|
|
|
15
16
|
getEventBridge,
|
|
16
17
|
getType
|
|
17
18
|
} from '@cloudcare/browser-core'
|
|
18
|
-
import { validateAndBuildRumConfiguration } from '../domain/configuration'
|
|
19
|
+
import { prepareReplayCanvasConfiguration, validateAndBuildRumConfiguration } from '../domain/configuration'
|
|
19
20
|
import { getPluginsTelemetry, validatePlugins } from '../domain/plugins'
|
|
21
|
+
import { callInitCallback, reportInitError, reportAlreadyInitialized } from './initCallbacks'
|
|
20
22
|
|
|
21
23
|
export function createPreStartStrategy(
|
|
22
24
|
rumPublicApiOptions,
|
|
@@ -28,7 +30,7 @@ export function createPreStartStrategy(
|
|
|
28
30
|
var startCompressionWorker = rumPublicApiOptions.startCompressionWorker
|
|
29
31
|
var overrideInitConfiguration = rumPublicApiOptions.overrideInitConfiguration
|
|
30
32
|
var bufferApiCalls = createBoundedBuffer()
|
|
31
|
-
var
|
|
33
|
+
var remoteConfigurationCallbacks = createBoundedBuffer()
|
|
32
34
|
var firstStartViewCall
|
|
33
35
|
|
|
34
36
|
var compressionWorker
|
|
@@ -37,11 +39,11 @@ export function createPreStartStrategy(
|
|
|
37
39
|
var cachedConfiguration
|
|
38
40
|
var cachedRemoteConfiguration
|
|
39
41
|
var hasStarted
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
+
var pendingAttempt
|
|
43
|
+
var workerFailed = false
|
|
42
44
|
var resourceTrackerManager = rumPublicApiOptions.resourceTrackerManager
|
|
43
45
|
function tryStartRum() {
|
|
44
|
-
if (hasStarted || !cachedInitConfiguration || !cachedConfiguration) {
|
|
46
|
+
if (hasStarted || workerFailed || !cachedInitConfiguration || !cachedConfiguration) {
|
|
45
47
|
return
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -61,17 +63,35 @@ export function createPreStartStrategy(
|
|
|
61
63
|
initialViewOptions = firstStartViewCall.options
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
hasStarted = true
|
|
64
67
|
var startRumResult = doStartRum(
|
|
65
68
|
cachedConfiguration,
|
|
66
69
|
compressionWorker,
|
|
67
70
|
initialViewOptions
|
|
68
71
|
)
|
|
69
|
-
hasStarted = true
|
|
70
72
|
|
|
71
73
|
bufferApiCalls.drain(startRumResult)
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
function
|
|
76
|
+
function fail(attempt, code, message) {
|
|
77
|
+
if (pendingAttempt !== attempt) return
|
|
78
|
+
attempt.$rConfigurationReadyCallbacks = undefined
|
|
79
|
+
pendingAttempt = undefined
|
|
80
|
+
if (code === 'worker_initialization_failed') workerFailed = true
|
|
81
|
+
reportInitError(attempt, code, message)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function run(attempt, callback) {
|
|
85
|
+
if (pendingAttempt !== attempt) return
|
|
86
|
+
try {
|
|
87
|
+
callback()
|
|
88
|
+
} catch (error) {
|
|
89
|
+
fail(attempt, 'initialization_failed', 'An error occurred while initializing RUM.')
|
|
90
|
+
monitorError(error)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function doInit(attempt, initConfiguration, remoteConfiguration, remoteError) {
|
|
75
95
|
var eventBridgeAvailable = canUseEventBridge()
|
|
76
96
|
if (eventBridgeAvailable) {
|
|
77
97
|
initConfiguration = overrideInitConfigurationForBridge(initConfiguration)
|
|
@@ -83,11 +103,7 @@ export function createPreStartStrategy(
|
|
|
83
103
|
// Update the exposed initConfiguration to reflect the bridge and remote configuration overrides
|
|
84
104
|
cachedInitConfiguration = initConfiguration
|
|
85
105
|
cachedRemoteConfiguration = remoteConfiguration
|
|
86
|
-
|
|
87
|
-
if (cachedConfiguration) {
|
|
88
|
-
displayAlreadyInitializedError('DATAFLUX_RUM', initConfiguration)
|
|
89
|
-
return
|
|
90
|
-
}
|
|
106
|
+
remoteConfigurationCallbacks.drain(cachedRemoteConfiguration)
|
|
91
107
|
var telemetryConfiguration = deepClone(initConfiguration)
|
|
92
108
|
if (initConfiguration.plugins) {
|
|
93
109
|
telemetryConfiguration.plugins = getPluginsTelemetry(
|
|
@@ -97,7 +113,7 @@ export function createPreStartStrategy(
|
|
|
97
113
|
addTelemetryConfiguration(telemetryConfiguration)
|
|
98
114
|
var configuration = validateAndBuildRumConfiguration(initConfiguration)
|
|
99
115
|
if (!configuration) {
|
|
100
|
-
|
|
116
|
+
fail(attempt, 'invalid_configuration', 'Invalid RUM configuration.')
|
|
101
117
|
return
|
|
102
118
|
}
|
|
103
119
|
|
|
@@ -109,48 +125,71 @@ export function createPreStartStrategy(
|
|
|
109
125
|
display.warn(
|
|
110
126
|
'No storage available for session. We will not send any data.'
|
|
111
127
|
)
|
|
112
|
-
|
|
128
|
+
fail(attempt, 'storage_unavailable', 'No storage available for the RUM session.')
|
|
113
129
|
return
|
|
114
130
|
}
|
|
115
131
|
|
|
132
|
+
var prepared = false
|
|
133
|
+
var workerReady = true
|
|
134
|
+
function notifyIfReady() {
|
|
135
|
+
if (!prepared || !workerReady || pendingAttempt !== attempt) return
|
|
136
|
+
pendingAttempt = undefined
|
|
137
|
+
const result = { remoteConfiguration: 'disabled' }
|
|
138
|
+
if (remoteError) {
|
|
139
|
+
result.remoteConfiguration = 'fallback'
|
|
140
|
+
result.remoteConfigurationError = remoteError
|
|
141
|
+
} else if (remoteConfiguration !== undefined) {
|
|
142
|
+
result.remoteConfiguration = 'applied'
|
|
143
|
+
}
|
|
144
|
+
callInitCallback(attempt, 'onInitSuccess', result)
|
|
145
|
+
}
|
|
146
|
+
|
|
116
147
|
if (
|
|
117
148
|
configuration.compressIntakeRequests &&
|
|
118
149
|
!configuration.sendContentTypeByJson &&
|
|
119
150
|
!eventBridgeAvailable &&
|
|
120
151
|
startCompressionWorker
|
|
121
152
|
) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
'RUM'
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
)
|
|
130
|
-
if (!compressionWorker) {
|
|
131
|
-
|
|
132
|
-
initializationPending = false
|
|
153
|
+
workerReady = false
|
|
154
|
+
function onWorkerError(reason) {
|
|
155
|
+
fail(attempt, 'worker_initialization_failed', reason || 'Unable to create the RUM compression Worker.')
|
|
156
|
+
}
|
|
157
|
+
compressionWorker = startCompressionWorker(configuration, 'RUM', onWorkerError, undefined, function () {
|
|
158
|
+
workerReady = true
|
|
159
|
+
notifyIfReady()
|
|
160
|
+
})
|
|
161
|
+
if (!compressionWorker || workerFailed) {
|
|
162
|
+
onWorkerError()
|
|
133
163
|
return
|
|
134
164
|
}
|
|
135
165
|
}
|
|
136
166
|
|
|
167
|
+
// Let plugins queue the initial manual View before collection starts.
|
|
168
|
+
const callbacks = attempt.$rConfigurationReadyCallbacks
|
|
169
|
+
attempt.$rConfigurationReadyCallbacks = undefined
|
|
170
|
+
callbacks.forEach(function (callback) {
|
|
171
|
+
catchUserErrors(callback, 'Plugin configuration callback threw an error:')()
|
|
172
|
+
})
|
|
137
173
|
cachedConfiguration = configuration
|
|
138
|
-
|
|
139
|
-
// Instrumuent fetch to track network requests
|
|
140
|
-
// This is needed in case the consent is not granted and some cutsomer
|
|
141
|
-
// library (Apollo Client) is storing uninstrumented fetch to be used later
|
|
142
|
-
// The subscrption is needed so that the instrumentation process is completed
|
|
174
|
+
// Instrument fetch before returning so libraries can cache the wrapped function.
|
|
143
175
|
initFetchObservable().subscribe(noop)
|
|
144
176
|
tryStartRum()
|
|
177
|
+
// The handshake gates the notification. Collection starts as soon as the Worker exists.
|
|
178
|
+
prepared = true
|
|
179
|
+
notifyIfReady()
|
|
145
180
|
}
|
|
146
181
|
|
|
147
182
|
return {
|
|
148
183
|
init: function (initConfiguration, publicApi) {
|
|
184
|
+
if (workerFailed) return
|
|
149
185
|
if (!initConfiguration) {
|
|
150
186
|
display.error('Missing configuration')
|
|
151
187
|
return
|
|
152
188
|
}
|
|
153
|
-
|
|
189
|
+
if (pendingAttempt || cachedConfiguration) {
|
|
190
|
+
reportAlreadyInitialized(initConfiguration)
|
|
191
|
+
return
|
|
192
|
+
}
|
|
154
193
|
|
|
155
194
|
// If we are in a Synthetics test configured to automatically inject a RUM instance, we want
|
|
156
195
|
// to completely discard the customer application RUM instance by ignoring their init() call.
|
|
@@ -158,37 +197,40 @@ export function createPreStartStrategy(
|
|
|
158
197
|
// internal `ignoreInitIfSyntheticsWillInjectRum` option is here to bypass this condition.
|
|
159
198
|
if (ignoreInitIfSyntheticsWillInjectRum && willSyntheticsInjectRum()) {
|
|
160
199
|
cachedInitConfiguration = initConfiguration
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
if (initializationPending || cachedConfiguration) {
|
|
164
|
-
displayAlreadyInitializedError('DATAFLUX_RUM', initConfiguration)
|
|
200
|
+
reportInitError(initConfiguration, 'initialization_ignored', 'RUM initialization was delegated to Synthetics.')
|
|
165
201
|
return
|
|
166
202
|
}
|
|
167
203
|
// Expose the accepted configuration regardless of initialization success.
|
|
204
|
+
initConfiguration = prepareReplayCanvasConfiguration(initConfiguration)
|
|
168
205
|
cachedInitConfiguration = initConfiguration
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (rumPublicApiOptions.onInit) {
|
|
174
|
-
rumPublicApiOptions.onInit(initConfiguration, publicApi)
|
|
175
|
-
}
|
|
176
|
-
pluginsRequireManualViewTracking =
|
|
177
|
-
!!initConfiguration.plugins &&
|
|
178
|
-
initConfiguration.trackViewsManually === true
|
|
179
|
-
if (initConfiguration.remoteConfiguration) {
|
|
180
|
-
fetchAndApplyRemoteConfiguration(
|
|
181
|
-
initConfiguration,
|
|
182
|
-
function (remoteInitConfiguration, remoteConfiguration) {
|
|
183
|
-
if (pluginsRequireManualViewTracking) {
|
|
184
|
-
remoteInitConfiguration.trackViewsManually = true
|
|
185
|
-
}
|
|
186
|
-
doInit(remoteInitConfiguration, remoteConfiguration)
|
|
187
|
-
}
|
|
188
|
-
)
|
|
189
|
-
} else {
|
|
190
|
-
doInit(initConfiguration)
|
|
206
|
+
const attempt = pendingAttempt = {
|
|
207
|
+
onInitSuccess: initConfiguration.onInitSuccess,
|
|
208
|
+
onInitError: initConfiguration.onInitError,
|
|
209
|
+
$rConfigurationReadyCallbacks: []
|
|
191
210
|
}
|
|
211
|
+
run(attempt, function () {
|
|
212
|
+
if (!validatePlugins(initConfiguration.plugins)) {
|
|
213
|
+
fail(attempt, 'invalid_plugins', 'Invalid RUM plugins configuration.')
|
|
214
|
+
return
|
|
215
|
+
}
|
|
216
|
+
if (rumPublicApiOptions.onInit) {
|
|
217
|
+
rumPublicApiOptions.onInit(initConfiguration, publicApi, function (callback) {
|
|
218
|
+
if (attempt.$rConfigurationReadyCallbacks) attempt.$rConfigurationReadyCallbacks.push(callback)
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
const pluginsRequireManualViewTracking =
|
|
222
|
+
!!initConfiguration.plugins && initConfiguration.trackViewsManually === true
|
|
223
|
+
if (initConfiguration.remoteConfiguration) {
|
|
224
|
+
fetchAndApplyRemoteConfiguration(initConfiguration, function (resolved, remote, error) {
|
|
225
|
+
run(attempt, function () {
|
|
226
|
+
if (pluginsRequireManualViewTracking) resolved.trackViewsManually = true
|
|
227
|
+
doInit(attempt, resolved, remote, error)
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
} else {
|
|
231
|
+
doInit(attempt, initConfiguration)
|
|
232
|
+
}
|
|
233
|
+
})
|
|
192
234
|
},
|
|
193
235
|
|
|
194
236
|
getInitConfiguration: function () {
|
|
@@ -196,10 +238,11 @@ export function createPreStartStrategy(
|
|
|
196
238
|
},
|
|
197
239
|
getRemoteConfiguration: function (callback) {
|
|
198
240
|
if (getType(callback) === 'function') {
|
|
241
|
+
callback = catchUserErrors(callback, 'getRemoteConfiguration callback threw an error:')
|
|
199
242
|
if (cachedRemoteConfiguration) {
|
|
200
243
|
callback(cachedRemoteConfiguration)
|
|
201
244
|
} else {
|
|
202
|
-
|
|
245
|
+
remoteConfigurationCallbacks.add(callback)
|
|
203
246
|
}
|
|
204
247
|
}
|
|
205
248
|
},
|
package/src/boot/rum.js
CHANGED
|
@@ -6,6 +6,7 @@ import { startCacheUsrCache } from '../domain/usr'
|
|
|
6
6
|
import {
|
|
7
7
|
LifeCycle,
|
|
8
8
|
LifeCycleEventType,
|
|
9
|
+
assign,
|
|
9
10
|
createPageExitObservable,
|
|
10
11
|
canUseEventBridge,
|
|
11
12
|
startTelemetry,
|
|
@@ -41,6 +42,7 @@ export function startRum(
|
|
|
41
42
|
createEncoder,
|
|
42
43
|
resourceTrackerManager
|
|
43
44
|
) {
|
|
45
|
+
var excludeDocumentQuery = initialViewOptions?.excludeHashRouteOuterQuery && location.hash.indexOf('#/') === 0
|
|
44
46
|
var cleanupTasks = []
|
|
45
47
|
var lifeCycle = new LifeCycle()
|
|
46
48
|
var telemetry = startRumTelemetry(configuration)
|
|
@@ -143,7 +145,8 @@ export function startRum(
|
|
|
143
145
|
pageStateHistory,
|
|
144
146
|
undefined,
|
|
145
147
|
undefined,
|
|
146
|
-
resourceTrackerManager
|
|
148
|
+
resourceTrackerManager,
|
|
149
|
+
excludeDocumentQuery
|
|
147
150
|
)
|
|
148
151
|
var addResource = _startResourceCollection.addResource
|
|
149
152
|
cleanupTasks.push(_startResourceCollection.stop)
|
|
@@ -155,7 +158,7 @@ export function startRum(
|
|
|
155
158
|
cleanupTasks.unshift(webSocketCollection.stop)
|
|
156
159
|
}
|
|
157
160
|
if (
|
|
158
|
-
PerformanceObserver.supportedEntryTypes &&
|
|
161
|
+
window.PerformanceObserver && PerformanceObserver.supportedEntryTypes &&
|
|
159
162
|
PerformanceObserver.supportedEntryTypes.includes(
|
|
160
163
|
RumPerformanceEntryType.LONG_ANIMATION_FRAME
|
|
161
164
|
)
|
|
@@ -176,7 +179,7 @@ export function startRum(
|
|
|
176
179
|
pageStateHistory
|
|
177
180
|
)
|
|
178
181
|
var addError = _startErrorCollection.addError
|
|
179
|
-
startRequestCollection(lifeCycle, configuration, session)
|
|
182
|
+
cleanupTasks.push(startRequestCollection(lifeCycle, configuration, session).stop)
|
|
180
183
|
|
|
181
184
|
var internalContext = startInternalContext(
|
|
182
185
|
configuration.applicationId,
|
|
@@ -197,7 +200,7 @@ export function startRum(
|
|
|
197
200
|
getViewContext,
|
|
198
201
|
setViewName,
|
|
199
202
|
lifeCycle: lifeCycle,
|
|
200
|
-
viewContexts: viewContexts,
|
|
203
|
+
viewContexts: assign({}, viewContexts, { $rGetDocumentUrl: urlContexts.$rGetDocumentUrl }),
|
|
201
204
|
session: session,
|
|
202
205
|
setForcedSession: function () {
|
|
203
206
|
session.setForcedSession({ refreshView: true })
|
package/src/boot/rumPublicApi.js
CHANGED
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
sanitize,
|
|
19
19
|
createCustomerDataTrackerManager,
|
|
20
20
|
CustomerDataCompressionStatus,
|
|
21
|
-
displayAlreadyInitializedError,
|
|
22
21
|
getType,
|
|
23
22
|
noop
|
|
24
23
|
} from '@cloudcare/browser-core'
|
|
@@ -98,12 +97,13 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
|
|
|
98
97
|
strategy = createPreStartStrategy(
|
|
99
98
|
assign({}, options, {
|
|
100
99
|
resourceTrackerManager: resourceTrackerManager,
|
|
101
|
-
onInit: function (initConfiguration, publicApi) {
|
|
100
|
+
onInit: function (initConfiguration, publicApi, onConfigurationReady) {
|
|
102
101
|
callPluginsMethod(initConfiguration.plugins, 'onInit', {
|
|
103
102
|
addError: addPluginError,
|
|
104
103
|
publicApi: publicApi,
|
|
105
104
|
rum: publicApi,
|
|
106
|
-
initConfiguration: initConfiguration
|
|
105
|
+
initConfiguration: initConfiguration,
|
|
106
|
+
onConfigurationReady: onConfigurationReady
|
|
107
107
|
})
|
|
108
108
|
},
|
|
109
109
|
onConfigurationReady: function (configuration) {
|
|
@@ -252,7 +252,7 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
|
|
|
252
252
|
}),
|
|
253
253
|
|
|
254
254
|
getInitConfiguration: monitor(function () {
|
|
255
|
-
return deepClone(strategy.
|
|
255
|
+
return deepClone(strategy.getInitConfiguration())
|
|
256
256
|
}),
|
|
257
257
|
getRemoteConfiguration: monitor(function (callback) {
|
|
258
258
|
return strategy.getRemoteConfiguration(callback)
|
|
@@ -389,10 +389,8 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
|
|
|
389
389
|
function createPostStartStrategy(preStartStrategy, startRumResult) {
|
|
390
390
|
return assign(
|
|
391
391
|
{
|
|
392
|
-
init:
|
|
393
|
-
|
|
394
|
-
},
|
|
395
|
-
initConfiguration: preStartStrategy.getInitConfiguration(),
|
|
392
|
+
init: preStartStrategy.init,
|
|
393
|
+
getInitConfiguration: preStartStrategy.getInitConfiguration,
|
|
396
394
|
getRemoteConfiguration: function (callback) {
|
|
397
395
|
preStartStrategy.getRemoteConfiguration(callback)
|
|
398
396
|
}
|
|
@@ -288,6 +288,7 @@ export function startRecording(
|
|
|
288
288
|
emit: wrappedEmit,
|
|
289
289
|
$rEmitBaseline: wrappedEmitBaseline,
|
|
290
290
|
configuration: configuration,
|
|
291
|
+
$rGetDocumentUrl: viewContexts.$rGetDocumentUrl,
|
|
291
292
|
lifeCycle: lifeCycle,
|
|
292
293
|
sessionManager: sessionManager,
|
|
293
294
|
$rWasLastEmitBackpressured: wasLastEmitBackpressured,
|
|
@@ -306,6 +307,7 @@ export function startRecording(
|
|
|
306
307
|
_record = recordImpl({
|
|
307
308
|
emit: addRecord,
|
|
308
309
|
configuration: configuration,
|
|
310
|
+
$rGetDocumentUrl: viewContexts.$rGetDocumentUrl,
|
|
309
311
|
lifeCycle: lifeCycle,
|
|
310
312
|
sessionManager: sessionManager,
|
|
311
313
|
$rWasLastEmitBackpressured: wasLastEmitBackpressured,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { replayCanvasSupported } from './replayCanvasSupported'
|
|
1
2
|
import {
|
|
2
3
|
assign,
|
|
3
4
|
display,
|
|
@@ -23,6 +24,16 @@ import { isTracingOption } from '../domain/tracing/tracer'
|
|
|
23
24
|
import { validatePlugins } from './plugins'
|
|
24
25
|
import { DEFAULT_VISITOR_ID_TTL_HOURS } from './visitorId'
|
|
25
26
|
|
|
27
|
+
// The WebGL addon can install capture hooks in onInit, before configuration
|
|
28
|
+
// validation. Give plugins the capabilities of the selected bundle up front.
|
|
29
|
+
export function prepareReplayCanvasConfiguration(initConfiguration) {
|
|
30
|
+
if (!replayCanvasSupported && initConfiguration.replayCanvasEnabled) {
|
|
31
|
+
display.warn('Use dataflux-rum.js for Canvas replay.')
|
|
32
|
+
return assign({}, initConfiguration, { replayCanvasEnabled: false })
|
|
33
|
+
}
|
|
34
|
+
return initConfiguration
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
var REPLAY_CANVAS_QUALITY_PRESETS = {
|
|
27
38
|
low: {
|
|
28
39
|
quality: 0.25,
|
|
@@ -350,8 +361,8 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
350
361
|
enableLongAnimationFrame: !!initConfiguration.enableLongAnimationFrame,
|
|
351
362
|
trackViewsManually: !!initConfiguration.trackViewsManually,
|
|
352
363
|
plugins: initConfiguration.plugins || [],
|
|
353
|
-
sessionReplayWebGL: initConfiguration.sessionReplayWebGL,
|
|
354
|
-
replayCanvasEnabled: !!initConfiguration.replayCanvasEnabled,
|
|
364
|
+
sessionReplayWebGL: replayCanvasSupported ? initConfiguration.sessionReplayWebGL : undefined,
|
|
365
|
+
replayCanvasEnabled: replayCanvasSupported && !!initConfiguration.replayCanvasEnabled,
|
|
355
366
|
replayCanvasMode: replayCanvasMode,
|
|
356
367
|
replayCanvasSampling: replayCanvasSampling,
|
|
357
368
|
replayCanvasQuality: isNullUndefinedDefaultValue(
|
|
@@ -7,11 +7,16 @@ import {
|
|
|
7
7
|
replaceNumberCharByPath,
|
|
8
8
|
getQueryParamsFromUrl,
|
|
9
9
|
getURLSearchParams,
|
|
10
|
-
isHashAnAnchor,
|
|
11
10
|
getPathFromHash,
|
|
12
11
|
buildUrl
|
|
13
12
|
} from '@cloudcare/browser-core'
|
|
14
13
|
|
|
14
|
+
function withoutDocumentQuery(href) {
|
|
15
|
+
var url = buildUrl(href)
|
|
16
|
+
url.search = ''
|
|
17
|
+
return url
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
/**
|
|
16
21
|
* We want to attach to an event:
|
|
17
22
|
* - the url corresponding to its start
|
|
@@ -29,28 +34,27 @@ export function startUrlContexts(
|
|
|
29
34
|
expireDelay: URL_CONTEXT_TIME_OUT_DELAY
|
|
30
35
|
})
|
|
31
36
|
|
|
37
|
+
var excludeHashRouteOuterQuery
|
|
32
38
|
var previousViewUrl
|
|
33
39
|
|
|
34
40
|
lifeCycle.subscribe(LifeCycleEventType.BEFORE_VIEW_CREATED, function (data) {
|
|
35
|
-
|
|
41
|
+
excludeHashRouteOuterQuery = data.excludeHashRouteOuterQuery
|
|
36
42
|
var viewLocation = location
|
|
37
43
|
if (data.url) {
|
|
38
44
|
try {
|
|
39
45
|
viewLocation = buildUrl(data.url, location.href)
|
|
40
|
-
viewUrl = viewLocation.href
|
|
41
46
|
} catch (error) {
|
|
42
47
|
// Fall back to the browser location for invalid framework URLs.
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
previousViewUrl = viewUrl
|
|
50
|
+
var referrer = previousViewUrl || document.referrer
|
|
51
|
+
if (!previousViewUrl && referrer && excludeHashRouteOuterQuery) {
|
|
52
|
+
// Browsers omit the source fragment, so its routing mode is unknown.
|
|
53
|
+
referrer = withoutDocumentQuery(referrer).href
|
|
54
|
+
}
|
|
55
|
+
var context = buildUrlContext(viewLocation, referrer)
|
|
56
|
+
urlContextHistory.add(context, data.startClocks.relative)
|
|
57
|
+
previousViewUrl = context.url
|
|
54
58
|
})
|
|
55
59
|
lifeCycle.subscribe(LifeCycleEventType.AFTER_VIEW_ENDED, function (data) {
|
|
56
60
|
urlContextHistory.closeActive(data.endClocks.relative)
|
|
@@ -63,33 +67,33 @@ export function startUrlContexts(
|
|
|
63
67
|
var changeTime = relativeNow()
|
|
64
68
|
urlContextHistory.closeActive(changeTime)
|
|
65
69
|
urlContextHistory.add(
|
|
66
|
-
buildUrlContext(
|
|
67
|
-
{
|
|
68
|
-
url: data.newLocation.href,
|
|
69
|
-
location: data.newLocation,
|
|
70
|
-
referrer: current.referrer
|
|
71
|
-
},
|
|
72
|
-
true
|
|
73
|
-
),
|
|
70
|
+
buildUrlContext(data.newLocation, current.referrer),
|
|
74
71
|
changeTime
|
|
75
72
|
)
|
|
76
73
|
}
|
|
77
74
|
})
|
|
78
75
|
|
|
79
|
-
function
|
|
80
|
-
|
|
76
|
+
function getViewLocation(viewLocation) {
|
|
77
|
+
return excludeHashRouteOuterQuery && viewLocation.hash?.indexOf('#/') === 0
|
|
78
|
+
? withoutDocumentQuery(viewLocation.href)
|
|
79
|
+
: viewLocation
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function buildUrlContext(viewLocation, referrer) {
|
|
83
|
+
viewLocation = getViewLocation(viewLocation)
|
|
84
|
+
var pathname = viewLocation.pathname
|
|
81
85
|
var path = pathname
|
|
82
|
-
var hash =
|
|
86
|
+
var hash = viewLocation.hash
|
|
83
87
|
if (hash && hash.indexOf('#/') === 0) {
|
|
84
88
|
path = '/' + getPathFromHash(hash)
|
|
85
89
|
}
|
|
86
90
|
return {
|
|
87
|
-
url:
|
|
88
|
-
referrer
|
|
89
|
-
host:
|
|
91
|
+
url: viewLocation.href,
|
|
92
|
+
referrer,
|
|
93
|
+
host: viewLocation.host,
|
|
90
94
|
path: path,
|
|
91
95
|
pathGroup: replaceNumberCharByPath(path),
|
|
92
|
-
urlQuery: getLocationQuery(
|
|
96
|
+
urlQuery: getLocationQuery(viewLocation),
|
|
93
97
|
pathname: pathname
|
|
94
98
|
}
|
|
95
99
|
}
|
|
@@ -109,6 +113,9 @@ export function startUrlContexts(
|
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
return {
|
|
116
|
+
$rGetDocumentUrl: function () {
|
|
117
|
+
return getViewLocation(location).href
|
|
118
|
+
},
|
|
112
119
|
findUrl: function (startTime) {
|
|
113
120
|
return urlContextHistory.find(startTime)
|
|
114
121
|
},
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
SESSION_TIME_OUT_DELAY,
|
|
3
3
|
createValueHistory,
|
|
4
4
|
LifeCycleEventType,
|
|
5
|
-
|
|
5
|
+
getUrlParts
|
|
6
6
|
} from '@cloudcare/browser-core'
|
|
7
7
|
|
|
8
8
|
export var VIEW_CONTEXT_TIME_OUT_DELAY = SESSION_TIME_OUT_DELAY
|
|
@@ -39,7 +39,7 @@ export function startViewContexts(lifeCycle) {
|
|
|
39
39
|
context: view.context,
|
|
40
40
|
id: view.id,
|
|
41
41
|
name: view.name,
|
|
42
|
-
path:
|
|
42
|
+
path: getUrlParts(view.url || location.href).Path,
|
|
43
43
|
startClocks: view.startClocks
|
|
44
44
|
}
|
|
45
45
|
}
|