@newrelic/browser-agent 1.288.0 → 1.289.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 (163) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/common/config/info.js +7 -17
  3. package/dist/cjs/common/config/init.js +6 -34
  4. package/dist/cjs/common/config/loader-config.js +6 -16
  5. package/dist/cjs/common/config/runtime.js +21 -27
  6. package/dist/cjs/common/constants/env.cdn.js +1 -1
  7. package/dist/cjs/common/constants/env.npm.js +1 -1
  8. package/dist/cjs/common/event-emitter/contextual-ee.js +1 -2
  9. package/dist/cjs/common/serialize/bel-serializer.js +1 -3
  10. package/dist/cjs/common/timing/time-keeper.js +2 -3
  11. package/dist/cjs/features/ajax/aggregate/index.js +1 -1
  12. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +10 -26
  13. package/dist/cjs/features/ajax/instrument/index.js +1 -1
  14. package/dist/cjs/features/logging/aggregate/index.js +1 -1
  15. package/dist/cjs/features/page_view_event/aggregate/index.js +2 -2
  16. package/dist/cjs/features/page_view_timing/aggregate/index.js +1 -1
  17. package/dist/cjs/features/session_replay/aggregate/index.js +1 -1
  18. package/dist/cjs/features/session_replay/instrument/index.js +3 -3
  19. package/dist/cjs/features/session_replay/shared/recorder.js +1 -1
  20. package/dist/cjs/features/session_replay/shared/utils.js +5 -6
  21. package/dist/cjs/features/session_trace/instrument/index.js +1 -1
  22. package/dist/cjs/features/soft_navigations/aggregate/ajax-node.js +3 -3
  23. package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +3 -3
  24. package/dist/cjs/features/soft_navigations/aggregate/index.js +8 -15
  25. package/dist/cjs/features/soft_navigations/aggregate/initial-page-load-interaction.js +4 -6
  26. package/dist/cjs/features/soft_navigations/aggregate/interaction.js +5 -6
  27. package/dist/cjs/features/spa/aggregate/index.js +1 -1
  28. package/dist/cjs/features/spa/aggregate/interaction.js +1 -1
  29. package/dist/cjs/features/spa/aggregate/serializer.js +8 -11
  30. package/dist/cjs/features/utils/aggregate-base.js +8 -6
  31. package/dist/cjs/features/utils/event-store-manager.js +15 -5
  32. package/dist/cjs/features/utils/feature-gates.js +2 -3
  33. package/dist/cjs/features/utils/instrument-base.js +4 -4
  34. package/dist/cjs/loaders/agent.js +1 -1
  35. package/dist/cjs/loaders/api/api.js +1 -11
  36. package/dist/cjs/loaders/configure/configure.js +7 -7
  37. package/dist/cjs/loaders/features/enabled-features.js +2 -6
  38. package/dist/cjs/loaders/micro-agent.js +1 -1
  39. package/dist/esm/common/config/info.js +6 -16
  40. package/dist/esm/common/config/init.js +4 -31
  41. package/dist/esm/common/config/loader-config.js +4 -14
  42. package/dist/esm/common/config/runtime.js +19 -25
  43. package/dist/esm/common/constants/env.cdn.js +1 -1
  44. package/dist/esm/common/constants/env.npm.js +1 -1
  45. package/dist/esm/common/event-emitter/contextual-ee.js +1 -2
  46. package/dist/esm/common/serialize/bel-serializer.js +1 -3
  47. package/dist/esm/common/timing/time-keeper.js +2 -3
  48. package/dist/esm/features/ajax/aggregate/index.js +1 -1
  49. package/dist/esm/features/ajax/instrument/distributed-tracing.js +10 -26
  50. package/dist/esm/features/ajax/instrument/index.js +1 -1
  51. package/dist/esm/features/logging/aggregate/index.js +1 -1
  52. package/dist/esm/features/page_view_event/aggregate/index.js +2 -2
  53. package/dist/esm/features/page_view_timing/aggregate/index.js +1 -1
  54. package/dist/esm/features/session_replay/aggregate/index.js +1 -1
  55. package/dist/esm/features/session_replay/instrument/index.js +3 -3
  56. package/dist/esm/features/session_replay/shared/recorder.js +1 -1
  57. package/dist/esm/features/session_replay/shared/utils.js +5 -6
  58. package/dist/esm/features/session_trace/instrument/index.js +1 -1
  59. package/dist/esm/features/soft_navigations/aggregate/ajax-node.js +3 -3
  60. package/dist/esm/features/soft_navigations/aggregate/bel-node.js +3 -3
  61. package/dist/esm/features/soft_navigations/aggregate/index.js +8 -15
  62. package/dist/esm/features/soft_navigations/aggregate/initial-page-load-interaction.js +4 -6
  63. package/dist/esm/features/soft_navigations/aggregate/interaction.js +5 -6
  64. package/dist/esm/features/spa/aggregate/index.js +1 -1
  65. package/dist/esm/features/spa/aggregate/interaction.js +1 -2
  66. package/dist/esm/features/spa/aggregate/serializer.js +8 -11
  67. package/dist/esm/features/utils/aggregate-base.js +8 -6
  68. package/dist/esm/features/utils/event-store-manager.js +15 -6
  69. package/dist/esm/features/utils/feature-gates.js +2 -3
  70. package/dist/esm/features/utils/instrument-base.js +4 -4
  71. package/dist/esm/loaders/agent.js +1 -1
  72. package/dist/esm/loaders/api/api.js +1 -11
  73. package/dist/esm/loaders/configure/configure.js +10 -10
  74. package/dist/esm/loaders/features/enabled-features.js +2 -6
  75. package/dist/esm/loaders/micro-agent.js +1 -1
  76. package/dist/tsconfig.tsbuildinfo +1 -1
  77. package/dist/types/common/config/info.d.ts +2 -3
  78. package/dist/types/common/config/info.d.ts.map +1 -1
  79. package/dist/types/common/config/init.d.ts +1 -3
  80. package/dist/types/common/config/init.d.ts.map +1 -1
  81. package/dist/types/common/config/loader-config.d.ts +1 -2
  82. package/dist/types/common/config/loader-config.d.ts.map +1 -1
  83. package/dist/types/common/config/runtime.d.ts +1 -2
  84. package/dist/types/common/config/runtime.d.ts.map +1 -1
  85. package/dist/types/common/event-emitter/contextual-ee.d.ts.map +1 -1
  86. package/dist/types/common/serialize/bel-serializer.d.ts +1 -1
  87. package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
  88. package/dist/types/common/timing/time-keeper.d.ts +1 -1
  89. package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
  90. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts +3 -4
  91. package/dist/types/features/ajax/instrument/distributed-tracing.d.ts.map +1 -1
  92. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  93. package/dist/types/features/logging/aggregate/index.d.ts.map +1 -1
  94. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  95. package/dist/types/features/session_replay/shared/utils.d.ts +2 -2
  96. package/dist/types/features/session_replay/shared/utils.d.ts.map +1 -1
  97. package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts +1 -1
  98. package/dist/types/features/soft_navigations/aggregate/ajax-node.d.ts.map +1 -1
  99. package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts +3 -2
  100. package/dist/types/features/soft_navigations/aggregate/bel-node.d.ts.map +1 -1
  101. package/dist/types/features/soft_navigations/aggregate/index.d.ts.map +1 -1
  102. package/dist/types/features/soft_navigations/aggregate/initial-page-load-interaction.d.ts +1 -1
  103. package/dist/types/features/soft_navigations/aggregate/initial-page-load-interaction.d.ts.map +1 -1
  104. package/dist/types/features/soft_navigations/aggregate/interaction.d.ts +1 -1
  105. package/dist/types/features/soft_navigations/aggregate/interaction.d.ts.map +1 -1
  106. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  107. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
  108. package/dist/types/features/spa/aggregate/serializer.d.ts +4 -2
  109. package/dist/types/features/spa/aggregate/serializer.d.ts.map +1 -1
  110. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  111. package/dist/types/features/utils/event-store-manager.d.ts +6 -4
  112. package/dist/types/features/utils/event-store-manager.d.ts.map +1 -1
  113. package/dist/types/features/utils/feature-gates.d.ts +1 -1
  114. package/dist/types/features/utils/feature-gates.d.ts.map +1 -1
  115. package/dist/types/loaders/api/api.d.ts.map +1 -1
  116. package/dist/types/loaders/features/enabled-features.d.ts +1 -1
  117. package/dist/types/loaders/features/enabled-features.d.ts.map +1 -1
  118. package/package.json +1 -1
  119. package/src/common/config/info.js +6 -18
  120. package/src/common/config/init.js +3 -33
  121. package/src/common/config/loader-config.js +3 -15
  122. package/src/common/config/runtime.js +11 -28
  123. package/src/common/event-emitter/contextual-ee.js +1 -2
  124. package/src/common/serialize/bel-serializer.js +1 -3
  125. package/src/common/timing/time-keeper.js +2 -3
  126. package/src/features/ajax/aggregate/index.js +1 -1
  127. package/src/features/ajax/instrument/distributed-tracing.js +10 -29
  128. package/src/features/ajax/instrument/index.js +1 -1
  129. package/src/features/logging/aggregate/index.js +1 -1
  130. package/src/features/page_view_event/aggregate/index.js +2 -2
  131. package/src/features/page_view_timing/aggregate/index.js +1 -1
  132. package/src/features/session_replay/aggregate/index.js +1 -1
  133. package/src/features/session_replay/instrument/index.js +3 -3
  134. package/src/features/session_replay/shared/recorder.js +1 -1
  135. package/src/features/session_replay/shared/utils.js +5 -6
  136. package/src/features/session_trace/instrument/index.js +1 -1
  137. package/src/features/soft_navigations/aggregate/ajax-node.js +3 -3
  138. package/src/features/soft_navigations/aggregate/bel-node.js +3 -3
  139. package/src/features/soft_navigations/aggregate/index.js +8 -16
  140. package/src/features/soft_navigations/aggregate/initial-page-load-interaction.js +4 -6
  141. package/src/features/soft_navigations/aggregate/interaction.js +5 -6
  142. package/src/features/spa/aggregate/index.js +1 -1
  143. package/src/features/spa/aggregate/interaction.js +1 -2
  144. package/src/features/spa/aggregate/serializer.js +8 -11
  145. package/src/features/utils/aggregate-base.js +8 -6
  146. package/src/features/utils/event-store-manager.js +18 -5
  147. package/src/features/utils/feature-gates.js +2 -3
  148. package/src/features/utils/instrument-base.js +4 -4
  149. package/src/loaders/agent.js +1 -1
  150. package/src/loaders/api/api.js +3 -5
  151. package/src/loaders/configure/configure.js +10 -10
  152. package/src/loaders/features/enabled-features.js +2 -7
  153. package/src/loaders/micro-agent.js +1 -1
  154. package/dist/cjs/common/context/shared-context.js +0 -31
  155. package/dist/esm/common/context/shared-context.js +0 -23
  156. package/dist/types/common/context/shared-context.d.ts +0 -5
  157. package/dist/types/common/context/shared-context.d.ts.map +0 -1
  158. package/src/common/config/__mocks__/info.js +0 -7
  159. package/src/common/config/__mocks__/init.js +0 -7
  160. package/src/common/config/__mocks__/loader-config.js +0 -6
  161. package/src/common/config/__mocks__/runtime.js +0 -6
  162. package/src/common/context/__mocks__/shared-context.js +0 -15
  163. package/src/common/context/shared-context.js +0 -25
