@unidy.io/sdk 1.1.8 → 1.1.10

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 (769) hide show
  1. package/dist/cjs/app-globals-Pb3mNuRv.js +10 -0
  2. package/dist/cjs/app-globals-Pb3mNuRv.js.map +1 -0
  3. package/dist/cjs/auth-ChsE2RD7.js +614 -0
  4. package/dist/cjs/auth-ChsE2RD7.js.map +1 -0
  5. package/dist/cjs/auth-store-BO38Txmj.js +187 -0
  6. package/dist/cjs/auth-store-BO38Txmj.js.map +1 -0
  7. package/dist/cjs/component-utils-bu3SY4dE.js +42 -0
  8. package/dist/cjs/component-utils-bu3SY4dE.js.map +1 -0
  9. package/dist/cjs/flash-store-D5vGuIFc.js +50 -0
  10. package/dist/cjs/flash-store-D5vGuIFc.js.map +1 -0
  11. package/dist/cjs/helpers-BcPlKlBG.js +11 -0
  12. package/dist/cjs/helpers-BcPlKlBG.js.map +1 -0
  13. package/dist/cjs/helpers-DJyRa0Qo.js +11 -0
  14. package/dist/cjs/helpers-DJyRa0Qo.js.map +1 -0
  15. package/dist/cjs/i18n-B2T1e9Mf.js +3072 -0
  16. package/dist/cjs/i18n-B2T1e9Mf.js.map +1 -0
  17. package/dist/cjs/index-BzhKFIXk.js +14706 -0
  18. package/dist/cjs/index-BzhKFIXk.js.map +1 -0
  19. package/dist/cjs/index-DmDGhWTM.js +6338 -0
  20. package/dist/cjs/index-DmDGhWTM.js.map +1 -0
  21. package/dist/cjs/index-DxENvy7x.js +283 -0
  22. package/dist/cjs/index-DxENvy7x.js.map +1 -0
  23. package/dist/cjs/index.cjs.js +64 -0
  24. package/dist/cjs/index.cjs.js.map +1 -0
  25. package/dist/cjs/loader.cjs.js +14 -0
  26. package/dist/cjs/loader.cjs.js.map +1 -0
  27. package/dist/cjs/newsletter-helpers-B5P7q8Xk.js +289 -0
  28. package/dist/cjs/newsletter-helpers-B5P7q8Xk.js.map +1 -0
  29. package/dist/cjs/newsletter-store-f5zhJljn.js +38 -0
  30. package/dist/cjs/newsletter-store-f5zhJljn.js.map +1 -0
  31. package/dist/cjs/pagination-store-DjGYEIqm.js +16 -0
  32. package/dist/cjs/pagination-store-DjGYEIqm.js.map +1 -0
  33. package/dist/cjs/profile-helpers-BcLjojeG.js +39 -0
  34. package/dist/cjs/profile-helpers-BcLjojeG.js.map +1 -0
  35. package/dist/cjs/profile-store-BWJ9qAcg.js +22 -0
  36. package/dist/cjs/profile-store-BWJ9qAcg.js.map +1 -0
  37. package/dist/cjs/sdk.cjs.js +53 -0
  38. package/dist/cjs/sdk.cjs.js.map +1 -0
  39. package/dist/cjs/u-conditional-render.cjs.entry.js +102 -0
  40. package/dist/cjs/u-conditional-render.entry.cjs.js.map +1 -0
  41. package/dist/cjs/u-config.cjs.entry.js +91 -0
  42. package/dist/cjs/u-config.entry.cjs.js.map +1 -0
  43. package/dist/cjs/u-email-field.cjs.entry.js +77 -0
  44. package/dist/cjs/u-email-field.entry.cjs.js.map +1 -0
  45. package/dist/cjs/u-error-message.cjs.entry.js +82 -0
  46. package/dist/cjs/u-error-message.entry.cjs.js.map +1 -0
  47. package/dist/cjs/u-field.u-raw-field.entry.cjs.js.map +1 -0
  48. package/dist/cjs/u-field_2.cjs.entry.js +371 -0
  49. package/dist/cjs/u-flash-message.cjs.entry.js +37 -0
  50. package/dist/cjs/u-flash-message.entry.cjs.js.map +1 -0
  51. package/dist/cjs/u-full-profile.cjs.entry.js +37 -0
  52. package/dist/cjs/u-full-profile.entry.cjs.js.map +1 -0
  53. package/dist/cjs/u-logout-button.u-signed-in.entry.cjs.js.map +1 -0
  54. package/dist/cjs/u-logout-button_2.cjs.entry.js +62 -0
  55. package/dist/cjs/u-magic-code-field.cjs.entry.js +91 -0
  56. package/dist/cjs/u-magic-code-field.entry.cjs.js.map +1 -0
  57. package/dist/cjs/u-missing-field.cjs.entry.js +22 -0
  58. package/dist/cjs/u-missing-field.entry.cjs.js.map +1 -0
  59. package/dist/cjs/u-missing-fields-submit-button.cjs.entry.js +46 -0
  60. package/dist/cjs/u-missing-fields-submit-button.entry.cjs.js.map +1 -0
  61. package/dist/cjs/u-newsletter-checkbox.cjs.entry.js +77 -0
  62. package/dist/cjs/u-newsletter-checkbox.entry.cjs.js.map +1 -0
  63. package/dist/cjs/u-newsletter-logout-button.cjs.entry.js +41 -0
  64. package/dist/cjs/u-newsletter-logout-button.entry.cjs.js.map +1 -0
  65. package/dist/cjs/u-newsletter-preference-checkbox.cjs.entry.js +120 -0
  66. package/dist/cjs/u-newsletter-preference-checkbox.entry.cjs.js.map +1 -0
  67. package/dist/cjs/u-newsletter-resend-doi-button.cjs.entry.js +49 -0
  68. package/dist/cjs/u-newsletter-resend-doi-button.entry.cjs.js.map +1 -0
  69. package/dist/cjs/u-newsletter-root.cjs.entry.js +72 -0
  70. package/dist/cjs/u-newsletter-root.entry.cjs.js.map +1 -0
  71. package/dist/cjs/u-newsletter-toggle-subscription-button.cjs.entry.js +73 -0
  72. package/dist/cjs/u-newsletter-toggle-subscription-button.entry.cjs.js.map +1 -0
  73. package/dist/cjs/u-pagination-button.cjs.entry.js +63 -0
  74. package/dist/cjs/u-pagination-button.entry.cjs.js.map +1 -0
  75. package/dist/cjs/u-pagination-page.cjs.entry.js +44 -0
  76. package/dist/cjs/u-pagination-page.entry.cjs.js.map +1 -0
  77. package/dist/cjs/u-passkey.cjs.entry.js +47 -0
  78. package/dist/cjs/u-passkey.entry.cjs.js.map +1 -0
  79. package/dist/cjs/u-password-field.cjs.entry.js +106 -0
  80. package/dist/cjs/u-password-field.entry.cjs.js.map +1 -0
  81. package/dist/cjs/u-profile.u-submit-button.entry.cjs.js.map +1 -0
  82. package/dist/cjs/u-profile_2.cjs.entry.js +329 -0
  83. package/dist/cjs/u-registration-button.cjs.entry.js +48 -0
  84. package/dist/cjs/u-registration-button.entry.cjs.js.map +1 -0
  85. package/dist/cjs/u-reset-password-button.cjs.entry.js +56 -0
  86. package/dist/cjs/u-reset-password-button.entry.cjs.js.map +1 -0
  87. package/dist/cjs/u-send-magic-code-button.cjs.entry.js +68 -0
  88. package/dist/cjs/u-send-magic-code-button.entry.cjs.js.map +1 -0
  89. package/dist/cjs/u-signin-root.cjs.entry.js +43 -0
  90. package/dist/cjs/u-signin-root.entry.cjs.js.map +1 -0
  91. package/dist/cjs/u-signin-step.cjs.entry.js +66 -0
  92. package/dist/cjs/u-signin-step.entry.cjs.js.map +1 -0
  93. package/dist/cjs/u-signin-strategy.cjs.entry.js +30 -0
  94. package/dist/cjs/u-signin-strategy.entry.cjs.js.map +1 -0
  95. package/dist/cjs/u-social-login-button.cjs.entry.js +100 -0
  96. package/dist/cjs/u-social-login-button.entry.cjs.js.map +1 -0
  97. package/dist/cjs/u-spinner.cjs.entry.js +18 -0
  98. package/dist/cjs/u-spinner.entry.cjs.js.map +1 -0
  99. package/dist/cjs/u-ticketable-list.cjs.entry.js +6097 -0
  100. package/dist/cjs/u-ticketable-list.entry.cjs.js.map +1 -0
  101. package/dist/cjs/unidy-store-zhdhlK0a.js +41 -0
  102. package/dist/cjs/unidy-store-zhdhlK0a.js.map +1 -0
  103. package/dist/collection/api/client.js +144 -0
  104. package/dist/collection/api/client.js.map +1 -0
  105. package/dist/collection/api/index.js +42 -0
  106. package/dist/collection/api/index.js.map +1 -0
  107. package/dist/collection/api/shared.js +18 -0
  108. package/dist/collection/api/shared.js.map +1 -0
  109. package/dist/collection/auth/api/auth.js +274 -0
  110. package/dist/collection/auth/api/auth.js.map +1 -0
  111. package/dist/collection/auth/auth-helpers.js +314 -0
  112. package/dist/collection/auth/auth-helpers.js.map +1 -0
  113. package/dist/collection/auth/auth.js +139 -0
  114. package/dist/collection/auth/auth.js.map +1 -0
  115. package/dist/collection/auth/components/helpers.js +5 -0
  116. package/dist/collection/auth/components/helpers.js.map +1 -0
  117. package/dist/collection/auth/components/logout-button/logout-button.js +94 -0
  118. package/dist/collection/auth/components/logout-button/logout-button.js.map +1 -0
  119. package/dist/collection/auth/components/magic-code-field/magic-code-field.css +1 -0
  120. package/dist/collection/auth/components/magic-code-field/magic-code-field.js +113 -0
  121. package/dist/collection/auth/components/magic-code-field/magic-code-field.js.map +1 -0
  122. package/dist/collection/auth/components/missing-field/missing-field.js +14 -0
  123. package/dist/collection/auth/components/missing-field/missing-field.js.map +1 -0
  124. package/dist/collection/auth/components/missing-fields-submit-button/missing-fields-submit-button.js +39 -0
  125. package/dist/collection/auth/components/missing-fields-submit-button/missing-fields-submit-button.js.map +1 -0
  126. package/dist/collection/auth/components/passkey/passkey.js +103 -0
  127. package/dist/collection/auth/components/passkey/passkey.js.map +1 -0
  128. package/dist/collection/auth/components/password-field/password-field.js +168 -0
  129. package/dist/collection/auth/components/password-field/password-field.js.map +1 -0
  130. package/dist/collection/auth/components/registration/registration-button.js +104 -0
  131. package/dist/collection/auth/components/registration/registration-button.js.map +1 -0
  132. package/dist/collection/auth/components/reset-pass-button/reset-pass-button.js +68 -0
  133. package/dist/collection/auth/components/reset-pass-button/reset-pass-button.js.map +1 -0
  134. package/dist/collection/auth/components/send-magic-code-button/send-magic-code-button.js +104 -0
  135. package/dist/collection/auth/components/send-magic-code-button/send-magic-code-button.js.map +1 -0
  136. package/dist/collection/auth/components/signed-in/signed-in.js +59 -0
  137. package/dist/collection/auth/components/signed-in/signed-in.js.map +1 -0
  138. package/dist/collection/auth/components/signin-root/signin-root.js +97 -0
  139. package/dist/collection/auth/components/signin-root/signin-root.js.map +1 -0
  140. package/dist/collection/auth/components/signin-step/signin-step.js +135 -0
  141. package/dist/collection/auth/components/signin-step/signin-step.js.map +1 -0
  142. package/dist/collection/auth/components/signin-strategy/signin-strategy.js +64 -0
  143. package/dist/collection/auth/components/signin-strategy/signin-strategy.js.map +1 -0
  144. package/dist/collection/auth/components/social-logins/logos/apple.js +3 -0
  145. package/dist/collection/auth/components/social-logins/logos/apple.js.map +1 -0
  146. package/dist/collection/auth/components/social-logins/logos/discord.js +3 -0
  147. package/dist/collection/auth/components/social-logins/logos/discord.js.map +1 -0
  148. package/dist/collection/auth/components/social-logins/logos/facebook.js +3 -0
  149. package/dist/collection/auth/components/social-logins/logos/facebook.js.map +1 -0
  150. package/dist/collection/auth/components/social-logins/logos/google.js +3 -0
  151. package/dist/collection/auth/components/social-logins/logos/google.js.map +1 -0
  152. package/dist/collection/auth/components/social-logins/logos/linkedin.js +3 -0
  153. package/dist/collection/auth/components/social-logins/logos/linkedin.js.map +1 -0
  154. package/dist/collection/auth/components/social-logins/social-login-button.css +1 -0
  155. package/dist/collection/auth/components/social-logins/social-login-button.js +188 -0
  156. package/dist/collection/auth/components/social-logins/social-login-button.js.map +1 -0
  157. package/dist/collection/auth/components/submit-button/auth-submit-button.js +62 -0
  158. package/dist/collection/auth/components/submit-button/auth-submit-button.js.map +1 -0
  159. package/dist/collection/auth/error-definitions.js +26 -0
  160. package/dist/collection/auth/error-definitions.js.map +1 -0
  161. package/dist/collection/auth/index.js +13 -0
  162. package/dist/collection/auth/index.js.map +1 -0
  163. package/dist/collection/auth/passkey-auth.js +106 -0
  164. package/dist/collection/auth/passkey-auth.js.map +1 -0
  165. package/dist/collection/auth/store/auth-store.js +178 -0
  166. package/dist/collection/auth/store/auth-store.js.map +1 -0
  167. package/dist/collection/collection-manifest.json +46 -0
  168. package/dist/collection/globalScript.js +18 -0
  169. package/dist/collection/globalScript.js.map +1 -0
  170. package/dist/collection/i18n.js +31 -0
  171. package/dist/collection/i18n.js.map +1 -0
  172. package/dist/collection/index.js +16 -0
  173. package/dist/collection/index.js.map +1 -0
  174. package/dist/collection/locales/de.json +133 -0
  175. package/dist/collection/locales/en.json +133 -0
  176. package/dist/collection/locales/fr.json +133 -0
  177. package/dist/collection/locales/it.json +133 -0
  178. package/dist/collection/locales/nl_be.json +133 -0
  179. package/dist/collection/locales/ro.json +133 -0
  180. package/dist/collection/logger.js +106 -0
  181. package/dist/collection/logger.js.map +1 -0
  182. package/dist/collection/newsletter/api/newsletters.js +189 -0
  183. package/dist/collection/newsletter/api/newsletters.js.map +1 -0
  184. package/dist/collection/newsletter/components/helpers.js +5 -0
  185. package/dist/collection/newsletter/components/helpers.js.map +1 -0
  186. package/dist/collection/newsletter/components/logout-button/logout-button.js +53 -0
  187. package/dist/collection/newsletter/components/logout-button/logout-button.js.map +1 -0
  188. package/dist/collection/newsletter/components/newsletter-checkbox/newsletter-checkbox.js +165 -0
  189. package/dist/collection/newsletter/components/newsletter-checkbox/newsletter-checkbox.js.map +1 -0
  190. package/dist/collection/newsletter/components/newsletter-root/newsletter-root.js +119 -0
  191. package/dist/collection/newsletter/components/newsletter-root/newsletter-root.js.map +1 -0
  192. package/dist/collection/newsletter/components/preference-checkbox/preference-checkbox.js +234 -0
  193. package/dist/collection/newsletter/components/preference-checkbox/preference-checkbox.js.map +1 -0
  194. package/dist/collection/newsletter/components/resend-doi-button/resend-doi-button.css +1 -0
  195. package/dist/collection/newsletter/components/resend-doi-button/resend-doi-button.js +89 -0
  196. package/dist/collection/newsletter/components/resend-doi-button/resend-doi-button.js.map +1 -0
  197. package/dist/collection/newsletter/components/submit-button/newsletter-submit-button.js +18 -0
  198. package/dist/collection/newsletter/components/submit-button/newsletter-submit-button.js.map +1 -0
  199. package/dist/collection/newsletter/components/toggle-subscription-button/toggle-subscription-button.css +1 -0
  200. package/dist/collection/newsletter/components/toggle-subscription-button/toggle-subscription-button.js +154 -0
  201. package/dist/collection/newsletter/components/toggle-subscription-button/toggle-subscription-button.js.map +1 -0
  202. package/dist/collection/newsletter/index.js +11 -0
  203. package/dist/collection/newsletter/index.js.map +1 -0
  204. package/dist/collection/newsletter/newsletter-helpers.js +277 -0
  205. package/dist/collection/newsletter/newsletter-helpers.js.map +1 -0
  206. package/dist/collection/newsletter/store/newsletter-store.js +34 -0
  207. package/dist/collection/newsletter/store/newsletter-store.js.map +1 -0
  208. package/dist/collection/profile/api/profile.js +168 -0
  209. package/dist/collection/profile/api/profile.js.map +1 -0
  210. package/dist/collection/profile/components/field/field.css +1 -0
  211. package/dist/collection/profile/components/field/field.js +355 -0
  212. package/dist/collection/profile/components/field/field.js.map +1 -0
  213. package/dist/collection/profile/components/full-profile/full-profile.css +1 -0
  214. package/dist/collection/profile/components/full-profile/full-profile.js +78 -0
  215. package/dist/collection/profile/components/full-profile/full-profile.js.map +1 -0
  216. package/dist/collection/profile/components/profile/profile.js +250 -0
  217. package/dist/collection/profile/components/profile/profile.js.map +1 -0
  218. package/dist/collection/profile/components/raw-field/raw-field.js +697 -0
  219. package/dist/collection/profile/components/raw-field/raw-field.js.map +1 -0
  220. package/dist/collection/profile/components/raw-input-fields/Input.js +3 -0
  221. package/dist/collection/profile/components/raw-input-fields/Input.js.map +1 -0
  222. package/dist/collection/profile/components/raw-input-fields/MultiSelect.js +8 -0
  223. package/dist/collection/profile/components/raw-input-fields/MultiSelect.js.map +1 -0
  224. package/dist/collection/profile/components/raw-input-fields/RadioGroup.js +8 -0
  225. package/dist/collection/profile/components/raw-input-fields/RadioGroup.js.map +1 -0
  226. package/dist/collection/profile/components/raw-input-fields/Select.js +11 -0
  227. package/dist/collection/profile/components/raw-input-fields/Select.js.map +1 -0
  228. package/dist/collection/profile/components/raw-input-fields/Textarea.js +3 -0
  229. package/dist/collection/profile/components/raw-input-fields/Textarea.js.map +1 -0
  230. package/dist/collection/profile/components/submit-button/profile-submit-button.js +17 -0
  231. package/dist/collection/profile/components/submit-button/profile-submit-button.js.map +1 -0
  232. package/dist/collection/profile/index.js +12 -0
  233. package/dist/collection/profile/index.js.map +1 -0
  234. package/dist/collection/profile/profile-helpers.js +31 -0
  235. package/dist/collection/profile/profile-helpers.js.map +1 -0
  236. package/dist/collection/profile/store/profile-store.js +15 -0
  237. package/dist/collection/profile/store/profile-store.js.map +1 -0
  238. package/dist/collection/sdk.css +39 -0
  239. package/dist/collection/shared/component-utils.js +35 -0
  240. package/dist/collection/shared/component-utils.js.map +1 -0
  241. package/dist/collection/shared/components/conditional-render/conditional-render.js +177 -0
  242. package/dist/collection/shared/components/conditional-render/conditional-render.js.map +1 -0
  243. package/dist/collection/shared/components/config/config.js +284 -0
  244. package/dist/collection/shared/components/config/config.js.map +1 -0
  245. package/dist/collection/shared/components/email-field/email-field.css +1 -0
  246. package/dist/collection/shared/components/email-field/email-field.js +145 -0
  247. package/dist/collection/shared/components/email-field/email-field.js.map +1 -0
  248. package/dist/collection/shared/components/error-message/error-message.js +141 -0
  249. package/dist/collection/shared/components/error-message/error-message.js.map +1 -0
  250. package/dist/collection/shared/components/flash-message/close-icon.js +3 -0
  251. package/dist/collection/shared/components/flash-message/close-icon.js.map +1 -0
  252. package/dist/collection/shared/components/flash-message/flash-message.css +1 -0
  253. package/dist/collection/shared/components/flash-message/flash-message.js +79 -0
  254. package/dist/collection/shared/components/flash-message/flash-message.js.map +1 -0
  255. package/dist/collection/shared/components/spinner/spinner.css +1 -0
  256. package/dist/collection/shared/components/spinner/spinner.js +19 -0
  257. package/dist/collection/shared/components/spinner/spinner.js.map +1 -0
  258. package/dist/collection/shared/components/submit-button/context.js +10 -0
  259. package/dist/collection/shared/components/submit-button/context.js.map +1 -0
  260. package/dist/collection/shared/components/submit-button/submit-button.css +1 -0
  261. package/dist/collection/shared/components/submit-button/submit-button.js +198 -0
  262. package/dist/collection/shared/components/submit-button/submit-button.js.map +1 -0
  263. package/dist/collection/shared/store/flash-store.js +43 -0
  264. package/dist/collection/shared/store/flash-store.js.map +1 -0
  265. package/dist/collection/shared/store/unidy-store.js +33 -0
  266. package/dist/collection/shared/store/unidy-store.js.map +1 -0
  267. package/dist/collection/ticketable/api/get-with-schema.js +35 -0
  268. package/dist/collection/ticketable/api/get-with-schema.js.map +1 -0
  269. package/dist/collection/ticketable/api/schemas.js +12 -0
  270. package/dist/collection/ticketable/api/schemas.js.map +1 -0
  271. package/dist/collection/ticketable/api/subscriptions.js +47 -0
  272. package/dist/collection/ticketable/api/subscriptions.js.map +1 -0
  273. package/dist/collection/ticketable/api/tickets.js +48 -0
  274. package/dist/collection/ticketable/api/tickets.js.map +1 -0
  275. package/dist/collection/ticketable/components/pagination/pagination-button.js +108 -0
  276. package/dist/collection/ticketable/components/pagination/pagination-button.js.map +1 -0
  277. package/dist/collection/ticketable/components/pagination/pagination-page.js +69 -0
  278. package/dist/collection/ticketable/components/pagination/pagination-page.js.map +1 -0
  279. package/dist/collection/ticketable/components/ticketable-list/skeleton-helpers.js +54 -0
  280. package/dist/collection/ticketable/components/ticketable-list/skeleton-helpers.js.map +1 -0
  281. package/dist/collection/ticketable/components/ticketable-list/ticketable-list.js +505 -0
  282. package/dist/collection/ticketable/components/ticketable-list/ticketable-list.js.map +1 -0
  283. package/dist/collection/ticketable/index.js +13 -0
  284. package/dist/collection/ticketable/index.js.map +1 -0
  285. package/dist/collection/ticketable/store/pagination-store.js +9 -0
  286. package/dist/collection/ticketable/store/pagination-store.js.map +1 -0
  287. package/dist/components/auth-store.js +182 -0
  288. package/dist/components/auth-store.js.map +1 -0
  289. package/dist/components/auth.js +613 -0
  290. package/dist/components/auth.js.map +1 -0
  291. package/dist/components/component-utils.js +39 -0
  292. package/dist/components/component-utils.js.map +1 -0
  293. package/dist/components/exports.js +4262 -0
  294. package/dist/components/exports.js.map +1 -0
  295. package/dist/components/field.js +134 -0
  296. package/dist/components/field.js.map +1 -0
  297. package/dist/components/flash-store.js +47 -0
  298. package/dist/components/flash-store.js.map +1 -0
  299. package/dist/components/helpers.js +9 -0
  300. package/dist/components/helpers.js.map +1 -0
  301. package/dist/components/helpers2.js +9 -0
  302. package/dist/components/helpers2.js.map +1 -0
  303. package/dist/components/i18n.js +3070 -0
  304. package/dist/components/i18n.js.map +1 -0
  305. package/dist/components/index.d.ts +33 -0
  306. package/dist/components/index.js +5929 -0
  307. package/dist/components/index.js.map +1 -0
  308. package/dist/components/index2.js +6327 -0
  309. package/dist/components/index2.js.map +1 -0
  310. package/dist/components/index3.js +281 -0
  311. package/dist/components/index3.js.map +1 -0
  312. package/dist/components/logger.js +111 -0
  313. package/dist/components/logger.js.map +1 -0
  314. package/dist/components/newsletter-helpers.js +278 -0
  315. package/dist/components/newsletter-helpers.js.map +1 -0
  316. package/dist/components/newsletter-store.js +34 -0
  317. package/dist/components/newsletter-store.js.map +1 -0
  318. package/dist/components/pagination-store.js +14 -0
  319. package/dist/components/pagination-store.js.map +1 -0
  320. package/dist/components/profile-helpers.js +36 -0
  321. package/dist/components/profile-helpers.js.map +1 -0
  322. package/dist/components/profile-store.js +18 -0
  323. package/dist/components/profile-store.js.map +1 -0
  324. package/dist/components/profile.js +151 -0
  325. package/dist/components/profile.js.map +1 -0
  326. package/dist/components/raw-field.js +318 -0
  327. package/dist/components/raw-field.js.map +1 -0
  328. package/dist/components/spinner.js +35 -0
  329. package/dist/components/spinner.js.map +1 -0
  330. package/dist/components/submit-button.js +233 -0
  331. package/dist/components/submit-button.js.map +1 -0
  332. package/dist/components/u-conditional-render.d.ts +11 -0
  333. package/dist/components/u-conditional-render.js +120 -0
  334. package/dist/components/u-conditional-render.js.map +1 -0
  335. package/dist/components/u-config.d.ts +11 -0
  336. package/dist/components/u-config.js +118 -0
  337. package/dist/components/u-config.js.map +1 -0
  338. package/dist/components/u-email-field.d.ts +11 -0
  339. package/dist/components/u-email-field.js +99 -0
  340. package/dist/components/u-email-field.js.map +1 -0
  341. package/dist/components/u-error-message.d.ts +11 -0
  342. package/dist/components/u-error-message.js +105 -0
  343. package/dist/components/u-error-message.js.map +1 -0
  344. package/dist/components/u-field.d.ts +11 -0
  345. package/dist/components/u-field.js +9 -0
  346. package/dist/components/u-field.js.map +1 -0
  347. package/dist/components/u-flash-message.d.ts +11 -0
  348. package/dist/components/u-flash-message.js +58 -0
  349. package/dist/components/u-flash-message.js.map +1 -0
  350. package/dist/components/u-full-profile.d.ts +11 -0
  351. package/dist/components/u-full-profile.js +87 -0
  352. package/dist/components/u-full-profile.js.map +1 -0
  353. package/dist/components/u-logout-button.d.ts +11 -0
  354. package/dist/components/u-logout-button.js +61 -0
  355. package/dist/components/u-logout-button.js.map +1 -0
  356. package/dist/components/u-magic-code-field.d.ts +11 -0
  357. package/dist/components/u-magic-code-field.js +106 -0
  358. package/dist/components/u-magic-code-field.js.map +1 -0
  359. package/dist/components/u-missing-field.d.ts +11 -0
  360. package/dist/components/u-missing-field.js +51 -0
  361. package/dist/components/u-missing-field.js.map +1 -0
  362. package/dist/components/u-missing-fields-submit-button.d.ts +11 -0
  363. package/dist/components/u-missing-fields-submit-button.js +70 -0
  364. package/dist/components/u-missing-fields-submit-button.js.map +1 -0
  365. package/dist/components/u-newsletter-checkbox.d.ts +11 -0
  366. package/dist/components/u-newsletter-checkbox.js +93 -0
  367. package/dist/components/u-newsletter-checkbox.js.map +1 -0
  368. package/dist/components/u-newsletter-logout-button.d.ts +11 -0
  369. package/dist/components/u-newsletter-logout-button.js +56 -0
  370. package/dist/components/u-newsletter-logout-button.js.map +1 -0
  371. package/dist/components/u-newsletter-preference-checkbox.d.ts +11 -0
  372. package/dist/components/u-newsletter-preference-checkbox.js +140 -0
  373. package/dist/components/u-newsletter-preference-checkbox.js.map +1 -0
  374. package/dist/components/u-newsletter-resend-doi-button.d.ts +11 -0
  375. package/dist/components/u-newsletter-resend-doi-button.js +70 -0
  376. package/dist/components/u-newsletter-resend-doi-button.js.map +1 -0
  377. package/dist/components/u-newsletter-root.d.ts +11 -0
  378. package/dist/components/u-newsletter-root.js +90 -0
  379. package/dist/components/u-newsletter-root.js.map +1 -0
  380. package/dist/components/u-newsletter-toggle-subscription-button.d.ts +11 -0
  381. package/dist/components/u-newsletter-toggle-subscription-button.js +97 -0
  382. package/dist/components/u-newsletter-toggle-subscription-button.js.map +1 -0
  383. package/dist/components/u-pagination-button.d.ts +11 -0
  384. package/dist/components/u-pagination-button.js +86 -0
  385. package/dist/components/u-pagination-button.js.map +1 -0
  386. package/dist/components/u-pagination-page.d.ts +11 -0
  387. package/dist/components/u-pagination-page.js +66 -0
  388. package/dist/components/u-pagination-page.js.map +1 -0
  389. package/dist/components/u-passkey.d.ts +11 -0
  390. package/dist/components/u-passkey.js +65 -0
  391. package/dist/components/u-passkey.js.map +1 -0
  392. package/dist/components/u-password-field.d.ts +11 -0
  393. package/dist/components/u-password-field.js +127 -0
  394. package/dist/components/u-password-field.js.map +1 -0
  395. package/dist/components/u-profile.d.ts +11 -0
  396. package/dist/components/u-profile.js +9 -0
  397. package/dist/components/u-profile.js.map +1 -0
  398. package/dist/components/u-raw-field.d.ts +11 -0
  399. package/dist/components/u-raw-field.js +9 -0
  400. package/dist/components/u-raw-field.js.map +1 -0
  401. package/dist/components/u-registration-button.d.ts +11 -0
  402. package/dist/components/u-registration-button.js +70 -0
  403. package/dist/components/u-registration-button.js.map +1 -0
  404. package/dist/components/u-reset-password-button.d.ts +11 -0
  405. package/dist/components/u-reset-password-button.js +72 -0
  406. package/dist/components/u-reset-password-button.js.map +1 -0
  407. package/dist/components/u-send-magic-code-button.d.ts +11 -0
  408. package/dist/components/u-send-magic-code-button.js +85 -0
  409. package/dist/components/u-send-magic-code-button.js.map +1 -0
  410. package/dist/components/u-signed-in.d.ts +11 -0
  411. package/dist/components/u-signed-in.js +44 -0
  412. package/dist/components/u-signed-in.js.map +1 -0
  413. package/dist/components/u-signin-root.d.ts +11 -0
  414. package/dist/components/u-signin-root.js +63 -0
  415. package/dist/components/u-signin-root.js.map +1 -0
  416. package/dist/components/u-signin-step.d.ts +11 -0
  417. package/dist/components/u-signin-step.js +84 -0
  418. package/dist/components/u-signin-step.js.map +1 -0
  419. package/dist/components/u-signin-strategy.d.ts +11 -0
  420. package/dist/components/u-signin-strategy.js +50 -0
  421. package/dist/components/u-signin-strategy.js.map +1 -0
  422. package/dist/components/u-social-login-button.d.ts +11 -0
  423. package/dist/components/u-social-login-button.js +125 -0
  424. package/dist/components/u-social-login-button.js.map +1 -0
  425. package/dist/components/u-spinner.d.ts +11 -0
  426. package/dist/components/u-spinner.js +9 -0
  427. package/dist/components/u-spinner.js.map +1 -0
  428. package/dist/components/u-submit-button.d.ts +11 -0
  429. package/dist/components/u-submit-button.js +9 -0
  430. package/dist/components/u-submit-button.js.map +1 -0
  431. package/dist/components/u-ticketable-list.d.ts +11 -0
  432. package/dist/components/u-ticketable-list.js +6130 -0
  433. package/dist/components/u-ticketable-list.js.map +1 -0
  434. package/dist/components/unidy-store.js +37 -0
  435. package/dist/components/unidy-store.js.map +1 -0
  436. package/dist/esm/app-globals-BHWOrMsm.js +8 -0
  437. package/dist/esm/app-globals-BHWOrMsm.js.map +1 -0
  438. package/dist/esm/auth-CAHM6e4m.js +612 -0
  439. package/dist/esm/auth-CAHM6e4m.js.map +1 -0
  440. package/dist/esm/auth-store-ItTnEMlF.js +182 -0
  441. package/dist/esm/auth-store-ItTnEMlF.js.map +1 -0
  442. package/dist/esm/component-utils-BGq0leDV.js +39 -0
  443. package/dist/esm/component-utils-BGq0leDV.js.map +1 -0
  444. package/dist/esm/flash-store-CMXH65i_.js +47 -0
  445. package/dist/esm/flash-store-CMXH65i_.js.map +1 -0
  446. package/dist/esm/helpers-BqFCd65h.js +9 -0
  447. package/dist/esm/helpers-BqFCd65h.js.map +1 -0
  448. package/dist/esm/helpers-DUHc_Cx7.js +9 -0
  449. package/dist/esm/helpers-DUHc_Cx7.js.map +1 -0
  450. package/dist/esm/i18n-OKf8uE5j.js +3069 -0
  451. package/dist/esm/i18n-OKf8uE5j.js.map +1 -0
  452. package/dist/esm/index-COQ27Nb6.js +14684 -0
  453. package/dist/esm/index-COQ27Nb6.js.map +1 -0
  454. package/dist/esm/index-DVkRTYPC.js +281 -0
  455. package/dist/esm/index-DVkRTYPC.js.map +1 -0
  456. package/dist/esm/index-Du3hUdhU.js +6325 -0
  457. package/dist/esm/index-Du3hUdhU.js.map +1 -0
  458. package/dist/esm/index.js +40 -0
  459. package/dist/esm/index.js.map +1 -0
  460. package/dist/esm/loader.js +12 -0
  461. package/dist/esm/loader.js.map +1 -0
  462. package/dist/esm/newsletter-helpers-ChXON0f4.js +278 -0
  463. package/dist/esm/newsletter-helpers-ChXON0f4.js.map +1 -0
  464. package/dist/esm/newsletter-store-CIsyE51r.js +34 -0
  465. package/dist/esm/newsletter-store-CIsyE51r.js.map +1 -0
  466. package/dist/esm/pagination-store-B9lk_lqK.js +14 -0
  467. package/dist/esm/pagination-store-B9lk_lqK.js.map +1 -0
  468. package/dist/esm/profile-helpers-Beduxnin.js +36 -0
  469. package/dist/esm/profile-helpers-Beduxnin.js.map +1 -0
  470. package/dist/esm/profile-store-CsSDT9Tb.js +18 -0
  471. package/dist/esm/profile-store-CsSDT9Tb.js.map +1 -0
  472. package/dist/esm/sdk.js +49 -0
  473. package/dist/esm/sdk.js.map +1 -0
  474. package/dist/esm/u-conditional-render.entry.js +100 -0
  475. package/dist/esm/u-conditional-render.entry.js.map +1 -0
  476. package/dist/esm/u-config.entry.js +89 -0
  477. package/dist/esm/u-config.entry.js.map +1 -0
  478. package/dist/esm/u-email-field.entry.js +75 -0
  479. package/dist/esm/u-email-field.entry.js.map +1 -0
  480. package/dist/esm/u-error-message.entry.js +80 -0
  481. package/dist/esm/u-error-message.entry.js.map +1 -0
  482. package/dist/esm/u-field.u-raw-field.entry.js.map +1 -0
  483. package/dist/esm/u-field_2.entry.js +368 -0
  484. package/dist/esm/u-flash-message.entry.js +35 -0
  485. package/dist/esm/u-flash-message.entry.js.map +1 -0
  486. package/dist/esm/u-full-profile.entry.js +35 -0
  487. package/dist/esm/u-full-profile.entry.js.map +1 -0
  488. package/dist/esm/u-logout-button.u-signed-in.entry.js.map +1 -0
  489. package/dist/esm/u-logout-button_2.entry.js +59 -0
  490. package/dist/esm/u-magic-code-field.entry.js +89 -0
  491. package/dist/esm/u-magic-code-field.entry.js.map +1 -0
  492. package/dist/esm/u-missing-field.entry.js +20 -0
  493. package/dist/esm/u-missing-field.entry.js.map +1 -0
  494. package/dist/esm/u-missing-fields-submit-button.entry.js +44 -0
  495. package/dist/esm/u-missing-fields-submit-button.entry.js.map +1 -0
  496. package/dist/esm/u-newsletter-checkbox.entry.js +75 -0
  497. package/dist/esm/u-newsletter-checkbox.entry.js.map +1 -0
  498. package/dist/esm/u-newsletter-logout-button.entry.js +39 -0
  499. package/dist/esm/u-newsletter-logout-button.entry.js.map +1 -0
  500. package/dist/esm/u-newsletter-preference-checkbox.entry.js +118 -0
  501. package/dist/esm/u-newsletter-preference-checkbox.entry.js.map +1 -0
  502. package/dist/esm/u-newsletter-resend-doi-button.entry.js +47 -0
  503. package/dist/esm/u-newsletter-resend-doi-button.entry.js.map +1 -0
  504. package/dist/esm/u-newsletter-root.entry.js +70 -0
  505. package/dist/esm/u-newsletter-root.entry.js.map +1 -0
  506. package/dist/esm/u-newsletter-toggle-subscription-button.entry.js +71 -0
  507. package/dist/esm/u-newsletter-toggle-subscription-button.entry.js.map +1 -0
  508. package/dist/esm/u-pagination-button.entry.js +61 -0
  509. package/dist/esm/u-pagination-button.entry.js.map +1 -0
  510. package/dist/esm/u-pagination-page.entry.js +42 -0
  511. package/dist/esm/u-pagination-page.entry.js.map +1 -0
  512. package/dist/esm/u-passkey.entry.js +45 -0
  513. package/dist/esm/u-passkey.entry.js.map +1 -0
  514. package/dist/esm/u-password-field.entry.js +104 -0
  515. package/dist/esm/u-password-field.entry.js.map +1 -0
  516. package/dist/esm/u-profile.u-submit-button.entry.js.map +1 -0
  517. package/dist/esm/u-profile_2.entry.js +326 -0
  518. package/dist/esm/u-registration-button.entry.js +46 -0
  519. package/dist/esm/u-registration-button.entry.js.map +1 -0
  520. package/dist/esm/u-reset-password-button.entry.js +54 -0
  521. package/dist/esm/u-reset-password-button.entry.js.map +1 -0
  522. package/dist/esm/u-send-magic-code-button.entry.js +66 -0
  523. package/dist/esm/u-send-magic-code-button.entry.js.map +1 -0
  524. package/dist/esm/u-signin-root.entry.js +41 -0
  525. package/dist/esm/u-signin-root.entry.js.map +1 -0
  526. package/dist/esm/u-signin-step.entry.js +64 -0
  527. package/dist/esm/u-signin-step.entry.js.map +1 -0
  528. package/dist/esm/u-signin-strategy.entry.js +28 -0
  529. package/dist/esm/u-signin-strategy.entry.js.map +1 -0
  530. package/dist/esm/u-social-login-button.entry.js +98 -0
  531. package/dist/esm/u-social-login-button.entry.js.map +1 -0
  532. package/dist/esm/u-spinner.entry.js +16 -0
  533. package/dist/esm/u-spinner.entry.js.map +1 -0
  534. package/dist/esm/u-ticketable-list.entry.js +6095 -0
  535. package/dist/esm/u-ticketable-list.entry.js.map +1 -0
  536. package/dist/esm/unidy-store-CAcMVdD8.js +37 -0
  537. package/dist/esm/unidy-store-CAcMVdD8.js.map +1 -0
  538. package/dist/index.cjs.js +1 -0
  539. package/dist/index.js +1 -0
  540. package/dist/sdk/index.esm.js +2 -0
  541. package/dist/sdk/index.esm.js.map +1 -0
  542. package/dist/sdk/loader.esm.js.map +1 -0
  543. package/dist/sdk/locales/de.json +133 -0
  544. package/dist/sdk/locales/en.json +133 -0
  545. package/dist/sdk/locales/fr.json +133 -0
  546. package/dist/sdk/locales/it.json +133 -0
  547. package/dist/sdk/locales/nl_be.json +133 -0
  548. package/dist/sdk/locales/ro.json +133 -0
  549. package/dist/sdk/p-1bad3fd0.entry.js +2 -0
  550. package/dist/sdk/p-1bad3fd0.entry.js.map +1 -0
  551. package/dist/sdk/p-1d6982cd.entry.js +2 -0
  552. package/dist/sdk/p-1d6982cd.entry.js.map +1 -0
  553. package/dist/sdk/p-23d8e922.entry.js +2 -0
  554. package/dist/sdk/p-23d8e922.entry.js.map +1 -0
  555. package/dist/sdk/p-2855d3bb.entry.js +2 -0
  556. package/dist/sdk/p-2855d3bb.entry.js.map +1 -0
  557. package/dist/sdk/p-288f37c3.entry.js +2 -0
  558. package/dist/sdk/p-288f37c3.entry.js.map +1 -0
  559. package/dist/sdk/p-32842e98.entry.js +2 -0
  560. package/dist/sdk/p-32842e98.entry.js.map +1 -0
  561. package/dist/sdk/p-34af7470.entry.js +2 -0
  562. package/dist/sdk/p-34af7470.entry.js.map +1 -0
  563. package/dist/sdk/p-39126514.entry.js +2 -0
  564. package/dist/sdk/p-39126514.entry.js.map +1 -0
  565. package/dist/sdk/p-438f62e5.entry.js +2 -0
  566. package/dist/sdk/p-438f62e5.entry.js.map +1 -0
  567. package/dist/sdk/p-46013b2f.entry.js +2 -0
  568. package/dist/sdk/p-46013b2f.entry.js.map +1 -0
  569. package/dist/sdk/p-46cdb255.entry.js +2 -0
  570. package/dist/sdk/p-46cdb255.entry.js.map +1 -0
  571. package/dist/sdk/p-4d9bde6e.entry.js +2 -0
  572. package/dist/sdk/p-4d9bde6e.entry.js.map +1 -0
  573. package/dist/sdk/p-5c40c6ea.entry.js +2 -0
  574. package/dist/sdk/p-5c40c6ea.entry.js.map +1 -0
  575. package/dist/sdk/p-5c8b31bd.entry.js +2 -0
  576. package/dist/sdk/p-5c8b31bd.entry.js.map +1 -0
  577. package/dist/sdk/p-69172b22.entry.js +2 -0
  578. package/dist/sdk/p-69172b22.entry.js.map +1 -0
  579. package/dist/sdk/p-7381aca7.entry.js +2 -0
  580. package/dist/sdk/p-7381aca7.entry.js.map +1 -0
  581. package/dist/sdk/p-BGq0leDV.js +2 -0
  582. package/dist/sdk/p-BGq0leDV.js.map +1 -0
  583. package/dist/sdk/p-BR6L248H.js +2 -0
  584. package/dist/sdk/p-BR6L248H.js.map +1 -0
  585. package/dist/sdk/p-BhrvnKAS.js +2 -0
  586. package/dist/sdk/p-BhrvnKAS.js.map +1 -0
  587. package/dist/sdk/p-BqFCd65h.js +2 -0
  588. package/dist/sdk/p-BqFCd65h.js.map +1 -0
  589. package/dist/sdk/p-CMw6v6sC.js +2 -0
  590. package/dist/sdk/p-CMw6v6sC.js.map +1 -0
  591. package/dist/sdk/p-COQ27Nb6.js +14 -0
  592. package/dist/sdk/p-COQ27Nb6.js.map +1 -0
  593. package/dist/sdk/p-CSLU6kes.js +2 -0
  594. package/dist/sdk/p-CSLU6kes.js.map +1 -0
  595. package/dist/sdk/p-Cai8JwlG.js +2 -0
  596. package/dist/sdk/p-Cai8JwlG.js.map +1 -0
  597. package/dist/sdk/p-CpJghKnM.js +2 -0
  598. package/dist/sdk/p-CpJghKnM.js.map +1 -0
  599. package/dist/sdk/p-DAn4FkxC.js +2 -0
  600. package/dist/sdk/p-DAn4FkxC.js.map +1 -0
  601. package/dist/sdk/p-DUHc_Cx7.js +2 -0
  602. package/dist/sdk/p-DUHc_Cx7.js.map +1 -0
  603. package/dist/sdk/p-FFRhPCmc.js +2 -0
  604. package/dist/sdk/p-FFRhPCmc.js.map +1 -0
  605. package/dist/sdk/p-Jrp0G45B.js +2 -0
  606. package/dist/sdk/p-Jrp0G45B.js.map +1 -0
  607. package/dist/sdk/p-MA26cw6g.js +2 -0
  608. package/dist/sdk/p-MA26cw6g.js.map +1 -0
  609. package/dist/sdk/p-P0eZf5rH.js +2 -0
  610. package/dist/sdk/p-P0eZf5rH.js.map +1 -0
  611. package/dist/sdk/p-PSIHL0wP.js +2 -0
  612. package/dist/sdk/p-PSIHL0wP.js.map +1 -0
  613. package/dist/sdk/p-a341c7f6.entry.js +2 -0
  614. package/dist/sdk/p-a341c7f6.entry.js.map +1 -0
  615. package/dist/sdk/p-a38cd448.entry.js +2 -0
  616. package/dist/sdk/p-a38cd448.entry.js.map +1 -0
  617. package/dist/sdk/p-a45ef398.entry.js +2 -0
  618. package/dist/sdk/p-a45ef398.entry.js.map +1 -0
  619. package/dist/sdk/p-b5a6ad01.entry.js +2 -0
  620. package/dist/sdk/p-b5a6ad01.entry.js.map +1 -0
  621. package/dist/sdk/p-b93bf91d.entry.js +2 -0
  622. package/dist/sdk/p-b93bf91d.entry.js.map +1 -0
  623. package/dist/sdk/p-baf5dcb7.entry.js +2 -0
  624. package/dist/sdk/p-baf5dcb7.entry.js.map +1 -0
  625. package/dist/sdk/p-c07a43e2.entry.js +2 -0
  626. package/dist/sdk/p-c07a43e2.entry.js.map +1 -0
  627. package/dist/sdk/p-c98ad60d.entry.js +2 -0
  628. package/dist/sdk/p-c98ad60d.entry.js.map +1 -0
  629. package/dist/sdk/p-d0c0fb6b.entry.js +2 -0
  630. package/dist/sdk/p-d0c0fb6b.entry.js.map +1 -0
  631. package/dist/sdk/p-d47aaf26.entry.js +2 -0
  632. package/dist/sdk/p-d47aaf26.entry.js.map +1 -0
  633. package/dist/sdk/p-e5ef30ef.entry.js +2 -0
  634. package/dist/sdk/p-e5ef30ef.entry.js.map +1 -0
  635. package/dist/sdk/p-eb348798.entry.js +2 -0
  636. package/dist/sdk/p-eb348798.entry.js.map +1 -0
  637. package/dist/sdk/p-f82f500d.entry.js +2 -0
  638. package/dist/sdk/p-f82f500d.entry.js.map +1 -0
  639. package/dist/sdk/p-f88ed6e8.entry.js +2 -0
  640. package/dist/sdk/p-f88ed6e8.entry.js.map +1 -0
  641. package/dist/sdk/p-f9affafe.entry.js +2 -0
  642. package/dist/sdk/p-f9affafe.entry.js.map +1 -0
  643. package/dist/sdk/p-jyF1XwDG.js +2 -0
  644. package/dist/sdk/p-jyF1XwDG.js.map +1 -0
  645. package/dist/sdk/sdk.css +39 -0
  646. package/dist/sdk/sdk.esm.js +2 -0
  647. package/dist/sdk/sdk.esm.js.map +1 -0
  648. package/dist/sdk/u-conditional-render.entry.esm.js.map +1 -0
  649. package/dist/sdk/u-config.entry.esm.js.map +1 -0
  650. package/dist/sdk/u-email-field.entry.esm.js.map +1 -0
  651. package/dist/sdk/u-error-message.entry.esm.js.map +1 -0
  652. package/dist/sdk/u-field.u-raw-field.entry.esm.js.map +1 -0
  653. package/dist/sdk/u-flash-message.entry.esm.js.map +1 -0
  654. package/dist/sdk/u-full-profile.entry.esm.js.map +1 -0
  655. package/dist/sdk/u-logout-button.u-signed-in.entry.esm.js.map +1 -0
  656. package/dist/sdk/u-magic-code-field.entry.esm.js.map +1 -0
  657. package/dist/sdk/u-missing-field.entry.esm.js.map +1 -0
  658. package/dist/sdk/u-missing-fields-submit-button.entry.esm.js.map +1 -0
  659. package/dist/sdk/u-newsletter-checkbox.entry.esm.js.map +1 -0
  660. package/dist/sdk/u-newsletter-logout-button.entry.esm.js.map +1 -0
  661. package/dist/sdk/u-newsletter-preference-checkbox.entry.esm.js.map +1 -0
  662. package/dist/sdk/u-newsletter-resend-doi-button.entry.esm.js.map +1 -0
  663. package/dist/sdk/u-newsletter-root.entry.esm.js.map +1 -0
  664. package/dist/sdk/u-newsletter-toggle-subscription-button.entry.esm.js.map +1 -0
  665. package/dist/sdk/u-pagination-button.entry.esm.js.map +1 -0
  666. package/dist/sdk/u-pagination-page.entry.esm.js.map +1 -0
  667. package/dist/sdk/u-passkey.entry.esm.js.map +1 -0
  668. package/dist/sdk/u-password-field.entry.esm.js.map +1 -0
  669. package/dist/sdk/u-profile.u-submit-button.entry.esm.js.map +1 -0
  670. package/dist/sdk/u-registration-button.entry.esm.js.map +1 -0
  671. package/dist/sdk/u-reset-password-button.entry.esm.js.map +1 -0
  672. package/dist/sdk/u-send-magic-code-button.entry.esm.js.map +1 -0
  673. package/dist/sdk/u-signin-root.entry.esm.js.map +1 -0
  674. package/dist/sdk/u-signin-step.entry.esm.js.map +1 -0
  675. package/dist/sdk/u-signin-strategy.entry.esm.js.map +1 -0
  676. package/dist/sdk/u-social-login-button.entry.esm.js.map +1 -0
  677. package/dist/sdk/u-spinner.entry.esm.js.map +1 -0
  678. package/dist/sdk/u-ticketable-list.entry.esm.js.map +1 -0
  679. package/dist/types/api/client.d.ts +32 -0
  680. package/dist/types/api/index.d.ts +22 -0
  681. package/dist/types/api/shared.d.ts +20 -0
  682. package/dist/types/auth/api/auth.d.ts +302 -0
  683. package/dist/types/auth/auth-helpers.d.ts +376 -0
  684. package/dist/types/auth/auth.d.ts +62 -0
  685. package/dist/types/auth/components/helpers.d.ts +1 -0
  686. package/dist/types/auth/components/logout-button/logout-button.d.ts +11 -0
  687. package/dist/types/auth/components/magic-code-field/magic-code-field.d.ts +10 -0
  688. package/dist/types/auth/components/missing-field/missing-field.d.ts +4 -0
  689. package/dist/types/auth/components/missing-fields-submit-button/missing-fields-submit-button.d.ts +5 -0
  690. package/dist/types/auth/components/passkey/passkey.d.ts +9 -0
  691. package/dist/types/auth/components/password-field/password-field.d.ts +15 -0
  692. package/dist/types/auth/components/registration/registration-button.d.ts +11 -0
  693. package/dist/types/auth/components/reset-pass-button/reset-pass-button.d.ts +7 -0
  694. package/dist/types/auth/components/send-magic-code-button/send-magic-code-button.d.ts +11 -0
  695. package/dist/types/auth/components/signed-in/signed-in.d.ts +5 -0
  696. package/dist/types/auth/components/signin-root/signin-root.d.ts +14 -0
  697. package/dist/types/auth/components/signin-step/signin-step.d.ts +8 -0
  698. package/dist/types/auth/components/signin-strategy/signin-strategy.d.ts +5 -0
  699. package/dist/types/auth/components/social-logins/logos/apple.d.ts +4 -0
  700. package/dist/types/auth/components/social-logins/logos/discord.d.ts +4 -0
  701. package/dist/types/auth/components/social-logins/logos/facebook.d.ts +4 -0
  702. package/dist/types/auth/components/social-logins/logos/google.d.ts +4 -0
  703. package/dist/types/auth/components/social-logins/logos/linkedin.d.ts +4 -0
  704. package/dist/types/auth/components/social-logins/social-login-button.d.ts +24 -0
  705. package/dist/types/auth/components/submit-button/auth-submit-button.d.ts +3 -0
  706. package/dist/types/auth/error-definitions.d.ts +23 -0
  707. package/dist/types/auth/index.d.ts +15 -0
  708. package/dist/types/auth/passkey-auth.d.ts +2 -0
  709. package/dist/types/auth/store/auth-store.d.ts +58 -0
  710. package/dist/types/components.d.ts +1270 -0
  711. package/dist/types/globalScript.d.ts +1 -0
  712. package/dist/types/i18n.d.ts +3 -0
  713. package/dist/types/index.d.ts +16 -0
  714. package/dist/types/logger.d.ts +55 -0
  715. package/dist/types/newsletter/api/newsletters.d.ts +198 -0
  716. package/dist/types/newsletter/components/helpers.d.ts +1 -0
  717. package/dist/types/newsletter/components/logout-button/logout-button.d.ts +8 -0
  718. package/dist/types/newsletter/components/newsletter-checkbox/newsletter-checkbox.d.ts +15 -0
  719. package/dist/types/newsletter/components/newsletter-root/newsletter-root.d.ts +11 -0
  720. package/dist/types/newsletter/components/preference-checkbox/preference-checkbox.d.ts +28 -0
  721. package/dist/types/newsletter/components/resend-doi-button/resend-doi-button.d.ts +8 -0
  722. package/dist/types/newsletter/components/submit-button/newsletter-submit-button.d.ts +3 -0
  723. package/dist/types/newsletter/components/toggle-subscription-button/toggle-subscription-button.d.ts +12 -0
  724. package/dist/types/newsletter/index.d.ts +10 -0
  725. package/dist/types/newsletter/newsletter-helpers.d.ts +15 -0
  726. package/dist/types/newsletter/store/newsletter-store.d.ts +25 -0
  727. package/dist/types/profile/api/profile.d.ts +238 -0
  728. package/dist/types/profile/components/field/field.d.ts +39 -0
  729. package/dist/types/profile/components/full-profile/full-profile.d.ts +6 -0
  730. package/dist/types/profile/components/profile/profile.d.ts +27 -0
  731. package/dist/types/profile/components/raw-field/raw-field.d.ts +45 -0
  732. package/dist/types/profile/components/raw-input-fields/Input.d.ts +17 -0
  733. package/dist/types/profile/components/raw-input-fields/MultiSelect.d.ts +28 -0
  734. package/dist/types/profile/components/raw-input-fields/RadioGroup.d.ts +30 -0
  735. package/dist/types/profile/components/raw-input-fields/Select.d.ts +24 -0
  736. package/dist/types/profile/components/raw-input-fields/Textarea.d.ts +17 -0
  737. package/dist/types/profile/components/submit-button/profile-submit-button.d.ts +2 -0
  738. package/dist/types/profile/index.d.ts +12 -0
  739. package/dist/types/profile/profile-helpers.d.ts +7 -0
  740. package/dist/types/profile/store/profile-store.d.ts +39 -0
  741. package/dist/types/shared/component-utils.d.ts +16 -0
  742. package/dist/types/shared/components/conditional-render/conditional-render.d.ts +11 -0
  743. package/dist/types/shared/components/config/config.d.ts +32 -0
  744. package/dist/types/shared/components/email-field/email-field.d.ts +13 -0
  745. package/dist/types/shared/components/error-message/error-message.d.ts +15 -0
  746. package/dist/types/shared/components/flash-message/close-icon.d.ts +1 -0
  747. package/dist/types/shared/components/flash-message/flash-message.d.ts +6 -0
  748. package/dist/types/shared/components/spinner/spinner.d.ts +3 -0
  749. package/dist/types/shared/components/submit-button/context.d.ts +9 -0
  750. package/dist/types/shared/components/submit-button/submit-button.d.ts +20 -0
  751. package/dist/types/shared/store/flash-store.d.ts +29 -0
  752. package/dist/types/shared/store/unidy-store.d.ts +12 -0
  753. package/dist/types/stencil-public-runtime.d.ts +1756 -0
  754. package/dist/types/ticketable/api/get-with-schema.d.ts +3 -0
  755. package/dist/types/ticketable/api/schemas.d.ts +18 -0
  756. package/dist/types/ticketable/api/subscriptions.d.ts +84 -0
  757. package/dist/types/ticketable/api/tickets.d.ts +86 -0
  758. package/dist/types/ticketable/components/pagination/pagination-button.d.ts +14 -0
  759. package/dist/types/ticketable/components/pagination/pagination-page.d.ts +12 -0
  760. package/dist/types/ticketable/components/ticketable-list/skeleton-helpers.d.ts +13 -0
  761. package/dist/types/ticketable/components/ticketable-list/ticketable-list.d.ts +41 -0
  762. package/dist/types/ticketable/index.d.ts +12 -0
  763. package/dist/types/ticketable/store/pagination-store.d.ts +10 -0
  764. package/loader/cdn.js +1 -0
  765. package/loader/index.cjs.js +1 -0
  766. package/loader/index.d.ts +24 -0
  767. package/loader/index.es2017.js +1 -0
  768. package/loader/index.js +2 -0
  769. package/package.json +23 -18
