@newrelic/browser-agent 1.232.1 → 1.233.0

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