@newrelic/browser-agent 1.232.0 → 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 (273) 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/canonicalize-url.js +32 -0
  16. package/dist/cjs/common/url/canonicalize-url.test.js +42 -0
  17. package/dist/cjs/common/url/clean-url.js +10 -3
  18. package/dist/cjs/common/url/protocol.test.js +0 -1
  19. package/dist/cjs/common/util/feature-flags.js +2 -1
  20. package/dist/cjs/common/util/global-scope.js +4 -2
  21. package/dist/cjs/common/util/submit-data.js +57 -18
  22. package/dist/cjs/common/wrap/wrap-fetch.js +1 -3
  23. package/dist/cjs/common/wrap/wrap-function.js +1 -3
  24. package/dist/cjs/common/wrap/wrap-promise.js +1 -1
  25. package/dist/cjs/features/ajax/aggregate/index.js +2 -2
  26. package/dist/cjs/features/ajax/instrument/index.js +1 -1
  27. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +12 -4
  28. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +93 -10
  29. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +164 -38
  30. package/dist/cjs/features/jserrors/aggregate/index.js +29 -48
  31. package/dist/cjs/features/jserrors/instrument/index.js +0 -2
  32. package/dist/cjs/features/metrics/aggregate/framework-detection.js +67 -0
  33. package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +137 -0
  34. package/dist/cjs/features/metrics/aggregate/index.js +7 -3
  35. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.js +14 -0
  36. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +17 -0
  37. package/dist/cjs/features/metrics/aggregate/polyfill-detection.js +53 -0
  38. package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +165 -0
  39. package/dist/cjs/features/page_action/aggregate/index.js +2 -2
  40. package/dist/cjs/features/page_view_event/aggregate/index.js +6 -3
  41. package/dist/cjs/features/page_view_timing/aggregate/index.js +2 -2
  42. package/dist/cjs/features/session_replay/aggregate/index.js +333 -0
  43. package/dist/cjs/features/session_replay/constants.js +9 -0
  44. package/dist/cjs/features/session_replay/index.js +12 -0
  45. package/dist/cjs/features/session_replay/instrument/index.js +29 -0
  46. package/dist/cjs/features/session_trace/aggregate/index.js +163 -164
  47. package/dist/cjs/features/session_trace/constants.js +2 -9
  48. package/dist/cjs/features/session_trace/instrument/index.js +24 -66
  49. package/dist/cjs/features/spa/aggregate/index.js +2 -2
  50. package/dist/cjs/features/utils/agent-session.js +1 -2
  51. package/dist/cjs/features/utils/aggregate-base.js +64 -0
  52. package/dist/cjs/features/utils/feature-base.js +0 -31
  53. package/dist/cjs/features/utils/handler-cache.js +3 -4
  54. package/dist/cjs/features/utils/instrument-base.js +42 -10
  55. package/dist/cjs/features/utils/{lazy-loader.js → lazy-feature-loader.js} +4 -2
  56. package/dist/cjs/loaders/agent.js +1 -1
  57. package/dist/cjs/loaders/api/apiAsync.js +3 -1
  58. package/dist/cjs/loaders/configure/configure.js +3 -3
  59. package/dist/cjs/loaders/features/featureDependencies.js +0 -12
  60. package/dist/cjs/loaders/features/features.js +3 -1
  61. package/dist/cjs/loaders/micro-agent.js +6 -6
  62. package/dist/esm/cdn/polyfills.js +5 -2
  63. package/dist/esm/common/config/state/configurable.js +14 -24
  64. package/dist/esm/common/config/state/info.js +2 -2
  65. package/dist/esm/common/config/state/init.js +102 -57
  66. package/dist/esm/common/config/state/loader-config.js +2 -2
  67. package/dist/esm/common/config/state/runtime.js +2 -4
  68. package/dist/esm/common/constants/env.cdn.js +1 -1
  69. package/dist/esm/common/constants/env.npm.js +1 -1
  70. package/dist/esm/common/drain/drain.js +1 -1
  71. package/dist/esm/common/harvest/harvest-scheduler.js +30 -10
  72. package/dist/esm/common/harvest/harvest.js +121 -56
  73. package/dist/esm/common/session/session-entity.js +35 -22
  74. package/dist/esm/common/session/session-entity.test.js +73 -49
  75. package/dist/esm/common/timer/interaction-timer.js +9 -12
  76. package/dist/esm/common/url/canonicalize-url.js +27 -0
  77. package/dist/esm/common/url/canonicalize-url.test.js +38 -0
  78. package/dist/esm/common/url/clean-url.js +10 -3
  79. package/dist/esm/common/url/protocol.test.js +0 -1
  80. package/dist/esm/common/util/feature-flags.js +2 -1
  81. package/dist/esm/common/util/global-scope.js +1 -0
  82. package/dist/esm/common/util/submit-data.js +57 -18
  83. package/dist/esm/common/wrap/wrap-fetch.js +1 -2
  84. package/dist/esm/common/wrap/wrap-function.js +1 -2
  85. package/dist/esm/common/wrap/wrap-promise.js +1 -1
  86. package/dist/esm/features/ajax/aggregate/index.js +2 -2
  87. package/dist/esm/features/ajax/instrument/index.js +1 -1
  88. package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +12 -4
  89. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +93 -10
  90. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +149 -25
  91. package/dist/esm/features/jserrors/aggregate/index.js +30 -48
  92. package/dist/esm/features/jserrors/instrument/index.js +0 -1
  93. package/dist/esm/features/metrics/aggregate/framework-detection.js +61 -0
  94. package/dist/esm/features/metrics/aggregate/framework-detection.test.js +133 -0
  95. package/dist/esm/features/metrics/aggregate/index.js +7 -3
  96. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.js +8 -0
  97. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +15 -0
  98. package/dist/esm/features/metrics/aggregate/polyfill-detection.js +47 -0
  99. package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +163 -0
  100. package/dist/esm/features/page_action/aggregate/index.js +2 -2
  101. package/dist/esm/features/page_view_event/aggregate/index.js +6 -3
  102. package/dist/esm/features/page_view_timing/aggregate/index.js +2 -2
  103. package/dist/esm/features/session_replay/aggregate/index.js +327 -0
  104. package/dist/esm/features/session_replay/constants.js +2 -0
  105. package/dist/esm/features/session_replay/index.js +12 -0
  106. package/dist/esm/features/session_replay/instrument/index.js +21 -0
  107. package/dist/esm/features/session_trace/aggregate/index.js +163 -163
  108. package/dist/esm/features/session_trace/constants.js +1 -5
  109. package/dist/esm/features/session_trace/instrument/index.js +24 -66
  110. package/dist/esm/features/spa/aggregate/index.js +2 -2
  111. package/dist/esm/features/utils/agent-session.js +1 -2
  112. package/dist/esm/features/utils/aggregate-base.js +57 -0
  113. package/dist/esm/features/utils/feature-base.js +1 -32
  114. package/dist/esm/features/utils/handler-cache.js +3 -4
  115. package/dist/esm/features/utils/instrument-base.js +42 -10
  116. package/dist/esm/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
  117. package/dist/esm/loaders/agent.js +1 -1
  118. package/dist/esm/loaders/api/apiAsync.js +3 -1
  119. package/dist/esm/loaders/configure/configure.js +3 -3
  120. package/dist/esm/loaders/features/featureDependencies.js +0 -11
  121. package/dist/esm/loaders/features/features.js +3 -1
  122. package/dist/esm/loaders/micro-agent.js +6 -6
  123. package/dist/types/common/config/state/configurable.d.ts +1 -3
  124. package/dist/types/common/config/state/configurable.d.ts.map +1 -1
  125. package/dist/types/common/config/state/init.d.ts.map +1 -1
  126. package/dist/types/common/config/state/runtime.d.ts.map +1 -1
  127. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  128. package/dist/types/common/harvest/harvest.d.ts +37 -34
  129. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  130. package/dist/types/common/session/session-entity.d.ts +6 -3
  131. package/dist/types/common/session/session-entity.d.ts.map +1 -1
  132. package/dist/types/common/timer/interaction-timer.d.ts +2 -1
  133. package/dist/types/common/timer/interaction-timer.d.ts.map +1 -1
  134. package/dist/types/common/url/canonicalize-url.d.ts +9 -0
  135. package/dist/types/common/url/canonicalize-url.d.ts.map +1 -0
  136. package/dist/types/common/url/clean-url.d.ts +7 -1
  137. package/dist/types/common/url/clean-url.d.ts.map +1 -1
  138. package/dist/types/common/util/feature-flags.d.ts.map +1 -1
  139. package/dist/types/common/util/global-scope.d.ts +1 -0
  140. package/dist/types/common/util/global-scope.d.ts.map +1 -1
  141. package/dist/types/common/util/submit-data.d.ts +40 -14
  142. package/dist/types/common/util/submit-data.d.ts.map +1 -1
  143. package/dist/types/common/wrap/wrap-fetch.d.ts.map +1 -1
  144. package/dist/types/common/wrap/wrap-function.d.ts.map +1 -1
  145. package/dist/types/features/ajax/aggregate/index.d.ts +2 -2
  146. package/dist/types/features/ajax/aggregate/index.d.ts.map +1 -1
  147. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts +8 -1
  148. package/dist/types/features/jserrors/aggregate/canonical-function-name.d.ts.map +1 -1
  149. package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts +48 -19
  150. package/dist/types/features/jserrors/aggregate/compute-stack-trace.d.ts.map +1 -1
  151. package/dist/types/features/jserrors/aggregate/index.d.ts +14 -5
  152. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  153. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  154. package/dist/types/features/metrics/aggregate/framework-detection.d.ts.map +1 -0
  155. package/dist/types/features/metrics/aggregate/index.d.ts +2 -2
  156. package/dist/types/features/metrics/aggregate/index.d.ts.map +1 -1
  157. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts +6 -0
  158. package/dist/types/features/metrics/aggregate/polyfill-detection.d.ts.map +1 -0
  159. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts +7 -0
  160. package/dist/types/features/metrics/aggregate/polyfill-detection.es5.d.ts.map +1 -0
  161. package/dist/types/features/page_action/aggregate/index.d.ts +3 -3
  162. package/dist/types/features/page_action/aggregate/index.d.ts.map +1 -1
  163. package/dist/types/features/page_view_event/aggregate/index.d.ts +2 -2
  164. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  165. package/dist/types/features/page_view_timing/aggregate/index.d.ts +2 -2
  166. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  167. package/dist/types/features/session_replay/aggregate/index.d.ts +96 -0
  168. package/dist/types/features/session_replay/aggregate/index.d.ts.map +1 -0
  169. package/dist/types/features/session_replay/constants.d.ts +2 -0
  170. package/dist/types/features/session_replay/constants.d.ts.map +1 -0
  171. package/dist/types/features/session_replay/index.d.ts +2 -0
  172. package/dist/types/features/session_replay/index.d.ts.map +1 -0
  173. package/dist/types/features/session_replay/instrument/index.d.ts +6 -0
  174. package/dist/types/features/session_replay/instrument/index.d.ts.map +1 -0
  175. package/dist/types/features/session_trace/aggregate/index.d.ts +8 -57
  176. package/dist/types/features/session_trace/aggregate/index.d.ts.map +1 -1
  177. package/dist/types/features/session_trace/constants.d.ts +0 -3
  178. package/dist/types/features/session_trace/constants.d.ts.map +1 -1
  179. package/dist/types/features/session_trace/instrument/index.d.ts +1 -3
  180. package/dist/types/features/session_trace/instrument/index.d.ts.map +1 -1
  181. package/dist/types/features/spa/aggregate/index.d.ts +2 -2
  182. package/dist/types/features/spa/aggregate/index.d.ts.map +1 -1
  183. package/dist/types/features/utils/agent-session.d.ts.map +1 -1
  184. package/dist/types/features/utils/aggregate-base.d.ts +11 -0
  185. package/dist/types/features/utils/aggregate-base.d.ts.map +1 -0
  186. package/dist/types/features/utils/feature-base.d.ts +0 -5
  187. package/dist/types/features/utils/feature-base.d.ts.map +1 -1
  188. package/dist/types/features/utils/handler-cache.d.ts.map +1 -1
  189. package/dist/types/features/utils/instrument-base.d.ts +3 -1
  190. package/dist/types/features/utils/instrument-base.d.ts.map +1 -1
  191. package/dist/types/features/utils/{lazy-loader.d.ts → lazy-feature-loader.d.ts} +2 -2
  192. package/dist/types/features/utils/lazy-feature-loader.d.ts.map +1 -0
  193. package/dist/types/loaders/configure/configure.d.ts.map +1 -1
  194. package/dist/types/loaders/features/featureDependencies.d.ts +0 -1
  195. package/dist/types/loaders/features/featureDependencies.d.ts.map +1 -1
  196. package/dist/types/loaders/features/features.d.ts +1 -0
  197. package/dist/types/loaders/features/features.d.ts.map +1 -1
  198. package/package.json +31 -22
  199. package/src/cdn/polyfills.js +4 -1
  200. package/src/common/config/state/configurable.js +18 -24
  201. package/src/common/config/state/info.js +2 -2
  202. package/src/common/config/state/init.js +62 -28
  203. package/src/common/config/state/loader-config.js +2 -2
  204. package/src/common/config/state/runtime.js +2 -4
  205. package/src/common/drain/drain.js +1 -1
  206. package/src/common/harvest/harvest-scheduler.js +35 -10
  207. package/src/common/harvest/harvest.js +73 -50
  208. package/src/common/session/session-entity.js +34 -23
  209. package/src/common/session/session-entity.test.js +57 -51
  210. package/src/common/timer/interaction-timer.js +9 -12
  211. package/src/common/url/canonicalize-url.js +28 -0
  212. package/src/common/url/canonicalize-url.test.js +34 -0
  213. package/src/common/url/clean-url.js +10 -3
  214. package/src/common/url/protocol.test.js +0 -1
  215. package/src/common/util/feature-flags.js +2 -2
  216. package/src/common/util/global-scope.js +2 -0
  217. package/src/common/util/submit-data.js +28 -17
  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-promise.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 +28 -52
  227. package/src/features/jserrors/instrument/index.js +0 -1
  228. package/src/features/metrics/aggregate/framework-detection.js +73 -0
  229. package/src/features/metrics/aggregate/framework-detection.test.js +201 -0
  230. package/src/features/metrics/aggregate/index.js +8 -3
  231. package/src/features/metrics/aggregate/polyfill-detection.es5.js +9 -0
  232. package/src/features/metrics/aggregate/polyfill-detection.es5.test.js +16 -0
  233. package/src/features/metrics/aggregate/polyfill-detection.js +48 -0
  234. package/src/features/metrics/aggregate/polyfill-detection.test.js +163 -0
  235. package/src/features/page_action/aggregate/index.js +2 -2
  236. package/src/features/page_view_event/aggregate/index.js +5 -5
  237. package/src/features/page_view_timing/aggregate/index.js +2 -2
  238. package/src/features/session_replay/aggregate/index.js +314 -0
  239. package/src/features/session_replay/constants.js +3 -0
  240. package/src/features/session_replay/index.js +12 -0
  241. package/src/features/session_replay/instrument/index.js +22 -0
  242. package/src/features/session_trace/aggregate/index.js +148 -188
  243. package/src/features/session_trace/constants.js +0 -4
  244. package/src/features/session_trace/instrument/index.js +17 -69
  245. package/src/features/spa/aggregate/index.js +2 -2
  246. package/src/features/utils/agent-session.js +1 -2
  247. package/src/features/utils/aggregate-base.js +51 -0
  248. package/src/features/utils/feature-base.js +1 -31
  249. package/src/features/utils/handler-cache.js +3 -4
  250. package/src/features/utils/instrument-base.js +40 -8
  251. package/src/features/utils/{lazy-loader.js → lazy-feature-loader.js} +3 -1
  252. package/src/loaders/agent.js +1 -1
  253. package/src/loaders/api/apiAsync.js +1 -1
  254. package/src/loaders/configure/configure.js +4 -3
  255. package/src/loaders/features/featureDependencies.js +0 -12
  256. package/src/loaders/features/features.js +3 -1
  257. package/src/loaders/micro-agent.js +4 -4
  258. package/dist/cjs/common/metrics/framework-detection.js +0 -72
  259. package/dist/cjs/common/util/user-agent.js +0 -57
  260. package/dist/cjs/common/window/supports-performance-observer.js +0 -15
  261. package/dist/esm/common/metrics/framework-detection.js +0 -66
  262. package/dist/esm/common/util/user-agent.js +0 -48
  263. package/dist/esm/common/window/supports-performance-observer.js +0 -9
  264. package/dist/types/common/metrics/framework-detection.d.ts.map +0 -1
  265. package/dist/types/common/util/user-agent.d.ts +0 -5
  266. package/dist/types/common/util/user-agent.d.ts.map +0 -1
  267. package/dist/types/common/window/supports-performance-observer.d.ts +0 -2
  268. package/dist/types/common/window/supports-performance-observer.d.ts.map +0 -1
  269. package/dist/types/features/utils/lazy-loader.d.ts.map +0 -1
  270. package/src/common/metrics/framework-detection.js +0 -71
  271. package/src/common/util/user-agent.js +0 -56
  272. package/src/common/window/supports-performance-observer.js +0 -10
  273. /package/dist/types/{common/metrics → features/metrics/aggregate}/framework-detection.d.ts +0 -0
