@swifty.js/sentry 0.0.4 → 0.0.6

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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -144
  3. package/dist/constants/index.cjs +1 -1
  4. package/dist/constants/index.js +1 -1
  5. package/dist/core/api.cjs +1 -1
  6. package/dist/core/api.d.ts +28 -9
  7. package/dist/core/api.js +1 -1
  8. package/dist/core/breadcrumb.cjs +1 -1
  9. package/dist/core/breadcrumb.js +1 -1
  10. package/dist/core/decorate-http.cjs +1 -1
  11. package/dist/core/decorate-http.js +1 -1
  12. package/dist/core/decorate-route.cjs +1 -1
  13. package/dist/core/decorate-route.js +1 -1
  14. package/dist/core/decorates.cjs +1 -1
  15. package/dist/core/decorates.js +1 -1
  16. package/dist/core/error-dedup.cjs +1 -0
  17. package/dist/core/error-dedup.js +1 -0
  18. package/dist/core/framework-error.cjs +1 -1
  19. package/dist/core/framework-error.js +1 -1
  20. package/dist/core/handle-code-error.cjs +1 -1
  21. package/dist/core/handle-code-error.js +1 -1
  22. package/dist/core/handle-error.cjs +1 -1
  23. package/dist/core/handle-error.js +1 -1
  24. package/dist/core/handle-events.cjs +1 -1
  25. package/dist/core/handle-events.js +1 -1
  26. package/dist/core/handle-route.cjs +1 -1
  27. package/dist/core/handle-route.js +1 -1
  28. package/dist/core/identity.cjs +1 -1
  29. package/dist/core/identity.js +1 -1
  30. package/dist/core/options-schema.cjs +1 -1
  31. package/dist/core/options-schema.d.ts +42 -45
  32. package/dist/core/options-schema.js +1 -1
  33. package/dist/core/pv-lifecycle.cjs +1 -1
  34. package/dist/core/pv-lifecycle.js +1 -1
  35. package/dist/core/sdk-lifecycle.cjs +1 -1
  36. package/dist/core/sdk-lifecycle.d.ts +1 -1
  37. package/dist/core/sdk-lifecycle.js +1 -1
  38. package/dist/core/setup.cjs +1 -1
  39. package/dist/core/setup.js +1 -1
  40. package/dist/core/white-screen.cjs +1 -1
  41. package/dist/core/white-screen.js +1 -1
  42. package/dist/index.cjs +1 -1
  43. package/dist/index.d.ts +4 -5
  44. package/dist/index.js +1 -1
  45. package/dist/node/dev-endpoint.cjs +1 -0
  46. package/dist/node/dev-endpoint.js +1 -0
  47. package/dist/package.json.cjs +1 -1
  48. package/dist/package.json.js +1 -1
  49. package/dist/plugins/exposure/index.cjs +1 -1
  50. package/dist/plugins/exposure/index.d.ts +0 -1
  51. package/dist/plugins/exposure/index.js +1 -1
  52. package/dist/plugins/performance/first-screen-paint.cjs +1 -1
  53. package/dist/plugins/performance/first-screen-paint.js +1 -1
  54. package/dist/plugins/performance/index.cjs +1 -1
  55. package/dist/plugins/performance/index.d.ts +0 -1
  56. package/dist/plugins/performance/index.js +1 -1
  57. package/dist/plugins/performance/navigation-timing.cjs +1 -1
  58. package/dist/plugins/performance/navigation-timing.js +1 -1
  59. package/dist/plugins/performance/perf.cjs +1 -1
  60. package/dist/plugins/performance/perf.js +1 -1
  61. package/dist/plugins/performance/resource-element-fallback.cjs +1 -1
  62. package/dist/plugins/performance/resource-element-fallback.js +1 -1
  63. package/dist/plugins/performance/resource-timing.cjs +1 -1
  64. package/dist/plugins/performance/resource-timing.js +1 -1
  65. package/dist/plugins/screen-record/index.cjs +1 -1
  66. package/dist/plugins/screen-record/index.js +1 -1
  67. package/dist/plugins/screen-record/recorder.cjs +1 -1
  68. package/dist/plugins/screen-record/recorder.d.ts +1 -1
  69. package/dist/plugins/screen-record/recorder.js +1 -1
  70. package/dist/react.cjs +1 -1
  71. package/dist/react.d.ts +7 -80
  72. package/dist/react.js +1 -1
  73. package/dist/reporter/index.cjs +1 -1
  74. package/dist/reporter/index.js +1 -1
  75. package/dist/reporter/network-listener.cjs +1 -1
  76. package/dist/reporter/network-listener.js +1 -1
  77. package/dist/reporter/offline-cache.cjs +1 -1
  78. package/dist/reporter/offline-cache.js +1 -1
  79. package/dist/reporter/report-data-schema.cjs +1 -1
  80. package/dist/reporter/report-data-schema.js +1 -1
  81. package/dist/reporter/report-data.cjs +1 -1
  82. package/dist/reporter/report-data.js +1 -1
  83. package/dist/reporter/server-recovery.cjs +1 -1
  84. package/dist/reporter/server-recovery.js +1 -1
  85. package/dist/reporter/transports.cjs +1 -1
  86. package/dist/reporter/transports.js +1 -1
  87. package/dist/source-map/source-map.cjs +1 -0
  88. package/dist/source-map/source-map.js +1 -0
  89. package/dist/source-map/vite.cjs +1 -0
  90. package/dist/source-map/vite.js +1 -0
  91. package/dist/source-map/webpack.cjs +1 -0
  92. package/dist/source-map/webpack.js +1 -0
  93. package/dist/types/common.d.ts +10 -11
  94. package/dist/types/enums.cjs +1 -1
  95. package/dist/types/enums.d.ts +1 -45
  96. package/dist/types/enums.js +1 -1
  97. package/dist/types/options.d.ts +9 -13
  98. package/dist/types/plugin.cjs +1 -1
  99. package/dist/types/plugin.d.ts +0 -3
  100. package/dist/types/plugin.js +1 -1
  101. package/dist/utils/click-data.cjs +1 -1
  102. package/dist/utils/click-data.js +1 -1
  103. package/dist/utils/data-structures.cjs +1 -1
  104. package/dist/utils/data-structures.js +1 -1
  105. package/dist/utils/dom2str.cjs +1 -0
  106. package/dist/utils/dom2str.js +1 -0
  107. package/dist/utils/get-base-data.cjs +1 -1
  108. package/dist/utils/get-base-data.js +1 -1
  109. package/dist/utils/logger.cjs +1 -1
  110. package/dist/utils/logger.js +1 -1
  111. package/dist/utils/noop.cjs +1 -0
  112. package/dist/utils/noop.js +1 -0
  113. package/dist/utils/sentry.cjs +1 -1
  114. package/dist/utils/sentry.js +1 -1
  115. package/dist/utils/session.cjs +1 -1
  116. package/dist/utils/session.js +1 -1
  117. package/dist/utils/throttle.cjs +1 -1
  118. package/dist/utils/throttle.js +1 -1
  119. package/dist/utils/transform-http-data.cjs +1 -1
  120. package/dist/utils/transform-http-data.js +1 -1
  121. package/dist/utils/uuid.cjs +1 -0
  122. package/dist/utils/uuid.js +1 -0
  123. package/dist/vite.cjs +1 -1
  124. package/dist/vite.d.ts +2 -2
  125. package/dist/vite.js +1 -1
  126. package/dist/vue.cjs +1 -1
  127. package/dist/vue.js +1 -1
  128. package/dist/webpack.cjs +1 -1
  129. package/dist/webpack.js +1 -1
  130. package/package.json +22 -26
  131. package/dist/core/ip.cjs +0 -1
  132. package/dist/core/ip.d.ts +0 -24
  133. package/dist/core/ip.js +0 -1
  134. package/dist/reporter/batch.cjs +0 -1
  135. package/dist/reporter/batch.js +0 -1
  136. package/dist/sourcemap/sourcemap.cjs +0 -1
  137. package/dist/sourcemap/sourcemap.js +0 -1
  138. package/dist/sourcemap/vite.cjs +0 -1
  139. package/dist/sourcemap/vite.js +0 -1
  140. package/dist/sourcemap/webpack.cjs +0 -1
  141. package/dist/sourcemap/webpack.js +0 -1
  142. package/dist/utils/base64.cjs +0 -1
  143. package/dist/utils/base64.js +0 -1
@@ -24,7 +24,6 @@ import { SentryPlugin } from '../../types/plugin.js';
24
24
 
