@newrelic/browser-agent 0.1.231 → 1.232.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 (256) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/common/config/state/configurable.js +27 -21
  3. package/dist/cjs/common/config/state/init.js +8 -0
  4. package/dist/cjs/common/config/state/runtime.js +24 -26
  5. package/dist/cjs/common/constants/env.cdn.js +1 -1
  6. package/dist/cjs/common/constants/env.npm.js +1 -1
  7. package/dist/cjs/common/context/shared-context.js +2 -1
  8. package/dist/cjs/common/event-emitter/contextual-ee.test.js +2 -2
  9. package/dist/cjs/common/event-emitter/register-handler.test.js +1 -1
  10. package/dist/cjs/common/event-listener/event-listener-opts.js +4 -2
  11. package/dist/cjs/common/harvest/harvest-scheduler.js +14 -11
  12. package/dist/cjs/common/harvest/harvest.js +3 -1
  13. package/dist/cjs/common/session/constants.js +12 -0
  14. package/dist/cjs/common/session/session-entity.js +278 -0
  15. package/dist/cjs/common/session/session-entity.test.js +436 -0
  16. package/dist/cjs/common/storage/first-party-cookies.js +35 -0
  17. package/dist/cjs/common/storage/local-memory.js +35 -0
  18. package/dist/cjs/common/storage/local-memory.test.js +20 -0
  19. package/dist/cjs/common/storage/local-storage.js +33 -0
  20. package/dist/cjs/common/storage/local-storage.test.js +14 -0
  21. package/dist/cjs/common/timer/interaction-timer.js +78 -0
  22. package/dist/cjs/common/timer/interaction-timer.test.js +216 -0
  23. package/dist/cjs/common/timer/timer.js +32 -0
  24. package/dist/cjs/common/timer/timer.test.js +105 -0
  25. package/dist/cjs/common/unload/eol.js +2 -2
  26. package/dist/cjs/common/url/canonicalize-url.js +32 -0
  27. package/dist/cjs/common/url/canonicalize-url.test.js +42 -0
  28. package/dist/cjs/common/url/clean-url.js +10 -3
  29. package/dist/cjs/common/util/data-size.js +6 -0
  30. package/dist/cjs/common/util/data-size.test.js +47 -0
  31. package/dist/cjs/common/util/global-scope.js +4 -2
  32. package/dist/cjs/common/util/invoke.js +73 -0
  33. package/dist/cjs/common/util/invoke.test.js +49 -0
  34. package/dist/cjs/common/util/obfuscate.js +0 -4
  35. package/dist/cjs/common/window/page-visibility.js +3 -1
  36. package/dist/cjs/common/wrap/wrap-fetch.js +1 -3
  37. package/dist/cjs/common/wrap/wrap-function.js +1 -3
  38. package/dist/cjs/common/wrap/wrap-timer.js +1 -1
  39. package/dist/cjs/features/ajax/aggregate/index.js +2 -2
  40. package/dist/cjs/features/ajax/instrument/index.js +1 -1
  41. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +12 -4
  42. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +93 -10
  43. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +164 -38
  44. package/dist/cjs/features/jserrors/aggregate/index.js +25 -46
  45. package/dist/cjs/features/jserrors/instrument/index.js +0 -2
  46. package/dist/cjs/features/metrics/aggregate/index.js +13 -2
  47. package/dist/cjs/features/page_action/aggregate/index.js +2 -2
  48. package/dist/cjs/features/page_view_event/aggregate/index.js +6 -3
  49. package/dist/cjs/features/page_view_timing/aggregate/index.js +6 -6
  50. package/dist/cjs/features/session_trace/aggregate/index.js +3 -5
  51. package/dist/cjs/features/spa/aggregate/index.js +6 -5
  52. package/dist/cjs/features/utils/agent-session.js +73 -0
  53. package/dist/cjs/features/utils/feature-base.js +1 -1
  54. package/dist/cjs/features/utils/instrument-base.js +7 -2
  55. package/dist/cjs/features/utils/lazy-loader.js +1 -1
  56. package/dist/cjs/loaders/agent.js +1 -1
  57. package/dist/cjs/loaders/api/api.js +1 -4
  58. package/dist/cjs/loaders/api/apiAsync.js +3 -2
  59. package/dist/cjs/loaders/configure/configure.js +0 -6
  60. package/dist/esm/common/config/state/configurable.js +26 -20
  61. package/dist/esm/common/config/state/init.js +8 -0
  62. package/dist/esm/common/config/state/runtime.js +24 -26
  63. package/dist/esm/common/constants/env.cdn.js +1 -1
  64. package/dist/esm/common/constants/env.npm.js +1 -1
  65. package/dist/esm/common/context/shared-context.js +2 -1
  66. package/dist/esm/common/event-emitter/contextual-ee.test.js +2 -2
  67. package/dist/esm/common/event-emitter/register-handler.test.js +1 -1
  68. package/dist/esm/common/event-listener/event-listener-opts.js +4 -2
  69. package/dist/esm/common/harvest/harvest-scheduler.js +14 -11
  70. package/dist/esm/common/harvest/harvest.js +3 -1
  71. package/dist/esm/common/session/constants.js +3 -0
  72. package/dist/esm/common/session/session-entity.js +271 -0
  73. package/dist/esm/common/session/session-entity.test.js +434 -0
  74. package/dist/esm/common/storage/first-party-cookies.js +28 -0
  75. package/dist/esm/common/storage/local-memory.js +28 -0
  76. package/dist/esm/common/storage/local-memory.test.js +18 -0
  77. package/dist/esm/common/storage/local-storage.js +26 -0
  78. package/dist/esm/common/storage/local-storage.test.js +12 -0
  79. package/dist/esm/common/timer/interaction-timer.js +71 -0
  80. package/dist/esm/common/timer/interaction-timer.test.js +214 -0
  81. package/dist/esm/common/timer/timer.js +25 -0
  82. package/dist/esm/common/timer/timer.test.js +103 -0
  83. package/dist/esm/common/unload/eol.js +1 -1
  84. package/dist/esm/common/url/canonicalize-url.js +27 -0
  85. package/dist/esm/common/url/canonicalize-url.test.js +38 -0
  86. package/dist/esm/common/url/clean-url.js +10 -3
  87. package/dist/esm/common/util/data-size.js +7 -0
  88. package/dist/esm/common/util/data-size.test.js +45 -0
  89. package/dist/esm/common/util/global-scope.js +1 -0
  90. package/dist/esm/common/util/invoke.js +66 -0
  91. package/dist/esm/common/util/invoke.test.js +47 -0
  92. package/dist/esm/common/util/obfuscate.js +0 -4
  93. package/dist/esm/common/window/page-visibility.js +3 -1
  94. package/dist/esm/common/wrap/wrap-fetch.js +1 -2
  95. package/dist/esm/common/wrap/wrap-function.js +1 -2
  96. package/dist/esm/common/wrap/wrap-timer.js +1 -1
  97. package/dist/esm/features/ajax/aggregate/index.js +2 -2
  98. package/dist/esm/features/ajax/instrument/index.js +1 -1
  99. package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +12 -4
  100. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +93 -10
  101. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +149 -25
  102. package/dist/esm/features/jserrors/aggregate/index.js +26 -46
  103. package/dist/esm/features/jserrors/instrument/index.js +0 -1
  104. package/dist/esm/features/metrics/aggregate/index.js +14 -3
  105. package/dist/esm/features/page_action/aggregate/index.js +2 -2
  106. package/dist/esm/features/page_view_event/aggregate/index.js +6 -3
  107. package/dist/esm/features/page_view_timing/aggregate/index.js +6 -6
  108. package/dist/esm/features/session_trace/aggregate/index.js +3 -4
  109. package/dist/esm/features/spa/aggregate/index.js +6 -5
  110. package/dist/esm/features/utils/agent-session.js +67 -0
  111. package/dist/esm/features/utils/feature-base.js +1 -1
  112. package/dist/esm/features/utils/instrument-base.js +7 -2
  113. package/dist/esm/features/utils/lazy-loader.js +1 -1
  114. package/dist/esm/loaders/agent.js +1 -1
  115. package/dist/esm/loaders/api/api.js +2 -5
  116. package/dist/esm/loaders/api/apiAsync.js +2 -1
  117. package/dist/esm/loaders/configure/configure.js +2 -8
  118. package/dist/types/common/config/state/configurable.d.ts.map +1 -1
  119. package/dist/types/common/config/state/init.d.ts.map +1 -1
  120. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  121. package/dist/types/common/context/shared-context.d.ts.map +1 -1
  122. package/dist/types/common/event-listener/event-listener-opts.d.ts +2 -2
  123. package/dist/types/common/event-listener/event-listener-opts.d.ts.map +1 -1
  124. package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -0
  125. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  126. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  127. package/dist/types/common/session/constants.d.ts +4 -0
  128. package/dist/types/common/session/constants.d.ts.map +1 -0
  129. package/dist/types/common/session/session-entity.d.ts +72 -0
  130. package/dist/types/common/session/session-entity.d.ts.map +1 -0
  131. package/dist/types/common/storage/first-party-cookies.d.ts +8 -0
  132. package/dist/types/common/storage/first-party-cookies.d.ts.map +1 -0
  133. package/dist/types/common/storage/local-memory.d.ts +8 -0
  134. package/dist/types/common/storage/local-memory.d.ts.map +1 -0
  135. package/dist/types/common/storage/local-storage.d.ts +6 -0
  136. package/dist/types/common/storage/local-storage.d.ts.map +1 -0
  137. package/dist/types/common/timer/interaction-timer.d.ts +11 -0
  138. package/dist/types/common/timer/interaction-timer.d.ts.map +1 -0
  139. package/dist/types/common/timer/timer.d.ts +12 -0
  140. package/dist/types/common/timer/timer.d.ts.map +1 -0
  141. package/dist/types/common/url/canonicalize-url.d.ts +9 -0
  142. package/dist/types/common/url/canonicalize-url.d.ts.map +1 -0
  143. package/dist/types/common/url/clean-url.d.ts +7 -1
  144. package/dist/types/common/url/clean-url.d.ts.map +1 -1
  145. package/dist/types/common/util/data-size.d.ts +7 -1
  146. package/dist/types/common/util/data-size.d.ts.map +1 -1
  147. package/dist/types/common/util/global-scope.d.ts +1 -0
  148. package/dist/types/common/util/global-scope.d.ts.map +1 -1
  149. package/dist/types/common/util/invoke.d.ts +35 -0
  150. package/dist/types/common/util/invoke.d.ts.map +1 -0
  151. package/dist/types/common/util/obfuscate.d.ts.map +1 -1
  152. package/dist/types/common/window/page-visibility.d.ts +1 -1
  153. package/dist/types/common/window/page-visibility.d.ts.map +1 -1
  154. package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
  155. package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
  156. package/dist/types/features/ajax/aggregate/index.d.ts +2 -2
  157. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  158. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts +8 -1
  159. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -1
  160. package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts +48 -19
  161. package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts.map +1 -1
  162. package/dist/types/features/jserrors/aggregate/index.d.ts +14 -5
  163. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  164. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  165. package/dist/types/features/metrics/aggregate/index.d.ts +2 -2
  166. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  167. package/dist/types/features/page_action/aggregate/index.d.ts +3 -3
  168. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  169. package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -2
  170. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  171. package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
  172. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  173. package/dist/types/features/session_trace/aggregate/index.d.ts +2 -2
  174. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  175. package/dist/types/features/spa/aggregate/index.d.ts +2 -2
  176. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  177. package/dist/types/features/utils/agent-session.d.ts +2 -0
  178. package/dist/types/features/utils/agent-session.d.ts.map +1 -0
  179. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  180. package/dist/types/features/utils/lazy-loader.d.ts +2 -2
  181. package/dist/types/features/utils/lazy-loader.d.ts.map +1 -1
  182. package/dist/types/loaders/api/api.d.ts.map +1 -1
  183. package/dist/types/loaders/api/apiAsync.d.ts.map +1 -1
  184. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  185. package/package.json +9 -8
  186. package/src/common/config/state/configurable.js +26 -19
  187. package/src/common/config/state/init.js +7 -0
  188. package/src/common/config/state/runtime.js +22 -27
  189. package/src/common/context/shared-context.js +2 -1
  190. package/src/common/event-emitter/contextual-ee.test.js +2 -2
  191. package/src/common/event-emitter/register-handler.test.js +1 -1
  192. package/src/common/event-listener/event-listener-opts.js +4 -4
  193. package/src/common/harvest/harvest-scheduler.js +12 -8
  194. package/src/common/harvest/harvest.js +3 -1
  195. package/src/common/session/constants.js +3 -0
  196. package/src/common/session/session-entity.js +271 -0
  197. package/src/common/session/session-entity.test.js +317 -0
  198. package/src/common/storage/first-party-cookies.js +31 -0
  199. package/src/common/storage/local-memory.js +30 -0
  200. package/src/common/storage/local-memory.test.js +19 -0
  201. package/src/common/storage/local-storage.js +28 -0
  202. package/src/common/storage/local-storage.test.js +17 -0
  203. package/src/common/timer/interaction-timer.js +75 -0
  204. package/src/common/timer/interaction-timer.test.js +167 -0
  205. package/src/common/timer/timer.js +31 -0
  206. package/src/common/timer/timer.test.js +100 -0
  207. package/src/common/unload/eol.js +1 -1
  208. package/src/common/url/canonicalize-url.js +28 -0
  209. package/src/common/url/canonicalize-url.test.js +34 -0
  210. package/src/common/url/clean-url.js +10 -3
  211. package/src/common/util/data-size.js +6 -0
  212. package/src/common/util/data-size.test.js +50 -0
  213. package/src/common/util/global-scope.js +2 -0
  214. package/src/common/util/invoke.js +55 -0
  215. package/src/common/util/invoke.test.js +65 -0
  216. package/src/common/util/obfuscate.js +0 -4
  217. package/src/common/window/page-visibility.js +2 -2
  218. package/src/common/wrap/wrap-fetch.js +1 -2
  219. package/src/common/wrap/wrap-function.js +1 -2
  220. package/src/common/wrap/wrap-timer.js +1 -1
  221. package/src/features/ajax/aggregate/index.js +2 -2
  222. package/src/features/ajax/instrument/index.js +1 -1
  223. package/src/features/jserrors/aggregate/canonical-function-name.js +12 -4
  224. package/src/features/jserrors/aggregate/compute-stack-trace.js +85 -11
  225. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +141 -24
  226. package/src/features/jserrors/aggregate/index.js +24 -50
  227. package/src/features/jserrors/instrument/index.js +0 -1
  228. package/src/features/metrics/aggregate/index.js +18 -3
  229. package/src/features/page_action/aggregate/index.js +2 -2
  230. package/src/features/page_view_event/aggregate/index.js +6 -3
  231. package/src/features/page_view_timing/aggregate/index.js +6 -6
  232. package/src/features/session_trace/aggregate/index.js +3 -4
  233. package/src/features/spa/aggregate/index.js +5 -5
  234. package/src/features/utils/agent-session.js +68 -0
  235. package/src/features/utils/feature-base.js +1 -1
  236. package/src/features/utils/instrument-base.js +5 -2
  237. package/src/features/utils/lazy-loader.js +1 -1
  238. package/src/loaders/agent.js +1 -1
  239. package/src/loaders/api/api.js +2 -5
  240. package/src/loaders/api/apiAsync.js +2 -1
  241. package/src/loaders/configure/configure.js +2 -7
  242. package/dist/cjs/common/util/single.js +0 -23
  243. package/dist/cjs/common/window/session-storage.js +0 -87
  244. package/dist/cjs/features/utils/aggregate-base.js +0 -13
  245. package/dist/esm/common/util/single.js +0 -16
  246. package/dist/esm/common/window/session-storage.js +0 -77
  247. package/dist/esm/features/utils/aggregate-base.js +0 -6
  248. package/dist/types/common/util/single.d.ts +0 -2
  249. package/dist/types/common/util/single.d.ts.map +0 -1
  250. package/dist/types/common/window/session-storage.d.ts +0 -18
  251. package/dist/types/common/window/session-storage.d.ts.map +0 -1
  252. package/dist/types/features/utils/aggregate-base.d.ts +0 -4
  253. package/dist/types/features/utils/aggregate-base.d.ts.map +0 -1
  254. package/src/common/util/single.js +0 -18
  255. package/src/common/window/session-storage.js +0 -75
  256. package/src/features/utils/aggregate-base.js +0 -7
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Aggregate = void 0;
7
7
  var _canonicalFunctionName = require("./canonical-function-name");
