@newrelic/browser-agent 0.0.9 → 0.1.229

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 (339) hide show
  1. package/README.md +84 -207
  2. package/dist/cjs/cdn/lite.js +14 -0
  3. package/dist/cjs/cdn/polyfills/lite.js +4 -0
  4. package/dist/cjs/cdn/polyfills/pro.js +4 -0
  5. package/dist/cjs/cdn/polyfills/spa.js +4 -0
  6. package/dist/cjs/cdn/polyfills.js +14 -0
  7. package/dist/cjs/cdn/pro.js +19 -0
  8. package/dist/cjs/cdn/spa.js +19 -0
  9. package/dist/cjs/cdn/worker.js +16 -0
  10. package/dist/cjs/common/aggregate/aggregator.js +168 -0
  11. package/dist/cjs/common/browser-version/firefox-version.js +17 -0
  12. package/dist/cjs/common/browser-version/ios-version.js +18 -0
  13. package/dist/cjs/common/config/config.js +76 -0
  14. package/dist/cjs/common/config/state/configurable.js +32 -0
  15. package/dist/cjs/common/config/state/info.js +50 -0
  16. package/dist/cjs/common/config/state/init.js +86 -0
  17. package/dist/cjs/common/config/state/loader-config.js +28 -0
  18. package/dist/cjs/common/config/state/originals.js +9 -0
  19. package/dist/cjs/common/config/state/runtime.js +50 -0
  20. package/dist/cjs/common/constants/environment-variables.js +20 -0
  21. package/dist/cjs/common/context/shared-context.js +25 -0
  22. package/dist/cjs/common/deny-list/deny-list.js +108 -0
  23. package/dist/cjs/common/drain/drain.js +126 -0
  24. package/dist/cjs/common/event-emitter/contextual-ee.js +149 -0
  25. package/dist/cjs/common/event-emitter/handle.js +24 -0
  26. package/dist/cjs/common/event-emitter/register-handler.js +24 -0
  27. package/dist/cjs/common/event-listener/event-listener-opts.js +46 -0
  28. package/dist/cjs/common/harvest/harvest-scheduler.js +111 -0
  29. package/dist/cjs/common/harvest/harvest.js +236 -0
  30. package/dist/cjs/common/ids/id.js +30 -0
  31. package/dist/cjs/common/ids/unique-id.js +84 -0
  32. package/dist/cjs/common/metrics/framework-detection.js +72 -0
  33. package/dist/cjs/common/metrics/paint-metrics.js +13 -0
  34. package/dist/cjs/common/serialize/bel-serializer.js +89 -0
  35. package/dist/cjs/common/timing/nav-timing.js +77 -0
  36. package/dist/cjs/common/timing/now.js +15 -0
  37. package/dist/cjs/common/unload/eol.js +69 -0
  38. package/dist/cjs/common/url/clean-url.js +16 -0
  39. package/dist/cjs/common/url/encode.js +79 -0
  40. package/dist/cjs/common/url/location.js +14 -0
  41. package/dist/cjs/common/url/parse-url.js +66 -0
  42. package/dist/cjs/common/url/protocol.js +25 -0
  43. package/dist/cjs/common/util/console.js +17 -0
  44. package/dist/cjs/common/util/data-size.js +25 -0
  45. package/dist/cjs/common/util/feature-flags.js +42 -0
  46. package/dist/cjs/common/util/get-or-set.js +39 -0
  47. package/dist/cjs/common/util/global-scope.js +56 -0
  48. package/dist/cjs/common/util/map-own.js +24 -0
  49. package/dist/cjs/common/util/obfuscate.js +76 -0
  50. package/dist/cjs/common/util/reduce.js +22 -0
  51. package/dist/cjs/common/util/s-hash.js +19 -0
  52. package/dist/cjs/common/util/single.js +23 -0
  53. package/dist/cjs/common/util/stringify.js +47 -0
  54. package/dist/cjs/common/util/submit-data.js +99 -0
  55. package/dist/cjs/common/util/traverse.js +41 -0
  56. package/dist/cjs/common/util/user-agent.js +57 -0
  57. package/dist/cjs/common/window/load.js +19 -0
  58. package/dist/cjs/common/window/nreum.js +107 -0
  59. package/dist/cjs/common/window/page-visibility.js +28 -0
  60. package/dist/cjs/common/window/session-storage.js +42 -0
  61. package/dist/cjs/common/window/supports-performance-observer.js +15 -0
  62. package/dist/cjs/common/window/top-level-callers.js +23 -0
  63. package/dist/cjs/common/wrap/index.js +68 -0
  64. package/dist/cjs/common/wrap/wrap-events.js +105 -0
  65. package/dist/cjs/common/wrap/wrap-fetch.js +114 -0
  66. package/dist/cjs/common/wrap/wrap-function.js +269 -0
  67. package/dist/cjs/common/wrap/wrap-history.js +56 -0
  68. package/dist/cjs/common/wrap/wrap-jsonp.js +129 -0
  69. package/dist/cjs/common/wrap/wrap-mutation.js +61 -0
  70. package/dist/cjs/common/wrap/wrap-promise.js +160 -0
  71. package/dist/cjs/common/wrap/wrap-raf.js +55 -0
  72. package/dist/cjs/common/wrap/wrap-timer.js +70 -0
  73. package/dist/cjs/common/wrap/wrap-xhr.js +206 -0
  74. package/dist/cjs/features/ajax/aggregate/index.js +226 -0
  75. package/dist/cjs/features/ajax/constants.js +9 -0
  76. package/dist/cjs/features/ajax/index.js +12 -0
  77. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +145 -0
  78. package/dist/cjs/features/ajax/instrument/index.js +338 -0
  79. package/dist/cjs/features/ajax/instrument/response-size.js +26 -0
  80. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.js +18 -0
  81. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +30 -0
  82. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.js +216 -0
  83. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +257 -0
  84. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.js +36 -0
  85. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +39 -0
  86. package/dist/cjs/features/jserrors/aggregate/index.js +267 -0
  87. package/dist/cjs/features/jserrors/aggregate/string-hash-code.js +23 -0
  88. package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +26 -0
  89. package/dist/cjs/features/jserrors/constants.js +11 -0
  90. package/dist/cjs/features/jserrors/index.js +12 -0
  91. package/dist/cjs/features/jserrors/instrument/debug.js +40 -0
  92. package/dist/cjs/features/jserrors/instrument/index.js +158 -0
  93. package/dist/cjs/features/metrics/aggregate/index.js +136 -0
  94. package/dist/cjs/features/metrics/constants.js +17 -0
  95. package/dist/cjs/features/metrics/index.js +12 -0
  96. package/dist/cjs/features/metrics/instrument/index.js +20 -0
  97. package/dist/cjs/features/metrics/instrument/workers-helper.js +121 -0
  98. package/dist/cjs/features/page_action/aggregate/index.js +112 -0
  99. package/dist/cjs/features/page_action/constants.js +9 -0
  100. package/dist/cjs/features/page_action/index.js +12 -0
  101. package/dist/cjs/features/page_action/instrument/index.js +21 -0
  102. package/dist/cjs/features/page_view_event/aggregate/index.js +133 -0
  103. package/dist/cjs/features/page_view_event/aggregate/initialized-features.js +39 -0
  104. package/dist/cjs/features/page_view_event/constants.js +15 -0
  105. package/dist/cjs/features/page_view_event/index.js +12 -0
  106. package/dist/cjs/features/page_view_event/instrument/index.js +38 -0
  107. package/dist/cjs/features/page_view_timing/aggregate/index.js +265 -0
  108. package/dist/cjs/features/page_view_timing/constants.js +9 -0
  109. package/dist/cjs/features/page_view_timing/first-paint.js +50 -0
  110. package/dist/cjs/features/page_view_timing/index.js +12 -0
  111. package/dist/cjs/features/page_view_timing/instrument/index.js +36 -0
  112. package/dist/cjs/features/page_view_timing/long-tasks.js +75 -0
  113. package/dist/cjs/features/session_trace/aggregate/index.js +375 -0
  114. package/dist/cjs/features/session_trace/constants.js +32 -0
  115. package/dist/cjs/features/session_trace/index.js +12 -0
  116. package/dist/cjs/features/session_trace/instrument/index.js +133 -0
  117. package/dist/cjs/features/spa/aggregate/index.js +684 -0
  118. package/dist/cjs/features/spa/aggregate/interaction-node.js +84 -0
  119. package/dist/cjs/features/spa/aggregate/interaction-node.test.js +16 -0
  120. package/dist/cjs/features/spa/aggregate/interaction.js +98 -0
  121. package/dist/cjs/features/spa/aggregate/serializer.js +147 -0
  122. package/dist/cjs/features/spa/constants.js +53 -0
  123. package/dist/cjs/features/spa/index.js +12 -0
  124. package/dist/cjs/features/spa/instrument/index.js +114 -0
  125. package/dist/cjs/features/utils/aggregate-base.js +13 -0
  126. package/dist/cjs/features/utils/feature-base.js +58 -0
  127. package/dist/cjs/features/utils/handler-cache.js +64 -0
  128. package/dist/cjs/features/utils/instrument-base.js +71 -0
  129. package/dist/cjs/features/utils/lazy-loader.js +44 -0
  130. package/dist/cjs/index.js +81 -58
  131. package/dist/cjs/loaders/agent.js +86 -0
  132. package/dist/cjs/loaders/api/api.js +109 -0
  133. package/dist/cjs/loaders/api/apiAsync.js +94 -0
  134. package/dist/cjs/loaders/browser-agent.js +29 -0
  135. package/dist/cjs/loaders/configure/configure.js +47 -0
  136. package/dist/cjs/loaders/features/enabled-features.js +19 -0
  137. package/dist/cjs/loaders/features/featureDependencies.js +32 -0
  138. package/dist/cjs/loaders/features/features.js +33 -0
  139. package/dist/cjs/loaders/micro-agent.js +93 -0
  140. package/dist/cjs/loaders/worker-agent.js +24 -0
  141. package/dist/esm/cdn/lite.js +12 -0
  142. package/dist/esm/cdn/polyfills/lite.js +7 -0
  143. package/dist/esm/cdn/polyfills/pro.js +7 -0
  144. package/dist/esm/cdn/polyfills/spa.js +7 -0
  145. package/dist/esm/cdn/polyfills.js +17 -0
  146. package/dist/esm/cdn/pro.js +17 -0
  147. package/dist/esm/cdn/spa.js +17 -0
  148. package/dist/esm/cdn/worker.js +14 -0
  149. package/dist/esm/common/aggregate/aggregator.js +161 -0
  150. package/dist/esm/common/browser-version/firefox-version.js +10 -0
  151. package/dist/esm/common/browser-version/ios-version.js +10 -0
  152. package/dist/esm/common/config/config.js +11 -0
  153. package/dist/esm/common/config/state/configurable.js +25 -0
  154. package/dist/esm/common/config/state/info.js +42 -0
  155. package/dist/esm/common/config/state/init.js +78 -0
  156. package/dist/esm/common/config/state/loader-config.js +21 -0
  157. package/dist/esm/common/config/state/originals.js +2 -0
  158. package/dist/esm/common/config/state/runtime.js +41 -0
  159. package/dist/esm/common/constants/environment-variables.js +11 -0
  160. package/dist/esm/common/context/shared-context.js +18 -0
  161. package/dist/esm/common/deny-list/deny-list.js +101 -0
  162. package/dist/esm/common/drain/drain.js +119 -0
  163. package/dist/esm/common/event-emitter/contextual-ee.js +142 -0
  164. package/dist/esm/common/event-emitter/handle.js +16 -0
  165. package/dist/esm/common/event-emitter/register-handler.js +19 -0
  166. package/dist/esm/common/event-listener/event-listener-opts.js +39 -0
  167. package/dist/esm/common/harvest/harvest-scheduler.js +105 -0
  168. package/dist/esm/common/harvest/harvest.js +228 -0
  169. package/dist/esm/common/ids/id.js +23 -0
  170. package/dist/esm/common/ids/unique-id.js +75 -0
  171. package/dist/esm/common/metrics/framework-detection.js +66 -0
  172. package/dist/esm/common/metrics/paint-metrics.js +6 -0
  173. package/dist/esm/common/serialize/bel-serializer.js +80 -0
  174. package/dist/esm/common/timing/nav-timing.js +67 -0
  175. package/dist/esm/common/timing/now.js +9 -0
  176. package/dist/esm/common/unload/eol.js +62 -0
  177. package/dist/esm/common/url/clean-url.js +10 -0
  178. package/dist/esm/common/url/encode.js +71 -0
  179. package/dist/esm/common/url/location.js +8 -0
  180. package/dist/esm/common/url/parse-url.js +60 -0
  181. package/dist/esm/common/url/protocol.js +17 -0
  182. package/dist/esm/common/util/console.js +11 -0
  183. package/dist/esm/common/util/data-size.js +19 -0
  184. package/dist/esm/common/util/feature-flags.js +33 -0
  185. package/dist/esm/common/util/get-or-set.js +33 -0
  186. package/dist/esm/common/util/global-scope.js +44 -0
  187. package/dist/esm/common/util/map-own.js +18 -0
  188. package/dist/esm/common/util/obfuscate.js +67 -0
  189. package/dist/esm/common/util/reduce.js +16 -0
  190. package/dist/esm/common/util/s-hash.js +13 -0
  191. package/dist/esm/common/util/single.js +16 -0
  192. package/dist/esm/common/util/stringify.js +42 -0
  193. package/dist/esm/common/util/submit-data.js +91 -0
  194. package/dist/esm/common/util/traverse.js +35 -0
  195. package/dist/esm/common/util/user-agent.js +48 -0
  196. package/dist/esm/common/window/load.js +12 -0
  197. package/dist/esm/common/window/nreum.js +91 -0
  198. package/dist/esm/common/window/page-visibility.js +23 -0
  199. package/dist/esm/common/window/session-storage.js +36 -0
  200. package/dist/esm/common/window/supports-performance-observer.js +9 -0
  201. package/dist/esm/common/window/top-level-callers.js +17 -0
  202. package/dist/esm/common/wrap/index.js +14 -0
  203. package/dist/esm/common/wrap/wrap-events.js +97 -0
  204. package/dist/esm/common/wrap/wrap-fetch.js +105 -0
  205. package/dist/esm/common/wrap/wrap-function.js +257 -0
  206. package/dist/esm/common/wrap/wrap-history.js +48 -0
  207. package/dist/esm/common/wrap/wrap-jsonp.js +122 -0
  208. package/dist/esm/common/wrap/wrap-mutation.js +54 -0
  209. package/dist/esm/common/wrap/wrap-promise.js +153 -0
  210. package/dist/esm/common/wrap/wrap-raf.js +48 -0
  211. package/dist/esm/common/wrap/wrap-timer.js +63 -0
  212. package/dist/esm/common/wrap/wrap-xhr.js +199 -0
  213. package/dist/esm/features/ajax/aggregate/index.js +218 -0
  214. package/dist/esm/features/ajax/constants.js +2 -0
  215. package/dist/esm/features/ajax/index.js +1 -0
  216. package/dist/esm/features/ajax/instrument/distributed-tracing.js +137 -0
  217. package/dist/esm/features/ajax/instrument/index.js +330 -0
  218. package/dist/esm/features/ajax/instrument/response-size.js +19 -0
  219. package/dist/esm/features/jserrors/aggregate/canonical-function-name.js +12 -0
  220. package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +28 -0
  221. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.js +209 -0
  222. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +255 -0
  223. package/dist/esm/features/jserrors/aggregate/format-stack-trace.js +29 -0
  224. package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +37 -0
  225. package/dist/esm/features/jserrors/aggregate/index.js +260 -0
  226. package/dist/esm/features/jserrors/aggregate/string-hash-code.js +17 -0
  227. package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +24 -0
  228. package/dist/esm/features/jserrors/constants.js +3 -0
  229. package/dist/esm/features/jserrors/index.js +1 -0
  230. package/dist/esm/features/jserrors/instrument/debug.js +38 -0
  231. package/dist/esm/features/jserrors/instrument/index.js +150 -0
  232. package/dist/esm/features/metrics/aggregate/index.js +129 -0
  233. package/dist/esm/features/metrics/constants.js +6 -0
  234. package/dist/esm/features/metrics/index.js +1 -0
  235. package/dist/esm/features/metrics/instrument/index.js +13 -0
  236. package/dist/esm/features/metrics/instrument/workers-helper.js +116 -0
  237. package/dist/esm/features/page_action/aggregate/index.js +105 -0
  238. package/dist/esm/features/page_action/constants.js +2 -0
  239. package/dist/esm/features/page_action/index.js +1 -0
  240. package/dist/esm/features/page_action/instrument/index.js +14 -0
  241. package/dist/esm/features/page_view_event/aggregate/index.js +124 -0
  242. package/dist/esm/features/page_view_event/aggregate/initialized-features.js +34 -0
  243. package/dist/esm/features/page_view_event/constants.js +5 -0
  244. package/dist/esm/features/page_view_event/index.js +1 -0
  245. package/dist/esm/features/page_view_event/instrument/index.js +29 -0
  246. package/dist/esm/features/page_view_timing/aggregate/index.js +258 -0
  247. package/dist/esm/features/page_view_timing/constants.js +2 -0
  248. package/dist/esm/features/page_view_timing/first-paint.js +43 -0
  249. package/dist/esm/features/page_view_timing/index.js +1 -0
  250. package/dist/esm/features/page_view_timing/instrument/index.js +28 -0
  251. package/dist/esm/features/page_view_timing/long-tasks.js +69 -0
  252. package/dist/esm/features/session_trace/aggregate/index.js +366 -0
  253. package/dist/esm/features/session_trace/constants.js +14 -0
  254. package/dist/esm/features/session_trace/index.js +1 -0
  255. package/dist/esm/features/session_trace/instrument/index.js +123 -0
  256. package/dist/esm/features/spa/aggregate/index.js +674 -0
  257. package/dist/esm/features/spa/aggregate/interaction-node.js +78 -0
  258. package/dist/esm/features/spa/aggregate/interaction-node.test.js +14 -0
  259. package/dist/esm/features/spa/aggregate/interaction.js +92 -0
  260. package/dist/esm/features/spa/aggregate/serializer.js +139 -0
  261. package/dist/esm/features/spa/constants.js +25 -0
  262. package/dist/esm/features/spa/index.js +1 -0
  263. package/dist/esm/features/spa/instrument/index.js +104 -0
  264. package/dist/esm/features/utils/aggregate-base.js +6 -0
  265. package/dist/esm/features/utils/feature-base.js +51 -0
  266. package/dist/esm/features/utils/handler-cache.js +57 -0
  267. package/dist/esm/features/utils/instrument-base.js +69 -0
  268. package/dist/esm/features/utils/lazy-loader.js +37 -0
  269. package/dist/esm/index.js +15 -0
  270. package/dist/esm/loaders/agent.js +77 -0
  271. package/dist/esm/loaders/api/api.js +104 -0
  272. package/dist/esm/loaders/api/apiAsync.js +88 -0
  273. package/dist/esm/loaders/browser-agent.js +23 -0
  274. package/dist/esm/loaders/configure/configure.js +41 -0
  275. package/dist/esm/loaders/features/enabled-features.js +13 -0
  276. package/dist/esm/loaders/features/featureDependencies.js +25 -0
  277. package/dist/esm/loaders/features/features.js +25 -0
  278. package/dist/esm/loaders/micro-agent.js +86 -0
  279. package/dist/esm/loaders/worker-agent.js +18 -0
  280. package/package.json +204 -71
  281. package/types.ts +221 -0
  282. package/dist/bundled/es5/index.js +0 -2
  283. package/dist/bundled/es5/index.js.map +0 -1
  284. package/dist/bundled/es6/index.js +0 -2
  285. package/dist/bundled/es6/index.js.map +0 -1
  286. package/dist/cjs/index.d.ts +0 -19
  287. package/dist/cjs/index.js.map +0 -1
  288. package/dist/cjs/types.d.ts +0 -94
  289. package/dist/cjs/types.js +0 -28
  290. package/dist/cjs/types.js.map +0 -1
  291. package/dist/cjs/utils/api/api.d.ts +0 -10
  292. package/dist/cjs/utils/api/api.js +0 -40
  293. package/dist/cjs/utils/api/api.js.map +0 -1
  294. package/dist/cjs/utils/config/build-configs.d.ts +0 -6
  295. package/dist/cjs/utils/config/build-configs.js +0 -68
  296. package/dist/cjs/utils/config/build-configs.js.map +0 -1
  297. package/dist/cjs/utils/features/features.d.ts +0 -5
  298. package/dist/cjs/utils/features/features.js +0 -14
  299. package/dist/cjs/utils/features/features.js.map +0 -1
  300. package/dist/cjs/utils/features/initialize.d.ts +0 -5
  301. package/dist/cjs/utils/features/initialize.js +0 -51
  302. package/dist/cjs/utils/features/initialize.js.map +0 -1
  303. package/dist/es/index.d.ts +0 -19
  304. package/dist/es/index.js +0 -55
  305. package/dist/es/index.js.map +0 -1
  306. package/dist/es/types.d.ts +0 -94
  307. package/dist/es/types.js +0 -24
  308. package/dist/es/types.js.map +0 -1
  309. package/dist/es/utils/api/api.d.ts +0 -10
  310. package/dist/es/utils/api/api.js +0 -36
  311. package/dist/es/utils/api/api.js.map +0 -1
  312. package/dist/es/utils/config/build-configs.d.ts +0 -6
  313. package/dist/es/utils/config/build-configs.js +0 -64
  314. package/dist/es/utils/config/build-configs.js.map +0 -1
  315. package/dist/es/utils/features/features.d.ts +0 -5
  316. package/dist/es/utils/features/features.js +0 -10
  317. package/dist/es/utils/features/features.js.map +0 -1
  318. package/dist/es/utils/features/initialize.d.ts +0 -5
  319. package/dist/es/utils/features/initialize.js +0 -24
  320. package/dist/es/utils/features/initialize.js.map +0 -1
  321. package/dist/umd/index.d.ts +0 -19
  322. package/dist/umd/index.js +0 -69
  323. package/dist/umd/index.js.map +0 -1
  324. package/dist/umd/types.d.ts +0 -94
  325. package/dist/umd/types.js +0 -38
  326. package/dist/umd/types.js.map +0 -1
  327. package/dist/umd/utils/api/api.d.ts +0 -10
  328. package/dist/umd/utils/api/api.js +0 -50
  329. package/dist/umd/utils/api/api.js.map +0 -1
  330. package/dist/umd/utils/config/build-configs.d.ts +0 -6
  331. package/dist/umd/utils/config/build-configs.js +0 -78
  332. package/dist/umd/utils/config/build-configs.js.map +0 -1
  333. package/dist/umd/utils/features/features.d.ts +0 -5
  334. package/dist/umd/utils/features/features.js +0 -24
  335. package/dist/umd/utils/features/features.js.map +0 -1
  336. package/dist/umd/utils/features/initialize.d.ts +0 -5
  337. package/dist/umd/utils/features/initialize.js +0 -63
  338. package/dist/umd/utils/features/initialize.js.map +0 -1
  339. package/dist/webpack-analysis.html +0 -38