25
25
  declare class PerformancePlugin extends SentryPlugin {
26
26
  private cleanups;
27
- constructor();
28
27
  init(): void;
29
28
  destroy(): void;
30
29
  private report;
@@ -1 +1 @@
1
- import{EventType as e}from"../../types/enums.js";import{SentryPlugin as r}from"../../types/plugin.js";import s from"../../reporter/index.js";import"../../constants/index.js";import t from"../../utils/get-base-data.js";import"../../utils/sentry.js";import"../../utils/is-type.js";import{getNavigationTimingData as o}from"./navigation-timing.js";import{getWebVitals as i}from"./perf.js";import{supportsPerformanceEntryType as n}from"./performance-observer-support.js";import{observeResourceElementFallback as a}from"./resource-element-fallback.js";import{observeResourceTimings as p,getInitialResourceListData as m}from"./resource-timing.js";function c(){}class l extends r{cleanups=[];constructor(){super(e.Performance)}init(){this.startWebVitals(),this.cleanups.push(this.observeLongTasks()),this.cleanups.push(p(e=>this.report(e))),this.cleanups.push(a(e=>this.report(e))),this.cleanups.push(this.onPageReady(()=>{this.reportPageLoadTimings()})),this.reportMemory()}destroy(){this.cleanups.toReversed().forEach(e=>{e()}),this.cleanups=[]}report(e){s.send(e)}startWebVitals(){try{i(e=>{this.report(e)})}catch{return}}observeLongTasks(){if(!n("longtask"))return c;const r=new globalThis.PerformanceObserver(r=>{const s={...t(),name:"LongTask",type:e.Performance,longTasks:r.getEntries()};this.report(s)});return r.observe({entryTypes:["longtask"]}),()=>{r.disconnect()}}onPageReady(e){if("complete"===document.readyState)return queueMicrotask(e),c;const r=()=>{e()};return globalThis.addEventListener("load",r,{once:!0}),()=>{globalThis.removeEventListener("load",r)}}reportPageLoadTimings(){const e=o();e&&this.report(e);const r=m();r&&this.report(r)}async reportMemory(){if("performance"in globalThis&&"measureUserAgentSpecificMemory"in globalThis.performance&&"function"==typeof globalThis.performance.measureUserAgentSpecificMemory){const r={...t(),name:"Memory",type:e.Performance,message:"performance.measureUserAgentSpecificMemory",memory:await globalThis.performance.measureUserAgentSpecificMemory()};this.report(r)}}}export{l as default};
1
+ import{EventType as e}from"../../types/enums.js";import{SentryPlugin as r}from"../../types/plugin.js";import s from"../../reporter/index.js";import"../../constants/index.js";import t from"../../utils/get-base-data.js";import"../../utils/sentry.js";import"../../utils/is-type.js";import{noop as o}from"../../utils/noop.js";import"../../utils/logger.js";import{getNavigationTimingData as i}from"./navigation-timing.js";import{getWebVitals as n}from"./perf.js";import{supportsPerformanceEntryType as a}from"./performance-observer-support.js";import{observeResourceElementFallback as p}from"./resource-element-fallback.js";import{observeResourceTimings as m,getInitialResourceListData as c}from"./resource-timing.js";class l extends r{cleanups=[];init(){this.cleanups.push(this.startWebVitals()),this.cleanups.push(this.observeLongTasks()),this.cleanups.push(m(e=>this.report(e))),this.cleanups.push(p(e=>this.report(e))),this.cleanups.push(this.onPageReady(()=>{this.reportPageLoadTimings()})),this.reportMemory()}destroy(){this.cleanups.toReversed().forEach(e=>{e()}),this.cleanups=[]}report(e){s.send(e)}startWebVitals(){try{return n(e=>{this.report(e)})}catch{return o}}observeLongTasks(){if(!a("longtask"))return o;const r=new globalThis.PerformanceObserver(r=>{const s={...t(),name:"LongTask",type:e.Performance,longTasks:r.getEntries()};this.report(s)});return r.observe({entryTypes:["longtask"]}),()=>{r.disconnect()}}onPageReady(e){if("complete"===document.readyState)return queueMicrotask(e),o;const r=()=>{e()};return globalThis.addEventListener("load",r,{once:!0}),()=>{globalThis.removeEventListener("load",r)}}reportPageLoadTimings(){const e=i();e&&this.report(e),this.report(c())}async reportMemory(){if("performance"in globalThis&&"measureUserAgentSpecificMemory"in globalThis.performance&&"function"==typeof globalThis.performance.measureUserAgentSpecificMemory){const r={...t(),name:"Memory",type:e.Performance,message:"performance.measureUserAgentSpecificMemory",memory:await globalThis.performance.measureUserAgentSpecificMemory()};this.report(r)}}}export{l as default};
@@ -1 +1 @@
1
- "use strict";var t=require("../../types/enums.cjs");require("../../constants/index.cjs");var e=require("../../utils/get-base-data.cjs");function n(t,e){return Math.max(0,Math.round(t-e))}function r(t,e){const r=t.fetchStart;return{paintTime:e>0?n(e,r):0,domInteractive:n(t.domInteractive,r),domContentLoaded:n(t.domContentLoadedEventEnd,r),loadEvent:n(t.loadEventStart,r),firstByte:n(t.responseStart,r),dnsLookup:n(t.domainLookupEnd,t.domainLookupStart),tcpConnection:n(t.connectEnd,t.connectStart),tlsHandshake:n(t.connectEnd,t.secureConnectionStart),timeToFirstByte:n(t.responseStart,t.requestStart),contentTransfer:n(t.responseEnd,t.responseStart),domProcessing:n(t.domInteractive,t.responseEnd),resourceLoad:n(t.loadEventStart,t.domContentLoadedEventEnd),redirect:n(t.redirectEnd,t.redirectStart),unloadTime:n(t.unloadEventEnd,t.unloadEventStart),triggerPageUrl:location.href}}require("../../utils/sentry.cjs"),require("../../utils/is-type.cjs"),exports.getNavigationTimingData=function(){if(!("performance"in globalThis)||"function"!=typeof globalThis.performance.getEntriesByType)return null;const n=function(){const t=globalThis.performance.getEntriesByType("navigation")[0];return t&&function(t){return"navigation"===t.entryType&&"fetchStart"in t}(t)?t:null}();return n?{...e.default(),type:t.EventType.Performance,name:"NavigationTiming",message:"Page navigation timing",status:t.Status.OK,extra:r(n,globalThis.performance.getEntriesByType("paint").at(-1)?.startTime??0)}:null};
1
+ "use strict";var t=require("../../types/enums.cjs");require("../../constants/index.cjs");var e=require("../../utils/get-base-data.cjs");function n(t,e){return Math.max(0,Math.round(t-e))}function r(t,e){const r=t.fetchStart;return{paintTime:e>0?n(e,r):0,domInteractive:n(t.domInteractive,r),domContentLoaded:n(t.domContentLoadedEventEnd,r),loadEvent:n(t.loadEventStart,r),firstByte:n(t.responseStart,r),dnsLookup:n(t.domainLookupEnd,t.domainLookupStart),tcpConnection:n(t.connectEnd,t.connectStart),tlsHandshake:n(t.connectEnd,t.secureConnectionStart),timeToFirstByte:n(t.responseStart,t.requestStart),contentTransfer:n(t.responseEnd,t.responseStart),domProcessing:n(t.domInteractive,t.responseEnd),resourceLoad:n(t.loadEventStart,t.domContentLoadedEventEnd),redirect:n(t.redirectEnd,t.redirectStart),unloadTime:n(t.unloadEventEnd,t.unloadEventStart),triggerPageUrl:location.href}}require("../../utils/sentry.cjs"),require("../../utils/is-type.cjs"),require("../../utils/logger.cjs"),exports.getNavigationTimingData=function(){if(!("performance"in globalThis)||"function"!=typeof globalThis.performance.getEntriesByType)return null;const n=function(){const t=globalThis.performance.getEntriesByType("navigation")[0];return t&&function(t){return"navigation"===t.entryType&&"fetchStart"in t}(t)?t:null}();return n?{...e.default(),type:t.EventType.Performance,name:"NavigationTiming",message:"Page navigation timing",status:t.Status.OK,extra:r(n,globalThis.performance.getEntriesByType("paint").at(-1)?.startTime??0)}:null};
@@ -1 +1 @@
1
- import{Status as t,EventType as n}from"../../types/enums.js";import"../../constants/index.js";import e from"../../utils/get-base-data.js";import"../../utils/sentry.js";import"../../utils/is-type.js";function o(t,n){return Math.max(0,Math.round(t-n))}function r(t,n){const e=t.fetchStart;return{paintTime:n>0?o(n,e):0,domInteractive:o(t.domInteractive,e),domContentLoaded:o(t.domContentLoadedEventEnd,e),loadEvent:o(t.loadEventStart,e),firstByte:o(t.responseStart,e),dnsLookup:o(t.domainLookupEnd,t.domainLookupStart),tcpConnection:o(t.connectEnd,t.connectStart),tlsHandshake:o(t.connectEnd,t.secureConnectionStart),timeToFirstByte:o(t.responseStart,t.requestStart),contentTransfer:o(t.responseEnd,t.responseStart),domProcessing:o(t.domInteractive,t.responseEnd),resourceLoad:o(t.loadEventStart,t.domContentLoadedEventEnd),redirect:o(t.redirectEnd,t.redirectStart),unloadTime:o(t.unloadEventEnd,t.unloadEventStart),triggerPageUrl:location.href}}function a(){if(!("performance"in globalThis)||"function"!=typeof globalThis.performance.getEntriesByType)return null;const o=function(){const t=globalThis.performance.getEntriesByType("navigation")[0];return t&&function(t){return"navigation"===t.entryType&&"fetchStart"in t}(t)?t:null}();return o?{...e(),type:n.Performance,name:"NavigationTiming",message:"Page navigation timing",status:t.OK,extra:r(o,globalThis.performance.getEntriesByType("paint").at(-1)?.startTime??0)}:null}export{a as getNavigationTimingData};
1
+ import{Status as t,EventType as n}from"../../types/enums.js";import"../../constants/index.js";import e from"../../utils/get-base-data.js";import"../../utils/sentry.js";import"../../utils/is-type.js";import"../../utils/logger.js";function o(t,n){return Math.max(0,Math.round(t-n))}function r(t,n){const e=t.fetchStart;return{paintTime:n>0?o(n,e):0,domInteractive:o(t.domInteractive,e),domContentLoaded:o(t.domContentLoadedEventEnd,e),loadEvent:o(t.loadEventStart,e),firstByte:o(t.responseStart,e),dnsLookup:o(t.domainLookupEnd,t.domainLookupStart),tcpConnection:o(t.connectEnd,t.connectStart),tlsHandshake:o(t.connectEnd,t.secureConnectionStart),timeToFirstByte:o(t.responseStart,t.requestStart),contentTransfer:o(t.responseEnd,t.responseStart),domProcessing:o(t.domInteractive,t.responseEnd),resourceLoad:o(t.loadEventStart,t.domContentLoadedEventEnd),redirect:o(t.redirectEnd,t.redirectStart),unloadTime:o(t.unloadEventEnd,t.unloadEventStart),triggerPageUrl:location.href}}function a(){if(!("performance"in globalThis)||"function"!=typeof globalThis.performance.getEntriesByType)return null;const o=function(){const t=globalThis.performance.getEntriesByType("navigation")[0];return t&&function(t){return"navigation"===t.entryType&&"fetchStart"in t}(t)?t:null}();return o?{...e(),type:n.Performance,name:"NavigationTiming",message:"Page navigation timing",status:t.OK,extra:r(o,globalThis.performance.getEntriesByType("paint").at(-1)?.startTime??0)}:null}export{a as getNavigationTimingData};
@@ -1 +1 @@
1
- "use strict";var e=require("../../types/enums.cjs"),t=require("web-vitals");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs");require("../../utils/sentry.cjs"),require("../../utils/is-type.cjs");var s=require("../../utils/metric2perf-data.cjs"),i=require("../../utils/logger.cjs"),n=require("./first-screen-paint.cjs");exports.getWebVitals=function(u){i.sentryLogger.info("Starting web vitals monitoring...");const a=e=>{i.sentryLogger.success(`Metric: ${e.name}`,e,function(e){if("value"in e&&"number"==typeof e.value)return Math.round(e.value)}(e)),u(e)};t.onLCP(e=>{a(s.default(e))}),t.onFCP(e=>{a(s.default(e))}),t.onCLS(e=>{a(s.default(e))}),t.onINP(e=>{a(s.default(e))}),t.onTTFB(e=>{a(s.default(e))}),n.getFirstScreenPaint(t=>{const s={...r.default(),name:"FSP",value:t,type:e.EventType.Performance,message:"First screen paint"};a(s)})};
1
+ "use strict";var e=require("../../types/enums.cjs"),t=require("web-vitals");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs");require("../../utils/sentry.cjs"),require("../../utils/is-type.cjs");var s=require("../../utils/metric2perf-data.cjs"),n=require("../../utils/logger.cjs"),i=require("./first-screen-paint.cjs");exports.getWebVitals=function(u){n.sentryLogger.info("Starting web vitals monitoring...");const a=e=>{n.sentryLogger.success(`Metric: ${e.name}`,e,function(e){if("value"in e&&"number"==typeof e.value)return Math.round(e.value)}(e)),u(e)};return t.onLCP(e=>{a(s.default(e))}),t.onFCP(e=>{a(s.default(e))}),t.onCLS(e=>{a(s.default(e))}),t.onINP(e=>{a(s.default(e))}),t.onTTFB(e=>{a(s.default(e))}),i.getFirstScreenPaint(t=>{const s={...r.default(),name:"FSP",value:t,type:e.EventType.Performance,message:"First screen paint"};a(s)})};
@@ -1 +1 @@
1
- import{EventType as t}from"../../types/enums.js";import{onLCP as e,onFCP as r,onCLS as s,onINP as i,onTTFB as o}from"web-vitals";import"../../constants/index.js";import n from"../../utils/get-base-data.js";import"../../utils/sentry.js";import"../../utils/is-type.js";import m from"../../utils/metric2perf-data.js";import{sentryLogger as a}from"../../utils/logger.js";import{getFirstScreenPaint as p}from"./first-screen-paint.js";function u(u){a.info("Starting web vitals monitoring...");const f=t=>{a.success(`Metric: ${t.name}`,t,function(t){if("value"in t&&"number"==typeof t.value)return Math.round(t.value)}(t)),u(t)};e(t=>{f(m(t))}),r(t=>{f(m(t))}),s(t=>{f(m(t))}),i(t=>{f(m(t))}),o(t=>{f(m(t))}),p(e=>{const r={...n(),name:"FSP",value:e,type:t.Performance,message:"First screen paint"};f(r)})}export{u as getWebVitals};
1
+ import{EventType as t}from"../../types/enums.js";import{onLCP as r,onFCP as e,onCLS as s,onINP as i,onTTFB as o}from"web-vitals";import"../../constants/index.js";import n from"../../utils/get-base-data.js";import"../../utils/sentry.js";import"../../utils/is-type.js";import m from"../../utils/metric2perf-data.js";import{sentryLogger as a}from"../../utils/logger.js";import{getFirstScreenPaint as p}from"./first-screen-paint.js";function u(u){a.info("Starting web vitals monitoring...");const f=t=>{a.success(`Metric: ${t.name}`,t,function(t){if("value"in t&&"number"==typeof t.value)return Math.round(t.value)}(t)),u(t)};return r(t=>{f(m(t))}),e(t=>{f(m(t))}),s(t=>{f(m(t))}),i(t=>{f(m(t))}),o(t=>{f(m(t))}),p(r=>{const e={...n(),name:"FSP",value:r,type:t.Performance,message:"First screen paint"};f(e)})}export{u as getWebVitals};
@@ -1 +1 @@
1
- "use strict";require("../../constants/index.cjs"),require("../../types/enums.cjs");var e=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs");var r=require("./resource-timing.cjs"),n=require("./performance-observer-support.cjs");const t=new Set(["IMG","SCRIPT","LINK"]);exports.observeResourceElementFallback=function(s){if(n.supportsPerformanceEntryType("resource")||!("MutationObserver"in globalThis)||"function"!=typeof globalThis.MutationObserver)return()=>{};const o=[],i=new Set,a=n=>{const t=function(e){return e instanceof HTMLImageElement?e.currentSrc||e.src:e instanceof HTMLScriptElement?e.src:e.href}(n);if(!t||i.has(t)||t.includes(e.default.options.dsn))return;i.add(t);const o=function(e){return r.getResourceList().filter(r=>r.name===e).at(-1)??null}(t)??function(e,r){const n="performance"in globalThis?Math.round(globalThis.performance.now()):Date.now();return{name:e,initiatorType:r,startTime:n,responseEnd:n,duration:0,transferSize:0,encodedBodySize:0,decodedBodySize:0,fromCache:!1}}(t,n.tagName.toLowerCase());s(r.createResourceTimingData(o))},c=new globalThis.MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{(function(e){return e instanceof HTMLElement&&t.has(e.tagName)})(e)&&(e=>{const r=()=>{a(e)};e.addEventListener("load",r,{once:!0}),e.addEventListener("error",r,{once:!0}),o.push({element:e,eventName:"load",listener:r}),o.push({element:e,eventName:"error",listener:r})})(e)})})});return c.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{c.disconnect(),o.forEach(({element:e,eventName:r,listener:n})=>{e.removeEventListener(r,n)})}};
1
+ "use strict";require("../../constants/index.cjs"),require("../../types/enums.cjs"),require("../../utils/sentry.cjs"),require("../../utils/is-type.cjs");var e=require("../../utils/noop.cjs");require("../../utils/logger.cjs");var r=require("./resource-timing.cjs"),n=require("./performance-observer-support.cjs");const t=new Set(["IMG","SCRIPT","LINK"]);exports.observeResourceElementFallback=function(o){if(n.supportsPerformanceEntryType("resource")||!("MutationObserver"in globalThis)||"function"!=typeof globalThis.MutationObserver)return e.noop;const s=[],i=new Set,c=e=>{const n=function(e){return e instanceof HTMLImageElement?e.currentSrc||e.src:e instanceof HTMLScriptElement?e.src:e.href}(e);if(!n||i.has(n)||r.isSdkReportUrl(n))return;i.add(n);const t=function(e){return r.getResourceList().filter(r=>r.name===e).at(-1)??null}(n)??function(e,r){const n="performance"in globalThis?Math.round(globalThis.performance.now()):Date.now();return{name:e,initiatorType:r,startTime:n,responseEnd:n,duration:0,transferSize:0,encodedBodySize:0,decodedBodySize:0,fromCache:!1}}(n,e.tagName.toLowerCase());o(r.createResourceTimingData(t))},a=new globalThis.MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{(function(e){return e instanceof HTMLElement&&t.has(e.tagName)})(e)&&(e=>{const r=()=>{c(e)};e.addEventListener("load",r,{once:!0}),e.addEventListener("error",r,{once:!0}),s.push({element:e,eventName:"load",listener:r}),s.push({element:e,eventName:"error",listener:r})})(e)})})});return a.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{a.disconnect(),s.forEach(({element:e,eventName:r,listener:n})=>{e.removeEventListener(r,n)})}};
@@ -1 +1 @@
1
- import"../../constants/index.js";import"../../types/enums.js";import e from"../../utils/sentry.js";import"../../utils/is-type.js";import{createResourceTimingData as n,getResourceList as t}from"./resource-timing.js";import{supportsPerformanceEntryType as r}from"./performance-observer-support.js";const o=new Set(["IMG","SCRIPT","LINK"]);function s(s){if(r("resource")||!("MutationObserver"in globalThis)||"function"!=typeof globalThis.MutationObserver)return()=>{};const i=[],a=new Set,c=r=>{const o=function(e){return e instanceof HTMLImageElement?e.currentSrc||e.src:e instanceof HTMLScriptElement?e.src:e.href}(r);if(!o||a.has(o)||o.includes(e.options.dsn))return;a.add(o);const i=function(e){return t().filter(n=>n.name===e).at(-1)??null}(o)??function(e,n){const t="performance"in globalThis?Math.round(globalThis.performance.now()):Date.now();return{name:e,initiatorType:n,startTime:t,responseEnd:t,duration:0,transferSize:0,encodedBodySize:0,decodedBodySize:0,fromCache:!1}}(o,r.tagName.toLowerCase());s(n(i))},m=new globalThis.MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{(function(e){return e instanceof HTMLElement&&o.has(e.tagName)})(e)&&(e=>{const n=()=>{c(e)};e.addEventListener("load",n,{once:!0}),e.addEventListener("error",n,{once:!0}),i.push({element:e,eventName:"load",listener:n}),i.push({element:e,eventName:"error",listener:n})})(e)})})});return m.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{m.disconnect(),i.forEach(({element:e,eventName:n,listener:t})=>{e.removeEventListener(n,t)})}}export{s as observeResourceElementFallback};
1
+ import"../../constants/index.js";import"../../types/enums.js";import"../../utils/sentry.js";import"../../utils/is-type.js";import{noop as e}from"../../utils/noop.js";import"../../utils/logger.js";import{isSdkReportUrl as t,createResourceTimingData as n,getResourceList as r}from"./resource-timing.js";import{supportsPerformanceEntryType as o}from"./performance-observer-support.js";const s=new Set(["IMG","SCRIPT","LINK"]);function i(i){if(o("resource")||!("MutationObserver"in globalThis)||"function"!=typeof globalThis.MutationObserver)return e;const a=[],c=new Set,m=e=>{const o=function(e){return e instanceof HTMLImageElement?e.currentSrc||e.src:e instanceof HTMLScriptElement?e.src:e.href}(e);if(!o||c.has(o)||t(o))return;c.add(o);const s=function(e){return r().filter(t=>t.name===e).at(-1)??null}(o)??function(e,t){const n="performance"in globalThis?Math.round(globalThis.performance.now()):Date.now();return{name:e,initiatorType:t,startTime:n,responseEnd:n,duration:0,transferSize:0,encodedBodySize:0,decodedBodySize:0,fromCache:!1}}(o,e.tagName.toLowerCase());i(n(s))},u=new globalThis.MutationObserver(e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{(function(e){return e instanceof HTMLElement&&s.has(e.tagName)})(e)&&(e=>{const t=()=>{m(e)};e.addEventListener("load",t,{once:!0}),e.addEventListener("error",t,{once:!0}),a.push({element:e,eventName:"load",listener:t}),a.push({element:e,eventName:"error",listener:t})})(e)})})});return u.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{u.disconnect(),a.forEach(({element:e,eventName:t,listener:n})=>{e.removeEventListener(t,n)})}}export{i as observeResourceElementFallback};
@@ -1 +1 @@
1
- "use strict";var e=require("../../types/enums.cjs");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs"),t=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs");var n=require("./performance-observer-support.cjs");const s=new Set(["fetch","xmlhttprequest","beacon"]);function i(e){return"resource"===e.entryType&&"initiatorType"in e}function o(e){return!s.has(e.initiatorType)&&!function(e){return""!==t.default.options.dsn&&e.name.includes(t.default.options.dsn)}(e)}function a(e){return{name:e.name,initiatorType:e.initiatorType,startTime:Math.round(e.startTime),responseEnd:Math.round(e.responseEnd),duration:Math.round(e.duration),transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize,fromCache:c(e)}}function u(t){return{...r.default(),type:e.EventType.Performance,name:"ResourceTiming",message:t.name,status:e.Status.OK,value:t.duration,extra:{resource:t}}}function c(e){return 0===e.transferSize||0!==e.transferSize&&0===e.encodedBodySize}function p(){return"performance"in globalThis&&"function"==typeof globalThis.performance.getEntriesByType?globalThis.performance.getEntriesByType("resource").filter(i).filter(o).map(a):[]}exports.createResourceTimingData=u,exports.getInitialResourceListData=function(){return{...r.default(),name:"ResourceList",type:e.EventType.Performance,status:e.Status.OK,resourceList:p()}},exports.getResourceList=p,exports.isFromCache=c,exports.observeResourceTimings=function(e){if(!n.supportsPerformanceEntryType("resource"))return()=>{};const r=new globalThis.PerformanceObserver(r=>{r.getEntries().filter(i).filter(o).map(a).forEach(r=>{e(u(r))})});return r.observe({entryTypes:["resource"]}),()=>{r.disconnect()}};
1
+ "use strict";var e=require("../../types/enums.cjs");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs"),t=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs");var n=require("../../utils/noop.cjs");require("../../utils/logger.cjs");var s=require("./performance-observer-support.cjs");const o=new Set(["fetch","xmlhttprequest","beacon"]);function i(e){return"resource"===e.entryType&&"initiatorType"in e}function u(e){return""!==t.default.options.dsn&&e.includes(t.default.options.dsn)}function a(e){return!o.has(e.initiatorType)&&!u(e.name)}function c(e){return{name:e.name,initiatorType:e.initiatorType,startTime:Math.round(e.startTime),responseEnd:Math.round(e.responseEnd),duration:Math.round(e.duration),transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize,fromCache:d(e)}}function p(t){return{...r.default(),type:e.EventType.Performance,name:"ResourceTiming",message:t.name,status:e.Status.OK,value:t.duration,extra:{resource:t}}}function d(e){return 0===e.transferSize||0===e.encodedBodySize}function f(){return"performance"in globalThis&&"function"==typeof globalThis.performance.getEntriesByType?globalThis.performance.getEntriesByType("resource").filter(i).filter(a).map(c):[]}exports.createResourceTimingData=p,exports.getInitialResourceListData=function(){return{...r.default(),name:"ResourceList",type:e.EventType.Performance,status:e.Status.OK,resourceList:f()}},exports.getResourceList=f,exports.isSdkReportUrl=u,exports.observeResourceTimings=function(e){if(!s.supportsPerformanceEntryType("resource"))return n.noop;const r=new globalThis.PerformanceObserver(r=>{r.getEntries().filter(i).filter(a).map(c).forEach(r=>{e(p(r))})});return r.observe({entryTypes:["resource"]}),()=>{r.disconnect()}};
@@ -1 +1 @@
1
- import{Status as e,EventType as r}from"../../types/enums.js";import"../../constants/index.js";import t from"../../utils/get-base-data.js";import n from"../../utils/sentry.js";import"../../utils/is-type.js";import{supportsPerformanceEntryType as o}from"./performance-observer-support.js";const i=new Set(["fetch","xmlhttprequest","beacon"]);function s(e){return"resource"===e.entryType&&"initiatorType"in e}function a(e){return!i.has(e.initiatorType)&&!function(e){return""!==n.options.dsn&&e.name.includes(n.options.dsn)}(e)}function u(e){return{name:e.name,initiatorType:e.initiatorType,startTime:Math.round(e.startTime),responseEnd:Math.round(e.responseEnd),duration:Math.round(e.duration),transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize,fromCache:f(e)}}function c(n){return{...t(),type:r.Performance,name:"ResourceTiming",message:n.name,status:e.OK,value:n.duration,extra:{resource:n}}}function f(e){return 0===e.transferSize||0!==e.transferSize&&0===e.encodedBodySize}function p(){return"performance"in globalThis&&"function"==typeof globalThis.performance.getEntriesByType?globalThis.performance.getEntriesByType("resource").filter(s).filter(a).map(u):[]}function m(){return{...t(),name:"ResourceList",type:r.Performance,status:e.OK,resourceList:p()}}function d(e){if(!o("resource"))return()=>{};const r=new globalThis.PerformanceObserver(r=>{r.getEntries().filter(s).filter(a).map(u).forEach(r=>{e(c(r))})});return r.observe({entryTypes:["resource"]}),()=>{r.disconnect()}}export{c as createResourceTimingData,m as getInitialResourceListData,p as getResourceList,f as isFromCache,d as observeResourceTimings};
1
+ import{Status as e,EventType as r}from"../../types/enums.js";import"../../constants/index.js";import t from"../../utils/get-base-data.js";import n from"../../utils/sentry.js";import"../../utils/is-type.js";import{noop as o}from"../../utils/noop.js";import"../../utils/logger.js";import{supportsPerformanceEntryType as i}from"./performance-observer-support.js";const s=new Set(["fetch","xmlhttprequest","beacon"]);function a(e){return"resource"===e.entryType&&"initiatorType"in e}function u(e){return""!==n.options.dsn&&e.includes(n.options.dsn)}function c(e){return!s.has(e.initiatorType)&&!u(e.name)}function p(e){return{name:e.name,initiatorType:e.initiatorType,startTime:Math.round(e.startTime),responseEnd:Math.round(e.responseEnd),duration:Math.round(e.duration),transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize,fromCache:f(e)}}function m(n){return{...t(),type:r.Performance,name:"ResourceTiming",message:n.name,status:e.OK,value:n.duration,extra:{resource:n}}}function f(e){return 0===e.transferSize||0===e.encodedBodySize}function d(){return"performance"in globalThis&&"function"==typeof globalThis.performance.getEntriesByType?globalThis.performance.getEntriesByType("resource").filter(a).filter(c).map(p):[]}function y(){return{...t(),name:"ResourceList",type:r.Performance,status:e.OK,resourceList:d()}}function l(e){if(!i("resource"))return o;const r=new globalThis.PerformanceObserver(r=>{r.getEntries().filter(a).filter(c).map(p).forEach(r=>{e(m(r))})});return r.observe({entryTypes:["resource"]}),()=>{r.disconnect()}}export{m as createResourceTimingData,y as getInitialResourceListData,d as getResourceList,u as isSdkReportUrl,l as observeResourceTimings};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../types/enums.cjs"),r=require("../../types/plugin.cjs"),s=require("../../constants/index.cjs"),n=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs");var t=require("../../reporter/index.cjs"),c=require("./recorder.cjs");class o extends r.SentryPlugin{durationMs=s.DEFAULT_OPTIONS.screenRecordDurationMs;eventTypes=s.DEFAULT_OPTIONS.screenRecordEventTypes;cleanup=null;constructor(r={durationMs:s.DEFAULT_OPTIONS.screenRecordDurationMs,eventTypes:s.DEFAULT_OPTIONS.screenRecordEventTypes}){super(e.EventType.ScreenRecord);const{durationMs:n=s.DEFAULT_OPTIONS.screenRecordDurationMs,eventTypes:t=s.DEFAULT_OPTIONS.screenRecordEventTypes}=r;this.durationMs=n,this.eventTypes=t}init(){n.default.options.enableScreenRecord=!0,n.default.options.screenRecordEventTypes=this.eventTypes,n.default.options.screenRecordDurationMs=this.durationMs,c.recorder(t.default).then(e=>{this.cleanup=e})}destroy(){this.cleanup?.(),this.cleanup=null}}exports.unzipScreenRecord=c.unzipScreenRecord,exports.default=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("../../types/enums.cjs");var e=require("../../types/plugin.cjs"),r=require("../../constants/index.cjs"),s=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs"),require("../../utils/logger.cjs");var t=require("../../reporter/index.cjs"),n=require("./recorder.cjs");class i extends e.SentryPlugin{durationMs;eventTypes;cleanup=null;constructor(e={}){super(),this.durationMs=e.durationMs??r.DEFAULT_OPTIONS.screenRecordDurationMs,this.eventTypes=[...e.eventTypes??r.DEFAULT_OPTIONS.screenRecordEventTypes]}init(){s.default.setOptions({screenRecordEventTypes:[...this.eventTypes],screenRecordDurationMs:this.durationMs}),n.recorder(t.default).then(e=>{this.cleanup=e})}destroy(){this.cleanup?.(),this.cleanup=null}}exports.unzipScreenRecord=n.unzipScreenRecord,exports.default=i;
@@ -1 +1 @@
1
- import{EventType as e}from"../../types/enums.js";import{SentryPlugin as r}from"../../types/plugin.js";import{DEFAULT_OPTIONS as s}from"../../constants/index.js";import t from"../../utils/sentry.js";import"../../utils/is-type.js";import n from"../../reporter/index.js";import{recorder as o}from"./recorder.js";export{unzipScreenRecord}from"./recorder.js";class i extends r{durationMs=s.screenRecordDurationMs;eventTypes=s.screenRecordEventTypes;cleanup=null;constructor(r={durationMs:s.screenRecordDurationMs,eventTypes:s.screenRecordEventTypes}){super(e.ScreenRecord);const{durationMs:t=s.screenRecordDurationMs,eventTypes:n=s.screenRecordEventTypes}=r;this.durationMs=t,this.eventTypes=n}init(){t.options.enableScreenRecord=!0,t.options.screenRecordEventTypes=this.eventTypes,t.options.screenRecordDurationMs=this.durationMs,o(n).then(e=>{this.cleanup=e})}destroy(){this.cleanup?.(),this.cleanup=null}}export{i as default};
1
+ import"../../types/enums.js";import{SentryPlugin as e}from"../../types/plugin.js";import{DEFAULT_OPTIONS as s}from"../../constants/index.js";import t from"../../utils/sentry.js";import"../../utils/is-type.js";import"../../utils/logger.js";import r from"../../reporter/index.js";import{recorder as n}from"./recorder.js";export{unzipScreenRecord}from"./recorder.js";class o extends e{durationMs;eventTypes;cleanup=null;constructor(e={}){super(),this.durationMs=e.durationMs??s.screenRecordDurationMs,this.eventTypes=[...e.eventTypes??s.screenRecordEventTypes]}init(){t.setOptions({screenRecordEventTypes:[...this.eventTypes],screenRecordDurationMs:this.durationMs}),n(r).then(e=>{this.cleanup=e})}destroy(){this.cleanup?.(),this.cleanup=null}}export{o as default};
@@ -1 +1 @@
1
- "use strict";var e=require("../../types/enums.cjs");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs"),t=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs");var n=require("../../utils/logger.cjs"),o=require("zod");let s=null;const c=o.z.object({timestamp:o.z.number()}).passthrough();function i(){}function u(e,r){const n=r-t.default.options.screenRecordDurationMs;return e.filter(e=>e.timestamp>=n)}function a(e){if(!e||!s)return"";const r=JSON.stringify(e);return function(e){let r="";return e.forEach(e=>{r+=String.fromCharCode(e)}),btoa(r)}(s.gzip(r))}exports.recorder=async function(o){n.sentryLogger.info("Initializing web recorder...");try{const[{record:d},l]=await Promise.all([import("@rrweb/record"),import("pako")]);s=l.default;let f=[];const p=d({emit(s,i){const d=c.safeParse(s);if(d.success&&(f=u([...f,d.data],d.data.timestamp),i&&(f=u(f,d.data.timestamp)),t.default.shouldScreenRecord&&f.length>0)){const s={...r.default(),name:"ScreenRecord",type:e.EventType.ScreenRecord,event:a(f),eventCount:f.length};n.sentryLogger.success("Screen record window packaged and sent",{eventCount:s.eventCount}),o.send(s),t.default.shouldScreenRecord=!1}},recordCanvas:!0,checkoutEveryNms:t.default.options.screenRecordDurationMs});return"function"==typeof p?p:i}catch(e){return n.sentryLogger.error("Failed to load web recorder",e),i}},exports.unzipScreenRecord=function(e){if(!e||!s)return null;const r=s.ungzip(function(e){const r=atob(e);return Uint8Array.from(r,e=>e.charCodeAt(0))}(e),{to:"string"});return JSON.parse(r)},exports.zip=a;
1
+ "use strict";var e=require("../../types/enums.cjs");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs"),t=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs");var n=require("../../utils/noop.cjs"),o=require("../../utils/logger.cjs"),s=require("zod");let c=null;const i=s.z.looseObject({timestamp:s.z.number()});function u(e){if(!e||!c)return"";const r=JSON.stringify(e);return function(e){let r="";for(let t=0;t<e.length;t+=32768)r+=String.fromCharCode(...e.subarray(t,t+32768));return btoa(r)}(c.gzip(r))}exports.recorder=async function(s){o.sentryLogger.info("Initializing web recorder...");try{const[{record:a},d]=await Promise.all([import("@rrweb/record"),import("pako")]);c=d.default;const l=[],p=e=>{const r=e-t.default.options.screenRecordDurationMs;for(;l.length>0&&l[0].timestamp<r;)l.shift()},f=a({emit(n){const c=i.safeParse(n);if(c.success&&(l.push(c.data),p(c.data.timestamp),t.default.shouldScreenRecord&&l.length>0)){const n={...r.default(),name:"ScreenRecord",type:e.EventType.ScreenRecord,event:u(l),eventCount:l.length};o.sentryLogger.success("Screen record window packaged and sent",{eventCount:n.eventCount}),s.send(n),t.default.shouldScreenRecord=!1}},recordCanvas:!0,checkoutEveryNms:t.default.options.screenRecordDurationMs});return"function"==typeof f?f:n.noop}catch(e){return o.sentryLogger.error("Failed to load web recorder",e),n.noop}},exports.unzipScreenRecord=async function(e){if(!e)return null;const r=(c??(await(import("pako"))).default).ungzip(function(e){const r=atob(e);return Uint8Array.from(r,e=>e.charCodeAt(0))}(e),{to:"string"});return JSON.parse(r)};
@@ -20,6 +20,6 @@
20
20
  * SOFTWARE.
