@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.
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildEnv = void 0;
7
7
  var buildEnv = {
8
- sdkVersion: '3.0.15',
8
+ sdkVersion: '3.0.17',
9
9
  sdkName: 'df_web_rum_sdk'
10
10
  };
11
11
  exports.buildEnv = buildEnv;
@@ -11,12 +11,31 @@ var SessionType = {
11
11
  SYNTHETICS: 'synthetics',
12
12
  USER: 'user'
13
13
  };
14
- var VIEW_EVENTS_MODIFIABLE_FIELD_PATHS = [// Fields with sensitive data
15
- 'view.url', 'view.referrer', 'action.target.name', 'error.message', 'error.stack', 'error.resource.url', 'resource.url'];
16
- var OTHER_EVENTS_MODIFIABLE_FIELD_PATHS = VIEW_EVENTS_MODIFIABLE_FIELD_PATHS.concat([// User-customizable field
17
- 'tags']);
14
+ var VIEW_MODIFIABLE_FIELD_PATHS = {
15
+ 'view.url': 'string',
16
+ 'view.referrer': 'string'
17
+ };
18
+ var USER_CUSTOMIZABLE_FIELD_PATHS = {
19
+ tags: 'object',
20
+ '_gc.trace_id': 'string',
21
+ '_gc.span_id': 'string'
22
+ };
23
+ var modifiableFieldPathsByEvent = {};
18
24
 
