@newrelic/browser-agent 1.238.0 → 1.239.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 (249) hide show
  1. package/dist/cjs/common/config/state/init.js +21 -13
  2. package/dist/cjs/common/config/state/runtime.js +0 -4
  3. package/dist/cjs/common/constants/env.cdn.js +1 -1
  4. package/dist/cjs/common/constants/env.npm.js +1 -1
  5. package/dist/cjs/common/constants/runtime.js +3 -3
  6. package/dist/cjs/common/constants/shared-channel.js +3 -1
  7. package/dist/cjs/common/deny-list/deny-list.js +2 -8
  8. package/dist/cjs/common/drain/drain.js +1 -1
  9. package/dist/cjs/common/event-emitter/contextual-ee.js +6 -6
  10. package/dist/cjs/common/harvest/harvest-scheduler.js +2 -4
  11. package/dist/cjs/common/harvest/harvest.js +2 -6
  12. package/dist/cjs/common/serialize/bel-serializer.js +1 -1
  13. package/dist/cjs/common/session/session-entity.js +16 -12
  14. package/dist/cjs/common/storage/first-party-cookies.js +5 -4
  15. package/dist/cjs/common/storage/local-storage.js +3 -2
  16. package/dist/cjs/common/timer/interaction-timer.js +14 -6
  17. package/dist/cjs/common/timing/nav-timing.js +1 -1
  18. package/dist/cjs/common/unload/eol.js +4 -30
  19. package/dist/cjs/common/util/feature-flags.js +14 -15
  20. package/dist/cjs/common/util/invoke.js +3 -1
  21. package/dist/cjs/common/util/obfuscate.js +3 -5
  22. package/dist/cjs/common/util/traverse.js +1 -0
  23. package/dist/cjs/common/window/page-visibility.js +1 -2
  24. package/dist/cjs/common/wrap/wrap-jsonp.js +1 -1
  25. package/dist/cjs/features/ajax/aggregate/index.js +5 -7
  26. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +8 -8
  27. package/dist/cjs/features/ajax/instrument/index.js +47 -15
  28. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +0 -1
  29. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  30. package/dist/cjs/features/jserrors/aggregate/index.js +4 -5
  31. package/dist/cjs/features/metrics/aggregate/framework-detection.js +103 -7
  32. package/dist/cjs/features/metrics/aggregate/index.js +20 -37
  33. package/dist/cjs/features/metrics/instrument/index.js +0 -2
  34. package/dist/cjs/features/page_action/aggregate/index.js +17 -19
  35. package/dist/cjs/features/page_view_event/aggregate/index.js +1 -2
  36. package/dist/cjs/features/page_view_event/instrument/index.js +4 -2
  37. package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -7
  38. package/dist/cjs/features/session_replay/aggregate/index.js +3 -3
  39. package/dist/cjs/features/session_trace/aggregate/index.js +8 -8
  40. package/dist/cjs/features/spa/aggregate/index.js +14 -20
  41. package/dist/cjs/features/spa/aggregate/interaction.js +0 -2
  42. package/dist/cjs/features/spa/aggregate/serializer.js +1 -1
  43. package/dist/cjs/features/utils/aggregate-base.js +4 -0
  44. package/dist/cjs/features/utils/handler-cache.js +3 -1
  45. package/dist/cjs/features/utils/instrument-base.js +24 -6
  46. package/dist/cjs/loaders/agent-base.js +11 -0
  47. package/dist/cjs/loaders/agent.js +7 -7
  48. package/dist/cjs/loaders/api/api.js +21 -4
  49. package/dist/cjs/loaders/api/apiAsync.js +19 -20
  50. package/dist/cjs/loaders/configure/configure.js +3 -0
  51. package/dist/cjs/loaders/micro-agent.js +20 -3
  52. package/dist/esm/common/config/state/init.js +21 -13
  53. package/dist/esm/common/config/state/runtime.js +0 -4
  54. package/dist/esm/common/constants/env.cdn.js +1 -1
  55. package/dist/esm/common/constants/env.npm.js +1 -1
  56. package/dist/esm/common/constants/runtime.js +1 -1
  57. package/dist/esm/common/constants/shared-channel.js +3 -1
  58. package/dist/esm/common/deny-list/deny-list.js +2 -8
  59. package/dist/esm/common/drain/drain.js +1 -1
  60. package/dist/esm/common/event-emitter/contextual-ee.js +6 -6
  61. package/dist/esm/common/harvest/harvest-scheduler.js +2 -4
  62. package/dist/esm/common/harvest/harvest.js +2 -6
  63. package/dist/esm/common/serialize/bel-serializer.js +1 -1
  64. package/dist/esm/common/session/session-entity.js +16 -12
  65. package/dist/esm/common/storage/first-party-cookies.js +5 -4
  66. package/dist/esm/common/storage/local-storage.js +3 -2
  67. package/dist/esm/common/timer/interaction-timer.js +14 -6
  68. package/dist/esm/common/timing/nav-timing.js +1 -1
  69. package/dist/esm/common/unload/eol.js +5 -31
  70. package/dist/esm/common/util/feature-flags.js +14 -15
  71. package/dist/esm/common/util/invoke.js +3 -1
  72. package/dist/esm/common/util/obfuscate.js +3 -5
  73. package/dist/esm/common/util/traverse.js +1 -0
  74. package/dist/esm/common/window/page-visibility.js +1 -2
  75. package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
  76. package/dist/esm/features/ajax/aggregate/index.js +5 -7
  77. package/dist/esm/features/ajax/instrument/distributed-tracing.js +8 -8
  78. package/dist/esm/features/ajax/instrument/index.js +47 -15
  79. package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +0 -1
  80. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  81. package/dist/esm/features/jserrors/aggregate/index.js +4 -5
  82. package/dist/esm/features/metrics/aggregate/framework-detection.js +103 -7
  83. package/dist/esm/features/metrics/aggregate/index.js +22 -39
  84. package/dist/esm/features/metrics/instrument/index.js +1 -3
  85. package/dist/esm/features/page_action/aggregate/index.js +17 -19
  86. package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
  87. package/dist/esm/features/page_view_event/instrument/index.js +4 -2
  88. package/dist/esm/features/page_view_timing/aggregate/index.js +7 -8
  89. package/dist/esm/features/session_replay/aggregate/index.js +2 -2
  90. package/dist/esm/features/session_trace/aggregate/index.js +8 -8
  91. package/dist/esm/features/spa/aggregate/index.js +14 -20
  92. package/dist/esm/features/spa/aggregate/interaction.js +0 -2
  93. package/dist/esm/features/spa/aggregate/serializer.js +1 -1
  94. package/dist/esm/features/utils/aggregate-base.js +4 -0
  95. package/dist/esm/features/utils/handler-cache.js +3 -1
  96. package/dist/esm/features/utils/instrument-base.js +24 -6
  97. package/dist/esm/loaders/agent-base.js +11 -0
  98. package/dist/esm/loaders/agent.js +7 -7
  99. package/dist/esm/loaders/api/api.js +21 -4
  100. package/dist/esm/loaders/api/apiAsync.js +19 -20
  101. package/dist/esm/loaders/configure/configure.js +3 -0
  102. package/dist/esm/loaders/features/enabled-features.js +1 -1
  103. package/dist/esm/loaders/micro-agent.js +21 -4
  104. package/dist/types/common/config/state/init.d.ts.map +1 -1
  105. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  106. package/dist/types/common/constants/runtime.d.ts +1 -1
  107. package/dist/types/common/constants/runtime.d.ts.map +1 -1
  108. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  109. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  110. package/dist/types/common/session/session-entity.d.ts +6 -9
  111. package/dist/types/common/session/session-entity.d.ts.map +1 -1
  112. package/dist/types/common/storage/first-party-cookies.d.ts +1 -1
  113. package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -1
  114. package/dist/types/common/storage/local-storage.d.ts.map +1 -1
  115. package/dist/types/common/timer/interaction-timer.d.ts +3 -0
  116. package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
  117. package/dist/types/common/unload/eol.d.ts +1 -2
  118. package/dist/types/common/unload/eol.d.ts.map +1 -1
  119. package/dist/types/common/util/feature-flags.d.ts.map +1 -1
  120. package/dist/types/common/util/obfuscate.d.ts.map +1 -1
  121. package/dist/types/common/util/traverse.d.ts.map +1 -1
  122. package/dist/types/common/window/page-visibility.d.ts.map +1 -1
  123. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  124. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  125. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -1
  126. package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
  127. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  128. package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -1
  129. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  130. package/dist/types/features/metrics/instrument/index.d.ts.map +1 -1
  131. package/dist/types/features/page_action/aggregate/index.d.ts +2 -2
  132. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  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.map +1 -1
  135. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -1
  136. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  137. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  138. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
  139. package/dist/types/features/utils/aggregate-base.d.ts +1 -0
  140. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  141. package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
  142. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  143. package/dist/types/loaders/agent-base.d.ts +6 -0
  144. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  145. package/dist/types/loaders/agent.d.ts +1 -1
  146. package/dist/types/loaders/agent.d.ts.map +1 -1
  147. package/dist/types/loaders/api/api.d.ts +1 -0
  148. package/dist/types/loaders/api/api.d.ts.map +1 -1
  149. package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
  150. package/dist/types/loaders/configure/configure.d.ts +1 -0
  151. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  152. package/dist/types/loaders/micro-agent.d.ts +7 -1
  153. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  154. package/package.json +41 -12
  155. package/src/common/aggregate/aggregator.test.js +107 -0
  156. package/src/common/config/state/configurable.test.js +73 -0
  157. package/src/common/config/state/info.test.js +31 -0
  158. package/src/common/config/state/init.js +13 -12
  159. package/src/common/config/state/init.test.js +28 -0
  160. package/src/common/config/state/loader-config.test.js +21 -0
  161. package/src/common/config/state/runtime.js +0 -2
  162. package/src/common/config/state/runtime.test.js +21 -0
  163. package/src/common/constants/__mocks__/runtime.js +1 -1
  164. package/src/common/constants/runtime.js +1 -1
  165. package/src/common/constants/runtime.test.js +2 -2
  166. package/src/common/constants/shared-channel.js +1 -1
  167. package/src/common/deny-list/deny-list.js +2 -10
  168. package/src/common/drain/drain.js +1 -1
  169. package/src/common/drain/drain.test.js +74 -0
  170. package/src/common/event-emitter/contextual-ee.js +6 -6
  171. package/src/common/harvest/harvest-scheduler.js +2 -5
  172. package/src/common/harvest/harvest-scheduler.test.js +2 -6
  173. package/src/common/harvest/harvest.js +2 -6
  174. package/src/common/harvest/harvest.test.js +0 -2
  175. package/src/common/ids/id.test.js +6 -6
  176. package/src/common/serialize/bel-serializer.js +1 -1
  177. package/src/common/session/session-entity.component-test.js +3 -2
  178. package/src/common/session/session-entity.js +11 -9
  179. package/src/common/storage/first-party-cookies.js +5 -4
  180. package/src/common/storage/local-storage.js +3 -2
  181. package/src/common/timer/interaction-timer.component-test.js +52 -7
  182. package/src/common/timer/interaction-timer.js +15 -6
  183. package/src/common/timer/timer.test.js +0 -1
  184. package/src/common/timing/nav-timing.js +1 -1
  185. package/src/common/unload/eol.js +5 -31
  186. package/src/common/url/encode.test.js +1 -0
  187. package/src/common/util/__mocks__/invoke.js +1 -0
  188. package/src/common/util/data-size.test.js +0 -1
  189. package/src/common/util/feature-flags.js +15 -17
  190. package/src/common/util/feature-flags.test.js +4 -8
  191. package/src/common/util/invoke.js +1 -1
  192. package/src/common/util/obfuscate.js +3 -5
  193. package/src/common/util/submit-data.test.js +1 -1
  194. package/src/common/util/traverse.js +1 -0
  195. package/src/common/window/__mocks__/nreum.js +3 -1
  196. package/src/common/window/page-visibility.js +1 -2
  197. package/src/common/wrap/wrap-jsonp.js +1 -1
  198. package/src/features/ajax/aggregate/index.js +5 -7
  199. package/src/features/ajax/instrument/distributed-tracing.js +8 -8
  200. package/src/features/ajax/instrument/index.js +40 -17
  201. package/src/features/jserrors/aggregate/canonical-function-name.js +0 -2
  202. package/src/features/jserrors/aggregate/compute-stack-trace.js +4 -4
  203. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
  204. package/src/features/jserrors/aggregate/index.js +4 -5
  205. package/src/features/metrics/aggregate/framework-detection.js +129 -8
  206. package/src/features/metrics/aggregate/framework-detection.test.js +213 -82
  207. package/src/features/metrics/aggregate/index.js +22 -45
  208. package/src/features/metrics/instrument/index.js +1 -3
  209. package/src/features/page_action/aggregate/index.js +12 -13
  210. package/src/features/page_view_event/aggregate/index.js +1 -2
  211. package/src/features/page_view_event/instrument/index.js +2 -2
  212. package/src/features/page_view_timing/aggregate/index.js +7 -8
  213. package/src/features/session_replay/aggregate/index.component-test.js +3 -15
  214. package/src/features/session_replay/aggregate/index.js +2 -2
  215. package/src/features/session_trace/aggregate/index.js +6 -9
  216. package/src/features/spa/aggregate/index.js +14 -20
  217. package/src/features/spa/aggregate/interaction.js +0 -2
  218. package/src/features/spa/aggregate/serializer.js +1 -1
  219. package/src/features/utils/aggregate-base.js +5 -0
  220. package/src/features/utils/aggregate-base.test.js +2 -1
  221. package/src/features/utils/handler-cache.js +3 -2
  222. package/src/features/utils/instrument-base.js +25 -6
  223. package/src/features/utils/instrument-base.test.js +2 -2
  224. package/src/loaders/agent-base.js +11 -0
  225. package/src/loaders/agent.js +7 -7
  226. package/src/loaders/api/api.js +21 -4
  227. package/src/loaders/api/api.test.js +85 -0
  228. package/src/loaders/api/apiAsync.js +19 -20
  229. package/src/loaders/api/apiAsync.test.js +17 -0
  230. package/src/loaders/configure/configure.js +3 -0
  231. package/src/loaders/features/enabled-features.js +1 -1
  232. package/src/loaders/micro-agent.js +22 -4
  233. package/dist/cjs/features/metrics/aggregate/endpoint-map.js +0 -14
  234. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +0 -14
  235. package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +0 -53
  236. package/dist/esm/features/metrics/aggregate/endpoint-map.js +0 -7
  237. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
  238. package/dist/esm/features/metrics/aggregate/polyfill-detection.js +0 -47
  239. package/dist/types/features/metrics/aggregate/endpoint-map.d.ts +0 -8
  240. package/dist/types/features/metrics/aggregate/endpoint-map.d.ts.map +0 -1
  241. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +0 -6
  242. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +0 -1
  243. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +0 -7
  244. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +0 -1
  245. package/src/features/metrics/aggregate/endpoint-map.js +0 -7
  246. package/src/features/metrics/aggregate/polyfill-detection.es5.js +0 -8
  247. package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -16
  248. package/src/features/metrics/aggregate/polyfill-detection.js +0 -48
  249. package/src/features/metrics/aggregate/polyfill-detection.test.js +0 -163
