@newrelic/browser-agent 1.232.1 → 1.233.1

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 (242) hide show
  1. package/dist/cjs/cdn/experimental.js +27 -0
  2. package/dist/cjs/cdn/polyfills.js +5 -2
  3. package/dist/cjs/common/config/state/configurable.js +15 -26
  4. package/dist/cjs/common/config/state/info.js +1 -1
  5. package/dist/cjs/common/config/state/init.js +101 -56
  6. package/dist/cjs/common/config/state/loader-config.js +1 -1
  7. package/dist/cjs/common/config/state/runtime.js +1 -5
  8. package/dist/cjs/common/constants/env.cdn.js +1 -1
  9. package/dist/cjs/common/constants/env.npm.js +1 -1
  10. package/dist/cjs/common/drain/drain.js +1 -1
  11. package/dist/cjs/common/harvest/harvest-scheduler.js +43 -8
  12. package/dist/cjs/common/harvest/harvest-scheduler.test.js +39 -0
  13. package/dist/cjs/common/harvest/harvest.js +106 -55
  14. package/dist/cjs/common/session/session-entity.js +35 -22
  15. package/dist/cjs/common/session/session-entity.test.js +73 -49
  16. package/dist/cjs/common/timer/interaction-timer.js +9 -12
  17. package/dist/cjs/common/url/protocol.test.js +0 -1
  18. package/dist/cjs/common/util/feature-flags.js +2 -1
  19. package/dist/cjs/common/util/submit-data.js +57 -18
  20. package/dist/cjs/common/wrap/wrap-fetch.js +1 -1
  21. package/dist/cjs/common/wrap/wrap-function.js +1 -1
  22. package/dist/cjs/common/wrap/wrap-promise.js +1 -1
  23. package/dist/cjs/features/ajax/aggregate/index.js +2 -2
  24. package/dist/cjs/features/jserrors/aggregate/index.js +7 -5
  25. package/dist/cjs/features/metrics/aggregate/framework-detection.js +67 -0
  26. package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +137 -0
  27. package/dist/cjs/features/metrics/aggregate/index.js +7 -3
  28. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +14 -0
  29. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +17 -0
  30. package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +53 -0
  31. package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +165 -0
  32. package/dist/cjs/features/page_action/aggregate/index.js +2 -2
  33. package/dist/cjs/features/page_view_event/aggregate/index.js +6 -3
  34. package/dist/cjs/features/page_view_timing/aggregate/index.js +2 -2
  35. package/dist/cjs/features/session_replay/aggregate/index.js +336 -0
  36. package/dist/cjs/features/session_replay/constants.js +9 -0
  37. package/dist/cjs/features/session_replay/index.js +12 -0
  38. package/dist/cjs/features/session_replay/instrument/index.js +29 -0
  39. package/dist/cjs/features/session_trace/aggregate/index.js +163 -162
  40. package/dist/cjs/features/session_trace/constants.js +2 -9
  41. package/dist/cjs/features/session_trace/instrument/index.js +24 -66
  42. package/dist/cjs/features/spa/aggregate/index.js +2 -2
  43. package/dist/cjs/features/utils/agent-session.js +1 -2
  44. package/dist/cjs/features/utils/aggregate-base.js +64 -0
  45. package/dist/cjs/features/utils/feature-base.js +0 -31
  46. package/dist/cjs/features/utils/handler-cache.js +3 -4
  47. package/dist/cjs/features/utils/instrument-base.js +42 -10
  48. package/dist/cjs/features/utils/{lazy-loader.js → lazy-feature-loader.js} +4 -2
  49. package/dist/cjs/loaders/agent.js +1 -1
  50. package/dist/cjs/loaders/api/apiAsync.js +3 -1
  51. package/dist/cjs/loaders/configure/configure.js +3 -3
  52. package/dist/cjs/loaders/features/featureDependencies.js +0 -12
  53. package/dist/cjs/loaders/features/features.js +3 -1
  54. package/dist/cjs/loaders/micro-agent.js +6 -6
  55. package/dist/esm/cdn/experimental.js +24 -0
  56. package/dist/esm/cdn/polyfills.js +5 -2
  57. package/dist/esm/common/config/state/configurable.js +14 -24
  58. package/dist/esm/common/config/state/info.js +2 -2
  59. package/dist/esm/common/config/state/init.js +102 -57
  60. package/dist/esm/common/config/state/loader-config.js +2 -2
  61. package/dist/esm/common/config/state/runtime.js +2 -4
  62. package/dist/esm/common/constants/env.cdn.js +1 -1
  63. package/dist/esm/common/constants/env.npm.js +1 -1
  64. package/dist/esm/common/drain/drain.js +1 -1
  65. package/dist/esm/common/harvest/harvest-scheduler.js +43 -8
  66. package/dist/esm/common/harvest/harvest-scheduler.test.js +37 -0
  67. package/dist/esm/common/harvest/harvest.js +108 -56
  68. package/dist/esm/common/session/session-entity.js +35 -22
  69. package/dist/esm/common/session/session-entity.test.js +73 -49
  70. package/dist/esm/common/timer/interaction-timer.js +9 -12
  71. package/dist/esm/common/url/protocol.test.js +0 -1
  72. package/dist/esm/common/util/feature-flags.js +2 -1
  73. package/dist/esm/common/util/submit-data.js +57 -18
  74. package/dist/esm/common/wrap/wrap-fetch.js +1 -1
  75. package/dist/esm/common/wrap/wrap-function.js +1 -1
  76. package/dist/esm/common/wrap/wrap-promise.js +1 -1
  77. package/dist/esm/features/ajax/aggregate/index.js +2 -2
  78. package/dist/esm/features/jserrors/aggregate/index.js +7 -5
  79. package/dist/esm/features/metrics/aggregate/framework-detection.js +61 -0
  80. package/dist/esm/features/metrics/aggregate/framework-detection.test.js +133 -0
  81. package/dist/esm/features/metrics/aggregate/index.js +7 -3
  82. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +8 -0
  83. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +15 -0
  84. package/dist/esm/features/metrics/aggregate/polyfill-detection.js +47 -0
  85. package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +163 -0
  86. package/dist/esm/features/page_action/aggregate/index.js +2 -2
  87. package/dist/esm/features/page_view_event/aggregate/index.js +6 -3
  88. package/dist/esm/features/page_view_timing/aggregate/index.js +2 -2
  89. package/dist/esm/features/session_replay/aggregate/index.js +330 -0
  90. package/dist/esm/features/session_replay/constants.js +2 -0
  91. package/dist/esm/features/session_replay/index.js +12 -0
  92. package/dist/esm/features/session_replay/instrument/index.js +21 -0
  93. package/dist/esm/features/session_trace/aggregate/index.js +163 -162
  94. package/dist/esm/features/session_trace/constants.js +1 -5
  95. package/dist/esm/features/session_trace/instrument/index.js +24 -66
  96. package/dist/esm/features/spa/aggregate/index.js +2 -2
  97. package/dist/esm/features/utils/agent-session.js +1 -2
  98. package/dist/esm/features/utils/aggregate-base.js +57 -0
  99. package/dist/esm/features/utils/feature-base.js +1 -32
  100. package/dist/esm/features/utils/handler-cache.js +3 -4
  101. package/dist/esm/features/utils/instrument-base.js +42 -10
  102. package/dist/esm/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
  103. package/dist/esm/loaders/agent.js +1 -1
  104. package/dist/esm/loaders/api/apiAsync.js +3 -1
  105. package/dist/esm/loaders/configure/configure.js +3 -3
  106. package/dist/esm/loaders/features/featureDependencies.js +0 -11
  107. package/dist/esm/loaders/features/features.js +3 -1
  108. package/dist/esm/loaders/micro-agent.js +6 -6
  109. package/dist/types/cdn/experimental.d.ts +2 -0
  110. package/dist/types/cdn/experimental.d.ts.map +1 -0
  111. package/dist/types/common/config/state/configurable.d.ts +1 -3
  112. package/dist/types/common/config/state/configurable.d.ts.map +1 -1
  113. package/dist/types/common/config/state/init.d.ts.map +1 -1
  114. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  115. package/dist/types/common/harvest/harvest-scheduler.d.ts +26 -3
  116. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  117. package/dist/types/common/harvest/harvest.d.ts +37 -34
  118. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  119. package/dist/types/common/session/session-entity.d.ts +6 -3
  120. package/dist/types/common/session/session-entity.d.ts.map +1 -1
  121. package/dist/types/common/timer/interaction-timer.d.ts +2 -1
  122. package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
  123. package/dist/types/common/util/feature-flags.d.ts.map +1 -1
  124. package/dist/types/common/util/submit-data.d.ts +40 -14
  125. package/dist/types/common/util/submit-data.d.ts.map +1 -1
  126. package/dist/types/features/ajax/aggregate/index.d.ts +2 -2
  127. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  128. package/dist/types/features/jserrors/aggregate/index.d.ts +2 -2
  129. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  130. package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -0
  131. package/dist/types/features/metrics/aggregate/index.d.ts +2 -2
  132. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  133. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +6 -0
  134. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +1 -0
  135. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +7 -0
  136. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +1 -0
  137. package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
  138. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  139. package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -2
  140. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  141. package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
  142. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  143. package/dist/types/features/session_replay/aggregate/index.d.ts +100 -0
  144. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -0
  145. package/dist/types/features/session_replay/constants.d.ts +2 -0
  146. package/dist/types/features/session_replay/constants.d.ts.map +1 -0
  147. package/dist/types/features/session_replay/index.d.ts +2 -0
  148. package/dist/types/features/session_replay/index.d.ts.map +1 -0
  149. package/dist/types/features/session_replay/instrument/index.d.ts +6 -0
  150. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -0
  151. package/dist/types/features/session_trace/aggregate/index.d.ts +8 -57
  152. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  153. package/dist/types/features/session_trace/constants.d.ts +0 -3
  154. package/dist/types/features/session_trace/constants.d.ts.map +1 -1
  155. package/dist/types/features/session_trace/instrument/index.d.ts +1 -3
  156. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  157. package/dist/types/features/spa/aggregate/index.d.ts +2 -2
  158. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  159. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  160. package/dist/types/features/utils/aggregate-base.d.ts +11 -0
  161. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -0
  162. package/dist/types/features/utils/feature-base.d.ts +0 -5
  163. package/dist/types/features/utils/feature-base.d.ts.map +1 -1
  164. package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
  165. package/dist/types/features/utils/instrument-base.d.ts +3 -1
  166. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  167. package/dist/types/features/utils/{lazy-loader.d.ts → lazy-feature-loader.d.ts} +2 -2
  168. package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -0
  169. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  170. package/dist/types/loaders/features/featureDependencies.d.ts +0 -1
  171. package/dist/types/loaders/features/featureDependencies.d.ts.map +1 -1
  172. package/dist/types/loaders/features/features.d.ts +1 -0
  173. package/dist/types/loaders/features/features.d.ts.map +1 -1
  174. package/package.json +30 -20
  175. package/src/cdn/experimental.js +36 -0
  176. package/src/cdn/polyfills.js +4 -1
  177. package/src/common/config/state/configurable.js +18 -24
  178. package/src/common/config/state/info.js +2 -2
  179. package/src/common/config/state/init.js +62 -28
  180. package/src/common/config/state/loader-config.js +2 -2
  181. package/src/common/config/state/runtime.js +2 -4
  182. package/src/common/drain/drain.js +1 -1
  183. package/src/common/harvest/harvest-scheduler.js +48 -8
  184. package/src/common/harvest/harvest-scheduler.test.js +25 -0
  185. package/src/common/harvest/harvest.js +72 -50
  186. package/src/common/session/session-entity.js +34 -23
  187. package/src/common/session/session-entity.test.js +57 -51
  188. package/src/common/timer/interaction-timer.js +9 -12
  189. package/src/common/url/protocol.test.js +0 -1
  190. package/src/common/util/feature-flags.js +2 -2
  191. package/src/common/util/submit-data.js +28 -17
  192. package/src/common/wrap/wrap-fetch.js +1 -1
  193. package/src/common/wrap/wrap-function.js +1 -1
  194. package/src/common/wrap/wrap-promise.js +1 -1
  195. package/src/features/ajax/aggregate/index.js +2 -2
  196. package/src/features/jserrors/aggregate/index.js +7 -5
  197. package/src/features/metrics/aggregate/framework-detection.js +73 -0
  198. package/src/features/metrics/aggregate/framework-detection.test.js +201 -0
  199. package/src/features/metrics/aggregate/index.js +8 -3
  200. package/src/features/metrics/aggregate/polyfill-detection.es5.js +9 -0
  201. package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +16 -0
  202. package/src/features/metrics/aggregate/polyfill-detection.js +48 -0
  203. package/src/features/metrics/aggregate/polyfill-detection.test.js +163 -0
  204. package/src/features/page_action/aggregate/index.js +2 -2
  205. package/src/features/page_view_event/aggregate/index.js +5 -5
  206. package/src/features/page_view_timing/aggregate/index.js +2 -2
  207. package/src/features/session_replay/aggregate/index.js +319 -0
  208. package/src/features/session_replay/constants.js +3 -0
  209. package/src/features/session_replay/index.js +12 -0
  210. package/src/features/session_replay/instrument/index.js +22 -0
  211. package/src/features/session_trace/aggregate/index.js +148 -187
  212. package/src/features/session_trace/constants.js +0 -4
  213. package/src/features/session_trace/instrument/index.js +17 -69
  214. package/src/features/spa/aggregate/index.js +2 -2
  215. package/src/features/utils/agent-session.js +1 -2
  216. package/src/features/utils/aggregate-base.js +51 -0
  217. package/src/features/utils/feature-base.js +1 -31
  218. package/src/features/utils/handler-cache.js +3 -4
  219. package/src/features/utils/instrument-base.js +40 -8
  220. package/src/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
  221. package/src/loaders/agent.js +1 -1
  222. package/src/loaders/api/apiAsync.js +1 -1
  223. package/src/loaders/configure/configure.js +4 -3
  224. package/src/loaders/features/featureDependencies.js +0 -12
  225. package/src/loaders/features/features.js +3 -1
  226. package/src/loaders/micro-agent.js +4 -4
  227. package/dist/cjs/common/metrics/framework-detection.js +0 -72
  228. package/dist/cjs/common/util/user-agent.js +0 -57
  229. package/dist/cjs/common/window/supports-performance-observer.js +0 -15
  230. package/dist/esm/common/metrics/framework-detection.js +0 -66
  231. package/dist/esm/common/util/user-agent.js +0 -48
  232. package/dist/esm/common/window/supports-performance-observer.js +0 -9
  233. package/dist/types/common/metrics/framework-detection.d.ts.map +0 -1
  234. package/dist/types/common/util/user-agent.d.ts +0 -5
  235. package/dist/types/common/util/user-agent.d.ts.map +0 -1
  236. package/dist/types/common/window/supports-performance-observer.d.ts +0 -2
  237. package/dist/types/common/window/supports-performance-observer.d.ts.map +0 -1
  238. package/dist/types/features/utils/lazy-loader.d.ts.map +0 -1
  239. package/src/common/metrics/framework-detection.js +0 -71
  240. package/src/common/util/user-agent.js +0 -56
  241. package/src/common/window/supports-performance-observer.js +0 -10
  242. /package/dist/types/{common/metrics → features/metrics/aggregate}/framework-detection.d.ts +0 -0
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ var _agent = require("../loaders/agent");
4
+ var _instrument = require("../features/page_view_event/instrument");
5
+ var _instrument2 = require("../features/page_view_timing/instrument");
6
+ var _instrument3 = require("../features/metrics/instrument");
7
+ var _instrument4 = require("../features/jserrors/instrument");
8
+ var _instrument5 = require("../features/ajax/instrument");
9
+ var _instrument6 = require("../features/session_trace/instrument");
10
+ var _instrument7 = require("../features/session_replay/instrument");
11
+ var _instrument8 = require("../features/spa/instrument");
12
+ var _instrument9 = require("../features/page_action/instrument");
13
+ /*
14
+ * Copyright 2023 New Relic Corporation. All rights reserved.
15
+ * SPDX-License-Identifier: Apache-2.0
16
+ */
17
+ /**
18
+ * @file Creates an "EXPERIMENTAL" agent loader bundle composed of the core agent and all available feature modules, including experimental features.
19
+ *
20
+ * NOTE: This loader is ONLY used for internal testing. The code contained within is likely under development and dormant. It will not download to instrumented pages or record any data.
21
+ * It is not production ready, and is not intended to be imported or implemented in any build of the browser agent
22
+ */
23
+
24
+ new _agent.Agent({
25
+ features: [_instrument5.Instrument, _instrument.Instrument, _instrument2.Instrument, _instrument6.Instrument, _instrument7.Instrument, _instrument3.Instrument, _instrument9.Instrument, _instrument4.Instrument, _instrument8.Instrument],
26
+ loaderType: 'experimental'
27
+ });
@@ -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: false,
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.1";
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.1";
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;
@@ -18,6 +18,17 @@ var _config = require("../config/config");
18
18
  * Periodically invokes harvest calls and handles retries