19
25
  function startRumAssembly(configuration, lifeCycle, sessionManager, userSessionManager, viewContexts, urlContexts, actionContexts, buildCommonContext, reportError) {
26
+ modifiableFieldPathsByEvent[_browserCore.RumEventType.VIEW] = VIEW_MODIFIABLE_FIELD_PATHS;
27
+ modifiableFieldPathsByEvent[_browserCore.RumEventType.ERROR] = (0, _browserCore.assign)({
28
+ 'error.message': 'string',
29
+ 'error.stack': 'string',
30
+ 'error.resource.url': 'string'
31
+ }, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS);
32
+ modifiableFieldPathsByEvent[_browserCore.RumEventType.RESOURCE] = (0, _browserCore.assign)({
33
+ 'resource.url': 'string'
34
+ }, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS);
35
+ modifiableFieldPathsByEvent[_browserCore.RumEventType.ACTION] = (0, _browserCore.assign)({
36
+ 'action.target.name': 'string'
37
+ }, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS);
38
+ modifiableFieldPathsByEvent[_browserCore.RumEventType.LONG_TASK] = (0, _browserCore.assign)({}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS);
20
39
  var eventRateLimiters = {};
21
40
  eventRateLimiters[_browserCore.RumEventType.ERROR] = (0, _browserCore.createEventRateLimiter)(_browserCore.RumEventType.ERROR, configuration.eventRateLimiterThreshold, reportError);
22
41
  eventRateLimiters[_browserCore.RumEventType.ACTION] = (0, _browserCore.createEventRateLimiter)(_browserCore.RumEventType.ACTION, configuration.eventRateLimiterThreshold, reportError);
@@ -34,7 +53,7 @@ function startRumAssembly(configuration, lifeCycle, sessionManager, userSessionM
34
53
  var actionId = actionContexts.findActionId(startTime);
35
54
  var commonContext = savedCommonContext || buildCommonContext();
36
55
  var rumContext = {
37
- _dd: {
56
+ _gc: {
38
57
  sdkName: configuration.sdkName,
39
58
  sdkVersion: configuration.sdkVersion,
40
59
  drift: (0, _browserCore.currentDrift)()
@@ -95,7 +114,7 @@ function startRumAssembly(configuration, lifeCycle, sessionManager, userSessionM
95
114
  }, commonContext.user);
96
115
  }
97
116
 
98
- if (shouldSend(serverRumEvent, configuration.beforeSend, eventRateLimiters, domainContext)) {
117
+ if (shouldSend(serverRumEvent, configuration.beforeSend, domainContext, eventRateLimiters)) {
99
118
  if ((0, _browserCore.isEmptyObject)(serverRumEvent.tags)) {
100
119
  delete serverRumEvent.tags;
101
120
  }
@@ -106,9 +125,9 @@ function startRumAssembly(configuration, lifeCycle, sessionManager, userSessionM
106
125
  });
107
126
  }
108
127
 
109
- function shouldSend(event, beforeSend, eventRateLimiters, domainContext) {
128
+ function shouldSend(event, beforeSend, domainContext, eventRateLimiters) {
110
129
  if (beforeSend) {
111
- var result = (0, _browserCore.limitModification)(event, event.type === _browserCore.RumEventType.VIEW ? VIEW_EVENTS_MODIFIABLE_FIELD_PATHS : OTHER_EVENTS_MODIFIABLE_FIELD_PATHS, function (event) {
130
+ var result = (0, _browserCore.limitModification)(event, modifiableFieldPathsByEvent[event.type], function (event) {
112
131
  return beforeSend(event, domainContext);
113
132
  });
114
133
 
@@ -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, options) {
220
- var domEvents = options && options.domEvents || [_browserCore.DOM_EVENT.INPUT, _browserCore.DOM_EVENT.CHANGE];
221
- var target = options && options.target || document;
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) {// frustrationCb({
451
- // timestamp: data.rawRumEvent.date,
452
- // type: RecordType.FrustrationRecord,
453
- // data: {
454
- // frustrationTypes: data.rawRumEvent.action.frustration.type,
455
- // recordIds: data.domainContext.events.map(function (e) {
456
- // return getRecordIdForEvent(e)
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() {
@@ -49,7 +49,7 @@ function processAction(action, foregroundContexts) {
49
49
  count: action.counts.resourceCount
50
50
  }
51
51
  },
52
- _dd: {
52
+ _gc: {
53
53
  action: {
54
54
  target: action.target,
55
55
  position: action.position
@@ -130,7 +130,7 @@ function computeRequestTracingInfo(request) {
130
130
  }
131
131
 
132
132
  return {
133
- _dd: {
133
+ _gc: {
134
134
  spanId: request.spanId,
135
135
  traceId: request.traceId
136
136
  },
@@ -142,7 +142,7 @@ function computeRequestTracingInfo(request) {
142
142
 
143
143
  function computeEntryTracingInfo(entry) {
144
144
  return entry.traceId ? {
145
- _dd: {
145
+ _gc: {
146
146
  traceId: entry.traceId
147
147
  }
148
148
  } : undefined;
@@ -69,7 +69,7 @@ function computePerformanceViewDetails(entry) {
69
69
  function processViewUpdate(view, foregroundContexts, recorderApi) {
70
70
  var replayStats = recorderApi.getReplayStats(view.id);
71
71
  var viewEvent = {
72
- _dd: {
72
+ _gc: {
73
73
  document_version: view.documentVersion,
74
74
  replay_stats: replayStats
75
75
  },
@@ -1,4 +1,4 @@
1
1
  export var buildEnv = {
2
- sdkVersion: '3.0.15',
2
+ sdkVersion: '3.0.17',
3
3
  sdkName: 'df_web_rum_sdk'
4
4
  };
@@ -1,13 +1,32 @@
1
- import { extend2Lev, withSnakeCaseKeys, timeStampNow, isEmptyObject, LifeCycleEventType, RumEventType, deviceInfo, currentDrift, createEventRateLimiter, limitModification, display } from '@cloudcare/browser-core';
1
+ import { extend2Lev, withSnakeCaseKeys, timeStampNow, isEmptyObject, LifeCycleEventType, RumEventType, deviceInfo, currentDrift, createEventRateLimiter, limitModification, display, assign } from '@cloudcare/browser-core';
2
2
  var SessionType = {
3
3
  SYNTHETICS: 'synthetics',
4
4
  USER: 'user'
5
5
  };
6
- var VIEW_EVENTS_MODIFIABLE_FIELD_PATHS = [// Fields with sensitive data
7
- 'view.url', 'view.referrer', 'action.target.name', 'error.message', 'error.stack', 'error.resource.url', 'resource.url'];
8
- var OTHER_EVENTS_MODIFIABLE_FIELD_PATHS = VIEW_EVENTS_MODIFIABLE_FIELD_PATHS.concat([// User-customizable field
9
- 'tags']);
6
+ var VIEW_MODIFIABLE_FIELD_PATHS = {
7
+ 'view.url': 'string',
8
+ 'view.referrer': 'string'
9
+ };
10
+ var USER_CUSTOMIZABLE_FIELD_PATHS = {
11
+ tags: 'object',
12
+ '_gc.trace_id': 'string',
13
+ '_gc.span_id': 'string'
14
+ };
15
+ var modifiableFieldPathsByEvent = {};
10
16
  export function startRumAssembly(configuration, lifeCycle, sessionManager, userSessionManager, viewContexts, urlContexts, actionContexts, buildCommonContext, reportError) {
17
+ modifiableFieldPathsByEvent[RumEventType.VIEW] = VIEW_MODIFIABLE_FIELD_PATHS;
18
+ modifiableFieldPathsByEvent[RumEventType.ERROR] = assign({
19
+ 'error.message': 'string',
20
+ 'error.stack': 'string',
21
+ 'error.resource.url': 'string'
22
+ }, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS);
23
+ modifiableFieldPathsByEvent[RumEventType.RESOURCE] = assign({
24
+ 'resource.url': 'string'
25
+ }, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS);
26
+ modifiableFieldPathsByEvent[RumEventType.ACTION] = assign({
27
+ 'action.target.name': 'string'
28
+ }, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS);
29
+ modifiableFieldPathsByEvent[RumEventType.LONG_TASK] = assign({}, USER_CUSTOMIZABLE_FIELD_PATHS, VIEW_MODIFIABLE_FIELD_PATHS);
11
30
  var eventRateLimiters = {};
12
31
  eventRateLimiters[RumEventType.ERROR] = createEventRateLimiter(RumEventType.ERROR, configuration.eventRateLimiterThreshold, reportError);
13
32
  eventRateLimiters[RumEventType.ACTION] = createEventRateLimiter(RumEventType.ACTION, configuration.eventRateLimiterThreshold, reportError);
@@ -25,7 +44,7 @@ export function startRumAssembly(configuration, lifeCycle, sessionManager, userS
25
44
  var actionId = actionContexts.findActionId(startTime);
26
45
  var commonContext = savedCommonContext || buildCommonContext();
27
46
  var rumContext = {
28
- _dd: {
47
+ _gc: {
29
48
  sdkName: configuration.sdkName,
30
49
  sdkVersion: configuration.sdkVersion,
31
50
  drift: currentDrift()
@@ -86,7 +105,7 @@ export function startRumAssembly(configuration, lifeCycle, sessionManager, userS
86
105
  }, commonContext.user);
87
106
  }
88
107
 
89
- if (shouldSend(serverRumEvent, configuration.beforeSend, eventRateLimiters, domainContext)) {
108
+ if (shouldSend(serverRumEvent, configuration.beforeSend, domainContext, eventRateLimiters)) {
90
109
  if (isEmptyObject(serverRumEvent.tags)) {
91
110
  delete serverRumEvent.tags;
92
111
  }
@@ -97,9 +116,9 @@ export function startRumAssembly(configuration, lifeCycle, sessionManager, userS
97
116
  });
98
117
  }
99
118
 
100
- function shouldSend(event, beforeSend, eventRateLimiters, domainContext) {
119
+ function shouldSend(event, beforeSend, domainContext, eventRateLimiters) {
101
120
  if (beforeSend) {
102
- var result = limitModification(event, event.type === RumEventType.VIEW ? VIEW_EVENTS_MODIFIABLE_FIELD_PATHS : OTHER_EVENTS_MODIFIABLE_FIELD_PATHS, function (event) {
121
+ var result = limitModification(event, modifiableFieldPathsByEvent[event.type], function (event) {
103
122
  return beforeSend(event, domainContext);
104
123
  });
105
124
 
@@ -201,10 +201,47 @@ function initViewportResizeObserver(cb) {
201
201
  return initViewportObservable().subscribe(cb).unsubscribe;
202
202
  }
203
203
 
204
- export function initInputObserver(cb, defaultPrivacyLevel, options) {
205
- var domEvents = options && options.domEvents || [DOM_EVENT.INPUT, DOM_EVENT.CHANGE];
206
- var target = options && options.target || document;
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) {// frustrationCb({
435
- // timestamp: data.rawRumEvent.date,
436
- // type: RecordType.FrustrationRecord,
437
- // data: {
438
- // frustrationTypes: data.rawRumEvent.action.frustration.type,
439
- // recordIds: data.domainContext.events.map(function (e) {
440
- // return getRecordIdForEvent(e)
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() {
@@ -40,7 +40,7 @@ function processAction(action, foregroundContexts) {
40
40
  count: action.counts.resourceCount
41
41
  }
42
42
  },
43
- _dd: {
43
+ _gc: {
44
44
  action: {
45
45
  target: action.target,
46
46
  position: action.position
@@ -119,7 +119,7 @@ function computeRequestTracingInfo(request) {
119
119
  }
120
120
 
121
121
  return {
122
- _dd: {
122
+ _gc: {
123
123
  spanId: request.spanId,
124
124
  traceId: request.traceId
125
125
  },
@@ -131,7 +131,7 @@ function computeRequestTracingInfo(request) {
131
131
 
132
132
  function computeEntryTracingInfo(entry) {
133
133
  return entry.traceId ? {
134
- _dd: {
134
+ _gc: {
135
135
  traceId: entry.traceId
136
136
  }
137
137
  } : undefined;
@@ -59,7 +59,7 @@ function computePerformanceViewDetails(entry) {
59
59
  function processViewUpdate(view, foregroundContexts, recorderApi) {
60
60
  var replayStats = recorderApi.getReplayStats(view.id);
61
61
  var viewEvent = {
62
- _dd: {
62
+ _gc: {
63
63
  document_version: view.documentVersion,
64
64
  replay_stats: replayStats
65
65
  },
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@cloudcare/browser-rum",
3
- "version": "3.0.15",
3
+ "version": "3.0.17",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "dependencies": {
7
- "@cloudcare/browser-core": "2.0.13"
7
+ "@cloudcare/browser-core": "2.0.15"
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": "770d3987076f77be6dee3ba6b2c11207ba593312"
32
+ "gitHead": "a62a6d650316cdd0471530a2954add77a21ebaad"
33
33
  }
@@ -9,29 +9,26 @@ import {
9
9
  currentDrift,
10
10
  createEventRateLimiter,
11
11
  limitModification,
12
- display
12
+ display,
13
+ assign
13
14
  } from '@cloudcare/browser-core'
14
15
  var SessionType = {
15
16
  SYNTHETICS: 'synthetics',
16
17
  USER: 'user'
17
18
  }
18
19
 
19
- var VIEW_EVENTS_MODIFIABLE_FIELD_PATHS = [
20
- // Fields with sensitive data
21
- 'view.url',
22
- 'view.referrer',
23
- 'action.target.name',
24
- 'error.message',
25
- 'error.stack',
26
- 'error.resource.url',
27
- 'resource.url'
28
- ]
20
+ var VIEW_MODIFIABLE_FIELD_PATHS = {
21
+ 'view.url': 'string',
22
+ 'view.referrer': 'string'
23
+ }
24
+
25
+ var USER_CUSTOMIZABLE_FIELD_PATHS = {
26
+ tags: 'object',
27
+ '_gc.trace_id': 'string',
28
+ '_gc.span_id': 'string'
29
+ }
29
30
 
30
- var OTHER_EVENTS_MODIFIABLE_FIELD_PATHS =
31
- VIEW_EVENTS_MODIFIABLE_FIELD_PATHS.concat([
32
- // User-customizable field
33
- 'tags'
34
- ])
31
+ var modifiableFieldPathsByEvent = {}
35
32
  export function startRumAssembly(
36
33
  configuration,
37
34
  lifeCycle,
@@ -43,6 +40,35 @@ export function startRumAssembly(
43
40
  buildCommonContext,
44
41
  reportError
45
42
  ) {
43
+ modifiableFieldPathsByEvent[RumEventType.VIEW] = VIEW_MODIFIABLE_FIELD_PATHS
44
+ modifiableFieldPathsByEvent[RumEventType.ERROR] = assign(
45
+ {
46
+ 'error.message': 'string',
47
+ 'error.stack': 'string',
48
+ 'error.resource.url': 'string'
49
+ },
50
+ USER_CUSTOMIZABLE_FIELD_PATHS,
51
+ VIEW_MODIFIABLE_FIELD_PATHS
52
+ )
53
+ modifiableFieldPathsByEvent[RumEventType.RESOURCE] = assign(
54
+ {
55
+ 'resource.url': 'string'
56
+ },
57
+ USER_CUSTOMIZABLE_FIELD_PATHS,
58
+ VIEW_MODIFIABLE_FIELD_PATHS
59
+ )
60
+ modifiableFieldPathsByEvent[RumEventType.ACTION] = assign(
61
+ {
62
+ 'action.target.name': 'string'
63
+ },
64
+ USER_CUSTOMIZABLE_FIELD_PATHS,
65
+ VIEW_MODIFIABLE_FIELD_PATHS
66
+ )
67
+ modifiableFieldPathsByEvent[RumEventType.LONG_TASK] = assign(
68
+ {},
69
+ USER_CUSTOMIZABLE_FIELD_PATHS,
70
+ VIEW_MODIFIABLE_FIELD_PATHS
71
+ )
46
72
  var eventRateLimiters = {}
47
73
  eventRateLimiters[RumEventType.ERROR] = createEventRateLimiter(
48
74
  RumEventType.ERROR,
@@ -72,7 +98,7 @@ export function startRumAssembly(
72
98
  var actionId = actionContexts.findActionId(startTime)
73
99
  var commonContext = savedCommonContext || buildCommonContext()
74
100
  var rumContext = {
75
- _dd: {
101
+ _gc: {
76
102
  sdkName: configuration.sdkName,
77
103
  sdkVersion: configuration.sdkVersion,
78
104
  drift: currentDrift()
@@ -139,8 +165,8 @@ export function startRumAssembly(
139
165
  shouldSend(
140
166
  serverRumEvent,
141
167
  configuration.beforeSend,
142
- eventRateLimiters,
143
- domainContext
168
+ domainContext,
169
+ eventRateLimiters
144
170
  )
145
171
  ) {
146
172
  if (isEmptyObject(serverRumEvent.tags)) {
@@ -156,13 +182,11 @@ export function startRumAssembly(
156
182
  )
157
183
  }
158
184
 
159
- function shouldSend(event, beforeSend, eventRateLimiters, domainContext) {
185
+ function shouldSend(event, beforeSend, domainContext, eventRateLimiters) {
160
186
  if (beforeSend) {
161
187
  var result = limitModification(
162
188
  event,
163
- event.type === RumEventType.VIEW
164
- ? VIEW_EVENTS_MODIFIABLE_FIELD_PATHS
165
- : OTHER_EVENTS_MODIFIABLE_FIELD_PATHS,
189
+ modifiableFieldPathsByEvent[event.type],
166
190
  function (event) {
167
191
  return beforeSend(event, domainContext)
168
192
  }