@@ -4,8 +4,6 @@
4
4
  */
5
5
  import { handle } from '../../../common/event-emitter/handle'
6
6
  import { wrapHistory, wrapEvents, wrapTimer, wrapRaf } from '../../../common/wrap'
7
- import { supportsPerformanceObserver } from '../../../common/window/supports-performance-observer'
8
- import { eventListenerOpts } from '../../../common/event-listener/event-listener-opts'
9
7
  import { now } from '../../../common/timing/now'
10
8
  import { InstrumentBase } from '../../utils/instrument-base'
11
9
  import * as CONSTANTS from '../constants'
@@ -13,10 +11,8 @@ import { FEATURE_NAMES } from '../../../loaders/features/features'
13
11
  import { isBrowserScope } from '../../../common/util/global-scope'
14
12
 
15
13
  const {
16
- BST_RESOURCE, BST_TIMER, END, FEATURE_NAME, FN_END, FN_START, ADD_EVENT_LISTENER,
17
- PUSH_STATE, RESOURCE, RESOURCE_TIMING_BUFFER_FULL, START, ORIG_EVENT: origEvent
14
+ BST_RESOURCE, RESOURCE, BST_TIMER, START, END, FEATURE_NAME, FN_END, FN_START, PUSH_STATE
18
15
  } = CONSTANTS