8
- var _cleanUrl = require("../../../common/url/clean-url");
9
8
  var _computeStackTrace = require("./compute-stack-trace");
10
9
  var _stringHashCode = require("./string-hash-code");
11
10
  var _formatStackTrace = require("./format-stack-trace");
@@ -17,16 +16,20 @@ var _mapOwn = require("../../../common/util/map-own");
17
16
  var _config = require("../../../common/config/config");
18
17
  var _now = require("../../../common/timing/now");
19
18
  var _globalScope = require("../../../common/util/global-scope");
20
- var _aggregateBase = require("../../utils/aggregate-base");
21
19
  var _constants = require("../constants");
22
20
  var _drain = require("../../../common/drain/drain");
23
21
  var _features = require("../../../loaders/features/features");
22
+ var _featureBase = require("../../utils/feature-base");
24
23
  /*
25
24
  * Copyright 2020 New Relic Corporation. All rights reserved.
26
25
  * SPDX-License-Identifier: Apache-2.0
27
26
  */
28
27
 
29
- class Aggregate extends _aggregateBase.AggregateBase {
28
+ /**
29
+ * @typedef {import('./compute-stack-trace.js').StackInfo} StackInfo
30
+ */
31
+
32
+ class Aggregate extends _featureBase.FeatureBase {
30
33
  static featureName = _constants.FEATURE_NAME;
31
34
  constructor(agentIdentifier, aggregator) {
32
35
  var _this;
@@ -109,49 +112,25 @@ class Aggregate extends _aggregateBase.AggregateBase {
109
112
  getBucketName(params, customParams) {
110
113
  return this.nameHash(params) + ':' + (0, _stringHashCode.stringHashCode)((0, _stringify.stringify)(customParams));
111
114
  }
112
- canonicalizeURL(url, cleanedOrigin) {
113
- if (typeof url !== 'string') return '';
114
- var cleanedURL = (0, _cleanUrl.cleanURL)(url);
115
- if (cleanedURL === cleanedOrigin) {
116
- return '<inline>';
117
- } else {
118
- return cleanedURL;
119
- }
120
- }
121
- buildCanonicalStackString(stackInfo, cleanedOrigin) {
122
- var canonicalStack = '';
123
- for (var i = 0; i < stackInfo.frames.length; i++) {
124
- var frame = stackInfo.frames[i];
125
- var func = (0, _canonicalFunctionName.canonicalFunctionName)(frame.func);
126
- if (canonicalStack) canonicalStack += '\n';
127
- if (func) canonicalStack += func + '@';
128
- if (typeof frame.url === 'string') canonicalStack += frame.url;
129
- if (frame.line) canonicalStack += ':' + frame.line;
130
- }
131
- return canonicalStack;
132
- }
133
115
 
134
- // Strip query parameters and fragments from the stackString property of the
135
- // given stackInfo, along with the 'url' properties of each frame in
136
- // stackInfo.frames.
137
- //
138
- // Any URLs that are equivalent to the cleaned version of the origin will also
139
- // be replaced with the string '<inline>'.
140
- //
141
- canonicalizeStackURLs(stackInfo) {
142
- // Currently, loader.origin might contain a fragment, but we don't want to use it
143
- // for comparing with frame URLs.
144
- var cleanedOrigin = (0, _cleanUrl.cleanURL)((0, _config.getRuntime)(this.agentIdentifier).origin);
116
+ /**
117
+ * Builds a standardized stack trace string from the frames in the given `stackInfo` object, with each frame separated
118
+ * by a newline character. Lines take the form `<functionName>@<url>:<lineNumber>`.
119
+ *
120
+ * @param {StackInfo} stackInfo - An object specifying a stack string and individual frames.
121
+ * @returns {string} A canonical stack string built from the URLs and function names in the given `stackInfo` object.
122
+ */
123
+ buildCanonicalStackString(stackInfo) {
124
+ var canonicalStackString = '';
145
125
  for (var i = 0; i < stackInfo.frames.length; i++) {
146
126
  var frame = stackInfo.frames[i];
147
- var originalURL = frame.url;
148
- var cleanedURL = this.canonicalizeURL(originalURL, cleanedOrigin);
149
- if (cleanedURL && cleanedURL !== frame.url) {
150
- frame.url = cleanedURL;
151
- stackInfo.stackString = stackInfo.stackString.split(originalURL).join(cleanedURL);
152
- }
127
+ var func = (0, _canonicalFunctionName.canonicalFunctionName)(frame.func);
128
+ if (canonicalStackString) canonicalStackString += '\n';
129
+ if (func) canonicalStackString += func + '@';
130
+ if (typeof frame.url === 'string') canonicalStackString += frame.url;
131
+ if (frame.line) canonicalStackString += ':' + frame.line;
153
132
  }
154
- return stackInfo;
133
+ return canonicalStackString;
155
134
  }
156
135
  storeError(err, time, internal, customAttributes) {
157
136
  // are we in an interaction
@@ -168,10 +147,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
168
147
  // Again as with previous usage, all falsey values would include the error.
169
148
  }
170
149
 
171
- var stackInfo = this.canonicalizeStackURLs((0, _computeStackTrace.computeStackTrace)(err));
172
- var canonicalStack = this.buildCanonicalStackString(stackInfo);
150
+ var stackInfo = (0, _computeStackTrace.computeStackTrace)(err);
151
+ var canonicalStackString = this.buildCanonicalStackString(stackInfo);
173
152
  const params = {
174
- stackHash: (0, _stringHashCode.stringHashCode)(canonicalStack),
153
+ stackHash: (0, _stringHashCode.stringHashCode)(canonicalStackString),
175
154
  exceptionClass: stackInfo.name,
176
155
  request_uri: _globalScope.globalScope?.location.pathname
177
156
  };
@@ -216,6 +195,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
216
195
 
217
196
  // still send EE events for other features such as above, but stop this one from aggregating internal data
218
197
  if (this.blocked) return;
198
+ var att = (0, _config.getInfo)(this.agentIdentifier).jsAttributes;
219
199
  if (params._interactionId != null) {
220
200
  // hold on to the error until the interaction finishes
221
201
  this.errorCache[params._interactionId] = this.errorCache[params._interactionId] || [];
@@ -223,7 +203,6 @@ class Aggregate extends _aggregateBase.AggregateBase {
223
203
  } else {
224
204
  // store custom attributes
225
205
  var customParams = {};
226
- var att = (0, _config.getInfo)(this.agentIdentifier).jsAttributes;
227
206
  (0, _mapOwn.mapOwn)(att, setCustom);
228
207
  if (customAttributes) {
229
208
  (0, _mapOwn.mapOwn)(customAttributes, setCustom);
@@ -8,7 +8,6 @@ var _handle = require("../../../common/event-emitter/handle");
8
8
  var _now = require("../../../common/timing/now");
9
9
  var _getOrSet = require("../../../common/util/get-or-set");
10
10
  var _wrap = require("../../../common/wrap");
11
- var _lodash = _interopRequireDefault(require("lodash._slice"));
12
11
  require("./debug");
13
12
  var _instrumentBase = require("../../utils/instrument-base");
14
13
  var _constants = require("../constants");
@@ -17,7 +16,6 @@ var _globalScope = require("../../../common/util/global-scope");
17
16
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
18
17
  var _config = require("../../../common/config/config");
19
18
  var _stringify = require("../../../common/util/stringify");
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
19
  /*
22
20
  * Copyright 2020 New Relic Corporation. All rights reserved.
23
21
  * SPDX-License-Identifier: Apache-2.0
@@ -7,7 +7,6 @@ exports.Aggregate = void 0;
7
7
  var _config = require("../../../common/config/config");
8
8
  var _registerHandler = require("../../../common/event-emitter/register-handler");
9
9
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
10
- var _aggregateBase = require("../../utils/aggregate-base");
11
10
  var _constants = require("../constants");
12
11
  var _drain = require("../../../common/drain/drain");
13
12
  var _frameworkDetection = require("../../../common/metrics/framework-detection");
@@ -17,7 +16,9 @@ var _env = require("../../../common/constants/env.npm");
17
16
  var _load = require("../../../common/window/load");
18
17
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
19
18
  var _globalScope = require("../../../common/util/global-scope");
20
- class Aggregate extends _aggregateBase.AggregateBase {
19
+ var _featureBase = require("../../utils/feature-base");
20
+ var _stringify = require("../../../common/util/stringify");
21
+ class Aggregate extends _featureBase.FeatureBase {
21
22
  static featureName = _constants.FEATURE_NAME;
22
23
  constructor(agentIdentifier, aggregator) {
23
24
  super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
@@ -109,6 +110,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
109
110
  try {
110
111
  if (this.resourcesSent) return;
111
112
  const agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
113
+ const info = (0, _config.getInfo)(this.agentIdentifier);
112
114
  // make sure this only gets sent once
113
115
  this.resourcesSent = true;
114
116
  // differentiate between internal+external and ajax+non-ajax
@@ -134,10 +136,19 @@ class Aggregate extends _aggregateBase.AggregateBase {
134
136
  this.storeSupportabilityMetrics("PageSession/Endpoint/".concat(endpoint.charAt(0).toUpperCase() + endpoint.slice(1), "/BytesSent"), agentRuntime.bytesSent[endpoint]);
135
137
  });
136
138
 
139
+ // Capture per-agent query bytes sent for each endpoint (see harvest) and RUM call (see page_view_event aggregator).
140
+ Object.keys(agentRuntime.bytesSent).forEach(endpoint => {
141
+ this.storeSupportabilityMetrics("PageSession/Endpoint/".concat(endpoint.charAt(0).toUpperCase() + endpoint.slice(1), "/QueryBytesSent"), agentRuntime.queryBytesSent[endpoint]);
142
+ });
143
+
137
144
  // Capture metrics for session trace if active (`ptid` is set when returned by replay ingest).
138
145
  if (agentRuntime.ptid) {
139
146
  this.storeSupportabilityMetrics('PageSession/Feature/SessionTrace/DurationMs', Math.round(performance.now()));
140
147
  }
148
+
149
+ // Capture metrics for size of custom attributes
150
+ const jsAttributes = (0, _stringify.stringify)(info.jsAttributes);
151
+ this.storeSupportabilityMetrics('PageSession/Feature/CustomData/Bytes', jsAttributes === '{}' ? 0 : jsAttributes.length);
141
152
  } catch (e) {
142
153
  // do nothing
143
154
  }
@@ -10,16 +10,16 @@ var _registerHandler = require("../../../common/event-emitter/register-handler")
10
10
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
11
11
  var _cleanUrl = require("../../../common/url/clean-url");
12
12
  var _config = require("../../../common/config/config");
13
- var _aggregateBase = require("../../utils/aggregate-base");
14
13
  var _constants = require("../constants");
15
14
  var _drain = require("../../../common/drain/drain");
16
15
  var _globalScope = require("../../../common/util/global-scope");
16
+ var _featureBase = require("../../utils/feature-base");
17
17
  /*
18
18
  * Copyright 2020 New Relic Corporation. All rights reserved.
19
19
  * SPDX-License-Identifier: Apache-2.0
20
20
  */
21
21
 
22
- class Aggregate extends _aggregateBase.AggregateBase {
22
+ class Aggregate extends _featureBase.FeatureBase {
23
23
  static featureName = _constants.FEATURE_NAME;
24
24
  constructor(agentIdentifier, aggregator) {
25
25
  var _this;
@@ -16,15 +16,15 @@ var _paintMetrics = require("../../../common/metrics/paint-metrics");
16
16
  var _submitData = require("../../../common/util/submit-data");
17
17
  var _config = require("../../../common/config/config");
18
18
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
19
- var _aggregateBase = require("../../utils/aggregate-base");
20
19
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
21
20
  var _initializedFeatures = require("./initialized-features");
22
21
  var _globalScope = require("../../../common/util/global-scope");
23
22
  var _drain = require("../../../common/drain/drain");
23
+ var _featureBase = require("../../utils/feature-base");
24
24
  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); }
25
25
  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; }
26
26
  const jsonp = 'NREUM.setToken';
27
- class Aggregate extends _aggregateBase.AggregateBase {
27
+ class Aggregate extends _featureBase.FeatureBase {
28
28
  static featureName = CONSTANTS.FEATURE_NAME;
29
29
  constructor(agentIdentifier, aggregator) {
30
30
  super(agentIdentifier, aggregator, CONSTANTS.FEATURE_NAME);
@@ -138,7 +138,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
138
138
  var queryString = (0, _encode.fromArray)(chunksForQueryString, agentRuntime.maxBytes);
139
139
 
140
140
  // Capture bytes sent to RUM call endpoint (currently `1`) as a supportability metric. See metrics aggregator (on unload).
141
- agentRuntime.bytesSent[protocol] = (agentRuntime.bytesSent[protocol] || 0) + queryString?.length || 0;
141
+ agentRuntime.bytesSent[protocol] = 0; // Set to zero for now until RUM is moved to POST
142
+
143
+ // Capture query bytes sent to RUM call endpoint (currently `1`) as a supportability metric. See metrics aggregator (on unload).
144
+ agentRuntime.queryBytesSent[protocol] = (agentRuntime.queryBytesSent[protocol] || 0) + queryString?.length || 0;
142
145
  const isValidJsonp = _submitData.submitData.jsonp(this.getScheme() + '://' + info.beacon + '/' + protocol + '/' + info.licenseKey + queryString, jsonp);
143
146
  // Usually `drain` is invoked automatically after processing feature flags contained in the JSONP callback from
144
147
  // ingest (see `activateFeatures`), so when JSONP cannot execute (as with module workers), we drain manually.
@@ -15,16 +15,16 @@ var _registerHandler = require("../../../common/event-emitter/register-handler")
15
15
  var _cleanUrl = require("../../../common/url/clean-url");
16
16
  var _handle = require("../../../common/event-emitter/handle");
17
17
  var _config = require("../../../common/config/config");
18
- var _aggregateBase = require("../../utils/aggregate-base");
19
18
  var _constants = require("../constants");
20
19
  var _drain = require("../../../common/drain/drain");
21
20
  var _features = require("../../../loaders/features/features");
21
+ var _featureBase = require("../../utils/feature-base");
22
22
  /*
23
23
  * Copyright 2020 New Relic Corporation. All rights reserved.
24
24
  * SPDX-License-Identifier: Apache-2.0
25
25
  */
26
26
 
27
- class Aggregate extends _aggregateBase.AggregateBase {
27
+ class Aggregate extends _featureBase.FeatureBase {
28
28
  static featureName = _constants.FEATURE_NAME;
29
29
  constructor(agentIdentifier, aggregator) {
30
30
  var _this;
@@ -35,7 +35,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
35
35
  this.curSessEndRecorded = false;
36
36
  this.cls = null; // this should be null unless set to a numeric value by web-vitals so that we differentiate if CLS is supported
37
37
 
38
- /*! This is the section that used to be in the loader portion: !*/
38
+ /* ! This is the section that used to be in the loader portion: ! */
39
39
  /* ------------------------------------------------------------ */
40
40
  const pageStartedHidden = (0, _config.getRuntime)(agentIdentifier).initHidden; // our attempt at recapturing initial vis state since this code runs post-load time
41
41
  this.alreadySent = new Set(); // since we don't support timings on BFCache restores, this tracks and helps cap metrics that web-vitals report more than once
@@ -111,10 +111,10 @@ class Aggregate extends _aggregateBase.AggregateBase {
111
111
  attributes.size = lcpEntry.size;
112
112
  attributes.eid = lcpEntry.id;
113
113
  if (lcpEntry.url) {
114
- attributes['elUrl'] = (0, _cleanUrl.cleanURL)(lcpEntry.url);
114
+ attributes.elUrl = (0, _cleanUrl.cleanURL)(lcpEntry.url);
115
115
  }
116
116
  if (lcpEntry.element?.tagName) {
117
- attributes['elTag'] = lcpEntry.element.tagName;
117
+ attributes.elTag = lcpEntry.element.tagName;
118
118
  }
119
119
  }
120
120
  this.addConnectionAttributes(attributes);
@@ -227,7 +227,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
227
227
  Future: onCLS value changes should be reported directly & CLS separated into its own timing node so it's not beholden to 'pageHide' firing. It'd also be possible to report the real final CLS.
228
228
  */
229
229
  if (this.cls !== null) {
230
- attrs['cls'] = this.cls;
230
+ attrs.cls = this.cls;
231
231
  }
232
232
  this.timings.push({
233
233
  name: name,
@@ -10,20 +10,18 @@ var _mapOwn = require("../../../common/util/map-own");
10
10
  var _stringify = require("../../../common/util/stringify");
11
11
  var _parseUrl = require("../../../common/url/parse-url");
12
12
  var _supportsPerformanceObserver = require("../../../common/window/supports-performance-observer");
13
- var _lodash = _interopRequireDefault(require("lodash._slice"));
14
13
  var _config = require("../../../common/config/config");
15
14
  var _now = require("../../../common/timing/now");
16
- var _aggregateBase = require("../../utils/aggregate-base");
17
15
  var _constants = require("../constants");
18
16
  var _drain = require("../../../common/drain/drain");
19
17
  var _handlerCache = require("../../utils/handler-cache");
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ var _featureBase = require("../../utils/feature-base");
21
19
  /*
22
20
  * Copyright 2020 New Relic Corporation. All rights reserved.
23
21
  * SPDX-License-Identifier: Apache-2.0
24
22
  */
25
23
 
26
- class Aggregate extends _aggregateBase.AggregateBase {
24
+ class Aggregate extends _featureBase.FeatureBase {
27
25
  static featureName = _constants.FEATURE_NAME;
28
26
  constructor(agentIdentifier, aggregator) {
29
27
  var _this;
@@ -260,7 +258,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
260
258
  } else if (t && typeof t.tagName === 'string') {
261
259
  origin = t.tagName.toLowerCase();
262
260
  if (t.id) origin += '#' + t.id;
263
- if (t.className) origin += '.' + (0, _lodash.default)(t.classList).join('.');
261
+ if (t.className) origin += '.' + Array.from(t.classList).join('.');
264
262
  }
265
263
  if (origin === 'unknown') {
266
264
  if (typeof target === 'string') origin = target;else if (target === document) origin = 'document';else if (target === window) origin = 'window';else if (target instanceof FileReader) origin = 'FileReader';
@@ -14,20 +14,20 @@ var _paintMetrics = require("../../../common/metrics/paint-metrics");
14
14
  var _interaction = require("./interaction");
15
15
  var _config = require("../../../common/config/config");
16
16
  var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
17
- var _aggregateBase = require("../../utils/aggregate-base");
18
17
  var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
19
18
  var _serializer = require("./serializer");
20
19
  var _contextualEe = require("../../../common/event-emitter/contextual-ee");
21
20
  var CONSTANTS = _interopRequireWildcard(require("../constants"));
22
21
  var _drain = require("../../../common/drain/drain");
23
22
  var _features = require("../../../loaders/features/features");
23
+ var _featureBase = require("../../utils/feature-base");
24
24
  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); }
25
25
  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; }
26
26
  /*
27
27
  * Copyright 2020 New Relic Corporation. All rights reserved.
28
28
  * SPDX-License-Identifier: Apache-2.0
29
29
  */
30
- /*eslint no-undef: "error"*/
30
+ /* eslint no-undef: "error" */
31
31
 
32
32
  const {
33
33
  FEATURE_NAME,
@@ -47,7 +47,7 @@ const {
47
47
  JSONP_END,
48
48
  originalSetTimeout
49
49
  } = CONSTANTS;
50
- class Aggregate extends _aggregateBase.AggregateBase {
50
+ class Aggregate extends _featureBase.FeatureBase {
51
51
  static featureName = FEATURE_NAME;
52
52
  constructor(agentIdentifier, aggregator) {
53
53
  super(agentIdentifier, aggregator, FEATURE_NAME);
@@ -90,7 +90,8 @@ class Aggregate extends _aggregateBase.AggregateBase {
90
90
  onFinished: onHarvestFinished,
91
91
  retryDelay: state.harvestTimeSeconds
92
92
  }, {
93
- agentIdentifier
93
+ agentIdentifier,
94
+ ee: baseEE
94
95
  });
95
96
  scheduler.harvest.on('events', onHarvestStarted);
96
97
 
@@ -222,7 +223,7 @@ class Aggregate extends _aggregateBase.AggregateBase {
222
223
  if (evName === 'click') {
223
224
  var value = getActionText(ev.target);
224
225
  if (value) {
225
- state.currentNode.attrs.custom['actionText'] = value;
226
+ state.currentNode.attrs.custom.actionText = value;
226
227
  }
227
228
  }
228
229
  }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setupAgentSession = setupAgentSession;
7
+ var _config = require("../../common/config/config");
8
+ var _drain = require("../../common/drain/drain");
9
+ var _contextualEe = require("../../common/event-emitter/contextual-ee");
10
+ var _registerHandler = require("../../common/event-emitter/register-handler");
11
+ var _globalScope = require("../../common/util/global-scope");
12
+ var _sessionEntity = require("../../common/session/session-entity");
13
+ var _localStorage = require("../../common/storage/local-storage.js");
14
+ var _firstPartyCookies = require("../../common/storage/first-party-cookies");
15
+ var _localMemory = require("../../common/storage/local-memory");
16
+ let ranOnce = 0;
17
+ function setupAgentSession(agentIdentifier) {
18
+ const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
19
+ if (ranOnce++) return agentRuntime.session;
20
+ const sharedEE = _contextualEe.ee.get(agentIdentifier);
21
+
22
+ // domain is a string that can be specified by customer.
23
+ // only way to keep the session object across subdomains is using first party cookies
24
+ // This determines which storage wrapper the session manager will use to keep state
25
+ let storageAPI;
26
+ const cookiesEnabled = (0, _config.getConfigurationValue)(agentIdentifier, 'privacy.cookies_enabled') === true;
27
+ if (cookiesEnabled && _globalScope.isBrowserScope) {
28
+ storageAPI = (0, _config.getConfigurationValue)(agentIdentifier, 'session.domain') ? new _firstPartyCookies.FirstPartyCookies((0, _config.getConfigurationValue)(agentIdentifier, 'session.domain')) : new _localStorage.LocalStorage();
29
+ }
30
+ if (cookiesEnabled) {
31
+ // defaults to "LocalMemory" if storageAPI is undefined, such as in Worker build
32
+ agentRuntime.session = new _sessionEntity.SessionEntity({
33
+ agentIdentifier,
34
+ key: 'SESSION',
35
+ storageAPI,
36
+ expiresMs: (0, _config.getConfigurationValue)(agentIdentifier, 'session.expiresMs'),
37
+ inactiveMs: (0, _config.getConfigurationValue)(agentIdentifier, 'session.inactiveMs')
38
+ });
39
+ }
40
+
41
+ // The first time the agent runs on a page, it should put everything
42
+ // that's currently stored in the storage API into the local info.jsAttributes object
43
+ if (_globalScope.isBrowserScope) {
44
+ // retrieve & re-add all of the persisted setCustomAttribute|setUserId k-v from previous page load(s)
45
+ const customSessionData = agentRuntime.session?.read?.()?.custom;
46
+ const agentInfo = (0, _config.getInfo)(agentIdentifier);
47
+ if (customSessionData) {
48
+ (0, _config.setInfo)(agentIdentifier, {
49
+ ...agentInfo,
50
+ jsAttributes: {
51
+ ...agentInfo.jsAttributes,
52
+ ...customSessionData
53
+ }
54
+ });
55
+ }
56
+ }
57
+
58
+ // any calls to newrelic.setCustomAttribute(<persisted>) will need to be added to:
59
+ // local info.jsAttributes {}
60
+ // the session's storage API
61
+ (0, _registerHandler.registerHandler)('api-setCustomAttribute', (time, key, value) => {
62
+ agentRuntime.session.syncCustomAttribute(key, value);
63
+ }, 'session', sharedEE);
64
+
65
+ // any calls to newrelic.setUserId(...) will need to be added to:
66
+ // local info.jsAttributes {}
67
+ // the session's storage API
68
+ (0, _registerHandler.registerHandler)('api-setUserId', (time, key, value) => {
69
+ agentRuntime.session.syncCustomAttribute(key, value);
70
+ }, 'session', sharedEE);
71
+ (0, _drain.drain)(agentIdentifier, 'session');
72
+ return agentRuntime.session;
73
+ }
@@ -32,7 +32,7 @@ class FeatureBase {
32
32
  * loader configurations may appear after the loader code is executed.
33
33
  */
34
34
  checkConfiguration() {
35
- // NOTE: This check has to happen at aggregator load time, but could be moved to `AggregateBase`.
35
+ // NOTE: This check has to happen at aggregator load time
36
36
  if (!(0, _config.isConfigured)(this.agentIdentifier)) {
37
37
  let jsAttributes = {
38
38
  ...(0, _nreum.gosCDN)().info?.jsAttributes
@@ -53,6 +53,12 @@ class InstrumentBase extends _featureBase.FeatureBase {
53
53
  * it's only responsible for aborting its one specific feature, rather than all.
54
54
  */
55
55
  try {
56
+ // The session entity needs to be attached to the config internals before the aggregator chunk runs
57
+ const {
58
+ setupAgentSession
59
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "session-manager" */'./agent-session')));
60
+ setupAgentSession(this.agentIdentifier);
61
+ // import and instantiate the aggregator chunk
56
62
  const {
57
63
  lazyLoader
58
64
  } = await Promise.resolve().then(() => _interopRequireWildcard(require( /* webpackChunkName: "lazy-loader" */'./lazy-loader')));
@@ -61,9 +67,8 @@ class InstrumentBase extends _featureBase.FeatureBase {
61
67
  } = await lazyLoader(this.featureName, 'aggregate');
62
68
  new Aggregate(this.agentIdentifier, this.aggregator);
63
69
  } catch (e) {
64
- (0, _console.warn)("Downloading ".concat(this.featureName, " failed..."));
70
+ (0, _console.warn)("Downloading ".concat(this.featureName, " failed..."), e);
65
71
  this.abortHandler?.(); // undo any important alterations made to the page
66
-
67
72
  // not supported yet but nice to do: "abort" this agent's EE for this feature specifically
68
73
  }
69
74
  };
@@ -16,7 +16,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
16
16
  * should be.
17
17
  * @param featureName Name of the feature to import such as ajax or session_trace
18
18
  * @param featurePart Name of the feature part to load; should be either instrument or aggregate
19
- * @returns {Promise<InstrumentBase|AggregateBase|null>}
19
+ * @returns {Promise<InstrumentBase|FeatureBase|null>}
20
20
  */
21
21
  function lazyLoader(featureName, featurePart) {
22
22
  if (featurePart === 'aggregate') {
@@ -74,7 +74,7 @@ class Agent {
74
74
  this.features[featName].abortHandler?.();
75
75
  }
76
76
  const newrelic = (0, _nreum.gosNREUM)();
77
- delete newrelic.initializedAgents[this.agentIdentifier]?.['api']; // prevent further calls to agent-specific APIs (see "configure.js")
77
+ delete newrelic.initializedAgents[this.agentIdentifier]?.api; // prevent further calls to agent-specific APIs (see "configure.js")
78
78
  delete newrelic.initializedAgents[this.agentIdentifier]?.[NR_FEATURES_REF_NAME]; // GC mem used internally by features
79
79
  delete this.sharedAggregator;
80
80
  // Keep the initialized agent object with its configs for troubleshooting purposes.
@@ -17,7 +17,6 @@ var _globalScope = require("../../common/util/global-scope");
17
17
  var _console = require("../../common/util/console");
18
18
  var _constants = require("../../features/metrics/constants");
19
19
  var _nreum = require("../../common/window/nreum");
20
- var _sessionStorage = require("../../common/window/session-storage");
21
20
  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); }
22
21
  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; } /*
23
22
  * Copyright 2020 New Relic Corporation. All rights reserved.
@@ -81,7 +80,6 @@ function setAPI(agentIdentifier, forceDrain) {
81
80
  const currentInfo = (0, _config.getInfo)(agentIdentifier);
82
81
  if (value === null) {
83
82
  delete currentInfo.jsAttributes[key];
84
- if (_globalScope.isBrowserScope) (0, _sessionStorage.removeFromBrowserStorage)(key, CUSTOM_ATTR_GROUP); // addToBrowserStorage flag isn't needed to unset keys from storage
85
83
  } else {
86
84
  (0, _config.setInfo)(agentIdentifier, {
87
85
  ...currentInfo,
@@ -90,9 +88,8 @@ function setAPI(agentIdentifier, forceDrain) {
90
88
  [key]: value
91
89
  }
92
90
  });
93
- if (_globalScope.isBrowserScope && addToBrowserStorage) (0, _sessionStorage.putInBrowserStorage)(key, value, CUSTOM_ATTR_GROUP);
94
91
  }
95
- return apiCall(prefix, apiName, true)();
92
+ return apiCall(prefix, apiName, true, !!addToBrowserStorage || value === null ? 'session' : undefined)(key, value);
96
93
  }
97
94
  apiInterface.setCustomAttribute = function (name, value) {
98
95
  let persistAttribute = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
@@ -9,7 +9,7 @@ var _config = require("../../common/config/config");
9
9
  var _contextualEe = require("../../common/event-emitter/contextual-ee");
10
10
  var _handle = require("../../common/event-emitter/handle");
11
11
  var _registerHandler = require("../../common/event-emitter/register-handler");
12
- var _single = require("../../common/util/single");
12
+ var _invoke = require("../../common/util/invoke");
13
13
  var _submitData = require("../../common/util/submit-data");
14
14
  var _globalScope = require("../../common/util/global-scope");
15
15
  var _constants = require("../../features/metrics/constants");
@@ -18,7 +18,7 @@ function setAPI(agentIdentifier) {
18
18
  var cycle = 0;
19
19
  var scheme = (0, _config.getConfigurationValue)(agentIdentifier, 'ssl') === false ? 'http' : 'https';
20
20
  var api = {
21
- finished: (0, _single.single)(finished),
21
+ finished: (0, _invoke.single)(finished),
22
22
  setErrorHandler: setErrorHandler,
23
23
  addToTrace: addToTrace,
24
24
  inlineHit: inlineHit,
@@ -71,6 +71,7 @@ function setAPI(agentIdentifier) {
71
71
  request_name = window.encodeURIComponent(request_name);
72
72
  cycle += 1;
73
73
  const agentInfo = (0, _config.getInfo)(agentIdentifier);
74
+ const agentRuntime = (0, _config.getRuntime)(agentIdentifier);
74
75
  if (!agentInfo.beacon) return;
75
76
  var url = scheme + '://' + agentInfo.beacon + '/1/' + agentInfo.licenseKey;
76
77
  url += '?a=' + agentInfo.applicationID + '&';
@@ -9,7 +9,6 @@ var _nreum = require("../../common/window/nreum");
9
9
  var _config = require("../../common/config/config");
10
10
  var _featureFlags = require("../../common/util/feature-flags");
11
11
  var _globalScope = require("../../common/util/global-scope");
12
- var _sessionStorage = require("../../common/window/session-storage");
13
12
  function configure(agentIdentifier) {
14
13
  let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15
14
  let loaderType = arguments.length > 2 ? arguments[2] : undefined;
@@ -34,11 +33,6 @@ function configure(agentIdentifier) {
34
33
  // add a default attr to all worker payloads
35
34
  info.jsAttributes.isWorker = true;
36
35
  }
37
- if (_globalScope.isBrowserScope) {
38
- // retrieve & re-add all of the persisted setCustomAttribute|setUserId k-v from previous page load(s)
39
- let prevPageSessionJsAttrs = (0, _sessionStorage.getAllStorageItemsOfGroup)(_api.CUSTOM_ATTR_GROUP);
40
- Object.assign(info.jsAttributes, prevPageSessionJsAttrs);
41
- }
42
36
  (0, _config.setInfo)(agentIdentifier, info);
43
37
  (0, _config.setConfiguration)(agentIdentifier, init || {});
44
38
  (0, _config.setLoaderConfig)(agentIdentifier, loader_config || {});