@newrelic/browser-agent 1.232.1 → 1.233.0

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.
Files changed (233) hide show
  1. package/dist/cjs/cdn/polyfills.js +5 -2
  2. package/dist/cjs/common/config/state/configurable.js +15 -26
  3. package/dist/cjs/common/config/state/info.js +1 -1
  4. package/dist/cjs/common/config/state/init.js +101 -56
  5. package/dist/cjs/common/config/state/loader-config.js +1 -1
  6. package/dist/cjs/common/config/state/runtime.js +1 -5
  7. package/dist/cjs/common/constants/env.cdn.js +1 -1
  8. package/dist/cjs/common/constants/env.npm.js +1 -1
  9. package/dist/cjs/common/drain/drain.js +1 -1
  10. package/dist/cjs/common/harvest/harvest-scheduler.js +30 -10
  11. package/dist/cjs/common/harvest/harvest.js +119 -55
  12. package/dist/cjs/common/session/session-entity.js +35 -22
  13. package/dist/cjs/common/session/session-entity.test.js +73 -49
  14. package/dist/cjs/common/timer/interaction-timer.js +9 -12
  15. package/dist/cjs/common/url/protocol.test.js +0 -1
  16. package/dist/cjs/common/util/feature-flags.js +2 -1
  17. package/dist/cjs/common/util/submit-data.js +57 -18
  18. package/dist/cjs/common/wrap/wrap-fetch.js +1 -1
  19. package/dist/cjs/common/wrap/wrap-function.js +1 -1
  20. package/dist/cjs/common/wrap/wrap-promise.js +1 -1
  21. package/dist/cjs/features/ajax/aggregate/index.js +2 -2
  22. package/dist/cjs/features/jserrors/aggregate/index.js +7 -5
  23. package/dist/cjs/features/metrics/aggregate/framework-detection.js +67 -0
  24. package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +137 -0
  25. package/dist/cjs/features/metrics/aggregate/index.js +7 -3
  26. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +14 -0
  27. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +17 -0
  28. package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +53 -0
  29. package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +165 -0
  30. package/dist/cjs/features/page_action/aggregate/index.js +2 -2
  31. package/dist/cjs/features/page_view_event/aggregate/index.js +6 -3
  32. package/dist/cjs/features/page_view_timing/aggregate/index.js +2 -2
  33. package/dist/cjs/features/session_replay/aggregate/index.js +333 -0
  34. package/dist/cjs/features/session_replay/constants.js +9 -0
  35. package/dist/cjs/features/session_replay/index.js +12 -0
  36. package/dist/cjs/features/session_replay/instrument/index.js +29 -0
  37. package/dist/cjs/features/session_trace/aggregate/index.js +163 -162
  38. package/dist/cjs/features/session_trace/constants.js +2 -9
  39. package/dist/cjs/features/session_trace/instrument/index.js +24 -66
  40. package/dist/cjs/features/spa/aggregate/index.js +2 -2
  41. package/dist/cjs/features/utils/agent-session.js +1 -2
  42. package/dist/cjs/features/utils/aggregate-base.js +64 -0
  43. package/dist/cjs/features/utils/feature-base.js +0 -31
  44. package/dist/cjs/features/utils/handler-cache.js +3 -4
  45. package/dist/cjs/features/utils/instrument-base.js +42 -10
  46. package/dist/cjs/features/utils/{lazy-loader.js → lazy-feature-loader.js} +4 -2
  47. package/dist/cjs/loaders/agent.js +1 -1
  48. package/dist/cjs/loaders/api/apiAsync.js +3 -1
  49. package/dist/cjs/loaders/configure/configure.js +3 -3
  50. package/dist/cjs/loaders/features/featureDependencies.js +0 -12
  51. package/dist/cjs/loaders/features/features.js +3 -1
  52. package/dist/cjs/loaders/micro-agent.js +6 -6
  53. package/dist/esm/cdn/polyfills.js +5 -2
  54. package/dist/esm/common/config/state/configurable.js +14 -24
  55. package/dist/esm/common/config/state/info.js +2 -2
  56. package/dist/esm/common/config/state/init.js +102 -57
  57. package/dist/esm/common/config/state/loader-config.js +2 -2
  58. package/dist/esm/common/config/state/runtime.js +2 -4
  59. package/dist/esm/common/constants/env.cdn.js +1 -1
  60. package/dist/esm/common/constants/env.npm.js +1 -1
  61. package/dist/esm/common/drain/drain.js +1 -1
  62. package/dist/esm/common/harvest/harvest-scheduler.js +30 -10
  63. package/dist/esm/common/harvest/harvest.js +121 -56
  64. package/dist/esm/common/session/session-entity.js +35 -22
  65. package/dist/esm/common/session/session-entity.test.js +73 -49
  66. package/dist/esm/common/timer/interaction-timer.js +9 -12
  67. package/dist/esm/common/url/protocol.test.js +0 -1
  68. package/dist/esm/common/util/feature-flags.js +2 -1
  69. package/dist/esm/common/util/submit-data.js +57 -18
  70. package/dist/esm/common/wrap/wrap-fetch.js +1 -1
  71. package/dist/esm/common/wrap/wrap-function.js +1 -1
  72. package/dist/esm/common/wrap/wrap-promise.js +1 -1
  73. package/dist/esm/features/ajax/aggregate/index.js +2 -2
  74. package/dist/esm/features/jserrors/aggregate/index.js +7 -5
  75. package/dist/esm/features/metrics/aggregate/framework-detection.js +61 -0
  76. package/dist/esm/features/metrics/aggregate/framework-detection.test.js +133 -0
  77. package/dist/esm/features/metrics/aggregate/index.js +7 -3
  78. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +8 -0
  79. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +15 -0
  80. package/dist/esm/features/metrics/aggregate/polyfill-detection.js +47 -0
  81. package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +163 -0
  82. package/dist/esm/features/page_action/aggregate/index.js +2 -2
  83. package/dist/esm/features/page_view_event/aggregate/index.js +6 -3
  84. package/dist/esm/features/page_view_timing/aggregate/index.js +2 -2
  85. package/dist/esm/features/session_replay/aggregate/index.js +327 -0
  86. package/dist/esm/features/session_replay/constants.js +2 -0
  87. package/dist/esm/features/session_replay/index.js +12 -0
  88. package/dist/esm/features/session_replay/instrument/index.js +21 -0
  89. package/dist/esm/features/session_trace/aggregate/index.js +163 -162
  90. package/dist/esm/features/session_trace/constants.js +1 -5
  91. package/dist/esm/features/session_trace/instrument/index.js +24 -66
  92. package/dist/esm/features/spa/aggregate/index.js +2 -2
  93. package/dist/esm/features/utils/agent-session.js +1 -2
  94. package/dist/esm/features/utils/aggregate-base.js +57 -0
  95. package/dist/esm/features/utils/feature-base.js +1 -32
  96. package/dist/esm/features/utils/handler-cache.js +3 -4
  97. package/dist/esm/features/utils/instrument-base.js +42 -10
  98. package/dist/esm/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
  99. package/dist/esm/loaders/agent.js +1 -1
  100. package/dist/esm/loaders/api/apiAsync.js +3 -1
  101. package/dist/esm/loaders/configure/configure.js +3 -3
  102. package/dist/esm/loaders/features/featureDependencies.js +0 -11
  103. package/dist/esm/loaders/features/features.js +3 -1
  104. package/dist/esm/loaders/micro-agent.js +6 -6
  105. package/dist/types/common/config/state/configurable.d.ts +1 -3
  106. package/dist/types/common/config/state/configurable.d.ts.map +1 -1
  107. package/dist/types/common/config/state/init.d.ts.map +1 -1
  108. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  109. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  110. package/dist/types/common/harvest/harvest.d.ts +37 -34
  111. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  112. package/dist/types/common/session/session-entity.d.ts +6 -3
  113. package/dist/types/common/session/session-entity.d.ts.map +1 -1
  114. package/dist/types/common/timer/interaction-timer.d.ts +2 -1
  115. package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
  116. package/dist/types/common/util/feature-flags.d.ts.map +1 -1
  117. package/dist/types/common/util/submit-data.d.ts +40 -14
  118. package/dist/types/common/util/submit-data.d.ts.map +1 -1
  119. package/dist/types/features/ajax/aggregate/index.d.ts +2 -2
  120. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  121. package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
  122. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  123. package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -0
  124. package/dist/types/features/metrics/aggregate/index.d.ts +2 -2
  125. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  126. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +6 -0
  127. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +1 -0
  128. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +7 -0
  129. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +1 -0
  130. package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
  131. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  132. package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -2
  133. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  134. package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
  135. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  136. package/dist/types/features/session_replay/aggregate/index.d.ts +96 -0
  137. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -0
  138. package/dist/types/features/session_replay/constants.d.ts +2 -0
  139. package/dist/types/features/session_replay/constants.d.ts.map +1 -0
  140. package/dist/types/features/session_replay/index.d.ts +2 -0
  141. package/dist/types/features/session_replay/index.d.ts.map +1 -0
  142. package/dist/types/features/session_replay/instrument/index.d.ts +6 -0
  143. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -0
  144. package/dist/types/features/session_trace/aggregate/index.d.ts +8 -57
  145. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  146. package/dist/types/features/session_trace/constants.d.ts +0 -3
  147. package/dist/types/features/session_trace/constants.d.ts.map +1 -1
  148. package/dist/types/features/session_trace/instrument/index.d.ts +1 -3
  149. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  150. package/dist/types/features/spa/aggregate/index.d.ts +2 -2
  151. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  152. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  153. package/dist/types/features/utils/aggregate-base.d.ts +11 -0
  154. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -0
  155. package/dist/types/features/utils/feature-base.d.ts +0 -5
  156. package/dist/types/features/utils/feature-base.d.ts.map +1 -1
  157. package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
  158. package/dist/types/features/utils/instrument-base.d.ts +3 -1
  159. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  160. package/dist/types/features/utils/{lazy-loader.d.ts → lazy-feature-loader.d.ts} +2 -2
  161. package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -0
  162. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  163. package/dist/types/loaders/features/featureDependencies.d.ts +0 -1
  164. package/dist/types/loaders/features/featureDependencies.d.ts.map +1 -1
  165. package/dist/types/loaders/features/features.d.ts +1 -0
  166. package/dist/types/loaders/features/features.d.ts.map +1 -1
  167. package/package.json +28 -19
  168. package/src/cdn/polyfills.js +4 -1
  169. package/src/common/config/state/configurable.js +18 -24
  170. package/src/common/config/state/info.js +2 -2
  171. package/src/common/config/state/init.js +62 -28
  172. package/src/common/config/state/loader-config.js +2 -2
  173. package/src/common/config/state/runtime.js +2 -4
  174. package/src/common/drain/drain.js +1 -1
  175. package/src/common/harvest/harvest-scheduler.js +35 -10
  176. package/src/common/harvest/harvest.js +73 -50
  177. package/src/common/session/session-entity.js +34 -23
  178. package/src/common/session/session-entity.test.js +57 -51
  179. package/src/common/timer/interaction-timer.js +9 -12
  180. package/src/common/url/protocol.test.js +0 -1
  181. package/src/common/util/feature-flags.js +2 -2
  182. package/src/common/util/submit-data.js +28 -17
  183. package/src/common/wrap/wrap-fetch.js +1 -1
  184. package/src/common/wrap/wrap-function.js +1 -1
  185. package/src/common/wrap/wrap-promise.js +1 -1
  186. package/src/features/ajax/aggregate/index.js +2 -2
  187. package/src/features/jserrors/aggregate/index.js +7 -5
  188. package/src/features/metrics/aggregate/framework-detection.js +73 -0
  189. package/src/features/metrics/aggregate/framework-detection.test.js +201 -0
  190. package/src/features/metrics/aggregate/index.js +8 -3
  191. package/src/features/metrics/aggregate/polyfill-detection.es5.js +9 -0
  192. package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +16 -0
  193. package/src/features/metrics/aggregate/polyfill-detection.js +48 -0
  194. package/src/features/metrics/aggregate/polyfill-detection.test.js +163 -0
  195. package/src/features/page_action/aggregate/index.js +2 -2
  196. package/src/features/page_view_event/aggregate/index.js +5 -5
  197. package/src/features/page_view_timing/aggregate/index.js +2 -2
  198. package/src/features/session_replay/aggregate/index.js +314 -0
  199. package/src/features/session_replay/constants.js +3 -0
  200. package/src/features/session_replay/index.js +12 -0
  201. package/src/features/session_replay/instrument/index.js +22 -0
  202. package/src/features/session_trace/aggregate/index.js +148 -187
  203. package/src/features/session_trace/constants.js +0 -4
  204. package/src/features/session_trace/instrument/index.js +17 -69
  205. package/src/features/spa/aggregate/index.js +2 -2
  206. package/src/features/utils/agent-session.js +1 -2
  207. package/src/features/utils/aggregate-base.js +51 -0
  208. package/src/features/utils/feature-base.js +1 -31
  209. package/src/features/utils/handler-cache.js +3 -4
  210. package/src/features/utils/instrument-base.js +40 -8
  211. package/src/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
  212. package/src/loaders/agent.js +1 -1
  213. package/src/loaders/api/apiAsync.js +1 -1
  214. package/src/loaders/configure/configure.js +4 -3
  215. package/src/loaders/features/featureDependencies.js +0 -12
  216. package/src/loaders/features/features.js +3 -1
  217. package/src/loaders/micro-agent.js +4 -4
  218. package/dist/cjs/common/metrics/framework-detection.js +0 -72
  219. package/dist/cjs/common/util/user-agent.js +0 -57
  220. package/dist/cjs/common/window/supports-performance-observer.js +0 -15
  221. package/dist/esm/common/metrics/framework-detection.js +0 -66
  222. package/dist/esm/common/util/user-agent.js +0 -48
  223. package/dist/esm/common/window/supports-performance-observer.js +0 -9
  224. package/dist/types/common/metrics/framework-detection.d.ts.map +0 -1
  225. package/dist/types/common/util/user-agent.d.ts +0 -5
  226. package/dist/types/common/util/user-agent.d.ts.map +0 -1
  227. package/dist/types/common/window/supports-performance-observer.d.ts +0 -2
  228. package/dist/types/common/window/supports-performance-observer.d.ts.map +0 -1
  229. package/dist/types/features/utils/lazy-loader.d.ts.map +0 -1
  230. package/src/common/metrics/framework-detection.js +0 -71
  231. package/src/common/util/user-agent.js +0 -56
  232. package/src/common/window/supports-performance-observer.js +0 -10
  233. /package/dist/types/{common/metrics → features/metrics/aggregate}/framework-detection.d.ts +0 -0