19
- const CRT = 'clearResourceTimings'
20
16
 
21
17
  export class Instrument extends InstrumentBase {
22
18
  static featureName = FEATURE_NAME
@@ -28,29 +24,21 @@ export class Instrument extends InstrumentBase {
28
24
  this.timerEE = wrapTimer(thisInstrumentEE)
29
25
  this.rafEE = wrapRaf(thisInstrumentEE)
30
26
  wrapHistory(thisInstrumentEE)
31
- wrapEvents(thisInstrumentEE)
27
+ this.eventsEE = wrapEvents(thisInstrumentEE)
32
28
 
33
- thisInstrumentEE.on(FN_START, function (args, target) {
34
- var evt = args[0]
35
- if (evt instanceof origEvent) {
36
- this.bstStart = now()
37
- }
29
+ this.eventsEE.on(FN_START, function (args, target) {
30
+ this.bstStart = now()
38
31
  })
39
-
40
- thisInstrumentEE.on(FN_END, function (args, target) {
41
- var evt = args[0]
42
- if (evt instanceof origEvent) {
43
- // ISSUE: when target is XMLHttpRequest, nr@context should have params so we can calculate event origin
44
- // When ajax is disabled, this may fail without making ajax a dependency of session_trace
45
- handle('bst', [evt, target, this.bstStart, now()], undefined, FEATURE_NAMES.sessionTrace, thisInstrumentEE)
46
- }
32
+ this.eventsEE.on(FN_END, function (args, target) {
33
+ // ISSUE: when target is XMLHttpRequest, nr@context should have params so we can calculate event origin
34
+ // When ajax is disabled, this may fail without making ajax a dependency of session_trace
35
+ handle('bst', [args[0], target, this.bstStart, now()], undefined, FEATURE_NAMES.sessionTrace, thisInstrumentEE)
47
36
  })
48
37
 
49
38
  this.timerEE.on(FN_START, function (args, obj, type) {
50
39
  this.bstStart = now()
51
40
  this.bstType = type
52
41
  })
53
-
54
42
  this.timerEE.on(FN_END, function (args, target) {
55
43
  handle(BST_TIMER, [target, this.bstStart, now(), this.bstType], undefined, FEATURE_NAMES.sessionTrace, thisInstrumentEE)
56
44
  })
@@ -58,7 +46,6 @@ export class Instrument extends InstrumentBase {
58
46
  this.rafEE.on(FN_START, function () {
59
47
  this.bstStart = now()
60
48
  })
61
-
62
49
  this.rafEE.on(FN_END, function (args, target) {
63
50
  handle(BST_TIMER, [target, this.bstStart, now(), 'requestAnimationFrame'], undefined, FEATURE_NAMES.sessionTrace, thisInstrumentEE)
64
51
  })
@@ -71,57 +58,18 @@ export class Instrument extends InstrumentBase {
71
58
  handle('bstHist', [location.pathname + location.hash, this.startPath, this.time], undefined, FEATURE_NAMES.sessionTrace, thisInstrumentEE)
72
59
  })
73
60
 
74
- if (supportsPerformanceObserver()) {
75
- // capture initial resources, in case our observer missed anything
76
- handle(BST_RESOURCE, [window.performance.getEntriesByType('resource')], undefined, FEATURE_NAMES.sessionTrace, thisInstrumentEE)
77
-
78
- observeResourceTimings()
79
- } else {
80
- // collect resource timings once when buffer is full
81
- if (window.performance[CRT] && window.performance[ADD_EVENT_LISTENER]) {
82
- window.performance.addEventListener(RESOURCE_TIMING_BUFFER_FULL, this.onResourceTimingBufferFull, eventListenerOpts(false))
83
- }
84
- }
85
-
86
- function observeResourceTimings () {
87
- var observer = new PerformanceObserver((list, observer) => { // eslint-disable-line no-undef
88
- var entries = list.getEntries()
89
-
61
+ let observer
62
+ try {
63
+ // Capture initial resources and watch for future ones. Don't defer this given there's a default cap on the number of buffered entries.
64
+ observer = new PerformanceObserver((list) => { // eslint-disable-line no-undef
65
+ const entries = list.getEntries()
90
66
  handle(BST_RESOURCE, [entries], undefined, FEATURE_NAMES.sessionTrace, thisInstrumentEE)
91
67
  })
92
-
93
- try {
94
- observer.observe({ entryTypes: ['resource'] })
95
- } catch (e) {
96
- // do nothing
97
- }
68
+ observer.observe({ type: RESOURCE, buffered: true })
69
+ } catch (e) {
70
+ // Per NEWRELIC-8525, we don't have a fallback for capturing resources for older versions that don't support PO at this time.
98
71
  }
99
72
 
100
- document.addEventListener('scroll', this.noOp, eventListenerOpts(false))
101
- document.addEventListener('keypress', this.noOp, eventListenerOpts(false))
102
- document.addEventListener('click', this.noOp, eventListenerOpts(false))
103
-
104
- this.abortHandler = this.#abort
105
- this.importAggregator()
106
- }
107
-
108
- /** Restoration and resource release tasks to be done if Session trace loader is being aborted. Unwind changes to globals. */
109
- #abort () {
110
- window.performance.removeEventListener(RESOURCE_TIMING_BUFFER_FULL, this.onResourceTimingBufferFull, false)
111
- // The doc interaction noOp listeners are harmless--cannot buffer data into EE.
112
- this.abortHandler = undefined // weakly allow this abort op to run only once
113
- }
114
-
115
- noOp (e) { /* no-op */ }
116
-
117
- onResourceTimingBufferFull (evt) {
118
- handle(BST_RESOURCE, [window.performance.getEntriesByType(RESOURCE)], undefined, FEATURE_NAMES.sessionTrace, this.ee)
119
-
120
- // stop recording once buffer is full
121
- if (window.performance[CRT]) {
122
- try {
123
- window.performance.removeEventListener(RESOURCE_TIMING_BUFFER_FULL, this.onResourceTimingBufferFull, false)
124
- } catch (e) {}
125
- }
73
+ this.importAggregator({ resourceObserver: observer })
126
74
  }
127
75
  }
@@ -19,13 +19,13 @@ import { ee } from '../../../common/event-emitter/contextual-ee'
19
19
  import * as CONSTANTS from '../constants'
20
20
  import { drain } from '../../../common/drain/drain'
21
21
  import { FEATURE_NAMES } from '../../../loaders/features/features'
22
- import { FeatureBase } from '../../utils/feature-base'
22
+ import { AggregateBase } from '../../utils/aggregate-base'
23
23
 
24
24
  const {
25
25
  FEATURE_NAME, INTERACTION_EVENTS, MAX_TIMER_BUDGET, FN_START, FN_END, CB_START, INTERACTION_API, REMAINING,
26
26
  INTERACTION, SPA_NODE, JSONP_NODE, FETCH_START, FETCH_DONE, FETCH_BODY, JSONP_END, originalSetTimeout
27
27
  } = CONSTANTS
28
- export class Aggregate extends FeatureBase {
28
+ export class Aggregate extends AggregateBase {
29
29
  static featureName = FEATURE_NAME
30
30
  constructor (agentIdentifier, aggregator) {
31
31
  super(agentIdentifier, aggregator, FEATURE_NAME)
@@ -6,7 +6,6 @@ import { isBrowserScope } from '../../common/util/global-scope'
6
6
  import { SessionEntity } from '../../common/session/session-entity'
7
7
  import { LocalStorage } from '../../common/storage/local-storage.js'
8
8
  import { FirstPartyCookies } from '../../common/storage/first-party-cookies'
9
- import { LocalMemory } from '../../common/storage/local-memory'
10
9
 
11
10
  let ranOnce = 0
12
11
  export function setupAgentSession (agentIdentifier) {
@@ -41,7 +40,7 @@ export function setupAgentSession (agentIdentifier) {
41
40
  // that's currently stored in the storage API into the local info.jsAttributes object
42
41
  if (isBrowserScope) {
43
42
  // retrieve & re-add all of the persisted setCustomAttribute|setUserId k-v from previous page load(s)
44
- const customSessionData = agentRuntime.session?.read?.()?.custom
43
+ const customSessionData = agentRuntime.session.state.custom
45
44
  const agentInfo = getInfo(agentIdentifier)
46
45
  if (customSessionData) {
47
46
  setInfo(agentIdentifier, { ...agentInfo, jsAttributes: { ...agentInfo.jsAttributes, ...customSessionData } })
@@ -0,0 +1,51 @@
1
+ import { registerHandler } from '../../common/event-emitter/register-handler'
2
+ import { FeatureBase } from './feature-base'
3
+ import { getInfo, isConfigured, getRuntime } from '../../common/config/config'
4
+ import { configure } from '../../loaders/configure/configure'
5
+ import { gosCDN } from '../../common/window/nreum'
6
+
7
+ export class AggregateBase extends FeatureBase {
8
+ constructor (...args) {
9
+ super(...args)
10
+ this.checkConfiguration()
11
+ }
12
+
13
+ waitForFlags (flagNames = []) {
14
+ return Promise.all(flagNames.map(fName => new Promise((resolve) => {
15
+ registerHandler(`feat-${fName}`, () => {
16
+ resolve({ name: fName, value: true })
17
+ }, this.featureName, this.ee)
18
+ registerHandler(`block-${fName}`, () => {
19
+ resolve({ name: fName, value: false })
20
+ }, this.feature, this.ee)
21
+ })
22
+ ))
23
+ }
24
+
25
+ /**
26
+ * Checks for additional `jsAttributes` items to support backward compatibility with implementations of the agent where
27
+ * loader configurations may appear after the loader code is executed.
28
+ */
29
+ checkConfiguration () {
30
+ // NOTE: This check has to happen at aggregator load time
31
+ if (!isConfigured(this.agentIdentifier)) {
32
+ let jsAttributes = { ...gosCDN().info?.jsAttributes }
33
+ try {
34
+ jsAttributes = {
35
+ ...jsAttributes,
36
+ ...getInfo(this.agentIdentifier)?.jsAttributes
37
+ }
38
+ } catch (err) {
39
+ // do nothing
40
+ }
41
+ configure(this.agentIdentifier, {
42
+ ...gosCDN(),
43
+ info: {
44
+ ...gosCDN().info,
45
+ jsAttributes
46
+ },
47
+ runtime: getRuntime(this.agentIdentifier)
48
+ })
49
+ }
50
+ }
51
+ }
@@ -1,7 +1,5 @@
1
- import { getInfo, isConfigured, getRuntime } from '../../common/config/config'
1
+ import { getRuntime } from '../../common/config/config'
2
2
  import { ee } from '../../common/event-emitter/contextual-ee'
3
- import { configure } from '../../loaders/configure/configure'
4
- import { gosCDN } from '../../common/window/nreum'
5
3
 
6
4
  export class FeatureBase {
7
5
  constructor (agentIdentifier, aggregator, featureName) {
@@ -19,33 +17,5 @@ export class FeatureBase {
19
17
  * @type {boolean}
20
18
  */
21
19
  this.blocked = false
22
-
23
- this.checkConfiguration()
24
- }
25
-
26
- /**
27
- * Checks for additional `jsAttributes` items to support backward compatibility with implementations of the agent where
28
- * loader configurations may appear after the loader code is executed.
29
- */
30
- checkConfiguration () {
31
- // NOTE: This check has to happen at aggregator load time
32
- if (!isConfigured(this.agentIdentifier)) {
33
- let jsAttributes = { ...gosCDN().info?.jsAttributes }
34
- try {
35
- jsAttributes = {
36
- ...jsAttributes,
37
- ...getInfo(this.agentIdentifier)?.jsAttributes
38
- }
39
- } catch (err) {
40
- // do nothing
41
- }
42
- configure(this.agentIdentifier, {
43
- ...gosCDN(),
44
- info: {
45
- ...gosCDN().info,
46
- jsAttributes
47
- }
48
- })
49
- }
50
20
  }
51
21
  }
@@ -5,8 +5,6 @@
5
5
  export class HandlerCache {
6
6
  /** @private @type {boolean | undefined} */
7
7
  #decision = undefined
8
- /** @private @type {boolean} */
9
- #shouldsettle = true
10
8
  /** @private @type {Function[]} */
11
9
  #cache = []
12
10
  /** @private @type {Timeout} */
@@ -29,7 +27,7 @@ export class HandlerCache {
29
27
  * @private
30
28
  */
31
29
  #close () {
32
- this.#shouldsettle = false
30
+ this.#decision = false // settle() & decide() cannot be used after close
33
31
  this.#cache = []
34
32
  }
35
33
 
@@ -39,7 +37,7 @@ export class HandlerCache {
39
37
  * @returns {void}
40
38
  */
41
39
  settle (handler) {
42
- if (this.#decision === false || this.#shouldsettle === false) return
40
+ if (this.#decision === false) return
43
41
  else if (this.#decision === undefined) this.#cache.push(handler)
44
42
  else handler()
45
43
  }
@@ -53,6 +51,7 @@ export class HandlerCache {
53
51
  * @param {boolean} decision
54
52
  */
55
53
  decide (decision) {
54
+ if (this.#decision !== undefined) return // a decision can only be made once
56
55
  this.#decision = decision
57
56
  if (decision === false) this.#close()
58
57
  if (decision === true) this.#drain()
@@ -4,11 +4,13 @@
4
4
  * exposes the `blocked` property.
5
5
  */
6
6
 
7
- import { registerDrain } from '../../common/drain/drain'
7
+ import { drain, registerDrain } from '../../common/drain/drain'
8
8
  import { FeatureBase } from './feature-base'
9
9
  import { onWindowLoad } from '../../common/window/load'
10
10
  import { isWorkerScope } from '../../common/util/global-scope'
11
11
  import { warn } from '../../common/util/console'
12
+ import { FEATURE_NAMES } from '../../loaders/features/features'
13
+ import { getConfigurationValue } from '../../common/config/config'
12
14
 
13
15
  /**
14
16
  * Base class for instrumenting a feature.
@@ -38,11 +40,19 @@ export class InstrumentBase extends FeatureBase {
38
40
  /**
39
41
  * Lazy-load the latter part of the feature: its aggregator. This method is called by the first part of the feature
40
42
  * (the instrumentation) when instrumentation is complete.
43
+ * @param {Object} [argsObjFromInstrument] - any values or references to pass down to aggregate
44
+ * @returns void
41
45
  */
42
- importAggregator () {
46
+ importAggregator (argsObjFromInstrument) {
43
47
  if (this.hasAggregator || !this.auto) return
44
48
  this.hasAggregator = true
45
-
49
+ let session, agentSessionImport
50
+ if (getConfigurationValue(this.agentIdentifier, 'privacy.cookies_enabled') === true && !isWorkerScope) {
51
+ agentSessionImport = import(/* webpackChunkName: "session-manager" */ './agent-session')
52
+ .catch(err => {
53
+ warn('failed to import the session manager', err)
54
+ })
55
+ }
46
56
  const importLater = async () => {
47
57
  /**
48
58
  * Note this try-catch differs from the one in Agent.start() in that it's placed later in a page's lifecycle and
@@ -50,12 +60,19 @@ export class InstrumentBase extends FeatureBase {
50
60
  */
51
61
  try {
52
62
  // The session entity needs to be attached to the config internals before the aggregator chunk runs
53
- const { setupAgentSession } = await import(/* webpackChunkName: "session-manager" */ './agent-session')
54
- setupAgentSession(this.agentIdentifier)
63
+ if (agentSessionImport && !session) {
64
+ const { setupAgentSession } = await agentSessionImport
65
+ session = setupAgentSession(this.agentIdentifier)
66
+ }
67
+ if (!shouldImportAgg(this.featureName, session)) {
68
+ drain(this.agentIdentifier, this.featureName)
69
+ return
70
+ }
71
+
55
72
  // import and instantiate the aggregator chunk
56
- const { lazyLoader } = await import(/* webpackChunkName: "lazy-loader" */ './lazy-loader')
57
- const { Aggregate } = await lazyLoader(this.featureName, 'aggregate')
58
- new Aggregate(this.agentIdentifier, this.aggregator)
73
+ const { lazyFeatureLoader } = await import(/* webpackChunkName: "lazy-feature-loader" */ './lazy-feature-loader')
74
+ const { Aggregate } = await lazyFeatureLoader(this.featureName, 'aggregate')
75
+ new Aggregate(this.agentIdentifier, this.aggregator, argsObjFromInstrument)
59
76
  } catch (e) {
60
77
  warn(`Downloading ${this.featureName} failed...`, e)
61
78
  this.abortHandler?.() // undo any important alterations made to the page
@@ -69,3 +86,18 @@ export class InstrumentBase extends FeatureBase {
69
86
  else onWindowLoad(() => importLater(), true)
70
87
  }
71
88
  }
89
+ /**
90
+ * Make a determination if an aggregate class should even be imported
91
+ * @param {string} featureName
92
+ * @param {SessionEntity} session
93
+ * @returns
94
+ */
95
+ function shouldImportAgg (featureName, session) {
96
+ // if this isnt the FIRST load of a session AND
97
+ // we are not actively recording SR... DO NOT run the aggregator
98
+ // session replay samples can only be decided on the first load of a session
99
+ // session replays can continue if in progress
100
+ if (featureName === FEATURE_NAMES.sessionReplay) return !!session?.isNew || !!session?.state.sessionReplayActive
101
+ // todo -- add case like above for session trace
102
+ return true
103
+ }
@@ -11,7 +11,7 @@ import { FEATURE_NAMES } from '../../loaders/features/features'
11
11
  * @param featurePart Name of the feature part to load; should be either instrument or aggregate
12
12
  * @returns {Promise<InstrumentBase|FeatureBase|null>}
13
13
  */
14
- export function lazyLoader (featureName, featurePart) {
14
+ export function lazyFeatureLoader (featureName, featurePart) {
15
15
  if (featurePart === 'aggregate') {
16
16
  switch (featureName) {
17
17
  case FEATURE_NAMES.ajax:
@@ -26,6 +26,8 @@ export function lazyLoader (featureName, featurePart) {
26
26
  return import(/* webpackChunkName: "page_view_event-aggregate" */ '../page_view_event/aggregate')
27
27
  case FEATURE_NAMES.pageViewTiming:
28
28
  return import(/* webpackChunkName: "page_view_timing-aggregate" */ '../page_view_timing/aggregate')
29
+ case FEATURE_NAMES.sessionReplay:
30
+ return import(/* webpackChunkName: "session_replay-aggregate" */ '../session_replay/aggregate')
29
31
  case FEATURE_NAMES.sessionTrace:
30
32
  return import(/* webpackChunkName: "session_trace-aggregate" */ '../session_trace/aggregate')
31
33
  case FEATURE_NAMES.spa:
@@ -49,7 +49,7 @@ export class Agent {
49
49
  // Attempt to initialize all the requested features (sequentially in prio order & synchronously), with any failure aborting the whole process.
50
50
  try {
51
51
  const enabledFeatures = getEnabledFeatures(this.agentIdentifier)
52
- const featuresToStart = Array.from(this.desiredFeatures)
52
+ const featuresToStart = [...this.desiredFeatures]
53
53
  featuresToStart.sort((a, b) => featurePriority[a.featureName] - featurePriority[b.featureName])
54
54
  featuresToStart.forEach(f => {
55
55
  // pageViewEvent must be enabled because RUM calls are not optional. See comment in constructor and PR 428.
@@ -78,7 +78,7 @@ export function setAPI (agentIdentifier) {
78
78
  url += 'fe=' + ~~fe_time + '&'
79
79
  url += 'c=' + cycle
80
80
 
81
- submitData.img(url)
81
+ submitData.img({ url })
82
82
  }
83
83
 
84
84
  function setErrorHandler (t, handler) {
@@ -13,15 +13,16 @@ export function configure (agentIdentifier, opts = {}, loaderType, forceDrain) {
13
13
  loader_config = nr.loader_config
14
14
  }
15
15
 
16
+ setConfiguration(agentIdentifier, init || {})
17
+ setLoaderConfig(agentIdentifier, loader_config || {})
18
+ setRuntime(agentIdentifier, runtime)
19
+
16
20
  info.jsAttributes ??= {}
17
21
  if (isWorkerScope) { // add a default attr to all worker payloads
18
22
  info.jsAttributes.isWorker = true
19
23
  }
20
24
 
21
25
  setInfo(agentIdentifier, info)
22
- setConfiguration(agentIdentifier, init || {})
23
- setLoaderConfig(agentIdentifier, loader_config || {})
24
- setRuntime(agentIdentifier, runtime)
25
26
 
26
27
  setTopLevelCallers()
27
28
  const api = setAPI(agentIdentifier, forceDrain)
@@ -12,15 +12,3 @@ export function getFeatureDependencyNames (feature) {
12
12
  return []
13
13
  }
14
14
  }
15
-
16
- export function getFrozenAttributes (feature) {
17
- switch (feature) {
18
- // right now, jserrors is the only feature that can have "on" or "off" page-level auto-instrumentation...
19
- // page_action is always "off" (no instr)
20
- // as new API/manual implementation methods are added, this list can likely be pruned
21
- case FEATURE_NAMES.jserrors:
22
- return []
23
- default:
24
- return ['auto']
25
- }
26
- }
@@ -5,6 +5,7 @@ export const FEATURE_NAMES = {
5
5
  pageAction: 'page_action',
6
6
  pageViewEvent: 'page_view_event',
7
7
  pageViewTiming: 'page_view_timing',
8
+ sessionReplay: 'session_replay',
8
9
  sessionTrace: 'session_trace',
9
10
  spa: 'spa'
10
11
  }
@@ -21,5 +22,6 @@ export const featurePriority = {
21
22
  [FEATURE_NAMES.ajax]: 5,
22
23
  [FEATURE_NAMES.sessionTrace]: 6,
23
24
  [FEATURE_NAMES.pageAction]: 7,
24
- [FEATURE_NAMES.spa]: 8
25
+ [FEATURE_NAMES.spa]: 8,
26
+ [FEATURE_NAMES.sessionReplay]: 9
25
27
  }
@@ -54,8 +54,8 @@ export class MicroAgent {
54
54
  autoFeatures.forEach(f => {
55
55
  if (enabledFeatures[f]) {
56
56
  // TODO - THIS does not work, the instrument switch in lazy loader increases the size of the worker build. Needs to be revisited
57
- import(/* webpackChunkName: "lazy-loader" */ '../features/utils/lazy-loader').then(({ lazyLoader }) => {
58
- return lazyLoader(f, 'instrument')
57
+ import(/* webpackChunkName: "lazy-feature-loader" */ '../features/utils/lazy-feature-loader').then(({ lazyFeatureLoader }) => {
58
+ return lazyFeatureLoader(f, 'instrument')
59
59
  }).then(({ Instrument }) => {
60
60
  this.features[f] = new Instrument(this.agentIdentifier, this.sharedAggregator)
61
61
  }).catch(err =>
@@ -66,8 +66,8 @@ export class MicroAgent {
66
66
  if (enabledFeatures[f]) {
67
67
  // TODO - THIS does not work, the instrument switch in lazy loader increases the size of the worker build. Needs to be revisited
68
68
  // Parts of the lazy-loader were removed because webpack was transpiling them into the worker build, errantly inflating the build size.
69
- import(/* webpackChunkName: "lazy-loader" */ '../features/utils/lazy-loader').then(({ lazyLoader }) => {
70
- return lazyLoader(f, 'aggregate')
69
+ import(/* webpackChunkName: "lazy-feature-loader" */ '../features/utils/lazy-feature-loader').then(({ lazyFeatureLoader }) => {
70
+ return lazyFeatureLoader(f, 'aggregate')
71
71
  }).then(({ Aggregate }) => {
72
72
  this.features[f] = new Aggregate(this.agentIdentifier, this.sharedAggregator)
73
73
  }).catch(err =>
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getFrameworks = getFrameworks;
7
- var _globalScope = require("../util/global-scope");
8
- var FRAMEWORKS = {
9
- REACT: 'React',
10
- ANGULAR: 'Angular',
11
- ANGULARJS: 'AngularJS',
12
- BACKBONE: 'Backbone',
13
- EMBER: 'Ember',
14
- VUE: 'Vue',
15
- METEOR: 'Meteor',
16
- ZEPTO: 'Zepto',
17
- JQUERY: 'Jquery'
18
- };
19
- function getFrameworks() {
20
- if (!_globalScope.isBrowserScope) return []; // don't bother detecting frameworks if not in the main window context
21
-
22
- var frameworks = [];
23
- try {
24
- if (detectReact()) frameworks.push(FRAMEWORKS.REACT);
25
- if (detectAngularJs()) frameworks.push(FRAMEWORKS.ANGULARJS);
26
- if (detectAngular()) frameworks.push(FRAMEWORKS.ANGULAR);
27
- if (window.Backbone) frameworks.push(FRAMEWORKS.BACKBONE);
28
- if (window.Ember) frameworks.push(FRAMEWORKS.EMBER);
29
- if (window.Vue) frameworks.push(FRAMEWORKS.VUE);
30
- if (window.Meteor) frameworks.push(FRAMEWORKS.METEOR);
31
- if (window.Zepto) frameworks.push(FRAMEWORKS.ZEPTO);
32
- if (window.jQuery) frameworks.push(FRAMEWORKS.JQUERY);
33
- } catch (err) {
34
- // not supported?
35
- }
36
- return frameworks;
37
- }
38
- function detectReact() {
39
- try {
40
- if (!!window.React || !!window.ReactDOM || !!window.ReactRedux) return true;
41
- if (document.querySelector('[data-reactroot], [data-reactid]')) return true;
42
- var divs = document.querySelectorAll('body > div');
43
- for (var i = 0; i < divs.length; i++) {
44
- if (Object.keys(divs[i]).indexOf('_reactRootContainer') >= 0) return true;
45
- }
46
- return false;
47
- } catch (err) {
48
- // not supported?
49
- return false;
50
- }
51
- }
52
- function detectAngularJs() {
53
- try {
54
- if (window.angular) return true;
55
- if (document.querySelector('.ng-binding, [ng-app], [data-ng-app], [ng-controller], [data-ng-controller], [ng-repeat], [data-ng-repeat]')) return true;
56
- if (document.querySelector('script[src*="angular.js"], script[src*="angular.min.js"]')) return true;
57
- return false;
58
- } catch (err) {
59
- // not supported?
60
- return false;
61
- }
62
- }
63
- function detectAngular() {
64
- try {
65
- // eslint-disable-next-line
66
- if (window.hasOwnProperty('ng') && window.ng.hasOwnProperty('coreTokens') && window.ng.coreTokens.hasOwnProperty('NgZone')) return true;
67
- return !!document.querySelectorAll('[ng-version]').length;
68
- } catch (err) {
69
- // not supported?
70
- return false;
71
- }
72
- }
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.agent = void 0;
7
- exports.match = match;
8
- exports.version = void 0;
9
- /*
10
- * Copyright 2020 New Relic Corporation. All rights reserved.
11
- * SPDX-License-Identifier: Apache-2.0
12
- */
13
-
14
- // Feature-detection is much preferred over using User Agent to detect browser.
15
- // However, there are cases where feature detection is not possible, for example
16
- // when a specific version of a browser has a bug that requires a workaround in just
17
- // that version.
18
- // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#Browser_Name
19
- var agentName = null;
20
- exports.agent = agentName;
21
- var agentVersion = null;
22
- exports.version = agentVersion;
23
- const safari = /Version\/(\S+)\s+Safari/;
24
- if (navigator.userAgent) {
25
- var userAgent = navigator.userAgent;
26
- var parts = userAgent.match(safari);
27
- if (parts && userAgent.indexOf('Chrome') === -1 && userAgent.indexOf('Chromium') === -1) {
28
- exports.agent = agentName = 'Safari';
29
- exports.version = agentVersion = parts[1];
30
- }
31
- }
32
- function match(name, version) {
33
- if (!agentName) {
34
- return false;
35
- }
36
- if (name !== agentName) {
37
- return false;
38
- }
39
-
40
- // version not provided, only match by name
41
- if (!version) {
42
- return true;
43
- }
44
-
45
- // version provided, but not detected - not reliable match
46
- if (!agentVersion) {
47
- return false;
48
- }
49
- var detectedParts = agentVersion.split('.');
50
- var requestedParts = version.split('.');
51
- for (var i = 0; i < requestedParts.length; i++) {
52
- if (requestedParts[i] !== detectedParts[i]) {
53
- return false;
54
- }
55
- }
56
- return true;
57
- }
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.supportsPerformanceObserver = supportsPerformanceObserver;
7
- var _globalScope = require("../util/global-scope");
8
- /*
9
- * Copyright 2020 New Relic Corporation. All rights reserved.
10
- * SPDX-License-Identifier: Apache-2.0
11
- */
12
-
13
- function supportsPerformanceObserver() {
14
- return typeof _globalScope.globalScope?.PerformanceObserver === 'function';
15
- }