@@ -0,0 +1,199 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ /**
6
+ * @file Wraps AJAX (XHR) related methods for instrumentation.
7
+ * This module is used by: ajax, jserrors, spa.
8
+ */
9
+
10
+ import { wrapEvents, unwrapEvents } from './wrap-events';
11
+ import { ee as contextualEE } from '../event-emitter/contextual-ee';
12
+ import { eventListenerOpts } from '../event-listener/event-listener-opts';
13
+ import { createWrapperWithEmitter as wfn, unwrapFunction } from './wrap-function';
14
+ import { originals } from '../config/config';
15
+ import { globalScope } from '../util/global-scope';
16
+ import { warn } from '../util/console';
17
+ const wrapped = {};
18
+ const XHR_PROPS = ['open', 'send']; // these are the specific funcs being wrapped on all XMLHttpRequests(.prototype)
19
+
20
+ /**
21
+ * Wraps the native XMLHttpRequest (XHR) object to emit custom events to its readystatechange event and an assortment
22
+ * of handlers. Adds instrumentation in context of a new event emitter scoped only to XHR.
23
+ * @param {Object} sharedEE - The shared event emitter on which a new scoped event emitter will be based.
24
+ * @returns {Object} Scoped event emitter with a debug ID of `xhr`.
25
+ */
26
+ // eslint-disable-next-line
27
+ export function wrapXhr(sharedEE) {
28
+ var baseEE = sharedEE || contextualEE;
29
+ const ee = scopedEE(baseEE);
30
+ if (wrapped[ee.debugId]++)
31
+ // Notice if our wrapping never ran yet, the falsey NaN will not early return; but if it has,
32
+ {
33
+ return ee;
34
+ } // then we increment the count to track # of feats using this at runtime.
35
+ wrapped[ee.debugId] = 1; // <- otherwise, first feature to wrap XHR
36
+
37
+ wrapEvents(baseEE); // wrap-events patches XMLHttpRequest.prototype.addEventListener for us
38
+ var wrapFn = wfn(ee);
39
+ var OrigXHR = originals.XHR;
40
+ var MutationObserver = originals.MO;
41
+ var Promise = originals.PR;
42
+ var setImmediate = originals.SI;
43
+ var READY_STATE_CHANGE = 'readystatechange';
44
+ var handlers = ['onload', 'onerror', 'onabort', 'onloadstart', 'onloadend', 'onprogress', 'ontimeout'];
45
+ var pendingXhrs = [];
46
+ var activeListeners = globalScope.XMLHttpRequest.listeners;
47
+ var XHR = globalScope.XMLHttpRequest = newXHR;
48
+ function newXHR(opts) {
49
+ var xhr = new OrigXHR(opts);
50
+ this.listeners = activeListeners ? [...activeListeners, intercept] : [intercept];
51
+ function intercept() {
52
+ try {
53
+ ee.emit('new-xhr', [xhr], xhr);
54
+ xhr.addEventListener(READY_STATE_CHANGE, wrapXHR, eventListenerOpts(false));
55
+ } catch (e) {
56
+ warn('An error occured while intercepting XHR', e);
57
+ try {
58
+ ee.emit('internal-error', [e]);
59
+ } catch (err) {
60
+ // do nothing
61
+ }
62
+ }
63
+ }
64
+ this.listeners.forEach(listener => listener());
65
+ return xhr;
66
+ }
67
+ copy(OrigXHR, XHR);
68
+ XHR.prototype = OrigXHR.prototype;
69
+ wrapFn.inPlace(XHR.prototype, XHR_PROPS, '-xhr-', getObject);
70
+ ee.on('send-xhr-start', function (args, xhr) {
71
+ wrapOnreadystatechange(args, xhr);
72
+ enqueuePendingXhr(xhr);
73
+ });
74
+ ee.on('open-xhr-start', wrapOnreadystatechange);
75
+ function wrapOnreadystatechange(args, xhr) {
76
+ wrapFn.inPlace(xhr, ['onreadystatechange'], 'fn-', getObject);
77
+ }
78
+ function wrapXHR() {
79
+ var xhr = this;
80
+ var ctx = ee.context(xhr);
81
+ if (xhr.readyState > 3 && !ctx.resolved) {
82
+ ctx.resolved = true;
83
+ ee.emit('xhr-resolved', [], xhr);
84
+ }
85
+ wrapFn.inPlace(xhr, handlers, 'fn-', getObject);
86
+ }
87
+
88
+ // Wrapping the onreadystatechange property of XHRs takes some special tricks.
89
+ //
90
+ // The issue is that the onreadystatechange property may be assigned *after*
91
+ // send() is called against an XHR. This is of particular importance because
92
+ // jQuery uses a single onreadystatechange handler to implement all of the XHR
93
+ // callbacks thtat it provides, and it assigns that property after calling send.
94
+ //
95
+ // There are several 'obvious' approaches to wrapping the onreadystatechange
96
+ // when it's assigned after send:
97
+ //
98
+ // 1. Try to wrap the onreadystatechange handler from a readystatechange
99
+ // addEventListener callback (the addEventListener callback will fire before
100
+ // the onreadystatechange callback).
101
+ //
102
+ // Caveat: this doesn't work in Chrome or Safari, and in fact will cause
103
+ // the onreadystatechange handler to not be invoked at all during the
104
+ // firing cycle in which it is wrapped, which may break applications :(
105
+ //
106
+ // 2. Use Object.defineProperty to create a setter for the onreadystatechange
107
+ // property, and wrap from that setter.
108
+ //
109
+ // Caveat: onreadystatechange is not a configurable property in Safari or
110
+ // older versions of the Android browser.
111
+ //
112
+ // 3. Schedule wrapping of the onreadystatechange property using a setTimeout
113
+ // call issued just before the call to send.
114
+ //
115
+ // Caveat: sometimes, the onreadystatechange handler fires before the
116
+ // setTimeout, meaning the wrapping happens too late.
117
+ //
118
+ // The setTimeout approach is closest to what we use here: we want to schedule
119
+ // the wrapping of the onreadystatechange property when send is called, but
120
+ // ensure that our wrapping happens before onreadystatechange has a chance to
121
+ // fire.
122
+ //
123
+ // We achieve this using a hybrid approach:
124
+ //
125
+ // * In browsers that support MutationObserver, we use that to schedule wrapping
126
+ // of onreadystatechange.
127
+ //
128
+ // * We have discovered that MutationObserver in IE causes a memory leak, so we
129
+ // now will prefer setImmediate for IE, and use a resolved promise to schedule
130
+ // the wrapping in Edge (and other browsers that support promises)
131
+ //
132
+ // * In older browsers that don't support MutationObserver, we rely on the fact
133
+ // that the call to send is probably happening within a callback that we've
134
+ // already wrapped, and use our existing fn-end event callback to wrap the
135
+ // onreadystatechange at the end of the current callback.
136
+ //
137
+
138
+ if (MutationObserver) {
139
+ var resolved = Promise && Promise.resolve();
140
+ if (!setImmediate && !Promise) {
141
+ var toggle = 1;
142
+ var dummyNode = document.createTextNode(toggle);
143
+ new MutationObserver(drainPendingXhrs).observe(dummyNode, {
144
+ characterData: true
145
+ });
146
+ }
147
+ } else {
148
+ // this below case applies to web workers too
149
+ baseEE.on('fn-end', function (args) {
150
+ // We don't want to try to wrap onreadystatechange from within a
151
+ // readystatechange callback.
152
+ if (args[0] && args[0].type === READY_STATE_CHANGE) return;
153
+ drainPendingXhrs();
154
+ });
155
+ }
156
+ function enqueuePendingXhr(xhr) {
157
+ pendingXhrs.push(xhr);
158
+ if (MutationObserver) {
159
+ if (resolved) {
160
+ resolved.then(drainPendingXhrs);
161
+ } else if (setImmediate) {
162
+ setImmediate(drainPendingXhrs);
163
+ } else {
164
+ toggle = -toggle;
165
+ dummyNode.data = toggle;
166
+ }
167
+ }
168
+ }
169
+ function drainPendingXhrs() {
170
+ for (var i = 0; i < pendingXhrs.length; i++) {
171
+ wrapOnreadystatechange([], pendingXhrs[i]);
172
+ }
173
+ if (pendingXhrs.length) pendingXhrs = [];
174
+ }
175
+
176
+ // Use the object these methods are on as their
177
+ // context store for the event emitter
178
+ function getObject(args, obj) {
179
+ return obj;
180
+ }
181
+ function copy(from, to) {
182
+ for (var i in from) {
183
+ to[i] = from[i];
184
+ }
185
+ return to;
186
+ }
187
+ return ee;
188
+ }
189
+
190
+ /**
191
+ * Returns an event emitter scoped specifically for the `xhr` context. This scoping is a remnant from when all the
192
+ * features shared the same group in the event, to isolate events between features. It will likely be revisited.
193
+ * @param {Object} sharedEE - Optional event emitter on which to base the scoped emitter.
194
+ * Uses `ee` on the global scope if undefined).
195
+ * @returns {Object} Scoped event emitter with a debug ID of 'xhr'.
196
+ */
197
+ export function scopedEE(sharedEE) {
198
+ return (sharedEE || contextualEE).get('xhr');
199
+ }
@@ -0,0 +1,218 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { registerHandler as register } from '../../../common/event-emitter/register-handler';
6
+ import { stringify } from '../../../common/util/stringify';
7
+ import { nullable, numeric, getAddStringContext, addCustomAttributes } from '../../../common/serialize/bel-serializer';
8
+ import { handle } from '../../../common/event-emitter/handle';
9
+ import { getConfigurationValue, getInfo } from '../../../common/config/config';
10
+ import { HarvestScheduler } from '../../../common/harvest/harvest-scheduler';
11
+ import { setDenyList, shouldCollectEvent } from '../../../common/deny-list/deny-list';
12
+ import { AggregateBase } from '../../utils/aggregate-base';
13
+ import { FEATURE_NAME } from '../constants';
14
+ import { drain } from '../../../common/drain/drain';
15
+ import { FEATURE_NAMES } from '../../../loaders/features/features';
16
+ import { SUPPORTABILITY_METRIC_CHANNEL } from '../../metrics/constants';
17
+ export class Aggregate extends AggregateBase {
18
+ static featureName = FEATURE_NAME;
19
+ constructor(agentIdentifier, aggregator) {
20
+ super(agentIdentifier, aggregator, FEATURE_NAME);
21
+ let ajaxEvents = [];
22
+ let spaAjaxEvents = {};
23
+ let sentAjaxEvents = [];
24
+ let scheduler;
25
+ const ee = this.ee;
26
+ const harvestTimeSeconds = getConfigurationValue(agentIdentifier, 'ajax.harvestTimeSeconds') || 10;
27
+ const MAX_PAYLOAD_SIZE = getConfigurationValue(agentIdentifier, 'ajax.maxPayloadSize') || 1000000;
28
+
29
+ // Exposes these methods to browser test files -- future TO DO: can be removed once these fns are extracted from the constructor into class func
30
+ this.storeXhr = storeXhr;
31
+ this.prepareHarvest = prepareHarvest;
32
+ this.getStoredEvents = function () {
33
+ return {
34
+ ajaxEvents,
35
+ spaAjaxEvents
36
+ };
37
+ };
38
+ ee.on('interactionSaved', interaction => {
39
+ if (!spaAjaxEvents[interaction.id]) return;
40
+ // remove from the spaAjaxEvents buffer, and let spa harvest it
41
+ delete spaAjaxEvents[interaction.id];
42
+ });
43
+ ee.on('interactionDiscarded', interaction => {
44
+ if (!spaAjaxEvents[interaction.id] || !allAjaxIsEnabled()) return;
45
+ spaAjaxEvents[interaction.id].forEach(function (item) {
46
+ // move it from the spaAjaxEvents buffer to the ajaxEvents buffer for harvesting here
47
+ ajaxEvents.push(item);
48
+ });
49
+ delete spaAjaxEvents[interaction.id];
50
+ });
51
+ if (allAjaxIsEnabled()) setDenyList(getConfigurationValue(agentIdentifier, 'ajax.deny_list'));
52
+ register('xhr', storeXhr, this.featureName, this.ee);
53
+ if (allAjaxIsEnabled()) {
54
+ scheduler = new HarvestScheduler('events', {
55
+ onFinished: onEventsHarvestFinished,
56
+ getPayload: prepareHarvest
57
+ }, this);
58
+ ee.on(`drain-${this.featureName}`, () => {
59
+ scheduler.startTimer(harvestTimeSeconds);
60
+ });
61
+ }
62
+ function storeXhr(params, metrics, startTime, endTime, type) {
63
+ metrics.time = startTime;
64
+
65
+ // send to session traces
66
+ var hash;
67
+ if (params.cat) {
68
+ hash = stringify([params.status, params.cat]);
69
+ } else {
70
+ hash = stringify([params.status, params.host, params.pathname]);
71
+ }
72
+ handle('bstXhrAgg', ['xhr', hash, params, metrics], undefined, FEATURE_NAMES.sessionTrace, ee);
73
+
74
+ // store as metric
75
+ aggregator.store('xhr', hash, params, metrics);
76
+ if (!allAjaxIsEnabled()) {
77
+ return;
78
+ }
79
+ if (!shouldCollectEvent(params)) {
80
+ if (params.hostname === getInfo(agentIdentifier).errorBeacon) {
81
+ handle(SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/Agent'], undefined, FEATURE_NAMES.metrics, ee);
82
+ } else {
83
+ handle(SUPPORTABILITY_METRIC_CHANNEL, ['Ajax/Events/Excluded/App'], undefined, FEATURE_NAMES.metrics, ee);
84
+ }
85
+ return;
86
+ }
87
+ var xhrContext = this;
88
+ var event = {
89
+ method: params.method,
90
+ status: params.status,
91
+ domain: params.host,
92
+ path: params.pathname,
93
+ requestSize: metrics.txSize,
94
+ responseSize: metrics.rxSize,
95
+ type: type,
96
+ startTime: startTime,
97
+ endTime: endTime,
98
+ callbackDuration: metrics.cbTime
99
+ };
100
+ if (xhrContext.dt) {
101
+ event.spanId = xhrContext.dt.spanId;
102
+ event.traceId = xhrContext.dt.traceId;
103
+ event.spanTimestamp = xhrContext.dt.timestamp;
104
+ }
105
+
106
+ // if the ajax happened inside an interaction, hold it until the interaction finishes
107
+ if (this.spaNode) {
108
+ var interactionId = this.spaNode.interaction.id;
109
+ spaAjaxEvents[interactionId] = spaAjaxEvents[interactionId] || [];
110
+ spaAjaxEvents[interactionId].push(event);
111
+ } else {
112
+ ajaxEvents.push(event);
113
+ }
114
+ }
115
+ function prepareHarvest(options) {
116
+ options = options || {};
117
+ if (ajaxEvents.length === 0) {
118
+ return null;
119
+ }
120
+ var payload = getPayload(ajaxEvents, options.maxPayloadSize || MAX_PAYLOAD_SIZE);
121
+ var payloadObjs = [];
122
+ for (var i = 0; i < payload.length; i++) {
123
+ payloadObjs.push({
124
+ body: {
125
+ e: payload[i]
126
+ }
127
+ });
128
+ }
129
+ if (options.retry) {
130
+ sentAjaxEvents = ajaxEvents.slice();
131
+ }
132
+ ajaxEvents = [];
133
+ return payloadObjs;
134
+ }
135
+ function getPayload(events, maxPayloadSize, chunks) {
136
+ chunks = chunks || 1;
137
+ var payload = [];
138
+ var chunkSize = events.length / chunks;
139
+ var eventChunks = splitChunks(events, chunkSize);
140
+ var tooBig = false;
141
+ for (var i = 0; i < eventChunks.length; i++) {
142
+ var currentChunk = eventChunks[i];
143
+ if (currentChunk.tooBig(maxPayloadSize)) {
144
+ if (currentChunk.events.length !== 1) {
145
+ /* if it is too big BUT it isnt length 1, we can split it down again,
146
+ else we just want to NOT push it into payload
147
+ because if it's length 1 and still too big for the maxPayloadSize
148
+ it cant get any smaller and we dont want to recurse forever */
149
+ tooBig = true;
150
+ break;
151
+ }
152
+ } else {
153
+ payload.push(currentChunk.payload);
154
+ }
155
+ }
156
+ // check if the current payload string is too big, if so then run getPayload again with more buckets
157
+ return tooBig ? getPayload(events, maxPayloadSize, ++chunks) : payload;
158
+ }
159
+ function onEventsHarvestFinished(result) {
160
+ if (result.retry && sentAjaxEvents.length > 0 && allAjaxIsEnabled()) {
161
+ ajaxEvents = ajaxEvents.concat(sentAjaxEvents);
162
+ sentAjaxEvents = [];
163
+ }
164
+ }
165
+ function splitChunks(arr, chunkSize) {
166
+ chunkSize = chunkSize || arr.length;
167
+ var chunks = [];
168
+ for (var i = 0, len = arr.length; i < len; i += chunkSize) {
169
+ chunks.push(new Chunk(arr.slice(i, i + chunkSize)));
170
+ }
171
+ return chunks;
172
+ }
173
+ function Chunk(events) {
174
+ this.addString = getAddStringContext(agentIdentifier); // pass agentIdentifier here
175
+ this.events = events;
176
+ this.payload = 'bel.7;';
177
+ for (var i = 0; i < events.length; i++) {
178
+ var event = events[i];
179
+ var fields = [numeric(event.startTime), numeric(event.endTime - event.startTime), numeric(0),
180
+ // callbackEnd
181
+ numeric(0),
182
+ // no callbackDuration for non-SPA events
183
+ this.addString(event.method), numeric(event.status), this.addString(event.domain), this.addString(event.path), numeric(event.requestSize), numeric(event.responseSize), event.type === 'fetch' ? 1 : '', this.addString(0),
184
+ // nodeId
185
+ nullable(event.spanId, this.addString, true) +
186
+ // guid
187
+ nullable(event.traceId, this.addString, true) +
188
+ // traceId
189
+ nullable(event.spanTimestamp, numeric, false) // timestamp
190
+ ];
191
+
192
+ var insert = '2,';
193
+
194
+ // add custom attributes
195
+ var attrParts = addCustomAttributes(getInfo(agentIdentifier).jsAttributes || {}, this.addString);
196
+ fields.unshift(numeric(attrParts.length));
197
+ insert += fields.join(',');
198
+ if (attrParts && attrParts.length > 0) {
199
+ insert += ';' + attrParts.join(';');
200
+ }
201
+ if (i + 1 < events.length) insert += ';';
202
+ this.payload += insert;
203
+ }
204
+ this.tooBig = function (maxPayloadSize) {
205
+ maxPayloadSize = maxPayloadSize || MAX_PAYLOAD_SIZE;
206
+ return this.payload.length * 2 > maxPayloadSize;
207
+ };
208
+ }
209
+ function allAjaxIsEnabled() {
210
+ var enabled = getConfigurationValue(agentIdentifier, 'ajax.enabled');
211
+ if (enabled === false) {
212
+ return false;
213
+ }
214
+ return true;
215
+ }
216
+ drain(this.agentIdentifier, this.featureName);
217
+ }
218
+ }
@@ -0,0 +1,2 @@
1
+ import { FEATURE_NAMES } from '../../loaders/features/features';
2
+ export const FEATURE_NAME = FEATURE_NAMES.ajax;
@@ -0,0 +1 @@
1
+ export { Instrument as Ajax } from './instrument/index';
@@ -0,0 +1,137 @@
1
+ /*
2
+ * Copyright 2020 New Relic Corporation. All rights reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { getConfiguration, getConfigurationValue, getLoaderConfig } from '../../../common/config/config';
6
+ import { generateSpanId, generateTraceId } from '../../../common/ids/unique-id';
7
+ import { parseUrl } from '../../../common/url/parse-url';
8
+ import { globalScope } from '../../../common/util/global-scope';
9
+ import { stringify } from '../../../common/util/stringify';
10
+ export class DT {
11
+ constructor(agentIdentifier) {
12
+ this.agentIdentifier = agentIdentifier;
13
+ // Binds this class instance context to the following fn used in an external module (exported);
14
+ // Alternatively, can make them class field arrow functions, but requires experimental features/plugin for eslint.
15
+ this.generateTracePayload = this.generateTracePayload.bind(this);
16
+ this.shouldGenerateTrace = this.shouldGenerateTrace.bind(this);
17
+ }
18
+ generateTracePayload(parsedOrigin) {
19
+ if (!this.shouldGenerateTrace(parsedOrigin)) {
20
+ return null;
21
+ }
22
+ var loader_config = getLoaderConfig(this.agentIdentifier);
23
+ if (!loader_config) {
24
+ return null;
25
+ }
26
+ var accountId = (loader_config.accountID || '').toString() || null;
27
+ var agentId = (loader_config.agentID || '').toString() || null;
28
+ var trustKey = (loader_config.trustKey || '').toString() || null;
29
+ if (!accountId || !agentId) {
30
+ return null;
31
+ }
32
+ var spanId = generateSpanId();
33
+ var traceId = generateTraceId();
34
+ var timestamp = Date.now();
35
+ var payload = {
36
+ spanId: spanId,
37
+ traceId: traceId,
38
+ timestamp: timestamp
39
+ };
40
+ if (parsedOrigin.sameOrigin || this.isAllowedOrigin(parsedOrigin) && this.useTraceContextHeadersForCors()) {
41
+ payload.traceContextParentHeader = this.generateTraceContextParentHeader(spanId, traceId);
42
+ payload.traceContextStateHeader = this.generateTraceContextStateHeader(spanId, timestamp, accountId, agentId, trustKey);
43
+ }
44
+ if (parsedOrigin.sameOrigin && !this.excludeNewrelicHeader() || !parsedOrigin.sameOrigin && this.isAllowedOrigin(parsedOrigin) && this.useNewrelicHeaderForCors()) {
45
+ payload.newrelicHeader = this.generateTraceHeader(spanId, traceId, timestamp, accountId, agentId, trustKey);
46
+ }
47
+ return payload;
48
+ }
49
+ generateTraceContextParentHeader(spanId, traceId) {
50
+ return '00-' + traceId + '-' + spanId + '-01';
51
+ }
52
+ generateTraceContextStateHeader(spanId, timestamp, accountId, appId, trustKey) {
53
+ var version = 0;
54
+ var transactionId = '';
55
+ var parentType = 1;
56
+ var sampled = '';
57
+ var priority = '';
58
+ return trustKey + '@nr=' + version + '-' + parentType + '-' + accountId + '-' + appId + '-' + spanId + '-' + transactionId + '-' + sampled + '-' + priority + '-' + timestamp;
59
+ }
60
+ generateTraceHeader(spanId, traceId, timestamp, accountId, appId, trustKey) {
61
+ var hasBtoa = typeof globalScope?.btoa === 'function';
62
+ if (!hasBtoa) {
63
+ return null;
64
+ }
65
+ var payload = {
66
+ v: [0, 1],
67
+ d: {
68
+ ty: 'Browser',
69
+ ac: accountId,
70
+ ap: appId,
71
+ id: spanId,
72
+ tr: traceId,
73
+ ti: timestamp
74
+ }
75
+ };
76
+ if (trustKey && accountId !== trustKey) {
77
+ payload.d.tk = trustKey;
78
+ }
79
+ return btoa(stringify(payload));
80
+ }
81
+
82
+ // return true if DT is enabled and the origin is allowed, either by being
83
+ // same-origin, or included in the allowed list
84
+ shouldGenerateTrace(parsedOrigin) {
85
+ return this.isDtEnabled() && this.isAllowedOrigin(parsedOrigin);
86
+ }
87
+ isAllowedOrigin(parsedOrigin) {
88
+ var allowed = false;
89
+ var dtConfig = {};
90
+ var dt = getConfigurationValue(this.agentIdentifier, 'distributed_tracing');
91
+ if (dt) {
92
+ dtConfig = getConfiguration(this.agentIdentifier).distributed_tracing;
93
+ }
94
+ if (parsedOrigin.sameOrigin) {
95
+ allowed = true;
96
+ } else if (dtConfig.allowed_origins instanceof Array) {
97
+ for (var i = 0; i < dtConfig.allowed_origins.length; i++) {
98
+ var allowedOrigin = parseUrl(dtConfig.allowed_origins[i]);
99
+ if (parsedOrigin.hostname === allowedOrigin.hostname && parsedOrigin.protocol === allowedOrigin.protocol && parsedOrigin.port === allowedOrigin.port) {
100
+ allowed = true;
101
+ break;
102
+ }
103
+ }
104
+ }
105
+ return allowed;
106
+ }
107
+ isDtEnabled() {
108
+ var dt = getConfigurationValue(this.agentIdentifier, 'distributed_tracing');
109
+ if (dt) {
110
+ return !!dt.enabled;
111
+ }
112
+ return false;
113
+ }
114
+
115
+ // exclude the newrelic header for same-origin calls
116
+ excludeNewrelicHeader() {
117
+ var dt = getConfigurationValue(this.agentIdentifier, 'distributed_tracing');
118
+ if (dt) {
119
+ return !!dt.exclude_newrelic_header;
120
+ }
121
+ return false;
122
+ }
123
+ useNewrelicHeaderForCors() {
124
+ var dt = getConfigurationValue(this.agentIdentifier, 'distributed_tracing');
125
+ if (dt) {
126
+ return dt.cors_use_newrelic_header !== false;
127
+ }
128
+ return false;
129
+ }
130
+ useTraceContextHeadersForCors() {
131
+ var dt = getConfigurationValue(this.agentIdentifier, 'distributed_tracing');
132
+ if (dt) {
133
+ return !!dt.cors_use_tracecontext_headers;
134
+ }
135
+ return false;
136
+ }
137
+ }