@@ -2,8 +2,10 @@
2
2
 
3
3
  require("core-js/stable/promise");
4
4
  require("core-js/stable/array/includes");
5
- require("core-js/stable/array/from");
6
5
  require("core-js/stable/array/find");
6
+ require("core-js/stable/array/flat");
7
+ require("core-js/stable/array/flat-map");
8
+ require("core-js/stable/array/from");
7
9
  require("core-js/stable/array/some");
8
10
  require("core-js/stable/object/assign");
9
11
  require("core-js/stable/object/entries");
@@ -11,4 +13,5 @@ require("core-js/stable/object/values");
11
13
  require("core-js/stable/map");
12
14
  require("core-js/stable/reflect");
13
15
  require("core-js/stable/set");
14
- require("core-js/stable/weak-set");
16
+ require("core-js/stable/weak-set");
17
+ require("core-js/stable/object/get-own-property-descriptors");
@@ -3,36 +3,25 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Configurable = void 0;
7
- var _featureDependencies = require("../../../loaders/features/featureDependencies");
6
+ exports.getModeledObject = getModeledObject;
8
7
  var _console = require("../../util/console");
9
- class Configurable {
10
- constructor(obj, model) {
11
- Object.assign(this, setValues(obj, model));
12
- }
13
- }
14
- exports.Configurable = Configurable;
15
- function setValues(obj, model) {
16
- const state = {};
8
+ function getModeledObject(obj, model) {
17
9
  try {
18
- if (!obj || typeof obj !== 'object') return (0, _console.warn)('New setting a Configurable requires an object as input');
10
+ if (!obj || typeof obj !== 'object') return (0, _console.warn)('Setting a Configurable requires an object as input');
19
11
  if (!model || typeof model !== 'object') return (0, _console.warn)('Setting a Configurable requires a model to set its initial properties');
20
- Object.assign(state, model);
21
- Object.entries(obj).forEach(_ref => {
22
- let [key, value] = _ref;
23
- if (!Object.keys(model).includes(key)) return;
24
- const frozenAttrs = (0, _featureDependencies.getFrozenAttributes)(key);
25
- if (frozenAttrs.length && value && typeof value === 'object') {
26
- frozenAttrs.forEach(attr => {
27
- if (attr in value) {
28
- (0, _console.warn)("\"".concat(attr, "\" is a protected attribute and can not be changed in feature ").concat(key, ". It will have no effect."));
29
- delete value[attr];
30
- }
31
- });
12
+ // allow getters and setters to pass from model to target
13
+ const output = Object.create(Object.getPrototypeOf(model), Object.getOwnPropertyDescriptors(model));
14
+ const target = Object.keys(output).length === 0 ? obj : output;
15
+ for (let key in target) {
16
+ if (obj[key] !== undefined) {
17
+ try {
18
+ if (typeof obj[key] === 'object' && typeof model[key] === 'object') output[key] = getModeledObject(obj[key], model[key]);else output[key] = obj[key];
19
+ } catch (e) {
20
+ (0, _console.warn)('An error occurred while setting a property of a Configurable', e);
21
+ }
32
22
  }
33
- state[key] = value;
34
- });
35
- return state;
23
+ }
24
+ return output;
36
25
  } catch (err) {
37
26
  (0, _console.warn)('An error occured while setting a Configurable', err);
38
27
  }
@@ -45,6 +45,6 @@ function getInfo(id) {
45
45
  }
46
46
  function setInfo(id, obj) {
47
47
  if (!id) throw new Error('All info objects require an agent identifier!');
48
- _cache[id] = new _configurable.Configurable(obj, model);
48
+ _cache[id] = (0, _configurable.getModeledObject)(obj, model);
49
49
  (0, _nreum.gosNREUMInitializedAgents)(id, _cache[id], 'info');
50
50
  }
@@ -7,63 +7,108 @@ exports.getConfiguration = getConfiguration;
7
7
  exports.getConfigurationValue = getConfigurationValue;
8
8
  exports.setConfiguration = setConfiguration;
9
9
  var _constants = require("../../session/constants");
10
- var _globalScope = require("../../util/global-scope");
11
10
  var _nreum = require("../../window/nreum");
12
11
  var _configurable = require("./configurable");
13
- const model = {
14
- allow_bfcache: true,
15
- // *cli - temporary feature flag for BFCache work
16
- privacy: {
17
- cookies_enabled: true
18
- },
19
- // *cli - per discussion, default should be true
20
- ajax: {
21
- deny_list: undefined,
22
- enabled: true,
23
- harvestTimeSeconds: 10
24
- },
25
- distributed_tracing: {
26
- enabled: undefined,
27
- exclude_newrelic_header: undefined,
28
- cors_use_newrelic_header: undefined,
29
- cors_use_tracecontext_headers: undefined,
30
- allowed_origins: undefined
31
- },
32
- session: {
33
- domain: undefined,
34
- // used by first party cookies to set the top-level domain
35
- expiresMs: _constants.DEFAULT_EXPIRES_MS,
36
- inactiveMs: _constants.DEFAULT_INACTIVE_MS
37
- },
38
- ssl: undefined,
39
- obfuscate: undefined,
40
- jserrors: {
41
- enabled: true,
42
- harvestTimeSeconds: 10
43
- },
44
- metrics: {
45
- enabled: true
46
- },
47
- page_action: {
48
- enabled: true,
49
- harvestTimeSeconds: 30
50
- },
51
- page_view_event: {
52
- enabled: true
53
- },
54
- page_view_timing: {
55
- enabled: true,
56
- harvestTimeSeconds: 30,
57
- long_task: false
58
- },
59
- session_trace: {
60
- enabled: true,
61
- harvestTimeSeconds: 10
62
- },
63
- spa: {
64
- enabled: true,
65
- harvestTimeSeconds: 10
66
- }
12
+ const model = () => {
13
+ const hiddenState = {
14
+ blockSelector: '[data-nr-block]',
15
+ maskInputOptions: {
16
+ password: true
17
+ }
18
+ };
19
+ return {
20
+ allow_bfcache: true,
21
+ // *cli - temporary feature flag for BFCache work
22
+ privacy: {
23
+ cookies_enabled: true
24
+ },
25
+ // *cli - per discussion, default should be true
26
+ ajax: {
27
+ deny_list: undefined,
28
+ enabled: true,
29
+ harvestTimeSeconds: 10
30
+ },
31
+ distributed_tracing: {
32
+ enabled: undefined,
33
+ exclude_newrelic_header: undefined,
34
+ cors_use_newrelic_header: undefined,
35
+ cors_use_tracecontext_headers: undefined,
36
+ allowed_origins: undefined
37
+ },
38
+ session: {
39
+ domain: undefined,
40
+ // used by first party cookies to set the top-level domain
41
+ expiresMs: _constants.DEFAULT_EXPIRES_MS,
42
+ inactiveMs: _constants.DEFAULT_INACTIVE_MS
43
+ },
44
+ ssl: undefined,
45
+ obfuscate: undefined,
46
+ jserrors: {
47
+ enabled: true,
48
+ harvestTimeSeconds: 10
49
+ },
50
+ metrics: {
51
+ enabled: true
52
+ },
53
+ page_action: {
54
+ enabled: true,
55
+ harvestTimeSeconds: 30
56
+ },
57
+ page_view_event: {
58
+ enabled: true
59
+ },
60
+ page_view_timing: {
61
+ enabled: true,
62
+ harvestTimeSeconds: 30,
63
+ long_task: false
64
+ },
65
+ session_trace: {
66
+ enabled: true,
67
+ harvestTimeSeconds: 10
68
+ },
69
+ session_replay: {
70
+ // feature settings
71
+ enabled: true,
72
+ harvestTimeSeconds: 60,
73
+ sampleRate: 0.1,
74
+ errorSampleRate: 0.1,
75
+ // recording config settings
76
+ maskTextSelector: '*',
77
+ maskAllInputs: true,
78
+ // these properties only have getters because they are enforcable constants and should error if someone tries to override them
79
+ get blockClass() {
80
+ return 'nr-block';
81
+ },
82
+ get ignoreClass() {
83
+ return 'nr-ignore';
84
+ },
85
+ get maskTextClass() {
86
+ return 'nr-mask';
87
+ },
88
+ // props with a getter and setter are used to extend enforcable constants with customer input
89
+ // we must preserve data-nr-block no matter what else the customer sets
90
+ get blockSelector() {
91
+ return hiddenState.blockSelector;
92
+ },
93
+ set blockSelector(val) {
94
+ hiddenState.blockSelector += ",".concat(val);
95
+ },
96
+ // password: must always be present and true no matter what customer sets
97
+ get maskInputOptions() {
98
+ return hiddenState.maskInputOptions;
99
+ },
100
+ set maskInputOptions(val) {
101
+ hiddenState.maskInputOptions = {
102
+ ...val,
103
+ password: true
104
+ };
105
+ }
106
+ },
107
+ spa: {
108
+ enabled: true,
109
+ harvestTimeSeconds: 10
110
+ }
111
+ };
67
112
  };
68
113
  const _cache = {};
69
114
  function getConfiguration(id) {
@@ -73,7 +118,7 @@ function getConfiguration(id) {
73
118
  }
74
119
  function setConfiguration(id, obj) {
75
120
  if (!id) throw new Error('All configuration objects require an agent identifier!');
76
- _cache[id] = new _configurable.Configurable(obj, model);
121
+ _cache[id] = (0, _configurable.getModeledObject)(obj, model());
77
122
  (0, _nreum.gosNREUMInitializedAgents)(id, _cache[id], 'config');
78
123
  }
79
124
  function getConfigurationValue(id, path) {
@@ -23,6 +23,6 @@ function getLoaderConfig(id) {
23
23
  }
24
24
  function setLoaderConfig(id, obj) {
25
25
  if (!id) throw new Error('All loader-config objects require an agent identifier!');
26
- _cache[id] = new _configurable.Configurable(obj, model);
26
+ _cache[id] = (0, _configurable.getModeledObject)(obj, model);
27
27
  (0, _nreum.gosNREUMInitializedAgents)(id, _cache[id], 'loader_config');
28
28
  }
@@ -5,13 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getRuntime = getRuntime;
7
7
  exports.setRuntime = setRuntime;
8
- var userAgent = _interopRequireWildcard(require("../../util/user-agent"));
9
8
  var _configurable = require("./configurable");
10
9
  var _nreum = require("../../window/nreum");
11
10
  var _globalScope = require("../../util/global-scope");
12
11
  var _env = require("../../constants/env.npm");
13
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
12
  const model = {
16
13
  buildEnv: _env.BUILD_ENV,
17
14
  bytesSent: {},
@@ -33,7 +30,6 @@ const model = {
33
30
  releaseIds: {},
34
31
  session: undefined,
35
32
  xhrWrappable: typeof _globalScope.globalScope.XMLHttpRequest?.prototype?.addEventListener === 'function',
36
- userAgent,
37
33
  version: _env.VERSION
38
34
  };
39
35
  const _cache = {};
@@ -44,6 +40,6 @@ function getRuntime(id) {
44
40
  }
45
41
  function setRuntime(id, obj) {
46
42
  if (!id) throw new Error('All runtime objects require an agent identifier!');
47
- _cache[id] = new _configurable.Configurable(obj, model);
43
+ _cache[id] = (0, _configurable.getModeledObject)(obj, model);
48
44
  (0, _nreum.gosNREUMInitializedAgents)(id, _cache[id], 'runtime');
49
45
  }
@@ -12,7 +12,7 @@ exports.VERSION = exports.DIST_METHOD = exports.BUILD_ENV = void 0;
12
12
  /**
13
13
  * Exposes the version of the agent
14
14
  */
15
- const VERSION = "1.232.1";
15
+ const VERSION = "1.233.0";
16
16
 
17
17
  /**
18
18
  * Exposes the build type of the agent
@@ -12,7 +12,7 @@ exports.VERSION = exports.DIST_METHOD = exports.BUILD_ENV = void 0;
12
12
  /**
13
13
  * Exposes the version of the agent
14
14
  */
15
- const VERSION = "1.232.1";
15
+ const VERSION = "1.233.0";
16
16
 
17
17
  /**
18
18
  * Exposes the build type of the agent
@@ -66,7 +66,7 @@ function drain() {
66
66
 
67
67
  // Only when the event-groups for all features are ready to drain (staged) do we execute the drain. This has the effect
68
68
  // that the last feature to call drain triggers drain for all features.
69
- const items = Array.from(registry[agentIdentifier]);
69
+ const items = [...registry[agentIdentifier]];
70
70
  if (items.every(_ref => {
71
71
  let [key, values] = _ref;
72
72
  return values.staged;
@@ -69,23 +69,43 @@ class HarvestScheduler extends _sharedContext.SharedContext {
69
69
  runHarvest(opts) {
70
70
  if (this.aborted) return;
71
71
  var scheduler = this;
72
+ let harvests = [];
73
+ let submitMethod;
72
74
  if (this.opts.getPayload) {
73
- // Ajax & PVT
74
- var submitMethod = (0, _harvest.getSubmitMethod)(this.endpoint, opts);
75
+ // Ajax & PVT & SR
76
+ submitMethod = (0, _harvest.getSubmitMethod)(this.endpoint, opts);
75
77
  if (!submitMethod) return false;
76
- var retry = submitMethod.method === _submitData.submitData.xhr;
78
+ const retry = submitMethod.method === _submitData.submitData.xhr;
77
79
  var payload = this.opts.getPayload({
78
80
  retry: retry
79
81
  });
80
- if (payload) {
81
- payload = Object.prototype.toString.call(payload) === '[object Array]' ? payload : [payload];
82
- for (var i = 0; i < payload.length; i++) {
83
- this.harvest.send(this.endpoint, payload[i], opts, submitMethod, onHarvestFinished);
84
- }
85
- }
82
+ if (!payload) return;
83
+ payload = Object.prototype.toString.call(payload) === '[object Array]' ? payload : [payload];
84
+ harvests.push(...payload);
85
+ }
86
+
87
+ /** sendX is used for features that do not supply a preformatted payload via "getPayload" */
88
+ let send = args => this.harvest.sendX(args);
89
+ if (harvests.length) {
90
+ /** _send is the underlying method for sending in the harvest, if sending raw we can bypass the other helpers completely which format the payloads */
91
+ if (this.opts.raw) send = args => this.harvest._send(args);
92
+ /** send is used to formated the payloads from "getPayload" and obfuscate before sending */else send = args => this.harvest.send(args);
86
93
  } else {
87
- this.harvest.sendX(this.endpoint, opts, onHarvestFinished);
94
+ // force it to run at least once in sendX mode
95
+ harvests.push(undefined);
88
96
  }
97
+ harvests.forEach(payload => {
98
+ send({
99
+ endpoint: this.endpoint,
100
+ payload,
101
+ opts,
102
+ submitMethod,
103
+ cbFinished: onHarvestFinished,
104
+ includeBaseParams: this.opts.includeBaseParams,
105
+ customUrl: this.opts.customUrl,
106
+ gzip: this.opts.gzip
107
+ });
108
+ });
89
109
  if (this.started) {
90
110
  this.scheduleHarvest();
91
111
  }
@@ -24,6 +24,23 @@ var _globalScope = require("../util/global-scope");
24
24
  * SPDX-License-Identifier: Apache-2.0
25
25
  */
26
26
 
27
+ /**
28
+ * @typedef {object} NetworkSendSpec
29
+ * @param {string} endpoint The endpoint to use (jserrors, events, resources etc.)
30
+ * @param {object} payload Object representing payload.
31
+ * @param {object} payload.qs Map of values that should be sent as part of the request query string.
32
+ * @param {string} payload.body String that should be sent as the body of the request.
33
+ * @param {string} payload.body.e Special case of body used for browser interactions.
34
+ * @param {object} opts Additional options for sending data
35
+ * @param {boolean} opts.needResponse Specify whether the caller expects a response data.
36
+ * @param {boolean} opts.unload Specify whether the call is a final harvest during page unload.
37
+ * @param {boolean} opts.sendEmptyBody Specify whether the call should be made even if the body is empty. Useful for rum calls.
38
+ * @param {function} submitMethod The submit method to use {@link ../util/submit-data}
39
+ * @param {string} customUrl Override the beacon url the data is sent to; must include protocol if defined
40
+ * @param {boolean} gzip Enabled gzip compression on the body of the request before it is sent
41
+ * @param {boolean} includeBaseParams Enables the use of base query parameters in the beacon url {@see Harvest.baseQueryString}
42
+ */
43
+
27
44
  const haveSendBeacon = !!navigator.sendBeacon; // only the web window obj has sendBeacon at this time, so 'false' for other envs
28
45
 
29
46
  class Harvest extends _sharedContext.SharedContext {
@@ -39,62 +56,78 @@ class Harvest extends _sharedContext.SharedContext {
39
56
  /**
40
57
  * Initiate a harvest from multiple sources. An event that corresponds to the endpoint
41
58
  * name is emitted, which gives any listeners the opportunity to provide payload data.
42
- *
43
- * @param {string} endpoint - The endpoint of the harvest (jserrors, events, resources etc.)
44
- *
45
- * @param {object} opts
46
- * @param {bool} opts.needResponse - Specify whether the caller expects a response data.
47
- * @param {bool} opts.unload - Specify whether the call is a final harvest during page unload.
59
+ * @param {NetworkSendSpec} spec Specification for sending data
48
60
  */
49
- sendX(endpoint, opts, cbFinished) {
61
+ sendX(spec) {
62
+ const {
63
+ endpoint,
64
+ opts
65
+ } = spec;
50
66
  var submitMethod = getSubmitMethod(endpoint, opts);
51
67
  if (!submitMethod) return false;
52
68
  var options = {
53
69
  retry: submitMethod.method === _submitData.submitData.xhr
54
70
  };
55
- return this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend(endpoint, this.createPayload(endpoint, options), opts, submitMethod, cbFinished) : this._send(endpoint, this.createPayload(endpoint, options), opts, submitMethod, cbFinished);
71
+ const payload = this.createPayload(endpoint, options);
72
+ var caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this);
73
+ return caller({
74
+ ...spec,
75
+ payload,
76
+ submitMethod
77
+ });
56
78
  }
57
79
 
58
80
  /**
59
- * Initiate a harvest call.
60
- *
61
- * @param {string} endpoint - The endpoint of the harvest (jserrors, events, resources etc.)
62
- * @param {object} nr - The loader singleton.
63
- *
64
- * @param {object} singlePayload - Object representing payload.
65
- * @param {object} singlePayload.qs - Map of values that should be sent as part of the request query string.
66
- * @param {string} singlePayload.body - String that should be sent as the body of the request.
67
- * @param {string} singlePayload.body.e - Special case of body used for browser interactions.
68
- *
69
- * @param {object} opts
70
- * @param {bool} opts.needResponse - Specify whether the caller expects a response data.
71
- * @param {bool} opts.unload - Specify whether the call is a final harvest during page unload.
72
- */
73
- send(endpoint, singlePayload, opts, submitMethod, cbFinished) {
74
- var _this = this;
81
+ * Initiate a harvest call.
82
+ * @param {NetworkSendSpec} spec Specification for sending data
83
+ */
84
+ send(spec) {
85
+ const {
86
+ payload = {}
87
+ } = spec;
75
88
  var makeBody = createAccumulator();
76
89
  var makeQueryString = createAccumulator();
77
- if (singlePayload.body) (0, _mapOwn.mapOwn)(singlePayload.body, makeBody);
78
- if (singlePayload.qs) (0, _mapOwn.mapOwn)(singlePayload.qs, makeQueryString);
79
- var payload = {
90
+ if (payload.body) (0, _mapOwn.mapOwn)(payload.body, makeBody);
91
+ if (payload.qs) (0, _mapOwn.mapOwn)(payload.qs, makeQueryString);
92
+ var newPayload = {
80
93
  body: makeBody(),
81
94
  qs: makeQueryString()
82
95
  };
83
- var caller = this.obfuscator.shouldObfuscate() ? function () {
84
- return _this.obfuscateAndSend(...arguments);
85
- } : function () {
86
- return _this._send(...arguments);
87
- };
88
- return caller(endpoint, payload, opts, submitMethod, cbFinished);
96
+ var caller = this.obfuscator.shouldObfuscate() ? this.obfuscateAndSend.bind(this) : this._send.bind(this);
97
+ return caller({
98
+ ...spec,
99
+ payload: newPayload
100
+ });
89
101
  }
90
- obfuscateAndSend(endpoint, payload, opts, submitMethod, cbFinished) {
91
- var _this2 = this;
102
+
103
+ /**
104
+ * Apply obfuscation rules to the payload and then initial the harvest network call.
105
+ * @param {NetworkSendSpec} spec Specification for sending data
106
+ */
107
+ obfuscateAndSend(spec) {
108
+ var _this = this;
109
+ const {
110
+ payload = {}
111
+ } = spec;
92
112
  (0, _traverse.applyFnToProps)(payload, function () {
93
- return _this2.obfuscator.obfuscateString(...arguments);
113
+ return _this.obfuscator.obfuscateString(...arguments);
94
114
  }, 'string', ['e']);
95
- return this._send(endpoint, payload, opts, submitMethod, cbFinished);
115
+ return this._send({
116
+ ...spec,
117
+ payload
118
+ });
96
119
  }
97
- _send(endpoint, payload, opts, submitMethod, cbFinished) {
120
+ _send(_ref) {
121
+ let {
122
+ endpoint,
123
+ payload = {},
124
+ opts = {},
125
+ submitMethod,
126
+ cbFinished,
127
+ customUrl,
128
+ gzip,
129
+ includeBaseParams = true
130
+ } = _ref;
98
131
  var info = (0, _config.getInfo)(this.sharedContext.agentIdentifier);
99
132
  if (!info.errorBeacon) return false;
100
133
  var agentRuntime = (0, _config.getRuntime)(this.sharedContext.agentIdentifier);
@@ -107,38 +140,67 @@ class Harvest extends _sharedContext.SharedContext {
107
140
  }
108
141
  return false;
109
142
  }
110
- if (!opts) opts = {};
111
- var url = this.getScheme() + '://' + info.errorBeacon + '/' + endpoint + '/1/' + info.licenseKey + this.baseQueryString();
112
- if (payload.qs) url += (0, _encode.obj)(payload.qs, agentRuntime.maxBytes);
143
+ var url = customUrl || this.getScheme() + '://' + info.errorBeacon + '/' + endpoint + '/1/' + info.licenseKey + '?';
144
+ var baseParams = includeBaseParams ? this.baseQueryString() : '';
145
+ var params = payload.qs ? (0, _encode.obj)(payload.qs, agentRuntime.maxBytes) : '';
113
146
  if (!submitMethod) {
114
147
  submitMethod = getSubmitMethod(endpoint, opts);
115
148
  }
116
149
  var method = submitMethod.method;
117
150
  var useBody = submitMethod.useBody;
118
151
  var body;
119
- var fullUrl = url;
120
- if (useBody && endpoint === 'events') {
121
- body = payload.body.e;
122
- } else if (useBody) {
123
- body = (0, _stringify.stringify)(payload.body);
124
- } else {
125
- fullUrl = url + (0, _encode.obj)(payload.body, agentRuntime.maxBytes);
126
- }
152
+ var fullUrl = url + baseParams + params;
153
+ if (!gzip) {
154
+ if (useBody && endpoint === 'events') {
155
+ body = payload.body.e;
156
+ } else if (useBody) {
157
+ body = (0, _stringify.stringify)(payload.body);
158
+ } else {
159
+ fullUrl = fullUrl + (0, _encode.obj)(payload.body, agentRuntime.maxBytes);
160
+ }
161
+ } else body = payload.body;
127
162
 
128
163
  // Get bytes harvested per endpoint as a supportability metric. See metrics aggregator (on unload).
129
164
  agentRuntime.bytesSent[endpoint] = (agentRuntime.bytesSent[endpoint] || 0) + body?.length || 0;
130
165
  // Get query bytes harvested per endpoint as a supportability metric. See metrics aggregator (on unload).
131
166
  agentRuntime.queryBytesSent[endpoint] = (agentRuntime.queryBytesSent[endpoint] || 0) + fullUrl.split('?').slice(-1)[0]?.length || 0;
167
+ const headers = [];
168
+ if (gzip) {
169
+ headers.push({
170
+ key: 'content-type',
171
+ value: 'application/json'
172
+ });
173
+ headers.push({
174
+ key: 'X-Browser-Monitoring-Key',
175
+ value: info.licenseKey
176
+ });
177
+ headers.push({
178
+ key: 'Content-Encoding',
179
+ value: 'gzip'
180
+ });
181
+ } else {
182
+ headers.push({
183
+ key: 'content-type',
184
+ value: 'text/plain'
185
+ });
186
+ }
132
187
 
133
188
  /* Since workers don't support sendBeacon right now, or Image(), they can only use XHR method.
134
189
  Because they still do permit synch XHR, the idea is that at final harvest time (worker is closing),
135
190
  we just make a BLOCKING request--trivial impact--with the remaining data as a temp fill-in for sendBeacon. */
136
- var result = method(fullUrl, body, opts.unload && _globalScope.isWorkerScope);
191
+
192
+ var result = method({
193
+ url: fullUrl,
194
+ body,
195
+ sync: opts.unload && _globalScope.isWorkerScope,
196
+ headers
197
+ });
137
198
  if (cbFinished && method === _submitData.submitData.xhr) {
138
199
  var xhr = result;
139
200
  xhr.addEventListener('load', function () {
140
201
  var result = {
141
- sent: true
202
+ sent: true,
203
+ status: this.status
142
204
  };
143
205
  if (this.status === 429) {
144
206
  result.retry = true;
@@ -156,7 +218,9 @@ class Harvest extends _sharedContext.SharedContext {
156
218
  // if beacon request failed, retry with an alternative method -- will not happen for workers
157
219
  if (!result && method === _submitData.submitData.beacon) {
158
220
  method = _submitData.submitData.img;
159
- result = method(url + (0, _encode.obj)(payload.body, agentRuntime.maxBytes));
221
+ result = method({
222
+ url: fullUrl + (0, _encode.obj)(payload.body, agentRuntime.maxBytes)
223
+ });
160
224
  }
161
225
  return result;
162
226
  }
@@ -167,9 +231,9 @@ class Harvest extends _sharedContext.SharedContext {
167
231
  var info = (0, _config.getInfo)(this.sharedContext.agentIdentifier);
168
232
  var location = (0, _cleanUrl.cleanURL)((0, _location.getLocation)());
169
233
  var ref = this.obfuscator.shouldObfuscate() ? this.obfuscator.obfuscateString(location) : location;
170
- return ['?a=' + info.applicationID, (0, _encode.param)('sa', info.sa ? '' + info.sa : ''), (0, _encode.param)('v', _env.VERSION), transactionNameParam(info), (0, _encode.param)('ct', runtime.customTransaction), '&rst=' + (0, _now.now)(), '&ck=0',
234
+ return ['a=' + info.applicationID, (0, _encode.param)('sa', info.sa ? '' + info.sa : ''), (0, _encode.param)('v', _env.VERSION), transactionNameParam(info), (0, _encode.param)('ct', runtime.customTransaction), '&rst=' + (0, _now.now)(), '&ck=0',
171
235
  // ck param DEPRECATED - still expected by backend
172
- '&s=' + (runtime.session?.value || '0'),
236
+ '&s=' + (runtime.session?.state.value || '0'),
173
237
  // the 0 id encaps all untrackable and default traffic
174
238
  (0, _encode.param)('ref', ref), (0, _encode.param)('ptid', runtime.ptid ? '' + runtime.ptid : '')].join('');
175
239
  }
@@ -240,7 +304,7 @@ function createAccumulator() {
240
304
  var accumulator = {};
241
305
  var hasData = false;
242
306
  return function (key, val) {
243
- if (val && val.length) {
307
+ if (val !== null && val !== undefined && val.length) {
244
308
  accumulator[key] = val;
245
309
  hasData = true;
246
310
  }