@cloudcare/browser-rum 2.2.13 → 3.0.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/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/recorderApi.js +161 -0
- package/cjs/boot/rum.entry.js +6 -1
- package/cjs/boot/rum.js +15 -5
- package/cjs/boot/rumPublicApi.js +8 -4
- package/cjs/boot/startRecording.js +55 -0
- package/cjs/constants.js +52 -0
- package/cjs/domain/assembly.js +1 -7
- package/cjs/domain/configuration.js +3 -2
- package/cjs/domain/contexts/foregroundContexts.js +138 -0
- package/cjs/domain/contexts/internalContext.js +1 -1
- package/cjs/domain/contexts/urlContexts.js +9 -2
- package/cjs/domain/domMutationCollection.js +4 -5
- package/cjs/domain/initViewportObservable.js +52 -0
- package/cjs/domain/locationChangeObservable.js +12 -26
- package/cjs/domain/performanceCollection.js +2 -13
- package/cjs/domain/replay/record/elementsScrollPositions.js +27 -0
- package/cjs/domain/replay/record/index.js +41 -0
- package/cjs/domain/replay/record/mutationBatch.js +58 -0
- package/cjs/domain/replay/record/mutationObserver.js +383 -0
- package/cjs/domain/replay/record/observers.js +473 -0
- package/cjs/domain/replay/record/privacy.js +256 -0
- package/cjs/domain/replay/record/record.js +174 -0
- package/cjs/domain/replay/record/serializationUtils.js +137 -0
- package/cjs/domain/replay/record/serialize.js +488 -0
- package/cjs/domain/replay/record/shadowRootsController.js +61 -0
- package/cjs/domain/replay/record/utils.js +53 -0
- package/cjs/domain/replay/record/viewports.js +104 -0
- package/cjs/domain/replay/replayStats.js +83 -0
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +43 -0
- package/cjs/domain/replay/segmentCollection/deflateWorker.js +4399 -0
- package/cjs/domain/replay/segmentCollection/index.js +33 -0
- package/cjs/domain/replay/segmentCollection/segment.js +101 -0
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +179 -0
- package/cjs/domain/replay/segmentCollection/startDeflateWorker.js +126 -0
- package/cjs/domain/requestCollection.js +35 -17
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js +12 -4
- package/cjs/domain/rumEventsCollection/actions/clickChain.js +3 -3
- package/cjs/domain/rumEventsCollection/actions/computeFrustration.js +6 -5
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +8 -6
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +111 -75
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js +22 -28
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +94 -54
- package/cjs/domain/rumEventsCollection/error/errorCollection.js +13 -5
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js +45 -0
- package/cjs/domain/rumEventsCollection/view/trackViewMetrics.js +1 -19
- package/cjs/domain/rumEventsCollection/view/trackViews.js +21 -18
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +12 -9
- package/cjs/domain/rumSessionManager.js +6 -3
- package/cjs/domain/tracing/getDocumentTraceId.js +2 -10
- package/cjs/domain/trackEventCounts.js +10 -2
- package/cjs/domain/waitPageActivityEnd.js +5 -1
- package/cjs/transport/startRumBatch.js +5 -7
- package/cjs/types/index.js +18 -0
- package/cjs/types/sessionReplayConstants.js +56 -0
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/recorderApi.js +149 -0
- package/esm/boot/rum.entry.js +4 -1
- package/esm/boot/rum.js +15 -6
- package/esm/boot/rumPublicApi.js +8 -4
- package/esm/boot/startRecording.js +44 -0
- package/esm/constants.js +31 -0
- package/esm/domain/assembly.js +1 -7
- package/esm/domain/configuration.js +4 -3
- package/esm/domain/contexts/foregroundContexts.js +122 -0
- package/esm/domain/contexts/internalContext.js +1 -1
- package/esm/domain/contexts/urlContexts.js +10 -3
- package/esm/domain/domMutationCollection.js +5 -6
- package/esm/domain/initViewportObservable.js +39 -0
- package/esm/domain/locationChangeObservable.js +13 -27
- package/esm/domain/performanceCollection.js +1 -12
- package/esm/domain/replay/record/elementsScrollPositions.js +20 -0
- package/esm/domain/replay/record/index.js +3 -0
- package/esm/domain/replay/record/mutationBatch.js +35 -0
- package/esm/domain/replay/record/mutationObserver.js +331 -0
- package/esm/domain/replay/record/observers.js +457 -0
- package/esm/domain/replay/record/privacy.js +233 -0
- package/esm/domain/replay/record/record.js +158 -0
- package/esm/domain/replay/record/serializationUtils.js +107 -0
- package/esm/domain/replay/record/serialize.js +461 -0
- package/esm/domain/replay/record/shadowRootsController.js +49 -0
- package/esm/domain/replay/record/utils.js +38 -0
- package/esm/domain/replay/record/viewports.js +87 -0
- package/esm/domain/replay/replayStats.js +64 -0
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js +31 -0
- package/esm/domain/replay/segmentCollection/deflateWorker.js +4390 -0
- package/esm/domain/replay/segmentCollection/index.js +3 -0
- package/esm/domain/replay/segmentCollection/segment.js +84 -0
- package/esm/domain/replay/segmentCollection/segmentCollection.js +158 -0
- package/esm/domain/replay/segmentCollection/startDeflateWorker.js +113 -0
- package/esm/domain/requestCollection.js +36 -18
- package/esm/domain/rumEventsCollection/actions/actionCollection.js +12 -4
- package/esm/domain/rumEventsCollection/actions/clickChain.js +3 -3
- package/esm/domain/rumEventsCollection/actions/computeFrustration.js +6 -5
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +6 -6
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +105 -74
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +22 -28
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +99 -59
- package/esm/domain/rumEventsCollection/error/errorCollection.js +13 -5
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js +33 -0
- package/esm/domain/rumEventsCollection/view/trackViewMetrics.js +1 -18
- package/esm/domain/rumEventsCollection/view/trackViews.js +21 -19
- package/esm/domain/rumEventsCollection/view/viewCollection.js +12 -9
- package/esm/domain/rumSessionManager.js +6 -3
- package/esm/domain/tracing/getDocumentTraceId.js +1 -9
- package/esm/domain/trackEventCounts.js +10 -2
- package/esm/domain/waitPageActivityEnd.js +5 -1
- package/esm/transport/startRumBatch.js +5 -7
- package/esm/types/index.js +1 -0
- package/esm/types/sessionReplayConstants.js +45 -0
- package/package.json +3 -3
- package/src/boot/recorderApi.js +166 -0
- package/src/boot/rum.entry.js +4 -1
- package/src/boot/rum.js +38 -10
- package/src/boot/rumPublicApi.js +13 -3
- package/src/boot/startRecording.js +77 -0
- package/src/constants.js +37 -0
- package/src/domain/assembly.js +1 -6
- package/src/domain/configuration.js +10 -2
- package/src/domain/contexts/foregroundContexts.js +140 -0
- package/src/domain/contexts/internalContext.js +10 -4
- package/src/domain/contexts/urlContexts.js +29 -15
- package/src/domain/domMutationCollection.js +14 -6
- package/src/domain/initViewportObservable.js +46 -0
- package/src/domain/locationChangeObservable.js +17 -25
- package/src/domain/performanceCollection.js +42 -42
- package/src/domain/replay/record/elementsScrollPositions.js +22 -0
- package/src/domain/replay/record/index.js +7 -0
- package/src/domain/replay/record/mutationBatch.js +38 -0
- package/src/domain/replay/record/mutationObserver.js +393 -0
- package/src/domain/replay/record/observers.js +562 -0
- package/src/domain/replay/record/privacy.js +304 -0
- package/src/domain/replay/record/record.js +158 -0
- package/src/domain/replay/record/serializationUtils.js +134 -0
- package/src/domain/replay/record/serialize.js +497 -0
- package/src/domain/replay/record/shadowRootsController.js +58 -0
- package/src/domain/replay/record/utils.js +44 -0
- package/src/domain/replay/record/viewports.js +89 -0
- package/src/domain/replay/replayStats.js +67 -0
- package/src/domain/replay/segmentCollection/buildReplayPayload.js +34 -0
- package/src/domain/replay/segmentCollection/deflateWorker.js +4577 -0
- package/src/domain/replay/segmentCollection/index.js +6 -0
- package/src/domain/replay/segmentCollection/segment.js +87 -0
- package/src/domain/replay/segmentCollection/segmentCollection.js +205 -0
- package/src/domain/replay/segmentCollection/startDeflateWorker.js +101 -0
- package/src/domain/requestCollection.js +64 -28
- package/src/domain/rumEventsCollection/actions/actionCollection.js +11 -4
- package/src/domain/rumEventsCollection/actions/clickChain.js +3 -3
- package/src/domain/rumEventsCollection/actions/computeFrustration.js +7 -4
- package/src/domain/rumEventsCollection/actions/getActionNameFromElement.js +9 -6
- package/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +130 -108
- package/src/domain/rumEventsCollection/actions/listenActionEvents.js +26 -27
- package/src/domain/rumEventsCollection/actions/trackClickActions.js +162 -92
- package/src/domain/rumEventsCollection/error/errorCollection.js +11 -5
- package/src/domain/rumEventsCollection/view/trackViewEventCounts.js +38 -0
- package/src/domain/rumEventsCollection/view/trackViewMetrics.js +1 -19
- package/src/domain/rumEventsCollection/view/trackViews.js +98 -68
- package/src/domain/rumEventsCollection/view/viewCollection.js +15 -7
- package/src/domain/rumSessionManager.js +33 -19
- package/src/domain/tracing/getDocumentTraceId.js +6 -9
- package/src/domain/trackEventCounts.js +10 -4
- package/src/domain/waitPageActivityEnd.js +4 -1
- package/src/transport/startRumBatch.js +29 -24
- package/src/types/index.js +1 -0
- package/src/types/sessionReplayConstants.js +49 -0
|
@@ -10,16 +10,18 @@ import {
|
|
|
10
10
|
timeStampNow,
|
|
11
11
|
looksLikeRelativeTime,
|
|
12
12
|
ViewLoadingType,
|
|
13
|
-
LifeCycleEventType
|
|
13
|
+
LifeCycleEventType,
|
|
14
|
+
PageExitReason,
|
|
15
|
+
isHashAnAnchor,
|
|
16
|
+
getPathFromHash
|
|
14
17
|
} from '@cloudcare/browser-core'
|
|
15
18
|
|
|
16
19
|
import { trackInitialViewTimings } from './trackInitialViewTimings'
|
|
17
20
|
import { trackViewMetrics } from './trackViewMetrics'
|
|
18
|
-
|
|
21
|
+
import { trackViewEventCounts } from './trackViewEventCounts'
|
|
19
22
|
export var THROTTLE_VIEW_UPDATE_PERIOD = 3000
|
|
20
23
|
export var SESSION_KEEP_ALIVE_INTERVAL = 5 * ONE_MINUTE
|
|
21
24
|
|
|
22
|
-
|
|
23
25
|
export function trackViews(
|
|
24
26
|
location,
|
|
25
27
|
lifeCycle,
|
|
@@ -34,11 +36,13 @@ export function trackViews(
|
|
|
34
36
|
var initialView = _trackInitialView.initialView
|
|
35
37
|
var currentView = initialView
|
|
36
38
|
|
|
37
|
-
var _startViewLifeCycle= startViewLifeCycle()
|
|
39
|
+
var _startViewLifeCycle = startViewLifeCycle()
|
|
38
40
|
var stopViewLifeCycle = _startViewLifeCycle.stop
|
|
39
41
|
var locationChangeSubscription
|
|
40
42
|
if (areViewsTrackedAutomatically) {
|
|
41
|
-
locationChangeSubscription = renewViewOnLocationChange(
|
|
43
|
+
locationChangeSubscription = renewViewOnLocationChange(
|
|
44
|
+
locationChangeObservable
|
|
45
|
+
)
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
function trackInitialView(options) {
|
|
@@ -51,10 +55,13 @@ export function trackViews(
|
|
|
51
55
|
clocksOrigin(),
|
|
52
56
|
options
|
|
53
57
|
)
|
|
54
|
-
var _trackInitialViewTimings = trackInitialViewTimings(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
var _trackInitialViewTimings = trackInitialViewTimings(
|
|
59
|
+
lifeCycle,
|
|
60
|
+
function (timings) {
|
|
61
|
+
initialView.updateTimings(timings)
|
|
62
|
+
initialView.scheduleUpdate()
|
|
63
|
+
}
|
|
64
|
+
)
|
|
58
65
|
return { initialView: initialView, stop: _trackInitialViewTimings.stop }
|
|
59
66
|
}
|
|
60
67
|
|
|
@@ -71,40 +78,44 @@ export function trackViews(
|
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
function startViewLifeCycle() {
|
|
74
|
-
lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function() {
|
|
81
|
+
lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function () {
|
|
75
82
|
// do not trigger view update to avoid wrong data
|
|
76
83
|
currentView.end()
|
|
77
84
|
// Renew view on session renewal
|
|
78
85
|
currentView = trackViewChange(undefined, {
|
|
79
86
|
name: currentView.name,
|
|
80
87
|
service: currentView.service,
|
|
81
|
-
version: currentView.version
|
|
88
|
+
version: currentView.version
|
|
82
89
|
})
|
|
83
90
|
})
|
|
84
91
|
|
|
85
92
|
// End the current view on page unload
|
|
86
|
-
lifeCycle.subscribe(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
lifeCycle.subscribe(
|
|
94
|
+
LifeCycleEventType.PAGE_EXITED,
|
|
95
|
+
function (pageExitEvent) {
|
|
96
|
+
if (
|
|
97
|
+
pageExitEvent.reason === PageExitReason.UNLOADING ||
|
|
98
|
+
pageExitEvent.reason === PageExitReason.PAGEHIDE
|
|
99
|
+
) {
|
|
100
|
+
currentView.end()
|
|
101
|
+
currentView.triggerUpdate()
|
|
102
|
+
}
|
|
103
|
+
}
|
|
97
104
|
)
|
|
105
|
+
// Session keep alive
|
|
106
|
+
var keepAliveInterval = window.setInterval(function () {
|
|
107
|
+
currentView.triggerUpdate()
|
|
108
|
+
}, SESSION_KEEP_ALIVE_INTERVAL)
|
|
98
109
|
|
|
99
110
|
return {
|
|
100
|
-
stop: function() {
|
|
111
|
+
stop: function () {
|
|
101
112
|
clearInterval(keepAliveInterval)
|
|
102
|
-
}
|
|
113
|
+
}
|
|
103
114
|
}
|
|
104
115
|
}
|
|
105
116
|
|
|
106
117
|
function renewViewOnLocationChange(locationChangeObservable) {
|
|
107
|
-
return locationChangeObservable.subscribe(function (params){
|
|
118
|
+
return locationChangeObservable.subscribe(function (params) {
|
|
108
119
|
var oldLocation = params.oldLocation
|
|
109
120
|
var newLocation = params.newLocation
|
|
110
121
|
if (areDifferentLocation(oldLocation, newLocation)) {
|
|
@@ -117,26 +128,26 @@ export function trackViews(
|
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
return {
|
|
120
|
-
addTiming: function(name, time) {
|
|
131
|
+
addTiming: function (name, time) {
|
|
121
132
|
if (typeof time === 'undefined') {
|
|
122
133
|
time = timeStampNow()
|
|
123
134
|
}
|
|
124
135
|
currentView.addTiming(name, time)
|
|
125
136
|
currentView.scheduleUpdate()
|
|
126
137
|
},
|
|
127
|
-
startView: function(options, startClocks){
|
|
138
|
+
startView: function (options, startClocks) {
|
|
128
139
|
currentView.end(startClocks)
|
|
129
140
|
currentView.triggerUpdate()
|
|
130
141
|
currentView = trackViewChange(startClocks, options)
|
|
131
142
|
},
|
|
132
|
-
stop: function(){
|
|
143
|
+
stop: function () {
|
|
133
144
|
if (locationChangeSubscription) {
|
|
134
145
|
locationChangeSubscription.unsubscribe()
|
|
135
146
|
}
|
|
136
147
|
stopInitialViewTracking()
|
|
137
148
|
stopViewLifeCycle()
|
|
138
149
|
currentView.end()
|
|
139
|
-
}
|
|
150
|
+
}
|
|
140
151
|
}
|
|
141
152
|
}
|
|
142
153
|
|
|
@@ -169,44 +180,67 @@ function newView(
|
|
|
169
180
|
version = viewOptions.version
|
|
170
181
|
}
|
|
171
182
|
|
|
172
|
-
lifeCycle.notify(LifeCycleEventType.VIEW_CREATED, {
|
|
183
|
+
lifeCycle.notify(LifeCycleEventType.VIEW_CREATED, {
|
|
184
|
+
id: id,
|
|
185
|
+
name: name,
|
|
186
|
+
startClocks: startClocks,
|
|
187
|
+
service: service,
|
|
188
|
+
version: version
|
|
189
|
+
})
|
|
173
190
|
|
|
174
191
|
// Update the view every time the measures are changing
|
|
175
|
-
var
|
|
192
|
+
var _scheduleViewUpdate = throttle(
|
|
176
193
|
triggerViewUpdate,
|
|
177
194
|
THROTTLE_VIEW_UPDATE_PERIOD,
|
|
178
195
|
{
|
|
179
|
-
leading: false
|
|
196
|
+
leading: false
|
|
180
197
|
}
|
|
181
198
|
)
|
|
182
|
-
var
|
|
183
|
-
|
|
184
|
-
|
|
199
|
+
var scheduleViewUpdate = _scheduleViewUpdate.throttled
|
|
200
|
+
var cancelScheduleViewUpdate = _scheduleViewUpdate.cancel
|
|
201
|
+
|
|
202
|
+
var _trackViewMetrics = trackViewMetrics(
|
|
203
|
+
lifeCycle,
|
|
204
|
+
domMutationObservable,
|
|
205
|
+
configuration,
|
|
206
|
+
scheduleViewUpdate,
|
|
207
|
+
loadingType,
|
|
208
|
+
startClocks
|
|
209
|
+
)
|
|
185
210
|
var setLoadEvent = _trackViewMetrics.setLoadEvent
|
|
186
211
|
var stopViewMetricsTracking = _trackViewMetrics.stop
|
|
187
212
|
var viewMetrics = _trackViewMetrics.viewMetrics
|
|
213
|
+
var _trackViewEventCounts = trackViewEventCounts(
|
|
214
|
+
lifeCycle,
|
|
215
|
+
id,
|
|
216
|
+
scheduleViewUpdate
|
|
217
|
+
)
|
|
218
|
+
var scheduleStopEventCountsTracking = _trackViewEventCounts.scheduleStop
|
|
219
|
+
var eventCounts = _trackViewEventCounts.eventCounts
|
|
188
220
|
// Initial view update
|
|
189
221
|
triggerViewUpdate()
|
|
190
222
|
|
|
191
223
|
function triggerViewUpdate() {
|
|
192
224
|
documentVersion += 1
|
|
193
|
-
var currentEnd =
|
|
225
|
+
var currentEnd =
|
|
226
|
+
endClocks === undefined ? timeStampNow() : endClocks.timeStamp
|
|
194
227
|
lifeCycle.notify(
|
|
195
228
|
LifeCycleEventType.VIEW_UPDATED,
|
|
196
229
|
assign(
|
|
197
230
|
{
|
|
198
|
-
customTimings:customTimings,
|
|
199
|
-
documentVersion:documentVersion,
|
|
200
|
-
id:id,
|
|
201
|
-
name:name,
|
|
202
|
-
service:service,
|
|
203
|
-
version:version,
|
|
204
|
-
loadingType:loadingType,
|
|
205
|
-
location:location,
|
|
206
|
-
startClocks:startClocks,
|
|
207
|
-
timings:timings,
|
|
231
|
+
customTimings: customTimings,
|
|
232
|
+
documentVersion: documentVersion,
|
|
233
|
+
id: id,
|
|
234
|
+
name: name,
|
|
235
|
+
service: service,
|
|
236
|
+
version: version,
|
|
237
|
+
loadingType: loadingType,
|
|
238
|
+
location: location,
|
|
239
|
+
startClocks: startClocks,
|
|
240
|
+
timings: timings,
|
|
208
241
|
duration: elapsed(startClocks.timeStamp, currentEnd),
|
|
209
242
|
isActive: endClocks === undefined,
|
|
243
|
+
eventCounts: eventCounts
|
|
210
244
|
},
|
|
211
245
|
viewMetrics
|
|
212
246
|
)
|
|
@@ -214,33 +248,36 @@ function newView(
|
|
|
214
248
|
}
|
|
215
249
|
|
|
216
250
|
return {
|
|
217
|
-
name:name,
|
|
218
|
-
service:service,
|
|
219
|
-
version:version,
|
|
251
|
+
name: name,
|
|
252
|
+
service: service,
|
|
253
|
+
version: version,
|
|
220
254
|
scheduleUpdate: scheduleViewUpdate,
|
|
221
|
-
end: function(clocks) {
|
|
255
|
+
end: function (clocks) {
|
|
222
256
|
if (typeof clocks === 'undefined') {
|
|
223
257
|
clocks = clocksNow()
|
|
224
258
|
}
|
|
225
259
|
endClocks = clocks
|
|
226
|
-
lifeCycle.notify(LifeCycleEventType.VIEW_ENDED, { endClocks })
|
|
260
|
+
lifeCycle.notify(LifeCycleEventType.VIEW_ENDED, { endClocks: endClocks })
|
|
227
261
|
stopViewMetricsTracking()
|
|
262
|
+
scheduleStopEventCountsTracking
|
|
228
263
|
},
|
|
229
|
-
triggerUpdate: function() {
|
|
264
|
+
triggerUpdate: function () {
|
|
230
265
|
// cancel any pending view updates execution
|
|
231
266
|
cancelScheduleViewUpdate()
|
|
232
267
|
triggerViewUpdate()
|
|
233
268
|
},
|
|
234
|
-
updateTimings: function(newTimings) {
|
|
269
|
+
updateTimings: function (newTimings) {
|
|
235
270
|
timings = newTimings
|
|
236
271
|
if (newTimings.loadEvent !== undefined) {
|
|
237
272
|
setLoadEvent(newTimings.loadEvent)
|
|
238
273
|
}
|
|
239
274
|
},
|
|
240
|
-
addTiming: function(name, time) {
|
|
241
|
-
var relativeTime = looksLikeRelativeTime(time)
|
|
275
|
+
addTiming: function (name, time) {
|
|
276
|
+
var relativeTime = looksLikeRelativeTime(time)
|
|
277
|
+
? time
|
|
278
|
+
: elapsed(startClocks.timeStamp, time)
|
|
242
279
|
customTimings[sanitizeTiming(name)] = relativeTime
|
|
243
|
-
}
|
|
280
|
+
}
|
|
244
281
|
}
|
|
245
282
|
}
|
|
246
283
|
|
|
@@ -250,7 +287,9 @@ function newView(
|
|
|
250
287
|
function sanitizeTiming(name) {
|
|
251
288
|
var sanitized = name.replace(/[^a-zA-Z0-9-_.@$]/g, '_')
|
|
252
289
|
if (sanitized !== name) {
|
|
253
|
-
console.warn(
|
|
290
|
+
console.warn(
|
|
291
|
+
'Invalid timing name: ' + name + ', sanitized to: ' + sanitized
|
|
292
|
+
)
|
|
254
293
|
}
|
|
255
294
|
return sanitized
|
|
256
295
|
}
|
|
@@ -259,16 +298,7 @@ function areDifferentLocation(currentLocation, otherLocation) {
|
|
|
259
298
|
return (
|
|
260
299
|
currentLocation.pathname !== otherLocation.pathname ||
|
|
261
300
|
(!isHashAnAnchor(otherLocation.hash) &&
|
|
262
|
-
getPathFromHash(otherLocation.hash) !==
|
|
301
|
+
getPathFromHash(otherLocation.hash) !==
|
|
302
|
+
getPathFromHash(currentLocation.hash))
|
|
263
303
|
)
|
|
264
304
|
}
|
|
265
|
-
|
|
266
|
-
function isHashAnAnchor(hash) {
|
|
267
|
-
var correspondingId = hash.substr(1)
|
|
268
|
-
return !!document.getElementById(correspondingId)
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function getPathFromHash(hash) {
|
|
272
|
-
var index = hash.indexOf('?')
|
|
273
|
-
return index < 0 ? hash : hash.slice(0, index)
|
|
274
|
-
}
|
|
@@ -15,12 +15,14 @@ export function startViewCollection(
|
|
|
15
15
|
location,
|
|
16
16
|
domMutationObservable,
|
|
17
17
|
locationChangeObservable,
|
|
18
|
+
foregroundContexts,
|
|
19
|
+
recorderApi,
|
|
18
20
|
initialViewOptions
|
|
19
21
|
) {
|
|
20
22
|
lifeCycle.subscribe(LifeCycleEventType.VIEW_UPDATED, function (view) {
|
|
21
23
|
lifeCycle.notify(
|
|
22
24
|
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,
|
|
23
|
-
processViewUpdate(view)
|
|
25
|
+
processViewUpdate(view, foregroundContexts, recorderApi)
|
|
24
26
|
)
|
|
25
27
|
})
|
|
26
28
|
|
|
@@ -75,10 +77,12 @@ function computePerformanceViewDetails(entry) {
|
|
|
75
77
|
}
|
|
76
78
|
return details
|
|
77
79
|
}
|
|
78
|
-
function processViewUpdate(view) {
|
|
80
|
+
function processViewUpdate(view, foregroundContexts, recorderApi) {
|
|
81
|
+
var replayStats = recorderApi.getReplayStats(view.id)
|
|
79
82
|
var viewEvent = {
|
|
80
83
|
_dd: {
|
|
81
|
-
document_version: view.documentVersion
|
|
84
|
+
document_version: view.documentVersion,
|
|
85
|
+
replay_stats: replayStats
|
|
82
86
|
},
|
|
83
87
|
date: view.startClocks.timeStamp,
|
|
84
88
|
type: RumEventType.VIEW,
|
|
@@ -116,11 +120,15 @@ function processViewUpdate(view) {
|
|
|
116
120
|
resource: {
|
|
117
121
|
count: view.eventCounts.resourceCount
|
|
118
122
|
},
|
|
119
|
-
time_spent: toServerDuration(view.duration)
|
|
123
|
+
time_spent: toServerDuration(view.duration),
|
|
124
|
+
in_foreground_periods: foregroundContexts.selectInForegroundPeriodsFor(
|
|
125
|
+
view.startClocks.relative,
|
|
126
|
+
view.duration
|
|
127
|
+
)
|
|
128
|
+
},
|
|
129
|
+
session: {
|
|
130
|
+
has_replay: replayStats ? true : undefined
|
|
120
131
|
}
|
|
121
|
-
// session: {
|
|
122
|
-
// has_replay: replayStats ? true : undefined,
|
|
123
|
-
// },
|
|
124
132
|
}
|
|
125
133
|
if (!isEmptyObject(view.customTimings)) {
|
|
126
134
|
viewEvent.view.custom_timings = mapValues(
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
performDraw,
|
|
3
|
+
startSessionManager,
|
|
4
|
+
LifeCycleEventType
|
|
5
|
+
} from '@cloudcare/browser-core'
|
|
2
6
|
|
|
3
7
|
export var RUM_SESSION_KEY = 'rum'
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
PREMIUM: 2,
|
|
9
|
+
export var RumSessionPlan = {
|
|
10
|
+
WITHOUT_SESSION_REPLAY: 1,
|
|
11
|
+
WITH_SESSION_REPLAY: 2
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
export var
|
|
12
|
-
NOT_TRACKED
|
|
14
|
+
export var RumTrackingType = {
|
|
15
|
+
NOT_TRACKED: '0',
|
|
13
16
|
// Note: the "tracking type" value (stored in the session cookie) does not match the "session
|
|
14
17
|
// plan" value (sent in RUM events). This is expected, and was done to keep retrocompatibility
|
|
15
18
|
// with active sessions when upgrading the SDK.
|
|
16
|
-
TRACKED_WITH_SESSION_REPLAY:
|
|
17
|
-
TRACKED_WITHOUT_SESSION_REPLAY: '2'
|
|
19
|
+
TRACKED_WITH_SESSION_REPLAY: '1',
|
|
20
|
+
TRACKED_WITHOUT_SESSION_REPLAY: '2'
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
export function startRumSessionManager(configuration, lifeCycle) {
|
|
21
|
-
var sessionManager = startSessionManager(
|
|
24
|
+
var sessionManager = startSessionManager(
|
|
25
|
+
configuration.cookieOptions,
|
|
26
|
+
RUM_SESSION_KEY,
|
|
27
|
+
function (rawTrackingType) {
|
|
22
28
|
return computeSessionState(configuration, rawTrackingType)
|
|
23
29
|
}
|
|
24
30
|
)
|
|
25
31
|
|
|
26
|
-
sessionManager.expireObservable.subscribe(function() {
|
|
32
|
+
sessionManager.expireObservable.subscribe(function () {
|
|
27
33
|
lifeCycle.notify(LifeCycleEventType.SESSION_EXPIRED)
|
|
28
34
|
})
|
|
29
35
|
|
|
@@ -32,15 +38,21 @@ export function startRumSessionManager(configuration, lifeCycle) {
|
|
|
32
38
|
})
|
|
33
39
|
|
|
34
40
|
return {
|
|
35
|
-
findTrackedSession: function(startTime) {
|
|
41
|
+
findTrackedSession: function (startTime) {
|
|
36
42
|
var session = sessionManager.findActiveSession(startTime)
|
|
37
43
|
if (!session || !isTypeTracked(session.trackingType)) {
|
|
38
44
|
return
|
|
39
45
|
}
|
|
46
|
+
var plan =
|
|
47
|
+
session.trackingType === RumTrackingType.TRACKED_WITH_SESSION_REPLAY
|
|
48
|
+
? RumSessionPlan.WITH_SESSION_REPLAY
|
|
49
|
+
: RumSessionPlan.WITHOUT_SESSION_REPLAY
|
|
40
50
|
return {
|
|
41
51
|
id: session.id,
|
|
52
|
+
plan: plan,
|
|
53
|
+
sessionReplayAllowed: plan === RumSessionPlan.WITH_SESSION_REPLAY
|
|
42
54
|
}
|
|
43
|
-
}
|
|
55
|
+
}
|
|
44
56
|
}
|
|
45
57
|
}
|
|
46
58
|
|
|
@@ -50,12 +62,12 @@ export function startRumSessionManager(configuration, lifeCycle) {
|
|
|
50
62
|
*/
|
|
51
63
|
export function startRumSessionManagerStub() {
|
|
52
64
|
var session = {
|
|
53
|
-
id: '00000000-aaaa-0000-aaaa-000000000000'
|
|
65
|
+
id: '00000000-aaaa-0000-aaaa-000000000000'
|
|
54
66
|
}
|
|
55
67
|
return {
|
|
56
|
-
findTrackedSession: function() {
|
|
68
|
+
findTrackedSession: function () {
|
|
57
69
|
return session
|
|
58
|
-
}
|
|
70
|
+
}
|
|
59
71
|
}
|
|
60
72
|
}
|
|
61
73
|
|
|
@@ -72,7 +84,7 @@ function computeSessionState(configuration, rawTrackingType) {
|
|
|
72
84
|
}
|
|
73
85
|
return {
|
|
74
86
|
trackingType: trackingType,
|
|
75
|
-
isTracked: isTypeTracked(trackingType)
|
|
87
|
+
isTracked: isTypeTracked(trackingType)
|
|
76
88
|
}
|
|
77
89
|
}
|
|
78
90
|
|
|
@@ -85,6 +97,8 @@ function hasValidRumSession(trackingType) {
|
|
|
85
97
|
}
|
|
86
98
|
|
|
87
99
|
function isTypeTracked(rumSessionType) {
|
|
88
|
-
return
|
|
89
|
-
|
|
100
|
+
return (
|
|
101
|
+
rumSessionType === RumTrackingType.TRACKED_WITHOUT_SESSION_REPLAY ||
|
|
102
|
+
rumSessionType === RumTrackingType.TRACKED_WITH_SESSION_REPLAY
|
|
103
|
+
)
|
|
90
104
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
findCommaSeparatedValue,
|
|
3
|
+
ONE_MINUTE,
|
|
4
|
+
isCommentNode,
|
|
5
|
+
isTextNode
|
|
6
|
+
} from '@cloudcare/browser-core'
|
|
2
7
|
|
|
3
8
|
export var INITIAL_DOCUMENT_OUTDATED_TRACE_ID_THRESHOLD = 2 * ONE_MINUTE
|
|
4
9
|
|
|
@@ -87,11 +92,3 @@ function getTraceCommentFromNode(node) {
|
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
|
-
|
|
91
|
-
function isCommentNode() {
|
|
92
|
-
return node.nodeName === '#comment'
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function isTextNode(node) {
|
|
96
|
-
return node.nodeName === '#text'
|
|
97
|
-
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { noop, RumEventType, LifeCycleEventType } from '@cloudcare/browser-core'
|
|
2
2
|
|
|
3
|
-
export function trackEventCounts(
|
|
4
|
-
|
|
3
|
+
export function trackEventCounts(data) {
|
|
4
|
+
var lifeCycle = data.lifeCycle
|
|
5
|
+
var isChildEvent = data.isChildEvent
|
|
6
|
+
var callback = data.onChange
|
|
7
|
+
if (callback === undefined) {
|
|
5
8
|
callback = noop
|
|
6
9
|
}
|
|
7
10
|
var eventCounts = {
|
|
@@ -9,16 +12,19 @@ export function trackEventCounts(lifeCycle, callback) {
|
|
|
9
12
|
longTaskCount: 0,
|
|
10
13
|
resourceCount: 0,
|
|
11
14
|
actionCount: 0,
|
|
12
|
-
frustrationCount: 0
|
|
15
|
+
frustrationCount: 0
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
var subscription = lifeCycle.subscribe(
|
|
16
19
|
LifeCycleEventType.RUM_EVENT_COLLECTED,
|
|
17
20
|
function (event) {
|
|
21
|
+
if (event.type === RumEventType.VIEW || !isChildEvent(event)) {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
18
24
|
switch (event.type) {
|
|
19
25
|
case RumEventType.ERROR:
|
|
20
26
|
eventCounts.errorCount += 1
|
|
21
|
-
|
|
27
|
+
|
|
22
28
|
callback(eventCounts)
|
|
23
29
|
break
|
|
24
30
|
case RumEventType.ACTION:
|
|
@@ -73,6 +73,7 @@ export function doWaitPageActivityEnd(
|
|
|
73
73
|
var validationTimeoutId = setTimeout(function () {
|
|
74
74
|
complete({ hadActivity: false })
|
|
75
75
|
}, PAGE_ACTIVITY_VALIDATION_DELAY)
|
|
76
|
+
|
|
76
77
|
var maxDurationTimeoutId =
|
|
77
78
|
maxDuration &&
|
|
78
79
|
setTimeout(function () {
|
|
@@ -168,8 +169,10 @@ export function createPageActivityObservable(
|
|
|
168
169
|
)
|
|
169
170
|
)
|
|
170
171
|
|
|
171
|
-
trackWindowOpen(notifyPageActivity)
|
|
172
|
+
var _trackWindowOpen = trackWindowOpen(notifyPageActivity)
|
|
173
|
+
var stopTrackingWindowOpen = _trackWindowOpen.stop
|
|
172
174
|
return function () {
|
|
175
|
+
stopTrackingWindowOpen()
|
|
173
176
|
each(subscriptions, function (s) {
|
|
174
177
|
s.unsubscribe()
|
|
175
178
|
})
|
|
@@ -1,48 +1,53 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Batch,
|
|
3
|
+
createHttpRequest,
|
|
4
|
+
LifeCycleEventType,
|
|
5
|
+
RumEventType
|
|
6
|
+
} from '@cloudcare/browser-core'
|
|
2
7
|
|
|
3
8
|
export function startRumBatch(
|
|
4
9
|
configuration,
|
|
5
10
|
lifeCycle,
|
|
6
|
-
reportError
|
|
11
|
+
reportError,
|
|
12
|
+
pageExitObservable
|
|
7
13
|
) {
|
|
8
|
-
var batch = makeRumBatch(configuration,
|
|
14
|
+
var batch = makeRumBatch(configuration, reportError, pageExitObservable)
|
|
9
15
|
|
|
10
|
-
lifeCycle.subscribe(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
lifeCycle.subscribe(
|
|
17
|
+
LifeCycleEventType.RUM_EVENT_COLLECTED,
|
|
18
|
+
function (serverRumEvent) {
|
|
19
|
+
if (serverRumEvent.type === RumEventType.VIEW) {
|
|
20
|
+
batch.upsert(serverRumEvent, serverRumEvent.view.id)
|
|
21
|
+
} else {
|
|
22
|
+
batch.add(serverRumEvent)
|
|
23
|
+
}
|
|
15
24
|
}
|
|
16
|
-
|
|
25
|
+
)
|
|
17
26
|
}
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function makeRumBatch(
|
|
22
|
-
configuration,
|
|
23
|
-
lifeCycle,
|
|
24
|
-
reportError
|
|
25
|
-
) {
|
|
26
|
-
var primaryBatch = createRumBatch(configuration.datakitUrl, function() {
|
|
27
|
-
lifeCycle.notify(LifeCycleEventType.BEFORE_UNLOAD)
|
|
28
|
-
})
|
|
28
|
+
function makeRumBatch(configuration, reportError, pageExitObservable) {
|
|
29
|
+
var primaryBatch = createRumBatch(configuration.datakitUrl)
|
|
29
30
|
function createRumBatch(endpointUrl, unloadCallback) {
|
|
30
31
|
return new Batch(
|
|
31
|
-
createHttpRequest(
|
|
32
|
+
createHttpRequest(
|
|
33
|
+
endpointUrl,
|
|
34
|
+
configuration.batchBytesLimit,
|
|
35
|
+
reportError
|
|
36
|
+
),
|
|
32
37
|
configuration.batchMessagesLimit,
|
|
33
38
|
configuration.batchBytesLimit,
|
|
34
39
|
configuration.messageBytesLimit,
|
|
35
40
|
configuration.flushTimeout,
|
|
36
|
-
|
|
41
|
+
pageExitObservable
|
|
37
42
|
)
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
return {
|
|
41
|
-
add: function(message){
|
|
46
|
+
add: function (message) {
|
|
42
47
|
primaryBatch.add(message)
|
|
43
48
|
},
|
|
44
|
-
upsert: function(message, key){
|
|
49
|
+
upsert: function (message, key) {
|
|
45
50
|
primaryBatch.upsert(message, key)
|
|
46
|
-
}
|
|
51
|
+
}
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sessionReplayConstants'
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export var RecordType = {
|
|
2
|
+
FullSnapshot: 2,
|
|
3
|
+
IncrementalSnapshot: 3,
|
|
4
|
+
Meta: 4,
|
|
5
|
+
Focus: 6,
|
|
6
|
+
ViewEnd: 7,
|
|
7
|
+
VisualViewport: 8,
|
|
8
|
+
FrustrationRecord: 9
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export var NodeType = {
|
|
12
|
+
Document: 0,
|
|
13
|
+
DocumentType: 1,
|
|
14
|
+
Element: 2,
|
|
15
|
+
Text: 3,
|
|
16
|
+
CDATA: 4,
|
|
17
|
+
DocumentFragment: 11
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export var IncrementalSource = {
|
|
21
|
+
Mutation: 0,
|
|
22
|
+
MouseMove: 1,
|
|
23
|
+
MouseInteraction: 2,
|
|
24
|
+
Scroll: 3,
|
|
25
|
+
ViewportResize: 4,
|
|
26
|
+
Input: 5,
|
|
27
|
+
TouchMove: 6,
|
|
28
|
+
MediaInteraction: 7,
|
|
29
|
+
StyleSheetRule: 8
|
|
30
|
+
// CanvasMutation : 9,
|
|
31
|
+
// Font : 10,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export var MouseInteractionType = {
|
|
35
|
+
MouseUp: 0,
|
|
36
|
+
MouseDown: 1,
|
|
37
|
+
Click: 2,
|
|
38
|
+
ContextMenu: 3,
|
|
39
|
+
DblClick: 4,
|
|
40
|
+
Focus: 5,
|
|
41
|
+
Blur: 6,
|
|
42
|
+
TouchStart: 7,
|
|
43
|
+
TouchEnd: 9
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export var MediaInteractionType = {
|
|
47
|
+
Play: 0,
|
|
48
|
+
Pause: 1
|
|
49
|
+
}
|