@cloudcare/browser-rum 2.2.15 → 3.0.1
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 +388 -0
- package/cjs/domain/replay/record/observers.js +470 -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 +4400 -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 +127 -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 +336 -0
- package/esm/domain/replay/record/observers.js +454 -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 +4393 -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 +114 -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 +403 -0
- package/src/domain/replay/record/observers.js +565 -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 +4584 -0
- package/src/domain/replay/segmentCollection/index.js +6 -0
- package/src/domain/replay/segmentCollection/segment.js +86 -0
- package/src/domain/replay/segmentCollection/segmentCollection.js +205 -0
- package/src/domain/replay/segmentCollection/startDeflateWorker.js +102 -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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "SEGMENT_BYTES_LIMIT", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _segmentCollection.SEGMENT_BYTES_LIMIT;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "setSegmentBytesLimit", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _segmentCollection.setSegmentBytesLimit;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "startDeflateWorker", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _startDeflateWorker.startDeflateWorker;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "startSegmentCollection", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _segmentCollection.startSegmentCollection;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
var _segmentCollection = require("./segmentCollection");
|
|
32
|
+
|
|
33
|
+
var _startDeflateWorker = require("./startDeflateWorker");
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.Segment = Segment;
|
|
9
|
+
|
|
10
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
+
|
|
12
|
+
var _types = require("../../../types");
|
|
13
|
+
|
|
14
|
+
var replayStats = _interopRequireWildcard(require("../replayStats"));
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
var nextId = 0;
|
|
21
|
+
|
|
22
|
+
function Segment(worker, context, creationReason, initialRecord, onWrote, onFlushed) {
|
|
23
|
+
this.worker = worker;
|
|
24
|
+
this.id = nextId++;
|
|
25
|
+
var viewId = context.view.id;
|
|
26
|
+
this.metadata = (0, _browserCore.assign)({
|
|
27
|
+
start: initialRecord.timestamp,
|
|
28
|
+
end: initialRecord.timestamp,
|
|
29
|
+
creation_reason: creationReason,
|
|
30
|
+
records_count: 1,
|
|
31
|
+
has_full_snapshot: initialRecord.type === _types.RecordType.FullSnapshot,
|
|
32
|
+
index_in_view: replayStats.getSegmentsCount(viewId),
|
|
33
|
+
source: 'browser'
|
|
34
|
+
}, context);
|
|
35
|
+
replayStats.addSegment(viewId);
|
|
36
|
+
replayStats.addRecord(viewId);
|
|
37
|
+
|
|
38
|
+
var _this = this;
|
|
39
|
+
|
|
40
|
+
var listener = function listener(params) {
|
|
41
|
+
var data = params.data;
|
|
42
|
+
|
|
43
|
+
if (data.type === 'errored' || data.type === 'initialized') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (data.id === _this.id) {
|
|
48
|
+
replayStats.addWroteData(viewId, data.additionalBytesCount);
|
|
49
|
+
|
|
50
|
+
if (data.type === 'flushed') {
|
|
51
|
+
onFlushed(data.result, data.rawBytesCount);
|
|
52
|
+
worker.removeEventListener('message', listener);
|
|
53
|
+
} else {
|
|
54
|
+
onWrote(data.compressedBytesCount);
|
|
55
|
+
}
|
|
56
|
+
} else if (data.id > _this.id) {
|
|
57
|
+
// Messages should be received in the same order as they are sent, so if we receive a
|
|
58
|
+
// message with an id superior to this Segment instance id, we know that another, more
|
|
59
|
+
// recent Segment instance is being used.
|
|
60
|
+
//
|
|
61
|
+
// In theory, a "flush" response should have been received at this point, so the listener
|
|
62
|
+
// should already have been removed. But if something goes wrong and we didn't receive a
|
|
63
|
+
// "flush" response, remove the listener to avoid any leak, and send a monitor message to
|
|
64
|
+
// help investigate the issue.
|
|
65
|
+
worker.removeEventListener('message', listener);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
worker.addEventListener('message', listener);
|
|
70
|
+
this.worker.postMessage({
|
|
71
|
+
data: '{"records":[' + JSON.stringify(initialRecord),
|
|
72
|
+
id: this.id,
|
|
73
|
+
action: 'write'
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
Segment.prototype.addRecord = function (record) {
|
|
78
|
+
this.metadata.start = Math.min(this.metadata.start, record.timestamp);
|
|
79
|
+
this.metadata.end = Math.max(this.metadata.end, record.timestamp);
|
|
80
|
+
this.metadata.records_count += 1;
|
|
81
|
+
replayStats.addRecord(this.metadata.view.id);
|
|
82
|
+
|
|
83
|
+
if (!this.metadata.has_full_snapshot) {
|
|
84
|
+
this.metadata.has_full_snapshot = record.type === _types.RecordType.FullSnapshot;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
this.worker.postMessage({
|
|
88
|
+
data: ',' + JSON.stringify(record),
|
|
89
|
+
id: this.id,
|
|
90
|
+
action: 'write'
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
Segment.prototype.flush = function (reason) {
|
|
95
|
+
this.worker.postMessage({
|
|
96
|
+
data: '],' + JSON.stringify(this.metadata).slice(1) + '\n',
|
|
97
|
+
id: this.id,
|
|
98
|
+
action: 'flush'
|
|
99
|
+
});
|
|
100
|
+
this.flushReason = reason;
|
|
101
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SEGMENT_DURATION_LIMIT = exports.SEGMENT_BYTES_LIMIT = void 0;
|
|
7
|
+
exports.computeSegmentContext = computeSegmentContext;
|
|
8
|
+
exports.doStartSegmentCollection = doStartSegmentCollection;
|
|
9
|
+
exports.setSegmentBytesLimit = setSegmentBytesLimit;
|
|
10
|
+
exports.startSegmentCollection = startSegmentCollection;
|
|
11
|
+
|
|
12
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
13
|
+
|
|
14
|
+
var _buildReplayPayload = require("./buildReplayPayload");
|
|
15
|
+
|
|
16
|
+
var _segment = require("./segment");
|
|
17
|
+
|
|
18
|
+
var SEGMENT_DURATION_LIMIT = 30 * _browserCore.ONE_SECOND;
|
|
19
|
+
/**
|
|
20
|
+
* beacon payload max queue size implementation is 64kb
|
|
21
|
+
* ensure that we leave room for logs, rum and potential other users
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
exports.SEGMENT_DURATION_LIMIT = SEGMENT_DURATION_LIMIT;
|
|
25
|
+
var SEGMENT_BYTES_LIMIT = 60000; // Segments are the main data structure for session replays. They contain context information used
|
|
26
|
+
// for indexing or UI needs, and a list of records (RRWeb 'events', renamed to avoid confusing
|
|
27
|
+
// namings). They are stored without any processing from the intake, and fetched one after the
|
|
28
|
+
// other while a session is being replayed. Their encoding (deflate) are carefully crafted to allow
|
|
29
|
+
// concatenating multiple segments together. Segments have a size overhead (metadata), so our goal is to
|
|
30
|
+
// build segments containing as many records as possible while complying with the various flush
|
|
31
|
+
// strategies to guarantee a good replay quality.
|
|
32
|
+
//
|
|
33
|
+
// When the recording starts, a segment is initially created. The segment is flushed (finalized and
|
|
34
|
+
// sent) based on various events (non-exhaustive list):
|
|
35
|
+
//
|
|
36
|
+
// * the page visibility change or becomes to unload
|
|
37
|
+
// * the segment duration reaches a limit
|
|
38
|
+
// * the encoded segment bytes count reaches a limit
|
|
39
|
+
// * ...
|
|
40
|
+
//
|
|
41
|
+
// A segment cannot be created without its context. If the RUM session ends and no session id is
|
|
42
|
+
// available when creating a new segment, records will be ignored, until the session is renewed and
|
|
43
|
+
// a new session id is available.
|
|
44
|
+
//
|
|
45
|
+
// Empty segments (segments with no record) aren't useful and should be ignored.
|
|
46
|
+
//
|
|
47
|
+
// To help investigate session replays issues, each segment is created with a "creation reason",
|
|
48
|
+
// indicating why the session has been created.
|
|
49
|
+
|
|
50
|
+
exports.SEGMENT_BYTES_LIMIT = SEGMENT_BYTES_LIMIT;
|
|
51
|
+
|
|
52
|
+
function startSegmentCollection(lifeCycle, configuration, sessionManager, viewContexts, httpRequest, worker) {
|
|
53
|
+
return doStartSegmentCollection(lifeCycle, function () {
|
|
54
|
+
return computeSegmentContext(configuration, sessionManager, viewContexts);
|
|
55
|
+
}, httpRequest, worker);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var SegmentCollectionStatus = {
|
|
59
|
+
WaitingForInitialRecord: 0,
|
|
60
|
+
SegmentPending: 1,
|
|
61
|
+
Stopped: 2
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, worker) {
|
|
65
|
+
var state = {
|
|
66
|
+
status: SegmentCollectionStatus.WaitingForInitialRecord,
|
|
67
|
+
nextSegmentCreationReason: 'init'
|
|
68
|
+
};
|
|
69
|
+
var subscribeViewCreated = lifeCycle.subscribe(_browserCore.LifeCycleEventType.VIEW_CREATED, function () {
|
|
70
|
+
flushSegment('view_change');
|
|
71
|
+
});
|
|
72
|
+
var unsubscribeViewCreated = subscribeViewCreated.unsubscribe;
|
|
73
|
+
var subscribePageExited = lifeCycle.subscribe(_browserCore.LifeCycleEventType.PAGE_EXITED, function (pageExitEvent) {
|
|
74
|
+
flushSegment(pageExitEvent.reason);
|
|
75
|
+
});
|
|
76
|
+
var unsubscribePageExited = subscribePageExited.unsubscribe;
|
|
77
|
+
|
|
78
|
+
function flushSegment(flushReason) {
|
|
79
|
+
if (state.status === SegmentCollectionStatus.SegmentPending) {
|
|
80
|
+
state.segment.flush(flushReason);
|
|
81
|
+
clearTimeout(state.expirationTimeoutId);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (flushReason !== 'stop') {
|
|
85
|
+
state = {
|
|
86
|
+
status: SegmentCollectionStatus.WaitingForInitialRecord,
|
|
87
|
+
nextSegmentCreationReason: flushReason
|
|
88
|
+
};
|
|
89
|
+
} else {
|
|
90
|
+
state = {
|
|
91
|
+
status: SegmentCollectionStatus.Stopped
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function createNewSegment(creationReason, initialRecord) {
|
|
97
|
+
var context = getSegmentContext();
|
|
98
|
+
|
|
99
|
+
if (!context) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
var segment = new _segment.Segment(worker, context, creationReason, initialRecord, function (compressedSegmentBytesCount) {
|
|
104
|
+
if (!segment.flushReason && compressedSegmentBytesCount > SEGMENT_BYTES_LIMIT) {
|
|
105
|
+
flushSegment('segment_bytes_limit');
|
|
106
|
+
}
|
|
107
|
+
}, function (data, rawSegmentBytesCount) {
|
|
108
|
+
var payload = (0, _buildReplayPayload.buildReplayPayload)(data, segment.metadata, rawSegmentBytesCount);
|
|
109
|
+
|
|
110
|
+
if ((0, _browserCore.isPageExitReason)(segment.flushReason)) {
|
|
111
|
+
httpRequest.sendOnExit(payload);
|
|
112
|
+
} else {
|
|
113
|
+
httpRequest.send(payload);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
state = {
|
|
117
|
+
status: SegmentCollectionStatus.SegmentPending,
|
|
118
|
+
segment: segment,
|
|
119
|
+
expirationTimeoutId: setTimeout(function () {
|
|
120
|
+
flushSegment('segment_duration_limit');
|
|
121
|
+
}, SEGMENT_DURATION_LIMIT)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
addRecord: function addRecord(record) {
|
|
127
|
+
switch (state.status) {
|
|
128
|
+
case SegmentCollectionStatus.WaitingForInitialRecord:
|
|
129
|
+
createNewSegment(state.nextSegmentCreationReason, record);
|
|
130
|
+
break;
|
|
131
|
+
|
|
132
|
+
case SegmentCollectionStatus.SegmentPending:
|
|
133
|
+
state.segment.addRecord(record);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
stop: function stop() {
|
|
138
|
+
flushSegment('stop');
|
|
139
|
+
unsubscribeViewCreated();
|
|
140
|
+
unsubscribePageExited();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function computeSegmentContext(configuration, sessionManager, viewContexts) {
|
|
146
|
+
var session = sessionManager.findTrackedSession();
|
|
147
|
+
var viewContext = viewContexts.findView();
|
|
148
|
+
|
|
149
|
+
if (!session || !viewContext) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
sdk: {
|
|
155
|
+
name: configuration.sdkName,
|
|
156
|
+
version: configuration.sdkVersion
|
|
157
|
+
},
|
|
158
|
+
env: configuration.env || '',
|
|
159
|
+
service: viewContext.service || configuration.service || 'browser',
|
|
160
|
+
version: viewContext.version || configuration.version || '',
|
|
161
|
+
app: {
|
|
162
|
+
id: configuration.applicationId
|
|
163
|
+
},
|
|
164
|
+
session: {
|
|
165
|
+
id: session.id
|
|
166
|
+
},
|
|
167
|
+
view: {
|
|
168
|
+
id: viewContext.id
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function setSegmentBytesLimit(newSegmentBytesLimit) {
|
|
174
|
+
if (newSegmentBytesLimit === undefined) {
|
|
175
|
+
newSegmentBytesLimit = 60000;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
exports.SEGMENT_BYTES_LIMIT = SEGMENT_BYTES_LIMIT = newSegmentBytesLimit;
|
|
179
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.doStartDeflateWorker = doStartDeflateWorker;
|
|
7
|
+
exports.resetDeflateWorkerState = resetDeflateWorkerState;
|
|
8
|
+
exports.startDeflateWorker = startDeflateWorker;
|
|
9
|
+
|
|
10
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
+
|
|
12
|
+
var _deflateWorker = require("./deflateWorker");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* In order to be sure that the worker is correctly working, we need a round trip of
|
|
16
|
+
* initialization messages, making the creation asynchronous.
|
|
17
|
+
* These worker lifecycle states handle this case.
|
|
18
|
+
*/
|
|
19
|
+
var DeflateWorkerStatus = {
|
|
20
|
+
Nil: 0,
|
|
21
|
+
Loading: 1,
|
|
22
|
+
Error: 2,
|
|
23
|
+
Initialized: 3
|
|
24
|
+
};
|
|
25
|
+
var state = {
|
|
26
|
+
status: DeflateWorkerStatus.Nil
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function startDeflateWorker(callback, createDeflateWorkerImpl) {
|
|
30
|
+
if (createDeflateWorkerImpl === undefined) {
|
|
31
|
+
createDeflateWorkerImpl = _deflateWorker.createDeflateWorker;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
switch (state.status) {
|
|
35
|
+
case DeflateWorkerStatus.Nil:
|
|
36
|
+
state = {
|
|
37
|
+
status: DeflateWorkerStatus.Loading,
|
|
38
|
+
callbacks: [callback]
|
|
39
|
+
};
|
|
40
|
+
doStartDeflateWorker(createDeflateWorkerImpl);
|
|
41
|
+
break;
|
|
42
|
+
|
|
43
|
+
case DeflateWorkerStatus.Loading:
|
|
44
|
+
state.callbacks.push(callback);
|
|
45
|
+
break;
|
|
46
|
+
|
|
47
|
+
case DeflateWorkerStatus.Error:
|
|
48
|
+
callback();
|
|
49
|
+
break;
|
|
50
|
+
|
|
51
|
+
case DeflateWorkerStatus.Initialized:
|
|
52
|
+
callback(state.worker);
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function resetDeflateWorkerState() {
|
|
58
|
+
state = {
|
|
59
|
+
status: DeflateWorkerStatus.Nil
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Starts the deflate worker and handle messages and errors
|
|
64
|
+
*
|
|
65
|
+
* The spec allow browsers to handle worker errors differently:
|
|
66
|
+
* - Chromium throws an exception
|
|
67
|
+
* - Firefox fires an error event
|
|
68
|
+
*
|
|
69
|
+
* more details: https://bugzilla.mozilla.org/show_bug.cgi?id=1736865#c2
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
function doStartDeflateWorker(createDeflateWorkerImpl) {
|
|
74
|
+
if (createDeflateWorkerImpl === undefined) {
|
|
75
|
+
createDeflateWorkerImpl = _deflateWorker.createDeflateWorker;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
var worker = createDeflateWorkerImpl();
|
|
80
|
+
worker.addEventListener('error', onError);
|
|
81
|
+
worker.addEventListener('message', function (event) {
|
|
82
|
+
var data = event.data;
|
|
83
|
+
|
|
84
|
+
if (data.type === 'errored') {
|
|
85
|
+
onError(data.error);
|
|
86
|
+
} else if (data.type === 'initialized') {
|
|
87
|
+
onInitialized(worker);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
worker.postMessage({
|
|
91
|
+
action: 'init'
|
|
92
|
+
});
|
|
93
|
+
return worker;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.errror('====doStartDeflateWorker', error);
|
|
96
|
+
onError(error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function onInitialized(worker) {
|
|
101
|
+
if (state.status === DeflateWorkerStatus.Loading) {
|
|
102
|
+
(0, _browserCore.each)(state.callbacks, function (callback) {
|
|
103
|
+
callback(worker);
|
|
104
|
+
});
|
|
105
|
+
state = {
|
|
106
|
+
status: DeflateWorkerStatus.Initialized,
|
|
107
|
+
worker: worker
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function onError(error) {
|
|
113
|
+
if (state.status === DeflateWorkerStatus.Loading) {
|
|
114
|
+
_browserCore.display.error('Session Replay recording failed to start: an error occurred while creating the Worker:', error);
|
|
115
|
+
|
|
116
|
+
if (error instanceof Event || error instanceof Error && (0, _browserCore.includes)(error.message, 'Content Security Policy')) {
|
|
117
|
+
_browserCore.display.error('Please make sure CSP is correctly configured !!!');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
(0, _browserCore.each)(state.callbacks, function (callback) {
|
|
121
|
+
callback();
|
|
122
|
+
});
|
|
123
|
+
state = {
|
|
124
|
+
status: DeflateWorkerStatus.Error
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -82,23 +82,25 @@ function trackFetch(lifeCycle, configuration, tracer) {
|
|
|
82
82
|
});
|
|
83
83
|
break;
|
|
84
84
|
|
|
85
|
-
case '
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
85
|
+
case 'resolve':
|
|
86
|
+
waitForResponseToComplete(context, function (duration) {
|
|
87
|
+
tracer.clearTracingIfNeeded(context);
|
|
88
|
+
lifeCycle.notify(_browserCore.LifeCycleEventType.REQUEST_COMPLETED, {
|
|
89
|
+
duration: duration,
|
|
90
|
+
method: context.method,
|
|
91
|
+
requestIndex: context.requestIndex,
|
|
92
|
+
responseType: context.responseType,
|
|
93
|
+
spanId: context.spanId,
|
|
94
|
+
startClocks: context.startClocks,
|
|
95
|
+
status: context.status,
|
|
96
|
+
traceId: context.traceId,
|
|
97
|
+
traceSampled: context.traceSampled,
|
|
98
|
+
type: _browserCore.RequestType.FETCH,
|
|
99
|
+
url: context.url,
|
|
100
|
+
response: context.response,
|
|
101
|
+
init: context.init,
|
|
102
|
+
input: context.input
|
|
103
|
+
});
|
|
102
104
|
});
|
|
103
105
|
break;
|
|
104
106
|
}
|
|
@@ -114,4 +116,20 @@ function getNextRequestIndex() {
|
|
|
114
116
|
var result = nextRequestIndex;
|
|
115
117
|
nextRequestIndex += 1;
|
|
116
118
|
return result;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function waitForResponseToComplete(context, callback) {
|
|
122
|
+
var clonedResponse = context.response && (0, _browserCore.tryToClone)(context.response);
|
|
123
|
+
|
|
124
|
+
if (!clonedResponse || !clonedResponse.body) {
|
|
125
|
+
// do not try to wait for the response if the clone failed, fetch error or null body
|
|
126
|
+
callback((0, _browserCore.elapsed)(context.startClocks.timeStamp, (0, _browserCore.timeStampNow)()));
|
|
127
|
+
} else {
|
|
128
|
+
(0, _browserCore.readBytesFromStream)(clonedResponse.body, function () {
|
|
129
|
+
callback((0, _browserCore.elapsed)(context.startClocks.timeStamp, (0, _browserCore.timeStampNow)()));
|
|
130
|
+
}, {
|
|
131
|
+
bytesLimit: Number.POSITIVE_INFINITY,
|
|
132
|
+
collectStreamBody: false
|
|
133
|
+
});
|
|
134
|
+
}
|
|
117
135
|
}
|
|
@@ -9,9 +9,9 @@ var _browserCore = require("@cloudcare/browser-core");
|
|
|
9
9
|
|
|
10
10
|
var _trackClickActions = require("./trackClickActions");
|
|
11
11
|
|
|
12
|
-
function startActionCollection(lifeCycle, domMutationObservable, configuration) {
|
|
12
|
+
function startActionCollection(lifeCycle, domMutationObservable, configuration, foregroundContexts) {
|
|
13
13
|
lifeCycle.subscribe(_browserCore.LifeCycleEventType.AUTO_ACTION_COMPLETED, function (action) {
|
|
14
|
-
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action));
|
|
14
|
+
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processAction(action, foregroundContexts));
|
|
15
15
|
});
|
|
16
16
|
var actionContexts = {
|
|
17
17
|
findActionId: _browserCore.noop
|
|
@@ -26,12 +26,12 @@ function startActionCollection(lifeCycle, domMutationObservable, configuration)
|
|
|
26
26
|
addAction: function addAction(action, savedCommonContext) {
|
|
27
27
|
lifeCycle.notify(_browserCore.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, (0, _browserCore.extend)({
|
|
28
28
|
savedCommonContext: savedCommonContext
|
|
29
|
-
}, processAction(action)));
|
|
29
|
+
}, processAction(action, foregroundContexts)));
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
function processAction(action) {
|
|
34
|
+
function processAction(action, foregroundContexts) {
|
|
35
35
|
var autoActionProperties = isAutoAction(action) ? {
|
|
36
36
|
action: {
|
|
37
37
|
error: {
|
|
@@ -72,6 +72,14 @@ function processAction(action) {
|
|
|
72
72
|
date: action.startClocks.timeStamp,
|
|
73
73
|
type: _browserCore.RumEventType.ACTION
|
|
74
74
|
}, autoActionProperties);
|
|
75
|
+
var inForeground = foregroundContexts.isInForegroundAt(action.startClocks.relative);
|
|
76
|
+
|
|
77
|
+
if (inForeground !== undefined) {
|
|
78
|
+
actionEvent.view = {
|
|
79
|
+
in_foreground: inForeground
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
75
83
|
return {
|
|
76
84
|
customerContext: customerContext,
|
|
77
85
|
rawRumEvent: actionEvent,
|
|
@@ -13,9 +13,9 @@ exports.MAX_DURATION_BETWEEN_CLICKS = MAX_DURATION_BETWEEN_CLICKS;
|
|
|
13
13
|
var MAX_DISTANCE_BETWEEN_CLICKS = 100;
|
|
14
14
|
exports.MAX_DISTANCE_BETWEEN_CLICKS = MAX_DISTANCE_BETWEEN_CLICKS;
|
|
15
15
|
var ClickChainStatus = {
|
|
16
|
-
WaitingForMoreClicks:
|
|
17
|
-
WaitingForClicksToStop:
|
|
18
|
-
Finalized:
|
|
16
|
+
WaitingForMoreClicks: 0,
|
|
17
|
+
WaitingForClicksToStop: 1,
|
|
18
|
+
Finalized: 2
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
function createClickChain(firstClick, onFinalize) {
|
|
@@ -15,11 +15,11 @@ function computeFrustration(clicks, rageClick) {
|
|
|
15
15
|
if (isRage(clicks)) {
|
|
16
16
|
rageClick.addFrustration(_browserCore.FrustrationType.RAGE_CLICK);
|
|
17
17
|
|
|
18
|
-
if (
|
|
18
|
+
if ((0, _browserCore.some)(clicks, isDead)) {
|
|
19
19
|
rageClick.addFrustration(_browserCore.FrustrationType.DEAD_CLICK);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
if (rageClick.hasError) {
|
|
22
|
+
if (rageClick.hasError()) {
|
|
23
23
|
rageClick.addFrustration(_browserCore.FrustrationType.ERROR_CLICK);
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -32,7 +32,7 @@ function computeFrustration(clicks, rageClick) {
|
|
|
32
32
|
return click.getUserActivity().selection;
|
|
33
33
|
});
|
|
34
34
|
(0, _browserCore.each)(clicks, function (click) {
|
|
35
|
-
if (click.hasError) {
|
|
35
|
+
if (click.hasError()) {
|
|
36
36
|
click.addFrustration(_browserCore.FrustrationType.ERROR_CLICK);
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -64,13 +64,14 @@ function isRage(clicks) {
|
|
|
64
64
|
|
|
65
65
|
var DEAD_CLICK_EXCLUDE_SELECTOR = // inputs that don't trigger a meaningful event like "input" when clicked, including textual
|
|
66
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,' + //
|
|
67
|
+
'input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="range"]),' + 'textarea,' + 'select,' + // contenteditable and their descendants don't always trigger meaningful changes when manipulated
|
|
68
|
+
'[contenteditable],' + '[contenteditable] *,' + // canvas, as there is no good way to detect activity occurring on them
|
|
68
69
|
'canvas,' + // links that are interactive (have an href attribute) or any of their descendants, as they can
|
|
69
70
|
// open a new tab or navigate to a hash without triggering a meaningful event
|
|
70
71
|
'a[href],' + 'a[href] *';
|
|
71
72
|
|
|
72
73
|
function isDead(click) {
|
|
73
|
-
if (click.hasPageActivity || click.getUserActivity().input) {
|
|
74
|
+
if (click.hasPageActivity() || click.getUserActivity().input) {
|
|
74
75
|
return false;
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE = void 0;
|
|
6
7
|
exports.getActionNameFromElement = getActionNameFromElement;
|
|
7
8
|
|
|
8
9
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
10
|
|
|
10
|
-
var
|
|
11
|
+
var DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE = 'data-guance-action-name';
|
|
12
|
+
exports.DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE = DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE;
|
|
11
13
|
|
|
12
14
|
function getActionNameFromElement(element, userProgrammaticAttribute) {
|
|
13
15
|
// Proceed to get the action name in two steps:
|
|
@@ -16,7 +18,7 @@ function getActionNameFromElement(element, userProgrammaticAttribute) {
|
|
|
16
18
|
// the element and a few parents, but it's likely that they won't succeed at all.
|
|
17
19
|
// * if no name is found this way, use strategies returning less accurate names as a fallback.
|
|
18
20
|
// Those are much likely to succeed.
|
|
19
|
-
return getActionNameFromElementProgrammatically(element,
|
|
21
|
+
return getActionNameFromElementProgrammatically(element, DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE) || userProgrammaticAttribute && getActionNameFromElementProgrammatically(element, userProgrammaticAttribute) || getActionNameFromElementForStrategies(element, userProgrammaticAttribute, priorityStrategies) || getActionNameFromElementForStrategies(element, userProgrammaticAttribute, fallbackStrategies) || '';
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
function getActionNameFromElementProgrammatically(targetElement, programmaticAttribute) {
|
|
@@ -92,7 +94,7 @@ function (element, userProgrammaticAttribute) {
|
|
|
92
94
|
return Boolean(label);
|
|
93
95
|
});
|
|
94
96
|
labelledByAttribute = (0, _browserCore.map)(labelledByAttribute, function (ele) {
|
|
95
|
-
return getTextualContent(ele);
|
|
97
|
+
return getTextualContent(ele, userProgrammaticAttribute);
|
|
96
98
|
});
|
|
97
99
|
return labelledByAttribute.join(' ');
|
|
98
100
|
}
|
|
@@ -105,9 +107,9 @@ function (element, userProgrammaticAttribute) {
|
|
|
105
107
|
}, function (element) {
|
|
106
108
|
return element.getAttribute('placeholder');
|
|
107
109
|
}, // SELECT first OPTION text
|
|
108
|
-
function (element) {
|
|
110
|
+
function (element, userProgrammaticAttribute) {
|
|
109
111
|
if ('options' in element && element.options.length > 0) {
|
|
110
|
-
return getTextualContent(element.options[0]);
|
|
112
|
+
return getTextualContent(element.options[0], userProgrammaticAttribute);
|
|
111
113
|
}
|
|
112
114
|
}];
|
|
113
115
|
var fallbackStrategies = [function (element, userProgrammaticAttribute) {
|
|
@@ -194,7 +196,7 @@ function getTextualContent(element, userProgrammaticAttribute) {
|
|
|
194
196
|
} // remove the text of elements with programmatic attribute value
|
|
195
197
|
|
|
196
198
|
|
|
197
|
-
removeTextFromElements('[' +
|
|
199
|
+
removeTextFromElements('[' + DEFAULT_PROGRAMMATIC_ACTION_NAME_ATTRIBUTE + ']');
|
|
198
200
|
|
|
199
201
|
if (userProgrammaticAttribute) {
|
|
200
202
|
removeTextFromElements('[' + userProgrammaticAttribute + ']');
|