19
19
  */
20
20
  class HarvestScheduler extends _sharedContext.SharedContext {
21
+ /**
22
+ * Create a HarvestScheduler
23
+ * @param {string} endpoint - The base BAM endpoint name -- ex. 'events'
24
+ * @param {object} opts - The options used to configure the HarvestScheduler
25
+ * @param {Function} opts.onFinished - The callback to be fired when a harvest has finished
26
+ * @param {Function} opts.getPayload - A callback which can be triggered to return a payload for harvesting
27
+ * @param {number} opts.retryDelay - The number of seconds to wait before retrying after a network failure
28
+ * @param {boolean} opts.raw - Use a prefabricated payload shape as the harvest payload without the need for formatting
29
+ * @param {string} opts.customUrl - A custom url that falls outside of the shape of the standard BAM harvester url pattern. Will use directly instead of concatenating various pieces
30
+ * @param {*} parent - The parent object, whose state can be passed into SharedContext
31
+ */
21
32
  constructor(endpoint, opts, parent) {
22
33
  super(parent); // gets any allowed properties from the parent and stores them in `sharedContext`
23
34
  this.endpoint = endpoint;
@@ -69,23 +80,47 @@ class HarvestScheduler extends _sharedContext.SharedContext {
69
80
  runHarvest(opts) {
70
81
  if (this.aborted) return;
71
82
  var scheduler = this;
83
+ let harvests = [];
84
+ let submitMethod;
72
85
  if (this.opts.getPayload) {
73
- // Ajax & PVT
74
- var submitMethod = (0, _harvest.getSubmitMethod)(this.endpoint, opts);
86
+ // Ajax & PVT & SR
87
+ submitMethod = (0, _harvest.getSubmitMethod)(this.endpoint, opts);
75
88
  if (!submitMethod) return false;
76
- var retry = submitMethod.method === _submitData.submitData.xhr;
89
+ const retry = submitMethod.method === _submitData.submitData.xhr;
77
90
  var payload = this.opts.getPayload({
78
91
  retry: retry
79
92
  });
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);
93
+ if (!payload) {
94
+ if (this.started) {
95
+ this.scheduleHarvest();
84
96
  }
97
+ return;
85
98
  }
99
+ payload = Object.prototype.toString.call(payload) === '[object Array]' ? payload : [payload];
100
+ harvests.push(...payload);
101
+ }
102
+
103
+ /** sendX is used for features that do not supply a preformatted payload via "getPayload" */
104
+ let send = args => this.harvest.sendX(args);
105
+ if (harvests.length) {
106
+ /** _send is the underlying method for sending in the harvest, if sending raw we can bypass the other helpers completely which format the payloads */
107
+ if (this.opts.raw) send = args => this.harvest._send(args);
108
+ /** send is used to formated the payloads from "getPayload" and obfuscate before sending */else send = args => this.harvest.send(args);
86
109
  } else {
87
- this.harvest.sendX(this.endpoint, opts, onHarvestFinished);
110
+ // force it to run at least once in sendX mode
111
+ harvests.push(undefined);
88
112
  }
113
+ harvests.forEach(payload => {
114
+ send({
115
+ endpoint: this.endpoint,
116
+ payload,
117
+ opts,
118
+ submitMethod,
119
+ cbFinished: onHarvestFinished,
120
+ customUrl: this.opts.customUrl,
121
+ raw: this.opts.raw
122
+ });
123
+ });
89
124
  if (this.started) {
90
125
  this.scheduleHarvest();
91
126
  }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var _init = require("../config/state/init");
4
+ var _harvestScheduler = require("./harvest-scheduler");
5
+ describe('runHarvest', () => {
6
+ it('should re-schedule harvest even if there is no accumulated data', () => {
7
+ (0, _init.setConfiguration)('asdf', {});
8
+ const scheduler = new _harvestScheduler.HarvestScheduler('events', {
9
+ getPayload: jest.fn()
10
+ }, {
11
+ agentIdentifier: 'asdf',
12
+ ee: {
13
+ on: jest.fn()
14
+ }
15
+ });
16
+ scheduler.started = true;
17
+ jest.spyOn(scheduler, 'scheduleHarvest');
18
+ scheduler.runHarvest();
19
+ expect(scheduler.opts.getPayload()).toBeFalsy();
20
+ expect(scheduler.scheduleHarvest).toHaveBeenCalledTimes(1);
21
+ });
22
+ it('should also re-schedule harvest if there is accumulated data', () => {
23
+ (0, _init.setConfiguration)('asdf', {});
24
+ const scheduler = new _harvestScheduler.HarvestScheduler('events', {
25
+ getPayload: jest.fn().mockImplementation(() => 'payload')
26
+ }, {
27
+ agentIdentifier: 'asdf',
28
+ ee: {
29
+ on: jest.fn()
30
+ }
31
+ });
32
+ scheduler.started = true;
33
+ scheduler.harvest._send = () => {};
34
+ jest.spyOn(scheduler, 'scheduleHarvest');
35
+ scheduler.runHarvest();
36
+ expect(scheduler.opts.getPayload()).toBeTruthy();
37
+ expect(scheduler.scheduleHarvest).toHaveBeenCalledTimes(1);
38
+ });
39
+ });