@cloudcare/browser-rum 3.1.24 → 3.2.0
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 +49 -30
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/perStartRum.js +158 -0
- package/cjs/boot/perStartRum.js.map +1 -0
- package/cjs/boot/recorderApi.js +10 -17
- package/cjs/boot/recorderApi.js.map +1 -1
- package/cjs/boot/rum.entry.js +5 -1
- package/cjs/boot/rum.entry.js.map +1 -1
- package/cjs/boot/rum.js +32 -33
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/boot/rumPublicApi.js +90 -156
- package/cjs/boot/rumPublicApi.js.map +1 -1
- package/cjs/boot/startRecording.js +9 -7
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/domain/assembly.js +3 -3
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/configuration.js +3 -0
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/deflate/deflateEncoder.js +121 -0
- package/cjs/domain/deflate/deflateEncoder.js.map +1 -0
- package/cjs/domain/deflate/deflateWorker.js +160 -0
- package/cjs/domain/deflate/deflateWorker.js.map +1 -0
- package/cjs/domain/deflate/index.js.map +1 -0
- package/cjs/domain/replay/segmentCollection/segment.js +34 -25
- package/cjs/domain/replay/segmentCollection/segment.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +9 -8
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js +29 -0
- package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -0
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +12 -5
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/trackConsoleError.js +2 -9
- package/cjs/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js +72 -0
- package/cjs/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -0
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js +1 -1
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +27 -22
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +5 -4
- package/cjs/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/cjs/transport/startRumBatch.js +7 -30
- package/cjs/transport/startRumBatch.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/perStartRum.js +152 -0
- package/esm/boot/perStartRum.js.map +1 -0
- package/esm/boot/recorderApi.js +11 -18
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/rum.entry.js +5 -1
- package/esm/boot/rum.entry.js.map +1 -1
- package/esm/boot/rum.js +33 -33
- package/esm/boot/rum.js.map +1 -1
- package/esm/boot/rumPublicApi.js +91 -157
- package/esm/boot/rumPublicApi.js.map +1 -1
- package/esm/boot/startRecording.js +9 -7
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/domain/assembly.js +3 -3
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/configuration.js +3 -0
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/deflate/deflateEncoder.js +113 -0
- package/esm/domain/deflate/deflateEncoder.js.map +1 -0
- package/esm/domain/deflate/deflateWorker.js +147 -0
- package/esm/domain/deflate/deflateWorker.js.map +1 -0
- package/esm/domain/deflate/index.js.map +1 -0
- package/esm/domain/replay/segmentCollection/segment.js +33 -24
- package/esm/domain/replay/segmentCollection/segment.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +10 -9
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js +19 -0
- package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -0
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +10 -3
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js +3 -10
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js.map +1 -1
- package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js +66 -0
- package/esm/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js.map +1 -0
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js +1 -1
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.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/view/trackCommonViewMetrics.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackCommonViewMetrics.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +29 -24
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +5 -4
- package/esm/domain/rumEventsCollection/view/trackInteractionToNextPaint.js.map +1 -1
- package/esm/transport/startRumBatch.js +8 -31
- package/esm/transport/startRumBatch.js.map +1 -1
- package/package.json +4 -4
- package/src/boot/perStartRum.js +207 -0
- package/src/boot/recorderApi.js +18 -26
- package/src/boot/rum.entry.js +5 -1
- package/src/boot/rum.js +47 -48
- package/src/boot/rumPublicApi.js +115 -198
- package/src/boot/startRecording.js +8 -9
- package/src/domain/assembly.js +3 -5
- package/src/domain/configuration.js +3 -0
- package/src/domain/deflate/deflateEncoder.js +139 -0
- package/src/domain/{replay/deflate → deflate}/deflateWorker.js +57 -20
- package/src/domain/replay/segmentCollection/segment.js +36 -30
- package/src/domain/replay/segmentCollection/segmentCollection.js +11 -18
- package/src/domain/rumEventsCollection/actions/interactionSelectorCache.js +20 -0
- package/src/domain/rumEventsCollection/actions/trackClickActions.js +14 -3
- package/src/domain/rumEventsCollection/error/trackConsoleError.js +6 -12
- package/src/domain/rumEventsCollection/longTask/longAnimationFrameCollection.js +69 -0
- package/src/domain/rumEventsCollection/longTask/longTaskCollection.js +1 -1
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +1 -1
- package/src/domain/rumEventsCollection/view/trackCommonViewMetrics.js +0 -1
- package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +33 -42
- package/src/domain/rumEventsCollection/view/trackInteractionToNextPaint.js +11 -4
- package/src/transport/startRumBatch.js +10 -52
- package/cjs/domain/performanceCollection.js +0 -75
- package/cjs/domain/performanceCollection.js.map +0 -1
- package/cjs/domain/replay/deflate/deflateEncoder.js +0 -82
- package/cjs/domain/replay/deflate/deflateEncoder.js.map +0 -1
- package/cjs/domain/replay/deflate/deflateWorker.js +0 -142
- package/cjs/domain/replay/deflate/deflateWorker.js.map +0 -1
- package/cjs/domain/replay/deflate/index.js.map +0 -1
- package/esm/domain/performanceCollection.js +0 -69
- package/esm/domain/performanceCollection.js.map +0 -1
- package/esm/domain/replay/deflate/deflateEncoder.js +0 -74
- package/esm/domain/replay/deflate/deflateEncoder.js.map +0 -1
- package/esm/domain/replay/deflate/deflateWorker.js +0 -129
- package/esm/domain/replay/deflate/deflateWorker.js.map +0 -1
- package/esm/domain/replay/deflate/index.js.map +0 -1
- package/src/domain/performanceCollection.js +0 -95
- package/src/domain/replay/deflate/deflateEncoder.js +0 -88
- /package/cjs/domain/{replay/deflate → deflate}/index.js +0 -0
- /package/esm/domain/{replay/deflate → deflate}/index.js +0 -0
- /package/src/domain/{replay/deflate → deflate}/index.js +0 -0
package/src/boot/rumPublicApi.js
CHANGED
|
@@ -1,191 +1,105 @@
|
|
|
1
1
|
import {
|
|
2
2
|
makePublicApi,
|
|
3
|
-
areCookiesAuthorized,
|
|
4
|
-
BoundedBuffer,
|
|
5
|
-
display,
|
|
6
|
-
buildCookieOptions,
|
|
7
3
|
createContextManager,
|
|
8
4
|
CustomerDataType,
|
|
9
5
|
clocksNow,
|
|
10
|
-
timeStampNow,
|
|
11
6
|
ActionType,
|
|
12
7
|
deepClone,
|
|
13
8
|
createHandlingStack,
|
|
14
9
|
sanitizeUser,
|
|
15
10
|
checkUser,
|
|
16
|
-
|
|
11
|
+
callMonitored,
|
|
17
12
|
assign,
|
|
18
|
-
canUseEventBridge,
|
|
19
13
|
monitor,
|
|
20
|
-
storeContextManager
|
|
14
|
+
storeContextManager,
|
|
15
|
+
createIdentityEncoder,
|
|
16
|
+
addTelemetryUsage,
|
|
17
|
+
sanitize,
|
|
18
|
+
displayAlreadyInitializedError
|
|
21
19
|
} from '@cloudcare/browser-core'
|
|
22
|
-
import { validateAndBuildRumConfiguration } from '../domain/configuration'
|
|
23
20
|
import { buildCommonContext } from '../domain/contexts/commonContext'
|
|
21
|
+
import { createPreStartStrategy } from './perStartRum'
|
|
24
22
|
var RUM_STORAGE_KEY = 'rum'
|
|
25
|
-
export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
26
|
-
|
|
23
|
+
export function makeRumPublicApi(startRumImpl, recorderApi, options) {
|
|
24
|
+
if (options === undefined) {
|
|
25
|
+
options = {}
|
|
26
|
+
}
|
|
27
27
|
|
|
28
28
|
var globalContextManager = createContextManager(
|
|
29
29
|
CustomerDataType.GlobalContext
|
|
30
30
|
)
|
|
31
31
|
var userContextManager = createContextManager(CustomerDataType.User)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
var stopSessionStrategy = function () {
|
|
40
|
-
return noop()
|
|
41
|
-
}
|
|
42
|
-
var bufferApiCalls = new BoundedBuffer()
|
|
43
|
-
var addTimingStrategy = function (name, time) {
|
|
44
|
-
if (typeof time === 'undefined') {
|
|
45
|
-
time = timeStampNow()
|
|
46
|
-
}
|
|
47
|
-
bufferApiCalls.add(function () {
|
|
48
|
-
return addTimingStrategy(name, time)
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
var startViewStrategy = function (options, startClocks) {
|
|
52
|
-
if (typeof startClocks === 'undefined') {
|
|
53
|
-
startClocks = clocksNow()
|
|
54
|
-
}
|
|
55
|
-
bufferApiCalls.add(function () {
|
|
56
|
-
return startViewStrategy(options, startClocks)
|
|
57
|
-
})
|
|
58
|
-
}
|
|
59
|
-
var addActionStrategy = function (action, commonContext) {
|
|
60
|
-
if (typeof commonContext == 'undefined') {
|
|
61
|
-
commonContext = buildCommonContext(
|
|
62
|
-
globalContextManager,
|
|
63
|
-
userContextManager,
|
|
64
|
-
recorderApi
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
bufferApiCalls.add(function () {
|
|
68
|
-
return addActionStrategy(action, commonContext)
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
var addErrorStrategy = function (providedError, commonContext) {
|
|
72
|
-
if (typeof commonContext == 'undefined') {
|
|
73
|
-
commonContext = buildCommonContext(
|
|
74
|
-
globalContextManager,
|
|
75
|
-
userContextManager,
|
|
76
|
-
recorderApi
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
bufferApiCalls.add(function () {
|
|
80
|
-
return addErrorStrategy(providedError, commonContext)
|
|
81
|
-
})
|
|
32
|
+
function getCommonContext() {
|
|
33
|
+
return buildCommonContext(
|
|
34
|
+
globalContextManager,
|
|
35
|
+
userContextManager,
|
|
36
|
+
recorderApi
|
|
37
|
+
)
|
|
82
38
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var configuration = validateAndBuildRumConfiguration(initConfiguration)
|
|
101
|
-
if (!configuration) {
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!configuration.trackViewsManually) {
|
|
106
|
-
doStartRum(configuration)
|
|
107
|
-
} else {
|
|
108
|
-
// drain beforeInitCalls by buffering them until we start RUM
|
|
109
|
-
// if we get a startView, drain re-buffered calls before continuing to drain beforeInitCalls
|
|
110
|
-
// in order to ensure that calls are processed in order
|
|
111
|
-
var beforeInitCalls = bufferApiCalls
|
|
112
|
-
bufferApiCalls = new BoundedBuffer()
|
|
113
|
-
|
|
114
|
-
startViewStrategy = function (options) {
|
|
115
|
-
doStartRum(configuration, options)
|
|
39
|
+
let strategy = createPreStartStrategy(
|
|
40
|
+
options,
|
|
41
|
+
getCommonContext,
|
|
42
|
+
function (configuration, deflateWorker, initialViewOptions) {
|
|
43
|
+
if (configuration.storeContextsToLocal) {
|
|
44
|
+
storeContextManager(
|
|
45
|
+
configuration,
|
|
46
|
+
globalContextManager,
|
|
47
|
+
RUM_STORAGE_KEY,
|
|
48
|
+
CustomerDataType.GlobalContext
|
|
49
|
+
)
|
|
50
|
+
storeContextManager(
|
|
51
|
+
configuration,
|
|
52
|
+
userContextManager,
|
|
53
|
+
RUM_STORAGE_KEY,
|
|
54
|
+
CustomerDataType.User
|
|
55
|
+
)
|
|
116
56
|
}
|
|
117
|
-
beforeInitCalls.drain()
|
|
118
|
-
}
|
|
119
57
|
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
function doStartRum(configuration, initialViewOptions) {
|
|
123
|
-
if (configuration.storeContextsToLocal) {
|
|
124
|
-
storeContextManager(
|
|
58
|
+
var startRumResult = startRumImpl(
|
|
125
59
|
configuration,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
60
|
+
recorderApi,
|
|
61
|
+
getCommonContext,
|
|
62
|
+
initialViewOptions,
|
|
63
|
+
deflateWorker && options.createDeflateEncoder
|
|
64
|
+
? function (streamId) {
|
|
65
|
+
return options.createDeflateEncoder(deflateWorker, streamId)
|
|
66
|
+
}
|
|
67
|
+
: createIdentityEncoder
|
|
129
68
|
)
|
|
130
|
-
|
|
69
|
+
|
|
70
|
+
recorderApi.onRumStart(
|
|
71
|
+
startRumResult.lifeCycle,
|
|
131
72
|
configuration,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
73
|
+
startRumResult.session,
|
|
74
|
+
startRumResult.viewContexts,
|
|
75
|
+
deflateWorker
|
|
135
76
|
)
|
|
136
|
-
// // localstorage
|
|
137
|
-
// var beforeInitGlobalContext = globalContextManager.getContext()
|
|
138
|
-
// globalContextManager = createStoredContextManager(
|
|
139
|
-
// RUM_STORAGE_KEY,
|
|
140
|
-
// CustomerDataType.GlobalContext
|
|
141
|
-
// )
|
|
142
|
-
// globalContextManager.setContext(
|
|
143
|
-
// extend2Lev(globalContextManager.getContext(), beforeInitGlobalContext)
|
|
144
|
-
// )
|
|
145
77
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
// CustomerDataType.User
|
|
150
|
-
// )
|
|
151
|
-
// userContextManager.setContext(
|
|
152
|
-
// extend2Lev(userContextManager.getContext(), beforeInitUserContext)
|
|
153
|
-
// )
|
|
78
|
+
strategy = createPostStartStrategy(strategy, startRumResult)
|
|
79
|
+
|
|
80
|
+
return startRumResult
|
|
154
81
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
userContextManager,
|
|
160
|
-
initialViewOptions
|
|
161
|
-
)
|
|
162
|
-
startViewStrategy = startRumResults.startView
|
|
163
|
-
addActionStrategy = startRumResults.addAction
|
|
164
|
-
addErrorStrategy = startRumResults.addError
|
|
165
|
-
addTimingStrategy = startRumResults.addTiming
|
|
166
|
-
getInternalContextStrategy = startRumResults.getInternalContext
|
|
167
|
-
stopSessionStrategy = startRumResults.stopSession
|
|
168
|
-
bufferApiCalls.drain()
|
|
169
|
-
recorderApi.onRumStart(
|
|
170
|
-
startRumResults.lifeCycle,
|
|
171
|
-
configuration,
|
|
172
|
-
startRumResults.session,
|
|
173
|
-
startRumResults.viewContexts
|
|
174
|
-
)
|
|
175
|
-
}
|
|
176
|
-
var startView = monitor(function (options) {
|
|
177
|
-
var sanitizedOptions =
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
const startView = monitor(function (options) {
|
|
85
|
+
const sanitizedOptions =
|
|
178
86
|
typeof options === 'object' ? options : { name: options }
|
|
179
|
-
|
|
87
|
+
strategy.startView(sanitizedOptions)
|
|
88
|
+
addTelemetryUsage({ feature: 'start-view' })
|
|
180
89
|
})
|
|
90
|
+
|
|
181
91
|
var rumPublicApi = makePublicApi({
|
|
182
|
-
init: monitor(
|
|
92
|
+
init: monitor(function (initConfiguration) {
|
|
93
|
+
strategy.init(initConfiguration)
|
|
94
|
+
}),
|
|
183
95
|
/** @deprecated: use setGlobalContextProperty instead */
|
|
184
96
|
addRumGlobalContext: monitor(function (key, value) {
|
|
185
|
-
|
|
97
|
+
globalContextManager.add(key, value)
|
|
98
|
+
addTelemetryUsage({ feature: 'set-global-context' })
|
|
186
99
|
}),
|
|
187
100
|
setGlobalContextProperty: monitor(function (key, value) {
|
|
188
|
-
|
|
101
|
+
globalContextManager.setContextProperty(key, value)
|
|
102
|
+
addTelemetryUsage({ feature: 'set-global-context' })
|
|
189
103
|
}),
|
|
190
104
|
|
|
191
105
|
/** @deprecated: use removeGlobalContextProperty instead */
|
|
@@ -206,10 +120,12 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
206
120
|
|
|
207
121
|
/** @deprecated: use setGlobalContext instead */
|
|
208
122
|
setRumGlobalContext: monitor(function (context) {
|
|
209
|
-
|
|
123
|
+
globalContextManager.set(context)
|
|
124
|
+
addTelemetryUsage({ feature: 'set-global-context' })
|
|
210
125
|
}),
|
|
211
126
|
setGlobalContext: monitor(function (context) {
|
|
212
|
-
|
|
127
|
+
globalContextManager.setContext(context)
|
|
128
|
+
addTelemetryUsage({ feature: 'set-global-context' })
|
|
213
129
|
}),
|
|
214
130
|
|
|
215
131
|
clearGlobalContext: monitor(function () {
|
|
@@ -217,38 +133,48 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
217
133
|
}),
|
|
218
134
|
|
|
219
135
|
getInitConfiguration: monitor(function () {
|
|
220
|
-
return
|
|
136
|
+
return deepClone(strategy.getInitConfiguration())
|
|
221
137
|
}),
|
|
222
138
|
getInternalContext: monitor(function (startTime) {
|
|
223
|
-
return
|
|
139
|
+
return strategy.getInternalContext(startTime)
|
|
224
140
|
}),
|
|
225
141
|
addDebugSession: monitor(function (id) {}),
|
|
226
142
|
clearDebugSession: monitor(function () {}),
|
|
227
143
|
getDebugSession: monitor(function () {}),
|
|
228
144
|
addAction: monitor(function (name, context) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
145
|
+
const handlingStack = createHandlingStack()
|
|
146
|
+
|
|
147
|
+
callMonitored(function () {
|
|
148
|
+
strategy.addAction({
|
|
149
|
+
name: sanitize(name),
|
|
150
|
+
context: sanitize(context),
|
|
151
|
+
startClocks: clocksNow(),
|
|
152
|
+
type: ActionType.CUSTOM,
|
|
153
|
+
handlingStack: handlingStack
|
|
154
|
+
})
|
|
155
|
+
addTelemetryUsage({ feature: 'add-action' })
|
|
234
156
|
})
|
|
235
157
|
}),
|
|
236
158
|
addError: monitor(function (error, context) {
|
|
237
159
|
var handlingStack = createHandlingStack()
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
160
|
+
callMonitored(function () {
|
|
161
|
+
strategy.addError({
|
|
162
|
+
error, // Do not sanitize error here, it is needed unserialized by computeRawError()
|
|
163
|
+
handlingStack,
|
|
164
|
+
context: sanitize(context),
|
|
165
|
+
startClocks: clocksNow()
|
|
166
|
+
})
|
|
167
|
+
addTelemetryUsage({ feature: 'add-error' })
|
|
243
168
|
})
|
|
244
169
|
}),
|
|
245
170
|
addTiming: monitor(function (name, time) {
|
|
246
|
-
|
|
171
|
+
strategy.addTiming(sanitize(name), time)
|
|
247
172
|
}),
|
|
248
173
|
setUser: monitor(function (newUser) {
|
|
249
174
|
if (checkUser(newUser)) {
|
|
250
175
|
userContextManager.setContext(sanitizeUser(newUser))
|
|
251
176
|
}
|
|
177
|
+
addTelemetryUsage({ feature: 'set-user' })
|
|
252
178
|
}),
|
|
253
179
|
getUser: monitor(function () {
|
|
254
180
|
return userContextManager.getContext()
|
|
@@ -258,6 +184,7 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
258
184
|
newUser[key] = property
|
|
259
185
|
var sanitizedProperty = sanitizeUser(newUser)[key]
|
|
260
186
|
userContextManager.setContextProperty(key, sanitizedProperty)
|
|
187
|
+
addTelemetryUsage({ feature: 'set-user' })
|
|
261
188
|
}),
|
|
262
189
|
removeUserProperty: monitor(function (key) {
|
|
263
190
|
return userContextManager.removeContextProperty(key)
|
|
@@ -272,40 +199,30 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
272
199
|
}),
|
|
273
200
|
startView: startView,
|
|
274
201
|
stopSession: monitor(function () {
|
|
275
|
-
|
|
202
|
+
strategy.stopSession()
|
|
203
|
+
addTelemetryUsage({ feature: 'stop-session' })
|
|
204
|
+
}),
|
|
205
|
+
startSessionReplayRecording: monitor(function (options) {
|
|
206
|
+
recorderApi.start(options)
|
|
207
|
+
addTelemetryUsage({
|
|
208
|
+
feature: 'start-session-replay-recording',
|
|
209
|
+
force: options && options.force
|
|
210
|
+
})
|
|
276
211
|
}),
|
|
277
|
-
startSessionReplayRecording: monitor(recorderApi.start),
|
|
278
212
|
stopSessionReplayRecording: monitor(recorderApi.stop)
|
|
279
213
|
})
|
|
280
214
|
return rumPublicApi
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
return true
|
|
292
|
-
}
|
|
293
|
-
function canInitRum(initConfiguration) {
|
|
294
|
-
if (isAlreadyInitialized) {
|
|
295
|
-
if (!initConfiguration.silentMultipleInit) {
|
|
296
|
-
display.error('DATAFLUX_RUM is already initialized.')
|
|
215
|
+
}
|
|
216
|
+
function createPostStartStrategy(preStartStrategy, startRumResult) {
|
|
217
|
+
return assign(
|
|
218
|
+
{
|
|
219
|
+
init: function (initConfiguration) {
|
|
220
|
+
displayAlreadyInitializedError('DATAFLUX_RUM', initConfiguration)
|
|
221
|
+
},
|
|
222
|
+
getInitConfiguration: function () {
|
|
223
|
+
return preStartStrategy.initConfiguration
|
|
297
224
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
function isLocalFile() {
|
|
303
|
-
return window.location.protocol === 'file:'
|
|
304
|
-
}
|
|
305
|
-
function overrideInitConfigurationForBridge(initConfiguration) {
|
|
306
|
-
return assign({}, initConfiguration, {
|
|
307
|
-
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
|
|
308
|
-
sessionSampleRate: 100
|
|
309
|
-
})
|
|
310
|
-
}
|
|
225
|
+
},
|
|
226
|
+
startRumResult
|
|
227
|
+
)
|
|
311
228
|
}
|
|
@@ -19,6 +19,7 @@ export function startRecording(
|
|
|
19
19
|
encoder,
|
|
20
20
|
httpRequest
|
|
21
21
|
) {
|
|
22
|
+
var cleanupTasks = []
|
|
22
23
|
var reportError = function (error) {
|
|
23
24
|
lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error })
|
|
24
25
|
addTelemetryDebug('Error reported to customer', {
|
|
@@ -31,7 +32,6 @@ export function startRecording(
|
|
|
31
32
|
createHttpRequest(
|
|
32
33
|
configuration.sessionReplayEndPoint,
|
|
33
34
|
SEGMENT_BYTES_LIMIT,
|
|
34
|
-
false,
|
|
35
35
|
reportError
|
|
36
36
|
)
|
|
37
37
|
|
|
@@ -44,14 +44,13 @@ export function startRecording(
|
|
|
44
44
|
encoder
|
|
45
45
|
)
|
|
46
46
|
var addRecord = segmentCollection.addRecord
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
cleanupTasks.push(segmentCollection.stop)
|
|
49
48
|
var _record = record({
|
|
50
49
|
emit: addRecord,
|
|
51
50
|
configuration: configuration,
|
|
52
51
|
lifeCycle: lifeCycle
|
|
53
52
|
})
|
|
54
|
-
|
|
53
|
+
cleanupTasks.push(_record.stop)
|
|
55
54
|
var takeSubsequentFullSnapshot = _record.takeSubsequentFullSnapshot
|
|
56
55
|
var flushMutations = _record.flushMutations
|
|
57
56
|
var subscribeViewEnded = lifeCycle.subscribe(
|
|
@@ -64,19 +63,19 @@ export function startRecording(
|
|
|
64
63
|
})
|
|
65
64
|
}
|
|
66
65
|
)
|
|
66
|
+
cleanupTasks.push(subscribeViewEnded.unsubscribe)
|
|
67
67
|
var scribeViewCreated = lifeCycle.subscribe(
|
|
68
68
|
LifeCycleEventType.VIEW_CREATED,
|
|
69
69
|
function (view) {
|
|
70
70
|
takeSubsequentFullSnapshot(view.startClocks.timeStamp)
|
|
71
71
|
}
|
|
72
72
|
)
|
|
73
|
-
|
|
73
|
+
cleanupTasks.push(scribeViewCreated.unsubscribe)
|
|
74
74
|
return {
|
|
75
75
|
stop: function () {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
stopSegmentCollection()
|
|
76
|
+
cleanupTasks.forEach(function (task) {
|
|
77
|
+
task()
|
|
78
|
+
})
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
}
|
package/src/domain/assembly.js
CHANGED
|
@@ -37,7 +37,7 @@ export function startRumAssembly(
|
|
|
37
37
|
urlContexts,
|
|
38
38
|
actionContexts,
|
|
39
39
|
displayContext,
|
|
40
|
-
|
|
40
|
+
getCommonContext,
|
|
41
41
|
reportError
|
|
42
42
|
) {
|
|
43
43
|
modifiableFieldPathsByEvent[RumEventType.VIEW] = VIEW_MODIFIABLE_FIELD_PATHS
|
|
@@ -90,14 +90,12 @@ export function startRumAssembly(
|
|
|
90
90
|
var domainContext = data.domainContext
|
|
91
91
|
var viewContext = viewContexts.findView(startTime)
|
|
92
92
|
var urlContext = urlContexts.findUrl(startTime)
|
|
93
|
-
var session = sessionManager.findTrackedSession(
|
|
94
|
-
rawRumEvent.type !== RumEventType.VIEW ? startTime : undefined
|
|
95
|
-
)
|
|
93
|
+
var session = sessionManager.findTrackedSession(startTime)
|
|
96
94
|
|
|
97
95
|
if (session && viewContext && urlContext) {
|
|
98
96
|
var actionId = actionContexts.findActionId(startTime)
|
|
99
97
|
var actionIds = actionContexts.findAllActionId(startTime)
|
|
100
|
-
var commonContext = savedCommonContext ||
|
|
98
|
+
var commonContext = savedCommonContext || getCommonContext()
|
|
101
99
|
var rumContext = {
|
|
102
100
|
_gc: {
|
|
103
101
|
sdkName: configuration.sdkName,
|
|
@@ -94,7 +94,10 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
94
94
|
initConfiguration.excludedActivityUrls,
|
|
95
95
|
[]
|
|
96
96
|
),
|
|
97
|
+
workerUrl: initConfiguration.workerUrl,
|
|
98
|
+
compressIntakeRequests: !!initConfiguration.compressIntakeRequests,
|
|
97
99
|
trackUserInteractions: trackUserInteractions,
|
|
100
|
+
enableLongAnimationFrame: !!initConfiguration.enableLongAnimationFrame,
|
|
98
101
|
trackViewsManually: !!initConfiguration.trackViewsManually,
|
|
99
102
|
traceType: isNullUndefinedDefaultValue(
|
|
100
103
|
initConfiguration.traceType,
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addEventListener,
|
|
3
|
+
concatBuffers,
|
|
4
|
+
addTelemetryDebug,
|
|
5
|
+
assign
|
|
6
|
+
} from '@cloudcare/browser-core'
|
|
7
|
+
export var DeflateEncoderStreamId = {
|
|
8
|
+
REPLAY: 1,
|
|
9
|
+
RUM: 2
|
|
10
|
+
}
|
|
11
|
+
export function createDeflateEncoder(worker, streamId) {
|
|
12
|
+
var rawBytesCount = 0
|
|
13
|
+
var compressedData = []
|
|
14
|
+
var compressedDataTrailer
|
|
15
|
+
|
|
16
|
+
var nextWriteActionId = 0
|
|
17
|
+
var pendingWriteActions = []
|
|
18
|
+
|
|
19
|
+
var wokerListener = addEventListener(worker, 'message', function (params) {
|
|
20
|
+
var workerResponse = params.data
|
|
21
|
+
if (
|
|
22
|
+
workerResponse.type !== 'wrote' ||
|
|
23
|
+
(workerResponse.streamId && workerResponse.streamId !== streamId)
|
|
24
|
+
) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
rawBytesCount += workerResponse.additionalBytesCount
|
|
29
|
+
compressedData.push(workerResponse.result)
|
|
30
|
+
compressedDataTrailer = workerResponse.trailer
|
|
31
|
+
var nextPendingAction = pendingWriteActions.shift()
|
|
32
|
+
if (nextPendingAction && nextPendingAction.id === workerResponse.id) {
|
|
33
|
+
if (nextPendingAction.writeCallback) {
|
|
34
|
+
nextPendingAction.writeCallback(workerResponse.result.byteLength)
|
|
35
|
+
} else if (nextPendingAction.finishCallback) {
|
|
36
|
+
nextPendingAction.finishCallback()
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
removeMessageListener()
|
|
40
|
+
addTelemetryDebug('Worker responses received out of order.')
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
var removeMessageListener = wokerListener.stop
|
|
45
|
+
function consumeResult() {
|
|
46
|
+
var output =
|
|
47
|
+
compressedData.length === 0
|
|
48
|
+
? new Uint8Array(0)
|
|
49
|
+
: concatBuffers(compressedData.concat(compressedDataTrailer))
|
|
50
|
+
var result = {
|
|
51
|
+
rawBytesCount: rawBytesCount,
|
|
52
|
+
output: output,
|
|
53
|
+
outputBytesCount: output.byteLength,
|
|
54
|
+
encoding: 'deflate'
|
|
55
|
+
}
|
|
56
|
+
rawBytesCount = 0
|
|
57
|
+
compressedData = []
|
|
58
|
+
return result
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function sendResetIfNeeded() {
|
|
62
|
+
if (nextWriteActionId > 0) {
|
|
63
|
+
worker.postMessage({
|
|
64
|
+
action: 'reset',
|
|
65
|
+
streamId: streamId
|
|
66
|
+
})
|
|
67
|
+
nextWriteActionId = 0
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
isAsync: true,
|
|
72
|
+
isEmpty: function () {
|
|
73
|
+
return nextWriteActionId === 0
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
write: function (data, callback) {
|
|
77
|
+
worker.postMessage({
|
|
78
|
+
action: 'write',
|
|
79
|
+
id: nextWriteActionId,
|
|
80
|
+
data: data,
|
|
81
|
+
streamId: streamId
|
|
82
|
+
})
|
|
83
|
+
pendingWriteActions.push({
|
|
84
|
+
id: nextWriteActionId,
|
|
85
|
+
writeCallback: callback,
|
|
86
|
+
data: data
|
|
87
|
+
})
|
|
88
|
+
nextWriteActionId += 1
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
finish: function (callback) {
|
|
92
|
+
sendResetIfNeeded()
|
|
93
|
+
|
|
94
|
+
if (!pendingWriteActions.length) {
|
|
95
|
+
callback(consumeResult())
|
|
96
|
+
} else {
|
|
97
|
+
// Make sure we do not call any write callback
|
|
98
|
+
pendingWriteActions.forEach(function (pendingWriteAction) {
|
|
99
|
+
delete pendingWriteAction.writeCallback
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
// Wait for the last action to finish before calling the finish callback
|
|
103
|
+
pendingWriteActions[pendingWriteActions.length - 1].finishCallback =
|
|
104
|
+
function () {
|
|
105
|
+
return callback(consumeResult())
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
finishSync: function () {
|
|
111
|
+
sendResetIfNeeded()
|
|
112
|
+
|
|
113
|
+
var pendingData = pendingWriteActions
|
|
114
|
+
.map(function (pendingWriteAction) {
|
|
115
|
+
// Make sure we do not call any write or finish callback
|
|
116
|
+
delete pendingWriteAction.writeCallback
|
|
117
|
+
delete pendingWriteAction.finishCallback
|
|
118
|
+
return pendingWriteAction.data
|
|
119
|
+
})
|
|
120
|
+
.join('')
|
|
121
|
+
|
|
122
|
+
return assign(consumeResult(), {
|
|
123
|
+
pendingData: pendingData
|
|
124
|
+
})
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
estimateEncodedBytesCount: function (data) {
|
|
128
|
+
// This is a rough estimation of the data size once it'll be encoded by deflate. We observed
|
|
129
|
+
// that if it's the first chunk of data pushed to the stream, the ratio is lower (3-4), but
|
|
130
|
+
// after that the ratio is greater (10+). We chose 8 here, which (on average) seems to produce
|
|
131
|
+
// requests of the expected size.
|
|
132
|
+
return data.length / 8
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
stop: function () {
|
|
136
|
+
removeMessageListener()
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|