21
21
  */
22
22
 
23
- declare function unzipScreenRecord(data: string): unknown;
23
+ declare function unzipScreenRecord(data: string): Promise<unknown>;
24
24
 
25
25
  export { unzipScreenRecord };
@@ -1 +1 @@
1
- import{EventType as t}from"../../types/enums.js";import"../../constants/index.js";import e from"../../utils/get-base-data.js";import r from"../../utils/sentry.js";import"../../utils/is-type.js";import{sentryLogger as n}from"../../utils/logger.js";import{z as o}from"zod";let s=null;const i=o.object({timestamp:o.number()}).passthrough();function c(){}function a(t,e){const n=e-r.options.screenRecordDurationMs;return t.filter(t=>t.timestamp>=n)}async function u(o){n.info("Initializing web recorder...");try{const[{record:u},d]=await Promise.all([import("@rrweb/record"),import("pako")]);s=d.default;let p=[];const f=u({emit(s,c){const u=i.safeParse(s);if(u.success&&(p=a([...p,u.data],u.data.timestamp),c&&(p=a(p,u.data.timestamp)),r.shouldScreenRecord&&p.length>0)){const s={...e(),name:"ScreenRecord",type:t.ScreenRecord,event:m(p),eventCount:p.length};n.success("Screen record window packaged and sent",{eventCount:s.eventCount}),o.send(s),r.shouldScreenRecord=!1}},recordCanvas:!0,checkoutEveryNms:r.options.screenRecordDurationMs});return"function"==typeof f?f:c}catch(t){return n.error("Failed to load web recorder",t),c}}function m(t){if(!t||!s)return"";const e=JSON.stringify(t);return function(t){let e="";return t.forEach(t=>{e+=String.fromCharCode(t)}),btoa(e)}(s.gzip(e))}function d(t){if(!t||!s)return null;const e=s.ungzip(function(t){const e=atob(t);return Uint8Array.from(e,t=>t.charCodeAt(0))}(t),{to:"string"});return JSON.parse(e)}export{u as recorder,d as unzipScreenRecord,m as zip};
1
+ import{EventType as t}from"../../types/enums.js";import"../../constants/index.js";import e from"../../utils/get-base-data.js";import r from"../../utils/sentry.js";import"../../utils/is-type.js";import{noop as o}from"../../utils/noop.js";import{sentryLogger as n}from"../../utils/logger.js";import{z as s}from"zod";let i=null;const c=s.looseObject({timestamp:s.number()});async function a(s){n.info("Initializing web recorder...");try{const[{record:a},m]=await Promise.all([import("@rrweb/record"),import("pako")]);i=m.default;const d=[],p=t=>{const e=t-r.options.screenRecordDurationMs;for(;d.length>0&&d[0].timestamp<e;)d.shift()},l=a({emit(o){const i=c.safeParse(o);if(i.success&&(d.push(i.data),p(i.data.timestamp),r.shouldScreenRecord&&d.length>0)){const o={...e(),name:"ScreenRecord",type:t.ScreenRecord,event:u(d),eventCount:d.length};n.success("Screen record window packaged and sent",{eventCount:o.eventCount}),s.send(o),r.shouldScreenRecord=!1}},recordCanvas:!0,checkoutEveryNms:r.options.screenRecordDurationMs});return"function"==typeof l?l:o}catch(t){return n.error("Failed to load web recorder",t),o}}function u(t){if(!t||!i)return"";const e=JSON.stringify(t);return function(t){let e="";for(let r=0;r<t.length;r+=32768)e+=String.fromCharCode(...t.subarray(r,r+32768));return btoa(e)}(i.gzip(e))}async function m(t){if(!t)return null;const e=(i??(await(import("pako"))).default).ungzip(function(t){const e=atob(t);return Uint8Array.from(e,t=>t.charCodeAt(0))}(t),{to:"string"});return JSON.parse(e)}export{a as recorder,m as unzipScreenRecord};
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var r=require("react"),e=require("./types/enums.cjs"),t=require("./core/framework-error.cjs");class o extends r.Component{state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),t.reportFrameworkError({type:e.EventType.React,error:r,context:o})}render(){const{error:r,errorInfo:e}=this.state;if(r){const{fallback:t}=this.props;return"function"==typeof t?t(r,e):t??null}return this.props.children??null}}exports.ReactErrorBoundary=o;
1
+ "use strict";var r=require("react"),e=require("./types/enums.cjs"),t=require("./core/framework-error.cjs");class o extends r.Component{static displayName="ReactErrorBoundary";state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),t.reportFrameworkError({type:e.EventType.React,error:r,context:o})}render(){const{error:r,errorInfo:e}=this.state;if(r){const{fallback:t}=this.props;return"function"==typeof t?t(r,e):t??null}return this.props.children??null}}exports.ReactErrorBoundary=o;
package/dist/react.d.ts CHANGED
@@ -22,101 +22,28 @@ import { Component, ReactNode, ErrorInfo } from 'react';
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- /**
26
- * Props for the {@link ReactErrorBoundary} component.
27
- *
28
- * The boundary renders `children` normally. When a descendant throws during
29
- * rendering, it switches to rendering {@link fallback} and reports the error
30
- * to the Sentry SDK.
31
- */
32
25
  interface ReactErrorBoundaryProps {
33
- /**
34
- * The subtree to render when no error has occurred. When an error is
35
- * caught, this is replaced by {@link fallback}.
36
- */
37
26
  readonly children?: ReactNode;
38
27
  /**
39
- * The UI to display when a descendant throws.
40
- *
41
- * Can be a static `ReactNode` (no access to the error) or a render function
42
- * that receives the caught error and React's component-stack info.
43
- *
44
- * @remarks
45
- * The render function may be invoked twice during an error cycle:
46
- * 1. First, right after `getDerivedStateFromError` runs in the render
47
- * phase — at this point `errorInfo` is still `undefined` because React
48
- * only delivers {@link ErrorInfo} in `componentDidCatch` (commit phase).
49
- * 2. Again after `componentDidCatch` merges `errorInfo` into state.
50
- *
51
- * Therefore `errorInfo` is typed as optional. Guard against `undefined` if
52
- * your fallback relies on `componentStack`.
53
- *
54
- * @param error - The Error thrown by the descendant component. Always
55
- * defined when the fallback is invoked, because the boundary only enters
56
- * the error state when an Error is present.
57
- * @param errorInfo - React's {@link ErrorInfo}, containing `componentStack`.
58
- * `undefined` on the first render after the error is caught.
59
- * @returns The fallback React subtree to render.
28
+ * Error UI. A render function may be called once with `errorInfo`
29
+ * undefined (the fallback renders from `getDerivedStateFromError` before
30
+ * React delivers `ErrorInfo` in `componentDidCatch`) and again once it is
31
+ * available.
60
32
  */
61
33
  readonly fallback?: ReactNode | ((error: Error, errorInfo?: ErrorInfo) => ReactNode);
62
34
  }