@@ -17,8 +17,6 @@ const model = () => {
17
17
  }
18
18
  };
19
19
  return {
20
- allow_bfcache: true,
21
- // *cli - temporary feature flag for BFCache work
22
20
  privacy: {
23
21
  cookies_enabled: true
24
22
  },
@@ -27,7 +25,8 @@ const model = () => {
27
25
  deny_list: undefined,
28
26
  block_internal: true,
29
27
  enabled: true,
30
- harvestTimeSeconds: 10
28
+ harvestTimeSeconds: 10,
29
+ autoStart: true
31
30
  },
32
31
  distributed_tracing: {
33
32
  enabled: undefined,
@@ -46,32 +45,39 @@ const model = () => {
46
45
  obfuscate: undefined,
47
46
  jserrors: {
48
47
  enabled: true,
49
- harvestTimeSeconds: 10
48
+ harvestTimeSeconds: 10,
49
+ autoStart: true
50
50
  },
51
51
  metrics: {
52
- enabled: true
52
+ enabled: true,
53
+ autoStart: true
53
54
  },
54
55
  page_action: {
55
56
  enabled: true,
56
- harvestTimeSeconds: 30
57
+ harvestTimeSeconds: 30,
58
+ autoStart: true
57
59
  },
58
60
  page_view_event: {
59
- enabled: true
61
+ enabled: true,
62
+ autoStart: true
60
63
  },
61
64
  page_view_timing: {
62
65
  enabled: true,
63
66
  harvestTimeSeconds: 30,
64
- long_task: false
67
+ long_task: false,
68
+ autoStart: true
65
69
  },
66
70
  session_trace: {
67
71
  enabled: true,
68
- harvestTimeSeconds: 10
72
+ harvestTimeSeconds: 10,
73
+ autoStart: true
69
74
  },
70
75
  harvest: {
71
76
  tooManyRequestsDelay: 60
72
77
  },
73
78
  session_replay: {
74
79
  // feature settings
80
+ autoStart: true,
75
81
  enabled: false,
76
82
  harvestTimeSeconds: 60,
77
83
  sampleRate: 0.1,
@@ -110,23 +116,25 @@ const model = () => {
110
116
  },
111
117
  spa: {
112
118
  enabled: true,
113
- harvestTimeSeconds: 10
119
+ harvestTimeSeconds: 10,
120
+ autoStart: true
114
121
  }
115
122
  };
116
123
  };
117
124
  const _cache = {};
125
+ const missingAgentIdError = 'All configuration objects require an agent identifier!';
118
126
  function getConfiguration(id) {
119
- if (!id) throw new Error('All configuration objects require an agent identifier!');
127
+ if (!id) throw new Error(missingAgentIdError);
120
128
  if (!_cache[id]) throw new Error("Configuration for ".concat(id, " was never set"));
121
129
  return _cache[id];
122
130
  }
123
131
  function setConfiguration(id, obj) {
124
- if (!id) throw new Error('All configuration objects require an agent identifier!');
132
+ if (!id) throw new Error(missingAgentIdError);
125
133
  _cache[id] = (0, _configurable.getModeledObject)(obj, model());
126
134
  (0, _nreum.gosNREUMInitializedAgents)(id, _cache[id], 'config');
127
135
  }
128
136
  function getConfigurationValue(id, path) {
129
- if (!id) throw new Error('All configuration objects require an agent identifier!');
137
+ if (!id) throw new Error(missingAgentIdError);
130
138
  var val = getConfiguration(id);
131
139
  if (val) {
132
140
  var parts = path.split('.');
@@ -11,10 +11,6 @@ var _runtime = require("../../constants/runtime");
11
11
  var _env = require("../../constants/env.npm");
12
12
  const model = {
13
13
  buildEnv: _env.BUILD_ENV,
14
- bytesSent: {},
15
- // Used for SM to capture body bytes sent per endpoint
16
- queryBytesSent: {},
17
- // Used for SM to capture query parameter bytes sent per endpoint
18
14
  customTransaction: undefined,
19
15
  disabled: false,
20
16
  distMethod: _env.DIST_METHOD,
@@ -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.238.0";
15
+ const VERSION = "1.239.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.238.0";
15
+ const VERSION = "1.239.0";
16
16
 
17
17
  /**
18
18
  * Exposes the build type of the agent
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.supportsSendBeacon = exports.isiOS = exports.isWorkerScope = exports.isIE = exports.isBrowserScope = exports.initialLocation = exports.iOS_below16 = exports.globalScope = exports.ffVersion = void 0;
6
+ exports.supportsSendBeacon = exports.isiOS = exports.isWorkerScope = exports.isIE = exports.isBrowserScope = exports.initialLocation = exports.iOSBelow16 = exports.globalScope = exports.ffVersion = void 0;
7
7
  /**
8
8
  * @file Contains constants about the environment the agent is running
9
9
  * within. These values are derived at the time the agent is first loaded.
@@ -36,8 +36,8 @@ const isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
36
36
  * This was fixed in v16+.
37
37
  */
38
38
  exports.isiOS = isiOS;
39
- const iOS_below16 = isiOS && typeof SharedWorker === 'undefined';
40
- exports.iOS_below16 = iOS_below16;
39
+ const iOSBelow16 = isiOS && typeof SharedWorker === 'undefined';
40
+ exports.iOSBelow16 = iOSBelow16;
41
41
  const ffVersion = (() => {
42
42
  const match = navigator.userAgent.match(/Firefox[/\s](\d+\.\d+)/);
43
43
  if (Array.isArray(match) && match.length >= 2) {
@@ -11,7 +11,9 @@ exports.sharedChannel = void 0;
11
11
  */
12
12
 
13
13
  let onReplayReady;
14
- const sessionReplayInitialized = new Promise(resolve => onReplayReady = resolve);
14
+ const sessionReplayInitialized = new Promise(resolve => {
15
+ onReplayReady = resolve;
16
+ });
15
17
  const sharedChannel = Object.freeze({
16
18
  onReplayReady,
17
19
  sessionReplayInitialized
@@ -81,10 +81,7 @@ function domainMatchesPattern(pattern, domain) {
81
81
  if (pattern.length > domain.length) {
82
82
  return false;
83
83
  }
84
- if (domain.indexOf(pattern) === domain.length - pattern.length) {
85
- return true;
86
- }
87
- return false;
84
+ return domain.indexOf(pattern) === domain.length - pattern.length;
88
85
  }
89
86
 
90
87
  /**
@@ -105,8 +102,5 @@ function comparePath(pattern, path) {
105
102
  if (pattern === '') {
106
103
  return true;
107
104
  }
108
- if (pattern === path) {
109
- return true;
110
- }
111
- return false;
105
+ return pattern === path;
112
106
  }
@@ -55,7 +55,6 @@ function drain() {
55
55
  let agentIdentifier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
56
56
  let featureName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'feature';
57
57
  curateRegistry(agentIdentifier);
58
-
59
58
  // If the feature for the specified agent is not in the registry, that means the instrument file was bypassed.
60
59
  // This could happen in tests, or loaders that directly import the aggregator. In these cases it is safe to
61
60
  // drain the feature group immediately rather than waiting to drain all at once.
@@ -74,6 +73,7 @@ function drain() {
74
73
  items.sort((a, b) => a[1].priority - b[1].priority);
75
74
  items.forEach(_ref2 => {
76
75
  let [group] = _ref2;
76
+ registry[agentIdentifier].delete(group);
77
77
  drainGroup(group);
78
78
  });
79
79
  }
@@ -44,16 +44,16 @@ function ee(old, debugId) {
44
44
  }
45
45
  var emitter = {
46
46
  on: addEventListener,
47
- addEventListener: addEventListener,
48
- removeEventListener: removeEventListener,
49
- emit: emit,
47
+ addEventListener,
48
+ removeEventListener,
49
+ emit,
50
50
  get: getOrCreate,
51
- listeners: listeners,
52
- context: context,
51
+ listeners,
52
+ context,
53
53
  buffer: bufferEventsByGroup,
54
54
  abort,
55
55
  aborted: false,
56
- isBuffering: isBuffering,
56
+ isBuffering,
57
57
  debugId,
58
58
  backlog: isolatedBacklog ? {} : old && typeof old.backlog === 'object' ? old.backlog : {}
59
59
  };
@@ -8,7 +8,6 @@ var submitData = _interopRequireWildcard(require("../util/submit-data"));
8
8
  var _sharedContext = require("../context/shared-context");
9
9
  var _harvest = require("./harvest");
10
10
  var _eol = require("../unload/eol");
11
- var _config = require("../config/config");
12
11
  var _sessionEntity = require("../session/session-entity");
13
12
  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
13
  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; }
@@ -43,7 +42,7 @@ class HarvestScheduler extends _sharedContext.SharedContext {
43
42
  this.harvest = new _harvest.Harvest(this.sharedContext);
44
43
 
45
44
  // unload if EOL mechanism fires
46
- (0, _eol.subscribeToEOL)(this.unload.bind(this), (0, _config.getConfigurationValue)(this.sharedContext.agentIdentifier, 'allow_bfcache')); // TO DO: remove feature flag after rls stable
45
+ (0, _eol.subscribeToEOL)(this.unload.bind(this));
47
46
 
48
47
  /* Flush all buffered data if session resets and give up retries. This should be synchronous to ensure that the correct `session` value is sent.
49
48
  Since session-reset generates a new session ID and the ID is grabbed at send-time, any delays or retries would cause the payload to be sent under
@@ -110,7 +109,7 @@ class HarvestScheduler extends _sharedContext.SharedContext {
110
109
  if (!submitMethod) return false;
111
110
  const retry = !opts?.unload && submitMethod === submitData.xhr;
112
111
  payload = this.opts.getPayload({
113
- retry: retry
112
+ retry
114
113
  });
115
114
  if (!payload) {
116
115
  if (this.started) {
@@ -146,7 +145,6 @@ class HarvestScheduler extends _sharedContext.SharedContext {
146
145
  if (this.started) {
147
146
  this.scheduleHarvest();
148
147
  }
149
- return;
150
148
  }
151
149
  onHarvestFinished(opts, result) {
152
150
  if (this.opts.onFinished) {
@@ -131,7 +131,8 @@ class Harvest extends _sharedContext.SharedContext {
131
131
  }
132
132
  return false;
133
133
  }
134
- let url = "".concat(this.getScheme(), "://").concat(info.errorBeacon).concat(endpoint !== 'rum' ? "/".concat(endpoint) : '', "/1/").concat(info.licenseKey);
134
+ const endpointURLPart = endpoint !== 'rum' ? "/".concat(endpoint) : '';
135
+ let url = "".concat(this.getScheme(), "://").concat(info.errorBeacon).concat(endpointURLPart, "/1/").concat(info.licenseKey);
135
136
  if (customUrl) url = customUrl;
136
137
  if (raw) url = "".concat(this.getScheme(), "://").concat(info.errorBeacon, "/").concat(endpoint);
137
138
  const baseParams = !raw && includeBaseParams ? this.baseQueryString() : '';
@@ -159,11 +160,6 @@ class Harvest extends _sharedContext.SharedContext {
159
160
  // If body is null, undefined, or an empty object or array, send an empty string instead
160
161
  body = '';
161
162
  }
162
-
163
- // Get bytes harvested per endpoint as a supportability metric. See metrics aggregator (on unload).
164
- agentRuntime.bytesSent[endpoint] = (agentRuntime.bytesSent[endpoint] || 0) + body?.length || 0;
165
- // Get query bytes harvested per endpoint as a supportability metric. See metrics aggregator (on unload).
166
- agentRuntime.queryBytesSent[endpoint] = (agentRuntime.queryBytesSent[endpoint] || 0) + fullUrl.split('?').slice(-1)[0]?.length || 0;
167
163
  const headers = [];
168
164
  headers.push({
169
165
  key: 'content-type',
@@ -34,7 +34,7 @@ function getAddStringContext(agentIdentifier) {
34
34
  function addString(str) {
35
35
  if (typeof str === 'undefined' || str === '') return '';
36
36
  var obfuscator = new _obfuscate.Obfuscator({
37
- agentIdentifier: agentIdentifier
37
+ agentIdentifier
38
38
  });
39
39
  str = String(str);
40
40
  if (obfuscator.shouldObfuscate()) str = obfuscator.obfuscateString(str);
@@ -48,33 +48,37 @@ class SessionEntity {
48
48
  * expiresMs and inactiveMs are used to "expire" the session, but can be overridden in the constructor. Pass 0 to disable expiration timers.
49
49
  */
50
50
  constructor(opts) {
51
- this.setup(opts);
52
- }
53
- setup(_ref) {
54
- let {
51
+ const {
55
52
  agentIdentifier,
56
53
  key,
57
- storage,
58
- value = (0, _uniqueId.generateRandomHexString)(16),
59
- expiresMs = _constants.DEFAULT_EXPIRES_MS,
60
- inactiveMs = _constants.DEFAULT_INACTIVE_MS
61
- } = _ref;
54
+ storage
55
+ } = opts;
62
56
  if (!agentIdentifier || !key || !storage) {
63
57
  throw new Error("Missing required field(s):".concat(!agentIdentifier ? ' agentID' : '').concat(!key ? ' key' : '').concat(!storage ? ' storage' : ''));
64
58
  }
65
59
  this.agentIdentifier = agentIdentifier;
66
60
  this.storage = storage;
67
61
  this.state = {};
68
- this.sync(model);
69
62
 
70
63
  // key is intended to act as the k=v pair
71
64
  this.key = key;
65
+ this.ee = _contextualEe.ee.get(agentIdentifier);
66
+ (0, _wrap.wrapEvents)(this.ee);
67
+ this.setup(opts);
68
+ }
69
+ setup(_ref) {
70
+ let {
71
+ value = (0, _uniqueId.generateRandomHexString)(16),
72
+ expiresMs = _constants.DEFAULT_EXPIRES_MS,
73
+ inactiveMs = _constants.DEFAULT_INACTIVE_MS
74
+ } = _ref;
75
+ this.state = {};
76
+ this.sync(model);
77
+
72
78
  // value is intended to act as the primary value of the k=v pair
73
79
  this.state.value = value;
74
80
  this.expiresMs = expiresMs;
75
81
  this.inactiveMs = inactiveMs;
76
- this.ee = _contextualEe.ee.get(agentIdentifier);
77
- (0, _wrap.wrapEvents)(this.ee);
78
82
 
79
83
  // the first time the session entity class is instantiated, we check the storage API for an existing
80
84
  // object. If it exists, the values inside the object are used to inform the timers that run locally.
@@ -13,22 +13,23 @@ class FirstPartyCookies {
13
13
  var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
14
14
  if (match) return match[2];
15
15
  } catch (err) {
16
+ // Error is ignored
16
17
  return '';
17
18
  }
18
19
  }
19
20
  set(key, value) {
20
21
  try {
21
- const cookie = "".concat(key, "=").concat(value, "; Domain=").concat(domain, "; Path=/");
22
+ const cookie = "".concat(key, "=").concat(value, "; Domain=").concat(this.domain, "; Path=/");
22
23
  document.cookie = cookie;
23
24
  } catch (err) {
24
- return;
25
+ // Error is ignored
25
26
  }
26
27
  }
27
28
  remove(key) {
28
29
  try {
29
- return document.cookie = "".concat(key, "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; Domain=").concat(domain, "; Path=/");
30
+ document.cookie = "".concat(key, "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; Domain=").concat(this.domain, "; Path=/");
30
31
  } catch (err) {
31
- return;
32
+ // Error is ignored
32
33
  }
33
34
  }
34
35
  }
@@ -11,6 +11,7 @@ class LocalStorage {
11
11
  // Cast it back to undefined if it doesnt exist
12
12
  return localStorage.getItem(key) || undefined;
13
13
  } catch (err) {
14
+ // Error is ignored
14
15
  return '';
15
16
  }
16
17
  }
@@ -19,14 +20,14 @@ class LocalStorage {
19
20
  if (value === undefined || value === null) return this.remove(key);
20
21
  return localStorage.setItem(key, value);
21
22
  } catch (err) {
22
- return;
23
+ // Error is ignored
23
24
  }
24
25
  }
25
26
  remove(key) {
26
27
  try {
27
28
  localStorage.removeItem(key);
28
29
  } catch (err) {
29
- return;
30
+ // Error is ignored
30
31
  }
31
32
  }
32
33
  }
@@ -27,14 +27,16 @@ class InteractionTimer extends _timer.Timer {
27
27
  }
28
28
  if (_runtime.isBrowserScope && opts.ee) {
29
29
  if (opts.ee) {
30
+ this.ee = opts.ee;
30
31
  const debouncedRefresh = (0, _invoke.debounce)(this.refresh.bind(this), 500, {
31
32
  leading: true
32
33
  });
33
- opts.ee.on('fn-end', evts => {
34
+ this.refreshHandler = evts => {
34
35
  if (opts.refreshEvents.includes(evts?.[0]?.type)) {
35
36
  debouncedRefresh();
36
37
  }
37
- });
38
+ };
39
+ opts.ee.on('fn-end', this.refreshHandler);
38
40
  }
39
41
 
40
42
  // watch for the vis state changing. If the page is hidden, the local inactivity timer should be paused
@@ -48,22 +50,28 @@ class InteractionTimer extends _timer.Timer {
48
50
  (0, _pageVisibility.subscribeToVisibilityChange)(state => {
49
51
  if (state === 'hidden') this.pause();
50
52
  // vis change --> visible is treated like a new interaction with the page
51
- else {
52
- this.refresh();
53
- this.onResume(); // emit resume event after state updated
54
- }
53
+ else this.resume();
55
54
  }, false, false, this.abortController?.signal);
56
55
  }
57
56
  }
58
57
  abort() {
59
58
  this.clear();
60
59
  this.abortController?.abort();
60
+ if (this.refreshHandler) {
61
+ this.ee.removeEventListener('fn-end', this.refreshHandler);
62
+ this.refreshHandler = this.ee = null;
63
+ }
61
64
  }
62
65
  pause() {
63
66
  this.onPause();
64
67
  clearTimeout(this.timer);
65
68
  this.remainingMs = this.initialMs - (Date.now() - this.startTimestamp);
66
69
  }
70
+ resume() {
71
+ this.refresh();
72
+ this.onResume(); // emit resume event after state updated
73
+ }
74
+
67
75
  refresh(cb, ms) {
68
76
  this.clear();
69
77
  this.timer = this.create(cb, ms);
@@ -35,7 +35,7 @@ var DOM_CONTENT_LOAD_EVENT = 'domContentLoadedEvent';
35
35
  var navTimingValues = [];
36
36
  exports.navTimingValues = navTimingValues;
37
37
  function getPntType(type) {
38
- if (typeof type == 'number') return type;
38
+ if (typeof type === 'number') return type;
39
39
  const types = {
40
40
  navigate: undefined,
41
41
  reload: 1,
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.subscribeToEOL = subscribeToEOL;
7
7
  var _eventListenerOpts = require("../event-listener/event-listener-opts");
8
- var _invoke = require("../util/invoke");
9
8
  var _runtime = require("../constants/runtime");
10
9
  var _pageVisibility = require("../window/page-visibility");
11
10
  /*
@@ -30,37 +29,12 @@ if (_runtime.isWorkerScope) {
30
29
  * Subscribes a provided callback to the time/event when the agent should treat it as end-of-life.
31
30
  * This is used, for example, to submit a final harvest and send all remaining data on best-effort.
32
31
  * @param {function} cb - func to run before or during the last reliable event or time of an env's life span
33
- * @param {boolean} allowBFCache - (temp) feature flag to gate new v1222 BFC support
34
32
  */
35
- function subscribeToEOL(cb, allowBFCache) {
33
+ function subscribeToEOL(cb) {
36
34
  if (_runtime.isBrowserScope) {
37
- if (allowBFCache) {
38
- (0, _pageVisibility.subscribeToVisibilityChange)(cb, true); // when user switches tab or hides window, esp. mobile scenario
39
- (0, _eventListenerOpts.windowAddEventListener)('pagehide', cb); // when user navigates away, and because safari iOS v14.4- doesn't fully support vis change
40
- // --this ought to be removed once support for version below 14.5 phases out
41
- } else {
42
- var oneCall = (0, _invoke.single)(cb);
43
-
44
- // Firefox has a bug wherein a slow-loading resource loaded from the 'pagehide'
45
- // or 'unload' event will delay the 'load' event firing on the next page load.
46
- // In Firefox versions that support sendBeacon, this doesn't matter, because
47
- // we'll use it instead of an image load for our final harvest.
48
- //
49
- // Some Safari versions never fire the 'unload' event for pages that are being
50
- // put into the WebKit page cache, so we *need* to use the pagehide event for
51
- // the final submission from Safari.
52
- //
53
- // Generally speaking, we will try to submit our final harvest from either
54
- // pagehide or unload, whichever comes first, but in Firefox, we need to avoid
55
- // attempting to submit from pagehide to ensure that we don't slow down loading
56
- // of the next page.
57
- if (!_runtime.ffVersion || navigator.sendBeacon) {
58
- (0, _eventListenerOpts.windowAddEventListener)('pagehide', oneCall);
59
- } else {
60
- (0, _eventListenerOpts.windowAddEventListener)('beforeunload', oneCall);
61
- }
62
- (0, _eventListenerOpts.windowAddEventListener)('unload', oneCall);
63
- }
35
+ (0, _pageVisibility.subscribeToVisibilityChange)(cb, true); // when user switches tab or hides window, esp. mobile scenario
36
+ (0, _eventListenerOpts.windowAddEventListener)('pagehide', cb); // when user navigates away, and because safari iOS v14.4- doesn't fully support vis change
37
+ // --this ought to be removed once support for version below 14.5 phases out
64
38
  } else if (_runtime.isWorkerScope) {
65
39
  _runtime.globalScope.cleanupTasks.push(cb); // close() should run these tasks before quitting thread
66
40
  }
@@ -7,7 +7,6 @@ exports.activateFeatures = activateFeatures;
7
7
  exports.activatedFeatures = void 0;
8
8
  var _contextualEe = require("../event-emitter/contextual-ee");
9
9
  var _handle = require("../event-emitter/handle");
10
- var _drain = require("../drain/drain");
11
10
  var _features = require("../../loaders/features/features");
12
11
  /*
13
12
  * Copyright 2020 New Relic Corporation. All rights reserved.
@@ -21,24 +20,24 @@ const bucketMap = {
21
20
  spa: [_features.FEATURE_NAMES.spa],
22
21
  sr: [_features.FEATURE_NAMES.sessionReplay, _features.FEATURE_NAMES.sessionTrace]
23
22
  };
23
+ const sentIds = new Set();
24
24
 
25
25
  /** Note that this function only processes each unique flag ONCE, with the first occurrence of each flag and numeric value determining its switch on/off setting. */
26
26
  function activateFeatures(flags, agentIdentifier) {
27
27
  const sharedEE = _contextualEe.ee.get(agentIdentifier);
28
28
  if (!(flags && typeof flags === 'object')) return;
29
- Object.entries(flags).forEach(_ref => {
30
- let [flag, num] = _ref;
31
- if (activatedFeatures[flag] !== undefined) return;
32
- if (bucketMap[flag]) {
33
- bucketMap[flag].forEach(feat => {
34
- if (!num) (0, _handle.handle)('block-' + flag, [], undefined, feat, sharedEE);else (0, _handle.handle)('feat-' + flag, [], undefined, feat, sharedEE);
35
- (0, _handle.handle)('rumresp-' + flag, [Boolean(num)], undefined, feat, sharedEE); // this is a duplicate of feat-/block- but makes awaiting for 1 event easier than 2
36
- });
37
- } else if (num) (0, _handle.handle)('feat-' + flag, [], undefined, undefined, sharedEE); // not sure what other flags are overlooked, but there's a test for ones not in the map --
38
- // ^^^ THIS DOESN'T ACTUALLY DO ANYTHHING AS UNDEFINED/FEATURE GROUP ISN'T DRAINED
39
-
40
- activatedFeatures[flag] = Boolean(num);
41
- });
29
+ if (!sentIds.has(agentIdentifier)) {
30
+ Object.entries(flags).forEach(_ref => {
31
+ let [flag, num] = _ref;
32
+ if (bucketMap[flag]) {
33
+ bucketMap[flag].forEach(feat => {
34
+ if (!num) (0, _handle.handle)('block-' + flag, [], undefined, feat, sharedEE);else (0, _handle.handle)('feat-' + flag, [], undefined, feat, sharedEE);
35
+ (0, _handle.handle)('rumresp-' + flag, [Boolean(num)], undefined, feat, sharedEE); // this is a duplicate of feat-/block- but makes awaiting for 1 event easier than 2
36
+ });
37
+ } else if (num) (0, _handle.handle)('feat-' + flag, [], undefined, undefined, sharedEE); // not sure what other flags are overlooked, but there's a test for ones not in the map --
38
+ activatedFeatures[flag] = Boolean(num);
39
+ });
40
+ }
42
41
 
43
42
  // Let the features waiting on their respective flags know that RUM response was received and that any missing flags are interpreted as bad entitlement / "off".
44
43
  // Hence, those features will not be hanging forever if their flags aren't included in the response.
@@ -48,7 +47,7 @@ function activateFeatures(flags, agentIdentifier) {
48
47
  activatedFeatures[flag] = false;
49
48
  }
50
49
  });
51
- (0, _drain.drain)(agentIdentifier, _features.FEATURE_NAMES.pageViewEvent);
50
+ sentIds.add(agentIdentifier);
52
51
  }
53
52
  const activatedFeatures = {};
54
53
  exports.activatedFeatures = activatedFeatures;
@@ -39,7 +39,9 @@ function debounce(func) {
39
39
  }
40
40
  if (leading && timer === undefined) {
41
41
  func.apply(_this, args);
42
- timer = setTimeout(() => timer = clearTimeout(timer), timeout);
42
+ timer = setTimeout(() => {
43
+ timer = clearTimeout(timer);
44
+ }, timeout);
43
45
  }
44
46
  if (!leading) {
45
47
  clearTimeout(timer);
@@ -61,11 +61,9 @@ function validateRules(rules) {
61
61
  invalidRegexDetected = true;
62
62
  }
63
63
  var replacement = rules[i].replacement;
64
- if (replacement) {
65
- if (typeof replacement !== 'string') {
66
- (0, _console.warn)('An obfuscation replacement rule contains a "replacement" value with an invalid type (must be a string)');
67
- invalidReplacementDetected = true;
68
- }
64
+ if (replacement && typeof replacement !== 'string') {
65
+ (0, _console.warn)('An obfuscation replacement rule contains a "replacement" value with an invalid type (must be a string)');
66
+ invalidReplacementDetected = true;
69
67
  }
70
68
  }
71
69
  return !invalidReplacementDetected && !invalidRegexDetected;
@@ -26,6 +26,7 @@ function applyFnToProps(obj, fn) {
26
26
  if (typeof obj[property] === 'object') {
27
27
  applyFnToProps(obj[property], fn, type, ignoreKeys);
28
28
  } else {
29
+ // eslint-disable-next-line valid-typeof
29
30
  if (typeof obj[property] === type && !ignoreKeys.includes(property)) obj[property] = fn(obj[property]);
30
31
  }
31
32
  });
@@ -20,11 +20,10 @@ function subscribeToVisibilityChange(cb) {
20
20
  let capture = arguments.length > 2 ? arguments[2] : undefined;
21
21
  let abortSignal = arguments.length > 3 ? arguments[3] : undefined;
22
22
  (0, _eventListenerOpts.documentAddEventListener)('visibilitychange', handleVisibilityChange, capture, abortSignal);
23
- return;
24
23
  function handleVisibilityChange() {
25
24
  if (toHiddenOnly) {
26
25
  // trigger cb on change to hidden state only
27
- if (document.visibilityState == 'hidden') cb();
26
+ if (document.visibilityState === 'hidden') cb();
28
27
  return;
29
28
  }
30
29
  cb(document.visibilityState);
@@ -117,7 +117,7 @@ function wrapJsonP(sharedEE) {
117
117
  };
118
118
  }
119
119
  return {
120
- key: key,
120
+ key,
121
121
  parent: window
122
122
  };
123
123
  }