@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,338 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Instrument = void 0;
7
+ var _config = require("../../../common/config/config");
8
+ var _handle = require("../../../common/event-emitter/handle");
9
+ var _id = require("../../../common/ids/id");
10
+ var _firefoxVersion = require("../../../common/browser-version/firefox-version");
11
+ var _dataSize = require("../../../common/util/data-size");
12
+ var _eventListenerOpts = require("../../../common/event-listener/event-listener-opts");
13
+ var _now = require("../../../common/timing/now");
14
+ var _wrap = require("../../../common/wrap");
15
+ var _parseUrl = require("../../../common/url/parse-url");
16
+ var _distributedTracing = require("./distributed-tracing");
17
+ var _responseSize = require("./response-size");
18
+ var _instrumentBase = require("../../utils/instrument-base");
19
+ var _constants = require("../constants");
20
+ var _features = require("../../../loaders/features/features");
21
+ var _globalScope = require("../../../common/util/global-scope");
22
+ /*
23
+ * Copyright 2020 New Relic Corporation. All rights reserved.
24
+ * SPDX-License-Identifier: Apache-2.0
25
+ */
26
+
27
+ var handlers = ['load', 'error', 'abort', 'timeout'];
28
+ var handlersLen = handlers.length;
29
+ var origRequest = _config.originals.REQ;
30
+ var origXHR = _globalScope.globalScope.XMLHttpRequest;
31
+ class Instrument extends _instrumentBase.InstrumentBase {
32
+ static featureName = _constants.FEATURE_NAME;
33
+ constructor(agentIdentifier, aggregator, auto = true) {
34
+ super(agentIdentifier, aggregator, _constants.FEATURE_NAME, auto);
35
+
36
+ // Very unlikely, but in case the existing XMLHttpRequest.prototype object on the page couldn't be wrapped.
37
+ if (!(0, _config.getRuntime)(agentIdentifier).xhrWrappable) return;
38
+ this.dt = new _distributedTracing.DT(agentIdentifier);
39
+ this.handler = (type, args, ctx, group) => (0, _handle.handle)(type, args, ctx, group, this.ee);
40
+ (0, _wrap.wrapFetch)(this.ee);
41
+ (0, _wrap.wrapXhr)(this.ee);
42
+ subscribeToEvents(agentIdentifier, this.ee, this.handler, this.dt);
43
+ this.importAggregator();
44
+ }
45
+ }
46
+ exports.Instrument = Instrument;
47
+ function subscribeToEvents(agentIdentifier, ee, handler, dt) {
48
+ ee.on('new-xhr', onNewXhr);
49
+ ee.on('open-xhr-start', onOpenXhrStart);
50
+ ee.on('open-xhr-end', onOpenXhrEnd);
51
+ ee.on('send-xhr-start', onSendXhrStart);
52
+ ee.on('xhr-cb-time', onXhrCbTime);
53
+ ee.on('xhr-load-added', onXhrLoadAdded);
54
+ ee.on('xhr-load-removed', onXhrLoadRemoved);
55
+ ee.on('xhr-resolved', onXhrResolved);
56
+ ee.on('addEventListener-end', onAddEventListenerEnd);
57
+ ee.on('removeEventListener-end', onRemoveEventListenerEnd);
58
+ ee.on('fn-end', onFnEnd);
59
+ ee.on('fetch-before-start', onFetchBeforeStart);
60
+ ee.on('fetch-start', onFetchStart);
61
+ ee.on('fn-start', onFnStart);
62
+ ee.on('fetch-done', onFetchDone);
63
+
64
+ // Setup the context for each new xhr object
65
+ function onNewXhr(xhr) {
66
+ var ctx = this;
67
+ ctx.totalCbs = 0;
68
+ ctx.called = 0;
69
+ ctx.cbTime = 0;
70
+ ctx.end = end;
71
+ ctx.ended = false;
72
+ ctx.xhrGuids = {};
73
+ ctx.lastSize = null;
74
+ ctx.loadCaptureCalled = false;
75
+ ctx.params = this.params || {};
76
+ ctx.metrics = this.metrics || {};
77
+ xhr.addEventListener('load', function (event) {
78
+ captureXhrData(ctx, xhr);
79
+ }, (0, _eventListenerOpts.eventListenerOpts)(false));
80
+
81
+ // In Firefox (v34+), XHR ProgressEvents report pre-content-decoding sizes via
82
+ // their 'loaded' property, rather than post-decoding sizes. We want
83
+ // post-decoding sizes for consistency with browsers where that's all we have.
84
+ // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1227674
85
+ //
86
+ // So we don't use ProgressEvents to measure XHR sizes for FF.
87
+ if (_firefoxVersion.ffVersion) return;
88
+ xhr.addEventListener('progress', function (event) {
89
+ ctx.lastSize = event.loaded;
90
+ }, (0, _eventListenerOpts.eventListenerOpts)(false));
91
+ }
92
+ function onOpenXhrStart(args) {
93
+ this.params = {
94
+ method: args[0]
95
+ };
96
+ addUrl(this, args[1]);
97
+ this.metrics = {};
98
+ }
99
+ function onOpenXhrEnd(args, xhr) {
100
+ var loader_config = (0, _config.getLoaderConfig)(agentIdentifier);
101
+ if ('xpid' in loader_config && this.sameOrigin) {
102
+ xhr.setRequestHeader('X-NewRelic-ID', loader_config.xpid);
103
+ }
104
+ var payload = dt.generateTracePayload(this.parsedOrigin);
105
+ if (payload) {
106
+ var added = false;
107
+ if (payload.newrelicHeader) {
108
+ xhr.setRequestHeader('newrelic', payload.newrelicHeader);
109
+ added = true;
110
+ }
111
+ if (payload.traceContextParentHeader) {
112
+ xhr.setRequestHeader('traceparent', payload.traceContextParentHeader);
113
+ if (payload.traceContextStateHeader) {
114
+ xhr.setRequestHeader('tracestate', payload.traceContextStateHeader);
115
+ }
116
+ added = true;
117
+ }
118
+ if (added) {
119
+ this.dt = payload;
120
+ }
121
+ }
122
+ }
123
+ function onSendXhrStart(args, xhr) {
124
+ var metrics = this.metrics;
125
+ var data = args[0];
126
+ var context = this;
127
+ if (metrics && data) {
128
+ var size = (0, _dataSize.dataSize)(data);
129
+ if (size) metrics.txSize = size;
130
+ }
131
+ this.startTime = (0, _now.now)();
132
+ this.listener = function (evt) {
133
+ try {
134
+ if (evt.type === 'abort' && !context.loadCaptureCalled) {
135
+ context.params.aborted = true;
136
+ }
137
+ if (evt.type !== 'load' || context.called === context.totalCbs && (context.onloadCalled || typeof xhr.onload !== 'function') && typeof context.end === 'function') context.end(xhr);
138
+ } catch (e) {
139
+ try {
140
+ ee.emit('internal-error', [e]);
141
+ } catch (err) {
142
+ // do nothing
143
+ }
144
+ }
145
+ };
146
+ for (var i = 0; i < handlersLen; i++) {
147
+ xhr.addEventListener(handlers[i], this.listener, (0, _eventListenerOpts.eventListenerOpts)(false));
148
+ }
149
+ }
150
+ function onXhrCbTime(time, onload, xhr) {
151
+ this.cbTime += time;
152
+ if (onload) this.onloadCalled = true;else this.called += 1;
153
+ if (this.called === this.totalCbs && (this.onloadCalled || typeof xhr.onload !== 'function') && typeof this.end === 'function') this.end(xhr);
154
+ }
155
+ function onXhrLoadAdded(cb, useCapture) {
156
+ // Ignore if the same arguments are passed to addEventListener twice
157
+ var idString = '' + (0, _id.id)(cb) + !!useCapture;
158
+ if (!this.xhrGuids || this.xhrGuids[idString]) return;
159
+ this.xhrGuids[idString] = true;
160
+ this.totalCbs += 1;
161
+ }
162
+ function onXhrLoadRemoved(cb, useCapture) {
163
+ // Ignore if event listener didn't exist for this xhr object
164
+ var idString = '' + (0, _id.id)(cb) + !!useCapture;
165
+ if (!this.xhrGuids || !this.xhrGuids[idString]) return;
166
+ delete this.xhrGuids[idString];
167
+ this.totalCbs -= 1;
168
+ }
169
+ function onXhrResolved() {
170
+ this.endTime = (0, _now.now)();
171
+ }
172
+
173
+ // Listen for load listeners to be added to xhr objects
174
+ function onAddEventListenerEnd(args, xhr) {
175
+ if (xhr instanceof origXHR && args[0] === 'load') ee.emit('xhr-load-added', [args[1], args[2]], xhr);
176
+ }
177
+ function onRemoveEventListenerEnd(args, xhr) {
178
+ if (xhr instanceof origXHR && args[0] === 'load') ee.emit('xhr-load-removed', [args[1], args[2]], xhr);
179
+ }
180
+
181
+ // Listen for those load listeners to be called.
182
+ function onFnStart(args, xhr, methodName) {
183
+ if (xhr instanceof origXHR) {
184
+ if (methodName === 'onload') this.onload = true;
185
+ if ((args[0] && args[0].type) === 'load' || this.onload) this.xhrCbStart = (0, _now.now)();
186
+ }
187
+ }
188
+ function onFnEnd(args, xhr) {
189
+ if (this.xhrCbStart) ee.emit('xhr-cb-time', [(0, _now.now)() - this.xhrCbStart, this.onload, xhr], xhr);
190
+ }
191
+
192
+ // this event only handles DT
193
+ function onFetchBeforeStart(args) {
194
+ var opts = args[1] || {};
195
+ var url;
196
+ // argument is USVString
197
+ if (typeof args[0] === 'string') {
198
+ url = args[0];
199
+ // argument is Request object
200
+ } else if (args[0] && args[0].url) {
201
+ url = args[0].url;
202
+ // argument is URL object
203
+ } else if (_globalScope.globalScope?.URL && args[0] && args[0] instanceof URL) {
204
+ url = args[0].href;
205
+ }
206
+ if (url) {
207
+ this.parsedOrigin = (0, _parseUrl.parseUrl)(url);
208
+ this.sameOrigin = this.parsedOrigin.sameOrigin;
209
+ }
210
+ var payload = dt.generateTracePayload(this.parsedOrigin);
211
+ if (!payload || !payload.newrelicHeader && !payload.traceContextParentHeader) {
212
+ return;
213
+ }
214
+ if (typeof args[0] === 'string' || _globalScope.globalScope?.URL && args[0] && args[0] instanceof URL) {
215
+ var clone = {};
216
+ for (var key in opts) {
217
+ clone[key] = opts[key];
218
+ }
219
+ clone.headers = new Headers(opts.headers || {});
220
+ if (addHeaders(clone.headers, payload)) {
221
+ this.dt = payload;
222
+ }
223
+ if (args.length > 1) {
224
+ args[1] = clone;
225
+ } else {
226
+ args.push(clone);
227
+ }
228
+ } else if (args[0] && args[0].headers) {
229
+ if (addHeaders(args[0].headers, payload)) {
230
+ this.dt = payload;
231
+ }
232
+ }
233
+ function addHeaders(headersObj, payload) {
234
+ var added = false;
235
+ if (payload.newrelicHeader) {
236
+ headersObj.set('newrelic', payload.newrelicHeader);
237
+ added = true;
238
+ }
239
+ if (payload.traceContextParentHeader) {
240
+ headersObj.set('traceparent', payload.traceContextParentHeader);
241
+ if (payload.traceContextStateHeader) {
242
+ headersObj.set('tracestate', payload.traceContextStateHeader);
243
+ }
244
+ added = true;
245
+ }
246
+ return added;
247
+ }
248
+ }
249
+ function onFetchStart(fetchArguments, dtPayload) {
250
+ this.params = {};
251
+ this.metrics = {};
252
+ this.startTime = (0, _now.now)();
253
+ this.dt = dtPayload;
254
+ if (fetchArguments.length >= 1) this.target = fetchArguments[0];
255
+ if (fetchArguments.length >= 2) this.opts = fetchArguments[1];
256
+ var opts = this.opts || {};
257
+ var target = this.target;
258
+ var url;
259
+ if (typeof target === 'string') {
260
+ url = target;
261
+ } else if (typeof target === 'object' && target instanceof origRequest) {
262
+ url = target.url;
263
+ } else if (_globalScope.globalScope?.URL && typeof target === 'object' && target instanceof URL) {
264
+ url = target.href;
265
+ }
266
+ addUrl(this, url);
267
+ var method = ('' + (target && target instanceof origRequest && target.method || opts.method || 'GET')).toUpperCase();
268
+ this.params.method = method;
269
+ this.txSize = (0, _dataSize.dataSize)(opts.body) || 0;
270
+ }
271
+
272
+ // we capture failed call as status 0, the actual error is ignored
273
+ // eslint-disable-next-line handle-callback-err
274
+ function onFetchDone(err, res) {
275
+ this.endTime = (0, _now.now)();
276
+ if (!this.params) {
277
+ this.params = {};
278
+ }
279
+ this.params.status = res ? res.status : 0;
280
+
281
+ // convert rxSize to a number
282
+ var responseSize;
283
+ if (typeof this.rxSize === 'string' && this.rxSize.length > 0) {
284
+ responseSize = +this.rxSize;
285
+ }
286
+ var metrics = {
287
+ txSize: this.txSize,
288
+ rxSize: responseSize,
289
+ duration: (0, _now.now)() - this.startTime
290
+ };
291
+ handler('xhr', [this.params, metrics, this.startTime, this.endTime, 'fetch'], this, _features.FEATURE_NAMES.ajax);
292
+ }
293
+
294
+ // Create report for XHR request that has finished
295
+ function end(xhr) {
296
+ var params = this.params;
297
+ var metrics = this.metrics;
298
+ if (this.ended) return;
299
+ this.ended = true;
300
+ for (var i = 0; i < handlersLen; i++) {
301
+ xhr.removeEventListener(handlers[i], this.listener, false);
302
+ }
303
+ if (params.aborted) return;
304
+ metrics.duration = (0, _now.now)() - this.startTime;
305
+ if (!this.loadCaptureCalled && xhr.readyState === 4) {
306
+ captureXhrData(this, xhr);
307
+ } else if (params.status == null) {
308
+ params.status = 0;
309
+ }
310
+
311
+ // Always send cbTime, even if no noticeable time was taken.
312
+ metrics.cbTime = this.cbTime;
313
+ handler('xhr', [params, metrics, this.startTime, this.endTime, 'xhr'], this, _features.FEATURE_NAMES.ajax);
314
+ }
315
+ function addUrl(ctx, url) {
316
+ var parsed = (0, _parseUrl.parseUrl)(url);
317
+ var params = ctx.params;
318
+ params.hostname = parsed.hostname;
319
+ params.port = parsed.port;
320
+ params.protocol = parsed.protocol;
321
+ params.host = parsed.hostname + ':' + parsed.port;
322
+ params.pathname = parsed.pathname;
323
+ ctx.parsedOrigin = parsed;
324
+ ctx.sameOrigin = parsed.sameOrigin;
325
+ }
326
+ function captureXhrData(ctx, xhr) {
327
+ ctx.params.status = xhr.status;
328
+ var size = (0, _responseSize.responseSizeFromXhr)(xhr, ctx.lastSize);
329
+ if (size) ctx.metrics.rxSize = size;
330
+ if (ctx.sameOrigin) {
331
+ var header = xhr.getResponseHeader('X-NewRelic-App-Data');
332
+ if (header) {
333
+ ctx.params.cat = header.split(', ').pop();
334
+ }
335
+ }
336
+ ctx.loadCaptureCalled = true;
337
+ }
338
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.responseSizeFromXhr = responseSizeFromXhr;
7
+ var _dataSize = require("../../../common/util/data-size");
8
+ /*
9
+ * Copyright 2020 New Relic Corporation. All rights reserved.
10
+ * SPDX-License-Identifier: Apache-2.0
11
+ */
12
+
13
+ function responseSizeFromXhr(xhr, lastSize) {
14
+ var type = xhr.responseType;
15
+ if (type === 'json' && lastSize !== null) return lastSize;
16
+ // Caution! Chrome throws an error if you try to access xhr.responseText for binary data
17
+ if (type === 'arraybuffer' || type === 'blob' || type === 'json') {
18
+ return (0, _dataSize.dataSize)(xhr.response);
19
+ } else if (type === 'text' || type === '' || type === undefined) {
20
+ // empty string type defaults to 'text'
21
+ return (0, _dataSize.dataSize)(xhr.responseText);
22
+ } else {
23
+ // e.g. ms-stream and document (we do not currently determine the size of Document objects)
24
+ return undefined;
25
+ }
26
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.canonicalFunctionName = canonicalFunctionName;
7
+ /*
8
+ * Copyright 2020 New Relic Corporation. All rights reserved.
9
+ * SPDX-License-Identifier: Apache-2.0
10
+ */
11
+
12
+ var canonicalFunctionNameRe = /([a-z0-9]+)$/i;
13
+ function canonicalFunctionName(orig) {
14
+ if (!orig) return;
15
+ var match = orig.match(canonicalFunctionNameRe);
16
+ if (match) return match[1];
17
+ return;
18
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _canonicalFunctionName = require("./canonical-function-name");
4
+ test.each([{
5
+ input: null,
6
+ expected: undefined,
7
+ title: 'Return undefined if no function name'
8
+ }, {
9
+ input: 'test',
10
+ expected: 'test',
11
+ title: 'Simple function name'
12
+ }, {
13
+ input: 'scope1/scope2/func',
14
+ expected: 'func',
15
+ title: 'Remove Firefox scopes'
16
+ }, {
17
+ input: 'scope1.func',
18
+ expected: 'func',
19
+ title: 'Remove Chrome scopes'
20
+ }, {
21
+ input: '<anonymous>',
22
+ expected: undefined,
23
+ title: 'Return undefined ending is non-alphanumeric'
24
+ }])('$title', ({
25
+ input,
26
+ expected
27
+ }) => {
28
+ const result = (0, _canonicalFunctionName.canonicalFunctionName)(input);
29
+ expect(result).toEqual(expected);
30
+ });
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.computeStackTrace = computeStackTrace;
7
+ var _reduce = require("../../../common/util/reduce");
8
+ var _formatStackTrace = require("./format-stack-trace");
9
+ /*
10
+ * Copyright 2020 New Relic Corporation. All rights reserved.
11
+ * SPDX-License-Identifier: Apache-2.0
12
+ */
13
+
14
+ /* eslint-disable no-useless-escape */
15
+
16
+ // computeStackTrace: cross-browser stack traces in JavaScript
17
+ //
18
+ // Syntax:
19
+ // s = computeStackTrace(exception) // consider using TraceKit.report instead
20
+ // Returns:
21
+ // s.name - exception name
22
+ // s.message - exception message
23
+ // s.stack[i].url - JavaScript or HTML file URL
24
+ // s.stack[i].func - function name, or empty for anonymous functions
25
+ // s.stack[i].line - line number, if known
26
+ // s.stack[i].column - column number, if known
27
+ // s.stack[i].context - an array of source code lines; the middle element corresponds to the correct line#
28
+ // s.mode - 'stack', 'stacktrace', 'multiline', 'callers', 'onerror', or 'failed' -- method used to collect the stack trace
29
+ //
30
+ // Supports:
31
+ // - Firefox: full stack trace with line numbers and unreliable column
32
+ // number on top frame
33
+ // - Chrome: full stack trace with line and column numbers
34
+ // - Safari: line and column number for the topmost stacktrace element
35
+ // only
36
+ // - IE: no line numbers whatsoever
37
+
38
+ // Contents of Exception in various browsers.
39
+ //
40
+ // SAFARI:
41
+ // ex.message = Can't find variable: qq
42
+ // ex.line = 59
43
+ // ex.sourceId = 580238192
44
+ // ex.sourceURL = http://...
45
+ // ex.expressionBeginOffset = 96
46
+ // ex.expressionCaretOffset = 98
47
+ // ex.expressionEndOffset = 98
48
+ // ex.name = ReferenceError
49
+ //
50
+ // FIREFOX:
51
+ // ex.message = qq is not defined
52
+ // ex.fileName = http://...
53
+ // ex.lineNumber = 59
54
+ // ex.stack = ...stack trace... (see the example below)
55
+ // ex.name = ReferenceError
56
+ //
57
+ // CHROME:
58
+ // ex.message = qq is not defined
59
+ // ex.name = ReferenceError
60
+ // ex.type = not_defined
61
+ // ex.arguments = ['aa']
62
+ // ex.stack = ...stack trace...
63
+ //
64
+ // INTERNET EXPLORER:
65
+ // ex.message = ...
66
+ // ex.name = ReferenceError
67
+
68
+ var debug = false;
69
+ var classNameRegex = /function (.+?)\s*\(/;
70
+ var chrome = /^\s*at (?:((?:\[object object\])?(?:[^(]*\([^)]*\))*[^()]*(?: \[as \S+\])?) )?\(?((?:file|http|https|chrome-extension):.*?)?:(\d+)(?::(\d+))?\)?\s*$/i;
71
+ var gecko = /^\s*(?:(\S*|global code)(?:\(.*?\))?@)?((?:file|http|https|chrome|safari-extension).*?):(\d+)(?::(\d+))?\s*$/i;
72
+ var chrome_eval = /^\s*at .+ \(eval at \S+ \((?:(?:file|http|https):[^)]+)?\)(?:, [^:]*:\d+:\d+)?\)$/i;
73
+ var ie_eval = /^\s*at Function code \(Function code:\d+:\d+\)\s*/i;
74
+ function computeStackTrace(ex) {
75
+ var stack = null;
76
+ try {
77
+ stack = computeStackTraceFromStackProp(ex);
78
+ if (stack) {
79
+ return stack;
80
+ }
81
+ } catch (e) {
82
+ if (debug) {
83
+ throw e;
84
+ }
85
+ }
86
+ try {
87
+ stack = computeStackTraceBySourceAndLine(ex);
88
+ if (stack) {
89
+ return stack;
90
+ }
91
+ } catch (e) {
92
+ if (debug) {
93
+ throw e;
94
+ }
95
+ }
96
+ try {
97
+ stack = computeStackTraceWithMessageOnly(ex);
98
+ if (stack) {
99
+ return stack;
100
+ }
101
+ } catch (e) {
102
+ if (debug) {
103
+ throw e;
104
+ }
105
+ }
106
+ return {
107
+ mode: 'failed',
108
+ stackString: '',
109
+ frames: []
110
+ };
111
+ }
112
+
113
+ /**
114
+ * Computes stack trace information from the stack property.
115
+ * Chrome and Gecko use this property.
116
+ * @param {Error} ex
117
+ * @return {?Object.<string, *>} Stack trace information.
118
+ */
119
+ function computeStackTraceFromStackProp(ex) {
120
+ if (!ex.stack) {
121
+ return null;
122
+ }
123
+ var errorInfo = (0, _reduce.reduce)(ex.stack.split('\n'), parseStackProp, {
124
+ frames: [],
125
+ stackLines: [],
126
+ wrapperSeen: false
127
+ });
128
+ if (!errorInfo.frames.length) return null;
129
+ return {
130
+ mode: 'stack',
131
+ name: ex.name || getClassName(ex),
132
+ message: ex.message,
133
+ stackString: (0, _formatStackTrace.formatStackTrace)(errorInfo.stackLines),
134
+ frames: errorInfo.frames
135
+ };
136
+ }
137
+ function parseStackProp(info, line) {
138
+ var element = getElement(line);
139
+ if (!element) {
140
+ info.stackLines.push(line);
141
+ return info;
142
+ }
143
+ if (isWrapper(element.func)) info.wrapperSeen = true;else info.stackLines.push(line);
144
+ if (!info.wrapperSeen) info.frames.push(element);
145
+ return info;
146
+ }
147
+ function getElement(line) {
148
+ var parts = line.match(gecko);
149
+ if (!parts) parts = line.match(chrome);
150
+ if (parts) {
151
+ return {
152
+ url: parts[2],
153
+ func: parts[1] !== 'Anonymous function' && parts[1] !== 'global code' && parts[1] || null,
154
+ line: +parts[3],
155
+ column: parts[4] ? +parts[4] : null
156
+ };
157
+ }
158
+ if (line.match(chrome_eval) || line.match(ie_eval) || line === 'anonymous') {
159
+ return {
160
+ func: 'evaluated code'
161
+ };
162
+ }
163
+ }
164
+ function computeStackTraceBySourceAndLine(ex) {
165
+ if (!('line' in ex)) return null;
166
+ var className = ex.name || getClassName(ex);
167
+
168
+ // Safari does not provide a URL for errors in eval'd code
169
+ if (!ex.sourceURL) {
170
+ return {
171
+ mode: 'sourceline',
172
+ name: className,
173
+ message: ex.message,
174
+ stackString: getClassName(ex) + ': ' + ex.message + '\n in evaluated code',
175
+ frames: [{
176
+ func: 'evaluated code'
177
+ }]
178
+ };
179
+ }
180
+ var stackString = className + ': ' + ex.message + '\n at ' + ex.sourceURL;
181
+ if (ex.line) {
182
+ stackString += ':' + ex.line;
183
+ if (ex.column) {
184
+ stackString += ':' + ex.column;
185
+ }
186
+ }
187
+ return {
188
+ mode: 'sourceline',
189
+ name: className,
190
+ message: ex.message,
191
+ stackString: stackString,
192
+ frames: [{
193
+ url: ex.sourceURL,
194
+ line: ex.line,
195
+ column: ex.column
196
+ }]
197
+ };
198
+ }
199
+ function computeStackTraceWithMessageOnly(ex) {
200
+ var className = ex.name || getClassName(ex);
201
+ if (!className) return null;
202
+ return {
203
+ mode: 'nameonly',
204
+ name: className,
205
+ message: ex.message,
206
+ stackString: className + ': ' + ex.message,
207
+ frames: []
208
+ };
209
+ }
210
+ function getClassName(obj) {
211
+ var results = classNameRegex.exec(String(obj.constructor));
212
+ return results && results.length > 1 ? results[1] : 'unknown';
213
+ }
214
+ function isWrapper(functionName) {
215
+ return functionName && functionName.indexOf('nrWrapper') >= 0;
216
+ }