63
- /** Internal state tracking the caught error and React component-stack info. */
64
35
  interface ReactErrorBoundaryState {
65
36
  readonly error?: Error;
66
37
  readonly errorInfo?: ErrorInfo;
67
38
  }
68
39
  /**
69
- * A React Error Boundary that reports caught errors to the Sentry SDK.
70
- *
71
- * @example
72
- * ```tsx
73
- * <ReactErrorBoundary fallback={<div>Something went wrong</div>}>
74
- * <Page />
75
- * </ReactErrorBoundary>
76
- * ```
40
+ * React Error Boundary that renders `fallback` and reports the caught error
41
+ * to the SDK as an `EventType.React` event.
77
42
  */
78
43
  declare class ReactErrorBoundary extends Component<ReactErrorBoundaryProps, ReactErrorBoundaryState> {
44
+ static displayName: string;
79
45
  state: ReactErrorBoundaryState;
80
- /**
81
- * Called by React during the **render phase** when a descendant throws.
82
- *
83
- * This is a pure static method — it must not access `this` or cause side
84
- * effects. Its sole responsibility is to return the next state so React can
85
- * immediately re-render the boundary and show the fallback UI without
86
- * waiting for the commit phase.
87
- *
88
- * Only `error` is available here; React does not deliver {@link ErrorInfo}
89
- * until {@link componentDidCatch} runs (commit phase), so `errorInfo` is
90
- * left `undefined` at this point.
91
- *
92
- * This method is **not redundant** with {@link componentDidCatch}. It
93
- * triggers the fallback render synchronously in the render phase; without
94
- * it the fallback would not appear until after commit.
95
- *
96
- * @param error - The Error thrown by the descendant component.
97
- * @returns The next state, setting `error` so the boundary renders the
98
- * fallback.
99
- */
100
46
  static getDerivedStateFromError(error: Error): ReactErrorBoundaryState;
101
- /**
102
- * Called by React during the **commit phase** (after the DOM has been
103
- * updated) when a descendant throws.
104
- *
105
- * This is where side effects belong. It performs two duties:
106
- * 1. Merges `errorInfo` (React's component-stack trace) into state so the
107
- * fallback render function can access it. `error` is also set again —
108
- * it is already present from
109
- * {@link getDerivedStateFromError | getDerivedStateFromError} but is
110
- * included for a single atomic state update.
111
- * 2. Reports the error to the Sentry SDK as a `React` event via
112
- * {@link reportFrameworkError}.
113
- *
114
- * @param error - The Error thrown by the descendant component.
115
- * @param errorInfo - React's {@link ErrorInfo}, containing `componentStack`:
116
- * a string describing the component tree from the throwing component up to
117
- * this boundary. Useful for locating where in the component hierarchy the
118
- * error originated.
119
- */
120
47
  componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
121
48
  render(): ReactNode;
122
49
  }
