@cloudcare/browser-rum 2.2.15 → 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
|
@@ -13,10 +13,15 @@ import {
|
|
|
13
13
|
map,
|
|
14
14
|
LifeCycleEventType,
|
|
15
15
|
ActionType,
|
|
16
|
-
isNullUndefinedDefaultValue
|
|
16
|
+
isNullUndefinedDefaultValue,
|
|
17
|
+
isArray,
|
|
18
|
+
includes
|
|
17
19
|
} from '@cloudcare/browser-core'
|
|
18
20
|
import { trackEventCounts } from '../../trackEventCounts'
|
|
19
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
waitPageActivityEnd,
|
|
23
|
+
PAGE_ACTIVITY_VALIDATION_DELAY
|
|
24
|
+
} from '../../waitPageActivityEnd'
|
|
20
25
|
import { createClickChain } from './clickChain'
|
|
21
26
|
import { getActionNameFromElement } from './getActionNameFromElement'
|
|
22
27
|
// import { getSelectorsFromElement } from './getSelectorsFromElement'
|
|
@@ -39,23 +44,29 @@ export function trackClickActions(
|
|
|
39
44
|
lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function () {
|
|
40
45
|
history.reset()
|
|
41
46
|
})
|
|
42
|
-
lifeCycle.subscribe(LifeCycleEventType.BEFORE_UNLOAD, stopClickChain)
|
|
43
47
|
lifeCycle.subscribe(LifeCycleEventType.VIEW_ENDED, stopClickChain)
|
|
44
48
|
var _listenActionEvents = listenActionEvents({
|
|
45
49
|
onPointerDown: function (pointerDownEvent) {
|
|
46
|
-
return processPointerDown(
|
|
50
|
+
return processPointerDown(
|
|
51
|
+
configuration,
|
|
52
|
+
lifeCycle,
|
|
53
|
+
domMutationObservable,
|
|
54
|
+
history,
|
|
55
|
+
pointerDownEvent
|
|
56
|
+
)
|
|
47
57
|
},
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
onPointerUp: function (data, startEvent, getUserActivity) {
|
|
59
|
+
startClickAction(
|
|
50
60
|
configuration,
|
|
51
61
|
lifeCycle,
|
|
52
62
|
domMutationObservable,
|
|
53
63
|
history,
|
|
54
64
|
stopObservable,
|
|
55
65
|
appendClickToClickChain,
|
|
56
|
-
clickActionBase,
|
|
57
|
-
|
|
58
|
-
getUserActivity
|
|
66
|
+
data.clickActionBase,
|
|
67
|
+
startEvent,
|
|
68
|
+
getUserActivity,
|
|
69
|
+
data.hadActivityOnPointerDown
|
|
59
70
|
)
|
|
60
71
|
}
|
|
61
72
|
})
|
|
@@ -90,86 +101,130 @@ export function trackClickActions(
|
|
|
90
101
|
})
|
|
91
102
|
}
|
|
92
103
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
}
|
|
105
|
+
function processPointerDown(
|
|
106
|
+
configuration,
|
|
107
|
+
lifeCycle,
|
|
108
|
+
domMutationObservable,
|
|
109
|
+
history,
|
|
110
|
+
pointerDownEvent
|
|
111
|
+
) {
|
|
112
|
+
if (!configuration.trackFrustrations && history.find()) {
|
|
113
|
+
// TODO: remove this in a future major version. To keep retrocompatibility, ignore any new
|
|
114
|
+
// action if another one is already occurring.
|
|
115
|
+
return
|
|
99
116
|
}
|
|
100
|
-
|
|
101
|
-
|
|
117
|
+
|
|
118
|
+
var clickActionBase = computeClickActionBase(
|
|
119
|
+
pointerDownEvent,
|
|
120
|
+
configuration.actionNameAttribute
|
|
121
|
+
)
|
|
122
|
+
if (!configuration.trackFrustrations && !clickActionBase.name) {
|
|
123
|
+
// TODO: remove this in a future major version. To keep retrocompatibility, ignore any action
|
|
124
|
+
// with a blank name
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
var hadActivityOnPointerDown = false
|
|
129
|
+
|
|
130
|
+
waitPageActivityEnd(
|
|
102
131
|
lifeCycle,
|
|
103
132
|
domMutationObservable,
|
|
133
|
+
configuration,
|
|
134
|
+
function (pageActivityEndEvent) {
|
|
135
|
+
hadActivityOnPointerDown = pageActivityEndEvent.hadActivity
|
|
136
|
+
},
|
|
137
|
+
// We don't care about the activity duration, we just want to know whether an activity did happen
|
|
138
|
+
// within the "validation delay" or not. Limit the duration so the callback is called sooner.
|
|
139
|
+
PAGE_ACTIVITY_VALIDATION_DELAY
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
clickActionBase: clickActionBase,
|
|
144
|
+
hadActivityOnPointerDown: function () {
|
|
145
|
+
return hadActivityOnPointerDown
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function startClickAction(
|
|
150
|
+
configuration,
|
|
151
|
+
lifeCycle,
|
|
152
|
+
domMutationObservable,
|
|
153
|
+
history,
|
|
154
|
+
stopObservable,
|
|
155
|
+
appendClickToClickChain,
|
|
156
|
+
clickActionBase,
|
|
157
|
+
startEvent,
|
|
158
|
+
getUserActivity,
|
|
159
|
+
hadActivityOnPointerDown
|
|
160
|
+
) {
|
|
161
|
+
var click = newClick(
|
|
162
|
+
lifeCycle,
|
|
104
163
|
history,
|
|
105
|
-
|
|
106
|
-
appendClickToClickChain,
|
|
164
|
+
getUserActivity,
|
|
107
165
|
clickActionBase,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
) {
|
|
111
|
-
var click = newClick(
|
|
112
|
-
lifeCycle,
|
|
113
|
-
history,
|
|
114
|
-
getUserActivity,
|
|
115
|
-
clickActionBase,
|
|
116
|
-
clickEvent
|
|
117
|
-
)
|
|
118
|
-
if (configuration.trackFrustrations) {
|
|
119
|
-
appendClickToClickChain(click)
|
|
120
|
-
}
|
|
166
|
+
startEvent
|
|
167
|
+
)
|
|
121
168
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
169
|
+
if (configuration.trackFrustrations) {
|
|
170
|
+
appendClickToClickChain(click)
|
|
171
|
+
}
|
|
172
|
+
var _waitPageActivityEnd = waitPageActivityEnd(
|
|
173
|
+
lifeCycle,
|
|
174
|
+
domMutationObservable,
|
|
175
|
+
configuration,
|
|
176
|
+
function (pageActivityEndEvent) {
|
|
177
|
+
if (
|
|
178
|
+
pageActivityEndEvent.hadActivity &&
|
|
179
|
+
pageActivityEndEvent.end < click.startClocks.timeStamp
|
|
180
|
+
) {
|
|
181
|
+
// If the clock is looking weird, just discard the click
|
|
182
|
+
click.discard()
|
|
183
|
+
} else {
|
|
184
|
+
if (pageActivityEndEvent.hadActivity) {
|
|
185
|
+
click.stop(pageActivityEndEvent.end)
|
|
186
|
+
} else if (hadActivityOnPointerDown()) {
|
|
134
187
|
click.stop(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
188
|
+
// using the click start as activity end, so the click will have some activity but its
|
|
189
|
+
// duration will be 0 (as the activity started before the click start)
|
|
190
|
+
click.startClocks.timeStamp
|
|
138
191
|
)
|
|
192
|
+
} else {
|
|
193
|
+
click.stop()
|
|
194
|
+
}
|
|
139
195
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
196
|
+
// Validate or discard the click only if we don't track frustrations. It'll be done when
|
|
197
|
+
// the click chain is finalized.
|
|
198
|
+
if (!configuration.trackFrustrations) {
|
|
199
|
+
if (!pageActivityEndEvent.hadActivity) {
|
|
200
|
+
// If we are not tracking frustrations, we should discard the click to keep backward
|
|
201
|
+
// compatibility.
|
|
202
|
+
click.discard()
|
|
203
|
+
} else {
|
|
204
|
+
click.validate()
|
|
150
205
|
}
|
|
151
206
|
}
|
|
152
|
-
},
|
|
153
|
-
CLICK_ACTION_MAX_DURATION
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
var viewEndedSubscription = lifeCycle.subscribe(
|
|
157
|
-
LifeCycleEventType.VIEW_ENDED,
|
|
158
|
-
function (data) {
|
|
159
|
-
click.stop(data.endClocks.timeStamp)
|
|
160
207
|
}
|
|
161
|
-
|
|
208
|
+
},
|
|
209
|
+
CLICK_ACTION_MAX_DURATION
|
|
210
|
+
)
|
|
211
|
+
var stopWaitPageActivityEnd = _waitPageActivityEnd.stop
|
|
212
|
+
var viewEndedSubscription = lifeCycle.subscribe(
|
|
213
|
+
LifeCycleEventType.VIEW_ENDED,
|
|
214
|
+
function (data) {
|
|
215
|
+
click.stop(data.endClocks.timeStamp)
|
|
216
|
+
}
|
|
217
|
+
)
|
|
162
218
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
219
|
+
var stopSubscription = stopObservable.subscribe(function () {
|
|
220
|
+
click.stop()
|
|
221
|
+
})
|
|
166
222
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
223
|
+
click.stopObservable.subscribe(function () {
|
|
224
|
+
viewEndedSubscription.unsubscribe()
|
|
225
|
+
stopWaitPageActivityEnd()
|
|
226
|
+
stopSubscription.unsubscribe()
|
|
227
|
+
})
|
|
173
228
|
}
|
|
174
229
|
|
|
175
230
|
function computeClickActionBase(event, actionNameAttribute) {
|
|
@@ -193,7 +248,7 @@ function computeClickActionBase(event, actionNameAttribute) {
|
|
|
193
248
|
// }
|
|
194
249
|
|
|
195
250
|
return {
|
|
196
|
-
type:
|
|
251
|
+
type: ActionType.CLICK,
|
|
197
252
|
target: target,
|
|
198
253
|
position: position,
|
|
199
254
|
name: getActionNameFromElement(event.target, actionNameAttribute)
|
|
@@ -202,11 +257,11 @@ function computeClickActionBase(event, actionNameAttribute) {
|
|
|
202
257
|
|
|
203
258
|
var ClickStatus = {
|
|
204
259
|
// Initial state, the click is still ongoing.
|
|
205
|
-
ONGOING:
|
|
260
|
+
ONGOING: 0,
|
|
206
261
|
// The click is no more ongoing but still needs to be validated or discarded.
|
|
207
|
-
STOPPED:
|
|
262
|
+
STOPPED: 1,
|
|
208
263
|
// Final state, the click has been stopped and validated or discarded.
|
|
209
|
-
FINALIZED:
|
|
264
|
+
FINALIZED: 2
|
|
210
265
|
}
|
|
211
266
|
|
|
212
267
|
function newClick(
|
|
@@ -214,12 +269,22 @@ function newClick(
|
|
|
214
269
|
history,
|
|
215
270
|
getUserActivity,
|
|
216
271
|
clickActionBase,
|
|
217
|
-
|
|
272
|
+
startEvent
|
|
218
273
|
) {
|
|
219
274
|
var id = UUID()
|
|
220
275
|
var startClocks = clocksNow()
|
|
221
276
|
var historyEntry = history.add(id, startClocks.relative)
|
|
222
|
-
var eventCountsSubscription = trackEventCounts(
|
|
277
|
+
var eventCountsSubscription = trackEventCounts({
|
|
278
|
+
lifeCycle: lifeCycle,
|
|
279
|
+
isChildEvent: function (event) {
|
|
280
|
+
return (
|
|
281
|
+
event.action !== undefined &&
|
|
282
|
+
(isArray(event.action.id)
|
|
283
|
+
? includes(event.action.id, id)
|
|
284
|
+
: event.action.id === id)
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
})
|
|
223
288
|
var status = ClickStatus.ONGOING
|
|
224
289
|
var activityEndTime
|
|
225
290
|
var frustrationTypes = []
|
|
@@ -241,17 +306,20 @@ function newClick(
|
|
|
241
306
|
}
|
|
242
307
|
|
|
243
308
|
return {
|
|
244
|
-
event:
|
|
309
|
+
event: startEvent,
|
|
245
310
|
stop: stop,
|
|
246
|
-
startClocks: startClocks,
|
|
247
311
|
stopObservable: stopObservable,
|
|
248
|
-
hasError:
|
|
249
|
-
|
|
312
|
+
hasError: function () {
|
|
313
|
+
return eventCountsSubscription.eventCounts.errorCount > 0
|
|
314
|
+
},
|
|
315
|
+
hasPageActivity: function () {
|
|
316
|
+
return activityEndTime !== undefined
|
|
317
|
+
},
|
|
250
318
|
getUserActivity: getUserActivity,
|
|
251
319
|
addFrustration: function (frustrationType) {
|
|
252
320
|
frustrationTypes.push(frustrationType)
|
|
253
321
|
},
|
|
254
|
-
|
|
322
|
+
startClocks: startClocks,
|
|
255
323
|
isStopped: function () {
|
|
256
324
|
return status === ClickStatus.STOPPED || status === ClickStatus.FINALIZED
|
|
257
325
|
},
|
|
@@ -262,7 +330,7 @@ function newClick(
|
|
|
262
330
|
history,
|
|
263
331
|
getUserActivity,
|
|
264
332
|
clickActionBase,
|
|
265
|
-
|
|
333
|
+
startEvent
|
|
266
334
|
)
|
|
267
335
|
},
|
|
268
336
|
|
|
@@ -284,15 +352,16 @@ function newClick(
|
|
|
284
352
|
id: id,
|
|
285
353
|
frustrationTypes: frustrationTypes,
|
|
286
354
|
counts: {
|
|
287
|
-
resourceCount,
|
|
288
|
-
errorCount,
|
|
289
|
-
longTaskCount
|
|
355
|
+
resourceCount: resourceCount,
|
|
356
|
+
errorCount: errorCount,
|
|
357
|
+
longTaskCount: longTaskCount
|
|
290
358
|
},
|
|
291
|
-
events: isNullUndefinedDefaultValue(domEvents, [
|
|
292
|
-
event:
|
|
359
|
+
events: isNullUndefinedDefaultValue(domEvents, [startEvent]),
|
|
360
|
+
event: startEvent
|
|
293
361
|
},
|
|
294
362
|
clickActionBase
|
|
295
363
|
)
|
|
364
|
+
|
|
296
365
|
lifeCycle.notify(LifeCycleEventType.AUTO_ACTION_COMPLETED, clickAction)
|
|
297
366
|
status = ClickStatus.FINALIZED
|
|
298
367
|
},
|
|
@@ -307,6 +376,7 @@ function newClick(
|
|
|
307
376
|
export function finalizeClicks(clicks, rageClick) {
|
|
308
377
|
var _computeFrustration = computeFrustration(clicks, rageClick)
|
|
309
378
|
var isRage = _computeFrustration.isRage
|
|
379
|
+
|
|
310
380
|
if (isRage) {
|
|
311
381
|
each(clicks, function (click) {
|
|
312
382
|
click.discard()
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { trackConsoleError } from './trackConsoleError'
|
|
14
14
|
import { trackReportError } from './trackReportError'
|
|
15
15
|
|
|
16
|
-
export function startErrorCollection(lifeCycle) {
|
|
16
|
+
export function startErrorCollection(lifeCycle, foregroundContexts) {
|
|
17
17
|
var errorObservable = new Observable()
|
|
18
18
|
|
|
19
19
|
trackConsoleError(errorObservable)
|
|
@@ -24,10 +24,10 @@ export function startErrorCollection(lifeCycle) {
|
|
|
24
24
|
lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error })
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
return doStartErrorCollection(lifeCycle)
|
|
27
|
+
return doStartErrorCollection(lifeCycle, foregroundContexts)
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function doStartErrorCollection(lifeCycle) {
|
|
30
|
+
export function doStartErrorCollection(lifeCycle, foregroundContexts) {
|
|
31
31
|
lifeCycle.subscribe(LifeCycleEventType.RAW_ERROR_COLLECTED, function (error) {
|
|
32
32
|
lifeCycle.notify(
|
|
33
33
|
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,
|
|
@@ -36,7 +36,7 @@ export function doStartErrorCollection(lifeCycle) {
|
|
|
36
36
|
customerContext: error.customerContext,
|
|
37
37
|
savedCommonContext: error.savedCommonContext
|
|
38
38
|
},
|
|
39
|
-
processError(error.error)
|
|
39
|
+
processError(error.error, foregroundContexts)
|
|
40
40
|
)
|
|
41
41
|
)
|
|
42
42
|
})
|
|
@@ -64,7 +64,7 @@ export function doStartErrorCollection(lifeCycle) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
function processError(error) {
|
|
67
|
+
function processError(error, foregroundContexts) {
|
|
68
68
|
var rawRumEvent = {
|
|
69
69
|
date: error.startClocks.timeStamp,
|
|
70
70
|
error: {
|
|
@@ -80,6 +80,12 @@ function processError(error) {
|
|
|
80
80
|
},
|
|
81
81
|
type: RumEventType.ERROR
|
|
82
82
|
}
|
|
83
|
+
var inForeground = foregroundContexts.isInForegroundAt(
|
|
84
|
+
error.startClocks.relative
|
|
85
|
+
)
|
|
86
|
+
if (inForeground) {
|
|
87
|
+
rawRumEvent.view = { in_foreground: inForeground }
|
|
88
|
+
}
|
|
83
89
|
return {
|
|
84
90
|
rawRumEvent: rawRumEvent,
|
|
85
91
|
startTime: error.startClocks.relative,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ONE_MINUTE } from '@cloudcare/browser-core'
|
|
2
|
+
import { trackEventCounts } from '../../trackEventCounts'
|
|
3
|
+
|
|
4
|
+
// Some events are not being counted as they transcend views. To reduce the occurrence;
|
|
5
|
+
// an arbitrary delay is added for stopping event counting after the view ends.
|
|
6
|
+
//
|
|
7
|
+
// Ideally, we would not stop and keep counting events until the end of the session.
|
|
8
|
+
// But this might have a small performance impact if there are many many views:
|
|
9
|
+
// we would need to go through each event to see if the related view matches.
|
|
10
|
+
// So let's have a fairly short delay to avoid impacting performances too much.
|
|
11
|
+
//
|
|
12
|
+
// In the future, we could have views stored in a data structure similar to ContextHistory. Whenever
|
|
13
|
+
// a child event is collected, we could look into this history to find the matching view and
|
|
14
|
+
// increase the associated and increase its counter. Having a centralized data structure for it
|
|
15
|
+
// would allow us to look for views more efficiently.
|
|
16
|
+
//
|
|
17
|
+
// For now, having a small cleanup delay will already improve the situation in most cases.
|
|
18
|
+
|
|
19
|
+
export var KEEP_TRACKING_EVENT_COUNTS_AFTER_VIEW_DELAY = 5 * ONE_MINUTE
|
|
20
|
+
|
|
21
|
+
export function trackViewEventCounts(lifeCycle, viewId, onChange) {
|
|
22
|
+
var _trackEventCounts = trackEventCounts({
|
|
23
|
+
lifeCycle: lifeCycle,
|
|
24
|
+
isChildEvent: function (event) {
|
|
25
|
+
return event.view.id === viewId
|
|
26
|
+
},
|
|
27
|
+
onChange: onChange
|
|
28
|
+
})
|
|
29
|
+
return {
|
|
30
|
+
scheduleStop: function () {
|
|
31
|
+
setTimeout(
|
|
32
|
+
_trackEventCounts.stop,
|
|
33
|
+
KEEP_TRACKING_EVENT_COUNTS_AFTER_VIEW_DELAY
|
|
34
|
+
)
|
|
35
|
+
},
|
|
36
|
+
eventCounts: _trackEventCounts.eventCounts
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
ViewLoadingType
|
|
8
8
|
} from '@cloudcare/browser-core'
|
|
9
9
|
import { supportPerformanceTimingEvent } from '../../performanceCollection'
|
|
10
|
-
import { trackEventCounts } from '../../trackEventCounts'
|
|
11
10
|
import { waitPageActivityEnd } from '../../waitPageActivityEnd'
|
|
12
11
|
export function trackViewMetrics(
|
|
13
12
|
lifeCycle,
|
|
@@ -17,24 +16,8 @@ export function trackViewMetrics(
|
|
|
17
16
|
loadingType,
|
|
18
17
|
viewStart
|
|
19
18
|
) {
|
|
20
|
-
var viewMetrics = {
|
|
21
|
-
eventCounts: {
|
|
22
|
-
errorCount: 0,
|
|
23
|
-
longTaskCount: 0,
|
|
24
|
-
resourceCount: 0,
|
|
25
|
-
actionCount: 0,
|
|
26
|
-
frustrationCount: 0
|
|
27
|
-
}
|
|
28
|
-
}
|
|
19
|
+
var viewMetrics = {}
|
|
29
20
|
|
|
30
|
-
var _trackEventCounts = trackEventCounts(
|
|
31
|
-
lifeCycle,
|
|
32
|
-
function (newEventCounts) {
|
|
33
|
-
viewMetrics.eventCounts = newEventCounts
|
|
34
|
-
scheduleViewUpdate()
|
|
35
|
-
}
|
|
36
|
-
)
|
|
37
|
-
var stopEventCountsTracking = _trackEventCounts.stop
|
|
38
21
|
var _trackLoadingTime = trackLoadingTime(
|
|
39
22
|
lifeCycle,
|
|
40
23
|
domMutationObservable,
|
|
@@ -64,7 +47,6 @@ export function trackViewMetrics(
|
|
|
64
47
|
}
|
|
65
48
|
return {
|
|
66
49
|
stop: function () {
|
|
67
|
-
stopEventCountsTracking()
|
|
68
50
|
stopLoadingTimeTracking()
|
|
69
51
|
stopCLSTracking()
|
|
70
52
|
},
|