@newrelic/browser-agent 1.262.0 → 1.264.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 (259) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +2 -2
  3. package/dist/cjs/cdn/experimental.js +3 -7
  4. package/dist/cjs/cdn/pro.js +2 -2
  5. package/dist/cjs/cdn/spa.js +2 -2
  6. package/dist/cjs/common/aggregate/aggregator.js +3 -3
  7. package/dist/cjs/common/config/state/configurable.js +4 -4
  8. package/dist/cjs/common/config/state/init.js +11 -6
  9. package/dist/cjs/common/constants/env.cdn.js +1 -1
  10. package/dist/cjs/common/constants/env.npm.js +1 -1
  11. package/dist/cjs/common/constants/runtime.js +1 -3
  12. package/dist/cjs/common/context/shared-context.js +2 -2
  13. package/dist/cjs/common/drain/drain.js +5 -5
  14. package/dist/cjs/common/harvest/harvest.js +3 -3
  15. package/dist/cjs/common/serialize/bel-serializer.js +2 -2
  16. package/dist/cjs/common/session/session-entity.js +3 -3
  17. package/dist/cjs/common/timing/time-keeper.js +13 -2
  18. package/dist/cjs/common/url/encode.js +3 -5
  19. package/dist/cjs/common/util/console.js +3 -4
  20. package/dist/cjs/common/util/obfuscate.js +3 -3
  21. package/dist/cjs/common/util/submit-data.js +0 -1
  22. package/dist/cjs/common/vitals/vital-metric.js +1 -1
  23. package/dist/cjs/common/wrap/wrap-logger.js +1 -2
  24. package/dist/cjs/common/wrap/wrap-xhr.js +1 -1
  25. package/dist/cjs/features/ajax/aggregate/index.js +1 -1
  26. package/dist/cjs/features/ajax/instrument/index.js +1 -1
  27. package/dist/cjs/features/generic_events/aggregate/index.js +137 -0
  28. package/dist/cjs/features/generic_events/constants.js +8 -0
  29. package/dist/cjs/features/generic_events/index.js +12 -0
  30. package/dist/cjs/features/generic_events/instrument/index.js +27 -0
  31. package/dist/cjs/features/jserrors/aggregate/index.js +13 -12
  32. package/dist/cjs/features/jserrors/instrument/index.js +1 -1
  33. package/dist/cjs/features/logging/aggregate/index.js +6 -6
  34. package/dist/cjs/features/logging/constants.js +2 -5
  35. package/dist/cjs/features/logging/instrument/index.js +1 -1
  36. package/dist/cjs/features/metrics/aggregate/index.js +17 -1
  37. package/dist/cjs/features/metrics/instrument/index.js +1 -1
  38. package/dist/cjs/features/page_action/instrument/index.js +6 -6
  39. package/dist/cjs/features/page_view_event/aggregate/index.js +21 -5
  40. package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +1 -1
  41. package/dist/cjs/features/page_view_event/instrument/index.js +1 -1
  42. package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -3
  43. package/dist/cjs/features/page_view_timing/instrument/index.js +1 -1
  44. package/dist/cjs/features/session_replay/aggregate/index.js +3 -3
  45. package/dist/cjs/features/session_replay/instrument/index.js +1 -1
  46. package/dist/cjs/features/session_replay/shared/recorder.js +1 -1
  47. package/dist/cjs/features/session_replay/shared/stylesheet-evaluator.js +1 -1
  48. package/dist/cjs/features/session_trace/aggregate/index.js +1 -1
  49. package/dist/cjs/features/session_trace/aggregate/trace/storage.js +2 -2
  50. package/dist/cjs/features/session_trace/instrument/index.js +1 -1
  51. package/dist/cjs/features/soft_navigations/aggregate/bel-node.js +1 -1
  52. package/dist/cjs/features/soft_navigations/aggregate/index.js +1 -1
  53. package/dist/cjs/features/soft_navigations/aggregate/interaction.js +5 -5
  54. package/dist/cjs/features/soft_navigations/instrument/index.js +1 -1
  55. package/dist/cjs/features/spa/aggregate/index.js +3 -4
  56. package/dist/cjs/features/spa/aggregate/interaction.js +2 -2
  57. package/dist/cjs/features/spa/aggregate/serializer.js +1 -2
  58. package/dist/cjs/features/spa/instrument/index.js +1 -1
  59. package/dist/cjs/features/utils/aggregate-base.js +6 -3
  60. package/dist/cjs/features/utils/instrument-base.js +2 -2
  61. package/dist/cjs/features/utils/lazy-feature-loader.js +2 -2
  62. package/dist/cjs/index.js +21 -0
  63. package/dist/cjs/loaders/agent-base.js +1 -5
  64. package/dist/cjs/loaders/agent.js +3 -4
  65. package/dist/cjs/loaders/api/api.js +10 -8
  66. package/dist/cjs/loaders/api/apiAsync.js +1 -1
  67. package/dist/cjs/loaders/browser-agent.js +4 -3
  68. package/dist/cjs/loaders/configure/configure.js +4 -3
  69. package/dist/cjs/loaders/features/features.js +8 -4
  70. package/dist/cjs/loaders/micro-agent.js +6 -6
  71. package/dist/esm/cdn/experimental.js +2 -5
  72. package/dist/esm/cdn/pro.js +2 -2
  73. package/dist/esm/cdn/spa.js +2 -2
  74. package/dist/esm/common/aggregate/aggregator.js +3 -3
  75. package/dist/esm/common/config/state/configurable.js +4 -4
  76. package/dist/esm/common/config/state/init.js +11 -6
  77. package/dist/esm/common/constants/env.cdn.js +1 -1
  78. package/dist/esm/common/constants/env.npm.js +1 -1
  79. package/dist/esm/common/constants/runtime.js +0 -2
  80. package/dist/esm/common/context/shared-context.js +2 -2
  81. package/dist/esm/common/drain/drain.js +5 -5
  82. package/dist/esm/common/harvest/harvest.js +4 -4
  83. package/dist/esm/common/serialize/bel-serializer.js +2 -2
  84. package/dist/esm/common/session/session-entity.js +4 -4
  85. package/dist/esm/common/timing/time-keeper.js +12 -2
  86. package/dist/esm/common/url/encode.js +3 -5
  87. package/dist/esm/common/util/console.js +3 -4
  88. package/dist/esm/common/util/obfuscate.js +3 -3
  89. package/dist/esm/common/util/submit-data.js +0 -1
  90. package/dist/esm/common/vitals/vital-metric.js +1 -1
  91. package/dist/esm/common/wrap/wrap-logger.js +1 -2
  92. package/dist/esm/common/wrap/wrap-xhr.js +1 -1
  93. package/dist/esm/features/ajax/aggregate/index.js +1 -1
  94. package/dist/esm/features/ajax/instrument/index.js +1 -1
  95. package/dist/esm/features/generic_events/aggregate/index.js +129 -0
  96. package/dist/esm/features/generic_events/constants.js +2 -0
  97. package/dist/esm/features/generic_events/index.js +1 -0
  98. package/dist/esm/features/generic_events/instrument/index.js +20 -0
  99. package/dist/esm/features/jserrors/aggregate/index.js +13 -12
  100. package/dist/esm/features/jserrors/instrument/index.js +1 -1
  101. package/dist/esm/features/logging/aggregate/index.js +7 -7
  102. package/dist/esm/features/logging/constants.js +1 -4
  103. package/dist/esm/features/logging/instrument/index.js +1 -1
  104. package/dist/esm/features/metrics/aggregate/index.js +17 -1
  105. package/dist/esm/features/metrics/instrument/index.js +1 -1
  106. package/dist/esm/features/page_action/instrument/index.js +7 -6
  107. package/dist/esm/features/page_view_event/aggregate/index.js +22 -6
  108. package/dist/esm/features/page_view_event/aggregate/initialized-features.js +1 -1
  109. package/dist/esm/features/page_view_event/instrument/index.js +1 -1
  110. package/dist/esm/features/page_view_timing/aggregate/index.js +3 -3
  111. package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
  112. package/dist/esm/features/session_replay/aggregate/index.js +3 -3
  113. package/dist/esm/features/session_replay/instrument/index.js +1 -1
  114. package/dist/esm/features/session_replay/shared/recorder.js +1 -1
  115. package/dist/esm/features/session_replay/shared/stylesheet-evaluator.js +1 -1
  116. package/dist/esm/features/session_trace/aggregate/index.js +1 -1
  117. package/dist/esm/features/session_trace/aggregate/trace/storage.js +2 -2
  118. package/dist/esm/features/session_trace/instrument/index.js +1 -1
  119. package/dist/esm/features/soft_navigations/aggregate/bel-node.js +1 -1
  120. package/dist/esm/features/soft_navigations/aggregate/index.js +1 -1
  121. package/dist/esm/features/soft_navigations/aggregate/interaction.js +5 -5
  122. package/dist/esm/features/soft_navigations/instrument/index.js +1 -1
  123. package/dist/esm/features/spa/aggregate/index.js +3 -4
  124. package/dist/esm/features/spa/aggregate/interaction.js +2 -2
  125. package/dist/esm/features/spa/aggregate/serializer.js +1 -2
  126. package/dist/esm/features/spa/instrument/index.js +1 -1
  127. package/dist/esm/features/utils/aggregate-base.js +7 -4
  128. package/dist/esm/features/utils/instrument-base.js +2 -2
  129. package/dist/esm/features/utils/lazy-feature-loader.js +2 -2
  130. package/dist/esm/index.js +3 -0
  131. package/dist/esm/loaders/agent-base.js +1 -5
  132. package/dist/esm/loaders/agent.js +3 -4
  133. package/dist/esm/loaders/api/api.js +10 -8
  134. package/dist/esm/loaders/api/apiAsync.js +1 -1
  135. package/dist/esm/loaders/browser-agent.js +3 -2
  136. package/dist/esm/loaders/configure/configure.js +4 -3
  137. package/dist/esm/loaders/features/features.js +8 -4
  138. package/dist/esm/loaders/micro-agent.js +6 -6
  139. package/dist/types/common/aggregate/aggregator.d.ts.map +1 -1
  140. package/dist/types/common/config/state/init.d.ts.map +1 -1
  141. package/dist/types/common/constants/runtime.d.ts +0 -1
  142. package/dist/types/common/constants/runtime.d.ts.map +1 -1
  143. package/dist/types/common/drain/drain.d.ts.map +1 -1
  144. package/dist/types/common/serialize/bel-serializer.d.ts.map +1 -1
  145. package/dist/types/common/timing/time-keeper.d.ts +2 -1
  146. package/dist/types/common/timing/time-keeper.d.ts.map +1 -1
  147. package/dist/types/common/url/encode.d.ts.map +1 -1
  148. package/dist/types/common/util/console.d.ts +1 -1
  149. package/dist/types/common/util/console.d.ts.map +1 -1
  150. package/dist/types/common/util/submit-data.d.ts.map +1 -1
  151. package/dist/types/common/wrap/wrap-logger.d.ts.map +1 -1
  152. package/dist/types/features/{page_action → generic_events}/aggregate/index.d.ts +7 -5
  153. package/dist/types/features/generic_events/aggregate/index.d.ts.map +1 -0
  154. package/dist/types/features/generic_events/constants.d.ts +2 -0
  155. package/dist/types/features/generic_events/constants.d.ts.map +1 -0
  156. package/dist/types/features/generic_events/index.d.ts +2 -0
  157. package/dist/types/features/generic_events/index.d.ts.map +1 -0
  158. package/dist/types/features/generic_events/instrument/index.d.ts +6 -0
  159. package/dist/types/features/generic_events/instrument/index.d.ts.map +1 -0
  160. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  161. package/dist/types/features/logging/constants.d.ts +0 -3
  162. package/dist/types/features/logging/constants.d.ts.map +1 -1
  163. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  164. package/dist/types/features/page_action/instrument/index.d.ts +5 -4
  165. package/dist/types/features/page_action/instrument/index.d.ts.map +1 -1
  166. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  167. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  168. package/dist/types/features/session_replay/shared/recorder.d.ts.map +1 -1
  169. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  170. package/dist/types/features/spa/aggregate/interaction.d.ts.map +1 -1
  171. package/dist/types/features/spa/aggregate/serializer.d.ts.map +1 -1
  172. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -1
  173. package/dist/types/index.d.ts +3 -0
  174. package/dist/types/loaders/agent-base.d.ts +0 -1
  175. package/dist/types/loaders/agent-base.d.ts.map +1 -1
  176. package/dist/types/loaders/agent.d.ts.map +1 -1
  177. package/dist/types/loaders/api/api.d.ts.map +1 -1
  178. package/dist/types/loaders/browser-agent.d.ts.map +1 -1
  179. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  180. package/dist/types/loaders/features/features.d.ts +1 -0
  181. package/dist/types/loaders/features/features.d.ts.map +1 -1
  182. package/package.json +25 -6
  183. package/src/cdn/experimental.js +2 -4
  184. package/src/cdn/pro.js +2 -2
  185. package/src/cdn/spa.js +2 -2
  186. package/src/common/aggregate/aggregator.js +2 -3
  187. package/src/common/config/state/configurable.js +4 -4
  188. package/src/common/config/state/init.js +6 -4
  189. package/src/common/constants/runtime.js +0 -2
  190. package/src/common/context/shared-context.js +2 -2
  191. package/src/common/drain/drain.js +4 -5
  192. package/src/common/harvest/harvest.js +4 -4
  193. package/src/common/serialize/bel-serializer.js +1 -2
  194. package/src/common/session/session-entity.js +4 -4
  195. package/src/common/timing/time-keeper.js +14 -2
  196. package/src/common/url/encode.js +2 -3
  197. package/src/common/util/console.js +3 -4
  198. package/src/common/util/obfuscate.js +3 -3
  199. package/src/common/util/submit-data.js +0 -1
  200. package/src/common/wrap/wrap-logger.js +1 -2
  201. package/src/common/wrap/wrap-xhr.js +1 -1
  202. package/src/features/generic_events/aggregate/index.js +133 -0
  203. package/src/features/generic_events/constants.js +3 -0
  204. package/src/features/generic_events/index.js +1 -0
  205. package/src/features/generic_events/instrument/index.js +22 -0
  206. package/src/features/jserrors/aggregate/index.js +4 -5
  207. package/src/features/logging/aggregate/index.js +6 -6
  208. package/src/features/logging/constants.js +0 -4
  209. package/src/features/metrics/aggregate/index.js +12 -0
  210. package/src/features/page_action/instrument/index.js +6 -6
  211. package/src/features/page_view_event/aggregate/index.js +22 -5
  212. package/src/features/page_view_event/aggregate/initialized-features.js +1 -1
  213. package/src/features/page_view_timing/aggregate/index.js +1 -2
  214. package/src/features/session_replay/aggregate/index.js +1 -1
  215. package/src/features/session_replay/shared/recorder.js +1 -1
  216. package/src/features/spa/aggregate/index.js +2 -3
  217. package/src/features/spa/aggregate/interaction.js +1 -2
  218. package/src/features/spa/aggregate/serializer.js +1 -2
  219. package/src/features/utils/aggregate-base.js +7 -4
  220. package/src/features/utils/instrument-base.js +2 -2
  221. package/src/features/utils/lazy-feature-loader.js +2 -2
  222. package/src/index.js +3 -0
  223. package/src/loaders/agent-base.js +1 -5
  224. package/src/loaders/agent.js +3 -4
  225. package/src/loaders/api/api.js +10 -8
  226. package/src/loaders/api/apiAsync.js +1 -1
  227. package/src/loaders/browser-agent.js +5 -3
  228. package/src/loaders/configure/configure.js +5 -1
  229. package/src/loaders/features/features.js +8 -4
  230. package/src/loaders/micro-agent.js +6 -6
  231. package/dist/cjs/cdn/polyfills/lite.js +0 -16
  232. package/dist/cjs/cdn/polyfills/pro.js +0 -21
  233. package/dist/cjs/cdn/polyfills/spa.js +0 -22
  234. package/dist/cjs/cdn/polyfills.js +0 -24
  235. package/dist/cjs/common/util/map-own.js +0 -31
  236. package/dist/cjs/features/page_action/aggregate/index.js +0 -121
  237. package/dist/esm/cdn/polyfills/lite.js +0 -14
  238. package/dist/esm/cdn/polyfills/pro.js +0 -19
  239. package/dist/esm/cdn/polyfills/spa.js +0 -20
  240. package/dist/esm/cdn/polyfills.js +0 -27
  241. package/dist/esm/common/util/map-own.js +0 -24
  242. package/dist/esm/features/page_action/aggregate/index.js +0 -114
  243. package/dist/types/cdn/polyfills/lite.d.ts +0 -2
  244. package/dist/types/cdn/polyfills/lite.d.ts.map +0 -1
  245. package/dist/types/cdn/polyfills/pro.d.ts +0 -2
  246. package/dist/types/cdn/polyfills/pro.d.ts.map +0 -1
  247. package/dist/types/cdn/polyfills/spa.d.ts +0 -2
  248. package/dist/types/cdn/polyfills/spa.d.ts.map +0 -1
  249. package/dist/types/cdn/polyfills.d.ts +0 -2
  250. package/dist/types/cdn/polyfills.d.ts.map +0 -1
  251. package/dist/types/common/util/map-own.d.ts +0 -3
  252. package/dist/types/common/util/map-own.d.ts.map +0 -1
  253. package/dist/types/features/page_action/aggregate/index.d.ts.map +0 -1
  254. package/src/cdn/polyfills/lite.js +0 -20
  255. package/src/cdn/polyfills/pro.js +0 -30
  256. package/src/cdn/polyfills/spa.js +0 -32
  257. package/src/cdn/polyfills.js +0 -27
  258. package/src/common/util/map-own.js +0 -22
  259. package/src/features/page_action/aggregate/index.js +0 -114