package/dist/react.js CHANGED
@@ -1 +1 @@
1
- import{Component as r}from"react";import{EventType as t}from"./types/enums.js";import{reportFrameworkError as e}from"./core/framework-error.js";class o extends r{state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),e({type:t.React,error:r,context:o})}render(){const{error:r,errorInfo:t}=this.state;if(r){const{fallback:e}=this.props;return"function"==typeof e?e(r,t):e??null}return this.props.children??null}}export{o as ReactErrorBoundary};
1
+ import{Component as r}from"react";import{EventType as t}from"./types/enums.js";import{reportFrameworkError as e}from"./core/framework-error.js";class o extends r{static displayName="ReactErrorBoundary";state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),e({type:t.React,error:r,context:o})}render(){const{error:r,errorInfo:t}=this.state;if(r){const{fallback:e}=this.props;return"function"==typeof e?e(r,t):e??null}return this.props.children??null}}export{o as ReactErrorBoundary};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../utils/data-structures.cjs");require("../types/enums.cjs");var t=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var s=require("../utils/logger.cjs"),i=require("./batch.cjs"),r=require("./flush-scheduler.cjs"),n=require("./network-listener.cjs"),h=require("./offline-cache.cjs"),u=require("./promise.cjs"),a=require("./report-data.cjs"),l=require("./send-preflight.cjs"),c=require("./server-recovery.cjs"),o=require("./transports.cjs");class f{cbQueue=new e.CallbackQueue;id=crypto.randomUUID();events=[];timeoutID;retryTimer;isOnline=!0;isFlushing=!1;static#e=null;constructor(){n.initNetworkListener({setOnline:e=>{this.isOnline=e},loadOfflineCache:()=>this.loadOfflineCache(),flush:()=>this.flush()})}static get instance(){return this.#e||(this.#e=new f),this.#e}static reset(){this.#e&&this.#e.dispose(),this.#e=null}dispose(){this.timeoutID&&clearTimeout(this.timeoutID),this.retryTimer&&clearTimeout(this.retryTimer),this.events=[],this.isFlushing=!1}loadOfflineCache(){this.events.unshift(...h.loadOfflineCache()),this.events=this.events.slice(-t.default.options.maxQueueLength)}saveOfflineCache(){h.saveOfflineCache(this.events)}handleServerError(){this.retryTimer=c.scheduleServerRecovery(this.retryTimer,{setOnline:e=>{this.isOnline=e},setRetryTimer:e=>{this.retryTimer=e},loadOfflineCache:()=>this.loadOfflineCache(),flush:()=>this.flush()})}async flush(){if(0!==this.events.length&&!this.isFlushing){this.isFlushing=!0;try{if(!this.isOnline)return this.events=this.events.slice(-t.default.options.maxQueueLength),void this.saveOfflineCache();const e=this.takeBatch(),i=u.isPromise(e)?await e:e;if(0===i.length)return void this.scheduleNextFlush();const r=performance.now(),n=this.sendBatch(i);if(!(u.isPromise(n)?await n:n))return this.events=[...i,...this.events].slice(-t.default.options.maxQueueLength),void this.saveOfflineCache();t.default.options.afterSendData?.(i),s.sentryLogger.success("Batch report queued or sent",{count:i.length},Math.round(performance.now()-r))}finally{this.isFlushing=!1}this.scheduleNextFlush()}}takeBatch(){const e=t.default.options.cacheMaxLength,s=this.events.slice(0,e);return this.events=this.events.slice(e),i.applyBeforePushHook(s)}sendBatch(e){return!(o.isObjectOverSizeLimit(e,60)||!o.sendBeacon(e))||(t.default.options.useImageReport&&!o.isObjectOverSizeLimit(e,2)?(o.reportByImage(e,this.cbQueue),!0):o.reportByFetch(e,()=>this.handleServerError()))}scheduleNextFlush(){0!==this.events.length&&(this.timeoutID=r.scheduleFlush(this.timeoutID,100,()=>this.flush()))}async flushOfflineCache(){this.loadOfflineCache(),await this.flush()}async send(e,i=!1){const n=t.default.options;if(!l.shouldQueuePayload(e))return;const h=a.runBeforeReportHook(this.id,e),c=u.isPromise(h)?await h:h;if(c){if(s.sentryLogger.info(`Type: ${e.type}`,c),this.events.push(c),!this.isOnline)return this.events=this.events.slice(-n.maxQueueLength),void this.saveOfflineCache();this.timeoutID&&clearTimeout(this.timeoutID),i||this.events.length>=n.cacheMaxLength?await this.flush():this.timeoutID=r.scheduleFlush(this.timeoutID,n.cacheWaitingTime,()=>this.flush())}}}let d=null;var v=new Proxy({},{get(e,t){const s=(d||(d=f.instance),d),i=Reflect.get(s,t,s);return"function"==typeof i?i.bind(s):i}});exports.DataReporter=f,exports.default=v,exports.resetReporter=function(){d&&(f.reset(),d=null)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("../constants/index.cjs"),require("../types/enums.cjs");var e=require("../utils/uuid.cjs"),t=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var s=require("../utils/logger.cjs"),i=require("./flush-scheduler.cjs"),r=require("./network-listener.cjs"),h=require("./offline-cache.cjs"),n=require("./promise.cjs"),u=require("./report-data.cjs"),o=require("./send-preflight.cjs"),l=require("./server-recovery.cjs"),a=require("./transports.cjs");class c{id=e.generateUUID();events=[];timeoutID;retryTimer;isOnline=!0;isFlushing=!1;hasPersistedCache=!1;removeNetworkListener;constructor(){this.removeNetworkListener=r.initNetworkListener({setOnline:e=>{this.isOnline=e},flush:()=>this.flush()}),this.loadOfflineCache()}dispose(){this.timeoutID&&clearTimeout(this.timeoutID),this.retryTimer&&clearTimeout(this.retryTimer),this.removeNetworkListener(),this.events=[],this.isFlushing=!1}loadOfflineCache(){this.events.unshift(...h.loadOfflineCache()),this.events=this.events.slice(-t.default.options.maxQueueLength)}saveOfflineCache(){h.saveOfflineCache(this.events),this.hasPersistedCache=!0}clearPersistedCache(){this.hasPersistedCache&&(h.clearOfflineCache(),this.hasPersistedCache=!1)}handleServerError(){this.retryTimer=l.scheduleServerRecovery(this.retryTimer,{setOnline:e=>{this.isOnline=e},setRetryTimer:e=>{this.retryTimer=e},flush:()=>this.flush()})}async flush(){if(0!==this.events.length&&!this.isFlushing){this.isFlushing=!0;try{if(!this.isOnline)return this.events=this.events.slice(-t.default.options.maxQueueLength),void this.saveOfflineCache();const e=this.takeBatch(),i=n.isPromise(e)?await e:e;if(0===i.length)return void this.scheduleNextFlush();const r=performance.now(),h=this.sendBatch(i);if(!(n.isPromise(h)?await h:h))return this.events=[...i,...this.events].slice(-t.default.options.maxQueueLength),void this.saveOfflineCache();this.clearPersistedCache(),t.default.options.afterSend?.(i),s.sentryLogger.success("Batch report queued or sent",{count:i.length},Math.round(performance.now()-r))}finally{this.isFlushing=!1}this.scheduleNextFlush()}}takeBatch(){const e=t.default.options.cacheMaxLength,s=this.events.slice(0,e);return this.events=this.events.slice(e),u.applyBeforePushHook(s)}sendBatch(e){const t=JSON.stringify(e),s=a.getBodyByteLength(t)<=a.MAX_KEEPALIVE_BYTES;return!(!s||!a.sendBeacon(t))||a.reportByFetch(t,s,()=>this.handleServerError())}scheduleNextFlush(){0!==this.events.length&&(this.timeoutID=i.scheduleFlush(this.timeoutID,100,()=>this.flush()))}async flushOfflineCache(){this.loadOfflineCache(),await this.flush()}async send(e,r=!1){const h=t.default.options;if(!o.shouldQueuePayload(e))return;const l=u.runBeforeReportHook(this.id,e),a=n.isPromise(l)?await l:l;if(a){if(s.sentryLogger.info(`Type: ${e.type}`,a),this.events.push(a),!this.isOnline)return this.events=this.events.slice(-h.maxQueueLength),void this.saveOfflineCache();this.timeoutID&&clearTimeout(this.timeoutID),r||this.events.length>=h.cacheMaxLength?await this.flush():this.timeoutID=i.scheduleFlush(this.timeoutID,h.cacheWaitingTime,()=>this.flush())}}}let f=null;var d=new Proxy({},{get(e,t){f??=new c;const s=Reflect.get(f,t,f);return"function"==typeof s?s.bind(f):s}});exports.DataReporter=c,exports.default=d,exports.resetReporter=function(){f?.dispose(),f=null};
@@ -1 +1 @@
1
- import{CallbackQueue as t}from"../utils/data-structures.js";import"../types/enums.js";import e from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as s}from"../utils/logger.js";import{applyBeforePushHook as i}from"./batch.js";import{scheduleFlush as n}from"./flush-scheduler.js";import{initNetworkListener as h}from"./network-listener.js";import{loadOfflineCache as r,saveOfflineCache as o}from"./offline-cache.js";import{isPromise as a}from"./promise.js";import{runBeforeReportHook as l}from"./report-data.js";import{shouldQueuePayload as u}from"./send-preflight.js";import{scheduleServerRecovery as c}from"./server-recovery.js";import{isObjectOverSizeLimit as f,sendBeacon as m,reportByImage as p,reportByFetch as d}from"./transports.js";class v{cbQueue=new t;id=crypto.randomUUID();events=[];timeoutID;retryTimer;isOnline=!0;isFlushing=!1;static#t=null;constructor(){h({setOnline:t=>{this.isOnline=t},loadOfflineCache:()=>this.loadOfflineCache(),flush:()=>this.flush()})}static get instance(){return this.#t||(this.#t=new v),this.#t}static reset(){this.#t&&this.#t.dispose(),this.#t=null}dispose(){this.timeoutID&&clearTimeout(this.timeoutID),this.retryTimer&&clearTimeout(this.retryTimer),this.events=[],this.isFlushing=!1}loadOfflineCache(){this.events.unshift(...r()),this.events=this.events.slice(-e.options.maxQueueLength)}saveOfflineCache(){o(this.events)}handleServerError(){this.retryTimer=c(this.retryTimer,{setOnline:t=>{this.isOnline=t},setRetryTimer:t=>{this.retryTimer=t},loadOfflineCache:()=>this.loadOfflineCache(),flush:()=>this.flush()})}async flush(){if(0!==this.events.length&&!this.isFlushing){this.isFlushing=!0;try{if(!this.isOnline)return this.events=this.events.slice(-e.options.maxQueueLength),void this.saveOfflineCache();const t=this.takeBatch(),i=a(t)?await t:t;if(0===i.length)return void this.scheduleNextFlush();const n=performance.now(),h=this.sendBatch(i);if(!(a(h)?await h:h))return this.events=[...i,...this.events].slice(-e.options.maxQueueLength),void this.saveOfflineCache();e.options.afterSendData?.(i),s.success("Batch report queued or sent",{count:i.length},Math.round(performance.now()-n))}finally{this.isFlushing=!1}this.scheduleNextFlush()}}takeBatch(){const t=e.options.cacheMaxLength,s=this.events.slice(0,t);return this.events=this.events.slice(t),i(s)}sendBatch(t){return!(f(t,60)||!m(t))||(e.options.useImageReport&&!f(t,2)?(p(t,this.cbQueue),!0):d(t,()=>this.handleServerError()))}scheduleNextFlush(){0!==this.events.length&&(this.timeoutID=n(this.timeoutID,100,()=>this.flush()))}async flushOfflineCache(){this.loadOfflineCache(),await this.flush()}async send(t,i=!1){const h=e.options;if(!u(t))return;const r=l(this.id,t),o=a(r)?await r:r;if(o){if(s.info(`Type: ${t.type}`,o),this.events.push(o),!this.isOnline)return this.events=this.events.slice(-h.maxQueueLength),void this.saveOfflineCache();this.timeoutID&&clearTimeout(this.timeoutID),i||this.events.length>=h.cacheMaxLength?await this.flush():this.timeoutID=n(this.timeoutID,h.cacheWaitingTime,()=>this.flush())}}}let g=null;function y(){g&&(v.reset(),g=null)}var O=new Proxy({},{get(t,e){const s=(g||(g=v.instance),g),i=Reflect.get(s,e,s);return"function"==typeof i?i.bind(s):i}});export{v as DataReporter,O as default,y as resetReporter};
1
+ import"../constants/index.js";import"../types/enums.js";import{generateUUID as e}from"../utils/uuid.js";import t from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as s}from"../utils/logger.js";import{scheduleFlush as i}from"./flush-scheduler.js";import{initNetworkListener as h}from"./network-listener.js";import{loadOfflineCache as n,saveOfflineCache as r,clearOfflineCache as o}from"./offline-cache.js";import{isPromise as l}from"./promise.js";import{applyBeforePushHook as a,runBeforeReportHook as u}from"./report-data.js";import{shouldQueuePayload as c}from"./send-preflight.js";import{scheduleServerRecovery as f}from"./server-recovery.js";import{getBodyByteLength as m,MAX_KEEPALIVE_BYTES as p,sendBeacon as d,reportByFetch as v}from"./transports.js";class g{id=e();events=[];timeoutID;retryTimer;isOnline=!0;isFlushing=!1;hasPersistedCache=!1;removeNetworkListener;constructor(){this.removeNetworkListener=h({setOnline:e=>{this.isOnline=e},flush:()=>this.flush()}),this.loadOfflineCache()}dispose(){this.timeoutID&&clearTimeout(this.timeoutID),this.retryTimer&&clearTimeout(this.retryTimer),this.removeNetworkListener(),this.events=[],this.isFlushing=!1}loadOfflineCache(){this.events.unshift(...n()),this.events=this.events.slice(-t.options.maxQueueLength)}saveOfflineCache(){r(this.events),this.hasPersistedCache=!0}clearPersistedCache(){this.hasPersistedCache&&(o(),this.hasPersistedCache=!1)}handleServerError(){this.retryTimer=f(this.retryTimer,{setOnline:e=>{this.isOnline=e},setRetryTimer:e=>{this.retryTimer=e},flush:()=>this.flush()})}async flush(){if(0!==this.events.length&&!this.isFlushing){this.isFlushing=!0;try{if(!this.isOnline)return this.events=this.events.slice(-t.options.maxQueueLength),void this.saveOfflineCache();const e=this.takeBatch(),i=l(e)?await e:e;if(0===i.length)return void this.scheduleNextFlush();const h=performance.now(),n=this.sendBatch(i);if(!(l(n)?await n:n))return this.events=[...i,...this.events].slice(-t.options.maxQueueLength),void this.saveOfflineCache();this.clearPersistedCache(),t.options.afterSend?.(i),s.success("Batch report queued or sent",{count:i.length},Math.round(performance.now()-h))}finally{this.isFlushing=!1}this.scheduleNextFlush()}}takeBatch(){const e=t.options.cacheMaxLength,s=this.events.slice(0,e);return this.events=this.events.slice(e),a(s)}sendBatch(e){const t=JSON.stringify(e),s=m(t)<=p;return!(!s||!d(t))||v(t,s,()=>this.handleServerError())}scheduleNextFlush(){0!==this.events.length&&(this.timeoutID=i(this.timeoutID,100,()=>this.flush()))}async flushOfflineCache(){this.loadOfflineCache(),await this.flush()}async send(e,h=!1){const n=t.options;if(!c(e))return;const r=u(this.id,e),o=l(r)?await r:r;if(o){if(s.info(`Type: ${e.type}`,o),this.events.push(o),!this.isOnline)return this.events=this.events.slice(-n.maxQueueLength),void this.saveOfflineCache();this.timeoutID&&clearTimeout(this.timeoutID),h||this.events.length>=n.cacheMaxLength?await this.flush():this.timeoutID=i(this.timeoutID,n.cacheWaitingTime,()=>this.flush())}}}let y=null;function O(){y?.dispose(),y=null}var j=new Proxy({},{get(e,t){y??=new g;const s=Reflect.get(y,t,y);return"function"==typeof s?s.bind(y):s}});export{g as DataReporter,j as default,O as resetReporter};
@@ -1 +1 @@
1
- "use strict";require("../constants/index.cjs"),require("../types/enums.cjs"),require("../utils/sentry.cjs"),require("../utils/is-type.cjs");var e=require("../utils/logger.cjs");exports.initNetworkListener=function(n){n.setOnline(!1!==navigator.onLine),globalThis.addEventListener("online",()=>{n.setOnline(!0),e.sentryLogger.info("Network is back online, flushing cache"),n.loadOfflineCache(),n.flush()}),globalThis.addEventListener("offline",()=>{n.setOnline(!1),e.sentryLogger.info("Network is offline, caching events")})};
1
+ "use strict";require("../constants/index.cjs"),require("../types/enums.cjs"),require("../utils/sentry.cjs"),require("../utils/is-type.cjs");var e=require("../utils/logger.cjs");exports.initNetworkListener=function(n){n.setOnline(!1!==navigator.onLine);const i=()=>{n.setOnline(!0),e.sentryLogger.info("Network is back online, flushing cache"),n.flush()},s=()=>{n.setOnline(!1),e.sentryLogger.info("Network is offline, caching events")};return globalThis.addEventListener("online",i),globalThis.addEventListener("offline",s),()=>{globalThis.removeEventListener("online",i),globalThis.removeEventListener("offline",s)}};
@@ -1 +1 @@
1
- import"../constants/index.js";import"../types/enums.js";import"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as n}from"../utils/logger.js";function e(e){e.setOnline(!1!==navigator.onLine),globalThis.addEventListener("online",()=>{e.setOnline(!0),n.info("Network is back online, flushing cache"),e.loadOfflineCache(),e.flush()}),globalThis.addEventListener("offline",()=>{e.setOnline(!1),n.info("Network is offline, caching events")})}export{e as initNetworkListener};
1
+ import"../constants/index.js";import"../types/enums.js";import"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as e}from"../utils/logger.js";function n(n){n.setOnline(!1!==navigator.onLine);const i=()=>{n.setOnline(!0),e.info("Network is back online, flushing cache"),n.flush()},t=()=>{n.setOnline(!1),e.info("Network is offline, caching events")};return globalThis.addEventListener("online",i),globalThis.addEventListener("offline",t),()=>{globalThis.removeEventListener("online",i),globalThis.removeEventListener("offline",t)}}export{n as initNetworkListener};
@@ -1 +1 @@
1
- "use strict";require("../constants/index.cjs"),require("../types/enums.cjs");var e=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var t=require("../utils/logger.cjs"),r=require("./report-data-schema.cjs");exports.loadOfflineCache=function(){try{const t=localStorage.getItem(e.default.options.offlineCacheKey);if(!t)return[];const a=JSON.parse(t),s=r.reportDataListSchema.safeParse(a);return s.success?(localStorage.removeItem(e.default.options.offlineCacheKey),s.data.slice(-e.default.options.maxQueueLength)):[]}catch{return localStorage.removeItem(e.default.options.offlineCacheKey),[]}},exports.saveOfflineCache=function(r){try{localStorage.setItem(e.default.options.offlineCacheKey,JSON.stringify(r.slice(-e.default.options.maxQueueLength)))}catch{t.sentryLogger.error("Failed to save offline cache")}};
1
+ "use strict";require("../constants/index.cjs"),require("../types/enums.cjs");var e=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var t=require("../utils/logger.cjs"),r=require("./report-data-schema.cjs");exports.clearOfflineCache=function(){try{localStorage.removeItem(e.default.options.offlineCacheKey)}catch{t.sentryLogger.error("Failed to clear offline cache")}},exports.loadOfflineCache=function(){try{const t=localStorage.getItem(e.default.options.offlineCacheKey);if(!t)return[];const a=JSON.parse(t),o=r.reportDataListSchema.safeParse(a);return o.success?(localStorage.removeItem(e.default.options.offlineCacheKey),o.data.slice(-e.default.options.maxQueueLength)):[]}catch{return localStorage.removeItem(e.default.options.offlineCacheKey),[]}},exports.saveOfflineCache=function(r){try{localStorage.setItem(e.default.options.offlineCacheKey,JSON.stringify(r.slice(-e.default.options.maxQueueLength)))}catch{t.sentryLogger.error("Failed to save offline cache")}};
@@ -1 +1 @@
1
- import"../constants/index.js";import"../types/enums.js";import e from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as t}from"../utils/logger.js";import{reportDataListSchema as o}from"./report-data-schema.js";function s(){try{const t=localStorage.getItem(e.options.offlineCacheKey);if(!t)return[];const s=JSON.parse(t),r=o.safeParse(s);return r.success?(localStorage.removeItem(e.options.offlineCacheKey),r.data.slice(-e.options.maxQueueLength)):[]}catch{return localStorage.removeItem(e.options.offlineCacheKey),[]}}function r(o){try{localStorage.setItem(e.options.offlineCacheKey,JSON.stringify(o.slice(-e.options.maxQueueLength)))}catch{t.error("Failed to save offline cache")}}export{s as loadOfflineCache,r as saveOfflineCache};
1
+ import"../constants/index.js";import"../types/enums.js";import e from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as o}from"../utils/logger.js";import{reportDataListSchema as t}from"./report-data-schema.js";function r(){try{const o=localStorage.getItem(e.options.offlineCacheKey);if(!o)return[];const r=JSON.parse(o),s=t.safeParse(r);return s.success?(localStorage.removeItem(e.options.offlineCacheKey),s.data.slice(-e.options.maxQueueLength)):[]}catch{return localStorage.removeItem(e.options.offlineCacheKey),[]}}function s(t){try{localStorage.setItem(e.options.offlineCacheKey,JSON.stringify(t.slice(-e.options.maxQueueLength)))}catch{o.error("Failed to save offline cache")}}function a(){try{localStorage.removeItem(e.options.offlineCacheKey)}catch{o.error("Failed to clear offline cache")}}export{a as clearOfflineCache,r as loadOfflineCache,s as saveOfflineCache};
@@ -1 +1 @@
1
- "use strict";var e=require("zod"),t=require("../types/enums.cjs");const r=e.z.object({browserName:e.z.string(),browserVersion:e.z.string(),osName:e.z.string(),osVersion:e.z.string(),userAgent:e.z.string(),deviceType:e.z.string(),deviceModel:e.z.string(),fingerprint:e.z.string(),language:e.z.string(),screenResolution:e.z.string()}),s=e.z.object({id:e.z.string(),type:e.z.enum(t.EventType),name:e.z.string(),time:e.z.string(),timestamp:e.z.number(),message:e.z.string(),status:e.z.enum(t.Status),url:e.z.string(),userId:e.z.string(),projectId:e.z.string(),sdkVersion:e.z.string(),deviceInfo:r,payload:e.z.custom(e=>"object"==typeof e&&null!==e,"Expected a report payload object")}),n=e.z.array(s);exports.deviceInfoSchema=r,exports.reportDataListSchema=n,exports.reportDataSchema=s;
1
+ "use strict";var e=require("zod"),t=require("../types/enums.cjs");const r=e.z.object({browserName:e.z.string(),browserVersion:e.z.string(),osName:e.z.string(),osVersion:e.z.string(),userAgent:e.z.string(),deviceType:e.z.string(),deviceModel:e.z.string(),language:e.z.string(),screenResolution:e.z.string()}),s=e.z.object({id:e.z.string(),type:e.z.enum(t.EventType),name:e.z.string(),time:e.z.string(),timestamp:e.z.number(),message:e.z.string(),status:e.z.enum(t.Status),url:e.z.string(),userId:e.z.string(),anonymousId:e.z.string(),visitorId:e.z.string(),projectId:e.z.string(),sdkVersion:e.z.string(),breadcrumbs:e.z.array(e.z.custom(e=>"object"==typeof e&&null!==e,"Expected a breadcrumb item object")).optional(),deviceInfo:r,payload:e.z.custom(e=>"object"==typeof e&&null!==e,"Expected a report payload object")}),n=e.z.array(s);exports.reportDataListSchema=n;
@@ -1 +1 @@
1
- import{z as e}from"zod";import{Status as r,EventType as t}from"../types/enums.js";const s=e.object({browserName:e.string(),browserVersion:e.string(),osName:e.string(),osVersion:e.string(),userAgent:e.string(),deviceType:e.string(),deviceModel:e.string(),fingerprint:e.string(),language:e.string(),screenResolution:e.string()}),n=e.object({id:e.string(),type:e.enum(t),name:e.string(),time:e.string(),timestamp:e.number(),message:e.string(),status:e.enum(r),url:e.string(),userId:e.string(),projectId:e.string(),sdkVersion:e.string(),deviceInfo:s,payload:e.custom(e=>"object"==typeof e&&null!==e,"Expected a report payload object")}),i=e.array(n);export{s as deviceInfoSchema,i as reportDataListSchema,n as reportDataSchema};
1
+ import{z as e}from"zod";import{Status as t,EventType as r}from"../types/enums.js";const s=e.object({browserName:e.string(),browserVersion:e.string(),osName:e.string(),osVersion:e.string(),userAgent:e.string(),deviceType:e.string(),deviceModel:e.string(),language:e.string(),screenResolution:e.string()}),n=e.object({id:e.string(),type:e.enum(r),name:e.string(),time:e.string(),timestamp:e.number(),message:e.string(),status:e.enum(t),url:e.string(),userId:e.string(),anonymousId:e.string(),visitorId:e.string(),projectId:e.string(),sdkVersion:e.string(),breadcrumbs:e.array(e.custom(e=>"object"==typeof e&&null!==e,"Expected a breadcrumb item object")).optional(),deviceInfo:s,payload:e.custom(e=>"object"==typeof e&&null!==e,"Expected a report payload object")}),o=e.array(n);export{o as reportDataListSchema};
@@ -1 +1 @@
1
- "use strict";var e=require("../constants/index.cjs");require("../types/enums.cjs");var t=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var r=require("./promise.cjs");function s(r,s){const{type:o,name:n,time:i,timestamp:a,message:u,status:p}=s;return{type:o,name:n,time:i,timestamp:a,message:u,status:p,id:r,url:location.href,userId:t.default.options.userId,projectId:t.default.options.projectId,sdkVersion:e.SDK_VERSION,deviceInfo:t.default.deviceInfo,payload:s}}function o(e){return!1===e?null:e}exports.payloadToReportData=s,exports.runBeforeReportHook=function(e,n){const i=s(e,n);if(!t.default.options.onBeforeReportData)return i;const a=t.default.options.onBeforeReportData(i);return r.isPromise(a)?a.then(o):o(a)};
1
+ "use strict";var e=require("../constants/index.cjs"),t=require("../core/breadcrumb.cjs"),r=require("../types/enums.cjs"),o=require("../utils/sentry.cjs");require("../utils/is-type.cjs"),require("../utils/logger.cjs");var n=require("./promise.cjs");const s=new Set([r.EventType.Error,r.EventType.UnhandledRejection,r.EventType.Resource,r.EventType.Vue,r.EventType.React,r.EventType.OtherFrameworks]);function u(e){return!1===e?null:e}function i(e){return!1===e?[]:[...e]}exports.applyBeforePushHook=function(e){const t=o.default.options.beforeSendBatch?o.default.options.beforeSendBatch(e):e;return n.isPromise(t)?t.then(i):i(t)},exports.runBeforeReportHook=function(r,i){const a=function(r,n){const{type:u,name:i,time:a,timestamp:d,message:c,status:p}=n,f={type:u,name:i,time:a,timestamp:d,message:c,status:p,id:r,url:location.href,userId:o.default.options.userId,anonymousId:o.default.options.anonymousId,visitorId:o.default.options.visitorId,projectId:o.default.options.projectId,sdkVersion:e.SDK_VERSION,deviceInfo:o.default.deviceInfo,payload:n};return s.has(u)&&(f.breadcrumbs=t.default.dump()),f}(r,i);if(!o.default.options.beforeSend)return a;const d=o.default.options.beforeSend(a);return n.isPromise(d)?d.then(u):u(d)};
@@ -1 +1 @@
1
- import{SDK_VERSION as t}from"../constants/index.js";import"../types/enums.js";import e from"../utils/sentry.js";import"../utils/is-type.js";import{isPromise as o}from"./promise.js";function s(o,s){const{type:n,name:r,time:i,timestamp:p,message:m,status:a}=s;return{type:n,name:r,time:i,timestamp:p,message:m,status:a,id:o,url:location.href,userId:e.options.userId,projectId:e.options.projectId,sdkVersion:t,deviceInfo:e.deviceInfo,payload:s}}function n(t,n){const i=s(t,n);if(!e.options.onBeforeReportData)return i;const p=e.options.onBeforeReportData(i);return o(p)?p.then(r):r(p)}function r(t){return!1===t?null:t}export{s as payloadToReportData,n as runBeforeReportHook};
1
+ import{SDK_VERSION as o}from"../constants/index.js";import t from"../core/breadcrumb.js";import{EventType as e}from"../types/enums.js";import n from"../utils/sentry.js";import"../utils/is-type.js";import"../utils/logger.js";import{isPromise as r}from"./promise.js";const s=new Set([e.Error,e.UnhandledRejection,e.Resource,e.Vue,e.React,e.OtherFrameworks]);function i(e,i){const u=function(e,r){const{type:i,name:m,time:u,timestamp:p,message:c,status:d}=r,a={type:i,name:m,time:u,timestamp:p,message:c,status:d,id:e,url:location.href,userId:n.options.userId,anonymousId:n.options.anonymousId,visitorId:n.options.visitorId,projectId:n.options.projectId,sdkVersion:o,deviceInfo:n.deviceInfo,payload:r};return s.has(i)&&(a.breadcrumbs=t.dump()),a}(e,i);if(!n.options.beforeSend)return u;const p=n.options.beforeSend(u);return r(p)?p.then(m):m(p)}function m(o){return!1===o?null:o}function u(o){const t=n.options.beforeSendBatch?n.options.beforeSendBatch(o):o;return r(t)?t.then(p):p(t)}function p(o){return!1===o?[]:[...o]}export{u as applyBeforePushHook,i as runBeforeReportHook};
@@ -1 +1 @@
1
- "use strict";require("../constants/index.cjs"),require("../types/enums.cjs");var e=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var r=require("../utils/logger.cjs"),t=require("./timer.cjs");function s(i,n){n.setOnline(!1),i&&clearTimeout(i);const c=setTimeout(()=>{!function(t){fetch(e.default.options.dsn,{method:"HEAD"}).then(e=>{e.ok?(t.setOnline(!0),r.sentryLogger.info("Server is back available, flushing cache"),t.loadOfflineCache(),t.flush()):s(void 0,t)}).catch(()=>{s(void 0,t)})}(n)},e.default.options.retryIntervalMilliseconds);return t.unrefTimer(c),n.setRetryTimer(c),c}exports.scheduleServerRecovery=s;
1
+ "use strict";require("../constants/index.cjs"),require("../types/enums.cjs");var e=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var r=require("../utils/logger.cjs"),t=require("./timer.cjs");function s(i,n){n.setOnline(!1),i&&clearTimeout(i);const u=setTimeout(()=>{!function(t){fetch(e.default.options.dsn,{method:"HEAD"}).then(e=>{e.ok?(t.setOnline(!0),r.sentryLogger.info("Server is back available, flushing cache"),t.flush()):s(void 0,t)}).catch(()=>{s(void 0,t)})}(n)},e.default.options.retryIntervalMilliseconds);return t.unrefTimer(u),n.setRetryTimer(u),u}exports.scheduleServerRecovery=s;
@@ -1 +1 @@
1
- import"../constants/index.js";import"../types/enums.js";import t from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as e}from"../utils/logger.js";import{unrefTimer as i}from"./timer.js";function o(s,n){n.setOnline(!1),s&&clearTimeout(s);const r=setTimeout(()=>{!function(i){fetch(t.options.dsn,{method:"HEAD"}).then(t=>{t.ok?(i.setOnline(!0),e.info("Server is back available, flushing cache"),i.loadOfflineCache(),i.flush()):o(void 0,i)}).catch(()=>{o(void 0,i)})}(n)},t.options.retryIntervalMilliseconds);return i(r),n.setRetryTimer(r),r}export{o as scheduleServerRecovery};
1
+ import"../constants/index.js";import"../types/enums.js";import t from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as e}from"../utils/logger.js";import{unrefTimer as i}from"./timer.js";function s(o,n){n.setOnline(!1),o&&clearTimeout(o);const r=setTimeout(()=>{!function(i){fetch(t.options.dsn,{method:"HEAD"}).then(t=>{t.ok?(i.setOnline(!0),e.info("Server is back available, flushing cache"),i.flush()):s(void 0,i)}).catch(()=>{s(void 0,i)})}(n)},t.options.retryIntervalMilliseconds);return i(r),n.setRetryTimer(r),r}export{s as scheduleServerRecovery};
@@ -1 +1 @@
1
- "use strict";require("../constants/index.cjs"),require("../types/enums.cjs");var e=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var t=require("../utils/logger.cjs");exports.isObjectOverSizeLimit=function(e,t){const n=JSON.stringify(e);return(new TextEncoder).encode(n).byteLength>1024*t},exports.reportByFetch=async function(n,r){try{const t=await fetch(e.default.options.dsn,{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json"},keepalive:!0});return t.ok||r(),t.ok}catch(e){return t.sentryLogger.error("Fetch report failed",e),r(),!1}},exports.reportByImage=function(t,n){const{dsn:r}=e.default.options;n.push(()=>{const e=new Image,n=r.includes("?")?"&":"?";e.src=`${r}${n}data=${encodeURIComponent(JSON.stringify(t))}`})},exports.sendBeacon=function(t){return!("undefined"==typeof navigator||!navigator.sendBeacon)&&navigator.sendBeacon(e.default.options.dsn,JSON.stringify(t))};
1
+ "use strict";require("../constants/index.cjs"),require("../types/enums.cjs");var e=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var t=require("../utils/logger.cjs");exports.MAX_KEEPALIVE_BYTES=61440,exports.getBodyByteLength=function(e){return(new TextEncoder).encode(e).byteLength},exports.reportByFetch=async function(n,r,o){try{const t=await fetch(e.default.options.dsn,{method:"POST",body:n,headers:{"Content-Type":"application/json"},keepalive:r});return t.ok||o(),t.ok}catch(e){return t.sentryLogger.error("Fetch report failed",e),o(),!1}},exports.sendBeacon=function(t){return!("undefined"==typeof navigator||!navigator.sendBeacon)&&navigator.sendBeacon(e.default.options.dsn,t)};
@@ -1 +1 @@
1
- import"../constants/index.js";import"../types/enums.js";import n from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as t}from"../utils/logger.js";function e(n,t){const e=JSON.stringify(n);return(new TextEncoder).encode(e).byteLength>1024*t}function o(t){return!("undefined"==typeof navigator||!navigator.sendBeacon)&&navigator.sendBeacon(n.options.dsn,JSON.stringify(t))}async function s(e,o){try{const t=await fetch(n.options.dsn,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"},keepalive:!0});return t.ok||o(),t.ok}catch(n){return t.error("Fetch report failed",n),o(),!1}}function i(t,e){const{dsn:o}=n.options;e.push(()=>{const n=new Image,e=o.includes("?")?"&":"?";n.src=`${o}${e}data=${encodeURIComponent(JSON.stringify(t))}`})}export{e as isObjectOverSizeLimit,s as reportByFetch,i as reportByImage,o as sendBeacon};
1
+ import"../constants/index.js";import"../types/enums.js";import t from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as n}from"../utils/logger.js";const e=61440;function o(t){return(new TextEncoder).encode(t).byteLength}function r(n){return!("undefined"==typeof navigator||!navigator.sendBeacon)&&navigator.sendBeacon(t.options.dsn,n)}async function s(e,o,r){try{const n=await fetch(t.options.dsn,{method:"POST",body:e,headers:{"Content-Type":"application/json"},keepalive:o});return n.ok||r(),n.ok}catch(t){return n.error("Fetch report failed",t),r(),!1}}export{e as MAX_KEEPALIVE_BYTES,o as getBodyByteLength,s as reportByFetch,r as sendBeacon};
@@ -0,0 +1 @@
1
+ "use strict";var n=require("source-map"),t=require("zod");const e=t.z.object({version:t.z.union([t.z.number(),t.z.string()]),sources:t.z.array(t.z.string().nullable()),names:t.z.array(t.z.string()),mappings:t.z.string()}),r=t.z.looseObject({type:t.z.string().optional(),name:t.z.string().optional(),payload:t.z.looseObject({line:t.z.number().optional(),column:t.z.number().optional(),extra:t.z.unknown().optional(),stack:t.z.unknown().optional()}).optional()}),s=/^\s*at (?:(.+?)\s+)?\(?(\S+?):(\d+):(\d+)\)?\s*$/,o=/^\s*(?:(.*?)@)?(\S+?):(\d+):(\d+)\s*$/;function a(n){const t=[];for(const e of n.split("\n")){if(t.length>=30)break;const n=s.exec(e)??o.exec(e);if(!n)continue;const[,r,a,c,i]=n;if(!a||!c||!i)continue;const u={url:a,line:Number.parseInt(c,10),column:Number.parseInt(i,10)};r&&(u.func=r),t.push(u)}return t}async function c(t,r){const s={resolved:!1,...r};try{const o=await t(r.url);return e.safeParse(o).success?await n.SourceMapConsumer.with(JSON.stringify(o),null,n=>{const t=n.originalPositionFor({line:r.line,column:Math.max(0,r.column-1)});if(null===t.source||null===t.line)return s;const e=n.sourceContentFor(t.source,!0),o={...s,resolved:!0,source:t.source,originalLine:t.line};return null!==t.column&&(o.originalColumn=t.column),null!==t.name&&(o.name=t.name),e&&(o.snippet=function(n,t){const e=n.split("\n"),r=Math.max(1,t-3),s=Math.min(e.length,t+3),o=[];for(let n=r;n<=s;n++)o.push({line:n,code:e[n-1]??"",highlight:n===t});return o}(e,t.line)),o}):s}catch{return s}}async function i(n,t){const e=a(t),r=[];for(const t of e)r.push(await c(n,t));return r}const u=t.z.looseObject({stack:t.z.string().optional()});async function l(n,t){const e=r.safeParse(t);if(!e.success)return t;const s=e.data,o=s.payload;if(!o)return t;const a=[];if("Error"===s.type&&"string"==typeof s.name&&"number"==typeof o.line&&"number"==typeof o.column)a.push(await c(n,{url:s.name,line:o.line,column:o.column}));else if("string"==typeof o.extra&&(l=o.extra,/(^|\n)\s*at .+:\d+:\d+/.test(l)||/@.+:\d+:\d+/.test(l)))a.push(...await i(n,o.extra));else if("React"===s.type||"Vue"===s.type||"OtherFrameworks"===s.type){const t=function(n){if("string"==typeof n.stack)return n.stack;const t=u.safeParse(n.extra);return t.success&&"string"==typeof t.data.stack?t.data.stack:null}(o);t&&a.push(...await i(n,t))}var l;return 0===a.length?t:{...s,sourcemap:{frames:a}}}exports.enrichReportData=async function(n,t){if(!Array.isArray(t))return t;const e=[];for(const r of t)e.push(await l(n,r));return e},exports.parseStack=a,exports.resolveFrame=c,exports.resolveStack=i,exports.splitScriptUrl=function(n){try{const t=new URL(n);return{pathname:t.pathname,search:t.search}}catch{const t=n.search(/[?#]/);return-1!==t?{pathname:n.slice(0,t),search:n.slice(t)}:{pathname:n,search:""}}};
@@ -0,0 +1 @@
1
+ import{SourceMapConsumer as n}from"source-map";import{z as t}from"zod";const e=t.object({version:t.union([t.number(),t.string()]),sources:t.array(t.string().nullable()),names:t.array(t.string()),mappings:t.string()}),r=t.looseObject({type:t.string().optional(),name:t.string().optional(),payload:t.looseObject({line:t.number().optional(),column:t.number().optional(),extra:t.unknown().optional(),stack:t.unknown().optional()}).optional()}),o=/^\s*at (?:(.+?)\s+)?\(?(\S+?):(\d+):(\d+)\)?\s*$/,s=/^\s*(?:(.*?)@)?(\S+?):(\d+):(\d+)\s*$/;function a(n){const t=[];for(const e of n.split("\n")){if(t.length>=30)break;const n=o.exec(e)??s.exec(e);if(!n)continue;const[,r,a,c,i]=n;if(!a||!c||!i)continue;const u={url:a,line:Number.parseInt(c,10),column:Number.parseInt(i,10)};r&&(u.func=r),t.push(u)}return t}function c(n){try{const t=new URL(n);return{pathname:t.pathname,search:t.search}}catch{const t=n.search(/[?#]/);return-1!==t?{pathname:n.slice(0,t),search:n.slice(t)}:{pathname:n,search:""}}}async function i(t,r){const o={resolved:!1,...r};try{const s=await t(r.url);return e.safeParse(s).success?await n.with(JSON.stringify(s),null,n=>{const t=n.originalPositionFor({line:r.line,column:Math.max(0,r.column-1)});if(null===t.source||null===t.line)return o;const e=n.sourceContentFor(t.source,!0),s={...o,resolved:!0,source:t.source,originalLine:t.line};return null!==t.column&&(s.originalColumn=t.column),null!==t.name&&(s.name=t.name),e&&(s.snippet=function(n,t){const e=n.split("\n"),r=Math.max(1,t-3),o=Math.min(e.length,t+3),s=[];for(let n=r;n<=o;n++)s.push({line:n,code:e[n-1]??"",highlight:n===t});return s}(e,t.line)),s}):o}catch{return o}}async function u(n,t){const e=a(t),r=[];for(const t of e)r.push(await i(n,t));return r}const l=t.looseObject({stack:t.string().optional()});async function p(n,t){const e=r.safeParse(t);if(!e.success)return t;const o=e.data,s=o.payload;if(!s)return t;const a=[];if("Error"===o.type&&"string"==typeof o.name&&"number"==typeof s.line&&"number"==typeof s.column)a.push(await i(n,{url:o.name,line:s.line,column:s.column}));else if("string"==typeof s.extra&&(c=s.extra,/(^|\n)\s*at .+:\d+:\d+/.test(c)||/@.+:\d+:\d+/.test(c)))a.push(...await u(n,s.extra));else if("React"===o.type||"Vue"===o.type||"OtherFrameworks"===o.type){const t=function(n){if("string"==typeof n.stack)return n.stack;const t=l.safeParse(n.extra);return t.success&&"string"==typeof t.data.stack?t.data.stack:null}(s);t&&a.push(...await u(n,t))}var c;return 0===a.length?t:{...o,sourcemap:{frames:a}}}async function f(n,t){if(!Array.isArray(t))return t;const e=[];for(const r of t)e.push(await p(n,r));return e}export{f as enrichReportData,a as parseStack,i as resolveFrame,u as resolveStack,c as splitScriptUrl};
@@ -0,0 +1 @@
1
+ "use strict";var r=require("./source-map.cjs");exports.enrichReportData=async function(t,e){return r.enrichReportData(function(t){return async e=>{const{pathname:a,search:n}=r.splitScriptUrl(e),u=await t.moduleGraph.getModuleByUrl(a+n)??await t.moduleGraph.getModuleByUrl(a);return u?.transformResult?.map??null}}(t),e)};
@@ -0,0 +1 @@
1
+ import{enrichReportData as r,splitScriptUrl as a}from"./source-map.js";async function t(t,e){return r(function(r){return async t=>{const{pathname:e,search:n}=a(t),o=await r.moduleGraph.getModuleByUrl(e+n)??await r.moduleGraph.getModuleByUrl(e);return o?.transformResult?.map??null}}(t),e)}export{t as enrichReportData};
@@ -0,0 +1 @@
1
+ "use strict";var t=require("./source-map.cjs");function e(t){return t.replace(/\\/g,"/").replace(/^\/+/,"")}exports.enrichReportData=t.enrichReportData,exports.createAssetMapStore=function(){const r=new Map;return{put:(t,n)=>{const a=e(t);a.endsWith(".map")&&r.set(a,n)},loadMap:async n=>{const{pathname:a}=t.splitScriptUrl(n),p=e(a);if(!p)return null;let s=r.get(`${p}.map`);if(void 0===s){const t=`${p.split("/").pop()}.map`;for(const[e,n]of r)if(e===t||e.endsWith(`/${t}`)){s=n;break}}if(void 0===s)return null;try{return JSON.parse(s)}catch{return null}}}};
@@ -0,0 +1 @@
1
+ import{splitScriptUrl as t}from"./source-map.js";export{enrichReportData}from"./source-map.js";function r(t){return t.replace(/\\/g,"/").replace(/^\/+/,"")}function e(){const e=new Map;return{put:(t,n)=>{const o=r(t);o.endsWith(".map")&&e.set(o,n)},loadMap:async n=>{const{pathname:o}=t(n),p=r(o);if(!p)return null;let a=e.get(`${p}.map`);if(void 0===a){const t=`${p.split("/").pop()}.map`;for(const[r,n]of e)if(r===t||r.endsWith(`/${t}`)){a=n;break}}if(void 0===a)return null;try{return JSON.parse(a)}catch{return null}}}}export{e as createAssetMapStore};
@@ -1,4 +1,4 @@
1
- import { EventType, Status, HttpMethod, BreadcrumbType } from './enums.js';
1
+ import { EventType, Status, BreadcrumbType } from './enums.js';
2
2
  import { Metric } from 'web-vitals';
3
3
  import { IOptions } from './options.js';
4
4
 
@@ -29,7 +29,6 @@ interface ISentry {
29
29
  has(value: string): boolean;
30
30
  add(value: string): void;
31
31
  };
32
- whiteScreenTimer: ReturnType<typeof setInterval> | null;
33
32
  options: IOptions;
34
33
  shouldScreenRecord: boolean;
35
34
  deviceInfo: IDeviceInfo;
@@ -46,7 +45,6 @@ interface IDeviceInfo {
46
45
  userAgent: string;
47
46
  deviceType: string;
48
47
  deviceModel: string;
49
- fingerprint: string;
50
48
  language: string;
51
49
  screenResolution: string;
52
50
  }
@@ -62,7 +60,7 @@ interface IReportPayload {
62
60
  status: Status;
63
61
  }
64
62
  interface IHttpData extends IReportPayload {
65
- method: HttpMethod | string;
63
+ method: string;
66
64
  api: string;
67
65
  elapsedTime: number;
68
66
  statusCode: number;
@@ -106,10 +104,10 @@ type IPerformanceData = IPerformanceMetricData | IPerformanceResourceListData |
106
104
  interface ICodeError extends IReportPayload {
107
105
  line: number;
108
106
  column: number;
107
+ extra?: string;
109
108
  }
110
109
  interface IScreenRecordData extends IReportPayload {
111
110
  event: string;
112
- events?: string;
113
111
  eventCount?: number;
114
112
  }
115
113
  interface IExposureData extends IReportPayload {
@@ -127,7 +125,7 @@ interface IRouteData extends IReportPayload {
127
125
  to: string;
128
126
  }
129
127
  type IBaseDataWithEvent = IReportPayload & {
130
- extra: "WhiteScreen" | unknown;
128
+ extra: unknown;
131
129
  };
132
130
  type TReportPayload = IBaseDataWithEvent | IHttpData | IResourceError | IPerformanceData | ICodeError | IExposureData | IScreenRecordData | IRouteData | IBatchErrorData;
133
131
  interface IBatchErrorData extends IReportPayload {
@@ -135,19 +133,21 @@ interface IBatchErrorData extends IReportPayload {
135
133
  batchErrorLength: number;
136
134
  batchErrorLastHappenTime: number;
137
135
  }
138
- type TOnReportWhiteScreenData = (data: IReportPayload) => void;
136
+ type TOnReportWhiteScreenData = (data: IBaseDataWithEvent) => void;
139
137
  type TOnReportPerformanceData = (data: IPerformanceData) => void;
140
138
  interface IReportData<T extends TReportPayload = TReportPayload> extends IReportPayload {
141
139
  url: string;
142
140
  userId: string;
141
+ anonymousId: string;
142
+ visitorId: string;
143
143
  projectId: string;
144
144
  sdkVersion: string;
145
- breadcrumbs?: IBreadcrumbItem[];
145
+ breadcrumbs?: IBreadcrumbItem[] | undefined;
146
146
  deviceInfo: IDeviceInfo;
147
147
  payload: T;
148
148
  }
149
149
  interface IDataReporter {
150
- send(payload: TReportPayload): Promise<void>;
150
+ send(payload: TReportPayload, immediate?: boolean): Promise<void>;
151
151
  flushOfflineCache(): Promise<void>;
152
152
  }
153
153
  /**
@@ -163,6 +163,5 @@ interface IExtendedErrorEvent extends Event {
163
163
  localName: string;
164
164
  };
165
165
  }
166
- type TUnknownError = IExtendedErrorEvent | Error /** React */ | unknown;
167
166
 
168
- export type { IBaseDataWithEvent, IBatchErrorData, IBreadcrumbItem, ICodeError, IDataReporter, IDeviceInfo, IExposureData, IExtendedErrorEvent, IHttpData, IPerformanceData, IPerformanceResourceTiming, IReportData, IReportPayload, IResourceError, IRouteData, IScreenRecordData, ISentry, TOnReportPerformanceData, TOnReportWhiteScreenData, TReportPayload, TUnknownError };
167
+ export type { IBaseDataWithEvent, IBatchErrorData, IBreadcrumbItem, ICodeError, IDataReporter, IDeviceInfo, IExposureData, IExtendedErrorEvent, IHttpData, IPerformanceData, IPerformanceResourceTiming, IReportData, IReportPayload, IResourceError, IRouteData, IScreenRecordData, ISentry, TOnReportPerformanceData, TOnReportWhiteScreenData, TReportPayload };
@@ -1 +1 @@
1
- "use strict";var e,t,o,r,a,n,s;exports.HttpStatus=void 0,(e=exports.HttpStatus||(exports.HttpStatus={})).OK="OK",e.BadRequest="Bad Request",e.Unauthorized="Unauthorized",e.Forbidden="Forbidden",e.NotFound="NotFound",e.Conflict="Conflict",e.PayloadTooLarge="Payload Too Large",e.TooManyRequests="Too Many Requests",e.InternalServerError="Internal Server Error",e.NotImplemented="Not Implemented",e.ServiceUnavailable="Service Unavailable",e.GatewayTimeout="Gateway Timeout",e.UnknownError="Unknown Error",exports.BreadcrumbType=void 0,(t=exports.BreadcrumbType||(exports.BreadcrumbType={})).Http="Http",t.Click="Click",t.Route="Route",t.Resource="Resource",t.CodeError="Code Error",t.Custom="Custom",exports.Status=void 0,(o=exports.Status||(exports.Status={})).Error="Error",o.OK="OK",exports.EventType=void 0,(r=exports.EventType||(exports.EventType={})).Xhr="XMLHttpRequest",r.Fetch="fetch",r.Click="Click",r.HashChange="Event hashchange",r.History="History",r.Resource="Resource",r.UnhandledRejection="Event unhandledrejection",r.Error="Error",r.Vue="Vue",r.React="React",r.OtherFrameworks="OtherFrameworks",r.Performance="Performance",r.ScreenRecord="ScreenRecord",r.Exposure="Exposure",r.WhiteScreen="WhiteScreen",r.Custom="Custom",r.PV="PV",exports.HttpType=void 0,(a=exports.HttpType||(exports.HttpType={})).Xhr="XMLHttpRequest",a.Fetch="fetch",exports.HttpStatusCode=void 0,(n=exports.HttpStatusCode||(exports.HttpStatusCode={}))[n.OK=200]="OK",n[n.BadRequest=400]="BadRequest",n[n.Unauthorized=401]="Unauthorized",n[n.Forbidden=403]="Forbidden",n[n.NotFound=404]="NotFound",n[n.Conflict=409]="Conflict",n[n.PayloadTooLarge=413]="PayloadTooLarge",n[n.TooManyRequests=429]="TooManyRequests",n[n.InternalServerError=500]="InternalServerError",n[n.NotImplemented=501]="NotImplemented",n[n.ServiceUnavailable=503]="ServiceUnavailable",n[n.GatewayTimeout=504]="GatewayTimeout",exports.HttpMethod=void 0,(s=exports.HttpMethod||(exports.HttpMethod={})).Get="GET",s.Head="HEAD",s.Post="POST",s.Put="PUT",s.Delete="DELETE",s.Connect="CONNECT",s.Options="OPTIONS",s.Trace="TRACE",s.Patch="PATCH";
1
+ "use strict";var e,r,t;exports.BreadcrumbType=void 0,(e=exports.BreadcrumbType||(exports.BreadcrumbType={})).Http="Http",e.Click="Click",e.Route="Route",e.Resource="Resource",e.CodeError="Code Error",e.Custom="Custom",exports.Status=void 0,(r=exports.Status||(exports.Status={})).Error="Error",r.OK="OK",exports.EventType=void 0,(t=exports.EventType||(exports.EventType={})).Xhr="XMLHttpRequest",t.Fetch="fetch",t.Click="Click",t.HashChange="Event hashchange",t.History="History",t.Resource="Resource",t.UnhandledRejection="Event unhandledrejection",t.Error="Error",t.Vue="Vue",t.React="React",t.OtherFrameworks="OtherFrameworks",t.Performance="Performance",t.ScreenRecord="ScreenRecord",t.Exposure="Exposure",t.WhiteScreen="WhiteScreen",t.Custom="Custom",t.PV="PV";