package/CHANGELOG.md CHANGED
@@ -3,6 +3,21 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.289.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.288.1...v1.289.0) (2025-04-24)
7
+
8
+
9
+ ### Features
10
+
11
+ * Remove agent config cache and getters/setters ([#1430](https://github.com/newrelic/newrelic-browser-agent/issues/1430)) ([6c3d716](https://github.com/newrelic/newrelic-browser-agent/commit/6c3d7166e6a7014e1ae453801a9da875d311a3e1))
12
+
13
+ ## [1.288.1](https://github.com/newrelic/newrelic-browser-agent/compare/v1.288.0...v1.288.1) (2025-04-18)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * Call handle directly for submitting SM from SR recorder ([#1453](https://github.com/newrelic/newrelic-browser-agent/issues/1453)) ([4920580](https://github.com/newrelic/newrelic-browser-agent/commit/49205807b6038afb32e3f04ebabedfe5fc11456b))
19
+ * Ensure event buffer always exists ([#1452](https://github.com/newrelic/newrelic-browser-agent/issues/1452)) ([56e75b2](https://github.com/newrelic/newrelic-browser-agent/commit/56e75b243b87d1d44e8014ac0ad5f408f0d145c5))
20
+
6
21
  ## [1.288.0](https://github.com/newrelic/newrelic-browser-agent/compare/v1.287.0...v1.288.0) (2025-04-16)
7
22
 
8
23
 
@@ -3,9 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getInfo = getInfo;
7
6
  exports.isValid = isValid;
8
- exports.setInfo = setInfo;
7
+ exports.mergeInfo = void 0;
9
8
  var _nreum = require("../window/nreum");
10
9
  var _configurable = require("./configurable");
11
10
  /**
@@ -34,7 +33,7 @@ var _configurable = require("./configurable");
34
33
  * @property {string} [tNamePlain]
35
34
  */
36
35
 
37
- const model = {
36
+ const InfoModel = {
38
37
  // preset defaults
39
38
  beacon: _nreum.defaults.beacon,
40
39
  errorBeacon: _nreum.defaults.errorBeacon,
@@ -55,23 +54,14 @@ const model = {
55
54
  transactionName: undefined,
56
55
  tNamePlain: undefined
57
56
  };
58
- const _cache = {};
59
- function isValid(id) {
57
+ function isValid(info) {
60
58
  try {
61
- const info = getInfo(id);
62
59
  return !!info.licenseKey && !!info.errorBeacon && !!info.applicationID;
63
60
  } catch (err) {
64
61
  return false;
65
62
  }
66
63
  }
67
- function getInfo(id) {
68
- if (!id) throw new Error('All info objects require an agent identifier!');
69
- if (!_cache[id]) throw new Error("Info for ".concat(id, " was never set"));
70
- return _cache[id];
71
- }
72
- function setInfo(id, obj) {
73
- if (!id) throw new Error('All info objects require an agent identifier!');
74
- _cache[id] = (0, _configurable.getModeledObject)(obj, model);
75
- const agentInst = (0, _nreum.getNREUMInitializedAgent)(id);
76
- if (agentInst) agentInst.info = _cache[id];
77
- }
64
+ const mergeInfo = info => {
65
+ return (0, _configurable.getModeledObject)(info, InfoModel);
66
+ };
67
+ exports.mergeInfo = mergeInfo;
@@ -3,14 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getConfiguration = getConfiguration;
7
- exports.getConfigurationValue = getConfigurationValue;
8
- exports.setConfiguration = setConfiguration;
6
+ exports.mergeInit = void 0;
9
7
  var _constants = require("../../features/generic_events/constants");
10
8
  var _querySelector = require("../dom/query-selector");
11
9
  var _constants2 = require("../session/constants");
12
10
  var _console = require("../util/console");
13
- var _nreum = require("../window/nreum");
14
11
  var _configurable = require("./configurable");
15
12
  /**
16
13
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
@@ -26,7 +23,7 @@ const nrMask = '[data-nr-mask]';
26
23
  /**
27
24
  * @returns {Init} the default configuration object
28
25
  */
29
- const model = () => {
26
+ const InitModelFn = () => {
30
27
  const hiddenState = {
31
28
  feature_flags: [],
32
29
  experimental: {
@@ -214,32 +211,7 @@ const model = () => {
214
211
  }
215
212
  };
216
213
  };
217
- const _cache = {};
218
- const missingAgentIdError = 'All configuration objects require an agent identifier!';
219
- function getConfiguration(id) {
220
- if (!id) throw new Error(missingAgentIdError);
221
- if (!_cache[id]) throw new Error("Configuration for ".concat(id, " was never set"));
222
- return _cache[id];
223
- }
224
- function setConfiguration(id, obj) {
225
- if (!id) throw new Error(missingAgentIdError);
226
- _cache[id] = (0, _configurable.getModeledObject)(obj, model());
227
- const agentInst = (0, _nreum.getNREUMInitializedAgent)(id);
228
- if (agentInst) agentInst.init = _cache[id];
229
- }
230
- function getConfigurationValue(id, path) {
231
- if (!id) throw new Error(missingAgentIdError);
232
- var val = getConfiguration(id);
233
- if (val) {
234
- var parts = path.split('.');
235
- for (var i = 0; i < parts.length - 1; i++) {
236
- val = val[parts[i]];
237
- if (typeof val !== 'object') return;
238
- }
239
- val = val[parts[parts.length - 1]];
240
- }
241
- return val;
242
- }
243
-
244
- // TO DO: a setConfigurationValue equivalent may be nice so individual
245
- // properties can be tuned instead of reseting the whole model per call to `setConfiguration(agentIdentifier, {})`
214
+ const mergeInit = init => {
215
+ return (0, _configurable.getModeledObject)(init, InitModelFn());
216
+ };
217
+ exports.mergeInit = mergeInit;
@@ -3,16 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getLoaderConfig = getLoaderConfig;
7
- exports.setLoaderConfig = setLoaderConfig;
8
- var _nreum = require("../window/nreum");
6
+ exports.mergeLoaderConfig = void 0;
9
7
  var _configurable = require("./configurable");
10
8
  /**
11
9
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
12
10
  * SPDX-License-Identifier: Apache-2.0
13
11
  */
14
12
 
15
- const model = {
13
+ const LoaderConfigModel = {
16
14
  accountID: undefined,
17
15
  trustKey: undefined,
18
16
  agentID: undefined,
@@ -20,15 +18,7 @@ const model = {
20
18
  applicationID: undefined,
21
19
  xpid: undefined
22
20
  };
23
- const _cache = {};
24
- function getLoaderConfig(id) {
25
- if (!id) throw new Error('All loader-config objects require an agent identifier!');
26
- if (!_cache[id]) throw new Error("LoaderConfig for ".concat(id, " was never set"));
27
- return _cache[id];
28
- }
29
- function setLoaderConfig(id, obj) {
30
- if (!id) throw new Error('All loader-config objects require an agent identifier!');
31
- _cache[id] = (0, _configurable.getModeledObject)(obj, model);
32
- const agentInst = (0, _nreum.getNREUMInitializedAgent)(id);
33
- if (agentInst) agentInst.loader_config = _cache[id];
34
- }
21
+ const mergeLoaderConfig = loaderConfig => {
22
+ return (0, _configurable.getModeledObject)(loaderConfig, LoaderConfigModel);
23
+ };
24
+ exports.mergeLoaderConfig = mergeLoaderConfig;
@@ -3,10 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getRuntime = getRuntime;
7
- exports.setRuntime = setRuntime;
6
+ exports.mergeRuntime = void 0;
8
7
  var _configurable = require("./configurable");
9
- var _nreum = require("../window/nreum");
10
8
  var _runtime = require("../constants/runtime");
11
9
  var _env = require("../constants/env.npm");
12
10
  /**
@@ -19,13 +17,13 @@ var _env = require("../constants/env.npm");
19
17
  * @type {number}
20
18
  */
21
19
  let harvestCount = 0;
22
- const readonly = {
20
+ const ReadOnly = {
23
21
  buildEnv: _env.BUILD_ENV,
24
22
  distMethod: _env.DIST_METHOD,
25
23
  version: _env.VERSION,
26
24
  originTime: _runtime.originTime
27
25
  };
28
- const model = {
26
+ const RuntimeModel = {
29
27
  /** Agent-specific metadata found in the RUM call response. ex. entityGuid */
30
28
  appMetadata: {},
31
29
  customTransaction: undefined,
@@ -41,26 +39,22 @@ const model = {
41
39
  ptid: undefined,
42
40
  releaseIds: {},
43
41
  session: undefined,
44
- timeKeeper: undefined
45
- };
46
- const _cache = {};
47
- function getRuntime(id) {
48
- if (!id) throw new Error('All runtime objects require an agent identifier!');
49
- if (!_cache[id]) throw new Error("Runtime for ".concat(id, " was never set"));
50
- return _cache[id];
51
- }
52
- function setRuntime(id, obj) {
53
- if (!id) throw new Error('All runtime objects require an agent identifier!');
54
- _cache[id] = {
55
- ...(0, _configurable.getModeledObject)(obj, model),
56
- ...readonly
57
- };
58
- if (!Object.hasOwnProperty.call(_cache[id], 'harvestCount')) {
59
- // Harvest count needs to be added as a getter so the variable is updated each time it is accessed
60
- Object.defineProperty(_cache[id], 'harvestCount', {
61
- get: () => ++harvestCount
62
- });
42
+ timeKeeper: undefined,
43
+ get harvestCount() {
44
+ return ++harvestCount;
63
45
  }
64
- const agentInst = (0, _nreum.getNREUMInitializedAgent)(id);
65
- if (agentInst) agentInst.runtime = _cache[id];
66
- }
46
+ };
47
+ const mergeRuntime = runtime => {
48
+ const modeledObject = (0, _configurable.getModeledObject)(runtime, RuntimeModel);
49
+ const readonlyDescriptors = Object.keys(ReadOnly).reduce((descriptors, key) => {
50
+ descriptors[key] = {
51
+ value: ReadOnly[key],
52
+ writable: false,
53
+ configurable: true,
54
+ enumerable: true
55
+ };
56
+ return descriptors;
57
+ }, {});
58
+ return Object.defineProperties(modeledObject, readonlyDescriptors);
59
+ };
60
+ exports.mergeRuntime = mergeRuntime;
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.288.0";
20
+ const VERSION = exports.VERSION = "1.289.0";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -17,7 +17,7 @@ exports.VERSION = exports.RRWEB_VERSION = exports.DIST_METHOD = exports.BUILD_EN
17
17
  /**
18
18
  * Exposes the version of the agent
19
19
  */
20
- const VERSION = exports.VERSION = "1.288.0";
20
+ const VERSION = exports.VERSION = "1.289.0";
21
21
 
22
22
  /**
23
23
  * Exposes the build type of the agent
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ee = exports.contextId = void 0;
7
7
  var _nreum = require("../window/nreum");
8
8
  var _getOrSet = require("../util/get-or-set");
9
- var _runtime = require("../config/runtime");
10
9
  var _eventContext = require("./event-context");
11
10
  var _bundleId = require("../ids/bundle-id");
12
11
  /**
@@ -36,7 +35,7 @@ function ee(old, debugId) {
36
35
  // We only want to check the runtime configuration for `isolatedBacklog` if the event emitter belongs to a feature.
37
36
  // For feature event emitters, the debugId will be an agentIdentifier with a length of 16. In contrast, some of our
38
37
  // tests do not namespace the event emitter with an agentID and just use the parent (which has no ID).
39
- isolatedBacklog = debugId.length !== 16 ? false : (0, _runtime.getRuntime)(debugId).isolatedBacklog;
38
+ isolatedBacklog = debugId.length !== 16 ? false : nr.initializedAgents?.[debugId]?.runtime.isolatedBacklog;
40
39
  } catch (err) {
41
40
  // Do nothing for now.
42
41
  }
@@ -8,7 +8,6 @@ exports.getAddStringContext = getAddStringContext;
8
8
  exports.nullable = nullable;
9
9
  exports.numeric = numeric;
10
10
  var _stringify = require("../util/stringify");
11
- var _runtime = require("../config/runtime");
12
11
  /**
13
12
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
14
13
  * SPDX-License-Identifier: Apache-2.0
@@ -25,10 +24,9 @@ function numeric(n, noDefault) {
25
24
  }
26
25
  return n === undefined || n === 0 ? '' : Math.floor(n).toString(36);
27
26
  }
28
- function getAddStringContext(agentIdentifier) {
27
+ function getAddStringContext(obfuscator) {
29
28
  let stringTableIdx = 0;
30
29
  const stringTable = Object.prototype.hasOwnProperty.call(Object, 'create') ? Object.create(null) : {};
31
- const obfuscator = (0, _runtime.getRuntime)(agentIdentifier).obfuscator;
32
30
  return addString;
33
31
  function addString(str) {
34
32
  if (typeof str === 'undefined' || str === '') return '';
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.TimeKeeper = void 0;
7
7
  var _runtime = require("../constants/runtime");
8
- var _runtime2 = require("../config/runtime");
9
8
  /**
10
9
  * Copyright 2020-2025 New Relic, Inc. All rights reserved.
11
10
  * SPDX-License-Identifier: Apache-2.0
@@ -42,8 +41,8 @@ class TimeKeeper {
42
41
  * @type {boolean}
43
42
  */
44
43
  #ready = false;
45
- constructor(agentIdentifier) {
46
- this.#session = (0, _runtime2.getRuntime)(agentIdentifier)?.session;
44
+ constructor(sessionObj) {
45
+ this.#session = sessionObj;
47
46
  this.processStoredDiff();
48
47
  }
49
48
  get ready() {
@@ -115,7 +115,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
115
115
  }
116
116
  serializer(eventBuffer) {
117
117
  if (!eventBuffer.length) return;
118
- const addString = (0, _belSerializer.getAddStringContext)(this.agentIdentifier);
118
+ const addString = (0, _belSerializer.getAddStringContext)(this.agentRef.runtime.obfuscator);
119
119
  let payload = 'bel.7;';
120
120
  for (let i = 0; i < eventBuffer.length; i++) {
121
121
  const event = eventBuffer[i];
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.DT = void 0;
7
- var _init = require("../../../common/config/init");
8
- var _loaderConfig = require("../../../common/config/loader-config");
9
7
  var _uniqueId = require("../../../common/ids/unique-id");
10
8
  var _parseUrl = require("../../../common/url/parse-url");
11
9
  var _runtime = require("../../../common/constants/runtime");
@@ -16,15 +14,12 @@ var _stringify = require("../../../common/util/stringify");
16
14
  */
17
15
 
18
16
  class DT {
19
- constructor(agentIdentifier) {
20
- this.agentIdentifier = agentIdentifier;
17
+ constructor(agentRef) {
18
+ this.agentRef = agentRef;
21
19
  }
22
20
  generateTracePayload(parsedOrigin) {
23
- if (!this.shouldGenerateTrace(parsedOrigin)) {
24
- return null;
25
- }
26
- var loaderConfig = (0, _loaderConfig.getLoaderConfig)(this.agentIdentifier);
27
- if (!loaderConfig) {
21
+ const loaderConfig = this.agentRef.loader_config;
22
+ if (!this.shouldGenerateTrace(parsedOrigin) || !loaderConfig) {
28
23
  return null;
29
24
  }
30
25
  var accountId = (loaderConfig.accountID || '').toString() || null;
@@ -86,18 +81,14 @@ class DT {
86
81
  // return true if DT is enabled and the origin is allowed, either by being
87
82
  // same-origin, or included in the allowed list
88
83
  shouldGenerateTrace(parsedOrigin) {
89
- return this.isDtEnabled() && this.isAllowedOrigin(parsedOrigin);
84
+ return this.agentRef.init?.distributed_tracing && this.isAllowedOrigin(parsedOrigin);
90
85
  }
91
86
  isAllowedOrigin(parsedOrigin) {
92
87
  var allowed = false;
93
- var dtConfig = {};
94
- var dt = (0, _init.getConfigurationValue)(this.agentIdentifier, 'distributed_tracing');
95
- if (dt) {
96
- dtConfig = (0, _init.getConfiguration)(this.agentIdentifier).distributed_tracing;
97
- }
88
+ const dtConfig = this.agentRef.init?.distributed_tracing;
98
89
  if (parsedOrigin.sameOrigin) {
99
90
  allowed = true;
100
- } else if (dtConfig.allowed_origins instanceof Array) {
91
+ } else if (dtConfig?.allowed_origins instanceof Array) {
101
92
  for (var i = 0; i < dtConfig.allowed_origins.length; i++) {
102
93
  var allowedOrigin = (0, _parseUrl.parseUrl)(dtConfig.allowed_origins[i]);
103
94
  if (parsedOrigin.hostname === allowedOrigin.hostname && parsedOrigin.protocol === allowedOrigin.protocol && parsedOrigin.port === allowedOrigin.port) {
@@ -108,31 +99,24 @@ class DT {
108
99
  }
109
100
  return allowed;
110
101
  }
111
- isDtEnabled() {
112
- var dt = (0, _init.getConfigurationValue)(this.agentIdentifier, 'distributed_tracing');
113
- if (dt) {
114
- return !!dt.enabled;
115
- }
116
- return false;
117
- }
118
102
 
119
103
  // exclude the newrelic header for same-origin calls
120
104
  excludeNewrelicHeader() {
121
- var dt = (0, _init.getConfigurationValue)(this.agentIdentifier, 'distributed_tracing');
105
+ var dt = this.agentRef.init?.distributed_tracing;
122
106
  if (dt) {
123
107
  return !!dt.exclude_newrelic_header;
124
108
  }
125
109
  return false;
126
110
  }
127
111
  useNewrelicHeaderForCors() {
128
- var dt = (0, _init.getConfigurationValue)(this.agentIdentifier, 'distributed_tracing');
112
+ var dt = this.agentRef.init?.distributed_tracing;
129
113
  if (dt) {
130
114
  return dt.cors_use_newrelic_header !== false;
131
115
  }
132
116
  return false;
133
117
  }
134
118
  useTraceContextHeadersForCors() {
135
- var dt = (0, _init.getConfigurationValue)(this.agentIdentifier, 'distributed_tracing');
119
+ var dt = this.agentRef.init?.distributed_tracing;
136
120
  if (dt) {
137
121
  return !!dt.cors_use_tracecontext_headers;
138
122
  }
@@ -35,7 +35,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
35
35
  static featureName = _constants.FEATURE_NAME;
36
36
  constructor(agentRef, auto = true) {
37
37
  super(agentRef, _constants.FEATURE_NAME, auto);
38
- this.dt = new _distributedTracing.DT(agentRef.agentIdentifier);
38
+ this.dt = new _distributedTracing.DT(agentRef);
39
39
  this.handler = (type, args, ctx, group) => (0, _handle.handle)(type, args, ctx, group, this.ee);
40
40
 
41
41
  // this is a best (but imperfect) effort at capturing AJAX calls that may have fired before the agent was instantiated
@@ -26,7 +26,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
26
26
  static featureName = _constants.FEATURE_NAME;
27
27
  constructor(agentRef) {
28
28
  super(agentRef, _constants.FEATURE_NAME);
29
- this.isSessionTrackingEnabled = (0, _featureGates.canEnableSessionTracking)(this.agentIdentifier) && this.agentRef.runtime.session;
29
+ this.isSessionTrackingEnabled = (0, _featureGates.canEnableSessionTracking)(agentRef.init) && agentRef.runtime.session;
30
30
 
31
31
  // The SessionEntity class can emit a message indicating the session was cleared and reset (expiry, inactivity). This feature must abort and never resume if that occurs.
32
32
  this.ee.on(_constants2.SESSION_EVENTS.RESET, () => {
@@ -39,11 +39,11 @@ class Aggregate extends _aggregateBase.AggregateBase {
39
39
  (0, _registerHandler.registerHandler)('send-rum', (customAttibutes, target) => {
40
40
  this.sendRum(customAttibutes, target);
41
41
  }, this.featureName, this.ee);
42
- if (!(0, _info.isValid)(agentRef.agentIdentifier)) {
42
+ if (!(0, _info.isValid)(agentRef.info)) {
43
43
  this.ee.abort();
44
44
  return (0, _console.warn)(43);
45
45
  }
46
- agentRef.runtime.timeKeeper = new _timeKeeper.TimeKeeper(agentRef.agentIdentifier);
46
+ agentRef.runtime.timeKeeper = new _timeKeeper.TimeKeeper(agentRef.runtime.session);
47
47
  if (_runtime.isBrowserScope) {
48
48
  _timeToFirstByte.timeToFirstByte.subscribe(({
49
49
  value,
@@ -139,7 +139,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
139
139
 
140
140
  // serialize array of timing data
141
141
  serializer(eventBuffer) {
142
- var addString = (0, _belSerializer.getAddStringContext)(this.agentIdentifier);
142
+ var addString = (0, _belSerializer.getAddStringContext)(this.agentRef.runtime.obfuscator);
143
143
  var payload = 'bel.6;';
144
144
  for (var i = 0; i < eventBuffer.length; i++) {
145
145
  var timing = eventBuffer[i];
@@ -50,7 +50,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
50
50
  this.recorder = args?.recorder;
51
51
  this.errorNoticed = args?.errorNoticed || false;
52
52
  this.harvestOpts.raw = true;
53
- this.isSessionTrackingEnabled = (0, _featureGates.canEnableSessionTracking)(this.agentIdentifier) && !!this.agentRef.runtime.session;
53
+ this.isSessionTrackingEnabled = (0, _featureGates.canEnableSessionTracking)(agentRef.init) && !!agentRef.runtime.session;
54
54
  this.reportSupportabilityMetric('Config/SessionReplay/Enabled');
55
55
 
56
56
  // The SessionEntity class can emit a message indicating the session was cleared and reset (expiry, inactivity). This feature must abort and never resume if that occurs.
@@ -28,7 +28,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
28
28
  try {
29
29
  session = JSON.parse(localStorage.getItem("".concat(_constants.PREFIX, "_").concat(_constants.DEFAULT_KEY)));
30
30
  } catch (err) {}
31
- if ((0, _utils.hasReplayPrerequisite)(agentRef.agentIdentifier)) {
31
+ if ((0, _utils.hasReplayPrerequisite)(agentRef.init)) {
32
32
  this.ee.on(_constants2.SR_EVENT_EMITTER_TYPES.RECORD, () => this.#apiStartOrRestartReplay());
33
33
  }
34
34
  if (this.#canPreloadRecorder(session)) {
@@ -58,12 +58,12 @@ class Instrument extends _instrumentBase.InstrumentBase {
58
58
  // this might be a new session if entity initializes: conservatively start recording if first-time config allows
59
59
  // Note: users with SR enabled, as well as these other configs enabled by-default, will be penalized by the recorder overhead EVEN IF they don't actually have or get
60
60
  // entitlement or sampling decision, or otherwise intentionally opted-in for the feature.
61
- return (0, _utils.isPreloadAllowed)(this.agentIdentifier);
61
+ return (0, _utils.isPreloadAllowed)(this.#agentRef.init);
62
62
  } else if (session.sessionReplayMode === _constants.MODE.FULL || session.sessionReplayMode === _constants.MODE.ERROR) {
63
63
  return true; // existing sessions get to continue recording, regardless of this page's configs or if it has expired (conservatively)
64
64
  } else {
65
65
  // SR mode was OFF but may potentially be turned on if session resets and configs allows the new session to have replay...
66
- return (0, _utils.isPreloadAllowed)(this.agentIdentifier);
66
+ return (0, _utils.isPreloadAllowed)(this.#agentRef.init);
67
67
  }
68
68
  }
69
69
  #alreadyStarted = false;
@@ -166,7 +166,7 @@ class Recorder {
166
166
  store(event, isCheckout) {
167
167
  if (!event) return;
168
168
  if (this.parent.agentRef.runtime?.session?.isAfterSessionExpiry(event.timestamp)) {
169
- this.parent.reportSupportabilityMetric('Session/Expired/SessionReplay/Seen');
169
+ (0, _handle.handle)(_constants3.SUPPORTABILITY_METRIC_CHANNEL, ['Session/Expired/SessionReplay/Seen'], undefined, _features.FEATURE_NAMES.metrics, this.ee);
170
170
  return;
171
171
  }
172
172
  if (!(this.parent instanceof _aggregateBase.AggregateBase) && this.#preloaded.length) this.currentBufferTarget = this.#preloaded[this.#preloaded.length - 1];else this.currentBufferTarget = this.#events;
@@ -8,7 +8,6 @@ exports.customMasker = customMasker;
8
8
  exports.hasReplayPrerequisite = hasReplayPrerequisite;
9
9
  exports.isPreloadAllowed = isPreloadAllowed;
10
10
  var _nreum = require("../../../common/window/nreum");
11
- var _init = require("../../../common/config/init");
12
11
  var _featureGates = require("../../utils/feature-gates");
13
12
  var _runtime = require("../../../common/constants/runtime");
14
13
  /**
@@ -16,15 +15,15 @@ var _runtime = require("../../../common/constants/runtime");
16
15
  * SPDX-License-Identifier: Apache-2.0
17
16
  */
18
17
 
19
- function hasReplayPrerequisite(agentId) {
18
+ function hasReplayPrerequisite(agentInit) {
20
19
  return !!(0, _nreum.gosNREUMOriginals)().o.MO &&
21
20
  // Session Replay cannot work without Mutation Observer
22
- (0, _featureGates.canEnableSessionTracking)(agentId) &&
21
+ (0, _featureGates.canEnableSessionTracking)(agentInit) &&
23
22
  // requires session tracking to be running (hence "session" replay...)
24
- (0, _init.getConfigurationValue)(agentId, 'session_trace.enabled') === true; // Session Replay as of now is tightly coupled with Session Trace in the UI
23
+ agentInit?.session_trace.enabled === true; // Session Replay as of now is tightly coupled with Session Trace in the UI
25
24
  }
26
- function isPreloadAllowed(agentId) {
27
- return (0, _init.getConfigurationValue)(agentId, 'session_replay.preload') === true && hasReplayPrerequisite(agentId);
25
+ function isPreloadAllowed(agentInit) {
26
+ return agentInit?.session_replay.preload === true && hasReplayPrerequisite(agentInit);
28
27
  }
29
28
  function buildNRMetaNode(timestamp, timeKeeper) {
30
29
  const correctedTimestamp = timeKeeper.correctAbsoluteTimestamp(timestamp);
@@ -33,7 +33,7 @@ class Instrument extends _instrumentBase.InstrumentBase {
33
33
  static featureName = FEATURE_NAME;
34
34
  constructor(agentRef, auto = true) {
35
35
  super(agentRef, FEATURE_NAME, auto);
36
- const canTrackSession = (0, _featureGates.canEnableSessionTracking)(this.agentIdentifier);
36
+ const canTrackSession = (0, _featureGates.canEnableSessionTracking)(agentRef.init);
37
37
  if (!canTrackSession) {
38
38
  this.deregisterDrain();
39
39
  return;
@@ -13,8 +13,8 @@ var _belNode = require("./bel-node");
13
13
  */
14
14
 
15
15
  class AjaxNode extends _belNode.BelNode {
16
- constructor(agentIdentifier, ajaxEvent) {
17
- super(agentIdentifier);
16
+ constructor(agentRef, ajaxEvent) {
17
+ super(agentRef);
18
18
  this.belType = _constants.NODE_TYPE.AJAX;
19
19
  this.method = ajaxEvent.method;
20
20
  this.status = ajaxEvent.status;
@@ -31,7 +31,7 @@ class AjaxNode extends _belNode.BelNode {
31
31
  this.end = ajaxEvent.endTime;
32
32
  }
33
33
  serialize(parentStartTimestamp) {
34
- const addString = (0, _belSerializer.getAddStringContext)(this.agentIdentifier);
34
+ const addString = (0, _belSerializer.getAddStringContext)(this.obfuscator);
35
35
  const nodeList = [];
36
36
 
37
37
  // IMPORTANT: The order in which addString is called matters and correlates to the order in which string shows up in the harvest payload. Do not re-order the following code.
@@ -18,9 +18,9 @@ class BelNode {
18
18
  callbackEnd = 0;
19
19
  callbackDuration = 0;
20
20
  nodeId = ++nodesSeen;
21
- constructor(agentIdentifier) {
22
- if (!agentIdentifier) throw new Error('Interaction is missing core attributes');
23
- this.agentIdentifier = agentIdentifier;
21
+ constructor(agentRef) {
22
+ this.obfuscator = agentRef.runtime.obfuscator;
23
+ this.info = agentRef.info;
24
24
  }
25
25
  addChild(child) {
26
26
  this.children.push(child);
@@ -27,20 +27,13 @@ class Aggregate extends _aggregateBase.AggregateBase {
27
27
  super(agentRef, _constants.FEATURE_NAME);
28
28
  this.interactionsToHarvest = this.events;
29
29
  this.domObserver = domObserver;
30
- this.initialPageLoadInteraction = new _initialPageLoadInteraction.InitialPageLoadInteraction(agentRef.agentIdentifier);
30
+ this.initialPageLoadInteraction = new _initialPageLoadInteraction.InitialPageLoadInteraction(agentRef);
31
31
  this.initialPageLoadInteraction.onDone.push(() => {
32
32
  // this ensures the .end() method also works with iPL
33
33
  if (agentRef.runtime.session?.isNew) this.initialPageLoadInteraction.customAttributes.isFirstOfSession = true; // mark the hard page load as first of its session
34
34
  this.initialPageLoadInteraction.forceSave = true; // unless forcibly ignored, iPL always finish by default
35
35
  const ixn = this.initialPageLoadInteraction;
36
- /** this.events (ixns to harvest) has already been set up, use it immediately */
37
- if (this.interactionsToHarvest) this.interactionsToHarvest.add(ixn);else {
38
- /** this.events (ixns to harvest) hasnt been initialized yet... wait for it */
39
- this.ee.on('entity-added', () => {
40
- this.interactionsToHarvest = this.events;
41
- this.interactionsToHarvest.add(ixn);
42
- });
43
- }
36
+ this.interactionsToHarvest.add(ixn);
44
37
  this.initialPageLoadInteraction = null;
45
38
  });
46
39
  _timeToFirstByte.timeToFirstByte.subscribe(({
@@ -98,7 +91,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
98
91
  if (this.interactionInProgress?.done() === false) return; // current in-progress is blocked from closing, e.g. by 'waitForEnd' api option
99
92
 
100
93
  const oldURL = eventName === _constants.INTERACTION_TRIGGERS[3] ? this.latestHistoryUrl : undefined; // see related comment in 'newURL' handler above, 'popstate'
101
- this.interactionInProgress = new _interaction.Interaction(this.agentIdentifier, eventName, startedAt, this.latestRouteSetByApi, oldURL);
94
+ this.interactionInProgress = new _interaction.Interaction(this.agentRef, eventName, startedAt, this.latestRouteSetByApi, oldURL);
102
95
  if (eventName === _constants.INTERACTION_TRIGGERS[0]) {
103
96
  // 'click'
104
97
  const sourceElemText = getActionText(sourceElem);
@@ -168,15 +161,15 @@ class Aggregate extends _aggregateBase.AggregateBase {
168
161
  // no interaction was happening when this ajax started, so give it back to Ajax feature for processing
169
162
  (0, _handle.handle)('returnAjax', [event], undefined, _features.FEATURE_NAMES.ajax, this.ee);
170
163
  } else {
171
- if (associatedInteraction.status === _constants.INTERACTION_STATUS.FIN) processAjax(this.agentIdentifier, event, associatedInteraction); // tack ajax onto the ixn object awaiting harvest
164
+ if (associatedInteraction.status === _constants.INTERACTION_STATUS.FIN) processAjax(this.agentRef, event, associatedInteraction); // tack ajax onto the ixn object awaiting harvest
172
165
  else {
173
166
  // same thing as above, just at a later time -- if the interaction in progress is cancelled, just send the event back to ajax feat unmodified
174
- associatedInteraction.on('finished', () => processAjax(this.agentIdentifier, event, associatedInteraction));
167
+ associatedInteraction.on('finished', () => processAjax(this.agentRef, event, associatedInteraction));
175
168
  associatedInteraction.on('cancelled', () => (0, _handle.handle)('returnAjax', [event], undefined, _features.FEATURE_NAMES.ajax, this.ee));
176
169
  }
177
170
  }
178
- function processAjax(agentId, event, parentInteraction) {
179
- const newNode = new _ajaxNode.AjaxNode(agentId, event);
171
+ function processAjax(agent, event, parentInteraction) {
172
+ const newNode = new _ajaxNode.AjaxNode(agent, event);
180
173
  parentInteraction.addChild(newNode);
181
174
  }
182
175
  }
@@ -215,7 +208,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
215
208
  if (this.associatedInteraction?.trigger === _constants.IPL_TRIGGER_NAME) this.associatedInteraction = null; // the api get-interaction method cannot target IPL
216
209
  if (!this.associatedInteraction) {
217
210
  // This new api-driven interaction will be the target of any subsequent .interaction() call, until it is closed by EITHER .end() OR the regular seenHistoryAndDomChange process.
218
- this.associatedInteraction = thisClass.interactionInProgress = new _interaction.Interaction(thisClass.agentIdentifier, _constants.API_TRIGGER_NAME, time, thisClass.latestRouteSetByApi);
211
+ this.associatedInteraction = thisClass.interactionInProgress = new _interaction.Interaction(thisClass.agentRef, _constants.API_TRIGGER_NAME, time, thisClass.latestRouteSetByApi);
219
212
  thisClass.domObserver.observe(document.body, {
220
213
  attributes: true,
221
214
  childList: true,