@@ -0,0 +1,4262 @@
1
+ /**
2
+ * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
3
+ *
4
+ * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.
5
+ */
6
+ const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
7
+
8
+ /** Internal global with common properties and Sentry extensions */
9
+
10
+ /** Get's the global object for the current JavaScript runtime */
11
+ const GLOBAL_OBJ = globalThis ;
12
+
13
+ // This is a magic string replaced by rollup
14
+
15
+ const SDK_VERSION = "10.33.0" ;
16
+
17
+ /**
18
+ * An object that contains globally accessible properties and maintains a scope stack.
19
+ * @hidden
20
+ */
21
+
22
+ /**
23
+ * Returns the global shim registry.
24
+ *
25
+ * FIXME: This function is problematic, because despite always returning a valid Carrier,
26
+ * it has an optional `__SENTRY__` property, which then in turn requires us to always perform an unnecessary check
27
+ * at the call-site. We always access the carrier through this function, so we can guarantee that `__SENTRY__` is there.
28
+ **/
29
+ function getMainCarrier() {
30
+ // This ensures a Sentry carrier exists
31
+ getSentryCarrier(GLOBAL_OBJ);
32
+ return GLOBAL_OBJ;
33
+ }
34
+
35
+ /** Will either get the existing sentry carrier, or create a new one. */
36
+ function getSentryCarrier(carrier) {
37
+ const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {});
38
+
39
+ // For now: First SDK that sets the .version property wins
40
+ __SENTRY__.version = __SENTRY__.version || SDK_VERSION;
41
+
42
+ // Intentionally populating and returning the version of "this" SDK instance
43
+ // rather than what's set in .version so that "this" SDK always gets its carrier
44
+ return (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});
45
+ }
46
+
47
+ /**
48
+ * Returns a global singleton contained in the global `__SENTRY__[]` object.
49
+ *
50
+ * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory
51
+ * function and added to the `__SENTRY__` object.
52
+ *
53
+ * @param name name of the global singleton on __SENTRY__
54
+ * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__`
55
+ * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value
56
+ * @returns the singleton
57
+ */
58
+ function getGlobalSingleton(
59
+ name,
60
+ creator,
61
+ obj = GLOBAL_OBJ,
62
+ ) {
63
+ const __SENTRY__ = (obj.__SENTRY__ = obj.__SENTRY__ || {});
64
+ const carrier = (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {});
65
+ // Note: We do not want to set `carrier.version` here, as this may be called before any `init` is called, e.g. for the default scopes
66
+ return carrier[name] || (carrier[name] = creator());
67
+ }
68
+
69
+ const CONSOLE_LEVELS = [
70
+ 'debug',
71
+ 'info',
72
+ 'warn',
73
+ 'error',
74
+ 'log',
75
+ 'assert',
76
+ 'trace',
77
+ ] ;
78
+
79
+ /** Prefix for logging strings */
80
+ const PREFIX = 'Sentry Logger ';
81
+
82
+ /** This may be mutated by the console instrumentation. */
83
+ const originalConsoleMethods
84
+
85
+ = {};
86
+
87
+ /**
88
+ * Temporarily disable sentry console instrumentations.
89
+ *
90
+ * @param callback The function to run against the original `console` messages
91
+ * @returns The results of the callback
92
+ */
93
+ function consoleSandbox(callback) {
94
+ if (!('console' in GLOBAL_OBJ)) {
95
+ return callback();
96
+ }
97
+
98
+ const console = GLOBAL_OBJ.console;
99
+ const wrappedFuncs = {};
100
+
101
+ const wrappedLevels = Object.keys(originalConsoleMethods) ;
102
+
103
+ // Restore all wrapped console methods
104
+ wrappedLevels.forEach(level => {
105
+ const originalConsoleMethod = originalConsoleMethods[level];
106
+ wrappedFuncs[level] = console[level] ;
107
+ console[level] = originalConsoleMethod ;
108
+ });
109
+
110
+ try {
111
+ return callback();
112
+ } finally {
113
+ // Revert restoration to wrapped state
114
+ wrappedLevels.forEach(level => {
115
+ console[level] = wrappedFuncs[level] ;
116
+ });
117
+ }
118
+ }
119
+
120
+ function enable() {
121
+ _getLoggerSettings().enabled = true;
122
+ }
123
+
124
+ function disable() {
125
+ _getLoggerSettings().enabled = false;
126
+ }
127
+
128
+ function isEnabled() {
129
+ return _getLoggerSettings().enabled;
130
+ }
131
+
132
+ function log(...args) {
133
+ _maybeLog('log', ...args);
134
+ }
135
+
136
+ function warn(...args) {
137
+ _maybeLog('warn', ...args);
138
+ }
139
+
140
+ function error(...args) {
141
+ _maybeLog('error', ...args);
142
+ }
143
+
144
+ function _maybeLog(level, ...args) {
145
+ if (!DEBUG_BUILD) {
146
+ return;
147
+ }
148
+
149
+ if (isEnabled()) {
150
+ consoleSandbox(() => {
151
+ GLOBAL_OBJ.console[level](`${PREFIX}[${level}]:`, ...args);
152
+ });
153
+ }
154
+ }
155
+
156
+ function _getLoggerSettings() {
157
+ if (!DEBUG_BUILD) {
158
+ return { enabled: false };
159
+ }
160
+
161
+ return getGlobalSingleton('loggerSettings', () => ({ enabled: false }));
162
+ }
163
+
164
+ /**
165
+ * This is a logger singleton which either logs things or no-ops if logging is not enabled.
166
+ */
167
+ const debug = {
168
+ /** Enable logging. */
169
+ enable,
170
+ /** Disable logging. */
171
+ disable,
172
+ /** Check if logging is enabled. */
173
+ isEnabled,
174
+ /** Log a message. */
175
+ log,
176
+ /** Log a warning. */
177
+ warn,
178
+ /** Log an error. */
179
+ error,
180
+ } ;
181
+
182
+ const STACKTRACE_FRAME_LIMIT = 50;
183
+ const UNKNOWN_FUNCTION = '?';
184
+ // Used to sanitize webpack (error: *) wrapped stack errors
185
+ const WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
186
+ const STRIP_FRAME_REGEXP = /captureMessage|captureException/;
187
+
188
+ /**
189
+ * Creates a stack parser with the supplied line parsers
190
+ *
191
+ * StackFrames are returned in the correct order for Sentry Exception
192
+ * frames and with Sentry SDK internal frames removed from the top and bottom
193
+ *
194
+ */
195
+ function createStackParser(...parsers) {
196
+ const sortedParsers = parsers.sort((a, b) => a[0] - b[0]).map(p => p[1]);
197
+
198
+ return (stack, skipFirstLines = 0, framesToPop = 0) => {
199
+ const frames = [];
200
+ const lines = stack.split('\n');
201
+
202
+ for (let i = skipFirstLines; i < lines.length; i++) {
203
+ let line = lines[i] ;
204
+ // Truncate lines over 1kb because many of the regular expressions use
205
+ // backtracking which results in run time that increases exponentially
206
+ // with input size. Huge strings can result in hangs/Denial of Service:
207
+ // https://github.com/getsentry/sentry-javascript/issues/2286
208
+ if (line.length > 1024) {
209
+ line = line.slice(0, 1024);
210
+ }
211
+
212
+ // https://github.com/getsentry/sentry-javascript/issues/5459
213
+ // Remove webpack (error: *) wrappers
214
+ const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, '$1') : line;
215
+
216
+ // https://github.com/getsentry/sentry-javascript/issues/7813
217
+ // Skip Error: lines
218
+ if (cleanedLine.match(/\S*Error: /)) {
219
+ continue;
220
+ }
221
+
222
+ for (const parser of sortedParsers) {
223
+ const frame = parser(cleanedLine);
224
+
225
+ if (frame) {
226
+ frames.push(frame);
227
+ break;
228
+ }
229
+ }
230
+
231
+ if (frames.length >= STACKTRACE_FRAME_LIMIT + framesToPop) {
232
+ break;
233
+ }
234
+ }
235
+
236
+ return stripSentryFramesAndReverse(frames.slice(framesToPop));
237
+ };
238
+ }
239
+
240
+ /**
241
+ * Gets a stack parser implementation from Options.stackParser
242
+ * @see Options
243
+ *
244
+ * If options contains an array of line parsers, it is converted into a parser
245
+ */
246
+ function stackParserFromStackParserOptions(stackParser) {
247
+ if (Array.isArray(stackParser)) {
248
+ return createStackParser(...stackParser);
249
+ }
250
+ return stackParser;
251
+ }
252
+
253
+ /**
254
+ * Removes Sentry frames from the top and bottom of the stack if present and enforces a limit of max number of frames.
255
+ * Assumes stack input is ordered from top to bottom and returns the reverse representation so call site of the
256
+ * function that caused the crash is the last frame in the array.
257
+ * @hidden
258
+ */
259
+ function stripSentryFramesAndReverse(stack) {
260
+ if (!stack.length) {
261
+ return [];
262
+ }
263
+
264
+ const localStack = Array.from(stack);
265
+
266
+ // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
267
+ if (/sentryWrapped/.test(getLastStackFrame(localStack).function || '')) {
268
+ localStack.pop();
269
+ }
270
+
271
+ // Reversing in the middle of the procedure allows us to just pop the values off the stack
272
+ localStack.reverse();
273
+
274
+ // If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
275
+ if (STRIP_FRAME_REGEXP.test(getLastStackFrame(localStack).function || '')) {
276
+ localStack.pop();
277
+
278
+ // When using synthetic events, we will have a 2 levels deep stack, as `new Error('Sentry syntheticException')`
279
+ // is produced within the scope itself, making it:
280
+ //
281
+ // Sentry.captureException()
282
+ // scope.captureException()
283
+ //
284
+ // instead of just the top `Sentry` call itself.
285
+ // This forces us to possibly strip an additional frame in the exact same was as above.
286
+ if (STRIP_FRAME_REGEXP.test(getLastStackFrame(localStack).function || '')) {
287
+ localStack.pop();
288
+ }
289
+ }
290
+
291
+ return localStack.slice(0, STACKTRACE_FRAME_LIMIT).map(frame => ({
292
+ ...frame,
293
+ filename: frame.filename || getLastStackFrame(localStack).filename,
294
+ function: frame.function || UNKNOWN_FUNCTION,
295
+ }));
296
+ }
297
+
298
+ function getLastStackFrame(arr) {
299
+ return arr[arr.length - 1] || {};
300
+ }
301
+
302
+ const defaultFunctionName = '<anonymous>';
303
+
304
+ /**
305
+ * Safely extract function name from itself
306
+ */
307
+ function getFunctionName(fn) {
308
+ try {
309
+ if (!fn || typeof fn !== 'function') {
310
+ return defaultFunctionName;
311
+ }
312
+ return fn.name || defaultFunctionName;
313
+ } catch {
314
+ // Just accessing custom props in some Selenium environments
315
+ // can cause a "Permission denied" exception (see raven-js#495).
316
+ return defaultFunctionName;
317
+ }
318
+ }
319
+
320
+ /**
321
+ * Get's stack frames from an event without needing to check for undefined properties.
322
+ */
323
+ function getFramesFromEvent(event) {
324
+ const exception = event.exception;
325
+
326
+ if (exception) {
327
+ const frames = [];
328
+ try {
329
+ // @ts-expect-error Object could be undefined
330
+ exception.values.forEach(value => {
331
+ // @ts-expect-error Value could be undefined
332
+ if (value.stacktrace.frames) {
333
+ // @ts-expect-error Value could be undefined
334
+ frames.push(...value.stacktrace.frames);
335
+ }
336
+ });
337
+ return frames;
338
+ } catch {
339
+ return undefined;
340
+ }
341
+ }
342
+ return undefined;
343
+ }
344
+
345
+ /**
346
+ * Get the internal name of an internal Vue value, to represent it in a stacktrace.
347
+ *
348
+ * @param value The value to get the internal name of.
349
+ */
350
+ function getVueInternalName(value) {
351
+ // Check if it's a VNode (has __v_isVNode) or a component instance (has _isVue/__isVue)
352
+ const isVNode = '__v_isVNode' in value && value.__v_isVNode;
353
+
354
+ return isVNode ? '[VueVNode]' : '[VueViewModel]';
355
+ }
356
+
357
+ // eslint-disable-next-line @typescript-eslint/unbound-method
358
+ const objectToString = Object.prototype.toString;
359
+
360
+ /**
361
+ * Checks whether given value's type is one of a few Error or Error-like
362
+ * {@link isError}.
363
+ *
364
+ * @param wat A value to be checked.
365
+ * @returns A boolean representing the result.
366
+ */
367
+ function isError(wat) {
368
+ switch (objectToString.call(wat)) {
369
+ case '[object Error]':
370
+ case '[object Exception]':
371
+ case '[object DOMException]':
372
+ case '[object WebAssembly.Exception]':
373
+ return true;
374
+ default:
375
+ return isInstanceOf(wat, Error);
376
+ }
377
+ }
378
+ /**
379
+ * Checks whether given value is an instance of the given built-in class.
380
+ *
381
+ * @param wat The value to be checked
382
+ * @param className
383
+ * @returns A boolean representing the result.
384
+ */
385
+ function isBuiltin(wat, className) {
386
+ return objectToString.call(wat) === `[object ${className}]`;
387
+ }
388
+
389
+ /**
390
+ * Checks whether given value's type is ErrorEvent
391
+ * {@link isErrorEvent}.
392
+ *
393
+ * @param wat A value to be checked.
394
+ * @returns A boolean representing the result.
395
+ */
396
+ function isErrorEvent(wat) {
397
+ return isBuiltin(wat, 'ErrorEvent');
398
+ }
399
+
400
+ /**
401
+ * Checks whether given value's type is DOMError
402
+ * {@link isDOMError}.
403
+ *
404
+ * @param wat A value to be checked.
405
+ * @returns A boolean representing the result.
406
+ */
407
+ function isDOMError(wat) {
408
+ return isBuiltin(wat, 'DOMError');
409
+ }
410
+
411
+ /**
412
+ * Checks whether given value's type is DOMException
413
+ * {@link isDOMException}.
414
+ *
415
+ * @param wat A value to be checked.
416
+ * @returns A boolean representing the result.
417
+ */
418
+ function isDOMException(wat) {
419
+ return isBuiltin(wat, 'DOMException');
420
+ }
421
+
422
+ /**
423
+ * Checks whether given value's type is a string
424
+ * {@link isString}.
425
+ *
426
+ * @param wat A value to be checked.
427
+ * @returns A boolean representing the result.
428
+ */
429
+ function isString(wat) {
430
+ return isBuiltin(wat, 'String');
431
+ }
432
+
433
+ /**
434
+ * Checks whether given string is parameterized
435
+ * {@link isParameterizedString}.
436
+ *
437
+ * @param wat A value to be checked.
438
+ * @returns A boolean representing the result.
439
+ */
440
+ function isParameterizedString(wat) {
441
+ return (
442
+ typeof wat === 'object' &&
443
+ wat !== null &&
444
+ '__sentry_template_string__' in wat &&
445
+ '__sentry_template_values__' in wat
446
+ );
447
+ }
448
+
449
+ /**
450
+ * Checks whether given value is a primitive (undefined, null, number, boolean, string, bigint, symbol)
451
+ * {@link isPrimitive}.
452
+ *
453
+ * @param wat A value to be checked.
454
+ * @returns A boolean representing the result.
455
+ */
456
+ function isPrimitive(wat) {
457
+ return wat === null || isParameterizedString(wat) || (typeof wat !== 'object' && typeof wat !== 'function');
458
+ }
459
+
460
+ /**
461
+ * Checks whether given value's type is an object literal, or a class instance.
462
+ * {@link isPlainObject}.
463
+ *
464
+ * @param wat A value to be checked.
465
+ * @returns A boolean representing the result.
466
+ */
467
+ function isPlainObject(wat) {
468
+ return isBuiltin(wat, 'Object');
469
+ }
470
+
471
+ /**
472
+ * Checks whether given value's type is an Event instance
473
+ * {@link isEvent}.
474
+ *
475
+ * @param wat A value to be checked.
476
+ * @returns A boolean representing the result.
477
+ */
478
+ function isEvent(wat) {
479
+ return typeof Event !== 'undefined' && isInstanceOf(wat, Event);
480
+ }
481
+
482
+ /**
483
+ * Checks whether given value's type is an Element instance
484
+ * {@link isElement}.
485
+ *
486
+ * @param wat A value to be checked.
487
+ * @returns A boolean representing the result.
488
+ */
489
+ function isElement(wat) {
490
+ return typeof Element !== 'undefined' && isInstanceOf(wat, Element);
491
+ }
492
+
493
+ /**
494
+ * Checks whether given value's type is an regexp
495
+ * {@link isRegExp}.
496
+ *
497
+ * @param wat A value to be checked.
498
+ * @returns A boolean representing the result.
499
+ */
500
+ function isRegExp(wat) {
501
+ return isBuiltin(wat, 'RegExp');
502
+ }
503
+
504
+ /**
505
+ * Checks whether given value has a then function.
506
+ * @param wat A value to be checked.
507
+ */
508
+ function isThenable(wat) {
509
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
510
+ return Boolean(wat?.then && typeof wat.then === 'function');
511
+ }
512
+
513
+ /**
514
+ * Checks whether given value's type is a SyntheticEvent
515
+ * {@link isSyntheticEvent}.
516
+ *
517
+ * @param wat A value to be checked.
518
+ * @returns A boolean representing the result.
519
+ */
520
+ function isSyntheticEvent(wat) {
521
+ return isPlainObject(wat) && 'nativeEvent' in wat && 'preventDefault' in wat && 'stopPropagation' in wat;
522
+ }
523
+
524
+ /**
525
+ * Checks whether given value's type is an instance of provided constructor.
526
+ * {@link isInstanceOf}.
527
+ *
528
+ * @param wat A value to be checked.
529
+ * @param base A constructor to be used in a check.
530
+ * @returns A boolean representing the result.
531
+ */
532
+ // TODO: fix in v11, convert any to unknown
533
+ // export function isInstanceOf<T>(wat: unknown, base: { new (...args: any[]): T }): wat is T {
534
+ function isInstanceOf(wat, base) {
535
+ try {
536
+ return wat instanceof base;
537
+ } catch {
538
+ return false;
539
+ }
540
+ }
541
+
542
+ /**
543
+ * Checks whether given value's type is a Vue ViewModel or a VNode.
544
+ *
545
+ * @param wat A value to be checked.
546
+ * @returns A boolean representing the result.
547
+ */
548
+ function isVueViewModel(wat) {
549
+ // Not using Object.prototype.toString because in Vue 3 it would read the instance's Symbol(Symbol.toStringTag) property.
550
+ // We also need to check for __v_isVNode because Vue 3 component render instances have an internal __v_isVNode property.
551
+ return !!(
552
+ typeof wat === 'object' &&
553
+ wat !== null &&
554
+ ((wat ).__isVue || (wat )._isVue || (wat ).__v_isVNode)
555
+ );
556
+ }
557
+
558
+ /**
559
+ * Checks whether the given parameter is a Standard Web API Request instance.
560
+ *
561
+ * Returns false if Request is not available in the current runtime.
562
+ */
563
+ function isRequest(request) {
564
+ return typeof Request !== 'undefined' && isInstanceOf(request, Request);
565
+ }
566
+
567
+ const WINDOW = GLOBAL_OBJ ;
568
+
569
+ const DEFAULT_MAX_STRING_LENGTH = 80;
570
+
571
+ /**
572
+ * Given a child DOM element, returns a query-selector statement describing that
573
+ * and its ancestors
574
+ * e.g. [HTMLElement] => body > div > input#foo.btn[name=baz]
575
+ * @returns generated DOM path
576
+ */
577
+ function htmlTreeAsString(
578
+ elem,
579
+ options = {},
580
+ ) {
581
+ if (!elem) {
582
+ return '<unknown>';
583
+ }
584
+
585
+ // try/catch both:
586
+ // - accessing event.target (see getsentry/raven-js#838, #768)
587
+ // - `htmlTreeAsString` because it's complex, and just accessing the DOM incorrectly
588
+ // - can throw an exception in some circumstances.
589
+ try {
590
+ let currentElem = elem ;
591
+ const MAX_TRAVERSE_HEIGHT = 5;
592
+ const out = [];
593
+ let height = 0;
594
+ let len = 0;
595
+ const separator = ' > ';
596
+ const sepLength = separator.length;
597
+ let nextStr;
598
+ const keyAttrs = Array.isArray(options) ? options : options.keyAttrs;
599
+ const maxStringLength = (!Array.isArray(options) && options.maxStringLength) || DEFAULT_MAX_STRING_LENGTH;
600
+
601
+ while (currentElem && height++ < MAX_TRAVERSE_HEIGHT) {
602
+ nextStr = _htmlElementAsString(currentElem, keyAttrs);
603
+ // bail out if
604
+ // - nextStr is the 'html' element
605
+ // - the length of the string that would be created exceeds maxStringLength
606
+ // (ignore this limit if we are on the first iteration)
607
+ if (nextStr === 'html' || (height > 1 && len + out.length * sepLength + nextStr.length >= maxStringLength)) {
608
+ break;
609
+ }
610
+
611
+ out.push(nextStr);
612
+
613
+ len += nextStr.length;
614
+ currentElem = currentElem.parentNode;
615
+ }
616
+
617
+ return out.reverse().join(separator);
618
+ } catch {
619
+ return '<unknown>';
620
+ }
621
+ }
622
+
623
+ /**
624
+ * Returns a simple, query-selector representation of a DOM element
625
+ * e.g. [HTMLElement] => input#foo.btn[name=baz]
626
+ * @returns generated DOM path
627
+ */
628
+ function _htmlElementAsString(el, keyAttrs) {
629
+ const elem = el
630
+
631
+ ;
632
+
633
+ const out = [];
634
+
635
+ if (!elem?.tagName) {
636
+ return '';
637
+ }
638
+
639
+ // @ts-expect-error WINDOW has HTMLElement
640
+ if (WINDOW.HTMLElement) {
641
+ // If using the component name annotation plugin, this value may be available on the DOM node
642
+ if (elem instanceof HTMLElement && elem.dataset) {
643
+ if (elem.dataset['sentryComponent']) {
644
+ return elem.dataset['sentryComponent'];
645
+ }
646
+ if (elem.dataset['sentryElement']) {
647
+ return elem.dataset['sentryElement'];
648
+ }
649
+ }
650
+ }
651
+
652
+ out.push(elem.tagName.toLowerCase());
653
+
654
+ // Pairs of attribute keys defined in `serializeAttribute` and their values on element.
655
+ const keyAttrPairs = keyAttrs?.length
656
+ ? keyAttrs.filter(keyAttr => elem.getAttribute(keyAttr)).map(keyAttr => [keyAttr, elem.getAttribute(keyAttr)])
657
+ : null;
658
+
659
+ if (keyAttrPairs?.length) {
660
+ keyAttrPairs.forEach(keyAttrPair => {
661
+ out.push(`[${keyAttrPair[0]}="${keyAttrPair[1]}"]`);
662
+ });
663
+ } else {
664
+ if (elem.id) {
665
+ out.push(`#${elem.id}`);
666
+ }
667
+
668
+ const className = elem.className;
669
+ if (className && isString(className)) {
670
+ const classes = className.split(/\s+/);
671
+ for (const c of classes) {
672
+ out.push(`.${c}`);
673
+ }
674
+ }
675
+ }
676
+ const allowedAttrs = ['aria-label', 'type', 'name', 'title', 'alt'];
677
+ for (const k of allowedAttrs) {
678
+ const attr = elem.getAttribute(k);
679
+ if (attr) {
680
+ out.push(`[${k}="${attr}"]`);
681
+ }
682
+ }
683
+
684
+ return out.join('');
685
+ }
686
+
687
+ /**
688
+ * A safe form of location.href
689
+ */
690
+ function getLocationHref() {
691
+ try {
692
+ return WINDOW.document.location.href;
693
+ } catch {
694
+ return '';
695
+ }
696
+ }
697
+
698
+ /**
699
+ * Given a DOM element, traverses up the tree until it finds the first ancestor node
700
+ * that has the `data-sentry-component` or `data-sentry-element` attribute with `data-sentry-component` taking
701
+ * precedence. This attribute is added at build-time by projects that have the component name annotation plugin installed.
702
+ *
703
+ * @returns a string representation of the component for the provided DOM element, or `null` if not found
704
+ */
705
+ function getComponentName(elem) {
706
+ // @ts-expect-error WINDOW has HTMLElement
707
+ if (!WINDOW.HTMLElement) {
708
+ return null;
709
+ }
710
+
711
+ let currentElem = elem ;
712
+ const MAX_TRAVERSE_HEIGHT = 5;
713
+ for (let i = 0; i < MAX_TRAVERSE_HEIGHT; i++) {
714
+ if (!currentElem) {
715
+ return null;
716
+ }
717
+
718
+ if (currentElem instanceof HTMLElement) {
719
+ if (currentElem.dataset['sentryComponent']) {
720
+ return currentElem.dataset['sentryComponent'];
721
+ }
722
+ if (currentElem.dataset['sentryElement']) {
723
+ return currentElem.dataset['sentryElement'];
724
+ }
725
+ }
726
+
727
+ currentElem = currentElem.parentNode;
728
+ }
729
+
730
+ return null;
731
+ }
732
+
733
+ /* eslint-disable @typescript-eslint/no-explicit-any */
734
+
735
+ /**
736
+ * Replace a method in an object with a wrapped version of itself.
737
+ *
738
+ * If the method on the passed object is not a function, the wrapper will not be applied.
739
+ *
740
+ * @param source An object that contains a method to be wrapped.
741
+ * @param name The name of the method to be wrapped.
742
+ * @param replacementFactory A higher-order function that takes the original version of the given method and returns a
743
+ * wrapped version. Note: The function returned by `replacementFactory` needs to be a non-arrow function, in order to
744
+ * preserve the correct value of `this`, and the original method must be called using `origMethod.call(this, <other
745
+ * args>)` or `origMethod.apply(this, [<other args>])` (rather than being called directly), again to preserve `this`.
746
+ * @returns void
747
+ */
748
+ function fill(source, name, replacementFactory) {
749
+ if (!(name in source)) {
750
+ return;
751
+ }
752
+
753
+ // explicitly casting to unknown because we don't know the type of the method initially at all
754
+ const original = source[name] ;
755
+
756
+ if (typeof original !== 'function') {
757
+ return;
758
+ }
759
+
760
+ const wrapped = replacementFactory(original) ;
761
+
762
+ // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work
763
+ // otherwise it'll throw "TypeError: Object.defineProperties called on non-object"
764
+ if (typeof wrapped === 'function') {
765
+ markFunctionWrapped(wrapped, original);
766
+ }
767
+
768
+ try {
769
+ source[name] = wrapped;
770
+ } catch {
771
+ DEBUG_BUILD && debug.log(`Failed to replace method "${name}" in object`, source);
772
+ }
773
+ }
774
+
775
+ /**
776
+ * Defines a non-enumerable property on the given object.
777
+ *
778
+ * @param obj The object on which to set the property
779
+ * @param name The name of the property to be set
780
+ * @param value The value to which to set the property
781
+ */
782
+ function addNonEnumerableProperty(obj, name, value) {
783
+ try {
784
+ Object.defineProperty(obj, name, {
785
+ // enumerable: false, // the default, so we can save on bundle size by not explicitly setting it
786
+ value: value,
787
+ writable: true,
788
+ configurable: true,
789
+ });
790
+ } catch {
791
+ DEBUG_BUILD && debug.log(`Failed to add non-enumerable property "${name}" to object`, obj);
792
+ }
793
+ }
794
+
795
+ /**
796
+ * Remembers the original function on the wrapped function and
797
+ * patches up the prototype.
798
+ *
799
+ * @param wrapped the wrapper function
800
+ * @param original the original function that gets wrapped
801
+ */
802
+ function markFunctionWrapped(wrapped, original) {
803
+ try {
804
+ const proto = original.prototype || {};
805
+ wrapped.prototype = original.prototype = proto;
806
+ addNonEnumerableProperty(wrapped, '__sentry_original__', original);
807
+ } catch {} // eslint-disable-line no-empty
808
+ }
809
+
810
+ /**
811
+ * This extracts the original function if available. See
812
+ * `markFunctionWrapped` for more information.
813
+ *
814
+ * @param func the function to unwrap
815
+ * @returns the unwrapped version of the function if available.
816
+ */
817
+ // eslint-disable-next-line @typescript-eslint/ban-types
818
+ function getOriginalFunction(func) {
819
+ return func.__sentry_original__;
820
+ }
821
+
822
+ /**
823
+ * Transforms any `Error` or `Event` into a plain object with all of their enumerable properties, and some of their
824
+ * non-enumerable properties attached.
825
+ *
826
+ * @param value Initial source that we have to transform in order for it to be usable by the serializer
827
+ * @returns An Event or Error turned into an object - or the value argument itself, when value is neither an Event nor
828
+ * an Error.
829
+ */
830
+ function convertToPlainObject(value)
831
+
832
+ {
833
+ if (isError(value)) {
834
+ return {
835
+ message: value.message,
836
+ name: value.name,
837
+ stack: value.stack,
838
+ ...getOwnProperties(value),
839
+ };
840
+ } else if (isEvent(value)) {
841
+ const newObj
842
+
843
+ = {
844
+ type: value.type,
845
+ target: serializeEventTarget(value.target),
846
+ currentTarget: serializeEventTarget(value.currentTarget),
847
+ ...getOwnProperties(value),
848
+ };
849
+
850
+ if (typeof CustomEvent !== 'undefined' && isInstanceOf(value, CustomEvent)) {
851
+ newObj.detail = value.detail;
852
+ }
853
+
854
+ return newObj;
855
+ } else {
856
+ return value;
857
+ }
858
+ }
859
+
860
+ /** Creates a string representation of the target of an `Event` object */
861
+ function serializeEventTarget(target) {
862
+ try {
863
+ return isElement(target) ? htmlTreeAsString(target) : Object.prototype.toString.call(target);
864
+ } catch {
865
+ return '<unknown>';
866
+ }
867
+ }
868
+
869
+ /** Filters out all but an object's own properties */
870
+ function getOwnProperties(obj) {
871
+ if (typeof obj === 'object' && obj !== null) {
872
+ const extractedProps = {};
873
+ for (const property in obj) {
874
+ if (Object.prototype.hasOwnProperty.call(obj, property)) {
875
+ extractedProps[property] = (obj )[property];
876
+ }
877
+ }
878
+ return extractedProps;
879
+ } else {
880
+ return {};
881
+ }
882
+ }
883
+
884
+ /**
885
+ * Given any captured exception, extract its keys and create a sorted
886
+ * and truncated list that will be used inside the event message.
887
+ * eg. `Non-error exception captured with keys: foo, bar, baz`
888
+ */
889
+ function extractExceptionKeysForMessage(exception) {
890
+ const keys = Object.keys(convertToPlainObject(exception));
891
+ keys.sort();
892
+
893
+ return !keys[0] ? '[object has no keys]' : keys.join(', ');
894
+ }
895
+
896
+ // undefined = not yet resolved, null = no runner found, function = runner found
897
+ let RESOLVED_RUNNER;
898
+
899
+ /**
900
+ * Simple wrapper that allows SDKs to *secretly* set context wrapper to generate safe random IDs in cache components contexts
901
+ */
902
+ function withRandomSafeContext(cb) {
903
+ // Skips future symbol lookups if we've already resolved (or attempted to resolve) the runner once
904
+ if (RESOLVED_RUNNER !== undefined) {
905
+ return RESOLVED_RUNNER ? RESOLVED_RUNNER(cb) : cb();
906
+ }
907
+
908
+ const sym = Symbol.for('__SENTRY_SAFE_RANDOM_ID_WRAPPER__');
909
+ const globalWithSymbol = GLOBAL_OBJ;
910
+
911
+ if (sym in globalWithSymbol && typeof globalWithSymbol[sym] === 'function') {
912
+ RESOLVED_RUNNER = globalWithSymbol[sym];
913
+ return RESOLVED_RUNNER(cb);
914
+ }
915
+
916
+ RESOLVED_RUNNER = null;
917
+ return cb();
918
+ }
919
+
920
+ /**
921
+ * Identical to Math.random() but wrapped in withRandomSafeContext
922
+ * to ensure safe random number generation in certain contexts (e.g., Next.js Cache Components).
923
+ */
924
+ function safeMathRandom() {
925
+ return withRandomSafeContext(() => Math.random());
926
+ }
927
+
928
+ /**
929
+ * Identical to Date.now() but wrapped in withRandomSafeContext
930
+ * to ensure safe time value generation in certain contexts (e.g., Next.js Cache Components).
931
+ */
932
+ function safeDateNow() {
933
+ return withRandomSafeContext(() => Date.now());
934
+ }
935
+
936
+ /**
937
+ * Truncates given string to the maximum characters count
938
+ *
939
+ * @param str An object that contains serializable values
940
+ * @param max Maximum number of characters in truncated string (0 = unlimited)
941
+ * @returns string Encoded
942
+ */
943
+ function truncate(str, max = 0) {
944
+ if (typeof str !== 'string' || max === 0) {
945
+ return str;
946
+ }
947
+ return str.length <= max ? str : `${str.slice(0, max)}...`;
948
+ }
949
+
950
+ /**
951
+ * Join values in array
952
+ * @param input array of values to be joined together
953
+ * @param delimiter string to be placed in-between values
954
+ * @returns Joined values
955
+ */
956
+ function safeJoin(input, delimiter) {
957
+ if (!Array.isArray(input)) {
958
+ return '';
959
+ }
960
+
961
+ const output = [];
962
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
963
+ for (let i = 0; i < input.length; i++) {
964
+ const value = input[i];
965
+ try {
966
+ // This is a hack to fix a Vue3-specific bug that causes an infinite loop of
967
+ // console warnings. This happens when a Vue template is rendered with
968
+ // an undeclared variable, which we try to stringify, ultimately causing
969
+ // Vue to issue another warning which repeats indefinitely.
970
+ // see: https://github.com/getsentry/sentry-javascript/pull/8981
971
+ if (isVueViewModel(value)) {
972
+ output.push(getVueInternalName(value));
973
+ } else {
974
+ output.push(String(value));
975
+ }
976
+ } catch {
977
+ output.push('[value cannot be serialized]');
978
+ }
979
+ }
980
+
981
+ return output.join(delimiter);
982
+ }
983
+
984
+ /**
985
+ * Checks if the given value matches a regex or string
986
+ *
987
+ * @param value The string to test
988
+ * @param pattern Either a regex or a string against which `value` will be matched
989
+ * @param requireExactStringMatch If true, `value` must match `pattern` exactly. If false, `value` will match
990
+ * `pattern` if it contains `pattern`. Only applies to string-type patterns.
991
+ */
992
+ function isMatchingPattern(
993
+ value,
994
+ pattern,
995
+ requireExactStringMatch = false,
996
+ ) {
997
+ if (!isString(value)) {
998
+ return false;
999
+ }
1000
+
1001
+ if (isRegExp(pattern)) {
1002
+ return pattern.test(value);
1003
+ }
1004
+ if (isString(pattern)) {
1005
+ return requireExactStringMatch ? value === pattern : value.includes(pattern);
1006
+ }
1007
+
1008
+ return false;
1009
+ }
1010
+
1011
+ /**
1012
+ * Test the given string against an array of strings and regexes. By default, string matching is done on a
1013
+ * substring-inclusion basis rather than a strict equality basis
1014
+ *
1015
+ * @param testString The string to test
1016
+ * @param patterns The patterns against which to test the string
1017
+ * @param requireExactStringMatch If true, `testString` must match one of the given string patterns exactly in order to
1018
+ * count. If false, `testString` will match a string pattern if it contains that pattern.
1019
+ * @returns
1020
+ */
1021
+ function stringMatchesSomePattern(
1022
+ testString,
1023
+ patterns = [],
1024
+ requireExactStringMatch = false,
1025
+ ) {
1026
+ return patterns.some(pattern => isMatchingPattern(testString, pattern, requireExactStringMatch));
1027
+ }
1028
+
1029
+ function getCrypto() {
1030
+ const gbl = GLOBAL_OBJ ;
1031
+ return gbl.crypto || gbl.msCrypto;
1032
+ }
1033
+
1034
+ let emptyUuid;
1035
+
1036
+ function getRandomByte() {
1037
+ return safeMathRandom() * 16;
1038
+ }
1039
+
1040
+ /**
1041
+ * UUID4 generator
1042
+ * @param crypto Object that provides the crypto API.
1043
+ * @returns string Generated UUID4.
1044
+ */
1045
+ function uuid4(crypto = getCrypto()) {
1046
+ try {
1047
+ if (crypto?.randomUUID) {
1048
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1049
+ return withRandomSafeContext(() => crypto.randomUUID()).replace(/-/g, '');
1050
+ }
1051
+ } catch {
1052
+ // some runtimes can crash invoking crypto
1053
+ // https://github.com/getsentry/sentry-javascript/issues/8935
1054
+ }
1055
+
1056
+ if (!emptyUuid) {
1057
+ // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523
1058
+ // Concatenating the following numbers as strings results in '10000000100040008000100000000000'
1059
+ emptyUuid = ([1e7] ) + 1e3 + 4e3 + 8e3 + 1e11;
1060
+ }
1061
+
1062
+ return emptyUuid.replace(/[018]/g, c =>
1063
+ // eslint-disable-next-line no-bitwise
1064
+ ((c ) ^ ((getRandomByte() & 15) >> ((c ) / 4))).toString(16),
1065
+ );
1066
+ }
1067
+
1068
+ function getFirstException(event) {
1069
+ return event.exception?.values?.[0];
1070
+ }
1071
+
1072
+ /**
1073
+ * Extracts either message or type+value from an event that can be used for user-facing logs
1074
+ * @returns event's description
1075
+ */
1076
+ function getEventDescription(event) {
1077
+ const { message, event_id: eventId } = event;
1078
+ if (message) {
1079
+ return message;
1080
+ }
1081
+
1082
+ const firstException = getFirstException(event);
1083
+ if (firstException) {
1084
+ if (firstException.type && firstException.value) {
1085
+ return `${firstException.type}: ${firstException.value}`;
1086
+ }
1087
+ return firstException.type || firstException.value || eventId || '<unknown>';
1088
+ }
1089
+ return eventId || '<unknown>';
1090
+ }
1091
+
1092
+ /**
1093
+ * Adds exception values, type and value to an synthetic Exception.
1094
+ * @param event The event to modify.
1095
+ * @param value Value of the exception.
1096
+ * @param type Type of the exception.
1097
+ * @hidden
1098
+ */
1099
+ function addExceptionTypeValue(event, value, type) {
1100
+ const exception = (event.exception = event.exception || {});
1101
+ const values = (exception.values = exception.values || []);
1102
+ const firstException = (values[0] = values[0] || {});
1103
+ if (!firstException.value) {
1104
+ firstException.value = value || '';
1105
+ }
1106
+ if (!firstException.type) {
1107
+ firstException.type = 'Error';
1108
+ }
1109
+ }
1110
+
1111
+ /**
1112
+ * Adds exception mechanism data to a given event. Uses defaults if the second parameter is not passed.
1113
+ *
1114
+ * @param event The event to modify.
1115
+ * @param newMechanism Mechanism data to add to the event.
1116
+ * @hidden
1117
+ */
1118
+ function addExceptionMechanism(event, newMechanism) {
1119
+ const firstException = getFirstException(event);
1120
+ if (!firstException) {
1121
+ return;
1122
+ }
1123
+
1124
+ const defaultMechanism = { type: 'generic', handled: true };
1125
+ const currentMechanism = firstException.mechanism;
1126
+ firstException.mechanism = { ...defaultMechanism, ...currentMechanism, ...newMechanism };
1127
+
1128
+ if (newMechanism && 'data' in newMechanism) {
1129
+ const mergedData = { ...currentMechanism?.data, ...newMechanism.data };
1130
+ firstException.mechanism.data = mergedData;
1131
+ }
1132
+ }
1133
+
1134
+ /**
1135
+ * Checks whether or not we've already captured the given exception (note: not an identical exception - the very object
1136
+ * in question), and marks it captured if not.
1137
+ *
1138
+ * This is useful because it's possible for an error to get captured by more than one mechanism. After we intercept and
1139
+ * record an error, we rethrow it (assuming we've intercepted it before it's reached the top-level global handlers), so
1140
+ * that we don't interfere with whatever effects the error might have had were the SDK not there. At that point, because
1141
+ * the error has been rethrown, it's possible for it to bubble up to some other code we've instrumented. If it's not
1142
+ * caught after that, it will bubble all the way up to the global handlers (which of course we also instrument). This
1143
+ * function helps us ensure that even if we encounter the same error more than once, we only record it the first time we
1144
+ * see it.
1145
+ *
1146
+ * Note: It will ignore primitives (always return `false` and not mark them as seen), as properties can't be set on
1147
+ * them. {@link: Object.objectify} can be used on exceptions to convert any that are primitives into their equivalent
1148
+ * object wrapper forms so that this check will always work. However, because we need to flag the exact object which
1149
+ * will get rethrown, and because that rethrowing happens outside of the event processing pipeline, the objectification
1150
+ * must be done before the exception captured.
1151
+ *
1152
+ * @param A thrown exception to check or flag as having been seen
1153
+ * @returns `true` if the exception has already been captured, `false` if not (with the side effect of marking it seen)
1154
+ */
1155
+ function checkOrSetAlreadyCaught(exception) {
1156
+ if (isAlreadyCaptured(exception)) {
1157
+ return true;
1158
+ }
1159
+
1160
+ try {
1161
+ // set it this way rather than by assignment so that it's not ennumerable and therefore isn't recorded by the
1162
+ // `ExtraErrorData` integration
1163
+ addNonEnumerableProperty(exception , '__sentry_captured__', true);
1164
+ } catch {
1165
+ // `exception` is a primitive, so we can't mark it seen
1166
+ }
1167
+
1168
+ return false;
1169
+ }
1170
+
1171
+ function isAlreadyCaptured(exception) {
1172
+ try {
1173
+ return (exception ).__sentry_captured__;
1174
+ } catch {} // eslint-disable-line no-empty
1175
+ }
1176
+
1177
+ const ONE_SECOND_IN_MS = 1000;
1178
+
1179
+ /**
1180
+ * A partial definition of the [Performance Web API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Performance}
1181
+ * for accessing a high-resolution monotonic clock.
1182
+ */
1183
+
1184
+ /**
1185
+ * Returns a timestamp in seconds since the UNIX epoch using the Date API.
1186
+ */
1187
+ function dateTimestampInSeconds() {
1188
+ return safeDateNow() / ONE_SECOND_IN_MS;
1189
+ }
1190
+
1191
+ /**
1192
+ * Returns a wrapper around the native Performance API browser implementation, or undefined for browsers that do not
1193
+ * support the API.
1194
+ *
1195
+ * Wrapping the native API works around differences in behavior from different browsers.
1196
+ */
1197
+ function createUnixTimestampInSecondsFunc() {
1198
+ const { performance } = GLOBAL_OBJ ;
1199
+ // Some browser and environments don't have a performance or timeOrigin, so we fallback to
1200
+ // using Date.now() to compute the starting time.
1201
+ if (!performance?.now || !performance.timeOrigin) {
1202
+ return dateTimestampInSeconds;
1203
+ }
1204
+
1205
+ const timeOrigin = performance.timeOrigin;
1206
+
1207
+ // performance.now() is a monotonic clock, which means it starts at 0 when the process begins. To get the current
1208
+ // wall clock time (actual UNIX timestamp), we need to add the starting time origin and the current time elapsed.
1209
+ //
1210
+ // TODO: This does not account for the case where the monotonic clock that powers performance.now() drifts from the
1211
+ // wall clock time, which causes the returned timestamp to be inaccurate. We should investigate how to detect and
1212
+ // correct for this.
1213
+ // See: https://github.com/getsentry/sentry-javascript/issues/2590
1214
+ // See: https://github.com/mdn/content/issues/4713
1215
+ // See: https://dev.to/noamr/when-a-millisecond-is-not-a-millisecond-3h6
1216
+ return () => {
1217
+ return (timeOrigin + withRandomSafeContext(() => performance.now())) / ONE_SECOND_IN_MS;
1218
+ };
1219
+ }
1220
+
1221
+ let _cachedTimestampInSeconds;
1222
+
1223
+ /**
1224
+ * Returns a timestamp in seconds since the UNIX epoch using either the Performance or Date APIs, depending on the
1225
+ * availability of the Performance API.
1226
+ *
1227
+ * BUG: Note that because of how browsers implement the Performance API, the clock might stop when the computer is
1228
+ * asleep. This creates a skew between `dateTimestampInSeconds` and `timestampInSeconds`. The
1229
+ * skew can grow to arbitrary amounts like days, weeks or months.
1230
+ * See https://github.com/getsentry/sentry-javascript/issues/2590.
1231
+ */
1232
+ function timestampInSeconds() {
1233
+ // We store this in a closure so that we don't have to create a new function every time this is called.
1234
+ const func = _cachedTimestampInSeconds ?? (_cachedTimestampInSeconds = createUnixTimestampInSecondsFunc());
1235
+ return func();
1236
+ }
1237
+
1238
+ /**
1239
+ * Creates a new `Session` object by setting certain default parameters. If optional @param context
1240
+ * is passed, the passed properties are applied to the session object.
1241
+ *
1242
+ * @param context (optional) additional properties to be applied to the returned session object
1243
+ *
1244
+ * @returns a new `Session` object
1245
+ */
1246
+ function makeSession(context) {
1247
+ // Both timestamp and started are in seconds since the UNIX epoch.
1248
+ const startingTime = timestampInSeconds();
1249
+
1250
+ const session = {
1251
+ sid: uuid4(),
1252
+ init: true,
1253
+ timestamp: startingTime,
1254
+ started: startingTime,
1255
+ duration: 0,
1256
+ status: 'ok',
1257
+ errors: 0,
1258
+ ignoreDuration: false,
1259
+ toJSON: () => sessionToJSON(session),
1260
+ };
1261
+
1262
+ if (context) {
1263
+ updateSession(session, context);
1264
+ }
1265
+
1266
+ return session;
1267
+ }
1268
+
1269
+ /**
1270
+ * Updates a session object with the properties passed in the context.
1271
+ *
1272
+ * Note that this function mutates the passed object and returns void.
1273
+ * (Had to do this instead of returning a new and updated session because closing and sending a session
1274
+ * makes an update to the session after it was passed to the sending logic.
1275
+ * @see Client.captureSession )
1276
+ *
1277
+ * @param session the `Session` to update
1278
+ * @param context the `SessionContext` holding the properties that should be updated in @param session
1279
+ */
1280
+ // eslint-disable-next-line complexity
1281
+ function updateSession(session, context = {}) {
1282
+ if (context.user) {
1283
+ if (!session.ipAddress && context.user.ip_address) {
1284
+ session.ipAddress = context.user.ip_address;
1285
+ }
1286
+
1287
+ if (!session.did && !context.did) {
1288
+ session.did = context.user.id || context.user.email || context.user.username;
1289
+ }
1290
+ }
1291
+
1292
+ session.timestamp = context.timestamp || timestampInSeconds();
1293
+
1294
+ if (context.abnormal_mechanism) {
1295
+ session.abnormal_mechanism = context.abnormal_mechanism;
1296
+ }
1297
+
1298
+ if (context.ignoreDuration) {
1299
+ session.ignoreDuration = context.ignoreDuration;
1300
+ }
1301
+ if (context.sid) {
1302
+ // Good enough uuid validation. — Kamil
1303
+ session.sid = context.sid.length === 32 ? context.sid : uuid4();
1304
+ }
1305
+ if (context.init !== undefined) {
1306
+ session.init = context.init;
1307
+ }
1308
+ if (!session.did && context.did) {
1309
+ session.did = `${context.did}`;
1310
+ }
1311
+ if (typeof context.started === 'number') {
1312
+ session.started = context.started;
1313
+ }
1314
+ if (session.ignoreDuration) {
1315
+ session.duration = undefined;
1316
+ } else if (typeof context.duration === 'number') {
1317
+ session.duration = context.duration;
1318
+ } else {
1319
+ const duration = session.timestamp - session.started;
1320
+ session.duration = duration >= 0 ? duration : 0;
1321
+ }
1322
+ if (context.release) {
1323
+ session.release = context.release;
1324
+ }
1325
+ if (context.environment) {
1326
+ session.environment = context.environment;
1327
+ }
1328
+ if (!session.ipAddress && context.ipAddress) {
1329
+ session.ipAddress = context.ipAddress;
1330
+ }
1331
+ if (!session.userAgent && context.userAgent) {
1332
+ session.userAgent = context.userAgent;
1333
+ }
1334
+ if (typeof context.errors === 'number') {
1335
+ session.errors = context.errors;
1336
+ }
1337
+ if (context.status) {
1338
+ session.status = context.status;
1339
+ }
1340
+ }
1341
+
1342
+ /**
1343
+ * Closes a session by setting its status and updating the session object with it.
1344
+ * Internally calls `updateSession` to update the passed session object.
1345
+ *
1346
+ * Note that this function mutates the passed session (@see updateSession for explanation).
1347
+ *
1348
+ * @param session the `Session` object to be closed
1349
+ * @param status the `SessionStatus` with which the session was closed. If you don't pass a status,
1350
+ * this function will keep the previously set status, unless it was `'ok'` in which case
1351
+ * it is changed to `'exited'`.
1352
+ */
1353
+ function closeSession(session, status) {
1354
+ let context = {};
1355
+ if (session.status === 'ok') {
1356
+ context = { status: 'exited' };
1357
+ }
1358
+
1359
+ updateSession(session, context);
1360
+ }
1361
+
1362
+ /**
1363
+ * Serializes a passed session object to a JSON object with a slightly different structure.
1364
+ * This is necessary because the Sentry backend requires a slightly different schema of a session
1365
+ * than the one the JS SDKs use internally.
1366
+ *
1367
+ * @param session the session to be converted
1368
+ *
1369
+ * @returns a JSON object of the passed session
1370
+ */
1371
+ function sessionToJSON(session) {
1372
+ return {
1373
+ sid: `${session.sid}`,
1374
+ init: session.init,
1375
+ // Make sure that sec is converted to ms for date constructor
1376
+ started: new Date(session.started * 1000).toISOString(),
1377
+ timestamp: new Date(session.timestamp * 1000).toISOString(),
1378
+ status: session.status,
1379
+ errors: session.errors,
1380
+ did: typeof session.did === 'number' || typeof session.did === 'string' ? `${session.did}` : undefined,
1381
+ duration: session.duration,
1382
+ abnormal_mechanism: session.abnormal_mechanism,
1383
+ attrs: {
1384
+ release: session.release,
1385
+ environment: session.environment,
1386
+ ip_address: session.ipAddress,
1387
+ user_agent: session.userAgent,
1388
+ },
1389
+ };
1390
+ }
1391
+
1392
+ /**
1393
+ * Shallow merge two objects.
1394
+ * Does not mutate the passed in objects.
1395
+ * Undefined/empty values in the merge object will overwrite existing values.
1396
+ *
1397
+ * By default, this merges 2 levels deep.
1398
+ */
1399
+ function merge(initialObj, mergeObj, levels = 2) {
1400
+ // If the merge value is not an object, or we have no merge levels left,
1401
+ // we just set the value to the merge value
1402
+ if (!mergeObj || typeof mergeObj !== 'object' || levels <= 0) {
1403
+ return mergeObj;
1404
+ }
1405
+
1406
+ // If the merge object is an empty object, and the initial object is not undefined, we return the initial object
1407
+ if (initialObj && Object.keys(mergeObj).length === 0) {
1408
+ return initialObj;
1409
+ }
1410
+
1411
+ // Clone object
1412
+ const output = { ...initialObj };
1413
+
1414
+ // Merge values into output, resursively
1415
+ for (const key in mergeObj) {
1416
+ if (Object.prototype.hasOwnProperty.call(mergeObj, key)) {
1417
+ output[key] = merge(output[key], mergeObj[key], levels - 1);
1418
+ }
1419
+ }
1420
+
1421
+ return output;
1422
+ }
1423
+
1424
+ /**
1425
+ * Generate a random, valid trace ID.
1426
+ */
1427
+ function generateTraceId() {
1428
+ return uuid4();
1429
+ }
1430
+
1431
+ /**
1432
+ * Generate a random, valid span ID.
1433
+ */
1434
+ function generateSpanId() {
1435
+ return uuid4().substring(16);
1436
+ }
1437
+
1438
+ const SCOPE_SPAN_FIELD = '_sentrySpan';
1439
+
1440
+ /**
1441
+ * Set the active span for a given scope.
1442
+ * NOTE: This should NOT be used directly, but is only used internally by the trace methods.
1443
+ */
1444
+ function _setSpanForScope(scope, span) {
1445
+ if (span) {
1446
+ addNonEnumerableProperty(scope , SCOPE_SPAN_FIELD, span);
1447
+ } else {
1448
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
1449
+ delete (scope )[SCOPE_SPAN_FIELD];
1450
+ }
1451
+ }
1452
+
1453
+ /**
1454
+ * Get the active span for a given scope.
1455
+ * NOTE: This should NOT be used directly, but is only used internally by the trace methods.
1456
+ */
1457
+ function _getSpanForScope(scope) {
1458
+ return scope[SCOPE_SPAN_FIELD];
1459
+ }
1460
+
1461
+ /**
1462
+ * Default value for maximum number of breadcrumbs added to an event.
1463
+ */
1464
+ const DEFAULT_MAX_BREADCRUMBS = 100;
1465
+
1466
+ /**
1467
+ * A context to be used for capturing an event.
1468
+ * This can either be a Scope, or a partial ScopeContext,
1469
+ * or a callback that receives the current scope and returns a new scope to use.
1470
+ */
1471
+
1472
+ /**
1473
+ * Holds additional event information.
1474
+ */
1475
+ class Scope {
1476
+ /** Flag if notifying is happening. */
1477
+
1478
+ /** Callback for client to receive scope changes. */
1479
+
1480
+ /** Callback list that will be called during event processing. */
1481
+
1482
+ /** Array of breadcrumbs. */
1483
+
1484
+ /** User */
1485
+
1486
+ /** Tags */
1487
+
1488
+ /** Attributes */
1489
+
1490
+ /** Extra */
1491
+
1492
+ /** Contexts */
1493
+
1494
+ /** Attachments */
1495
+
1496
+ /** Propagation Context for distributed tracing */
1497
+
1498
+ /**
1499
+ * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
1500
+ * sent to Sentry
1501
+ */
1502
+
1503
+ /** Fingerprint */
1504
+
1505
+ /** Severity */
1506
+
1507
+ /**
1508
+ * Transaction Name
1509
+ *
1510
+ * IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects.
1511
+ * It's purpose is to assign a transaction to the scope that's added to non-transaction events.
1512
+ */
1513
+
1514
+ /** Session */
1515
+
1516
+ /** The client on this scope */
1517
+
1518
+ /** Contains the last event id of a captured event. */
1519
+
1520
+ // NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.
1521
+
1522
+ constructor() {
1523
+ this._notifyingListeners = false;
1524
+ this._scopeListeners = [];
1525
+ this._eventProcessors = [];
1526
+ this._breadcrumbs = [];
1527
+ this._attachments = [];
1528
+ this._user = {};
1529
+ this._tags = {};
1530
+ this._attributes = {};
1531
+ this._extra = {};
1532
+ this._contexts = {};
1533
+ this._sdkProcessingMetadata = {};
1534
+ this._propagationContext = {
1535
+ traceId: generateTraceId(),
1536
+ sampleRand: safeMathRandom(),
1537
+ };
1538
+ }
1539
+
1540
+ /**
1541
+ * Clone all data from this scope into a new scope.
1542
+ */
1543
+ clone() {
1544
+ const newScope = new Scope();
1545
+ newScope._breadcrumbs = [...this._breadcrumbs];
1546
+ newScope._tags = { ...this._tags };
1547
+ newScope._attributes = { ...this._attributes };
1548
+ newScope._extra = { ...this._extra };
1549
+ newScope._contexts = { ...this._contexts };
1550
+ if (this._contexts.flags) {
1551
+ // We need to copy the `values` array so insertions on a cloned scope
1552
+ // won't affect the original array.
1553
+ newScope._contexts.flags = {
1554
+ values: [...this._contexts.flags.values],
1555
+ };
1556
+ }
1557
+
1558
+ newScope._user = this._user;
1559
+ newScope._level = this._level;
1560
+ newScope._session = this._session;
1561
+ newScope._transactionName = this._transactionName;
1562
+ newScope._fingerprint = this._fingerprint;
1563
+ newScope._eventProcessors = [...this._eventProcessors];
1564
+ newScope._attachments = [...this._attachments];
1565
+ newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };
1566
+ newScope._propagationContext = { ...this._propagationContext };
1567
+ newScope._client = this._client;
1568
+ newScope._lastEventId = this._lastEventId;
1569
+
1570
+ _setSpanForScope(newScope, _getSpanForScope(this));
1571
+
1572
+ return newScope;
1573
+ }
1574
+
1575
+ /**
1576
+ * Update the client assigned to this scope.
1577
+ * Note that not every scope will have a client assigned - isolation scopes & the global scope will generally not have a client,
1578
+ * as well as manually created scopes.
1579
+ */
1580
+ setClient(client) {
1581
+ this._client = client;
1582
+ }
1583
+
1584
+ /**
1585
+ * Set the ID of the last captured error event.
1586
+ * This is generally only captured on the isolation scope.
1587
+ */
1588
+ setLastEventId(lastEventId) {
1589
+ this._lastEventId = lastEventId;
1590
+ }
1591
+
1592
+ /**
1593
+ * Get the client assigned to this scope.
1594
+ */
1595
+ getClient() {
1596
+ return this._client ;
1597
+ }
1598
+
1599
+ /**
1600
+ * Get the ID of the last captured error event.
1601
+ * This is generally only available on the isolation scope.
1602
+ */
1603
+ lastEventId() {
1604
+ return this._lastEventId;
1605
+ }
1606
+
1607
+ /**
1608
+ * @inheritDoc
1609
+ */
1610
+ addScopeListener(callback) {
1611
+ this._scopeListeners.push(callback);
1612
+ }
1613
+
1614
+ /**
1615
+ * Add an event processor that will be called before an event is sent.
1616
+ */
1617
+ addEventProcessor(callback) {
1618
+ this._eventProcessors.push(callback);
1619
+ return this;
1620
+ }
1621
+
1622
+ /**
1623
+ * Set the user for this scope.
1624
+ * Set to `null` to unset the user.
1625
+ */
1626
+ setUser(user) {
1627
+ // If null is passed we want to unset everything, but still define keys,
1628
+ // so that later down in the pipeline any existing values are cleared.
1629
+ this._user = user || {
1630
+ email: undefined,
1631
+ id: undefined,
1632
+ ip_address: undefined,
1633
+ username: undefined,
1634
+ };
1635
+
1636
+ if (this._session) {
1637
+ updateSession(this._session, { user });
1638
+ }
1639
+
1640
+ this._notifyScopeListeners();
1641
+ return this;
1642
+ }
1643
+
1644
+ /**
1645
+ * Get the user from this scope.
1646
+ */
1647
+ getUser() {
1648
+ return this._user;
1649
+ }
1650
+
1651
+ /**
1652
+ * Set an object that will be merged into existing tags on the scope,
1653
+ * and will be sent as tags data with the event.
1654
+ */
1655
+ setTags(tags) {
1656
+ this._tags = {
1657
+ ...this._tags,
1658
+ ...tags,
1659
+ };
1660
+ this._notifyScopeListeners();
1661
+ return this;
1662
+ }
1663
+
1664
+ /**
1665
+ * Set a single tag that will be sent as tags data with the event.
1666
+ */
1667
+ setTag(key, value) {
1668
+ return this.setTags({ [key]: value });
1669
+ }
1670
+
1671
+ /**
1672
+ * Sets attributes onto the scope.
1673
+ *
1674
+ * These attributes are currently applied to logs and metrics.
1675
+ * In the future, they will also be applied to spans.
1676
+ *
1677
+ * Important: For now, only strings, numbers and boolean attributes are supported, despite types allowing for
1678
+ * more complex attribute types. We'll add this support in the future but already specify the wider type to
1679
+ * avoid a breaking change in the future.
1680
+ *
1681
+ * @param newAttributes - The attributes to set on the scope. You can either pass in key-value pairs, or
1682
+ * an object with a `value` and an optional `unit` (if applicable to your attribute).
1683
+ *
1684
+ * @example
1685
+ * ```typescript
1686
+ * scope.setAttributes({
1687
+ * is_admin: true,
1688
+ * payment_selection: 'credit_card',
1689
+ * render_duration: { value: 'render_duration', unit: 'ms' },
1690
+ * });
1691
+ * ```
1692
+ */
1693
+ setAttributes(newAttributes) {
1694
+ this._attributes = {
1695
+ ...this._attributes,
1696
+ ...newAttributes,
1697
+ };
1698
+
1699
+ this._notifyScopeListeners();
1700
+ return this;
1701
+ }
1702
+
1703
+ /**
1704
+ * Sets an attribute onto the scope.
1705
+ *
1706
+ * These attributes are currently applied to logs and metrics.
1707
+ * In the future, they will also be applied to spans.
1708
+ *
1709
+ * Important: For now, only strings, numbers and boolean attributes are supported, despite types allowing for
1710
+ * more complex attribute types. We'll add this support in the future but already specify the wider type to
1711
+ * avoid a breaking change in the future.
1712
+ *
1713
+ * @param key - The attribute key.
1714
+ * @param value - the attribute value. You can either pass in a raw value, or an attribute
1715
+ * object with a `value` and an optional `unit` (if applicable to your attribute).
1716
+ *
1717
+ * @example
1718
+ * ```typescript
1719
+ * scope.setAttribute('is_admin', true);
1720
+ * scope.setAttribute('render_duration', { value: 'render_duration', unit: 'ms' });
1721
+ * ```
1722
+ */
1723
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1724
+ setAttribute(
1725
+ key,
1726
+ value,
1727
+ ) {
1728
+ return this.setAttributes({ [key]: value });
1729
+ }
1730
+
1731
+ /**
1732
+ * Removes the attribute with the given key from the scope.
1733
+ *
1734
+ * @param key - The attribute key.
1735
+ *
1736
+ * @example
1737
+ * ```typescript
1738
+ * scope.removeAttribute('is_admin');
1739
+ * ```
1740
+ */
1741
+ removeAttribute(key) {
1742
+ if (key in this._attributes) {
1743
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
1744
+ delete this._attributes[key];
1745
+ this._notifyScopeListeners();
1746
+ }
1747
+ return this;
1748
+ }
1749
+
1750
+ /**
1751
+ * Set an object that will be merged into existing extra on the scope,
1752
+ * and will be sent as extra data with the event.
1753
+ */
1754
+ setExtras(extras) {
1755
+ this._extra = {
1756
+ ...this._extra,
1757
+ ...extras,
1758
+ };
1759
+ this._notifyScopeListeners();
1760
+ return this;
1761
+ }
1762
+
1763
+ /**
1764
+ * Set a single key:value extra entry that will be sent as extra data with the event.
1765
+ */
1766
+ setExtra(key, extra) {
1767
+ this._extra = { ...this._extra, [key]: extra };
1768
+ this._notifyScopeListeners();
1769
+ return this;
1770
+ }
1771
+
1772
+ /**
1773
+ * Sets the fingerprint on the scope to send with the events.
1774
+ * @param {string[]} fingerprint Fingerprint to group events in Sentry.
1775
+ */
1776
+ setFingerprint(fingerprint) {
1777
+ this._fingerprint = fingerprint;
1778
+ this._notifyScopeListeners();
1779
+ return this;
1780
+ }
1781
+
1782
+ /**
1783
+ * Sets the level on the scope for future events.
1784
+ */
1785
+ setLevel(level) {
1786
+ this._level = level;
1787
+ this._notifyScopeListeners();
1788
+ return this;
1789
+ }
1790
+
1791
+ /**
1792
+ * Sets the transaction name on the scope so that the name of e.g. taken server route or
1793
+ * the page location is attached to future events.
1794
+ *
1795
+ * IMPORTANT: Calling this function does NOT change the name of the currently active
1796
+ * root span. If you want to change the name of the active root span, use
1797
+ * `Sentry.updateSpanName(rootSpan, 'new name')` instead.
1798
+ *
1799
+ * By default, the SDK updates the scope's transaction name automatically on sensible
1800
+ * occasions, such as a page navigation or when handling a new request on the server.
1801
+ */
1802
+ setTransactionName(name) {
1803
+ this._transactionName = name;
1804
+ this._notifyScopeListeners();
1805
+ return this;
1806
+ }
1807
+
1808
+ /**
1809
+ * Sets context data with the given name.
1810
+ * Data passed as context will be normalized. You can also pass `null` to unset the context.
1811
+ * Note that context data will not be merged - calling `setContext` will overwrite an existing context with the same key.
1812
+ */
1813
+ setContext(key, context) {
1814
+ if (context === null) {
1815
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
1816
+ delete this._contexts[key];
1817
+ } else {
1818
+ this._contexts[key] = context;
1819
+ }
1820
+
1821
+ this._notifyScopeListeners();
1822
+ return this;
1823
+ }
1824
+
1825
+ /**
1826
+ * Set the session for the scope.
1827
+ */
1828
+ setSession(session) {
1829
+ if (!session) {
1830
+ delete this._session;
1831
+ } else {
1832
+ this._session = session;
1833
+ }
1834
+ this._notifyScopeListeners();
1835
+ return this;
1836
+ }
1837
+
1838
+ /**
1839
+ * Get the session from the scope.
1840
+ */
1841
+ getSession() {
1842
+ return this._session;
1843
+ }
1844
+
1845
+ /**
1846
+ * Updates the scope with provided data. Can work in three variations:
1847
+ * - plain object containing updatable attributes
1848
+ * - Scope instance that'll extract the attributes from
1849
+ * - callback function that'll receive the current scope as an argument and allow for modifications
1850
+ */
1851
+ update(captureContext) {
1852
+ if (!captureContext) {
1853
+ return this;
1854
+ }
1855
+
1856
+ const scopeToMerge = typeof captureContext === 'function' ? captureContext(this) : captureContext;
1857
+
1858
+ const scopeInstance =
1859
+ scopeToMerge instanceof Scope
1860
+ ? scopeToMerge.getScopeData()
1861
+ : isPlainObject(scopeToMerge)
1862
+ ? (captureContext )
1863
+ : undefined;
1864
+
1865
+ const {
1866
+ tags,
1867
+ attributes,
1868
+ extra,
1869
+ user,
1870
+ contexts,
1871
+ level,
1872
+ fingerprint = [],
1873
+ propagationContext,
1874
+ } = scopeInstance || {};
1875
+
1876
+ this._tags = { ...this._tags, ...tags };
1877
+ this._attributes = { ...this._attributes, ...attributes };
1878
+ this._extra = { ...this._extra, ...extra };
1879
+ this._contexts = { ...this._contexts, ...contexts };
1880
+
1881
+ if (user && Object.keys(user).length) {
1882
+ this._user = user;
1883
+ }
1884
+
1885
+ if (level) {
1886
+ this._level = level;
1887
+ }
1888
+
1889
+ if (fingerprint.length) {
1890
+ this._fingerprint = fingerprint;
1891
+ }
1892
+
1893
+ if (propagationContext) {
1894
+ this._propagationContext = propagationContext;
1895
+ }
1896
+
1897
+ return this;
1898
+ }
1899
+
1900
+ /**
1901
+ * Clears the current scope and resets its properties.
1902
+ * Note: The client will not be cleared.
1903
+ */
1904
+ clear() {
1905
+ // client is not cleared here on purpose!
1906
+ this._breadcrumbs = [];
1907
+ this._tags = {};
1908
+ this._attributes = {};
1909
+ this._extra = {};
1910
+ this._user = {};
1911
+ this._contexts = {};
1912
+ this._level = undefined;
1913
+ this._transactionName = undefined;
1914
+ this._fingerprint = undefined;
1915
+ this._session = undefined;
1916
+ _setSpanForScope(this, undefined);
1917
+ this._attachments = [];
1918
+ this.setPropagationContext({
1919
+ traceId: generateTraceId(),
1920
+ sampleRand: safeMathRandom(),
1921
+ });
1922
+
1923
+ this._notifyScopeListeners();
1924
+ return this;
1925
+ }
1926
+
1927
+ /**
1928
+ * Adds a breadcrumb to the scope.
1929
+ * By default, the last 100 breadcrumbs are kept.
1930
+ */
1931
+ addBreadcrumb(breadcrumb, maxBreadcrumbs) {
1932
+ const maxCrumbs = typeof maxBreadcrumbs === 'number' ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;
1933
+
1934
+ // No data has been changed, so don't notify scope listeners
1935
+ if (maxCrumbs <= 0) {
1936
+ return this;
1937
+ }
1938
+
1939
+ const mergedBreadcrumb = {
1940
+ timestamp: dateTimestampInSeconds(),
1941
+ ...breadcrumb,
1942
+ // Breadcrumb messages can theoretically be infinitely large and they're held in memory so we truncate them not to leak (too much) memory
1943
+ message: breadcrumb.message ? truncate(breadcrumb.message, 2048) : breadcrumb.message,
1944
+ };
1945
+
1946
+ this._breadcrumbs.push(mergedBreadcrumb);
1947
+ if (this._breadcrumbs.length > maxCrumbs) {
1948
+ this._breadcrumbs = this._breadcrumbs.slice(-maxCrumbs);
1949
+ this._client?.recordDroppedEvent('buffer_overflow', 'log_item');
1950
+ }
1951
+
1952
+ this._notifyScopeListeners();
1953
+
1954
+ return this;
1955
+ }
1956
+
1957
+ /**
1958
+ * Get the last breadcrumb of the scope.
1959
+ */
1960
+ getLastBreadcrumb() {
1961
+ return this._breadcrumbs[this._breadcrumbs.length - 1];
1962
+ }
1963
+
1964
+ /**
1965
+ * Clear all breadcrumbs from the scope.
1966
+ */
1967
+ clearBreadcrumbs() {
1968
+ this._breadcrumbs = [];
1969
+ this._notifyScopeListeners();
1970
+ return this;
1971
+ }
1972
+
1973
+ /**
1974
+ * Add an attachment to the scope.
1975
+ */
1976
+ addAttachment(attachment) {
1977
+ this._attachments.push(attachment);
1978
+ return this;
1979
+ }
1980
+
1981
+ /**
1982
+ * Clear all attachments from the scope.
1983
+ */
1984
+ clearAttachments() {
1985
+ this._attachments = [];
1986
+ return this;
1987
+ }
1988
+
1989
+ /**
1990
+ * Get the data of this scope, which should be applied to an event during processing.
1991
+ */
1992
+ getScopeData() {
1993
+ return {
1994
+ breadcrumbs: this._breadcrumbs,
1995
+ attachments: this._attachments,
1996
+ contexts: this._contexts,
1997
+ tags: this._tags,
1998
+ attributes: this._attributes,
1999
+ extra: this._extra,
2000
+ user: this._user,
2001
+ level: this._level,
2002
+ fingerprint: this._fingerprint || [],
2003
+ eventProcessors: this._eventProcessors,
2004
+ propagationContext: this._propagationContext,
2005
+ sdkProcessingMetadata: this._sdkProcessingMetadata,
2006
+ transactionName: this._transactionName,
2007
+ span: _getSpanForScope(this),
2008
+ };
2009
+ }
2010
+
2011
+ /**
2012
+ * Add data which will be accessible during event processing but won't get sent to Sentry.
2013
+ */
2014
+ setSDKProcessingMetadata(newData) {
2015
+ this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2);
2016
+ return this;
2017
+ }
2018
+
2019
+ /**
2020
+ * Add propagation context to the scope, used for distributed tracing
2021
+ */
2022
+ setPropagationContext(context) {
2023
+ this._propagationContext = context;
2024
+ return this;
2025
+ }
2026
+
2027
+ /**
2028
+ * Get propagation context from the scope, used for distributed tracing
2029
+ */
2030
+ getPropagationContext() {
2031
+ return this._propagationContext;
2032
+ }
2033
+
2034
+ /**
2035
+ * Capture an exception for this scope.
2036
+ *
2037
+ * @returns {string} The id of the captured Sentry event.
2038
+ */
2039
+ captureException(exception, hint) {
2040
+ const eventId = hint?.event_id || uuid4();
2041
+
2042
+ if (!this._client) {
2043
+ DEBUG_BUILD && debug.warn('No client configured on scope - will not capture exception!');
2044
+ return eventId;
2045
+ }
2046
+
2047
+ const syntheticException = new Error('Sentry syntheticException');
2048
+
2049
+ this._client.captureException(
2050
+ exception,
2051
+ {
2052
+ originalException: exception,
2053
+ syntheticException,
2054
+ ...hint,
2055
+ event_id: eventId,
2056
+ },
2057
+ this,
2058
+ );
2059
+
2060
+ return eventId;
2061
+ }
2062
+
2063
+ /**
2064
+ * Capture a message for this scope.
2065
+ *
2066
+ * @returns {string} The id of the captured message.
2067
+ */
2068
+ captureMessage(message, level, hint) {
2069
+ const eventId = hint?.event_id || uuid4();
2070
+
2071
+ if (!this._client) {
2072
+ DEBUG_BUILD && debug.warn('No client configured on scope - will not capture message!');
2073
+ return eventId;
2074
+ }
2075
+
2076
+ const syntheticException = hint?.syntheticException ?? new Error(message);
2077
+
2078
+ this._client.captureMessage(
2079
+ message,
2080
+ level,
2081
+ {
2082
+ originalException: message,
2083
+ syntheticException,
2084
+ ...hint,
2085
+ event_id: eventId,
2086
+ },
2087
+ this,
2088
+ );
2089
+
2090
+ return eventId;
2091
+ }
2092
+
2093
+ /**
2094
+ * Capture a Sentry event for this scope.
2095
+ *
2096
+ * @returns {string} The id of the captured event.
2097
+ */
2098
+ captureEvent(event, hint) {
2099
+ const eventId = hint?.event_id || uuid4();
2100
+
2101
+ if (!this._client) {
2102
+ DEBUG_BUILD && debug.warn('No client configured on scope - will not capture event!');
2103
+ return eventId;
2104
+ }
2105
+
2106
+ this._client.captureEvent(event, { ...hint, event_id: eventId }, this);
2107
+
2108
+ return eventId;
2109
+ }
2110
+
2111
+ /**
2112
+ * This will be called on every set call.
2113
+ */
2114
+ _notifyScopeListeners() {
2115
+ // We need this check for this._notifyingListeners to be able to work on scope during updates
2116
+ // If this check is not here we'll produce endless recursion when something is done with the scope
2117
+ // during the callback.
2118
+ if (!this._notifyingListeners) {
2119
+ this._notifyingListeners = true;
2120
+ this._scopeListeners.forEach(callback => {
2121
+ callback(this);
2122
+ });
2123
+ this._notifyingListeners = false;
2124
+ }
2125
+ }
2126
+ }
2127
+
2128
+ /** Get the default current scope. */
2129
+ function getDefaultCurrentScope() {
2130
+ return getGlobalSingleton('defaultCurrentScope', () => new Scope());
2131
+ }
2132
+
2133
+ /** Get the default isolation scope. */
2134
+ function getDefaultIsolationScope() {
2135
+ return getGlobalSingleton('defaultIsolationScope', () => new Scope());
2136
+ }
2137
+
2138
+ /**
2139
+ * This is an object that holds a stack of scopes.
2140
+ */
2141
+ class AsyncContextStack {
2142
+
2143
+ constructor(scope, isolationScope) {
2144
+ let assignedScope;
2145
+ if (!scope) {
2146
+ assignedScope = new Scope();
2147
+ } else {
2148
+ assignedScope = scope;
2149
+ }
2150
+
2151
+ let assignedIsolationScope;
2152
+ if (!isolationScope) {
2153
+ assignedIsolationScope = new Scope();
2154
+ } else {
2155
+ assignedIsolationScope = isolationScope;
2156
+ }
2157
+
2158
+ // scope stack for domains or the process
2159
+ this._stack = [{ scope: assignedScope }];
2160
+ this._isolationScope = assignedIsolationScope;
2161
+ }
2162
+
2163
+ /**
2164
+ * Fork a scope for the stack.
2165
+ */
2166
+ withScope(callback) {
2167
+ const scope = this._pushScope();
2168
+
2169
+ let maybePromiseResult;
2170
+ try {
2171
+ maybePromiseResult = callback(scope);
2172
+ } catch (e) {
2173
+ this._popScope();
2174
+ throw e;
2175
+ }
2176
+
2177
+ if (isThenable(maybePromiseResult)) {
2178
+ // @ts-expect-error - isThenable returns the wrong type
2179
+ return maybePromiseResult.then(
2180
+ res => {
2181
+ this._popScope();
2182
+ return res;
2183
+ },
2184
+ e => {
2185
+ this._popScope();
2186
+ throw e;
2187
+ },
2188
+ );
2189
+ }
2190
+
2191
+ this._popScope();
2192
+ return maybePromiseResult;
2193
+ }
2194
+
2195
+ /**
2196
+ * Get the client of the stack.
2197
+ */
2198
+ getClient() {
2199
+ return this.getStackTop().client ;
2200
+ }
2201
+
2202
+ /**
2203
+ * Returns the scope of the top stack.
2204
+ */
2205
+ getScope() {
2206
+ return this.getStackTop().scope;
2207
+ }
2208
+
2209
+ /**
2210
+ * Get the isolation scope for the stack.
2211
+ */
2212
+ getIsolationScope() {
2213
+ return this._isolationScope;
2214
+ }
2215
+
2216
+ /**
2217
+ * Returns the topmost scope layer in the order domain > local > process.
2218
+ */
2219
+ getStackTop() {
2220
+ return this._stack[this._stack.length - 1] ;
2221
+ }
2222
+
2223
+ /**
2224
+ * Push a scope to the stack.
2225
+ */
2226
+ _pushScope() {
2227
+ // We want to clone the content of prev scope
2228
+ const scope = this.getScope().clone();
2229
+ this._stack.push({
2230
+ client: this.getClient(),
2231
+ scope,
2232
+ });
2233
+ return scope;
2234
+ }
2235
+
2236
+ /**
2237
+ * Pop a scope from the stack.
2238
+ */
2239
+ _popScope() {
2240
+ if (this._stack.length <= 1) return false;
2241
+ return !!this._stack.pop();
2242
+ }
2243
+ }
2244
+
2245
+ /**
2246
+ * Get the global async context stack.
2247
+ * This will be removed during the v8 cycle and is only here to make migration easier.
2248
+ */
2249
+ function getAsyncContextStack() {
2250
+ const registry = getMainCarrier();
2251
+ const sentry = getSentryCarrier(registry);
2252
+
2253
+ return (sentry.stack = sentry.stack || new AsyncContextStack(getDefaultCurrentScope(), getDefaultIsolationScope()));
2254
+ }
2255
+
2256
+ function withScope$1(callback) {
2257
+ return getAsyncContextStack().withScope(callback);
2258
+ }
2259
+
2260
+ function withSetScope(scope, callback) {
2261
+ const stack = getAsyncContextStack();
2262
+ return stack.withScope(() => {
2263
+ stack.getStackTop().scope = scope;
2264
+ return callback(scope);
2265
+ });
2266
+ }
2267
+
2268
+ function withIsolationScope(callback) {
2269
+ return getAsyncContextStack().withScope(() => {
2270
+ return callback(getAsyncContextStack().getIsolationScope());
2271
+ });
2272
+ }
2273
+
2274
+ /**
2275
+ * Get the stack-based async context strategy.
2276
+ */
2277
+ function getStackAsyncContextStrategy() {
2278
+ return {
2279
+ withIsolationScope,
2280
+ withScope: withScope$1,
2281
+ withSetScope,
2282
+ withSetIsolationScope: (_isolationScope, callback) => {
2283
+ return withIsolationScope(callback);
2284
+ },
2285
+ getCurrentScope: () => getAsyncContextStack().getScope(),
2286
+ getIsolationScope: () => getAsyncContextStack().getIsolationScope(),
2287
+ };
2288
+ }
2289
+
2290
+ /**
2291
+ * Get the current async context strategy.
2292
+ * If none has been setup, the default will be used.
2293
+ */
2294
+ function getAsyncContextStrategy(carrier) {
2295
+ const sentry = getSentryCarrier(carrier);
2296
+
2297
+ if (sentry.acs) {
2298
+ return sentry.acs;
2299
+ }
2300
+
2301
+ // Otherwise, use the default one (stack)
2302
+ return getStackAsyncContextStrategy();
2303
+ }
2304
+
2305
+ /**
2306
+ * Get the currently active scope.
2307
+ */
2308
+ function getCurrentScope() {
2309
+ const carrier = getMainCarrier();
2310
+ const acs = getAsyncContextStrategy(carrier);
2311
+ return acs.getCurrentScope();
2312
+ }
2313
+
2314
+ /**
2315
+ * Get the currently active isolation scope.
2316
+ * The isolation scope is active for the current execution context.
2317
+ */
2318
+ function getIsolationScope() {
2319
+ const carrier = getMainCarrier();
2320
+ const acs = getAsyncContextStrategy(carrier);
2321
+ return acs.getIsolationScope();
2322
+ }
2323
+
2324
+ /**
2325
+ * Get the global scope.
2326
+ * This scope is applied to _all_ events.
2327
+ */
2328
+ function getGlobalScope() {
2329
+ return getGlobalSingleton('globalScope', () => new Scope());
2330
+ }
2331
+
2332
+ /**
2333
+ * Creates a new scope with and executes the given operation within.
2334
+ * The scope is automatically removed once the operation
2335
+ * finishes or throws.
2336
+ */
2337
+
2338
+ /**
2339
+ * Either creates a new active scope, or sets the given scope as active scope in the given callback.
2340
+ */
2341
+ function withScope(
2342
+ ...rest
2343
+ ) {
2344
+ const carrier = getMainCarrier();
2345
+ const acs = getAsyncContextStrategy(carrier);
2346
+
2347
+ // If a scope is defined, we want to make this the active scope instead of the default one
2348
+ if (rest.length === 2) {
2349
+ const [scope, callback] = rest;
2350
+
2351
+ if (!scope) {
2352
+ return acs.withScope(callback);
2353
+ }
2354
+
2355
+ return acs.withSetScope(scope, callback);
2356
+ }
2357
+
2358
+ return acs.withScope(rest[0]);
2359
+ }
2360
+
2361
+ /**
2362
+ * Get the currently active client.
2363
+ */
2364
+ function getClient() {
2365
+ return getCurrentScope().getClient();
2366
+ }
2367
+
2368
+ /**
2369
+ * Get a trace context for the given scope.
2370
+ */
2371
+ function getTraceContextFromScope(scope) {
2372
+ const propagationContext = scope.getPropagationContext();
2373
+
2374
+ const { traceId, parentSpanId, propagationSpanId } = propagationContext;
2375
+
2376
+ const traceContext = {
2377
+ trace_id: traceId,
2378
+ span_id: propagationSpanId || generateSpanId(),
2379
+ };
2380
+
2381
+ if (parentSpanId) {
2382
+ traceContext.parent_span_id = parentSpanId;
2383
+ }
2384
+
2385
+ return traceContext;
2386
+ }
2387
+
2388
+ /**
2389
+ * Use this attribute to represent the source of a span.
2390
+ * Should be one of: custom, url, route, view, component, task, unknown
2391
+ *
2392
+ */
2393
+ const SEMANTIC_ATTRIBUTE_SENTRY_SOURCE = 'sentry.source';
2394
+
2395
+ /**
2396
+ * Attributes that holds the sample rate that was locally applied to a span.
2397
+ * If this attribute is not defined, it means that the span inherited a sampling decision.
2398
+ *
2399
+ * NOTE: Is only defined on root spans.
2400
+ */
2401
+ const SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE = 'sentry.sample_rate';
2402
+
2403
+ /**
2404
+ * Attribute holding the sample rate of the previous trace.
2405
+ * This is used to sample consistently across subsequent traces in the browser SDK.
2406
+ *
2407
+ * Note: Only defined on root spans, if opted into consistent sampling
2408
+ */
2409
+ const SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE = 'sentry.previous_trace_sample_rate';
2410
+
2411
+ /**
2412
+ * Use this attribute to represent the operation of a span.
2413
+ */
2414
+ const SEMANTIC_ATTRIBUTE_SENTRY_OP = 'sentry.op';
2415
+
2416
+ /**
2417
+ * Use this attribute to represent the origin of a span.
2418
+ */
2419
+ const SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN = 'sentry.origin';
2420
+
2421
+ /**
2422
+ * The id of the profile that this span occurred in.
2423
+ */
2424
+ const SEMANTIC_ATTRIBUTE_PROFILE_ID = 'sentry.profile_id';
2425
+
2426
+ const SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME = 'sentry.exclusive_time';
2427
+
2428
+ const SPAN_STATUS_UNSET = 0;
2429
+ const SPAN_STATUS_OK = 1;
2430
+
2431
+ const SCOPE_ON_START_SPAN_FIELD = '_sentryScope';
2432
+ const ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';
2433
+
2434
+ /** Try to unwrap a scope from a potential WeakRef wrapper. */
2435
+ function unwrapScopeFromWeakRef(scopeRef) {
2436
+ if (!scopeRef) {
2437
+ return undefined;
2438
+ }
2439
+
2440
+ if (typeof scopeRef === 'object' && 'deref' in scopeRef && typeof scopeRef.deref === 'function') {
2441
+ try {
2442
+ return scopeRef.deref();
2443
+ } catch {
2444
+ return undefined;
2445
+ }
2446
+ }
2447
+
2448
+ // Fallback to a direct scope
2449
+ return scopeRef ;
2450
+ }
2451
+
2452
+ /**
2453
+ * Grabs the scope and isolation scope off a span that were active when the span was started.
2454
+ * If WeakRef was used and scopes have been garbage collected, returns undefined for those scopes.
2455
+ */
2456
+ function getCapturedScopesOnSpan(span) {
2457
+ const spanWithScopes = span ;
2458
+
2459
+ return {
2460
+ scope: spanWithScopes[SCOPE_ON_START_SPAN_FIELD],
2461
+ isolationScope: unwrapScopeFromWeakRef(spanWithScopes[ISOLATION_SCOPE_ON_START_SPAN_FIELD]),
2462
+ };
2463
+ }
2464
+
2465
+ const SENTRY_BAGGAGE_KEY_PREFIX = 'sentry-';
2466
+
2467
+ const SENTRY_BAGGAGE_KEY_PREFIX_REGEX = /^sentry-/;
2468
+
2469
+ /**
2470
+ * Takes a baggage header and turns it into Dynamic Sampling Context, by extracting all the "sentry-" prefixed values
2471
+ * from it.
2472
+ *
2473
+ * @param baggageHeader A very bread definition of a baggage header as it might appear in various frameworks.
2474
+ * @returns The Dynamic Sampling Context that was found on `baggageHeader`, if there was any, `undefined` otherwise.
2475
+ */
2476
+ function baggageHeaderToDynamicSamplingContext(
2477
+ // Very liberal definition of what any incoming header might look like
2478
+ baggageHeader,
2479
+ ) {
2480
+ const baggageObject = parseBaggageHeader(baggageHeader);
2481
+
2482
+ if (!baggageObject) {
2483
+ return undefined;
2484
+ }
2485
+
2486
+ // Read all "sentry-" prefixed values out of the baggage object and put it onto a dynamic sampling context object.
2487
+ const dynamicSamplingContext = Object.entries(baggageObject).reduce((acc, [key, value]) => {
2488
+ if (key.match(SENTRY_BAGGAGE_KEY_PREFIX_REGEX)) {
2489
+ const nonPrefixedKey = key.slice(SENTRY_BAGGAGE_KEY_PREFIX.length);
2490
+ acc[nonPrefixedKey] = value;
2491
+ }
2492
+ return acc;
2493
+ }, {});
2494
+
2495
+ // Only return a dynamic sampling context object if there are keys in it.
2496
+ // A keyless object means there were no sentry values on the header, which means that there is no DSC.
2497
+ if (Object.keys(dynamicSamplingContext).length > 0) {
2498
+ return dynamicSamplingContext ;
2499
+ } else {
2500
+ return undefined;
2501
+ }
2502
+ }
2503
+
2504
+ /**
2505
+ * Take a baggage header and parse it into an object.
2506
+ */
2507
+ function parseBaggageHeader(
2508
+ baggageHeader,
2509
+ ) {
2510
+ if (!baggageHeader || (!isString(baggageHeader) && !Array.isArray(baggageHeader))) {
2511
+ return undefined;
2512
+ }
2513
+
2514
+ if (Array.isArray(baggageHeader)) {
2515
+ // Combine all baggage headers into one object containing the baggage values so we can later read the Sentry-DSC-values from it
2516
+ return baggageHeader.reduce((acc, curr) => {
2517
+ const currBaggageObject = baggageHeaderToObject(curr);
2518
+ Object.entries(currBaggageObject).forEach(([key, value]) => {
2519
+ acc[key] = value;
2520
+ });
2521
+ return acc;
2522
+ }, {});
2523
+ }
2524
+
2525
+ return baggageHeaderToObject(baggageHeader);
2526
+ }
2527
+
2528
+ /**
2529
+ * Will parse a baggage header, which is a simple key-value map, into a flat object.
2530
+ *
2531
+ * @param baggageHeader The baggage header to parse.
2532
+ * @returns a flat object containing all the key-value pairs from `baggageHeader`.
2533
+ */
2534
+ function baggageHeaderToObject(baggageHeader) {
2535
+ return baggageHeader
2536
+ .split(',')
2537
+ .map(baggageEntry => {
2538
+ const eqIdx = baggageEntry.indexOf('=');
2539
+ if (eqIdx === -1) {
2540
+ // Likely an invalid entry
2541
+ return [];
2542
+ }
2543
+ const key = baggageEntry.slice(0, eqIdx);
2544
+ const value = baggageEntry.slice(eqIdx + 1);
2545
+ return [key, value].map(keyOrValue => {
2546
+ try {
2547
+ return decodeURIComponent(keyOrValue.trim());
2548
+ } catch {
2549
+ // We ignore errors here, e.g. if the value cannot be URL decoded.
2550
+ // This will then be skipped in the next step
2551
+ return;
2552
+ }
2553
+ });
2554
+ })
2555
+ .reduce((acc, [key, value]) => {
2556
+ if (key && value) {
2557
+ acc[key] = value;
2558
+ }
2559
+ return acc;
2560
+ }, {});
2561
+ }
2562
+
2563
+ /** Regular expression used to extract org ID from a DSN host. */
2564
+ const ORG_ID_REGEX = /^o(\d+)\./;
2565
+
2566
+ /** Regular expression used to parse a Dsn. */
2567
+ const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;
2568
+
2569
+ function isValidProtocol(protocol) {
2570
+ return protocol === 'http' || protocol === 'https';
2571
+ }
2572
+
2573
+ /**
2574
+ * Renders the string representation of this Dsn.
2575
+ *
2576
+ * By default, this will render the public representation without the password
2577
+ * component. To get the deprecated private representation, set `withPassword`
2578
+ * to true.
2579
+ *
2580
+ * @param withPassword When set to true, the password will be included.
2581
+ */
2582
+ function dsnToString(dsn, withPassword = false) {
2583
+ const { host, path, pass, port, projectId, protocol, publicKey } = dsn;
2584
+ return (
2585
+ `${protocol}://${publicKey}${withPassword && pass ? `:${pass}` : ''}` +
2586
+ `@${host}${port ? `:${port}` : ''}/${path ? `${path}/` : path}${projectId}`
2587
+ );
2588
+ }
2589
+
2590
+ /**
2591
+ * Parses a Dsn from a given string.
2592
+ *
2593
+ * @param str A Dsn as string
2594
+ * @returns Dsn as DsnComponents or undefined if @param str is not a valid DSN string
2595
+ */
2596
+ function dsnFromString(str) {
2597
+ const match = DSN_REGEX.exec(str);
2598
+
2599
+ if (!match) {
2600
+ // This should be logged to the console
2601
+ consoleSandbox(() => {
2602
+ // eslint-disable-next-line no-console
2603
+ console.error(`Invalid Sentry Dsn: ${str}`);
2604
+ });
2605
+ return undefined;
2606
+ }
2607
+
2608
+ const [protocol, publicKey, pass = '', host = '', port = '', lastPath = ''] = match.slice(1);
2609
+ let path = '';
2610
+ let projectId = lastPath;
2611
+
2612
+ const split = projectId.split('/');
2613
+ if (split.length > 1) {
2614
+ path = split.slice(0, -1).join('/');
2615
+ projectId = split.pop() ;
2616
+ }
2617
+
2618
+ if (projectId) {
2619
+ const projectMatch = projectId.match(/^\d+/);
2620
+ if (projectMatch) {
2621
+ projectId = projectMatch[0];
2622
+ }
2623
+ }
2624
+
2625
+ return dsnFromComponents({ host, pass, path, projectId, port, protocol: protocol , publicKey });
2626
+ }
2627
+
2628
+ function dsnFromComponents(components) {
2629
+ return {
2630
+ protocol: components.protocol,
2631
+ publicKey: components.publicKey || '',
2632
+ pass: components.pass || '',
2633
+ host: components.host,
2634
+ port: components.port || '',
2635
+ path: components.path || '',
2636
+ projectId: components.projectId,
2637
+ };
2638
+ }
2639
+
2640
+ function validateDsn(dsn) {
2641
+ if (!DEBUG_BUILD) {
2642
+ return true;
2643
+ }
2644
+
2645
+ const { port, projectId, protocol } = dsn;
2646
+
2647
+ const requiredComponents = ['protocol', 'publicKey', 'host', 'projectId'];
2648
+ const hasMissingRequiredComponent = requiredComponents.find(component => {
2649
+ if (!dsn[component]) {
2650
+ debug.error(`Invalid Sentry Dsn: ${component} missing`);
2651
+ return true;
2652
+ }
2653
+ return false;
2654
+ });
2655
+
2656
+ if (hasMissingRequiredComponent) {
2657
+ return false;
2658
+ }
2659
+
2660
+ if (!projectId.match(/^\d+$/)) {
2661
+ debug.error(`Invalid Sentry Dsn: Invalid projectId ${projectId}`);
2662
+ return false;
2663
+ }
2664
+
2665
+ if (!isValidProtocol(protocol)) {
2666
+ debug.error(`Invalid Sentry Dsn: Invalid protocol ${protocol}`);
2667
+ return false;
2668
+ }
2669
+
2670
+ if (port && isNaN(parseInt(port, 10))) {
2671
+ debug.error(`Invalid Sentry Dsn: Invalid port ${port}`);
2672
+ return false;
2673
+ }
2674
+
2675
+ return true;
2676
+ }
2677
+
2678
+ /**
2679
+ * Extract the org ID from a DSN host.
2680
+ *
2681
+ * @param host The host from a DSN
2682
+ * @returns The org ID if found, undefined otherwise
2683
+ */
2684
+ function extractOrgIdFromDsnHost(host) {
2685
+ const match = host.match(ORG_ID_REGEX);
2686
+
2687
+ return match?.[1];
2688
+ }
2689
+
2690
+ /**
2691
+ * Returns the organization ID of the client.
2692
+ *
2693
+ * The organization ID is extracted from the DSN. If the client options include a `orgId`, this will always take precedence.
2694
+ */
2695
+ function extractOrgIdFromClient(client) {
2696
+ const options = client.getOptions();
2697
+
2698
+ const { host } = client.getDsn() || {};
2699
+
2700
+ let org_id;
2701
+
2702
+ if (options.orgId) {
2703
+ org_id = String(options.orgId);
2704
+ } else if (host) {
2705
+ org_id = extractOrgIdFromDsnHost(host);
2706
+ }
2707
+
2708
+ return org_id;
2709
+ }
2710
+
2711
+ /**
2712
+ * Creates a valid Sentry Dsn object, identifying a Sentry instance and project.
2713
+ * @returns a valid DsnComponents object or `undefined` if @param from is an invalid DSN source
2714
+ */
2715
+ function makeDsn(from) {
2716
+ const components = typeof from === 'string' ? dsnFromString(from) : dsnFromComponents(from);
2717
+ if (!components || !validateDsn(components)) {
2718
+ return undefined;
2719
+ }
2720
+ return components;
2721
+ }
2722
+
2723
+ const TRACE_FLAG_SAMPLED = 0x1;
2724
+
2725
+ let hasShownSpanDropWarning = false;
2726
+
2727
+ /**
2728
+ * Convert a span to a trace context, which can be sent as the `trace` context in a non-transaction event.
2729
+ */
2730
+ function spanToTraceContext(span) {
2731
+ const { spanId, traceId: trace_id, isRemote } = span.spanContext();
2732
+
2733
+ // If the span is remote, we use a random/virtual span as span_id to the trace context,
2734
+ // and the remote span as parent_span_id
2735
+ const parent_span_id = isRemote ? spanId : spanToJSON(span).parent_span_id;
2736
+ const scope = getCapturedScopesOnSpan(span).scope;
2737
+
2738
+ const span_id = isRemote ? scope?.getPropagationContext().propagationSpanId || generateSpanId() : spanId;
2739
+
2740
+ return {
2741
+ parent_span_id,
2742
+ span_id,
2743
+ trace_id,
2744
+ };
2745
+ }
2746
+
2747
+ /**
2748
+ * Converts the span links array to a flattened version to be sent within an envelope.
2749
+ *
2750
+ * If the links array is empty, it returns `undefined` so the empty value can be dropped before it's sent.
2751
+ */
2752
+ function convertSpanLinksForEnvelope(links) {
2753
+ if (links && links.length > 0) {
2754
+ return links.map(({ context: { spanId, traceId, traceFlags, ...restContext }, attributes }) => ({
2755
+ span_id: spanId,
2756
+ trace_id: traceId,
2757
+ sampled: traceFlags === TRACE_FLAG_SAMPLED,
2758
+ attributes,
2759
+ ...restContext,
2760
+ }));
2761
+ } else {
2762
+ return undefined;
2763
+ }
2764
+ }
2765
+
2766
+ /**
2767
+ * Convert a span time input into a timestamp in seconds.
2768
+ */
2769
+ function spanTimeInputToSeconds(input) {
2770
+ if (typeof input === 'number') {
2771
+ return ensureTimestampInSeconds(input);
2772
+ }
2773
+
2774
+ if (Array.isArray(input)) {
2775
+ // See {@link HrTime} for the array-based time format
2776
+ return input[0] + input[1] / 1e9;
2777
+ }
2778
+
2779
+ if (input instanceof Date) {
2780
+ return ensureTimestampInSeconds(input.getTime());
2781
+ }
2782
+
2783
+ return timestampInSeconds();
2784
+ }
2785
+
2786
+ /**
2787
+ * Converts a timestamp to second, if it was in milliseconds, or keeps it as second.
2788
+ */
2789
+ function ensureTimestampInSeconds(timestamp) {
2790
+ const isMs = timestamp > 9999999999;
2791
+ return isMs ? timestamp / 1000 : timestamp;
2792
+ }
2793
+
2794
+ /**
2795
+ * Convert a span to a JSON representation.
2796
+ */
2797
+ // Note: Because of this, we currently have a circular type dependency (which we opted out of in package.json).
2798
+ // This is not avoidable as we need `spanToJSON` in `spanUtils.ts`, which in turn is needed by `span.ts` for backwards compatibility.
2799
+ // And `spanToJSON` needs the Span class from `span.ts` to check here.
2800
+ function spanToJSON(span) {
2801
+ if (spanIsSentrySpan(span)) {
2802
+ return span.getSpanJSON();
2803
+ }
2804
+
2805
+ const { spanId: span_id, traceId: trace_id } = span.spanContext();
2806
+
2807
+ // Handle a span from @opentelemetry/sdk-base-trace's `Span` class
2808
+ if (spanIsOpenTelemetrySdkTraceBaseSpan(span)) {
2809
+ const { attributes, startTime, name, endTime, status, links } = span;
2810
+
2811
+ // In preparation for the next major of OpenTelemetry, we want to support
2812
+ // looking up the parent span id according to the new API
2813
+ // In OTel v1, the parent span id is accessed as `parentSpanId`
2814
+ // In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`
2815
+ const parentSpanId =
2816
+ 'parentSpanId' in span
2817
+ ? span.parentSpanId
2818
+ : 'parentSpanContext' in span
2819
+ ? (span.parentSpanContext )?.spanId
2820
+ : undefined;
2821
+
2822
+ return {
2823
+ span_id,
2824
+ trace_id,
2825
+ data: attributes,
2826
+ description: name,
2827
+ parent_span_id: parentSpanId,
2828
+ start_timestamp: spanTimeInputToSeconds(startTime),
2829
+ // This is [0,0] by default in OTEL, in which case we want to interpret this as no end time
2830
+ timestamp: spanTimeInputToSeconds(endTime) || undefined,
2831
+ status: getStatusMessage(status),
2832
+ op: attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP],
2833
+ origin: attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] ,
2834
+ links: convertSpanLinksForEnvelope(links),
2835
+ };
2836
+ }
2837
+
2838
+ // Finally, at least we have `spanContext()`....
2839
+ // This should not actually happen in reality, but we need to handle it for type safety.
2840
+ return {
2841
+ span_id,
2842
+ trace_id,
2843
+ start_timestamp: 0,
2844
+ data: {},
2845
+ };
2846
+ }
2847
+
2848
+ function spanIsOpenTelemetrySdkTraceBaseSpan(span) {
2849
+ const castSpan = span ;
2850
+ return !!castSpan.attributes && !!castSpan.startTime && !!castSpan.name && !!castSpan.endTime && !!castSpan.status;
2851
+ }
2852
+
2853
+ /** Exported only for tests. */
2854
+
2855
+ /**
2856
+ * Sadly, due to circular dependency checks we cannot actually import the Span class here and check for instanceof.
2857
+ * :( So instead we approximate this by checking if it has the `getSpanJSON` method.
2858
+ */
2859
+ function spanIsSentrySpan(span) {
2860
+ return typeof (span ).getSpanJSON === 'function';
2861
+ }
2862
+
2863
+ /**
2864
+ * Returns true if a span is sampled.
2865
+ * In most cases, you should just use `span.isRecording()` instead.
2866
+ * However, this has a slightly different semantic, as it also returns false if the span is finished.
2867
+ * So in the case where this distinction is important, use this method.
2868
+ */
2869
+ function spanIsSampled(span) {
2870
+ // We align our trace flags with the ones OpenTelemetry use
2871
+ // So we also check for sampled the same way they do.
2872
+ const { traceFlags } = span.spanContext();
2873
+ return traceFlags === TRACE_FLAG_SAMPLED;
2874
+ }
2875
+
2876
+ /** Get the status message to use for a JSON representation of a span. */
2877
+ function getStatusMessage(status) {
2878
+ if (!status || status.code === SPAN_STATUS_UNSET) {
2879
+ return undefined;
2880
+ }
2881
+
2882
+ if (status.code === SPAN_STATUS_OK) {
2883
+ return 'ok';
2884
+ }
2885
+
2886
+ return status.message || 'internal_error';
2887
+ }
2888
+ const ROOT_SPAN_FIELD = '_sentryRootSpan';
2889
+
2890
+ /**
2891
+ * Returns the root span of a given span.
2892
+ */
2893
+ function getRootSpan(span) {
2894
+ return span[ROOT_SPAN_FIELD] || span;
2895
+ }
2896
+
2897
+ /**
2898
+ * Logs a warning once if `beforeSendSpan` is used to drop spans.
2899
+ */
2900
+ function showSpanDropWarning() {
2901
+ if (!hasShownSpanDropWarning) {
2902
+ consoleSandbox(() => {
2903
+ // eslint-disable-next-line no-console
2904
+ console.warn(
2905
+ '[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.',
2906
+ );
2907
+ });
2908
+ hasShownSpanDropWarning = true;
2909
+ }
2910
+ }
2911
+
2912
+ // Treeshakable guard to remove all code related to tracing
2913
+
2914
+ /**
2915
+ * Determines if span recording is currently enabled.
2916
+ *
2917
+ * Spans are recorded when at least one of `tracesSampleRate` and `tracesSampler`
2918
+ * is defined in the SDK config. This function does not make any assumption about
2919
+ * sampling decisions, it only checks if the SDK is configured to record spans.
2920
+ *
2921
+ * Important: This function only determines if span recording is enabled. Trace
2922
+ * continuation and propagation is separately controlled and not covered by this function.
2923
+ * If this function returns `false`, traces can still be propagated (which is what
2924
+ * we refer to by "Tracing without Performance")
2925
+ * @see https://develop.sentry.dev/sdk/telemetry/traces/tracing-without-performance/
2926
+ *
2927
+ * @param maybeOptions An SDK options object to be passed to this function.
2928
+ * If this option is not provided, the function will use the current client's options.
2929
+ */
2930
+ function hasSpansEnabled(
2931
+ maybeOptions,
2932
+ ) {
2933
+ if (typeof __SENTRY_TRACING__ === 'boolean' && !__SENTRY_TRACING__) {
2934
+ return false;
2935
+ }
2936
+
2937
+ const options = getClient()?.getOptions();
2938
+ return (
2939
+ !!options &&
2940
+ // Note: This check is `!= null`, meaning "nullish". `0` is not "nullish", `undefined` and `null` are. (This comment was brought to you by 15 minutes of questioning life)
2941
+ (options.tracesSampleRate != null || !!options.tracesSampler)
2942
+ );
2943
+ }
2944
+
2945
+ const DEFAULT_ENVIRONMENT = 'production';
2946
+
2947
+ /**
2948
+ * If you change this value, also update the terser plugin config to
2949
+ * avoid minification of the object property!
2950
+ */
2951
+ const FROZEN_DSC_FIELD = '_frozenDsc';
2952
+
2953
+ /**
2954
+ * Creates a dynamic sampling context from a client.
2955
+ *
2956
+ * Dispatches the `createDsc` lifecycle hook as a side effect.
2957
+ */
2958
+ function getDynamicSamplingContextFromClient(trace_id, client) {
2959
+ const options = client.getOptions();
2960
+
2961
+ const { publicKey: public_key } = client.getDsn() || {};
2962
+
2963
+ // Instead of conditionally adding non-undefined values, we add them and then remove them if needed
2964
+ // otherwise, the order of baggage entries changes, which "breaks" a bunch of tests etc.
2965
+ const dsc = {
2966
+ environment: options.environment || DEFAULT_ENVIRONMENT,
2967
+ release: options.release,
2968
+ public_key,
2969
+ trace_id,
2970
+ org_id: extractOrgIdFromClient(client),
2971
+ };
2972
+
2973
+ client.emit('createDsc', dsc);
2974
+
2975
+ return dsc;
2976
+ }
2977
+
2978
+ /**
2979
+ * Get the dynamic sampling context for the currently active scopes.
2980
+ */
2981
+ function getDynamicSamplingContextFromScope(client, scope) {
2982
+ const propagationContext = scope.getPropagationContext();
2983
+ return propagationContext.dsc || getDynamicSamplingContextFromClient(propagationContext.traceId, client);
2984
+ }
2985
+
2986
+ /**
2987
+ * Creates a dynamic sampling context from a span (and client and scope)
2988
+ *
2989
+ * @param span the span from which a few values like the root span name and sample rate are extracted.
2990
+ *
2991
+ * @returns a dynamic sampling context
2992
+ */
2993
+ function getDynamicSamplingContextFromSpan(span) {
2994
+ const client = getClient();
2995
+ if (!client) {
2996
+ return {};
2997
+ }
2998
+
2999
+ const rootSpan = getRootSpan(span);
3000
+ const rootSpanJson = spanToJSON(rootSpan);
3001
+ const rootSpanAttributes = rootSpanJson.data;
3002
+ const traceState = rootSpan.spanContext().traceState;
3003
+
3004
+ // The span sample rate that was locally applied to the root span should also always be applied to the DSC, even if the DSC is frozen.
3005
+ // This is so that the downstream traces/services can use parentSampleRate in their `tracesSampler` to make consistent sampling decisions across the entire trace.
3006
+ const rootSpanSampleRate =
3007
+ traceState?.get('sentry.sample_rate') ??
3008
+ rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] ??
3009
+ rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_PREVIOUS_TRACE_SAMPLE_RATE];
3010
+
3011
+ function applyLocalSampleRateToDsc(dsc) {
3012
+ if (typeof rootSpanSampleRate === 'number' || typeof rootSpanSampleRate === 'string') {
3013
+ dsc.sample_rate = `${rootSpanSampleRate}`;
3014
+ }
3015
+ return dsc;
3016
+ }
3017
+
3018
+ // For core implementation, we freeze the DSC onto the span as a non-enumerable property
3019
+ const frozenDsc = (rootSpan )[FROZEN_DSC_FIELD];
3020
+ if (frozenDsc) {
3021
+ return applyLocalSampleRateToDsc(frozenDsc);
3022
+ }
3023
+
3024
+ // For OpenTelemetry, we freeze the DSC on the trace state
3025
+ const traceStateDsc = traceState?.get('sentry.dsc');
3026
+
3027
+ // If the span has a DSC, we want it to take precedence
3028
+ const dscOnTraceState = traceStateDsc && baggageHeaderToDynamicSamplingContext(traceStateDsc);
3029
+
3030
+ if (dscOnTraceState) {
3031
+ return applyLocalSampleRateToDsc(dscOnTraceState);
3032
+ }
3033
+
3034
+ // Else, we generate it from the span
3035
+ const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);
3036
+
3037
+ // We don't want to have a transaction name in the DSC if the source is "url" because URLs might contain PII
3038
+ const source = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
3039
+
3040
+ // after JSON conversion, txn.name becomes jsonSpan.description
3041
+ const name = rootSpanJson.description;
3042
+ if (source !== 'url' && name) {
3043
+ dsc.transaction = name;
3044
+ }
3045
+
3046
+ // How can we even land here with hasSpansEnabled() returning false?
3047
+ // Otel creates a Non-recording span in Tracing Without Performance mode when handling incoming requests
3048
+ // So we end up with an active span that is not sampled (neither positively nor negatively)
3049
+ if (hasSpansEnabled()) {
3050
+ dsc.sampled = String(spanIsSampled(rootSpan));
3051
+ dsc.sample_rand =
3052
+ // In OTEL we store the sample rand on the trace state because we cannot access scopes for NonRecordingSpans
3053
+ // The Sentry OTEL SpanSampler takes care of writing the sample rand on the root span
3054
+ traceState?.get('sentry.sample_rand') ??
3055
+ // On all other platforms we can actually get the scopes from a root span (we use this as a fallback)
3056
+ getCapturedScopesOnSpan(rootSpan).scope?.getPropagationContext().sampleRand.toString();
3057
+ }
3058
+
3059
+ applyLocalSampleRateToDsc(dsc);
3060
+
3061
+ client.emit('createDsc', dsc, rootSpan);
3062
+
3063
+ return dsc;
3064
+ }
3065
+
3066
+ /**
3067
+ * Recursively normalizes the given object.
3068
+ *
3069
+ * - Creates a copy to prevent original input mutation
3070
+ * - Skips non-enumerable properties
3071
+ * - When stringifying, calls `toJSON` if implemented
3072
+ * - Removes circular references
3073
+ * - Translates non-serializable values (`undefined`/`NaN`/functions) to serializable format
3074
+ * - Translates known global objects/classes to a string representations
3075
+ * - Takes care of `Error` object serialization
3076
+ * - Optionally limits depth of final output
3077
+ * - Optionally limits number of properties/elements included in any single object/array
3078
+ *
3079
+ * @param input The object to be normalized.
3080
+ * @param depth The max depth to which to normalize the object. (Anything deeper stringified whole.)
3081
+ * @param maxProperties The max number of elements or properties to be included in any single array or
3082
+ * object in the normalized output.
3083
+ * @returns A normalized version of the object, or `"**non-serializable**"` if any errors are thrown during normalization.
3084
+ */
3085
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3086
+ function normalize(input, depth = 100, maxProperties = +Infinity) {
3087
+ try {
3088
+ // since we're at the outermost level, we don't provide a key
3089
+ return visit('', input, depth, maxProperties);
3090
+ } catch (err) {
3091
+ return { ERROR: `**non-serializable** (${err})` };
3092
+ }
3093
+ }
3094
+
3095
+ /** JSDoc */
3096
+ function normalizeToSize(
3097
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3098
+ object,
3099
+ // Default Node.js REPL depth
3100
+ depth = 3,
3101
+ // 100kB, as 200kB is max payload size, so half sounds reasonable
3102
+ maxSize = 100 * 1024,
3103
+ ) {
3104
+ const normalized = normalize(object, depth);
3105
+
3106
+ if (jsonSize(normalized) > maxSize) {
3107
+ return normalizeToSize(object, depth - 1, maxSize);
3108
+ }
3109
+
3110
+ return normalized ;
3111
+ }
3112
+
3113
+ /**
3114
+ * Visits a node to perform normalization on it
3115
+ *
3116
+ * @param key The key corresponding to the given node
3117
+ * @param value The node to be visited
3118
+ * @param depth Optional number indicating the maximum recursion depth
3119
+ * @param maxProperties Optional maximum number of properties/elements included in any single object/array
3120
+ * @param memo Optional Memo class handling decycling
3121
+ */
3122
+ function visit(
3123
+ key,
3124
+ value,
3125
+ depth = +Infinity,
3126
+ maxProperties = +Infinity,
3127
+ memo = memoBuilder(),
3128
+ ) {
3129
+ const [memoize, unmemoize] = memo;
3130
+
3131
+ // Get the simple cases out of the way first
3132
+ if (
3133
+ value == null || // this matches null and undefined -> eqeq not eqeqeq
3134
+ ['boolean', 'string'].includes(typeof value) ||
3135
+ (typeof value === 'number' && Number.isFinite(value))
3136
+ ) {
3137
+ return value ;
3138
+ }
3139
+
3140
+ const stringified = stringifyValue(key, value);
3141
+
3142
+ // Anything we could potentially dig into more (objects or arrays) will have come back as `"[object XXXX]"`.
3143
+ // Everything else will have already been serialized, so if we don't see that pattern, we're done.
3144
+ if (!stringified.startsWith('[object ')) {
3145
+ return stringified;
3146
+ }
3147
+
3148
+ // From here on, we can assert that `value` is either an object or an array.
3149
+
3150
+ // Do not normalize objects that we know have already been normalized. As a general rule, the
3151
+ // "__sentry_skip_normalization__" property should only be used sparingly and only should only be set on objects that
3152
+ // have already been normalized.
3153
+ if ((value )['__sentry_skip_normalization__']) {
3154
+ return value ;
3155
+ }
3156
+
3157
+ // We can set `__sentry_override_normalization_depth__` on an object to ensure that from there
3158
+ // We keep a certain amount of depth.
3159
+ // This should be used sparingly, e.g. we use it for the redux integration to ensure we get a certain amount of state.
3160
+ const remainingDepth =
3161
+ typeof (value )['__sentry_override_normalization_depth__'] === 'number'
3162
+ ? ((value )['__sentry_override_normalization_depth__'] )
3163
+ : depth;
3164
+
3165
+ // We're also done if we've reached the max depth
3166
+ if (remainingDepth === 0) {
3167
+ // At this point we know `serialized` is a string of the form `"[object XXXX]"`. Clean it up so it's just `"[XXXX]"`.
3168
+ return stringified.replace('object ', '');
3169
+ }
3170
+
3171
+ // If we've already visited this branch, bail out, as it's circular reference. If not, note that we're seeing it now.
3172
+ if (memoize(value)) {
3173
+ return '[Circular ~]';
3174
+ }
3175
+
3176
+ // If the value has a `toJSON` method, we call it to extract more information
3177
+ const valueWithToJSON = value ;
3178
+ if (valueWithToJSON && typeof valueWithToJSON.toJSON === 'function') {
3179
+ try {
3180
+ const jsonValue = valueWithToJSON.toJSON();
3181
+ // We need to normalize the return value of `.toJSON()` in case it has circular references
3182
+ return visit('', jsonValue, remainingDepth - 1, maxProperties, memo);
3183
+ } catch {
3184
+ // pass (The built-in `toJSON` failed, but we can still try to do it ourselves)
3185
+ }
3186
+ }
3187
+
3188
+ // At this point we know we either have an object or an array, we haven't seen it before, and we're going to recurse
3189
+ // because we haven't yet reached the max depth. Create an accumulator to hold the results of visiting each
3190
+ // property/entry, and keep track of the number of items we add to it.
3191
+ const normalized = (Array.isArray(value) ? [] : {}) ;
3192
+ let numAdded = 0;
3193
+
3194
+ // Before we begin, convert`Error` and`Event` instances into plain objects, since some of each of their relevant
3195
+ // properties are non-enumerable and otherwise would get missed.
3196
+ const visitable = convertToPlainObject(value );
3197
+
3198
+ for (const visitKey in visitable) {
3199
+ // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration.
3200
+ if (!Object.prototype.hasOwnProperty.call(visitable, visitKey)) {
3201
+ continue;
3202
+ }
3203
+
3204
+ if (numAdded >= maxProperties) {
3205
+ normalized[visitKey] = '[MaxProperties ~]';
3206
+ break;
3207
+ }
3208
+
3209
+ // Recursively visit all the child nodes
3210
+ const visitValue = visitable[visitKey];
3211
+ normalized[visitKey] = visit(visitKey, visitValue, remainingDepth - 1, maxProperties, memo);
3212
+
3213
+ numAdded++;
3214
+ }
3215
+
3216
+ // Once we've visited all the branches, remove the parent from memo storage
3217
+ unmemoize(value);
3218
+
3219
+ // Return accumulated values
3220
+ return normalized;
3221
+ }
3222
+
3223
+ /* eslint-disable complexity */
3224
+ /**
3225
+ * Stringify the given value. Handles various known special values and types.
3226
+ *
3227
+ * Not meant to be used on simple primitives which already have a string representation, as it will, for example, turn
3228
+ * the number 1231 into "[Object Number]", nor on `null`, as it will throw.
3229
+ *
3230
+ * @param value The value to stringify
3231
+ * @returns A stringified representation of the given value
3232
+ */
3233
+ function stringifyValue(
3234
+ key,
3235
+ // this type is a tiny bit of a cheat, since this function does handle NaN (which is technically a number), but for
3236
+ // our internal use, it'll do
3237
+ value,
3238
+ ) {
3239
+ try {
3240
+ if (key === 'domain' && value && typeof value === 'object' && (value )._events) {
3241
+ return '[Domain]';
3242
+ }
3243
+
3244
+ if (key === 'domainEmitter') {
3245
+ return '[DomainEmitter]';
3246
+ }
3247
+
3248
+ // It's safe to use `global`, `window`, and `document` here in this manner, as we are asserting using `typeof` first
3249
+ // which won't throw if they are not present.
3250
+
3251
+ if (typeof global !== 'undefined' && value === global) {
3252
+ return '[Global]';
3253
+ }
3254
+
3255
+ // eslint-disable-next-line no-restricted-globals
3256
+ if (typeof window !== 'undefined' && value === window) {
3257
+ return '[Window]';
3258
+ }
3259
+
3260
+ // eslint-disable-next-line no-restricted-globals
3261
+ if (typeof document !== 'undefined' && value === document) {
3262
+ return '[Document]';
3263
+ }
3264
+
3265
+ if (isVueViewModel(value)) {
3266
+ return getVueInternalName(value);
3267
+ }
3268
+
3269
+ // React's SyntheticEvent thingy
3270
+ if (isSyntheticEvent(value)) {
3271
+ return '[SyntheticEvent]';
3272
+ }
3273
+
3274
+ if (typeof value === 'number' && !Number.isFinite(value)) {
3275
+ return `[${value}]`;
3276
+ }
3277
+
3278
+ if (typeof value === 'function') {
3279
+ return `[Function: ${getFunctionName(value)}]`;
3280
+ }
3281
+
3282
+ if (typeof value === 'symbol') {
3283
+ return `[${String(value)}]`;
3284
+ }
3285
+
3286
+ // stringified BigInts are indistinguishable from regular numbers, so we need to label them to avoid confusion
3287
+ if (typeof value === 'bigint') {
3288
+ return `[BigInt: ${String(value)}]`;
3289
+ }
3290
+
3291
+ // Now that we've knocked out all the special cases and the primitives, all we have left are objects. Simply casting
3292
+ // them to strings means that instances of classes which haven't defined their `toStringTag` will just come out as
3293
+ // `"[object Object]"`. If we instead look at the constructor's name (which is the same as the name of the class),
3294
+ // we can make sure that only plain objects come out that way.
3295
+ const objName = getConstructorName(value);
3296
+
3297
+ // Handle HTML Elements
3298
+ if (/^HTML(\w*)Element$/.test(objName)) {
3299
+ return `[HTMLElement: ${objName}]`;
3300
+ }
3301
+
3302
+ return `[object ${objName}]`;
3303
+ } catch (err) {
3304
+ return `**non-serializable** (${err})`;
3305
+ }
3306
+ }
3307
+ /* eslint-enable complexity */
3308
+
3309
+ function getConstructorName(value) {
3310
+ const prototype = Object.getPrototypeOf(value);
3311
+
3312
+ return prototype?.constructor ? prototype.constructor.name : 'null prototype';
3313
+ }
3314
+
3315
+ /** Calculates bytes size of input string */
3316
+ function utf8Length(value) {
3317
+ // eslint-disable-next-line no-bitwise
3318
+ return ~-encodeURI(value).split(/%..|./).length;
3319
+ }
3320
+
3321
+ /** Calculates bytes size of input object */
3322
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3323
+ function jsonSize(value) {
3324
+ return utf8Length(JSON.stringify(value));
3325
+ }
3326
+
3327
+ /**
3328
+ * Helper to decycle json objects
3329
+ */
3330
+ function memoBuilder() {
3331
+ const inner = new WeakSet();
3332
+ function memoize(obj) {
3333
+ if (inner.has(obj)) {
3334
+ return true;
3335
+ }
3336
+ inner.add(obj);
3337
+ return false;
3338
+ }
3339
+
3340
+ function unmemoize(obj) {
3341
+ inner.delete(obj);
3342
+ }
3343
+ return [memoize, unmemoize];
3344
+ }
3345
+
3346
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3347
+
3348
+ /** SyncPromise internal states */
3349
+ const STATE_PENDING = 0;
3350
+ const STATE_RESOLVED = 1;
3351
+ const STATE_REJECTED = 2;
3352
+
3353
+ /**
3354
+ * Creates a resolved sync promise.
3355
+ *
3356
+ * @param value the value to resolve the promise with
3357
+ * @returns the resolved sync promise
3358
+ */
3359
+ function resolvedSyncPromise(value) {
3360
+ return new SyncPromise(resolve => {
3361
+ resolve(value);
3362
+ });
3363
+ }
3364
+
3365
+ /**
3366
+ * Creates a rejected sync promise.
3367
+ *
3368
+ * @param value the value to reject the promise with
3369
+ * @returns the rejected sync promise
3370
+ */
3371
+ function rejectedSyncPromise(reason) {
3372
+ return new SyncPromise((_, reject) => {
3373
+ reject(reason);
3374
+ });
3375
+ }
3376
+
3377
+ /**
3378
+ * Thenable class that behaves like a Promise and follows it's interface
3379
+ * but is not async internally
3380
+ */
3381
+ class SyncPromise {
3382
+
3383
+ constructor(executor) {
3384
+ this._state = STATE_PENDING;
3385
+ this._handlers = [];
3386
+
3387
+ this._runExecutor(executor);
3388
+ }
3389
+
3390
+ /** @inheritdoc */
3391
+ then(
3392
+ onfulfilled,
3393
+ onrejected,
3394
+ ) {
3395
+ return new SyncPromise((resolve, reject) => {
3396
+ this._handlers.push([
3397
+ false,
3398
+ result => {
3399
+ if (!onfulfilled) {
3400
+ // TODO: ¯\_(ツ)_/¯
3401
+ // TODO: FIXME
3402
+ resolve(result );
3403
+ } else {
3404
+ try {
3405
+ resolve(onfulfilled(result));
3406
+ } catch (e) {
3407
+ reject(e);
3408
+ }
3409
+ }
3410
+ },
3411
+ reason => {
3412
+ if (!onrejected) {
3413
+ reject(reason);
3414
+ } else {
3415
+ try {
3416
+ resolve(onrejected(reason));
3417
+ } catch (e) {
3418
+ reject(e);
3419
+ }
3420
+ }
3421
+ },
3422
+ ]);
3423
+ this._executeHandlers();
3424
+ });
3425
+ }
3426
+
3427
+ /** @inheritdoc */
3428
+ catch(
3429
+ onrejected,
3430
+ ) {
3431
+ return this.then(val => val, onrejected);
3432
+ }
3433
+
3434
+ /** @inheritdoc */
3435
+ finally(onfinally) {
3436
+ return new SyncPromise((resolve, reject) => {
3437
+ let val;
3438
+ let isRejected;
3439
+
3440
+ return this.then(
3441
+ value => {
3442
+ isRejected = false;
3443
+ val = value;
3444
+ if (onfinally) {
3445
+ onfinally();
3446
+ }
3447
+ },
3448
+ reason => {
3449
+ isRejected = true;
3450
+ val = reason;
3451
+ if (onfinally) {
3452
+ onfinally();
3453
+ }
3454
+ },
3455
+ ).then(() => {
3456
+ if (isRejected) {
3457
+ reject(val);
3458
+ return;
3459
+ }
3460
+
3461
+ resolve(val );
3462
+ });
3463
+ });
3464
+ }
3465
+
3466
+ /** Excute the resolve/reject handlers. */
3467
+ _executeHandlers() {
3468
+ if (this._state === STATE_PENDING) {
3469
+ return;
3470
+ }
3471
+
3472
+ const cachedHandlers = this._handlers.slice();
3473
+ this._handlers = [];
3474
+
3475
+ cachedHandlers.forEach(handler => {
3476
+ if (handler[0]) {
3477
+ return;
3478
+ }
3479
+
3480
+ if (this._state === STATE_RESOLVED) {
3481
+ handler[1](this._value );
3482
+ }
3483
+
3484
+ if (this._state === STATE_REJECTED) {
3485
+ handler[2](this._value);
3486
+ }
3487
+
3488
+ handler[0] = true;
3489
+ });
3490
+ }
3491
+
3492
+ /** Run the executor for the SyncPromise. */
3493
+ _runExecutor(executor) {
3494
+ const setResult = (state, value) => {
3495
+ if (this._state !== STATE_PENDING) {
3496
+ return;
3497
+ }
3498
+
3499
+ if (isThenable(value)) {
3500
+ void (value ).then(resolve, reject);
3501
+ return;
3502
+ }
3503
+
3504
+ this._state = state;
3505
+ this._value = value;
3506
+
3507
+ this._executeHandlers();
3508
+ };
3509
+
3510
+ const resolve = (value) => {
3511
+ setResult(STATE_RESOLVED, value);
3512
+ };
3513
+
3514
+ const reject = (reason) => {
3515
+ setResult(STATE_REJECTED, reason);
3516
+ };
3517
+
3518
+ try {
3519
+ executor(resolve, reject);
3520
+ } catch (e) {
3521
+ reject(e);
3522
+ }
3523
+ }
3524
+ }
3525
+
3526
+ /**
3527
+ * Process an array of event processors, returning the processed event (or `null` if the event was dropped).
3528
+ */
3529
+ function notifyEventProcessors(
3530
+ processors,
3531
+ event,
3532
+ hint,
3533
+ index = 0,
3534
+ ) {
3535
+ try {
3536
+ const result = _notifyEventProcessors(event, hint, processors, index);
3537
+ return isThenable(result) ? result : resolvedSyncPromise(result);
3538
+ } catch (error) {
3539
+ return rejectedSyncPromise(error);
3540
+ }
3541
+ }
3542
+
3543
+ function _notifyEventProcessors(
3544
+ event,
3545
+ hint,
3546
+ processors,
3547
+ index,
3548
+ ) {
3549
+ const processor = processors[index];
3550
+
3551
+ if (!event || !processor) {
3552
+ return event;
3553
+ }
3554
+
3555
+ const result = processor({ ...event }, hint);
3556
+
3557
+ DEBUG_BUILD && result === null && debug.log(`Event processor "${processor.id || '?'}" dropped event`);
3558
+
3559
+ if (isThenable(result)) {
3560
+ return result.then(final => _notifyEventProcessors(final, hint, processors, index + 1));
3561
+ }
3562
+
3563
+ return _notifyEventProcessors(result, hint, processors, index + 1);
3564
+ }
3565
+
3566
+ let parsedStackResults;
3567
+ let lastSentryKeysCount;
3568
+ let lastNativeKeysCount;
3569
+ let cachedFilenameDebugIds;
3570
+
3571
+ /**
3572
+ * Returns a map of filenames to debug identifiers.
3573
+ * Supports both proprietary _sentryDebugIds and native _debugIds (e.g., from Vercel) formats.
3574
+ */
3575
+ function getFilenameToDebugIdMap(stackParser) {
3576
+ const sentryDebugIdMap = GLOBAL_OBJ._sentryDebugIds;
3577
+ const nativeDebugIdMap = GLOBAL_OBJ._debugIds;
3578
+
3579
+ if (!sentryDebugIdMap && !nativeDebugIdMap) {
3580
+ return {};
3581
+ }
3582
+
3583
+ const sentryDebugIdKeys = sentryDebugIdMap ? Object.keys(sentryDebugIdMap) : [];
3584
+ const nativeDebugIdKeys = nativeDebugIdMap ? Object.keys(nativeDebugIdMap) : [];
3585
+
3586
+ // If the count of registered globals hasn't changed since the last call, we
3587
+ // can just return the cached result.
3588
+ if (
3589
+ cachedFilenameDebugIds &&
3590
+ sentryDebugIdKeys.length === lastSentryKeysCount &&
3591
+ nativeDebugIdKeys.length === lastNativeKeysCount
3592
+ ) {
3593
+ return cachedFilenameDebugIds;
3594
+ }
3595
+
3596
+ lastSentryKeysCount = sentryDebugIdKeys.length;
3597
+ lastNativeKeysCount = nativeDebugIdKeys.length;
3598
+
3599
+ // Build a map of filename -> debug_id from both sources
3600
+ cachedFilenameDebugIds = {};
3601
+
3602
+ if (!parsedStackResults) {
3603
+ parsedStackResults = {};
3604
+ }
3605
+
3606
+ const processDebugIds = (debugIdKeys, debugIdMap) => {
3607
+ for (const key of debugIdKeys) {
3608
+ const debugId = debugIdMap[key];
3609
+ const result = parsedStackResults?.[key];
3610
+
3611
+ if (result && cachedFilenameDebugIds && debugId) {
3612
+ // Use cached filename but update with current debug ID
3613
+ cachedFilenameDebugIds[result[0]] = debugId;
3614
+ // Update cached result with new debug ID
3615
+ if (parsedStackResults) {
3616
+ parsedStackResults[key] = [result[0], debugId];
3617
+ }
3618
+ } else if (debugId) {
3619
+ const parsedStack = stackParser(key);
3620
+
3621
+ for (let i = parsedStack.length - 1; i >= 0; i--) {
3622
+ const stackFrame = parsedStack[i];
3623
+ const filename = stackFrame?.filename;
3624
+
3625
+ if (filename && cachedFilenameDebugIds && parsedStackResults) {
3626
+ cachedFilenameDebugIds[filename] = debugId;
3627
+ parsedStackResults[key] = [filename, debugId];
3628
+ break;
3629
+ }
3630
+ }
3631
+ }
3632
+ }
3633
+ };
3634
+
3635
+ if (sentryDebugIdMap) {
3636
+ processDebugIds(sentryDebugIdKeys, sentryDebugIdMap);
3637
+ }
3638
+
3639
+ // Native _debugIds will override _sentryDebugIds if same file
3640
+ if (nativeDebugIdMap) {
3641
+ processDebugIds(nativeDebugIdKeys, nativeDebugIdMap);
3642
+ }
3643
+
3644
+ return cachedFilenameDebugIds;
3645
+ }
3646
+
3647
+ /**
3648
+ * Applies data from the scope to the event and runs all event processors on it.
3649
+ */
3650
+ function applyScopeDataToEvent(event, data) {
3651
+ const { fingerprint, span, breadcrumbs, sdkProcessingMetadata } = data;
3652
+
3653
+ // Apply general data
3654
+ applyDataToEvent(event, data);
3655
+
3656
+ // We want to set the trace context for normal events only if there isn't already
3657
+ // a trace context on the event. There is a product feature in place where we link
3658
+ // errors with transaction and it relies on that.
3659
+ if (span) {
3660
+ applySpanToEvent(event, span);
3661
+ }
3662
+
3663
+ applyFingerprintToEvent(event, fingerprint);
3664
+ applyBreadcrumbsToEvent(event, breadcrumbs);
3665
+ applySdkMetadataToEvent(event, sdkProcessingMetadata);
3666
+ }
3667
+
3668
+ /** Merge data of two scopes together. */
3669
+ function mergeScopeData(data, mergeData) {
3670
+ const {
3671
+ extra,
3672
+ tags,
3673
+ attributes,
3674
+ user,
3675
+ contexts,
3676
+ level,
3677
+ sdkProcessingMetadata,
3678
+ breadcrumbs,
3679
+ fingerprint,
3680
+ eventProcessors,
3681
+ attachments,
3682
+ propagationContext,
3683
+ transactionName,
3684
+ span,
3685
+ } = mergeData;
3686
+
3687
+ mergeAndOverwriteScopeData(data, 'extra', extra);
3688
+ mergeAndOverwriteScopeData(data, 'tags', tags);
3689
+ mergeAndOverwriteScopeData(data, 'attributes', attributes);
3690
+ mergeAndOverwriteScopeData(data, 'user', user);
3691
+ mergeAndOverwriteScopeData(data, 'contexts', contexts);
3692
+
3693
+ data.sdkProcessingMetadata = merge(data.sdkProcessingMetadata, sdkProcessingMetadata, 2);
3694
+
3695
+ if (level) {
3696
+ data.level = level;
3697
+ }
3698
+
3699
+ if (transactionName) {
3700
+ data.transactionName = transactionName;
3701
+ }
3702
+
3703
+ if (span) {
3704
+ data.span = span;
3705
+ }
3706
+
3707
+ if (breadcrumbs.length) {
3708
+ data.breadcrumbs = [...data.breadcrumbs, ...breadcrumbs];
3709
+ }
3710
+
3711
+ if (fingerprint.length) {
3712
+ data.fingerprint = [...data.fingerprint, ...fingerprint];
3713
+ }
3714
+
3715
+ if (eventProcessors.length) {
3716
+ data.eventProcessors = [...data.eventProcessors, ...eventProcessors];
3717
+ }
3718
+
3719
+ if (attachments.length) {
3720
+ data.attachments = [...data.attachments, ...attachments];
3721
+ }
3722
+
3723
+ data.propagationContext = { ...data.propagationContext, ...propagationContext };
3724
+ }
3725
+
3726
+ /**
3727
+ * Merges certain scope data. Undefined values will overwrite any existing values.
3728
+ * Exported only for tests.
3729
+ */
3730
+ function mergeAndOverwriteScopeData
3731
+
3732
+ (data, prop, mergeVal) {
3733
+ data[prop] = merge(data[prop], mergeVal, 1);
3734
+ }
3735
+
3736
+ /**
3737
+ * Get the scope data for the current scope after merging with the
3738
+ * global scope and isolation scope.
3739
+ *
3740
+ * @param currentScope - The current scope.
3741
+ * @returns The scope data.
3742
+ */
3743
+ function getCombinedScopeData(isolationScope, currentScope) {
3744
+ const scopeData = getGlobalScope().getScopeData();
3745
+ isolationScope && mergeScopeData(scopeData, isolationScope.getScopeData());
3746
+ currentScope && mergeScopeData(scopeData, currentScope.getScopeData());
3747
+ return scopeData;
3748
+ }
3749
+
3750
+ function applyDataToEvent(event, data) {
3751
+ const { extra, tags, user, contexts, level, transactionName } = data;
3752
+
3753
+ if (Object.keys(extra).length) {
3754
+ event.extra = { ...extra, ...event.extra };
3755
+ }
3756
+
3757
+ if (Object.keys(tags).length) {
3758
+ event.tags = { ...tags, ...event.tags };
3759
+ }
3760
+
3761
+ if (Object.keys(user).length) {
3762
+ event.user = { ...user, ...event.user };
3763
+ }
3764
+
3765
+ if (Object.keys(contexts).length) {
3766
+ event.contexts = { ...contexts, ...event.contexts };
3767
+ }
3768
+
3769
+ if (level) {
3770
+ event.level = level;
3771
+ }
3772
+
3773
+ // transaction events get their `transaction` from the root span name
3774
+ if (transactionName && event.type !== 'transaction') {
3775
+ event.transaction = transactionName;
3776
+ }
3777
+ }
3778
+
3779
+ function applyBreadcrumbsToEvent(event, breadcrumbs) {
3780
+ const mergedBreadcrumbs = [...(event.breadcrumbs || []), ...breadcrumbs];
3781
+ event.breadcrumbs = mergedBreadcrumbs.length ? mergedBreadcrumbs : undefined;
3782
+ }
3783
+
3784
+ function applySdkMetadataToEvent(event, sdkProcessingMetadata) {
3785
+ event.sdkProcessingMetadata = {
3786
+ ...event.sdkProcessingMetadata,
3787
+ ...sdkProcessingMetadata,
3788
+ };
3789
+ }
3790
+
3791
+ function applySpanToEvent(event, span) {
3792
+ event.contexts = {
3793
+ trace: spanToTraceContext(span),
3794
+ ...event.contexts,
3795
+ };
3796
+
3797
+ event.sdkProcessingMetadata = {
3798
+ dynamicSamplingContext: getDynamicSamplingContextFromSpan(span),
3799
+ ...event.sdkProcessingMetadata,
3800
+ };
3801
+
3802
+ const rootSpan = getRootSpan(span);
3803
+ const transactionName = spanToJSON(rootSpan).description;
3804
+ if (transactionName && !event.transaction && event.type === 'transaction') {
3805
+ event.transaction = transactionName;
3806
+ }
3807
+ }
3808
+
3809
+ /**
3810
+ * Applies fingerprint from the scope to the event if there's one,
3811
+ * uses message if there's one instead or get rid of empty fingerprint
3812
+ */
3813
+ function applyFingerprintToEvent(event, fingerprint) {
3814
+ // Make sure it's an array first and we actually have something in place
3815
+ event.fingerprint = event.fingerprint
3816
+ ? Array.isArray(event.fingerprint)
3817
+ ? event.fingerprint
3818
+ : [event.fingerprint]
3819
+ : [];
3820
+
3821
+ // If we have something on the scope, then merge it with event
3822
+ if (fingerprint) {
3823
+ event.fingerprint = event.fingerprint.concat(fingerprint);
3824
+ }
3825
+
3826
+ // If we have no data at all, remove empty array default
3827
+ if (!event.fingerprint.length) {
3828
+ delete event.fingerprint;
3829
+ }
3830
+ }
3831
+
3832
+ /**
3833
+ * This type makes sure that we get either a CaptureContext, OR an EventHint.
3834
+ * It does not allow mixing them, which could lead to unexpected outcomes, e.g. this is disallowed:
3835
+ * { user: { id: '123' }, mechanism: { handled: false } }
3836
+ */
3837
+
3838
+ /**
3839
+ * Adds common information to events.
3840
+ *
3841
+ * The information includes release and environment from `options`,
3842
+ * breadcrumbs and context (extra, tags and user) from the scope.
3843
+ *
3844
+ * Information that is already present in the event is never overwritten. For
3845
+ * nested objects, such as the context, keys are merged.
3846
+ *
3847
+ * @param event The original event.
3848
+ * @param hint May contain additional information about the original exception.
3849
+ * @param scope A scope containing event metadata.
3850
+ * @returns A new event with more information.
3851
+ * @hidden
3852
+ */
3853
+ function prepareEvent(
3854
+ options,
3855
+ event,
3856
+ hint,
3857
+ scope,
3858
+ client,
3859
+ isolationScope,
3860
+ ) {
3861
+ const { normalizeDepth = 3, normalizeMaxBreadth = 1000 } = options;
3862
+ const prepared = {
3863
+ ...event,
3864
+ event_id: event.event_id || hint.event_id || uuid4(),
3865
+ timestamp: event.timestamp || dateTimestampInSeconds(),
3866
+ };
3867
+ const integrations = hint.integrations || options.integrations.map(i => i.name);
3868
+
3869
+ applyClientOptions(prepared, options);
3870
+ applyIntegrationsMetadata(prepared, integrations);
3871
+
3872
+ if (client) {
3873
+ client.emit('applyFrameMetadata', event);
3874
+ }
3875
+
3876
+ // Only put debug IDs onto frames for error events.
3877
+ if (event.type === undefined) {
3878
+ applyDebugIds(prepared, options.stackParser);
3879
+ }
3880
+
3881
+ // If we have scope given to us, use it as the base for further modifications.
3882
+ // This allows us to prevent unnecessary copying of data if `captureContext` is not provided.
3883
+ const finalScope = getFinalScope(scope, hint.captureContext);
3884
+
3885
+ if (hint.mechanism) {
3886
+ addExceptionMechanism(prepared, hint.mechanism);
3887
+ }
3888
+
3889
+ const clientEventProcessors = client ? client.getEventProcessors() : [];
3890
+
3891
+ // This should be the last thing called, since we want that
3892
+ // {@link Scope.addEventProcessor} gets the finished prepared event.
3893
+ // Merge scope data together
3894
+ const data = getCombinedScopeData(isolationScope, finalScope);
3895
+
3896
+ const attachments = [...(hint.attachments || []), ...data.attachments];
3897
+ if (attachments.length) {
3898
+ hint.attachments = attachments;
3899
+ }
3900
+
3901
+ applyScopeDataToEvent(prepared, data);
3902
+
3903
+ const eventProcessors = [
3904
+ ...clientEventProcessors,
3905
+ // Run scope event processors _after_ all other processors
3906
+ ...data.eventProcessors,
3907
+ ];
3908
+
3909
+ const result = notifyEventProcessors(eventProcessors, prepared, hint);
3910
+
3911
+ return result.then(evt => {
3912
+ if (evt) {
3913
+ // We apply the debug_meta field only after all event processors have ran, so that if any event processors modified
3914
+ // file names (e.g.the RewriteFrames integration) the filename -> debug ID relationship isn't destroyed.
3915
+ // This should not cause any PII issues, since we're only moving data that is already on the event and not adding
3916
+ // any new data
3917
+ applyDebugMeta(evt);
3918
+ }
3919
+
3920
+ if (typeof normalizeDepth === 'number' && normalizeDepth > 0) {
3921
+ return normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth);
3922
+ }
3923
+ return evt;
3924
+ });
3925
+ }
3926
+
3927
+ /**
3928
+ * Enhances event using the client configuration.
3929
+ * It takes care of all "static" values like environment, release and `dist`,
3930
+ * as well as truncating overly long values.
3931
+ *
3932
+ * Only exported for tests.
3933
+ *
3934
+ * @param event event instance to be enhanced
3935
+ */
3936
+ function applyClientOptions(event, options) {
3937
+ const { environment, release, dist, maxValueLength } = options;
3938
+
3939
+ // empty strings do not make sense for environment, release, and dist
3940
+ // so we handle them the same as if they were not provided
3941
+ event.environment = event.environment || environment || DEFAULT_ENVIRONMENT;
3942
+
3943
+ if (!event.release && release) {
3944
+ event.release = release;
3945
+ }
3946
+
3947
+ if (!event.dist && dist) {
3948
+ event.dist = dist;
3949
+ }
3950
+
3951
+ const request = event.request;
3952
+ if (request?.url && maxValueLength) {
3953
+ request.url = truncate(request.url, maxValueLength);
3954
+ }
3955
+
3956
+ if (maxValueLength) {
3957
+ event.exception?.values?.forEach(exception => {
3958
+ if (exception.value) {
3959
+ // Truncates error messages
3960
+ exception.value = truncate(exception.value, maxValueLength);
3961
+ }
3962
+ });
3963
+ }
3964
+ }
3965
+
3966
+ /**
3967
+ * Puts debug IDs into the stack frames of an error event.
3968
+ */
3969
+ function applyDebugIds(event, stackParser) {
3970
+ // Build a map of filename -> debug_id
3971
+ const filenameDebugIdMap = getFilenameToDebugIdMap(stackParser);
3972
+
3973
+ event.exception?.values?.forEach(exception => {
3974
+ exception.stacktrace?.frames?.forEach(frame => {
3975
+ if (frame.filename) {
3976
+ frame.debug_id = filenameDebugIdMap[frame.filename];
3977
+ }
3978
+ });
3979
+ });
3980
+ }
3981
+
3982
+ /**
3983
+ * Moves debug IDs from the stack frames of an error event into the debug_meta field.
3984
+ */
3985
+ function applyDebugMeta(event) {
3986
+ // Extract debug IDs and filenames from the stack frames on the event.
3987
+ const filenameDebugIdMap = {};
3988
+ event.exception?.values?.forEach(exception => {
3989
+ exception.stacktrace?.frames?.forEach(frame => {
3990
+ if (frame.debug_id) {
3991
+ if (frame.abs_path) {
3992
+ filenameDebugIdMap[frame.abs_path] = frame.debug_id;
3993
+ } else if (frame.filename) {
3994
+ filenameDebugIdMap[frame.filename] = frame.debug_id;
3995
+ }
3996
+ delete frame.debug_id;
3997
+ }
3998
+ });
3999
+ });
4000
+
4001
+ if (Object.keys(filenameDebugIdMap).length === 0) {
4002
+ return;
4003
+ }
4004
+
4005
+ // Fill debug_meta information
4006
+ event.debug_meta = event.debug_meta || {};
4007
+ event.debug_meta.images = event.debug_meta.images || [];
4008
+ const images = event.debug_meta.images;
4009
+ Object.entries(filenameDebugIdMap).forEach(([filename, debug_id]) => {
4010
+ images.push({
4011
+ type: 'sourcemap',
4012
+ code_file: filename,
4013
+ debug_id,
4014
+ });
4015
+ });
4016
+ }
4017
+
4018
+ /**
4019
+ * This function adds all used integrations to the SDK info in the event.
4020
+ * @param event The event that will be filled with all integrations.
4021
+ */
4022
+ function applyIntegrationsMetadata(event, integrationNames) {
4023
+ if (integrationNames.length > 0) {
4024
+ event.sdk = event.sdk || {};
4025
+ event.sdk.integrations = [...(event.sdk.integrations || []), ...integrationNames];
4026
+ }
4027
+ }
4028
+
4029
+ /**
4030
+ * Applies `normalize` function on necessary `Event` attributes to make them safe for serialization.
4031
+ * Normalized keys:
4032
+ * - `breadcrumbs.data`
4033
+ * - `user`
4034
+ * - `contexts`
4035
+ * - `extra`
4036
+ * @param event Event
4037
+ * @returns Normalized event
4038
+ */
4039
+ function normalizeEvent(event, depth, maxBreadth) {
4040
+ if (!event) {
4041
+ return null;
4042
+ }
4043
+
4044
+ const normalized = {
4045
+ ...event,
4046
+ ...(event.breadcrumbs && {
4047
+ breadcrumbs: event.breadcrumbs.map(b => ({
4048
+ ...b,
4049
+ ...(b.data && {
4050
+ data: normalize(b.data, depth, maxBreadth),
4051
+ }),
4052
+ })),
4053
+ }),
4054
+ ...(event.user && {
4055
+ user: normalize(event.user, depth, maxBreadth),
4056
+ }),
4057
+ ...(event.contexts && {
4058
+ contexts: normalize(event.contexts, depth, maxBreadth),
4059
+ }),
4060
+ ...(event.extra && {
4061
+ extra: normalize(event.extra, depth, maxBreadth),
4062
+ }),
4063
+ };
4064
+
4065
+ // event.contexts.trace stores information about a Transaction. Similarly,
4066
+ // event.spans[] stores information about child Spans. Given that a
4067
+ // Transaction is conceptually a Span, normalization should apply to both
4068
+ // Transactions and Spans consistently.
4069
+ // For now the decision is to skip normalization of Transactions and Spans,
4070
+ // so this block overwrites the normalized event to add back the original
4071
+ // Transaction information prior to normalization.
4072
+ if (event.contexts?.trace && normalized.contexts) {
4073
+ normalized.contexts.trace = event.contexts.trace;
4074
+
4075
+ // event.contexts.trace.data may contain circular/dangerous data so we need to normalize it
4076
+ if (event.contexts.trace.data) {
4077
+ normalized.contexts.trace.data = normalize(event.contexts.trace.data, depth, maxBreadth);
4078
+ }
4079
+ }
4080
+
4081
+ // event.spans[].data may contain circular/dangerous data so we need to normalize it
4082
+ if (event.spans) {
4083
+ normalized.spans = event.spans.map(span => {
4084
+ return {
4085
+ ...span,
4086
+ ...(span.data && {
4087
+ data: normalize(span.data, depth, maxBreadth),
4088
+ }),
4089
+ };
4090
+ });
4091
+ }
4092
+
4093
+ // event.contexts.flags (FeatureFlagContext) stores context for our feature
4094
+ // flag integrations. It has a greater nesting depth than our other typed
4095
+ // Contexts, so we re-normalize with a fixed depth of 3 here. We do not want
4096
+ // to skip this in case of conflicting, user-provided context.
4097
+ if (event.contexts?.flags && normalized.contexts) {
4098
+ normalized.contexts.flags = normalize(event.contexts.flags, 3, maxBreadth);
4099
+ }
4100
+
4101
+ return normalized;
4102
+ }
4103
+
4104
+ function getFinalScope(scope, captureContext) {
4105
+ if (!captureContext) {
4106
+ return scope;
4107
+ }
4108
+
4109
+ const finalScope = scope ? scope.clone() : new Scope();
4110
+ finalScope.update(captureContext);
4111
+ return finalScope;
4112
+ }
4113
+
4114
+ /**
4115
+ * Parse either an `EventHint` directly, or convert a `CaptureContext` to an `EventHint`.
4116
+ * This is used to allow to update method signatures that used to accept a `CaptureContext` but should now accept an `EventHint`.
4117
+ */
4118
+ function parseEventHintOrCaptureContext(
4119
+ hint,
4120
+ ) {
4121
+ if (!hint) {
4122
+ return undefined;
4123
+ }
4124
+
4125
+ // If you pass a Scope or `() => Scope` as CaptureContext, we just return this as captureContext
4126
+ if (hintIsScopeOrFunction(hint)) {
4127
+ return { captureContext: hint };
4128
+ }
4129
+
4130
+ if (hintIsScopeContext(hint)) {
4131
+ return {
4132
+ captureContext: hint,
4133
+ };
4134
+ }
4135
+
4136
+ return hint;
4137
+ }
4138
+
4139
+ function hintIsScopeOrFunction(hint) {
4140
+ return hint instanceof Scope || typeof hint === 'function';
4141
+ }
4142
+
4143
+ const captureContextKeys = [
4144
+ 'user',
4145
+ 'level',
4146
+ 'extra',
4147
+ 'contexts',
4148
+ 'tags',
4149
+ 'fingerprint',
4150
+ 'propagationContext',
4151
+ ] ;
4152
+
4153
+ function hintIsScopeContext(hint) {
4154
+ return Object.keys(hint).some(key => captureContextKeys.includes(key ));
4155
+ }
4156
+
4157
+ /**
4158
+ * Captures an exception event and sends it to Sentry.
4159
+ *
4160
+ * @param exception The exception to capture.
4161
+ * @param hint Optional additional data to attach to the Sentry event.
4162
+ * @returns the id of the captured Sentry event.
4163
+ */
4164
+ function captureException(exception, hint) {
4165
+ return getCurrentScope().captureException(exception, parseEventHintOrCaptureContext(hint));
4166
+ }
4167
+
4168
+ /**
4169
+ * Captures a manually created event and sends it to Sentry.
4170
+ *
4171
+ * @param event The event to send to Sentry.
4172
+ * @param hint Optional additional data to attach to the Sentry event.
4173
+ * @returns the id of the captured event.
4174
+ */
4175
+ function captureEvent(event, hint) {
4176
+ return getCurrentScope().captureEvent(event, hint);
4177
+ }
4178
+
4179
+ /**
4180
+ * Start a session on the current isolation scope.
4181
+ *
4182
+ * @param context (optional) additional properties to be applied to the returned session object
4183
+ *
4184
+ * @returns the new active session
4185
+ */
4186
+ function startSession(context) {
4187
+ const isolationScope = getIsolationScope();
4188
+ const currentScope = getCurrentScope();
4189
+
4190
+ // Will fetch userAgent if called from browser sdk
4191
+ const { userAgent } = GLOBAL_OBJ.navigator || {};
4192
+
4193
+ const session = makeSession({
4194
+ user: currentScope.getUser() || isolationScope.getUser(),
4195
+ ...(userAgent && { userAgent }),
4196
+ ...context,
4197
+ });
4198
+
4199
+ // End existing session if there's one
4200
+ const currentSession = isolationScope.getSession();
4201
+ if (currentSession?.status === 'ok') {
4202
+ updateSession(currentSession, { status: 'exited' });
4203
+ }
4204
+
4205
+ endSession();
4206
+
4207
+ // Afterwards we set the new session on the scope
4208
+ isolationScope.setSession(session);
4209
+
4210
+ return session;
4211
+ }
4212
+
4213
+ /**
4214
+ * End the session on the current isolation scope.
4215
+ */
4216
+ function endSession() {
4217
+ const isolationScope = getIsolationScope();
4218
+ const currentScope = getCurrentScope();
4219
+
4220
+ const session = currentScope.getSession() || isolationScope.getSession();
4221
+ if (session) {
4222
+ closeSession(session);
4223
+ }
4224
+ _sendSessionUpdate();
4225
+
4226
+ // the session is over; take it off of the scope
4227
+ isolationScope.setSession();
4228
+ }
4229
+
4230
+ /**
4231
+ * Sends the current Session on the scope
4232
+ */
4233
+ function _sendSessionUpdate() {
4234
+ const isolationScope = getIsolationScope();
4235
+ const client = getClient();
4236
+ const session = isolationScope.getSession();
4237
+ if (session && client) {
4238
+ client.captureSession(session);
4239
+ }
4240
+ }
4241
+
4242
+ /**
4243
+ * Sends the current session on the scope to Sentry
4244
+ *
4245
+ * @param end If set the session will be marked as exited and removed from the scope.
4246
+ * Defaults to `false`.
4247
+ */
4248
+ function captureSession(end = false) {
4249
+ // both send the update and pull the session from the scope
4250
+ if (end) {
4251
+ endSession();
4252
+ return;
4253
+ }
4254
+
4255
+ // only send the update
4256
+ _sendSessionUpdate();
4257
+ }
4258
+
4259
+ export { isErrorEvent as $, merge as A, isThenable as B, isPlainObject as C, DEBUG_BUILD as D, consoleSandbox as E, SDK_VERSION as F, GLOBAL_OBJ as G, getClient as H, getOriginalFunction as I, getEventDescription as J, stringMatchesSomePattern as K, isInstanceOf as L, CONSOLE_LEVELS as M, fill as N, originalConsoleMethods as O, getFramesFromEvent as P, timestampInSeconds as Q, isError as R, SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME as S, addNonEnumerableProperty as T, isRequest as U, getLocationHref as V, markFunctionWrapped as W, withScope as X, addExceptionTypeValue as Y, addExceptionMechanism as Z, captureException as _, dsnToString as a, isDOMError as a0, isDOMException as a1, isEvent as a2, normalizeToSize as a3, extractExceptionKeysForMessage as a4, isString as a5, createStackParser as a6, UNKNOWN_FUNCTION as a7, htmlTreeAsString as a8, safeJoin as a9, getComponentName as aa, startSession as ab, captureSession as ac, captureEvent as ad, stackParserFromStackParserOptions as ae, getSentryCarrier as b, getGlobalSingleton as c, debug as d, rejectedSyncPromise as e, dateTimestampInSeconds as f, getFunctionName as g, SEMANTIC_ATTRIBUTE_PROFILE_ID as h, isMatchingPattern as i, checkOrSetAlreadyCaught as j, updateSession as k, DEFAULT_ENVIRONMENT as l, makeDsn as m, normalize as n, getTraceContextFromScope as o, prepareEvent as p, getDynamicSamplingContextFromScope as q, resolvedSyncPromise as r, safeDateNow as s, getCurrentScope as t, uuid4 as u, getIsolationScope as v, safeMathRandom as w, isParameterizedString as x, isPrimitive as y, showSpanDropWarning as z };
4260
+ //# sourceMappingURL=exports.js.map
4261
+
4262
+ //# sourceMappingURL=exports.js.map