@cloudcare/browser-rum 3.0.14 → 3.0.16
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/domain/replay/record/observers.js +51 -33
- package/cjs/domain/replay/record/shadowRootsController.js +1 -4
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +1 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +12 -19
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/replay/record/observers.js +51 -33
- package/esm/domain/replay/record/shadowRootsController.js +1 -4
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +12 -20
- package/package.json +3 -3
- package/src/domain/replay/record/observers.js +64 -54
- package/src/domain/replay/record/shadowRootsController.js +1 -4
- package/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +1 -1
- package/src/domain/rumEventsCollection/actions/trackClickActions.js +11 -22
- package/src/domain/rumEventsCollection/view/trackViewMetrics.js +0 -1
package/cjs/boot/buildEnv.js
CHANGED
|
@@ -216,10 +216,47 @@ function initViewportResizeObserver(cb) {
|
|
|
216
216
|
return (0, _initViewportObservable.initViewportObservable)().subscribe(cb).unsubscribe;
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
function initInputObserver(cb, defaultPrivacyLevel,
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
function initInputObserver(cb, defaultPrivacyLevel, target) {
|
|
220
|
+
if (target === undefined) {
|
|
221
|
+
target = document;
|
|
222
|
+
}
|
|
223
|
+
|
|
222
224
|
var lastInputStateMap = new WeakMap();
|
|
225
|
+
var isShadowRoot = target !== document;
|
|
226
|
+
|
|
227
|
+
var _addEventListeners = (0, _browserCore.addEventListeners)(target, // The 'input' event bubbles across shadow roots, so we don't have to listen for it on shadow
|
|
228
|
+
// roots since it will be handled by the event listener that we did add to the document. Only
|
|
229
|
+
// the 'change' event is blocked and needs to be handled on shadow roots.
|
|
230
|
+
isShadowRoot ? [_browserCore.DOM_EVENT.CHANGE] : [_browserCore.DOM_EVENT.INPUT, _browserCore.DOM_EVENT.CHANGE], function (event) {
|
|
231
|
+
var target = getEventTarget(event);
|
|
232
|
+
|
|
233
|
+
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement) {
|
|
234
|
+
onElementChange(target);
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
capture: true,
|
|
238
|
+
passive: true
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
var stopEventListeners = _addEventListeners.stop;
|
|
242
|
+
var stopPropertySetterInstrumentation;
|
|
243
|
+
|
|
244
|
+
if (!isShadowRoot) {
|
|
245
|
+
var instrumentationStoppers = [(0, _browserCore.instrumentSetter)(HTMLInputElement.prototype, 'value', onElementChange), (0, _browserCore.instrumentSetter)(HTMLInputElement.prototype, 'checked', onElementChange), (0, _browserCore.instrumentSetter)(HTMLSelectElement.prototype, 'value', onElementChange), (0, _browserCore.instrumentSetter)(HTMLTextAreaElement.prototype, 'value', onElementChange), (0, _browserCore.instrumentSetter)(HTMLSelectElement.prototype, 'selectedIndex', onElementChange)];
|
|
246
|
+
|
|
247
|
+
stopPropertySetterInstrumentation = function stopPropertySetterInstrumentation() {
|
|
248
|
+
instrumentationStoppers.forEach(function (stopper) {
|
|
249
|
+
return stopper.stop();
|
|
250
|
+
});
|
|
251
|
+
};
|
|
252
|
+
} else {
|
|
253
|
+
stopPropertySetterInstrumentation = _browserCore.noop;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return function () {
|
|
257
|
+
stopPropertySetterInstrumentation();
|
|
258
|
+
stopEventListeners();
|
|
259
|
+
};
|
|
223
260
|
|
|
224
261
|
function onElementChange(target) {
|
|
225
262
|
var nodePrivacyLevel = (0, _privacy.getNodePrivacyLevel)(target, defaultPrivacyLevel);
|
|
@@ -286,26 +323,6 @@ function initInputObserver(cb, defaultPrivacyLevel, options) {
|
|
|
286
323
|
}, inputState));
|
|
287
324
|
}
|
|
288
325
|
}
|
|
289
|
-
|
|
290
|
-
var _addEventListeners = (0, _browserCore.addEventListeners)(target, domEvents, function (event) {
|
|
291
|
-
var target = getEventTarget(event);
|
|
292
|
-
|
|
293
|
-
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement) {
|
|
294
|
-
onElementChange(target);
|
|
295
|
-
}
|
|
296
|
-
}, {
|
|
297
|
-
capture: true,
|
|
298
|
-
passive: true
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
var instrumentationStoppers = [(0, _browserCore.instrumentSetter)(HTMLInputElement.prototype, 'value', onElementChange), (0, _browserCore.instrumentSetter)(HTMLInputElement.prototype, 'checked', onElementChange), (0, _browserCore.instrumentSetter)(HTMLSelectElement.prototype, 'value', onElementChange), (0, _browserCore.instrumentSetter)(HTMLTextAreaElement.prototype, 'value', onElementChange), (0, _browserCore.instrumentSetter)(HTMLSelectElement.prototype, 'selectedIndex', onElementChange)];
|
|
302
|
-
return function () {
|
|
303
|
-
instrumentationStoppers.forEach(function (stopper) {
|
|
304
|
-
stopper.stop();
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
_addEventListeners.stop();
|
|
308
|
-
};
|
|
309
326
|
}
|
|
310
327
|
|
|
311
328
|
function initStyleSheetObserver(cb) {
|
|
@@ -447,16 +464,17 @@ function initVisualViewportResizeObserver(cb) {
|
|
|
447
464
|
|
|
448
465
|
function initFrustrationObserver(lifeCycle, frustrationCb) {
|
|
449
466
|
return lifeCycle.subscribe(_browserCore.LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (data) {
|
|
450
|
-
if (data.rawRumEvent.type === _browserCore.RumEventType.ACTION && data.rawRumEvent.action.type === _browserCore.ActionType.CLICK && data.rawRumEvent.action.frustration && data.rawRumEvent.action.frustration.type && data.rawRumEvent.action.frustration.type.length && 'events' in data.domainContext && data.domainContext.events && data.domainContext.events.length) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
467
|
+
if (data.rawRumEvent.type === _browserCore.RumEventType.ACTION && data.rawRumEvent.action.type === _browserCore.ActionType.CLICK && data.rawRumEvent.action.frustration && data.rawRumEvent.action.frustration.type && data.rawRumEvent.action.frustration.type.length && 'events' in data.domainContext && data.domainContext.events && data.domainContext.events.length) {
|
|
468
|
+
frustrationCb({
|
|
469
|
+
timestamp: data.rawRumEvent.date,
|
|
470
|
+
type: _types.RecordType.FrustrationRecord,
|
|
471
|
+
data: {
|
|
472
|
+
frustrationTypes: data.rawRumEvent.action.frustration.type,
|
|
473
|
+
recordIds: data.domainContext.events.map(function (e) {
|
|
474
|
+
return getRecordIdForEvent(e);
|
|
475
|
+
})
|
|
476
|
+
}
|
|
477
|
+
});
|
|
460
478
|
}
|
|
461
479
|
}).unsubscribe;
|
|
462
480
|
}
|
|
@@ -22,10 +22,7 @@ var initShadowRootsController = function initShadowRootsController(configuration
|
|
|
22
22
|
var flush = _startMutaionObserve.flush;
|
|
23
23
|
var stopMutationObserver = _startMutaionObserve.stop; // the change event no do bubble up across the shadow root, we have to listen on the shadow root
|
|
24
24
|
|
|
25
|
-
var stopInputObserver = (0, _observers.initInputObserver)(inputCb, configuration.defaultPrivacyLevel,
|
|
26
|
-
target: shadowRoot,
|
|
27
|
-
domEvents: [_browserCore.DOM_EVENT.CHANGE]
|
|
28
|
-
});
|
|
25
|
+
var stopInputObserver = (0, _observers.initInputObserver)(inputCb, configuration.defaultPrivacyLevel, shadowRoot);
|
|
29
26
|
controllerByShadowRoot.set(shadowRoot, {
|
|
30
27
|
flush: flush,
|
|
31
28
|
stop: function stop() {
|
|
@@ -30,7 +30,7 @@ var GLOBALLY_UNIQUE_SELECTOR_GETTERS = [getStableAttributeSelector, getIDSelecto
|
|
|
30
30
|
var UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS = [getStableAttributeSelector, getClassSelector, getTagNameSelector];
|
|
31
31
|
|
|
32
32
|
function getSelectorFromElement(targetElement, actionNameAttribute) {
|
|
33
|
-
var targetElementSelector =
|
|
33
|
+
var targetElementSelector = '';
|
|
34
34
|
var element = targetElement;
|
|
35
35
|
|
|
36
36
|
while (element && element.nodeName !== 'HTML') {
|
|
@@ -17,6 +17,8 @@ var _clickChain = require("./clickChain");
|
|
|
17
17
|
|
|
18
18
|
var _getActionNameFromElement = require("./getActionNameFromElement");
|
|
19
19
|
|
|
20
|
+
var _getSelectorsFromElement = require("./getSelectorsFromElement");
|
|
21
|
+
|
|
20
22
|
var _listenActionEvents2 = require("./listenActionEvents");
|
|
21
23
|
|
|
22
24
|
var _computeFrustration2 = require("./computeFrustration");
|
|
@@ -159,27 +161,18 @@ function startClickAction(configuration, lifeCycle, domMutationObservable, histo
|
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
function computeClickActionBase(event, actionNameAttribute) {
|
|
162
|
-
var target;
|
|
163
|
-
var position; // if (isExperimentalFeatureEnabled('clickmap')) {
|
|
164
|
-
// var rect = event.target.getBoundingClientRect()
|
|
165
|
-
// target = assign(
|
|
166
|
-
// {
|
|
167
|
-
// width: Math.round(rect.width),
|
|
168
|
-
// height: Math.round(rect.height),
|
|
169
|
-
// },
|
|
170
|
-
// getSelectorsFromElement(event.target, actionNameAttribute)
|
|
171
|
-
// )
|
|
172
|
-
// position = {
|
|
173
|
-
// // Use clientX and Y because for SVG element offsetX and Y are relatives to the <svg> element
|
|
174
|
-
// x: Math.round(event.clientX - rect.left),
|
|
175
|
-
// y: Math.round(event.clientY - rect.top),
|
|
176
|
-
// }
|
|
177
|
-
// }
|
|
178
|
-
|
|
164
|
+
var rect = event.target.getBoundingClientRect();
|
|
179
165
|
return {
|
|
180
166
|
type: _browserCore.ActionType.CLICK,
|
|
181
|
-
target:
|
|
182
|
-
|
|
167
|
+
target: {
|
|
168
|
+
width: Math.round(rect.width),
|
|
169
|
+
height: Math.round(rect.height),
|
|
170
|
+
selector: (0, _getSelectorsFromElement.getSelectorFromElement)(event.target, actionNameAttribute)
|
|
171
|
+
},
|
|
172
|
+
position: {
|
|
173
|
+
x: Math.round(event.clientX - rect.left),
|
|
174
|
+
y: Math.round(event.clientY - rect.top)
|
|
175
|
+
},
|
|
183
176
|
name: (0, _getActionNameFromElement.getActionNameFromElement)(event.target, actionNameAttribute)
|
|
184
177
|
};
|
|
185
178
|
}
|
package/esm/boot/buildEnv.js
CHANGED
|
@@ -201,10 +201,47 @@ function initViewportResizeObserver(cb) {
|
|
|
201
201
|
return initViewportObservable().subscribe(cb).unsubscribe;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
export function initInputObserver(cb, defaultPrivacyLevel,
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
export function initInputObserver(cb, defaultPrivacyLevel, target) {
|
|
205
|
+
if (target === undefined) {
|
|
206
|
+
target = document;
|
|
207
|
+
}
|
|
208
|
+
|
|
207
209
|
var lastInputStateMap = new WeakMap();
|
|
210
|
+
var isShadowRoot = target !== document;
|
|
211
|
+
|
|
212
|
+
var _addEventListeners = addEventListeners(target, // The 'input' event bubbles across shadow roots, so we don't have to listen for it on shadow
|
|
213
|
+
// roots since it will be handled by the event listener that we did add to the document. Only
|
|
214
|
+
// the 'change' event is blocked and needs to be handled on shadow roots.
|
|
215
|
+
isShadowRoot ? [DOM_EVENT.CHANGE] : [DOM_EVENT.INPUT, DOM_EVENT.CHANGE], function (event) {
|
|
216
|
+
var target = getEventTarget(event);
|
|
217
|
+
|
|
218
|
+
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement) {
|
|
219
|
+
onElementChange(target);
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
capture: true,
|
|
223
|
+
passive: true
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
var stopEventListeners = _addEventListeners.stop;
|
|
227
|
+
var stopPropertySetterInstrumentation;
|
|
228
|
+
|
|
229
|
+
if (!isShadowRoot) {
|
|
230
|
+
var instrumentationStoppers = [instrumentSetter(HTMLInputElement.prototype, 'value', onElementChange), instrumentSetter(HTMLInputElement.prototype, 'checked', onElementChange), instrumentSetter(HTMLSelectElement.prototype, 'value', onElementChange), instrumentSetter(HTMLTextAreaElement.prototype, 'value', onElementChange), instrumentSetter(HTMLSelectElement.prototype, 'selectedIndex', onElementChange)];
|
|
231
|
+
|
|
232
|
+
stopPropertySetterInstrumentation = function stopPropertySetterInstrumentation() {
|
|
233
|
+
instrumentationStoppers.forEach(function (stopper) {
|
|
234
|
+
return stopper.stop();
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
} else {
|
|
238
|
+
stopPropertySetterInstrumentation = noop;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return function () {
|
|
242
|
+
stopPropertySetterInstrumentation();
|
|
243
|
+
stopEventListeners();
|
|
244
|
+
};
|
|
208
245
|
|
|
209
246
|
function onElementChange(target) {
|
|
210
247
|
var nodePrivacyLevel = getNodePrivacyLevel(target, defaultPrivacyLevel);
|
|
@@ -271,26 +308,6 @@ export function initInputObserver(cb, defaultPrivacyLevel, options) {
|
|
|
271
308
|
}, inputState));
|
|
272
309
|
}
|
|
273
310
|
}
|
|
274
|
-
|
|
275
|
-
var _addEventListeners = addEventListeners(target, domEvents, function (event) {
|
|
276
|
-
var target = getEventTarget(event);
|
|
277
|
-
|
|
278
|
-
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement) {
|
|
279
|
-
onElementChange(target);
|
|
280
|
-
}
|
|
281
|
-
}, {
|
|
282
|
-
capture: true,
|
|
283
|
-
passive: true
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
var instrumentationStoppers = [instrumentSetter(HTMLInputElement.prototype, 'value', onElementChange), instrumentSetter(HTMLInputElement.prototype, 'checked', onElementChange), instrumentSetter(HTMLSelectElement.prototype, 'value', onElementChange), instrumentSetter(HTMLTextAreaElement.prototype, 'value', onElementChange), instrumentSetter(HTMLSelectElement.prototype, 'selectedIndex', onElementChange)];
|
|
287
|
-
return function () {
|
|
288
|
-
instrumentationStoppers.forEach(function (stopper) {
|
|
289
|
-
stopper.stop();
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
_addEventListeners.stop();
|
|
293
|
-
};
|
|
294
311
|
}
|
|
295
312
|
export function initStyleSheetObserver(cb) {
|
|
296
313
|
function checkStyleSheetAndCallback(styleSheet, callback) {
|
|
@@ -431,16 +448,17 @@ function initVisualViewportResizeObserver(cb) {
|
|
|
431
448
|
|
|
432
449
|
export function initFrustrationObserver(lifeCycle, frustrationCb) {
|
|
433
450
|
return lifeCycle.subscribe(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, function (data) {
|
|
434
|
-
if (data.rawRumEvent.type === RumEventType.ACTION && data.rawRumEvent.action.type === ActionType.CLICK && data.rawRumEvent.action.frustration && data.rawRumEvent.action.frustration.type && data.rawRumEvent.action.frustration.type.length && 'events' in data.domainContext && data.domainContext.events && data.domainContext.events.length) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
451
|
+
if (data.rawRumEvent.type === RumEventType.ACTION && data.rawRumEvent.action.type === ActionType.CLICK && data.rawRumEvent.action.frustration && data.rawRumEvent.action.frustration.type && data.rawRumEvent.action.frustration.type.length && 'events' in data.domainContext && data.domainContext.events && data.domainContext.events.length) {
|
|
452
|
+
frustrationCb({
|
|
453
|
+
timestamp: data.rawRumEvent.date,
|
|
454
|
+
type: RecordType.FrustrationRecord,
|
|
455
|
+
data: {
|
|
456
|
+
frustrationTypes: data.rawRumEvent.action.frustration.type,
|
|
457
|
+
recordIds: data.domainContext.events.map(function (e) {
|
|
458
|
+
return getRecordIdForEvent(e);
|
|
459
|
+
})
|
|
460
|
+
}
|
|
461
|
+
});
|
|
444
462
|
}
|
|
445
463
|
}).unsubscribe;
|
|
446
464
|
}
|
|
@@ -12,10 +12,7 @@ export var initShadowRootsController = function initShadowRootsController(config
|
|
|
12
12
|
var flush = _startMutaionObserve.flush;
|
|
13
13
|
var stopMutationObserver = _startMutaionObserve.stop; // the change event no do bubble up across the shadow root, we have to listen on the shadow root
|
|
14
14
|
|
|
15
|
-
var stopInputObserver = initInputObserver(inputCb, configuration.defaultPrivacyLevel,
|
|
16
|
-
target: shadowRoot,
|
|
17
|
-
domEvents: [DOM_EVENT.CHANGE]
|
|
18
|
-
});
|
|
15
|
+
var stopInputObserver = initInputObserver(inputCb, configuration.defaultPrivacyLevel, shadowRoot);
|
|
19
16
|
controllerByShadowRoot.set(shadowRoot, {
|
|
20
17
|
flush: flush,
|
|
21
18
|
stop: function stop() {
|
|
@@ -18,7 +18,7 @@ var GLOBALLY_UNIQUE_SELECTOR_GETTERS = [getStableAttributeSelector, getIDSelecto
|
|
|
18
18
|
|
|
19
19
|
var UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS = [getStableAttributeSelector, getClassSelector, getTagNameSelector];
|
|
20
20
|
export function getSelectorFromElement(targetElement, actionNameAttribute) {
|
|
21
|
-
var targetElementSelector =
|
|
21
|
+
var targetElementSelector = '';
|
|
22
22
|
var element = targetElement;
|
|
23
23
|
|
|
24
24
|
while (element && element.nodeName !== 'HTML') {
|
|
@@ -2,7 +2,8 @@ import { timeStampNow, Observable, assign, getRelativeTime, ONE_MINUTE, ContextH
|
|
|
2
2
|
import { trackEventCounts } from '../../trackEventCounts';
|
|
3
3
|
import { waitPageActivityEnd, PAGE_ACTIVITY_VALIDATION_DELAY } from '../../waitPageActivityEnd';
|
|
4
4
|
import { createClickChain } from './clickChain';
|
|
5
|
-
import { getActionNameFromElement } from './getActionNameFromElement';
|
|
5
|
+
import { getActionNameFromElement } from './getActionNameFromElement';
|
|
6
|
+
import { getSelectorFromElement } from './getSelectorsFromElement'; // import { getSelectorsFromElement } from './getSelectorsFromElement'
|
|
6
7
|
|
|
7
8
|
import { listenActionEvents } from './listenActionEvents';
|
|
8
9
|
import { computeFrustration } from './computeFrustration'; // Maximum duration for click actions
|
|
@@ -140,27 +141,18 @@ function startClickAction(configuration, lifeCycle, domMutationObservable, histo
|
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
function computeClickActionBase(event, actionNameAttribute) {
|
|
143
|
-
var target;
|
|
144
|
-
var position; // if (isExperimentalFeatureEnabled('clickmap')) {
|
|
145
|
-
// var rect = event.target.getBoundingClientRect()
|
|
146
|
-
// target = assign(
|
|
147
|
-
// {
|
|
148
|
-
// width: Math.round(rect.width),
|
|
149
|
-
// height: Math.round(rect.height),
|
|
150
|
-
// },
|
|
151
|
-
// getSelectorsFromElement(event.target, actionNameAttribute)
|
|
152
|
-
// )
|
|
153
|
-
// position = {
|
|
154
|
-
// // Use clientX and Y because for SVG element offsetX and Y are relatives to the <svg> element
|
|
155
|
-
// x: Math.round(event.clientX - rect.left),
|
|
156
|
-
// y: Math.round(event.clientY - rect.top),
|
|
157
|
-
// }
|
|
158
|
-
// }
|
|
159
|
-
|
|
144
|
+
var rect = event.target.getBoundingClientRect();
|
|
160
145
|
return {
|
|
161
146
|
type: ActionType.CLICK,
|
|
162
|
-
target:
|
|
163
|
-
|
|
147
|
+
target: {
|
|
148
|
+
width: Math.round(rect.width),
|
|
149
|
+
height: Math.round(rect.height),
|
|
150
|
+
selector: getSelectorFromElement(event.target, actionNameAttribute)
|
|
151
|
+
},
|
|
152
|
+
position: {
|
|
153
|
+
x: Math.round(event.clientX - rect.left),
|
|
154
|
+
y: Math.round(event.clientY - rect.top)
|
|
155
|
+
},
|
|
164
156
|
name: getActionNameFromElement(event.target, actionNameAttribute)
|
|
165
157
|
};
|
|
166
158
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcare/browser-rum",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.16",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@cloudcare/browser-core": "2.0.
|
|
7
|
+
"@cloudcare/browser-core": "2.0.14"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "webpack serve --open --mode=development",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"homepage": "https://github.com/CloudCare/dataflux-rum-sdk-javascript/blob/master/packages/rum/README.md",
|
|
31
31
|
"description": "DataFlux RUM Web 端数据指标监控",
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "1aee6e645bb9cfe3f31fe88008e83c74087ce41c"
|
|
33
33
|
}
|
|
@@ -283,13 +283,61 @@ function initViewportResizeObserver(cb) {
|
|
|
283
283
|
return initViewportObservable().subscribe(cb).unsubscribe
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
export function initInputObserver(cb, defaultPrivacyLevel,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
]
|
|
291
|
-
var target = (options && options.target) || document
|
|
286
|
+
export function initInputObserver(cb, defaultPrivacyLevel, target) {
|
|
287
|
+
if (target === undefined) {
|
|
288
|
+
target = document
|
|
289
|
+
}
|
|
292
290
|
var lastInputStateMap = new WeakMap()
|
|
291
|
+
var isShadowRoot = target !== document
|
|
292
|
+
|
|
293
|
+
var _addEventListeners = addEventListeners(
|
|
294
|
+
target,
|
|
295
|
+
// The 'input' event bubbles across shadow roots, so we don't have to listen for it on shadow
|
|
296
|
+
// roots since it will be handled by the event listener that we did add to the document. Only
|
|
297
|
+
// the 'change' event is blocked and needs to be handled on shadow roots.
|
|
298
|
+
isShadowRoot ? [DOM_EVENT.CHANGE] : [DOM_EVENT.INPUT, DOM_EVENT.CHANGE],
|
|
299
|
+
function (event) {
|
|
300
|
+
var target = getEventTarget(event)
|
|
301
|
+
if (
|
|
302
|
+
target instanceof HTMLInputElement ||
|
|
303
|
+
target instanceof HTMLTextAreaElement ||
|
|
304
|
+
target instanceof HTMLSelectElement
|
|
305
|
+
) {
|
|
306
|
+
onElementChange(target)
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
capture: true,
|
|
311
|
+
passive: true
|
|
312
|
+
}
|
|
313
|
+
)
|
|
314
|
+
var stopEventListeners = _addEventListeners.stop
|
|
315
|
+
var stopPropertySetterInstrumentation
|
|
316
|
+
if (!isShadowRoot) {
|
|
317
|
+
const instrumentationStoppers = [
|
|
318
|
+
instrumentSetter(HTMLInputElement.prototype, 'value', onElementChange),
|
|
319
|
+
instrumentSetter(HTMLInputElement.prototype, 'checked', onElementChange),
|
|
320
|
+
instrumentSetter(HTMLSelectElement.prototype, 'value', onElementChange),
|
|
321
|
+
instrumentSetter(HTMLTextAreaElement.prototype, 'value', onElementChange),
|
|
322
|
+
instrumentSetter(
|
|
323
|
+
HTMLSelectElement.prototype,
|
|
324
|
+
'selectedIndex',
|
|
325
|
+
onElementChange
|
|
326
|
+
)
|
|
327
|
+
]
|
|
328
|
+
stopPropertySetterInstrumentation = function () {
|
|
329
|
+
instrumentationStoppers.forEach(function (stopper) {
|
|
330
|
+
return stopper.stop()
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
} else {
|
|
334
|
+
stopPropertySetterInstrumentation = noop
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return function () {
|
|
338
|
+
stopPropertySetterInstrumentation()
|
|
339
|
+
stopEventListeners()
|
|
340
|
+
}
|
|
293
341
|
|
|
294
342
|
function onElementChange(target) {
|
|
295
343
|
var nodePrivacyLevel = getNodePrivacyLevel(target, defaultPrivacyLevel)
|
|
@@ -355,44 +403,6 @@ export function initInputObserver(cb, defaultPrivacyLevel, options) {
|
|
|
355
403
|
)
|
|
356
404
|
}
|
|
357
405
|
}
|
|
358
|
-
|
|
359
|
-
var _addEventListeners = addEventListeners(
|
|
360
|
-
target,
|
|
361
|
-
domEvents,
|
|
362
|
-
function (event) {
|
|
363
|
-
var target = getEventTarget(event)
|
|
364
|
-
if (
|
|
365
|
-
target instanceof HTMLInputElement ||
|
|
366
|
-
target instanceof HTMLTextAreaElement ||
|
|
367
|
-
target instanceof HTMLSelectElement
|
|
368
|
-
) {
|
|
369
|
-
onElementChange(target)
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
capture: true,
|
|
374
|
-
passive: true
|
|
375
|
-
}
|
|
376
|
-
)
|
|
377
|
-
|
|
378
|
-
var instrumentationStoppers = [
|
|
379
|
-
instrumentSetter(HTMLInputElement.prototype, 'value', onElementChange),
|
|
380
|
-
instrumentSetter(HTMLInputElement.prototype, 'checked', onElementChange),
|
|
381
|
-
instrumentSetter(HTMLSelectElement.prototype, 'value', onElementChange),
|
|
382
|
-
instrumentSetter(HTMLTextAreaElement.prototype, 'value', onElementChange),
|
|
383
|
-
instrumentSetter(
|
|
384
|
-
HTMLSelectElement.prototype,
|
|
385
|
-
'selectedIndex',
|
|
386
|
-
onElementChange
|
|
387
|
-
)
|
|
388
|
-
]
|
|
389
|
-
|
|
390
|
-
return function () {
|
|
391
|
-
instrumentationStoppers.forEach(function (stopper) {
|
|
392
|
-
stopper.stop()
|
|
393
|
-
})
|
|
394
|
-
_addEventListeners.stop()
|
|
395
|
-
}
|
|
396
406
|
}
|
|
397
407
|
|
|
398
408
|
export function initStyleSheetObserver(cb) {
|
|
@@ -542,16 +552,16 @@ export function initFrustrationObserver(lifeCycle, frustrationCb) {
|
|
|
542
552
|
data.domainContext.events &&
|
|
543
553
|
data.domainContext.events.length
|
|
544
554
|
) {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
+
frustrationCb({
|
|
556
|
+
timestamp: data.rawRumEvent.date,
|
|
557
|
+
type: RecordType.FrustrationRecord,
|
|
558
|
+
data: {
|
|
559
|
+
frustrationTypes: data.rawRumEvent.action.frustration.type,
|
|
560
|
+
recordIds: data.domainContext.events.map(function (e) {
|
|
561
|
+
return getRecordIdForEvent(e)
|
|
562
|
+
})
|
|
563
|
+
}
|
|
564
|
+
})
|
|
555
565
|
}
|
|
556
566
|
}
|
|
557
567
|
).unsubscribe
|
|
@@ -22,10 +22,7 @@ export var initShadowRootsController = function (configuration, data) {
|
|
|
22
22
|
var stopInputObserver = initInputObserver(
|
|
23
23
|
inputCb,
|
|
24
24
|
configuration.defaultPrivacyLevel,
|
|
25
|
-
|
|
26
|
-
target: shadowRoot,
|
|
27
|
-
domEvents: [DOM_EVENT.CHANGE]
|
|
28
|
-
}
|
|
25
|
+
shadowRoot
|
|
29
26
|
)
|
|
30
27
|
controllerByShadowRoot.set(shadowRoot, {
|
|
31
28
|
flush: flush,
|
|
@@ -43,7 +43,7 @@ var UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS = [
|
|
|
43
43
|
]
|
|
44
44
|
|
|
45
45
|
export function getSelectorFromElement(targetElement, actionNameAttribute) {
|
|
46
|
-
var targetElementSelector =
|
|
46
|
+
var targetElementSelector = ''
|
|
47
47
|
var element = targetElement
|
|
48
48
|
|
|
49
49
|
while (element && element.nodeName !== 'HTML') {
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
} from '../../waitPageActivityEnd'
|
|
25
25
|
import { createClickChain } from './clickChain'
|
|
26
26
|
import { getActionNameFromElement } from './getActionNameFromElement'
|
|
27
|
+
import { getSelectorFromElement } from './getSelectorsFromElement'
|
|
27
28
|
// import { getSelectorsFromElement } from './getSelectorsFromElement'
|
|
28
29
|
import { listenActionEvents } from './listenActionEvents'
|
|
29
30
|
import { computeFrustration } from './computeFrustration'
|
|
@@ -228,29 +229,18 @@ function startClickAction(
|
|
|
228
229
|
}
|
|
229
230
|
|
|
230
231
|
function computeClickActionBase(event, actionNameAttribute) {
|
|
231
|
-
var target
|
|
232
|
-
var position
|
|
233
|
-
|
|
234
|
-
// if (isExperimentalFeatureEnabled('clickmap')) {
|
|
235
|
-
// var rect = event.target.getBoundingClientRect()
|
|
236
|
-
// target = assign(
|
|
237
|
-
// {
|
|
238
|
-
// width: Math.round(rect.width),
|
|
239
|
-
// height: Math.round(rect.height),
|
|
240
|
-
// },
|
|
241
|
-
// getSelectorsFromElement(event.target, actionNameAttribute)
|
|
242
|
-
// )
|
|
243
|
-
// position = {
|
|
244
|
-
// // Use clientX and Y because for SVG element offsetX and Y are relatives to the <svg> element
|
|
245
|
-
// x: Math.round(event.clientX - rect.left),
|
|
246
|
-
// y: Math.round(event.clientY - rect.top),
|
|
247
|
-
// }
|
|
248
|
-
// }
|
|
249
|
-
|
|
232
|
+
var rect = event.target.getBoundingClientRect()
|
|
250
233
|
return {
|
|
251
234
|
type: ActionType.CLICK,
|
|
252
|
-
target:
|
|
253
|
-
|
|
235
|
+
target: {
|
|
236
|
+
width: Math.round(rect.width),
|
|
237
|
+
height: Math.round(rect.height),
|
|
238
|
+
selector: getSelectorFromElement(event.target, actionNameAttribute)
|
|
239
|
+
},
|
|
240
|
+
position: {
|
|
241
|
+
x: Math.round(event.clientX - rect.left),
|
|
242
|
+
y: Math.round(event.clientY - rect.top)
|
|
243
|
+
},
|
|
254
244
|
name: getActionNameFromElement(event.target, actionNameAttribute)
|
|
255
245
|
}
|
|
256
246
|
}
|
|
@@ -361,7 +351,6 @@ function newClick(
|
|
|
361
351
|
},
|
|
362
352
|
clickActionBase
|
|
363
353
|
)
|
|
364
|
-
|
|
365
354
|
lifeCycle.notify(LifeCycleEventType.AUTO_ACTION_COMPLETED, clickAction)
|
|
366
355
|
status = ClickStatus.FINALIZED
|
|
367
356
|
},
|