@cloudcare/browser-rum 3.0.15 → 3.0.17

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.
@@ -283,13 +283,61 @@ function initViewportResizeObserver(cb) {
283
283
  return initViewportObservable().subscribe(cb).unsubscribe
284
284
  }
285
285
 
286
- export function initInputObserver(cb, defaultPrivacyLevel, options) {
287
- var domEvents = (options && options.domEvents) || [
288
- DOM_EVENT.INPUT,
289
- DOM_EVENT.CHANGE
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
- // frustrationCb({
546
- // timestamp: data.rawRumEvent.date,
547
- // type: RecordType.FrustrationRecord,
548
- // data: {
549
- // frustrationTypes: data.rawRumEvent.action.frustration.type,
550
- // recordIds: data.domainContext.events.map(function (e) {
551
- // return getRecordIdForEvent(e)
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,
@@ -66,7 +66,7 @@ function processAction(action, foregroundContexts) {
66
66
  count: action.counts.resourceCount
67
67
  }
68
68
  },
69
- _dd: {
69
+ _gc: {
70
70
  action: {
71
71
  target: action.target,
72
72
  position: action.position
@@ -166,7 +166,7 @@ function computeRequestTracingInfo(request) {
166
166
  return undefined
167
167
  }
168
168
  return {
169
- _dd: {
169
+ _gc: {
170
170
  spanId: request.spanId,
171
171
  traceId: request.traceId
172
172
  },
@@ -175,5 +175,5 @@ function computeRequestTracingInfo(request) {
175
175
  }
176
176
 
177
177
  function computeEntryTracingInfo(entry) {
178
- return entry.traceId ? { _dd: { traceId: entry.traceId } } : undefined
178
+ return entry.traceId ? { _gc: { traceId: entry.traceId } } : undefined
179
179
  }
@@ -78,7 +78,7 @@ function computePerformanceViewDetails(entry) {
78
78
  function processViewUpdate(view, foregroundContexts, recorderApi) {
79
79
  var replayStats = recorderApi.getReplayStats(view.id)
80
80
  var viewEvent = {
81
- _dd: {
81
+ _gc: {
82
82
  document_version: view.documentVersion,
83
83
  replay_stats: replayStats
84
84
  },