@@ -30,7 +30,7 @@ export function setTopLevelCallers () {
30
30
  let returnVals = []
31
31
  Object.values(nr.initializedAgents).forEach(val => {
32
32
  if (!val || !val.api) {
33
- warn(`Call to api '${fnName}' made before agent fully initialized.`)
33
+ warn(38, fnName)
34
34
  } else if (val.exposed && val.api[fnName]) {
35
35
  returnVals.push(val.api[fnName](...args))
36
36
  }
@@ -57,17 +57,19 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
57
57
  var spaPrefix = prefix + 'ixn-'
58
58
 
59
59
  apiInterface.log = function (message, { customAttributes = {}, level = LOG_LEVELS.INFO } = {}) {
60
+ handle(SUPPORTABILITY_METRIC_CHANNEL, ['API/log/called'], undefined, FEATURE_NAMES.metrics, instanceEE)
60
61
  bufferLog(instanceEE, message, customAttributes, level)
61
62
  }
62
63
 
63
64
  apiInterface.wrapLogger = (parent, functionName, { customAttributes = {}, level = LOG_LEVELS.INFO } = {}) => {
65
+ handle(SUPPORTABILITY_METRIC_CHANNEL, ['API/wrapLogger/called'], undefined, FEATURE_NAMES.metrics, instanceEE)
64
66
  wrapLogger(instanceEE, parent, functionName, { customAttributes, level })
65
67
  }
66
68
 
67
69
  // Setup stub functions that queue calls for later processing.
68
70
  asyncApiMethods.forEach(fnName => { apiInterface[fnName] = apiCall(prefix, fnName, true, 'api') })
69
71
 
70
- apiInterface.addPageAction = apiCall(prefix, 'addPageAction', true, FEATURE_NAMES.pageAction)
72
+ apiInterface.addPageAction = apiCall(prefix, 'addPageAction', true, FEATURE_NAMES.genericEvents)
71
73
 
72
74
  apiInterface.setPageViewName = function (name, host) {
73
75
  if (typeof name !== 'string') return
@@ -95,11 +97,11 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
95
97
  }
96
98
  apiInterface.setCustomAttribute = function (name, value, persistAttribute = false) {
97
99
  if (typeof name !== 'string') {
98
- warn(`Failed to execute setCustomAttribute.\nName must be a string type, but a type of <${typeof name}> was provided.`)
100
+ warn(39, typeof name)
99
101
  return
100
102
  }
101
103
  if (!(['string', 'number', 'boolean'].includes(typeof value) || value === null)) {
102
- warn(`Failed to execute setCustomAttribute.\nNon-null value must be a string, number or boolean type, but a type of <${typeof value}> was provided.`)
104
+ warn(40, typeof value)
103
105
  return
104
106
  }
105
107
  return appendJsAttribute(name, value, 'setCustomAttribute', persistAttribute)
@@ -111,7 +113,7 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
111
113
  */
112
114
  apiInterface.setUserId = function (value) {
113
115
  if (!(typeof value === 'string' || value === null)) {
114
- warn(`Failed to execute setUserId.\nNon-null value must be a string type, but a type of <${typeof value}> was provided.`)
116
+ warn(41, typeof value)
115
117
  return
116
118
  }
117
119
  return appendJsAttribute('enduser.id', value, 'setUserId', true)
@@ -124,7 +126,7 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
124
126
  */
125
127
  apiInterface.setApplicationVersion = function (value) {
126
128
  if (!(typeof value === 'string' || value === null)) {
127
- warn(`Failed to execute setApplicationVersion. Expected <String | null>, but got <${typeof value}>.`)
129
+ warn(42, typeof value)
128
130
  return
129
131
  }
130
132
  return appendJsAttribute('application.version', value, 'setApplicationVersion', false)
@@ -135,7 +137,7 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
135
137
  handle(SUPPORTABILITY_METRIC_CHANNEL, ['API/start/called'], undefined, FEATURE_NAMES.metrics, instanceEE)
136
138
  instanceEE.emit('manual-start-all')
137
139
  } catch (err) {
138
- warn('An unexpected issue occurred', err)
140
+ warn(23, err)
139
141
  }
140
142
  }
141
143
 
@@ -210,7 +212,7 @@ export function setAPI (agentIdentifier, forceDrain, runSoftNavOverSpa = false)
210
212
  setAPI(agentIdentifier)
211
213
  drain(agentIdentifier, 'api')
212
214
  }).catch((err) => {
213
- warn('Downloading runtime APIs failed...', err)
215
+ warn(27, err)
214
216
  instanceEE.abort()
215
217
  })
216
218
  }
@@ -27,7 +27,7 @@ export function setAPI (agentIdentifier) {
27
27
  var time = providedTime ? providedTime - originTime : t
28
28
  handle(CUSTOM_METRIC_CHANNEL, ['finished', { time }], undefined, FEATURE_NAMES.metrics, instanceEE)
29
29
  addToTrace(t, { name: 'finished', start: time + originTime, origin: 'nr' })
30
- handle('api-addPageAction', [time, 'finished'], undefined, FEATURE_NAMES.pageAction, instanceEE)
30
+ handle('api-addPageAction', [time, 'finished'], undefined, FEATURE_NAMES.genericEvents, instanceEE)
31
31
  }
32
32
 
33
33
  function addToTrace (t, evt) {
@@ -7,8 +7,9 @@ import { Instrument as InstrumentErrors } from '../features/jserrors/instrument'
7
7
  import { Instrument as InstrumentXhr } from '../features/ajax/instrument'
8
8
  import { Instrument as InstrumentSessionTrace } from '../features/session_trace/instrument'
9
9
  import { Instrument as InstrumentSpa } from '../features/spa/instrument'
10
- import { Instrument as InstrumentPageAction } from '../features/page_action/instrument'
11
10
  import { Instrument as InstrumentSessionReplay } from '../features/session_replay/instrument'
11
+ import { Instrument as InstrumentGenericEvents } from '../features/generic_events/instrument'
12
+ import { Instrument as InstrumentLogs } from '../features/logging/instrument'
12
13
 
13
14
  /**
14
15
  * An agent class with all feature modules available. Features may be disabled and enabled via runtime configuration.
@@ -24,10 +25,11 @@ export class BrowserAgent extends Agent {
24
25
  InstrumentPageViewTiming,
25
26
  InstrumentSessionTrace,
26
27
  InstrumentMetrics,
27
- InstrumentPageAction,
28
28
  InstrumentErrors,
29
29
  InstrumentSpa,
30
- InstrumentSessionReplay
30
+ InstrumentSessionReplay,
31
+ InstrumentGenericEvents,
32
+ InstrumentLogs
31
33
  ],
32
34
  loaderType: 'browser-agent'
33
35
  })
@@ -4,6 +4,7 @@ import { getConfiguration, setConfiguration, setInfo, setLoaderConfig, setRuntim
4
4
  import { activatedFeatures } from '../../common/util/feature-flags'
5
5
  import { isWorkerScope } from '../../common/constants/runtime'
6
6
  import { redefinePublicPath } from './public-path'
7
+ import { ee } from '../../common/event-emitter/contextual-ee'
7
8
 
8
9
  let alreadySetOnce = false // the configure() function can run multiple times in agent lifecycle
9
10
 
@@ -12,7 +13,8 @@ let alreadySetOnce = false // the configure() function can run multiple times in
12
13
  */
13
14
  export function configure (agent, opts = {}, loaderType, forceDrain) {
14
15
  // eslint-disable-next-line camelcase
15
- let { init, info, loader_config, runtime = { loaderType }, exposed = true } = opts
16
+ let { init, info, loader_config, runtime = {}, exposed = true } = opts
17
+ runtime.loaderType = loaderType
16
18
  const nr = gosCDN()
17
19
  if (!info) {
18
20
  init = nr.init
@@ -55,6 +57,8 @@ export function configure (agent, opts = {}, loaderType, forceDrain) {
55
57
  runtime.ptid = agent.agentIdentifier
56
58
  setRuntime(agent.agentIdentifier, runtime)
57
59
 
60
+ agent.ee = ee.get(agent.agentIdentifier)
61
+
58
62
  if (agent.api === undefined) agent.api = setAPI(agent.agentIdentifier, forceDrain, agent.runSoftNavOverSpa)
59
63
  if (agent.exposed === undefined) agent.exposed = exposed
60
64
  alreadySetOnce = true
@@ -1,8 +1,12 @@
1
1
  export const FEATURE_NAMES = {
2
2
  ajax: 'ajax',
3
+ genericEvents: 'generic_events',
3
4
  jserrors: 'jserrors',
4
5
  logging: 'logging',
5
6
  metrics: 'metrics',
7
+ /**
8
+ * @deprecated This feature has been replaced by Generic Events. Use/Import `GenericEvents` instead. This wrapper will be removed in a future release
9
+ */
6
10
  pageAction: 'page_action',
7
11
  pageViewEvent: 'page_view_event',
8
12
  pageViewTiming: 'page_view_timing',
@@ -24,8 +28,8 @@ export const featurePriority = {
24
28
  [FEATURE_NAMES.spa]: 5,
25
29
  [FEATURE_NAMES.ajax]: 6,
26
30
  [FEATURE_NAMES.sessionTrace]: 7,
27
- [FEATURE_NAMES.pageAction]: 8,
28
- [FEATURE_NAMES.softNav]: 9,
29
- [FEATURE_NAMES.sessionReplay]: 10,
30
- [FEATURE_NAMES.logging]: 11
31
+ [FEATURE_NAMES.softNav]: 8,
32
+ [FEATURE_NAMES.sessionReplay]: 9,
33
+ [FEATURE_NAMES.logging]: 10,
34
+ [FEATURE_NAMES.genericEvents]: 11
31
35
  }
@@ -13,7 +13,7 @@ import { AgentBase } from './agent-base'
13
13
 
14
14
  const nonAutoFeatures = [
15
15
  FEATURE_NAMES.jserrors,
16
- FEATURE_NAMES.pageAction,
16
+ FEATURE_NAMES.genericEvents,
17
17
  FEATURE_NAMES.metrics
18
18
  ]
19
19
 
@@ -61,11 +61,11 @@ export class MicroAgent extends AgentBase {
61
61
  if (features === undefined) features = featNames
62
62
  else {
63
63
  features = Array.isArray(features) && features.length ? features : [features]
64
- if (features.some(f => !featNames.includes(f))) return warn(`Invalid feature name supplied. Acceptable feature names are: ${featNames}`)
64
+ if (features.some(f => !featNames.includes(f))) return warn(37, featNames)
65
65
  if (!features.includes(FEATURE_NAMES.pageViewEvent)) features.push(FEATURE_NAMES.pageViewEvent)
66
66
  }
67
67
  } catch (err) {
68
- warn('An unexpected issue occurred', err)
68
+ warn(23, err)
69
69
  }
70
70
 
71
71
  try {
@@ -75,7 +75,7 @@ export class MicroAgent extends AgentBase {
75
75
  // a biproduct of doing this is that the "session manager" is automatically handled through importing this feature
76
76
  this.features.page_view_event = new PVE(this.agentIdentifier, this.sharedAggregator)
77
77
  } catch (err) {
78
- warn('Something prevented the agent from instrumenting.', err)
78
+ warn(24, err)
79
79
  }
80
80
 
81
81
  onWindowLoad(() => {
@@ -87,13 +87,13 @@ export class MicroAgent extends AgentBase {
87
87
  }).then(({ Aggregate }) => {
88
88
  this.features[f] = new Aggregate(this.agentIdentifier, this.sharedAggregator)
89
89
  }).catch(err =>
90
- warn('Something prevented the agent from being downloaded.', err))
90
+ warn(25, err))
91
91
  }
92
92
  })
93
93
  })
94
94
  return true
95
95
  } catch (err) {
96
- warn('Failed to initialize instrument classes.', err)
96
+ warn(26, err)
97
97
  return false
98
98
  }
99
99
  }
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- require("../polyfills.js");
4
- var _agent = require("../../loaders/agent");
5
- var _instrument = require("../../features/page_view_event/instrument");
6
- var _instrument2 = require("../../features/page_view_timing/instrument");
7
- var _instrument3 = require("../../features/metrics/instrument");
8
- /**
9
- * @file Creates a version of the "Lite" agent loader with [core-js]{@link https://github.com/zloirock/core-js}
10
- * polyfills for pre-ES6 browsers and IE 11.
11
- */
12
-
13
- new _agent.Agent({
14
- features: [_instrument.Instrument, _instrument2.Instrument, _instrument3.Instrument],
15
- loaderType: 'lite-polyfills'
16
- });
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- require("../polyfills.js");
4
- var _agent = require("../../loaders/agent");
5
- var _instrument = require("../../features/page_view_event/instrument");
6
- var _instrument2 = require("../../features/page_view_timing/instrument");
7
- var _instrument3 = require("../../features/metrics/instrument");
8
- var _instrument4 = require("../../features/jserrors/instrument");
9
- var _instrument5 = require("../../features/ajax/instrument");
10
- var _instrument6 = require("../../features/session_trace/instrument");
11
- var _instrument7 = require("../../features/page_action/instrument");
12
- var _instrument8 = require("../../features/logging/instrument");
13
- /**
14
- * @file Creates a version of the "PRO" agent loader with [core-js]{@link https://github.com/zloirock/core-js}
15
- * polyfills for pre-ES6 browsers and IE 11.
16
- */
17
-
18
- new _agent.Agent({
19
- features: [_instrument.Instrument, _instrument2.Instrument, _instrument6.Instrument, _instrument5.Instrument, _instrument3.Instrument, _instrument7.Instrument, _instrument4.Instrument, _instrument8.Instrument],
20
- loaderType: 'pro-polyfills'
21
- });
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- require("../polyfills.js");
4
- var _agent = require("../../loaders/agent");
5
- var _instrument = require("../../features/page_view_event/instrument");
6
- var _instrument2 = require("../../features/page_view_timing/instrument");
7
- var _instrument3 = require("../../features/metrics/instrument");
8
- var _instrument4 = require("../../features/jserrors/instrument");
9
- var _instrument5 = require("../../features/ajax/instrument");
10
- var _instrument6 = require("../../features/session_trace/instrument");
11
- var _instrument7 = require("../../features/spa/instrument");
12
- var _instrument8 = require("../../features/page_action/instrument");
13
- var _instrument9 = require("../../features/logging/instrument");
14
- /**
15
- * @file Creates a version of the "SPA" agent loader with [core-js]{@link https://github.com/zloirock/core-js}
16
- * polyfills for pre-ES6 browsers and IE 11.
17
- */
18
-
19
- new _agent.Agent({
20
- features: [_instrument5.Instrument, _instrument.Instrument, _instrument2.Instrument, _instrument6.Instrument, _instrument3.Instrument, _instrument8.Instrument, _instrument4.Instrument, _instrument9.Instrument, _instrument7.Instrument],
21
- loaderType: 'spa-polyfills'
22
- });
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/stable/promise");
4
- require("core-js/stable/array/includes");
5
- require("core-js/stable/array/find");
6
- require("core-js/stable/array/flat");
7
- require("core-js/stable/array/flat-map");
8
- require("core-js/stable/array/from");
9
- require("core-js/stable/array/some");
10
- require("core-js/stable/array/find-index");
11
- require("core-js/stable/object/assign");
12
- require("core-js/stable/object/entries");
13
- require("core-js/stable/object/values");
14
- require("core-js/stable/object/from-entries");
15
- require("core-js/stable/map");
16
- require("core-js/stable/reflect");
17
- require("core-js/stable/set");
18
- require("core-js/stable/weak-set");
19
- require("core-js/stable/object/get-own-property-descriptors");
20
- require("core-js/stable/url");
21
- require("core-js/stable/url-search-params");
22
- require("core-js/stable/string/starts-with");
23
- require("core-js/stable/number/is-nan");
24
- require("core-js/stable/string/includes");
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mapOwn = void 0;
7
- /*
8
- * Copyright 2020 New Relic Corporation. All rights reserved.
9
- * SPDX-License-Identifier: Apache-2.0
10
- */
11
-
12
- /**
13
- * @typedef {function} MapOwnCallback
14
- * @param {string} key Object key
15
- * @param {any} value Object value
16
- * @returns {any}
17
- */
18
-
19
- /**
20
- * Iterates the own enumerable properties of an object passing the key and value pair to a given
21
- * callback function.
22
- * @param {object} obj Input object to iterate over. If null or undefined, an empty array will be returned.
23
- * @param {MapOwnCallback} fn A callback function called for each property. The callback should take the key
24
- * and value from the object iteration and return some value.
25
- * @returns {any[]} An array of values returned by the callback function.
26
- */
27
- const mapOwn = (obj, fn) => Object.entries(obj || {}).map(_ref => {
28
- let [key, value] = _ref;
29
- return fn(key, value);
30
- });
31
- exports.mapOwn = mapOwn;
@@ -1,121 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.Aggregate = void 0;
7
- var _mapOwn = require("../../../common/util/map-own");
8
- var _stringify = require("../../../common/util/stringify");
9
- var _registerHandler = require("../../../common/event-emitter/register-handler");
10
- var _harvestScheduler = require("../../../common/harvest/harvest-scheduler");
11
- var _cleanUrl = require("../../../common/url/clean-url");
12
- var _config = require("../../../common/config/config");
13
- var _constants = require("../constants");
14
- var _runtime = require("../../../common/constants/runtime");
15
- var _aggregateBase = require("../../utils/aggregate-base");
16
- var _drain = require("../../../common/drain/drain");
17
- /*
18
- * Copyright 2020 New Relic Corporation. All rights reserved.
19
- * SPDX-License-Identifier: Apache-2.0
20
- */
21
-
22
- class Aggregate extends _aggregateBase.AggregateBase {
23
- static featureName = _constants.FEATURE_NAME;
24
- constructor(agentIdentifier, aggregator) {
25
- var _this;
26
- super(agentIdentifier, aggregator, _constants.FEATURE_NAME);
27
- _this = this;
28
- this.eventsPerMinute = 240;
29
- this.harvestTimeSeconds = (0, _config.getConfigurationValue)(this.agentIdentifier, 'page_action.harvestTimeSeconds') || (0, _config.getConfigurationValue)(this.agentIdentifier, 'ins.harvestTimeSeconds') || 30;
30
- this.eventsPerHarvest = this.eventsPerMinute * this.harvestTimeSeconds / 60;
31
- this.referrerUrl = undefined;
32
- this.currentEvents = undefined;
33
- this.events = [];
34
- this.att = (0, _config.getInfo)(this.agentIdentifier).jsAttributes; // per-agent, aggregators-shared info context
35
-
36
- if (_runtime.isBrowserScope && document.referrer) this.referrerUrl = (0, _cleanUrl.cleanURL)(document.referrer);
37
- (0, _registerHandler.registerHandler)('api-addPageAction', function () {
38
- return _this.addPageAction(...arguments);
39
- }, this.featureName, this.ee);
40
- this.waitForFlags(['ins']).then(_ref => {
41
- let [insFlag] = _ref;
42
- if (insFlag) {
43
- const scheduler = new _harvestScheduler.HarvestScheduler('ins', {
44
- onFinished: function () {
45
- return _this.onHarvestFinished(...arguments);
46
- }
47
- }, this);
48
- scheduler.harvest.on('ins', function () {
49
- return _this.onHarvestStarted(...arguments);
50
- });
51
- scheduler.startTimer(this.harvestTimeSeconds, 0);
52
- this.drain();
53
- } else {
54
- this.blocked = true; // if rum response determines that customer lacks entitlements for ins endpoint, this feature shouldn't harvest
55
- (0, _drain.deregisterDrain)(this.agentIdentifier, this.featureName);
56
- }
57
- });
58
- }
59
- onHarvestStarted(options) {
60
- const {
61
- userAttributes,
62
- atts
63
- } = (0, _config.getInfo)(this.agentIdentifier);
64
- var payload = {
65
- qs: {
66
- ua: userAttributes,
67
- at: atts
68
- },
69
- body: {
70
- ins: this.events
71
- }
72
- };
73
- if (options.retry) {
74
- this.currentEvents = this.events;
75
- }
76
- this.events = [];
77
- return payload;
78
- }
79
- onHarvestFinished(result) {
80
- if (result && result.sent && result.retry && this.currentEvents) {
81
- this.events = this.events.concat(this.currentEvents);
82
- this.currentEvents = null;
83
- }
84
- }
85
-
86
- // WARNING: Insights times are in seconds. EXCEPT timestamp, which is in ms.
87
- addPageAction(t, name, attributes) {
88
- if (this.events.length >= this.eventsPerHarvest || this.blocked) return;
89
- var width;
90
- var height;
91
- var eventAttributes = {};
92
- if (_runtime.isBrowserScope && window.document.documentElement) {
93
- // Doesn't include the nav bar when it disappears in mobile safari
94
- // https://github.com/jquery/jquery/blob/10399ddcf8a239acc27bdec9231b996b178224d3/src/dimensions.js#L23
95
- width = window.document.documentElement.clientWidth;
96
- height = window.document.documentElement.clientHeight;
97
- }
98
- const agentRuntime = (0, _config.getRuntime)(this.agentIdentifier);
99
- var defaults = {
100
- timestamp: agentRuntime.timeKeeper.convertRelativeTimestamp(t),
101
- timeSinceLoad: t / 1000,
102
- browserWidth: width,
103
- browserHeight: height,
104
- referrerUrl: this.referrerUrl,
105
- currentUrl: (0, _cleanUrl.cleanURL)('' + location),
106
- pageUrl: (0, _cleanUrl.cleanURL)(agentRuntime.origin),
107
- eventType: 'PageAction'
108
- };
109
- (0, _mapOwn.mapOwn)(defaults, set);
110
- (0, _mapOwn.mapOwn)((0, _config.getInfo)(this.agentIdentifier).jsAttributes, set);
111
- if (attributes && typeof attributes === 'object') {
112
- (0, _mapOwn.mapOwn)(attributes, set);
113
- }
114
- eventAttributes.actionName = name || '';
115
- this.events.push(eventAttributes);
116
- function set(key, val) {
117
- eventAttributes[key] = val && typeof val === 'object' ? (0, _stringify.stringify)(val) : val;
118
- }
119
- }
120
- }
121
- exports.Aggregate = Aggregate;
@@ -1,14 +0,0 @@
1
- /**
2
- * @file Creates a version of the "Lite" agent loader with [core-js]{@link https://github.com/zloirock/core-js}
3
- * polyfills for pre-ES6 browsers and IE 11.
4
- */
5
-
6
- import '../polyfills.js';
7
- import { Agent } from '../../loaders/agent';
8
- import { Instrument as InstrumentPageViewEvent } from '../../features/page_view_event/instrument';
9
- import { Instrument as InstrumentPageViewTiming } from '../../features/page_view_timing/instrument';
10
- import { Instrument as InstrumentMetrics } from '../../features/metrics/instrument';
11
- new Agent({
12
- features: [InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentMetrics],
13
- loaderType: 'lite-polyfills'
14
- });
@@ -1,19 +0,0 @@
1
- /**
2
- * @file Creates a version of the "PRO" agent loader with [core-js]{@link https://github.com/zloirock/core-js}
3
- * polyfills for pre-ES6 browsers and IE 11.
4
- */
5
-
6
- import '../polyfills.js';
7
- import { Agent } from '../../loaders/agent';
8
- import { Instrument as InstrumentPageViewEvent } from '../../features/page_view_event/instrument';
9
- import { Instrument as InstrumentPageViewTiming } from '../../features/page_view_timing/instrument';
10
- import { Instrument as InstrumentMetrics } from '../../features/metrics/instrument';
11
- import { Instrument as InstrumentErrors } from '../../features/jserrors/instrument';
12
- import { Instrument as InstrumentXhr } from '../../features/ajax/instrument';
13
- import { Instrument as InstrumentSessionTrace } from '../../features/session_trace/instrument';
14
- import { Instrument as InstrumentPageAction } from '../../features/page_action/instrument';
15
- import { Instrument as InstrumentLogs } from '../../features/logging/instrument';
16
- new Agent({
17
- features: [InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentXhr, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentLogs],
18
- loaderType: 'pro-polyfills'
19
- });
@@ -1,20 +0,0 @@
1
- /**
2
- * @file Creates a version of the "SPA" agent loader with [core-js]{@link https://github.com/zloirock/core-js}
3
- * polyfills for pre-ES6 browsers and IE 11.
4
- */
5
-
6
- import '../polyfills.js';
7
- import { Agent } from '../../loaders/agent';
8
- import { Instrument as InstrumentPageViewEvent } from '../../features/page_view_event/instrument';
9
- import { Instrument as InstrumentPageViewTiming } from '../../features/page_view_timing/instrument';
10
- import { Instrument as InstrumentMetrics } from '../../features/metrics/instrument';
11
- import { Instrument as InstrumentErrors } from '../../features/jserrors/instrument';
12
- import { Instrument as InstrumentXhr } from '../../features/ajax/instrument';
13
- import { Instrument as InstrumentSessionTrace } from '../../features/session_trace/instrument';
14
- import { Instrument as InstrumentSpa } from '../../features/spa/instrument';
15
- import { Instrument as InstrumentPageAction } from '../../features/page_action/instrument';
16
- import { Instrument as InstrumentLogs } from '../../features/logging/instrument';
17
- new Agent({
18
- features: [InstrumentXhr, InstrumentPageViewEvent, InstrumentPageViewTiming, InstrumentSessionTrace, InstrumentMetrics, InstrumentPageAction, InstrumentErrors, InstrumentLogs, InstrumentSpa],
19
- loaderType: 'spa-polyfills'
20
- });
@@ -1,27 +0,0 @@
1
- /**
2
- * @file Selectively imports {@link https://github.com/zloirock/core-js core-js}
3
- * polyfills needed for pre-ES6 browsers and IE 11.
4
- */
5
-
6
- import 'core-js/stable/promise';
7
- import 'core-js/stable/array/includes';
8
- import 'core-js/stable/array/find';
9
- import 'core-js/stable/array/flat';
10
- import 'core-js/stable/array/flat-map';
11
- import 'core-js/stable/array/from';
12
- import 'core-js/stable/array/some';
13
- import 'core-js/stable/array/find-index';
14
- import 'core-js/stable/object/assign';
15
- import 'core-js/stable/object/entries';
16
- import 'core-js/stable/object/values';
17
- import 'core-js/stable/object/from-entries';
18
- import 'core-js/stable/map';
19
- import 'core-js/stable/reflect';
20
- import 'core-js/stable/set';
21
- import 'core-js/stable/weak-set';
22
- import 'core-js/stable/object/get-own-property-descriptors';
23
- import 'core-js/stable/url';
24
- import 'core-js/stable/url-search-params';
25
- import 'core-js/stable/string/starts-with';
26
- import 'core-js/stable/number/is-nan';
27
- import 'core-js/stable/string/includes';
@@ -1,24 +0,0 @@
1
- /*
2
- * Copyright 2020 New Relic Corporation. All rights reserved.
3
- * SPDX-License-Identifier: Apache-2.0
4
- */
5
-
6
- /**
7
- * @typedef {function} MapOwnCallback
8
- * @param {string} key Object key
9
- * @param {any} value Object value
10
- * @returns {any}
11
- */
12
-
13
- /**
14
- * Iterates the own enumerable properties of an object passing the key and value pair to a given
15
- * callback function.
16
- * @param {object} obj Input object to iterate over. If null or undefined, an empty array will be returned.
17
- * @param {MapOwnCallback} fn A callback function called for each property. The callback should take the key
18
- * and value from the object iteration and return some value.
19
- * @returns {any[]} An array of values returned by the callback function.
20
- */
21
- export const mapOwn = (obj, fn) => Object.entries(obj || {}).map(_ref => {
22
- let [key, value] = _ref;
23
- return fn(key, value);
24
- });