@cloudcare/browser-rum 2.1.5 → 2.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 +1 -2
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/rum.js +57 -48
- package/cjs/boot/rumPublicApi.js +169 -134
- package/cjs/domain/assembly.js +58 -44
- package/cjs/domain/configuration.js +67 -0
- package/cjs/domain/contexts/internalContext.js +45 -0
- package/cjs/domain/contexts/urlContexts.js +68 -0
- package/cjs/domain/contexts/viewContexts.js +43 -0
- package/cjs/domain/domMutationCollection.js +44 -31
- package/cjs/domain/{rumEventsCollection/view/trackLocationChanges.js → locationChangeObservable.js} +25 -25
- package/cjs/domain/performanceCollection.js +55 -24
- package/cjs/domain/requestCollection.js +117 -0
- package/cjs/domain/rumEventsCollection/actions/actionCollection.js +22 -4
- package/cjs/domain/rumEventsCollection/actions/clickChain.js +82 -0
- package/cjs/domain/rumEventsCollection/actions/computeFrustration.js +78 -0
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +60 -47
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +163 -0
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js +74 -0
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +263 -0
- package/cjs/domain/rumEventsCollection/error/errorCollection.js +33 -53
- package/cjs/domain/rumEventsCollection/error/trackConsoleError.js +26 -0
- package/cjs/domain/rumEventsCollection/error/trackReportError.js +26 -0
- package/cjs/domain/rumEventsCollection/longTask/longTaskCollection.js +46 -17
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +49 -9
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js +7 -5
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +61 -24
- package/cjs/domain/rumEventsCollection/view/trackViewMetrics.js +91 -51
- package/cjs/domain/rumEventsCollection/view/trackViews.js +119 -86
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +41 -31
- package/cjs/domain/rumSessionManager.js +95 -0
- package/cjs/domain/tracing/tracer.js +9 -10
- package/cjs/domain/trackEventCounts.js +9 -6
- package/cjs/domain/usr/index.js +30 -0
- package/cjs/domain/waitPageActivityEnd.js +163 -0
- package/cjs/transport/startRumBatch.js +38 -0
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rum.js +55 -48
- package/esm/boot/rumPublicApi.js +167 -135
- package/esm/domain/assembly.js +58 -44
- package/esm/domain/configuration.js +53 -0
- package/esm/domain/contexts/internalContext.js +38 -0
- package/esm/domain/contexts/urlContexts.js +58 -0
- package/esm/domain/contexts/viewContexts.js +32 -0
- package/esm/domain/domMutationCollection.js +43 -33
- package/esm/domain/{rumEventsCollection/view/trackLocationChanges.js → locationChangeObservable.js} +26 -24
- package/esm/domain/performanceCollection.js +56 -26
- package/esm/domain/requestCollection.js +102 -0
- package/esm/domain/rumEventsCollection/actions/actionCollection.js +23 -5
- package/esm/domain/rumEventsCollection/actions/clickChain.js +69 -0
- package/esm/domain/rumEventsCollection/actions/computeFrustration.js +64 -0
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +60 -47
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +139 -0
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +66 -0
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +244 -0
- package/esm/domain/rumEventsCollection/error/errorCollection.js +32 -54
- package/esm/domain/rumEventsCollection/error/trackConsoleError.js +18 -0
- package/esm/domain/rumEventsCollection/error/trackReportError.js +18 -0
- package/esm/domain/rumEventsCollection/longTask/longTaskCollection.js +30 -18
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +31 -9
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js +8 -6
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +43 -26
- package/esm/domain/rumEventsCollection/view/trackViewMetrics.js +75 -51
- package/esm/domain/rumEventsCollection/view/trackViews.js +120 -85
- package/esm/domain/rumEventsCollection/view/viewCollection.js +42 -32
- package/esm/domain/rumSessionManager.js +80 -0
- package/esm/domain/tracing/skywalkingTracer.js +1 -1
- package/esm/domain/tracing/tracer.js +8 -9
- package/esm/domain/trackEventCounts.js +9 -6
- package/esm/domain/usr/index.js +17 -0
- package/esm/domain/waitPageActivityEnd.js +147 -0
- package/esm/transport/startRumBatch.js +30 -0
- package/package.json +3 -3
- package/src/boot/rum.js +79 -59
- package/src/boot/rumPublicApi.js +165 -171
- package/src/domain/.DS_Store +0 -0
- package/src/domain/assembly.js +77 -54
- package/src/domain/configuration.js +69 -0
- package/src/domain/contexts/internalContext.js +39 -0
- package/src/domain/contexts/urlContexts.js +76 -0
- package/src/domain/contexts/viewContexts.js +37 -0
- package/src/domain/domMutationCollection.js +48 -32
- package/src/domain/{rumEventsCollection/view/trackLocationChanges.js → locationChangeObservable.js} +28 -28
- package/src/domain/performanceCollection.js +62 -45
- package/src/domain/requestCollection.js +103 -0
- package/src/domain/rumEventsCollection/actions/actionCollection.js +34 -11
- package/src/domain/rumEventsCollection/actions/clickChain.js +90 -0
- package/src/domain/rumEventsCollection/actions/computeFrustration.js +84 -0
- package/src/domain/rumEventsCollection/actions/getActionNameFromElement.js +73 -62
- package/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +157 -0
- package/src/domain/rumEventsCollection/actions/listenActionEvents.js +85 -0
- package/src/domain/rumEventsCollection/actions/trackClickActions.js +326 -0
- package/src/domain/rumEventsCollection/error/errorCollection.js +53 -69
- package/src/domain/rumEventsCollection/error/trackConsoleError.js +21 -0
- package/src/domain/rumEventsCollection/error/trackReportError.js +22 -0
- package/src/domain/rumEventsCollection/longTask/longTaskCollection.js +29 -18
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +39 -23
- package/src/domain/rumEventsCollection/view/trackFirstHidden.js +9 -6
- package/src/domain/rumEventsCollection/view/trackInitialViewTimings.js +63 -42
- package/src/domain/rumEventsCollection/view/trackViewMetrics.js +80 -61
- package/src/domain/rumEventsCollection/view/trackViews.js +171 -134
- package/src/domain/rumEventsCollection/view/viewCollection.js +69 -49
- package/src/domain/rumSessionManager.js +90 -0
- package/src/domain/tracing/jaegerTracer.js +5 -5
- package/src/domain/tracing/skywalkingTracer.js +3 -3
- package/src/domain/tracing/tracer.js +50 -38
- package/src/domain/tracing/w3cTraceParentTracer.js +5 -5
- package/src/domain/tracing/zipkinMultiTracer.js +5 -5
- package/src/domain/tracing/zipkinSingleTracer.js +5 -5
- package/src/domain/trackEventCounts.js +10 -6
- package/src/domain/usr/index.js +16 -0
- package/src/domain/waitPageActivityEnd.js +192 -0
- package/src/transport/startRumBatch.js +48 -0
- package/cjs/domain/internalContext.js +0 -34
- package/cjs/domain/parentContexts.js +0 -143
- package/cjs/domain/requestCollections.js +0 -131
- package/cjs/domain/rumEventsCollection/actions/trackActions.js +0 -114
- package/cjs/domain/rumSession.js +0 -82
- package/cjs/domain/trackPageActivities.js +0 -166
- package/cjs/transport/batch.js +0 -81
- package/esm/domain/internalContext.js +0 -27
- package/esm/domain/parentContexts.js +0 -130
- package/esm/domain/requestCollections.js +0 -118
- package/esm/domain/rumEventsCollection/actions/trackActions.js +0 -103
- package/esm/domain/rumSession.js +0 -70
- package/esm/domain/trackPageActivities.js +0 -149
- package/esm/transport/batch.js +0 -74
- package/src/domain/internalContext.js +0 -28
- package/src/domain/parentContexts.js +0 -171
- package/src/domain/requestCollections.js +0 -118
- package/src/domain/rumEventsCollection/actions/trackActions.js +0 -113
- package/src/domain/rumSession.js +0 -92
- package/src/domain/trackPageActivities.js +0 -170
- package/src/transport/batch.js +0 -85
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.retrieveInitialDocumentResourceTiming = retrieveInitialDocumentResourceTiming;
|
|
7
7
|
exports.startPerformanceCollection = startPerformanceCollection;
|
|
8
|
+
exports.supportPerformanceEntry = supportPerformanceEntry;
|
|
8
9
|
exports.supportPerformanceTimingEvent = supportPerformanceTimingEvent;
|
|
9
10
|
|
|
10
11
|
var _browserCore = require("@cloudcare/browser-core");
|
|
@@ -21,20 +22,48 @@ function supportPerformanceTimingEvent(entryType) {
|
|
|
21
22
|
|
|
22
23
|
function startPerformanceCollection(lifeCycle, configuration) {
|
|
23
24
|
retrieveInitialDocumentResourceTiming(function (timing) {
|
|
24
|
-
|
|
25
|
+
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
if (supportPerformanceObject()) {
|
|
28
|
-
|
|
29
|
+
var performanceEntries = performance.getEntries(); // Because the performance entry list can be quite large
|
|
30
|
+
// delay the computation to prevent the SDK from blocking the main thread on init
|
|
31
|
+
|
|
32
|
+
setTimeout(function () {
|
|
33
|
+
handleRumPerformanceEntries(lifeCycle, configuration, performanceEntries);
|
|
34
|
+
});
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
if (window.PerformanceObserver) {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
var handlePerformanceEntryList = function handlePerformanceEntryList(entries) {
|
|
39
|
+
handleRumPerformanceEntries(lifeCycle, configuration, entries.getEntries());
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var mainEntries = ['resource', 'navigation', 'longtask', 'paint'];
|
|
43
|
+
var experimentalEntries = ['largest-contentful-paint', 'first-input', 'layout-shift'];
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
// Experimental entries are not retrieved by performance.getEntries()
|
|
47
|
+
// use a single PerformanceObserver with buffered flag by type
|
|
48
|
+
// to get values that could happen before SDK init
|
|
49
|
+
(0, _browserCore.each)(experimentalEntries, function (type) {
|
|
50
|
+
var observer = new PerformanceObserver(handlePerformanceEntryList);
|
|
51
|
+
observer.observe({
|
|
52
|
+
type: type,
|
|
53
|
+
buffered: true
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
} catch (e) {
|
|
57
|
+
// Some old browser versions (ex: chrome 67) don't support the PerformanceObserver type and buffered options
|
|
58
|
+
// In these cases, fallback to PerformanceObserver with entryTypes
|
|
59
|
+
(0, _browserCore.each)(experimentalEntries, function (type) {
|
|
60
|
+
mainEntries.push(type);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var mainObserver = new PerformanceObserver(handlePerformanceEntryList);
|
|
65
|
+
mainObserver.observe({
|
|
66
|
+
entryTypes: mainEntries
|
|
38
67
|
});
|
|
39
68
|
|
|
40
69
|
if (supportPerformanceObject() && 'addEventListener' in performance) {
|
|
@@ -47,13 +76,13 @@ function startPerformanceCollection(lifeCycle, configuration) {
|
|
|
47
76
|
|
|
48
77
|
if (!supportPerformanceTimingEvent('navigation')) {
|
|
49
78
|
retrieveNavigationTiming(function (timing) {
|
|
50
|
-
|
|
79
|
+
handleRumPerformanceEntries(lifeCycle, configuration, [timing]);
|
|
51
80
|
});
|
|
52
81
|
}
|
|
53
82
|
|
|
54
83
|
if (!supportPerformanceTimingEvent('first-input')) {
|
|
55
84
|
retrieveFirstInputTiming(function (timing) {
|
|
56
|
-
|
|
85
|
+
return handleRumPerformanceEntries(lifeCycle, configuration, [timing]);
|
|
57
86
|
});
|
|
58
87
|
}
|
|
59
88
|
}
|
|
@@ -103,7 +132,7 @@ function retrieveNavigationTiming(callback) {
|
|
|
103
132
|
|
|
104
133
|
|
|
105
134
|
function retrieveFirstInputTiming(callback) {
|
|
106
|
-
var startTimeStamp =
|
|
135
|
+
var startTimeStamp = (0, _browserCore.dateNow)();
|
|
107
136
|
var timingSent = false;
|
|
108
137
|
var listeners = (0, _browserCore.addEventListeners)(window, [_browserCore.DOM_EVENT.CLICK, _browserCore.DOM_EVENT.MOUSE_DOWN, _browserCore.DOM_EVENT.KEY_DOWN, _browserCore.DOM_EVENT.TOUCH_START, _browserCore.DOM_EVENT.POINTER_DOWN], function (evt) {
|
|
109
138
|
// Only count cancelable events, which should trigger behavior important to the user.
|
|
@@ -116,7 +145,7 @@ function retrieveFirstInputTiming(callback) {
|
|
|
116
145
|
|
|
117
146
|
var timing = {
|
|
118
147
|
entryType: 'first-input',
|
|
119
|
-
processingStart:
|
|
148
|
+
processingStart: (0, _browserCore.relativeNow)(),
|
|
120
149
|
startTime: evt.timeStamp
|
|
121
150
|
};
|
|
122
151
|
|
|
@@ -158,7 +187,7 @@ function retrieveFirstInputTiming(callback) {
|
|
|
158
187
|
|
|
159
188
|
var delay = timing.processingStart - timing.startTime;
|
|
160
189
|
|
|
161
|
-
if (delay >= 0 && delay <
|
|
190
|
+
if (delay >= 0 && delay < (0, _browserCore.dateNow)() - startTimeStamp) {
|
|
162
191
|
callback(timing);
|
|
163
192
|
}
|
|
164
193
|
}
|
|
@@ -189,20 +218,17 @@ function computeRelativePerformanceTiming() {
|
|
|
189
218
|
return result;
|
|
190
219
|
}
|
|
191
220
|
|
|
192
|
-
function
|
|
193
|
-
(0, _browserCore.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
221
|
+
function handleRumPerformanceEntries(lifeCycle, configuration, entries) {
|
|
222
|
+
var rumPerformanceEntries = (0, _browserCore.filter)(entries, function (entry) {
|
|
223
|
+
return entry.entryType === 'resource' || entry.entryType === 'navigation' || entry.entryType === 'paint' || entry.entryType === 'longtask' || entry.entryType === 'largest-contentful-paint' || entry.entryType === 'first-input' || entry.entryType === 'layout-shift';
|
|
224
|
+
});
|
|
225
|
+
var rumAllowedPerformanceEntries = (0, _browserCore.filter)(rumPerformanceEntries, function (entry) {
|
|
226
|
+
return !isIncompleteNavigation(entry) && !isForbiddenResource(configuration, entry);
|
|
197
227
|
});
|
|
198
|
-
}
|
|
199
228
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
return;
|
|
229
|
+
if (rumAllowedPerformanceEntries.length) {
|
|
230
|
+
lifeCycle.notify(_browserCore.LifeCycleEventType.PERFORMANCE_ENTRIES_COLLECTED, rumAllowedPerformanceEntries);
|
|
203
231
|
}
|
|
204
|
-
|
|
205
|
-
lifeCycle.notify(_browserCore.LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, entry);
|
|
206
232
|
}
|
|
207
233
|
|
|
208
234
|
function isIncompleteNavigation(entry) {
|
|
@@ -211,4 +237,9 @@ function isIncompleteNavigation(entry) {
|
|
|
211
237
|
|
|
212
238
|
function isForbiddenResource(configuration, entry) {
|
|
213
239
|
return entry.entryType === 'resource' && !(0, _resourceUtils.isAllowedRequestUrl)(configuration, entry.name);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function supportPerformanceEntry() {
|
|
243
|
+
// Safari 10 doesn't support PerformanceEntry
|
|
244
|
+
return typeof PerformanceEntry === 'function';
|
|
214
245
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.startRequestCollection = startRequestCollection;
|
|
7
|
+
exports.trackFetch = trackFetch;
|
|
8
|
+
exports.trackXhr = trackXhr;
|
|
9
|
+
|
|
10
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
+
|
|
12
|
+
var _resourceUtils = require("./rumEventsCollection/resource/resourceUtils");
|
|
13
|
+
|
|
14
|
+
var _tracer = require("./tracing/tracer");
|
|
15
|
+
|
|
16
|
+
var nextRequestIndex = 1;
|
|
17
|
+
|
|
18
|
+
function startRequestCollection(lifeCycle, configuration, sessionManager) {
|
|
19
|
+
var tracer = (0, _tracer.startTracer)(configuration, sessionManager);
|
|
20
|
+
trackXhr(lifeCycle, configuration, tracer);
|
|
21
|
+
trackFetch(lifeCycle, configuration, tracer);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function trackXhr(lifeCycle, configuration, tracer) {
|
|
25
|
+
var subscription = (0, _browserCore.initXhrObservable)().subscribe(function (rawContext) {
|
|
26
|
+
var context = rawContext;
|
|
27
|
+
|
|
28
|
+
if (!(0, _resourceUtils.isAllowedRequestUrl)(configuration, context.url)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
switch (context.state) {
|
|
33
|
+
case 'start':
|
|
34
|
+
tracer.traceXhr(context, context.xhr);
|
|
35
|
+
context.requestIndex = getNextRequestIndex();
|
|
36
|
+
lifeCycle.notify(_browserCore.LifeCycleEventType.REQUEST_STARTED, {
|
|
37
|
+
requestIndex: context.requestIndex,
|
|
38
|
+
url: context.url
|
|
39
|
+
});
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
case 'complete':
|
|
43
|
+
tracer.clearTracingIfNeeded(context);
|
|
44
|
+
lifeCycle.notify(_browserCore.LifeCycleEventType.REQUEST_COMPLETED, {
|
|
45
|
+
duration: context.duration,
|
|
46
|
+
method: context.method,
|
|
47
|
+
requestIndex: context.requestIndex,
|
|
48
|
+
spanId: context.spanId,
|
|
49
|
+
startClocks: context.startClocks,
|
|
50
|
+
status: context.status,
|
|
51
|
+
traceId: context.traceId,
|
|
52
|
+
traceSampled: context.traceSampled,
|
|
53
|
+
type: _browserCore.RequestType.XHR,
|
|
54
|
+
url: context.url,
|
|
55
|
+
xhr: context.xhr
|
|
56
|
+
});
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
stop: function stop() {
|
|
62
|
+
return subscription.unsubscribe();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function trackFetch(lifeCycle, configuration, tracer) {
|
|
68
|
+
var subscription = (0, _browserCore.initFetchObservable)().subscribe(function (rawContext) {
|
|
69
|
+
var context = rawContext;
|
|
70
|
+
|
|
71
|
+
if (!(0, _resourceUtils.isAllowedRequestUrl)(configuration, context.url)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
switch (context.state) {
|
|
76
|
+
case 'start':
|
|
77
|
+
tracer.traceFetch(context);
|
|
78
|
+
context.requestIndex = getNextRequestIndex();
|
|
79
|
+
lifeCycle.notify(_browserCore.LifeCycleEventType.REQUEST_STARTED, {
|
|
80
|
+
requestIndex: context.requestIndex,
|
|
81
|
+
url: context.url
|
|
82
|
+
});
|
|
83
|
+
break;
|
|
84
|
+
|
|
85
|
+
case 'complete':
|
|
86
|
+
tracer.clearTracingIfNeeded(context);
|
|
87
|
+
lifeCycle.notify(_browserCore.LifeCycleEventType.REQUEST_COMPLETED, {
|
|
88
|
+
duration: context.duration,
|
|
89
|
+
method: context.method,
|
|
90
|
+
requestIndex: context.requestIndex,
|
|
91
|
+
responseType: context.responseType,
|
|
92
|
+
spanId: context.spanId,
|
|
93
|
+
startClocks: context.startClocks,
|
|
94
|
+
status: context.status,
|
|
95
|
+
traceId: context.traceId,
|
|
96
|
+
traceSampled: context.traceSampled,
|
|
97
|
+
type: _browserCore.RequestType.FETCH,
|
|
98
|
+
url: context.url,
|
|
99
|
+
response: context.response,
|
|
100
|
+
init: context.init,
|
|
101
|
+
input: context.input
|
|
102
|
+
});
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
stop: function stop() {
|
|
108
|
+
return subscription.unsubscribe();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function getNextRequestIndex() {
|
|
114
|
+
var result = nextRequestIndex;
|
|
115
|
+
nextRequestIndex += 1;
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
@@ -7,18 +7,22 @@ exports.startActionCollection = startActionCollection;
|
|
|
7
7
|
|
|
8
8
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _trackClickActions = require("./trackClickActions");
|
|
11
11
|
|
|
12
|
-
function startActionCollection(lifeCycle, configuration) {
|
|
12
|
+
function startActionCollection(lifeCycle, domMutationObservable, configuration) {
|
|
13
13
|
lifeCycle.subscribe(_browserCore.LifeCycleEventType.AUTO_ACTION_COMPLETED, function (action) {
|
|
14
14
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action));
|
|
15
15
|
});
|
|
16
|
+
var actionContexts = {
|
|
17
|
+
findActionId: _browserCore.noop
|
|
18
|
+
};
|
|
16
19
|
|
|
17
20
|
if (configuration.trackInteractions) {
|
|
18
|
-
(0,
|
|
21
|
+
actionContexts = (0, _trackClickActions.trackClickActions)(lifeCycle, domMutationObservable, configuration).actionContexts;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
return {
|
|
25
|
+
actionContexts: actionContexts,
|
|
22
26
|
addAction: function addAction(action, savedCommonContext) {
|
|
23
27
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, (0, _browserCore.extend)({
|
|
24
28
|
savedCommonContext: savedCommonContext
|
|
@@ -35,12 +39,21 @@ function processAction(action) {
|
|
|
35
39
|
},
|
|
36
40
|
id: action.id,
|
|
37
41
|
loadingTime: (0, _browserCore.toServerDuration)(action.duration),
|
|
42
|
+
frustration: {
|
|
43
|
+
type: action.frustrationTypes
|
|
44
|
+
},
|
|
38
45
|
long_task: {
|
|
39
46
|
count: action.counts.longTaskCount
|
|
40
47
|
},
|
|
41
48
|
resource: {
|
|
42
49
|
count: action.counts.resourceCount
|
|
43
50
|
}
|
|
51
|
+
},
|
|
52
|
+
_dd: {
|
|
53
|
+
action: {
|
|
54
|
+
target: action.target,
|
|
55
|
+
position: action.position
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
58
|
} : {
|
|
46
59
|
action: {
|
|
@@ -50,6 +63,7 @@ function processAction(action) {
|
|
|
50
63
|
var customerContext = !isAutoAction(action) ? action.context : undefined;
|
|
51
64
|
var actionEvent = (0, _browserCore.extend2Lev)({
|
|
52
65
|
action: {
|
|
66
|
+
id: (0, _browserCore.UUID)(),
|
|
53
67
|
target: {
|
|
54
68
|
name: action.name
|
|
55
69
|
},
|
|
@@ -61,7 +75,11 @@ function processAction(action) {
|
|
|
61
75
|
return {
|
|
62
76
|
customerContext: customerContext,
|
|
63
77
|
rawRumEvent: actionEvent,
|
|
64
|
-
startTime: action.startClocks.relative
|
|
78
|
+
startTime: action.startClocks.relative,
|
|
79
|
+
domainContext: isAutoAction(action) ? {
|
|
80
|
+
event: action.event,
|
|
81
|
+
events: action.events
|
|
82
|
+
} : {}
|
|
65
83
|
};
|
|
66
84
|
}
|
|
67
85
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MAX_DURATION_BETWEEN_CLICKS = exports.MAX_DISTANCE_BETWEEN_CLICKS = void 0;
|
|
7
|
+
exports.createClickChain = createClickChain;
|
|
8
|
+
|
|
9
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
10
|
+
|
|
11
|
+
var MAX_DURATION_BETWEEN_CLICKS = _browserCore.ONE_SECOND;
|
|
12
|
+
exports.MAX_DURATION_BETWEEN_CLICKS = MAX_DURATION_BETWEEN_CLICKS;
|
|
13
|
+
var MAX_DISTANCE_BETWEEN_CLICKS = 100;
|
|
14
|
+
exports.MAX_DISTANCE_BETWEEN_CLICKS = MAX_DISTANCE_BETWEEN_CLICKS;
|
|
15
|
+
var ClickChainStatus = {
|
|
16
|
+
WaitingForMoreClicks: 'WaitingForMoreClicks',
|
|
17
|
+
WaitingForClicksToStop: 'WaitingForClicksToStop',
|
|
18
|
+
Finalized: 'Finalized'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function createClickChain(firstClick, onFinalize) {
|
|
22
|
+
var bufferedClicks = [];
|
|
23
|
+
var status = ClickChainStatus.WaitingForMoreClicks;
|
|
24
|
+
var maxDurationBetweenClicksTimeout;
|
|
25
|
+
appendClick(firstClick);
|
|
26
|
+
|
|
27
|
+
function appendClick(click) {
|
|
28
|
+
click.stopObservable.subscribe(tryFinalize);
|
|
29
|
+
bufferedClicks.push(click);
|
|
30
|
+
clearTimeout(maxDurationBetweenClicksTimeout);
|
|
31
|
+
maxDurationBetweenClicksTimeout = setTimeout(dontAcceptMoreClick, MAX_DURATION_BETWEEN_CLICKS);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function tryFinalize() {
|
|
35
|
+
if (status === ClickChainStatus.WaitingForClicksToStop && (0, _browserCore.every)(bufferedClicks, function (click) {
|
|
36
|
+
return click.isStopped();
|
|
37
|
+
})) {
|
|
38
|
+
status = ClickChainStatus.Finalized;
|
|
39
|
+
onFinalize(bufferedClicks);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function dontAcceptMoreClick() {
|
|
44
|
+
clearTimeout(maxDurationBetweenClicksTimeout);
|
|
45
|
+
|
|
46
|
+
if (status === ClickChainStatus.WaitingForMoreClicks) {
|
|
47
|
+
status = ClickChainStatus.WaitingForClicksToStop;
|
|
48
|
+
tryFinalize();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
tryAppend: function tryAppend(click) {
|
|
54
|
+
if (status !== ClickChainStatus.WaitingForMoreClicks) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (bufferedClicks.length > 0 && !areEventsSimilar(bufferedClicks[bufferedClicks.length - 1].event, click.event)) {
|
|
59
|
+
dontAcceptMoreClick();
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
appendClick(click);
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
stop: function stop() {
|
|
67
|
+
dontAcceptMoreClick();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Checks whether two events are similar by comparing their target, position and timestamp
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
function areEventsSimilar(first, second) {
|
|
77
|
+
return first.target === second.target && mouseEventDistance(first, second) <= MAX_DISTANCE_BETWEEN_CLICKS && first.timeStamp - second.timeStamp <= MAX_DURATION_BETWEEN_CLICKS;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function mouseEventDistance(origin, other) {
|
|
81
|
+
return Math.sqrt(Math.pow(origin.clientX - other.clientX, 2) + Math.pow(origin.clientY - other.clientY, 2));
|
|
82
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.computeFrustration = computeFrustration;
|
|
7
|
+
exports.isDead = isDead;
|
|
8
|
+
exports.isRage = isRage;
|
|
9
|
+
|
|
10
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
+
|
|
12
|
+
var MIN_CLICKS_PER_SECOND_TO_CONSIDER_RAGE = 3;
|
|
13
|
+
|
|
14
|
+
function computeFrustration(clicks, rageClick) {
|
|
15
|
+
if (isRage(clicks)) {
|
|
16
|
+
rageClick.addFrustration(_browserCore.FrustrationType.RAGE_CLICK);
|
|
17
|
+
|
|
18
|
+
if (clicks.some(isDead)) {
|
|
19
|
+
rageClick.addFrustration(_browserCore.FrustrationType.DEAD_CLICK);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (rageClick.hasError) {
|
|
23
|
+
rageClick.addFrustration(_browserCore.FrustrationType.ERROR_CLICK);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
isRage: true
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var hasSelectionChanged = (0, _browserCore.some)(clicks, function (click) {
|
|
32
|
+
return click.getUserActivity().selection;
|
|
33
|
+
});
|
|
34
|
+
(0, _browserCore.each)(clicks, function (click) {
|
|
35
|
+
if (click.hasError) {
|
|
36
|
+
click.addFrustration(_browserCore.FrustrationType.ERROR_CLICK);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (isDead(click) && // Avoid considering clicks part of a double-click or triple-click selections as dead clicks
|
|
40
|
+
!hasSelectionChanged) {
|
|
41
|
+
click.addFrustration(_browserCore.FrustrationType.DEAD_CLICK);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
isRage: false
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isRage(clicks) {
|
|
50
|
+
if ((0, _browserCore.some)(clicks, function (click) {
|
|
51
|
+
return click.getUserActivity().selection;
|
|
52
|
+
})) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for (var i = 0; i < clicks.length - (MIN_CLICKS_PER_SECOND_TO_CONSIDER_RAGE - 1); i += 1) {
|
|
57
|
+
if (clicks[i + MIN_CLICKS_PER_SECOND_TO_CONSIDER_RAGE - 1].event.timeStamp - clicks[i].event.timeStamp <= _browserCore.ONE_SECOND) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var DEAD_CLICK_EXCLUDE_SELECTOR = // inputs that don't trigger a meaningful event like "input" when clicked, including textual
|
|
66
|
+
// inputs (using a negative selector is shorter here)
|
|
67
|
+
'input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="range"]),' + 'textarea,' + 'select,' + // canvas, as there is no good way to detect activity occurring on them
|
|
68
|
+
'canvas,' + // links that are interactive (have an href attribute) or any of their descendants, as they can
|
|
69
|
+
// open a new tab or navigate to a hash without triggering a meaningful event
|
|
70
|
+
'a[href],' + 'a[href] *';
|
|
71
|
+
|
|
72
|
+
function isDead(click) {
|
|
73
|
+
if (click.hasPageActivity || click.getUserActivity().input) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return !(0, _browserCore.elementMatches)(click.event.target, DEAD_CLICK_EXCLUDE_SELECTOR);
|
|
78
|
+
}
|