@cloudcare/browser-rum 3.0.6 → 3.0.8
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 +1 -1
- package/cjs/boot/rum.js +16 -7
- package/cjs/boot/rumPublicApi.js +27 -55
- package/cjs/domain/assembly.js +2 -2
- package/cjs/domain/contexts/commonContext.js +14 -0
- package/cjs/domain/performanceCollection.js +3 -3
- package/cjs/domain/replay/record/serialize.js +7 -5
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +2 -2
- package/cjs/domain/replay/segmentCollection/startDeflateWorker.js +2 -2
- package/cjs/domain/rumEventsCollection/actions/clickChain.js +3 -3
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +0 -1
- package/cjs/domain/rumEventsCollection/view/trackFirstHidden.js +4 -4
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +42 -18
- package/cjs/domain/rumEventsCollection/view/trackViewEventCounts.js +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +45 -67
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +2 -1
- package/cjs/domain/rumSessionManager.js +3 -1
- package/cjs/domain/tracing/getDocumentTraceId.js +1 -1
- package/cjs/domain/waitPageActivityEnd.js +9 -9
- package/cjs/transport/startRumBatch.js +20 -6
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/recorderApi.js +1 -1
- package/esm/boot/rum.js +15 -7
- package/esm/boot/rumPublicApi.js +25 -54
- package/esm/domain/assembly.js +2 -2
- package/esm/domain/contexts/commonContext.js +7 -0
- package/esm/domain/performanceCollection.js +2 -2
- package/esm/domain/replay/record/serialize.js +7 -5
- package/esm/domain/replay/segmentCollection/segmentCollection.js +1 -1
- package/esm/domain/replay/segmentCollection/startDeflateWorker.js +3 -3
- package/esm/domain/rumEventsCollection/actions/clickChain.js +1 -1
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +0 -1
- package/esm/domain/rumEventsCollection/view/trackFirstHidden.js +4 -4
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +39 -16
- package/esm/domain/rumEventsCollection/view/trackViewEventCounts.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +46 -68
- package/esm/domain/rumEventsCollection/view/viewCollection.js +2 -1
- package/esm/domain/rumSessionManager.js +3 -1
- package/esm/domain/tracing/getDocumentTraceId.js +1 -1
- package/esm/domain/waitPageActivityEnd.js +3 -3
- package/esm/transport/startRumBatch.js +21 -7
- package/package.json +31 -31
- package/src/boot/recorderApi.js +1 -0
- package/src/boot/rum.js +29 -9
- package/src/boot/rumPublicApi.js +37 -51
- package/src/domain/assembly.js +2 -2
- package/src/domain/contexts/commonContext.js +11 -0
- package/src/domain/performanceCollection.js +4 -2
- package/src/domain/replay/record/serialize.js +6 -5
- package/src/domain/replay/segmentCollection/segmentCollection.js +3 -1
- package/src/domain/replay/segmentCollection/startDeflateWorker.js +8 -3
- package/src/domain/rumEventsCollection/actions/clickChain.js +6 -1
- package/src/domain/rumEventsCollection/actions/getActionNameFromElement.js +0 -1
- package/src/domain/rumEventsCollection/view/trackFirstHidden.js +4 -4
- package/src/domain/rumEventsCollection/view/trackInitialViewTimings.js +53 -17
- package/src/domain/rumEventsCollection/view/trackViewEventCounts.js +1 -1
- package/src/domain/rumEventsCollection/view/trackViews.js +69 -77
- package/src/domain/rumEventsCollection/view/viewCollection.js +2 -1
- package/src/domain/rumSessionManager.js +3 -1
- package/src/domain/tracing/getDocumentTraceId.js +1 -1
- package/src/domain/waitPageActivityEnd.js +8 -5
- package/src/transport/startRumBatch.js +35 -12
|
@@ -20,66 +20,37 @@ var SESSION_KEEP_ALIVE_INTERVAL = 5 * _browserCore.ONE_MINUTE;
|
|
|
20
20
|
exports.SESSION_KEEP_ALIVE_INTERVAL = SESSION_KEEP_ALIVE_INTERVAL;
|
|
21
21
|
|
|
22
22
|
function trackViews(location, lifeCycle, domMutationObservable, configuration, locationChangeObservable, areViewsTrackedAutomatically, initialViewOptions) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var initialView = _trackInitialView.initialView;
|
|
27
|
-
var currentView = initialView;
|
|
28
|
-
|
|
29
|
-
var _startViewLifeCycle = startViewLifeCycle();
|
|
23
|
+
function startNewView(loadingType, startClocks, viewOptions) {
|
|
24
|
+
return newView(lifeCycle, domMutationObservable, configuration, location, loadingType, startClocks, viewOptions);
|
|
25
|
+
}
|
|
30
26
|
|
|
31
|
-
var
|
|
27
|
+
var currentView = startNewView(_browserCore.ViewLoadingType.INITIAL_LOAD, (0, _browserCore.clocksOrigin)(), initialViewOptions);
|
|
28
|
+
startViewLifeCycle();
|
|
32
29
|
var locationChangeSubscription;
|
|
33
30
|
|
|
34
31
|
if (areViewsTrackedAutomatically) {
|
|
35
32
|
locationChangeSubscription = renewViewOnLocationChange(locationChangeObservable);
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
function trackInitialView(options) {
|
|
39
|
-
var initialView = newView(lifeCycle, domMutationObservable, configuration, location, _browserCore.ViewLoadingType.INITIAL_LOAD, (0, _browserCore.clocksOrigin)(), options);
|
|
40
|
-
|
|
41
|
-
var _trackInitialViewTimings = (0, _trackInitialViewTimings2.trackInitialViewTimings)(lifeCycle, function (timings) {
|
|
42
|
-
initialView.updateTimings(timings);
|
|
43
|
-
initialView.scheduleUpdate();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
initialView: initialView,
|
|
48
|
-
stop: _trackInitialViewTimings.stop
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function trackViewChange(startClocks, viewOptions) {
|
|
53
|
-
return newView(lifeCycle, domMutationObservable, configuration, location, _browserCore.ViewLoadingType.ROUTE_CHANGE, startClocks, viewOptions);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
35
|
function startViewLifeCycle() {
|
|
57
36
|
lifeCycle.subscribe(_browserCore.LifeCycleEventType.SESSION_RENEWED, function () {
|
|
58
|
-
|
|
59
|
-
currentView.end(); // Renew view on session renewal
|
|
60
|
-
|
|
61
|
-
currentView = trackViewChange(undefined, {
|
|
37
|
+
startNewView(_browserCore.ViewLoadingType.ROUTE_CHANGE, undefined, {
|
|
62
38
|
name: currentView.name,
|
|
63
39
|
service: currentView.service,
|
|
64
40
|
version: currentView.version
|
|
65
41
|
});
|
|
42
|
+
});
|
|
43
|
+
lifeCycle.subscribe(_browserCore.LifeCycleEventType.SESSION_EXPIRED, function () {
|
|
44
|
+
currentView.end({
|
|
45
|
+
sessionIsActive: false
|
|
46
|
+
});
|
|
66
47
|
}); // End the current view on page unload
|
|
67
48
|
|
|
68
49
|
lifeCycle.subscribe(_browserCore.LifeCycleEventType.PAGE_EXITED, function (pageExitEvent) {
|
|
69
50
|
if (pageExitEvent.reason === _browserCore.PageExitReason.UNLOADING || pageExitEvent.reason === _browserCore.PageExitReason.PAGEHIDE) {
|
|
70
51
|
currentView.end();
|
|
71
|
-
currentView.triggerUpdate();
|
|
72
|
-
}
|
|
73
|
-
}); // Session keep alive
|
|
74
|
-
|
|
75
|
-
var keepAliveInterval = window.setInterval(function () {
|
|
76
|
-
currentView.triggerUpdate();
|
|
77
|
-
}, SESSION_KEEP_ALIVE_INTERVAL);
|
|
78
|
-
return {
|
|
79
|
-
stop: function stop() {
|
|
80
|
-
clearInterval(keepAliveInterval);
|
|
81
52
|
}
|
|
82
|
-
};
|
|
53
|
+
});
|
|
83
54
|
}
|
|
84
55
|
|
|
85
56
|
function renewViewOnLocationChange(locationChangeObservable) {
|
|
@@ -89,8 +60,7 @@ function trackViews(location, lifeCycle, domMutationObservable, configuration, l
|
|
|
89
60
|
|
|
90
61
|
if (areDifferentLocation(oldLocation, newLocation)) {
|
|
91
62
|
currentView.end();
|
|
92
|
-
currentView.
|
|
93
|
-
currentView = trackViewChange();
|
|
63
|
+
currentView = startNewView(_browserCore.ViewLoadingType.ROUTE_CHANGE);
|
|
94
64
|
return;
|
|
95
65
|
}
|
|
96
66
|
});
|
|
@@ -103,20 +73,18 @@ function trackViews(location, lifeCycle, domMutationObservable, configuration, l
|
|
|
103
73
|
}
|
|
104
74
|
|
|
105
75
|
currentView.addTiming(name, time);
|
|
106
|
-
currentView.scheduleUpdate();
|
|
107
76
|
},
|
|
108
77
|
startView: function startView(options, startClocks) {
|
|
109
|
-
currentView.end(
|
|
110
|
-
|
|
111
|
-
|
|
78
|
+
currentView.end({
|
|
79
|
+
endClocks: startClocks
|
|
80
|
+
});
|
|
81
|
+
currentView = startNewView(_browserCore.ViewLoadingType.ROUTE_CHANGE, startClocks, options);
|
|
112
82
|
},
|
|
113
83
|
stop: function stop() {
|
|
114
84
|
if (locationChangeSubscription) {
|
|
115
85
|
locationChangeSubscription.unsubscribe();
|
|
116
86
|
}
|
|
117
87
|
|
|
118
|
-
stopInitialViewTracking();
|
|
119
|
-
stopViewLifeCycle();
|
|
120
88
|
currentView.end();
|
|
121
89
|
}
|
|
122
90
|
};
|
|
@@ -129,11 +97,11 @@ function newView(lifeCycle, domMutationObservable, configuration, initialLocatio
|
|
|
129
97
|
}
|
|
130
98
|
|
|
131
99
|
var id = (0, _browserCore.UUID)();
|
|
132
|
-
var timings = {};
|
|
133
100
|
var customTimings = {};
|
|
134
101
|
var documentVersion = 0;
|
|
135
102
|
var endClocks;
|
|
136
103
|
var location = (0, _browserCore.shallowClone)(initialLocation);
|
|
104
|
+
var sessionIsActive = true;
|
|
137
105
|
var name;
|
|
138
106
|
var service;
|
|
139
107
|
var version;
|
|
@@ -165,14 +133,25 @@ function newView(lifeCycle, domMutationObservable, configuration, initialLocatio
|
|
|
165
133
|
var stopViewMetricsTracking = _trackViewMetrics.stop;
|
|
166
134
|
var viewMetrics = _trackViewMetrics.viewMetrics;
|
|
167
135
|
|
|
136
|
+
var _trackInitialViewTimings = loadingType === _browserCore.ViewLoadingType.INITIAL_LOAD ? (0, _trackInitialViewTimings2.trackInitialViewTimings)(lifeCycle, setLoadEvent, scheduleViewUpdate) : {
|
|
137
|
+
scheduleStop: _browserCore.noop,
|
|
138
|
+
timings: {}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
var scheduleStopInitialViewTimingsTracking = _trackInitialViewTimings.scheduleStop;
|
|
142
|
+
var timings = _trackInitialViewTimings.timings;
|
|
143
|
+
|
|
168
144
|
var _trackViewEventCounts = (0, _trackViewEventCounts2.trackViewEventCounts)(lifeCycle, id, scheduleViewUpdate);
|
|
169
145
|
|
|
170
146
|
var scheduleStopEventCountsTracking = _trackViewEventCounts.scheduleStop;
|
|
171
|
-
var eventCounts = _trackViewEventCounts.eventCounts; //
|
|
147
|
+
var eventCounts = _trackViewEventCounts.eventCounts; // Session keep alive
|
|
148
|
+
|
|
149
|
+
var keepAliveIntervalId = (0, _browserCore.setInterval)(triggerViewUpdate, SESSION_KEEP_ALIVE_INTERVAL); // Initial view update
|
|
172
150
|
|
|
173
151
|
triggerViewUpdate();
|
|
174
152
|
|
|
175
153
|
function triggerViewUpdate() {
|
|
154
|
+
cancelScheduleViewUpdate();
|
|
176
155
|
documentVersion += 1;
|
|
177
156
|
var currentEnd = endClocks === undefined ? (0, _browserCore.timeStampNow)() : endClocks.timeStamp;
|
|
178
157
|
lifeCycle.notify(_browserCore.LifeCycleEventType.VIEW_UPDATED, (0, _browserCore.assign)({
|
|
@@ -188,6 +167,7 @@ function newView(lifeCycle, domMutationObservable, configuration, initialLocatio
|
|
|
188
167
|
timings: timings,
|
|
189
168
|
duration: (0, _browserCore.elapsed)(startClocks.timeStamp, currentEnd),
|
|
190
169
|
isActive: endClocks === undefined,
|
|
170
|
+
sessionIsActive: sessionIsActive,
|
|
191
171
|
eventCounts: eventCounts
|
|
192
172
|
}, viewMetrics));
|
|
193
173
|
}
|
|
@@ -197,33 +177,31 @@ function newView(lifeCycle, domMutationObservable, configuration, initialLocatio
|
|
|
197
177
|
service: service,
|
|
198
178
|
version: version,
|
|
199
179
|
scheduleUpdate: scheduleViewUpdate,
|
|
200
|
-
end: function end(
|
|
201
|
-
if (
|
|
202
|
-
|
|
180
|
+
end: function end(options) {
|
|
181
|
+
if (endClocks) {
|
|
182
|
+
// view already ended
|
|
183
|
+
return;
|
|
203
184
|
}
|
|
204
185
|
|
|
205
|
-
endClocks =
|
|
186
|
+
endClocks = (0, _browserCore.isNullUndefinedDefaultValue)(options && options.endClocks, (0, _browserCore.clocksNow)());
|
|
187
|
+
sessionIsActive = (0, _browserCore.isNullUndefinedDefaultValue)(options && options.sessionIsActive, true);
|
|
206
188
|
lifeCycle.notify(_browserCore.LifeCycleEventType.VIEW_ENDED, {
|
|
207
189
|
endClocks: endClocks
|
|
208
190
|
});
|
|
191
|
+
(0, _browserCore.clearInterval)(keepAliveIntervalId);
|
|
209
192
|
stopViewMetricsTracking();
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
triggerUpdate: function triggerUpdate() {
|
|
213
|
-
// cancel any pending view updates execution
|
|
214
|
-
cancelScheduleViewUpdate();
|
|
193
|
+
scheduleStopInitialViewTimingsTracking();
|
|
194
|
+
scheduleStopEventCountsTracking();
|
|
215
195
|
triggerViewUpdate();
|
|
216
196
|
},
|
|
217
|
-
updateTimings: function updateTimings(newTimings) {
|
|
218
|
-
timings = newTimings;
|
|
219
|
-
|
|
220
|
-
if (newTimings.loadEvent !== undefined) {
|
|
221
|
-
setLoadEvent(newTimings.loadEvent);
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
197
|
addTiming: function addTiming(name, time) {
|
|
198
|
+
if (endClocks) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
225
202
|
var relativeTime = (0, _browserCore.looksLikeRelativeTime)(time) ? time : (0, _browserCore.elapsed)(startClocks.timeStamp, time);
|
|
226
203
|
customTimings[sanitizeTiming(name)] = relativeTime;
|
|
204
|
+
scheduleViewUpdate();
|
|
227
205
|
}
|
|
228
206
|
};
|
|
229
207
|
}
|
|
@@ -111,7 +111,8 @@ function processViewUpdate(view, foregroundContexts, recorderApi) {
|
|
|
111
111
|
in_foreground_periods: foregroundContexts.selectInForegroundPeriodsFor(view.startClocks.relative, view.duration)
|
|
112
112
|
},
|
|
113
113
|
session: {
|
|
114
|
-
has_replay: replayStats ? true : undefined
|
|
114
|
+
has_replay: replayStats ? true : undefined,
|
|
115
|
+
is_active: view.sessionIsActive ? undefined : false
|
|
115
116
|
}
|
|
116
117
|
};
|
|
117
118
|
|
|
@@ -50,7 +50,9 @@ function startRumSessionManager(configuration, lifeCycle) {
|
|
|
50
50
|
plan: plan,
|
|
51
51
|
sessionReplayAllowed: plan === RumSessionPlan.WITH_SESSION_REPLAY
|
|
52
52
|
};
|
|
53
|
-
}
|
|
53
|
+
},
|
|
54
|
+
expire: sessionManager.expire,
|
|
55
|
+
expireObservable: sessionManager.expireObservable
|
|
54
56
|
};
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
@@ -89,7 +89,7 @@ function findTraceComment(document) {
|
|
|
89
89
|
|
|
90
90
|
function getTraceCommentFromNode(node) {
|
|
91
91
|
if (node && (0, _browserCore.isCommentNode)(node)) {
|
|
92
|
-
var match = node.data.match(/^\s*
|
|
92
|
+
var match = node.data.match(/^\s*GUANCE;(.*?)\s*$/);
|
|
93
93
|
|
|
94
94
|
if (match) {
|
|
95
95
|
return match[1];
|
|
@@ -56,25 +56,25 @@ function waitPageActivityEnd(lifeCycle, domMutationObservable, configuration, pa
|
|
|
56
56
|
function doWaitPageActivityEnd(pageActivityObservable, pageActivityEndCallback, maxDuration) {
|
|
57
57
|
var pageActivityEndTimeoutId;
|
|
58
58
|
var hasCompleted = false;
|
|
59
|
-
var validationTimeoutId = setTimeout(function () {
|
|
59
|
+
var validationTimeoutId = (0, _browserCore.setTimeout)(function () {
|
|
60
60
|
complete({
|
|
61
61
|
hadActivity: false
|
|
62
62
|
});
|
|
63
63
|
}, PAGE_ACTIVITY_VALIDATION_DELAY);
|
|
64
|
-
var maxDurationTimeoutId = maxDuration
|
|
64
|
+
var maxDurationTimeoutId = maxDuration !== undefined ? (0, _browserCore.setTimeout)(function () {
|
|
65
65
|
return complete({
|
|
66
66
|
hadActivity: true,
|
|
67
67
|
end: (0, _browserCore.timeStampNow)()
|
|
68
68
|
});
|
|
69
|
-
}, maxDuration);
|
|
69
|
+
}, maxDuration) : undefined;
|
|
70
70
|
var pageActivitySubscription = pageActivityObservable.subscribe(function (data) {
|
|
71
71
|
var isBusy = data.isBusy;
|
|
72
|
-
clearTimeout(validationTimeoutId);
|
|
73
|
-
clearTimeout(pageActivityEndTimeoutId);
|
|
72
|
+
(0, _browserCore.clearTimeout)(validationTimeoutId);
|
|
73
|
+
(0, _browserCore.clearTimeout)(pageActivityEndTimeoutId);
|
|
74
74
|
var lastChangeTime = (0, _browserCore.timeStampNow)();
|
|
75
75
|
|
|
76
76
|
if (!isBusy) {
|
|
77
|
-
pageActivityEndTimeoutId = setTimeout(function () {
|
|
77
|
+
pageActivityEndTimeoutId = (0, _browserCore.setTimeout)(function () {
|
|
78
78
|
complete({
|
|
79
79
|
hadActivity: true,
|
|
80
80
|
end: lastChangeTime
|
|
@@ -85,9 +85,9 @@ function doWaitPageActivityEnd(pageActivityObservable, pageActivityEndCallback,
|
|
|
85
85
|
|
|
86
86
|
var stop = function stop() {
|
|
87
87
|
hasCompleted = true;
|
|
88
|
-
clearTimeout(validationTimeoutId);
|
|
89
|
-
clearTimeout(pageActivityEndTimeoutId);
|
|
90
|
-
clearTimeout(maxDurationTimeoutId);
|
|
88
|
+
(0, _browserCore.clearTimeout)(validationTimeoutId);
|
|
89
|
+
(0, _browserCore.clearTimeout)(pageActivityEndTimeoutId);
|
|
90
|
+
(0, _browserCore.clearTimeout)(maxDurationTimeoutId);
|
|
91
91
|
pageActivitySubscription.unsubscribe();
|
|
92
92
|
};
|
|
93
93
|
|
|
@@ -7,8 +7,8 @@ exports.startRumBatch = startRumBatch;
|
|
|
7
7
|
|
|
8
8
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
9
|
|
|
10
|
-
function startRumBatch(configuration, lifeCycle, reportError, pageExitObservable) {
|
|
11
|
-
var batch = makeRumBatch(configuration, reportError, pageExitObservable);
|
|
10
|
+
function startRumBatch(configuration, lifeCycle, reportError, pageExitObservable, sessionExpireObservable) {
|
|
11
|
+
var batch = makeRumBatch(configuration, reportError, pageExitObservable, sessionExpireObservable);
|
|
12
12
|
lifeCycle.subscribe(_browserCore.LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
|
|
13
13
|
if (serverRumEvent.type === _browserCore.RumEventType.VIEW) {
|
|
14
14
|
batch.upsert(serverRumEvent, serverRumEvent.view.id);
|
|
@@ -18,14 +18,28 @@ function startRumBatch(configuration, lifeCycle, reportError, pageExitObservable
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function makeRumBatch(configuration, reportError, pageExitObservable) {
|
|
22
|
-
var
|
|
21
|
+
function makeRumBatch(configuration, reportError, pageExitObservable, sessionExpireObservable) {
|
|
22
|
+
var rumBatch = createRumBatch(configuration.datakitUrl);
|
|
23
|
+
var primaryBatch = rumBatch.batch;
|
|
24
|
+
var primaryFlushController = rumBatch.flushController;
|
|
23
25
|
|
|
24
|
-
function createRumBatch(endpointUrl
|
|
25
|
-
|
|
26
|
+
function createRumBatch(endpointUrl) {
|
|
27
|
+
var flushController = (0, _browserCore.createFlushController)({
|
|
28
|
+
messagesLimit: configuration.batchMessagesLimit,
|
|
29
|
+
bytesLimit: configuration.batchBytesLimit,
|
|
30
|
+
durationLimit: configuration.flushTimeout,
|
|
31
|
+
pageExitObservable: pageExitObservable,
|
|
32
|
+
sessionExpireObservable: sessionExpireObservable
|
|
33
|
+
});
|
|
34
|
+
var batch = new _browserCore.Batch((0, _browserCore.createHttpRequest)(endpointUrl, configuration.batchBytesLimit, reportError), flushController, configuration.messageBytesLimit);
|
|
35
|
+
return {
|
|
36
|
+
batch: batch,
|
|
37
|
+
flushController: flushController
|
|
38
|
+
};
|
|
26
39
|
}
|
|
27
40
|
|
|
28
41
|
return {
|
|
42
|
+
flushObservable: primaryFlushController.flushObservable,
|
|
29
43
|
add: function add(message) {
|
|
30
44
|
primaryBatch.add(message);
|
|
31
45
|
},
|
package/esm/boot/buildEnv.js
CHANGED
package/esm/boot/recorderApi.js
CHANGED
|
@@ -144,6 +144,6 @@ function isBrowserSupported() {
|
|
|
144
144
|
return (// Array.from is a bit less supported by browsers than CSSSupportsRule, but has higher chances
|
|
145
145
|
// to be polyfilled. Test for both to be more confident. We could add more things if we find out
|
|
146
146
|
// this test is not sufficient.
|
|
147
|
-
typeof Array.from === 'function' && typeof CSSSupportsRule === 'function' && 'forEach' in NodeList.prototype
|
|
147
|
+
typeof Array.from === 'function' && typeof CSSSupportsRule === 'function' && typeof URL.createObjectURL === 'function' && 'forEach' in NodeList.prototype
|
|
148
148
|
);
|
|
149
149
|
}
|
package/esm/boot/rum.js
CHANGED
|
@@ -12,11 +12,12 @@ import { startInternalContext } from '../domain/contexts/internalContext';
|
|
|
12
12
|
import { startForegroundContexts } from '../domain/contexts/foregroundContexts';
|
|
13
13
|
import { startUrlContexts } from '../domain/contexts/urlContexts';
|
|
14
14
|
import { startViewContexts } from '../domain/contexts/viewContexts';
|
|
15
|
+
import { buildCommonContext } from '../domain/contexts/commonContext';
|
|
15
16
|
import { startErrorCollection } from '../domain/rumEventsCollection/error/errorCollection';
|
|
16
17
|
import { startViewCollection } from '../domain/rumEventsCollection/view/viewCollection';
|
|
17
18
|
import { startRequestCollection } from '../domain/requestCollection';
|
|
18
19
|
import { startResourceCollection } from '../domain/rumEventsCollection/resource/resourceCollection';
|
|
19
|
-
export function startRum(configuration,
|
|
20
|
+
export function startRum(configuration, recorderApi, globalContextManager, userContextManager, initialViewOptions) {
|
|
20
21
|
var lifeCycle = new LifeCycle();
|
|
21
22
|
|
|
22
23
|
var reportError = function reportError(error) {
|
|
@@ -29,18 +30,21 @@ export function startRum(configuration, getCommonContext, recorderApi, initialVi
|
|
|
29
30
|
pageExitObservable.subscribe(function (event) {
|
|
30
31
|
lifeCycle.notify(LifeCycleEventType.PAGE_EXITED, event);
|
|
31
32
|
});
|
|
32
|
-
startRumBatch(configuration, lifeCycle, reportError, pageExitObservable);
|
|
33
33
|
var session = startRumSessionManager(configuration, lifeCycle);
|
|
34
|
+
var batch = startRumBatch(configuration, lifeCycle, reportError, pageExitObservable, session.expireObservable);
|
|
34
35
|
var userSession = startCacheUsrCache(configuration);
|
|
35
36
|
var domMutationObservable = createDOMMutationObservable();
|
|
36
37
|
var locationChangeObservable = createLocationChangeObservable(location);
|
|
37
38
|
|
|
38
|
-
var _startRumEventCollection = startRumEventCollection(
|
|
39
|
+
var _startRumEventCollection = startRumEventCollection(lifeCycle, configuration, location, session, userSession, locationChangeObservable, domMutationObservable, function () {
|
|
40
|
+
return buildCommonContext(globalContextManager, userContextManager, recorderApi);
|
|
41
|
+
}, reportError);
|
|
39
42
|
|
|
40
43
|
var viewContexts = _startRumEventCollection.viewContexts;
|
|
41
44
|
var urlContexts = _startRumEventCollection.urlContexts;
|
|
42
45
|
var actionContexts = _startRumEventCollection.actionContexts;
|
|
43
46
|
var foregroundContexts = _startRumEventCollection.foregroundContexts;
|
|
47
|
+
var addAction = _startRumEventCollection.addAction;
|
|
44
48
|
startLongTaskCollection(lifeCycle, session);
|
|
45
49
|
startResourceCollection(lifeCycle, configuration);
|
|
46
50
|
|
|
@@ -56,7 +60,7 @@ export function startRum(configuration, getCommonContext, recorderApi, initialVi
|
|
|
56
60
|
startPerformanceCollection(lifeCycle, configuration);
|
|
57
61
|
var internalContext = startInternalContext(configuration.applicationId, session, viewContexts, actionContexts, urlContexts);
|
|
58
62
|
return {
|
|
59
|
-
addAction:
|
|
63
|
+
addAction: addAction,
|
|
60
64
|
addError: addError,
|
|
61
65
|
addTiming: addTiming,
|
|
62
66
|
configuration: configuration,
|
|
@@ -64,10 +68,13 @@ export function startRum(configuration, getCommonContext, recorderApi, initialVi
|
|
|
64
68
|
viewContexts: viewContexts,
|
|
65
69
|
session: session,
|
|
66
70
|
startView: startView,
|
|
71
|
+
stopSession: function stopSession() {
|
|
72
|
+
session.expire();
|
|
73
|
+
},
|
|
67
74
|
getInternalContext: internalContext.get
|
|
68
75
|
};
|
|
69
76
|
}
|
|
70
|
-
export function startRumEventCollection(
|
|
77
|
+
export function startRumEventCollection(lifeCycle, configuration, location, sessionManager, userSessionManager, locationChangeObservable, domMutationObservable, buildCommonContext, reportError) {
|
|
71
78
|
var viewContexts = startViewContexts(lifeCycle);
|
|
72
79
|
var urlContexts = startUrlContexts(lifeCycle, locationChangeObservable, location);
|
|
73
80
|
var foregroundContexts = startForegroundContexts();
|
|
@@ -75,12 +82,13 @@ export function startRumEventCollection(location, lifeCycle, configuration, sess
|
|
|
75
82
|
var _startActionCollection = startActionCollection(lifeCycle, domMutationObservable, configuration, foregroundContexts);
|
|
76
83
|
|
|
77
84
|
var actionContexts = _startActionCollection.actionContexts;
|
|
78
|
-
|
|
85
|
+
var addAction = _startActionCollection.addAction;
|
|
86
|
+
startRumAssembly(configuration, lifeCycle, sessionManager, userSessionManager, viewContexts, urlContexts, actionContexts, buildCommonContext, reportError);
|
|
79
87
|
return {
|
|
80
88
|
viewContexts: viewContexts,
|
|
81
89
|
urlContexts: urlContexts,
|
|
82
90
|
foregroundContexts: foregroundContexts,
|
|
83
|
-
addAction:
|
|
91
|
+
addAction: addAction,
|
|
84
92
|
actionContexts: actionContexts,
|
|
85
93
|
stop: function stop() {
|
|
86
94
|
viewContexts.stop();
|
package/esm/boot/rumPublicApi.js
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
import { makePublicApi,
|
|
1
|
+
import { makePublicApi, areCookiesAuthorized, BoundedBuffer, display, buildCookieOptions, createContextManager, CustomerDataType, clocksNow, timeStampNow, ActionType, deepClone, createHandlingStack, sanitizeUser, checkUser, noop } from '@cloudcare/browser-core';
|
|
2
2
|
import { validateAndBuildRumConfiguration } from '../domain/configuration';
|
|
3
|
+
import { buildCommonContext } from '../domain/contexts/commonContext';
|
|
3
4
|
export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
4
5
|
var isAlreadyInitialized = false;
|
|
5
|
-
var globalContextManager = createContextManager();
|
|
6
|
-
var userContextManager = createContextManager();
|
|
6
|
+
var globalContextManager = createContextManager(CustomerDataType.GlobalContext);
|
|
7
|
+
var userContextManager = createContextManager(CustomerDataType.User);
|
|
8
|
+
|
|
9
|
+
var getInternalContextStrategy = function getInternalContextStrategy() {
|
|
10
|
+
return undefined;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
var stopSessionStrategy = function stopSessionStrategy() {
|
|
18
|
+
return noop();
|
|
19
|
+
};
|
|
20
|
+
|
|
7
21
|
var bufferApiCalls = new BoundedBuffer();
|
|
8
22
|
|
|
9
23
|
var _addTimingStrategy = function addTimingStrategy(name, time) {
|
|
@@ -28,10 +42,7 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
28
42
|
|
|
29
43
|
var _addActionStrategy = function addActionStrategy(action, commonContext) {
|
|
30
44
|
if (typeof commonContext == 'undefined') {
|
|
31
|
-
commonContext =
|
|
32
|
-
context: globalContextManager.getContext(),
|
|
33
|
-
user: userContextManager.getContext()
|
|
34
|
-
};
|
|
45
|
+
commonContext = buildCommonContext(globalContextManager, userContextManager, recorderApi);
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
bufferApiCalls.add(function () {
|
|
@@ -41,10 +52,7 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
41
52
|
|
|
42
53
|
var _addErrorStrategy = function addErrorStrategy(providedError, commonContext) {
|
|
43
54
|
if (typeof commonContext == 'undefined') {
|
|
44
|
-
commonContext =
|
|
45
|
-
context: globalContextManager.getContext(),
|
|
46
|
-
user: userContextManager.getContext()
|
|
47
|
-
};
|
|
55
|
+
commonContext = buildCommonContext(globalContextManager, userContextManager, recorderApi);
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
bufferApiCalls.add(function () {
|
|
@@ -52,14 +60,6 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
52
60
|
});
|
|
53
61
|
};
|
|
54
62
|
|
|
55
|
-
var getInternalContextStrategy = function getInternalContextStrategy() {
|
|
56
|
-
return undefined;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
var getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
60
|
-
return undefined;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
63
|
function initRum(initConfiguration) {
|
|
64
64
|
if (!canHandleSession(initConfiguration)) {
|
|
65
65
|
return;
|
|
@@ -99,18 +99,13 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function doStartRum(configuration, initialViewOptions) {
|
|
102
|
-
var startRumResults = startRumImpl(configuration,
|
|
103
|
-
return {
|
|
104
|
-
user: userContextManager.getContext(),
|
|
105
|
-
context: globalContextManager.getContext(),
|
|
106
|
-
hasReplay: recorderApi.isRecording() ? true : undefined
|
|
107
|
-
};
|
|
108
|
-
}, recorderApi, initialViewOptions);
|
|
102
|
+
var startRumResults = startRumImpl(configuration, recorderApi, globalContextManager, userContextManager, initialViewOptions);
|
|
109
103
|
_startViewStrategy = startRumResults.startView;
|
|
110
104
|
_addActionStrategy = startRumResults.addAction;
|
|
111
105
|
_addErrorStrategy = startRumResults.addError;
|
|
112
106
|
_addTimingStrategy = startRumResults.addTiming;
|
|
113
107
|
getInternalContextStrategy = startRumResults.getInternalContext;
|
|
108
|
+
stopSessionStrategy = startRumResults.stopSession;
|
|
114
109
|
bufferApiCalls.drain();
|
|
115
110
|
recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts);
|
|
116
111
|
}
|
|
@@ -159,13 +154,6 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
159
154
|
type: ActionType.CUSTOM
|
|
160
155
|
});
|
|
161
156
|
},
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @deprecated use addAction instead
|
|
165
|
-
*/
|
|
166
|
-
// addUserAction: function (name, context) {
|
|
167
|
-
// rumPublicApi.addAction(name, context)
|
|
168
|
-
// },
|
|
169
157
|
addError: function addError(error, context) {
|
|
170
158
|
var handlingStack = createHandlingStack();
|
|
171
159
|
|
|
@@ -180,9 +168,7 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
180
168
|
_addTimingStrategy(name, time);
|
|
181
169
|
},
|
|
182
170
|
setUser: function setUser(newUser) {
|
|
183
|
-
if (
|
|
184
|
-
display.error('Unsupported user:', newUser);
|
|
185
|
-
} else {
|
|
171
|
+
if (checkUser(newUser)) {
|
|
186
172
|
userContextManager.setContext(sanitizeUser(newUser));
|
|
187
173
|
}
|
|
188
174
|
},
|
|
@@ -199,29 +185,14 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
199
185
|
removeUser: userContextManager.clearContext,
|
|
200
186
|
clearUser: userContextManager.clearContext,
|
|
201
187
|
startView: startView,
|
|
188
|
+
stopSession: function stopSession() {
|
|
189
|
+
stopSessionStrategy();
|
|
190
|
+
},
|
|
202
191
|
startSessionReplayRecording: recorderApi.start,
|
|
203
192
|
stopSessionReplayRecording: recorderApi.stop
|
|
204
193
|
});
|
|
205
194
|
return rumPublicApi;
|
|
206
195
|
|
|
207
|
-
function sanitizeUser(newUser) {
|
|
208
|
-
var shallowClonedUser = assign(newUser, {});
|
|
209
|
-
|
|
210
|
-
if ('id' in shallowClonedUser) {
|
|
211
|
-
shallowClonedUser.id = String(shallowClonedUser.id);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if ('name' in shallowClonedUser) {
|
|
215
|
-
shallowClonedUser.name = String(shallowClonedUser.name);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if ('email' in shallowClonedUser) {
|
|
219
|
-
shallowClonedUser.email = String(shallowClonedUser.email);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return shallowClonedUser;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
196
|
function canHandleSession(initConfiguration) {
|
|
226
197
|
if (!areCookiesAuthorized(buildCookieOptions(initConfiguration))) {
|
|
227
198
|
display.warn('Cookies are not authorized, we will not send any data.');
|
package/esm/domain/assembly.js
CHANGED
|
@@ -7,7 +7,7 @@ var VIEW_EVENTS_MODIFIABLE_FIELD_PATHS = [// Fields with sensitive data
|
|
|
7
7
|
'view.url', 'view.referrer', 'action.target.name', 'error.message', 'error.stack', 'error.resource.url', 'resource.url'];
|
|
8
8
|
var OTHER_EVENTS_MODIFIABLE_FIELD_PATHS = VIEW_EVENTS_MODIFIABLE_FIELD_PATHS.concat([// User-customizable field
|
|
9
9
|
'tags']);
|
|
10
|
-
export function startRumAssembly(configuration, lifeCycle, sessionManager, userSessionManager, viewContexts, urlContexts, actionContexts,
|
|
10
|
+
export function startRumAssembly(configuration, lifeCycle, sessionManager, userSessionManager, viewContexts, urlContexts, actionContexts, buildCommonContext, reportError) {
|
|
11
11
|
var eventRateLimiters = {};
|
|
12
12
|
eventRateLimiters[RumEventType.ERROR] = createEventRateLimiter(RumEventType.ERROR, configuration.eventRateLimiterThreshold, reportError);
|
|
13
13
|
eventRateLimiters[RumEventType.ACTION] = createEventRateLimiter(RumEventType.ACTION, configuration.eventRateLimiterThreshold, reportError);
|
|
@@ -23,7 +23,7 @@ export function startRumAssembly(configuration, lifeCycle, sessionManager, userS
|
|
|
23
23
|
|
|
24
24
|
if (session && viewContext && urlContext) {
|
|
25
25
|
var actionId = actionContexts.findActionId(startTime);
|
|
26
|
-
var commonContext = savedCommonContext ||
|
|
26
|
+
var commonContext = savedCommonContext || buildCommonContext();
|
|
27
27
|
var rumContext = {
|
|
28
28
|
_dd: {
|
|
29
29
|
sdkName: configuration.sdkName,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addEventListeners, getRelativeTime, isNumber, includes, each, extend, filter, dateNow, relativeNow, DOM_EVENT, LifeCycleEventType, runOnReadyState } from '@cloudcare/browser-core';
|
|
1
|
+
import { addEventListeners, getRelativeTime, isNumber, includes, each, extend, filter, dateNow, relativeNow, DOM_EVENT, LifeCycleEventType, runOnReadyState, setTimeout, addEventListener } from '@cloudcare/browser-core';
|
|
2
2
|
import { FAKE_INITIAL_DOCUMENT, isAllowedRequestUrl } from './rumEventsCollection/resource/resourceUtils';
|
|
3
3
|
|
|
4
4
|
function supportPerformanceObject() {
|
|
@@ -56,7 +56,7 @@ export function startPerformanceCollection(lifeCycle, configuration) {
|
|
|
56
56
|
|
|
57
57
|
if (supportPerformanceObject() && 'addEventListener' in performance) {
|
|
58
58
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1559377
|
|
59
|
-
|
|
59
|
+
addEventListener(performance, 'resourcetimingbufferfull', function () {
|
|
60
60
|
performance.clearResourceTimings();
|
|
61
61
|
});
|
|
62
62
|
}
|
|
@@ -329,17 +329,19 @@ function isSVGElement(el) {
|
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
function transformAttribute(doc, tagName, name, value) {
|
|
332
|
-
if (
|
|
332
|
+
if (!value) return value;
|
|
333
|
+
|
|
334
|
+
if (name === 'src' || name === 'href' && !(tagName === 'use' && value[0] === '#')) {
|
|
333
335
|
return absoluteToDoc(doc, value);
|
|
334
|
-
} else if (name === 'xlink:href' && value
|
|
336
|
+
} else if (name === 'xlink:href' && value[0] !== '#') {
|
|
335
337
|
return absoluteToDoc(doc, value);
|
|
336
338
|
} else if (name === 'background' && value && (tagName === 'table' || tagName === 'td' || tagName === 'th')) {
|
|
337
339
|
return absoluteToDoc(doc, value);
|
|
338
|
-
} else if (name === 'srcset'
|
|
340
|
+
} else if (name === 'srcset') {
|
|
339
341
|
return getAbsoluteSrcsetString(doc, value);
|
|
340
|
-
} else if (name === 'style'
|
|
342
|
+
} else if (name === 'style') {
|
|
341
343
|
return switchToAbsoluteUrl(value, getHref());
|
|
342
|
-
} else if (tagName === 'object' && name === 'data'
|
|
344
|
+
} else if (tagName === 'object' && name === 'data') {
|
|
343
345
|
return absoluteToDoc(doc, value);
|
|
344
346
|
} else {
|
|
345
347
|
return value;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ONE_SECOND, LifeCycleEventType, isPageExitReason } from '@cloudcare/browser-core';
|
|
1
|
+
import { ONE_SECOND, LifeCycleEventType, isPageExitReason, setTimeout, clearTimeout } from '@cloudcare/browser-core';
|
|
2
2
|
import { buildReplayPayload } from './buildReplayPayload';
|
|
3
3
|
import { Segment } from './segment';
|
|
4
4
|
export var SEGMENT_DURATION_LIMIT = 30 * ONE_SECOND;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { display, includes, each } from '@cloudcare/browser-core';
|
|
1
|
+
import { display, includes, each, addEventListener } from '@cloudcare/browser-core';
|
|
2
2
|
import { createDeflateWorker } from './deflateWorker';
|
|
3
3
|
/**
|
|
4
4
|
* In order to be sure that the worker is correctly working, we need a round trip of
|
|
@@ -64,8 +64,8 @@ export function doStartDeflateWorker(createDeflateWorkerImpl) {
|
|
|
64
64
|
|
|
65
65
|
try {
|
|
66
66
|
var worker = createDeflateWorkerImpl();
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
addEventListener(worker, 'error', onError);
|
|
68
|
+
addEventListener(worker, 'message', function (event) {
|
|
69
69
|
var data = event.data;
|
|
70
70
|
|
|
71
71
|
if (data.type === 'errored') {
|