@swifty.js/sentry 0.0.1 → 0.0.3

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 (117) hide show
  1. package/README.md +27 -42
  2. package/dist/core/api.cjs +1 -1
  3. package/dist/core/api.js +1 -1
  4. package/dist/core/breadcrumb.cjs +1 -1
  5. package/dist/core/breadcrumb.js +1 -1
  6. package/dist/core/bus.cjs +1 -1
  7. package/dist/core/bus.js +1 -1
  8. package/dist/core/decorate-http.cjs +1 -0
  9. package/dist/core/decorate-http.js +1 -0
  10. package/dist/core/decorate-route.cjs +1 -0
  11. package/dist/core/decorate-route.js +1 -0
  12. package/dist/core/decorates.cjs +1 -0
  13. package/dist/core/decorates.js +1 -0
  14. package/dist/core/framework-error.cjs +1 -1
  15. package/dist/core/framework-error.d.ts +32 -0
  16. package/dist/core/framework-error.js +1 -1
  17. package/dist/core/handle-code-error.cjs +1 -1
  18. package/dist/core/handle-code-error.js +1 -1
  19. package/dist/core/handle-error.cjs +1 -1
  20. package/dist/core/handle-error.js +1 -1
  21. package/dist/core/handle-events.cjs +1 -1
  22. package/dist/core/handle-events.js +1 -1
  23. package/dist/core/handle-http.cjs +1 -1
  24. package/dist/core/handle-http.js +1 -1
  25. package/dist/core/handle-route.cjs +1 -1
  26. package/dist/core/handle-route.js +1 -1
  27. package/dist/core/identity.cjs +1 -1
  28. package/dist/core/identity.js +1 -1
  29. package/dist/core/ip.d.ts +21 -0
  30. package/dist/core/pv-lifecycle.cjs +1 -1
  31. package/dist/core/pv-lifecycle.js +1 -1
  32. package/dist/core/sdk-lifecycle.cjs +1 -1
  33. package/dist/core/sdk-lifecycle.d.ts +22 -0
  34. package/dist/core/sdk-lifecycle.js +1 -1
  35. package/dist/core/setup.cjs +1 -1
  36. package/dist/core/setup.js +1 -1
  37. package/dist/core/white-screen.cjs +1 -1
  38. package/dist/core/white-screen.js +1 -1
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +1 -1
  42. package/dist/package.json.cjs +1 -1
  43. package/dist/package.json.js +1 -1
  44. package/dist/plugins/exposure/index.cjs +1 -1
  45. package/dist/plugins/exposure/index.d.ts +22 -0
  46. package/dist/plugins/exposure/index.js +1 -1
  47. package/dist/plugins/performance/index.cjs +1 -1
  48. package/dist/plugins/performance/index.d.ts +22 -0
  49. package/dist/plugins/performance/index.js +1 -1
  50. package/dist/plugins/performance/navigation-timing.cjs +1 -1
  51. package/dist/plugins/performance/navigation-timing.js +1 -1
  52. package/dist/plugins/performance/perf.cjs +1 -1
  53. package/dist/plugins/performance/perf.js +1 -1
  54. package/dist/plugins/performance/resource-element-fallback.cjs +1 -1
  55. package/dist/plugins/performance/resource-element-fallback.js +1 -1
  56. package/dist/plugins/performance/resource-timing.cjs +1 -1
  57. package/dist/plugins/performance/resource-timing.js +1 -1
  58. package/dist/plugins/screen-record/index.cjs +1 -1
  59. package/dist/plugins/screen-record/index.d.ts +22 -0
  60. package/dist/plugins/screen-record/index.js +1 -1
  61. package/dist/plugins/screen-record/recorder.cjs +1 -1
  62. package/dist/plugins/screen-record/recorder.d.ts +22 -0
  63. package/dist/plugins/screen-record/recorder.js +1 -1
  64. package/dist/preact.cjs +1 -0
  65. package/dist/preact.d.ts +74 -0
  66. package/dist/preact.js +1 -0
  67. package/dist/react.d.ts +22 -0
  68. package/dist/reporter/batch.cjs +1 -1
  69. package/dist/reporter/batch.js +1 -1
  70. package/dist/reporter/index.cjs +1 -1
  71. package/dist/reporter/index.js +1 -1
  72. package/dist/reporter/network-listener.cjs +1 -1
  73. package/dist/reporter/network-listener.js +1 -1
  74. package/dist/reporter/offline-cache.cjs +1 -1
  75. package/dist/reporter/offline-cache.js +1 -1
  76. package/dist/reporter/report-data-schema.cjs +1 -1
  77. package/dist/reporter/report-data-schema.js +1 -1
  78. package/dist/reporter/report-data.cjs +1 -1
  79. package/dist/reporter/report-data.js +1 -1
  80. package/dist/reporter/send-preflight.cjs +1 -1
  81. package/dist/reporter/send-preflight.js +1 -1
  82. package/dist/reporter/server-recovery.cjs +1 -1
  83. package/dist/reporter/server-recovery.js +1 -1
  84. package/dist/reporter/transports.cjs +1 -1
  85. package/dist/reporter/transports.js +1 -1
  86. package/dist/sourcemap/sourcemap.cjs +1 -0
  87. package/dist/sourcemap/sourcemap.js +1 -0
  88. package/dist/sourcemap/vite.cjs +1 -0
  89. package/dist/sourcemap/vite.js +1 -0
  90. package/dist/sourcemap/webpack.cjs +1 -0
  91. package/dist/sourcemap/webpack.js +1 -0
  92. package/dist/types/common.d.ts +31 -3
  93. package/dist/types/enums.cjs +1 -1
  94. package/dist/types/enums.d.ts +22 -1
  95. package/dist/types/enums.js +1 -1
  96. package/dist/types/handlers.d.ts +22 -0
  97. package/dist/types/options.d.ts +22 -0
  98. package/dist/types/plugin.d.ts +22 -0
  99. package/dist/utils/click-data.cjs +1 -1
  100. package/dist/utils/click-data.js +1 -1
  101. package/dist/utils/decorate-prop.d.ts +21 -0
  102. package/dist/utils/is-type.cjs +1 -1
  103. package/dist/utils/is-type.js +1 -1
  104. package/dist/vite.cjs +1 -1
  105. package/dist/vite.d.ts +22 -0
  106. package/dist/vite.js +1 -1
  107. package/dist/vue.d.ts +22 -0
  108. package/dist/webpack.cjs +1 -1
  109. package/dist/webpack.d.ts +22 -0
  110. package/dist/webpack.js +1 -1
  111. package/package.json +23 -7
  112. package/dist/core/decorate-http-publish.cjs +0 -1
  113. package/dist/core/decorate-http-publish.js +0 -1
  114. package/dist/core/decorate-publish.cjs +0 -1
  115. package/dist/core/decorate-publish.js +0 -1
  116. package/dist/core/decorate-route-publish.cjs +0 -1
  117. package/dist/core/decorate-route-publish.js +0 -1
package/README.md CHANGED
@@ -24,11 +24,7 @@ npm install vue
24
24
 
25
25
  ```ts
26
26
  import { init, destroy, isInitialized, pluginEnable } from "@swifty.js/sentry";
27
- import {
28
- PerformancePlugin,
29
- ScreenRecordPlugin,
30
- ExposurePlugin,
31
- } from "@swifty.js/sentry/plugins";
27
+ import { PerformancePlugin, ScreenRecordPlugin, ExposurePlugin } from "@swifty.js/sentry/plugins";
32
28
  import { ReactErrorBoundary } from "@swifty.js/sentry/react";
33
29
  import { vuePlugin } from "@swifty.js/sentry/vue";
34
30
  ```
@@ -39,11 +35,7 @@ Each public export provides ESM, CJS, and TypeScript declaration files.
39
35
 
40
36
  ```ts
41
37
  import { init, pluginEnable } from "@swifty.js/sentry";
42
- import {
43
- PerformancePlugin,
44
- ScreenRecordPlugin,
45
- ExposurePlugin,
46
- } from "@swifty.js/sentry/plugins";
38
+ import { PerformancePlugin, ScreenRecordPlugin, ExposurePlugin } from "@swifty.js/sentry/plugins";
47
39
 
48
40
  init({
49
41
  dsn: "/api/log",
@@ -294,30 +286,30 @@ tracePageView({
294
286
 
295
287
  ## Declarative Clicks
296
288
 
297
- Declarative click tracking uses `s-swifty-*` attributes. Plain clicks are not reported unless the clicked element or one of its composed path ancestors has a tracking attribute.
289
+ Declarative click tracking uses `swifty-sentry-*` attributes. Plain clicks are not reported unless the clicked element or one of its composed path ancestors has a tracking attribute.
298
290
 
299
291
  ```html
300
- <section s-swifty-view="profile-card" s-swifty-src="home">
301
- <button s-swifty-ev="save-profile" s-swifty-msg="Save">Save</button>
292
+ <section swifty-sentry-el="profile-card" swifty-sentry-src="home">
293
+ <button swifty-sentry-ev="save-profile" swifty-sentry-msg="Save">Save</button>
302
294
  </section>
303
295
  ```
304
296
 
305
297
  Reserved attributes:
306
298
 
307
- | Attribute | Description |
308
- | --------------- | ------------------------------ |
309
- | `s-swifty-ev` | Explicit event ID. |
310
- | `s-swifty-msg` | Human-readable message. |
311
- | `s-swifty-view` | View ID and event ID fallback. |
299
+ | Attribute | Description |
300
+ | ------------------- | ------------------------------ |
301
+ | `swifty-sentry-ev` | Explicit event ID. |
302
+ | `swifty-sentry-msg` | Human-readable message. |
303
+ | `swifty-sentry-el` | View ID and event ID fallback. |
312
304
 
313
- Custom `s-swifty-*` attributes become `params`.
305
+ Custom `swifty-sentry-*` attributes become `params`.
314
306
 
315
307
  ```html
316
308
  <a
317
- s-swifty-ev="open-banner"
318
- s-swifty-msg="Open campaign banner"
319
- s-swifty-campaign="spring"
320
- s-swifty-rank="1"
309
+ swifty-sentry-ev="open-banner"
310
+ swifty-sentry-msg="Open campaign banner"
311
+ swifty-sentry-campaign="spring"
312
+ swifty-sentry-rank="1"
321
313
  >
322
314
  Campaign
323
315
  </a>
@@ -325,16 +317,16 @@ Custom `s-swifty-*` attributes become `params`.
325
317
 
326
318
  The reported click payload (`DeclarativeClickData`) includes:
327
319
 
328
- | Field | Type | Description |
329
- | ---------------- | ------------------------------------------ | ------------------------------------------------------------------------- |
330
- | `ev` | `string` | Event ID (from `s-swifty-ev`, `title`, `s-swifty-view`, or tag). |
331
- | `msg` | `string` | Human-readable message (from `s-swifty-msg`, text, `aria-label`, or tag). |
332
- | `triggerPageUrl` | `string` | Current page URL (`location.href`). |
333
- | `x` | `number` | Click X coordinate (element offset + scroll offset). |
334
- | `y` | `number` | Click Y coordinate (element offset + scroll offset). |
335
- | `params` | `Readonly<Record<string, string \| null>>` | Custom `s-swifty-*` attributes (excluding reserved keys). |
336
- | `elementPath` | `string` | XPath-like path from element to body (max 128 characters). |
337
- | `triggerTime` | `number` | `Date.now()` at click time. |
320
+ | Field | Type | Description |
321
+ | ---------------- | ------------------------------------------ | ------------------------------------------------------------------------------ |
322
+ | `ev` | `string` | Event ID (from `swifty-sentry-ev`, `title`, `swifty-sentry-el`, or tag). |
323
+ | `msg` | `string` | Human-readable message (from `swifty-sentry-msg`, text, `aria-label`, or tag). |
324
+ | `triggerPageUrl` | `string` | Current page URL (`location.href`). |
325
+ | `x` | `number` | Click X coordinate (element offset + scroll offset). |
326
+ | `y` | `number` | Click Y coordinate (element offset + scroll offset). |
327
+ | `params` | `Readonly<Record<string, string \| null>>` | Custom `swifty-sentry-*` attributes (excluding reserved keys). |
328
+ | `elementPath` | `string` | XPath-like path from element to body (max 128 characters). |
329
+ | `triggerTime` | `number` | `Date.now()` at click time. |
338
330
 
339
331
  ## White-Screen Detection
340
332
 
@@ -439,11 +431,7 @@ await sendLocal();
439
431
  Register hooks after initialization or provide equivalent hooks in `init` options.
440
432
 
441
433
  ```ts
442
- import {
443
- afterSendData,
444
- beforePushEventList,
445
- beforeSendData,
446
- } from "@swifty.js/sentry";
434
+ import { afterSendData, beforePushEventList, beforeSendData } from "@swifty.js/sentry";
447
435
 
448
436
  beforeSendData((data) => {
449
437
  if (data.type === "Click") {
@@ -585,10 +573,7 @@ Unsupported browser capabilities are skipped safely.
585
573
 
586
574
  ```ts
587
575
  import { pluginEnable } from "@swifty.js/sentry";
588
- import {
589
- ScreenRecordPlugin,
590
- unzipScreenRecord,
591
- } from "@swifty.js/sentry/plugins";
576
+ import { ScreenRecordPlugin, unzipScreenRecord } from "@swifty.js/sentry/plugins";
592
577
 
593
578
  pluginEnable(ScreenRecordPlugin);
594
579
 
package/dist/core/api.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("../types/enums.cjs");require("../constants/index.cjs");var t=require("../utils/get-base-data.cjs"),r=require("../utils/sentry.cjs"),a=require("./handle-error.cjs");require("./breadcrumb.cjs");var s=require("../reporter/index.cjs");exports.afterSendData=function(e){r.default.setOptions({afterSendData:e})},exports.beforePushEventList=function(e){r.default.setOptions({beforePushEventList:e})},exports.beforeSendData=function(e){r.default.setOptions({onBeforeReportData:e})},exports.getBaseInfo=function(){return t.default()},exports.getUserId=function(){return r.default.options.userId},exports.sendLocal=async function(){await s.default.flushOfflineCache()},exports.traceCustomEvent=function(r){s.default.send({...t.default(),type:e.EventType.Custom,status:e.Status.OK,name:r.name,message:r.message,extra:r.extra})},exports.traceError=function(r){a.handleError({...t.default(),type:e.EventType.Error,status:e.Status.Error,extra:r})},exports.tracePageView=function(r={}){s.default.send({...t.default(),type:e.EventType.PV,name:r.name??"ManualPageView",message:r.message??location.href,status:e.Status.OK,extra:r.extra??{url:location.href,referrer:document.referrer}})},exports.tracePerformance=function(r){s.default.send({...t.default(),type:e.EventType.Performance,status:e.Status.OK,...r})};
1
+ "use strict";var e=require("../types/enums.cjs");require("../constants/index.cjs");var t=require("../utils/get-base-data.cjs"),r=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var a=require("./handle-error.cjs");require("./breadcrumb.cjs");var s=require("../reporter/index.cjs");exports.afterSendData=function(e){r.default.setOptions({afterSendData:e})},exports.beforePushEventList=function(e){r.default.setOptions({beforePushEventList:e})},exports.beforeSendData=function(e){r.default.setOptions({onBeforeReportData:e})},exports.getBaseInfo=function(){return t.default()},exports.getUserId=function(){return r.default.options.userId},exports.sendLocal=async function(){await s.default.flushOfflineCache()},exports.traceCustomEvent=function(r){s.default.send({...t.default(),type:e.EventType.Custom,status:e.Status.OK,name:r.name,message:r.message,extra:r.extra})},exports.traceError=function(r){a.handleError({...t.default(),type:e.EventType.Error,status:e.Status.Error,extra:r})},exports.tracePageView=function(r={}){s.default.send({...t.default(),type:e.EventType.PV,name:r.name??"ManualPageView",message:r.message??location.href,status:e.Status.OK,extra:r.extra??{url:location.href,referrer:document.referrer}})},exports.tracePerformance=function(r){s.default.send({...t.default(),type:e.EventType.Performance,status:e.Status.OK,...r})};
package/dist/core/api.js CHANGED
@@ -1 +1 @@
1
- import{Status as e,EventType as t}from"../types/enums.js";import"../constants/index.js";import r from"../utils/get-base-data.js";import n from"../utils/sentry.js";import{handleError as s}from"./handle-error.js";import"./breadcrumb.js";import o from"../reporter/index.js";function a(n){s({...r(),type:t.Error,status:e.Error,extra:n})}function i(n){o.send({...r(),type:t.Performance,status:e.OK,...n})}function u(n){o.send({...r(),type:t.Custom,status:e.OK,name:n.name,message:n.message,extra:n.extra})}function f(n={}){o.send({...r(),type:t.PV,name:n.name??"ManualPageView",message:n.message??location.href,status:e.OK,extra:n.extra??{url:location.href,referrer:document.referrer}})}function m(){return n.options.userId}function p(){return r()}function c(e){n.setOptions({onBeforeReportData:e})}function d(e){n.setOptions({beforePushEventList:e})}function l(e){n.setOptions({afterSendData:e})}async function x(){await o.flushOfflineCache()}export{l as afterSendData,d as beforePushEventList,c as beforeSendData,p as getBaseInfo,m as getUserId,x as sendLocal,u as traceCustomEvent,a as traceError,f as tracePageView,i as tracePerformance};
1
+ import{Status as e,EventType as t}from"../types/enums.js";import"../constants/index.js";import r from"../utils/get-base-data.js";import n from"../utils/sentry.js";import"../utils/is-type.js";import{handleError as s}from"./handle-error.js";import"./breadcrumb.js";import o from"../reporter/index.js";function a(n){s({...r(),type:t.Error,status:e.Error,extra:n})}function i(n){o.send({...r(),type:t.Performance,status:e.OK,...n})}function u(n){o.send({...r(),type:t.Custom,status:e.OK,name:n.name,message:n.message,extra:n.extra})}function f(n={}){o.send({...r(),type:t.PV,name:n.name??"ManualPageView",message:n.message??location.href,status:e.OK,extra:n.extra??{url:location.href,referrer:document.referrer}})}function m(){return n.options.userId}function p(){return r()}function c(e){n.setOptions({onBeforeReportData:e})}function d(e){n.setOptions({beforePushEventList:e})}function l(e){n.setOptions({afterSendData:e})}async function j(){await o.flushOfflineCache()}export{l as afterSendData,d as beforePushEventList,c as beforeSendData,p as getBaseInfo,m as getUserId,j as sendLocal,u as traceCustomEvent,a as traceError,f as tracePageView,i as tracePerformance};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../utils/data-structures.cjs");require("../types/enums.cjs");var s=require("../utils/sentry.cjs");class t extends e.MinHeap{static#e;static get instance(){return t.#e||(t.#e=new t),t.#e}push(e){const{onBeforePushBreadcrumb:t}=s.default.options;return t&&(e=t(e)),super.push(e)}}const r=t.instance;exports.Breadcrumb=t,exports.default=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../utils/data-structures.cjs");require("../types/enums.cjs");var s=require("../utils/sentry.cjs");require("../utils/is-type.cjs");class t extends e.MinHeap{static#e;static get instance(){return t.#e||(t.#e=new t),t.#e}push(e){const{onBeforePushBreadcrumb:t}=s.default.options;return t&&(e=t(e)),super.push(e)}}const r=t.instance;exports.Breadcrumb=t,exports.default=r;
@@ -1 +1 @@
1
- import{MinHeap as s}from"../utils/data-structures.js";import"../types/enums.js";import t from"../utils/sentry.js";class e extends s{static#s;static get instance(){return e.#s||(e.#s=new e),e.#s}push(s){const{onBeforePushBreadcrumb:e}=t.options;return e&&(s=e(s)),super.push(s)}}const n=e.instance;export{e as Breadcrumb,n as default};
1
+ import{MinHeap as s}from"../utils/data-structures.js";import"../types/enums.js";import t from"../utils/sentry.js";import"../utils/is-type.js";class e extends s{static#s;static get instance(){return e.#s||(e.#s=new e),e.#s}push(s){const{onBeforePushBreadcrumb:e}=t.options;return e&&(s=e(s)),super.push(s)}}const n=e.instance;export{e as Breadcrumb,n as default};
package/dist/core/bus.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";require("../constants/index.cjs"),require("../types/enums.cjs"),require("../utils/sentry.cjs");var e=require("../utils/logger.cjs");const r=new Map;exports.clearSubscriptions=()=>{r.clear()},exports.pub=(t,s)=>{const n=r.get(t);if(n)for(const r of n)try{r(s)}catch(r){e.sentryLogger.error("Error executing event handler",r)}},exports.sub=(e,t)=>{const s=r.get(e);return s?(s.add(t),()=>{s.delete(t)}):(r.set(e,new Set([t])),()=>{r.get(e)?.delete(t)})};
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");const r=new Map;exports.clearSubscriptions=()=>{r.clear()},exports.pub=(t,s)=>{const c=r.get(t);if(c)for(const r of c)try{r(s)}catch(r){e.sentryLogger.error("Error executing event handler",r)}},exports.sub=(e,t)=>{const s=r.get(e);return s?(s.add(t),()=>{s.delete(t)}):(r.set(e,new Set([t])),()=>{r.get(e)?.delete(t)})};
package/dist/core/bus.js CHANGED
@@ -1 +1 @@
1
- import"../constants/index.js";import"../types/enums.js";import"../utils/sentry.js";import{sentryLogger as e}from"../utils/logger.js";const t=new Map,r=(r,o)=>{const s=t.get(r);if(s)for(const t of s)try{t(o)}catch(t){e.error("Error executing event handler",t)}},o=(e,r)=>{const o=t.get(e);return o?(o.add(r),()=>{o.delete(r)}):(t.set(e,new Set([r])),()=>{t.get(e)?.delete(r)})},s=()=>{t.clear()};export{s as clearSubscriptions,r as pub,o as sub};
1
+ import"../constants/index.js";import"../types/enums.js";import"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as t}from"../utils/logger.js";const e=new Map,r=(r,s)=>{const o=e.get(r);if(o)for(const e of o)try{e(s)}catch(e){t.error("Error executing event handler",e)}},s=(t,r)=>{const s=e.get(t);return s?(s.add(r),()=>{s.delete(r)}):(e.set(t,new Set([r])),()=>{e.get(t)?.delete(r)})},o=()=>{e.clear()};export{o as clearSubscriptions,r as pub,s as sub};
@@ -0,0 +1 @@
1
+ "use strict";var e=require("../types/enums.cjs");require("../constants/index.cjs");var t=require("../utils/decorate-prop.cjs"),s=require("../utils/get-base-data.cjs"),r=require("../utils/is-excluded-api.cjs"),n=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var i=require("../utils/server-timing.cjs"),a=require("./bus.cjs");function o(t,s){return t.toUpperCase()===e.HttpMethod.Post&&s===n.default.options.dsn||r.default(s)}exports.pubFetch=function(){return t.default(globalThis,"fetch",t=>async function(r,n){const u=n?.method?.toUpperCase()??e.HttpMethod.Get,p={...s.default(),type:e.EventType.Fetch,method:u,requestData:{body:n?.body},name:"Fetch",api:r.toString(),elapsedTime:0,statusCode:e.HttpStatusCode.OK};return t.call(globalThis,r,n).then(t=>{const s=t.clone();return p.elapsedTime=Date.now()-p.timestamp,p.statusCode=s.status,p.serverTiming=i.getServerTimingFromHeaders(s.headers),s.text().then(t=>{o(u,r.toString())||(p.responseData=t,a.pub(e.EventType.Fetch,p))}).catch(()=>{o(u,r.toString())||a.pub(e.EventType.Fetch,p)}),t}).catch(t=>{throw o(u,r.toString())||(p.elapsedTime=Date.now()-p.timestamp,p.statusCode=0,p.message=t instanceof Error?t.message:"Network error",a.pub(e.EventType.Fetch,p)),t})})},exports.pubXhr=function(){const r=XMLHttpRequest.prototype,n=t.default(r,"open",t=>function(r,n,i,...a){return this.__sentry__={...s.default(),name:"XMLHttpRequest",type:e.EventType.Xhr,method:r.toUpperCase(),api:n,elapsedTime:0,statusCode:e.HttpStatusCode.OK},t.call(this,r,n,i,...a)}),u=t.default(r,"send",t=>function(s){if(!this.__sentry__)return t.call(this,s);const{method:r,api:n}=this.__sentry__;return this.addEventListener("loadend",()=>{o(r,n)||(this.__sentry__.statusCode=this.status,this.__sentry__.requestData={body:s},this.__sentry__.responseData={responseType:this.responseType,response:this.response},this.__sentry__.serverTiming=i.parseServerTiming(this.getResponseHeader("server-timing")),this.__sentry__.elapsedTime=Date.now()-this.__sentry__.timestamp,a.pub(e.EventType.Xhr,this.__sentry__))}),t.call(this,s)});return()=>{u(),n()}};
@@ -0,0 +1 @@
1
+ import{EventType as t,HttpStatusCode as e,HttpMethod as s}from"../types/enums.js";import"../constants/index.js";import r from"../utils/decorate-prop.js";import o from"../utils/get-base-data.js";import i from"../utils/is-excluded-api.js";import n from"../utils/sentry.js";import"../utils/is-type.js";import{parseServerTiming as a,getServerTimingFromHeaders as p}from"../utils/server-timing.js";import{pub as m}from"./bus.js";function _(){const s=XMLHttpRequest.prototype,i=r(s,"open",s=>function(r,i,n,...a){return this.__sentry__={...o(),name:"XMLHttpRequest",type:t.Xhr,method:r.toUpperCase(),api:i,elapsedTime:0,statusCode:e.OK},s.call(this,r,i,n,...a)}),n=r(s,"send",e=>function(s){if(!this.__sentry__)return e.call(this,s);const{method:r,api:o}=this.__sentry__;return this.addEventListener("loadend",()=>{u(r,o)||(this.__sentry__.statusCode=this.status,this.__sentry__.requestData={body:s},this.__sentry__.responseData={responseType:this.responseType,response:this.response},this.__sentry__.serverTiming=a(this.getResponseHeader("server-timing")),this.__sentry__.elapsedTime=Date.now()-this.__sentry__.timestamp,m(t.Xhr,this.__sentry__))}),e.call(this,s)});return()=>{n(),i()}}function h(){return r(globalThis,"fetch",r=>async function(i,n){const a=n?.method?.toUpperCase()??s.Get,_={...o(),type:t.Fetch,method:a,requestData:{body:n?.body},name:"Fetch",api:i.toString(),elapsedTime:0,statusCode:e.OK};return r.call(globalThis,i,n).then(e=>{const s=e.clone();return _.elapsedTime=Date.now()-_.timestamp,_.statusCode=s.status,_.serverTiming=p(s.headers),s.text().then(e=>{u(a,i.toString())||(_.responseData=e,m(t.Fetch,_))}).catch(()=>{u(a,i.toString())||m(t.Fetch,_)}),e}).catch(e=>{throw u(a,i.toString())||(_.elapsedTime=Date.now()-_.timestamp,_.statusCode=0,_.message=e instanceof Error?e.message:"Network error",m(t.Fetch,_)),e})})}function u(t,e){return t.toUpperCase()===s.Post&&e===n.options.dsn||i(e)}export{h as pubFetch,_ as pubXhr};
@@ -0,0 +1 @@
1
+ "use strict";var t=require("../types/enums.cjs");require("../constants/index.cjs");var e=require("../utils/decorate-prop.cjs"),s=require("../utils/get-base-data.cjs");require("../utils/sentry.cjs"),require("../utils/is-type.cjs");var r=require("./bus.cjs");let o="";function i(){return"document"in globalThis?globalThis.document.location.href:""}exports.pubHistory=function(){const n=globalThis.onpopstate;o=i(),globalThis.onpopstate=function(e){const u=o,l=i();return u===l?n?.call(this,e):(o=l,r.pub(t.EventType.History,{...s.default(),type:t.EventType.History,from:u,to:l}),"function"==typeof n?n.call(this,e):void 0)};const u=e=>function(n,u,l){if(l){const a=o,c=function(t){return new URL(t.toString(),i()).href}(l);if(a===c)return e.call(this,n,u,l);o=c,r.pub(t.EventType.History,{...s.default(),type:t.EventType.History,from:a,to:c})}return e.call(this,n,u,l)},l=e.default(globalThis.history,"pushState",u),a=e.default(globalThis.history,"replaceState",u);return()=>{globalThis.onpopstate=n,a(),l()}};
@@ -0,0 +1 @@
1
+ import{EventType as t}from"../types/enums.js";import"../constants/index.js";import o from"../utils/decorate-prop.js";import s from"../utils/get-base-data.js";import"../utils/sentry.js";import"../utils/is-type.js";import{pub as i}from"./bus.js";let r="";function n(){return"document"in globalThis?globalThis.document.location.href:""}function e(){const e=globalThis.onpopstate;r=n(),globalThis.onpopstate=function(o){const l=r,a=n();return l===a?e?.call(this,o):(r=a,i(t.History,{...s(),type:t.History,from:l,to:a}),"function"==typeof e?e.call(this,o):void 0)};const l=o=>function(e,l,a){if(a){const p=r,u=function(t){return new URL(t.toString(),n()).href}(a);if(p===u)return o.call(this,e,l,a);r=u,i(t.History,{...s(),type:t.History,from:p,to:u})}return o.call(this,e,l,a)},a=o(globalThis.history,"pushState",l),p=o(globalThis.history,"replaceState",l);return()=>{globalThis.onpopstate=e,p(),a()}}export{e as pubHistory};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../types/enums.cjs");require("../constants/index.cjs");var t=require("../utils/decorate-prop.cjs"),r=require("../utils/get-base-data.cjs"),n=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var i=require("../utils/throttle.cjs"),c=require("./bus.cjs"),u=require("./decorate-http.cjs"),s=require("./decorate-route.cjs");function a(){}exports.default=function(o){switch(o){case e.EventType.Click:return function(){const t=i.throttle(c.pub,n.default.options.clickThrottleDelay),u=function(n){t(e.EventType.Click,{...r.default(),type:e.EventType.Click,extra:n})};return document.addEventListener("click",u),()=>{document.removeEventListener("click",u)}}();case e.EventType.Error:return function(){const n=function(t){c.pub(e.EventType.Error,{...r.default(),type:e.EventType.Error,extra:t})};globalThis.addEventListener("error",n,!0);let i=!1;const u=t.default(console,"error",t=>function(...n){if(!i){i=!0;try{c.pub(e.EventType.Error,{...r.default(),type:e.EventType.Error,extra:n.find(e=>e instanceof Error)??n.join(" ")})}finally{i=!1}}t.call(this,...n)});return()=>{globalThis.removeEventListener("error",n,!0),u()}}();case e.EventType.Xhr:return u.pubXhr();case e.EventType.Fetch:return u.pubFetch();case e.EventType.History:return s.pubHistory();case e.EventType.UnhandledRejection:return function(){const t=function(t){c.pub(e.EventType.UnhandledRejection,{...r.default(),type:e.EventType.UnhandledRejection,extra:t})};return globalThis.addEventListener("unhandledrejection",t),()=>{globalThis.removeEventListener("unhandledrejection",t)}}();case e.EventType.HashChange:return function(){const t=function(t){c.pub(e.EventType.HashChange,{...r.default(),type:e.EventType.HashChange,extra:t})};return globalThis.addEventListener("hashchange",t),()=>{globalThis.removeEventListener("hashchange",t)}}();case e.EventType.WhiteScreen:return c.pub(e.EventType.WhiteScreen,{...r.default(),type:e.EventType.WhiteScreen,extra:"WhiteScreen"}),a;default:return a}};
@@ -0,0 +1 @@
1
+ import{EventType as e}from"../types/enums.js";import"../constants/index.js";import t from"../utils/decorate-prop.js";import r from"../utils/get-base-data.js";import n from"../utils/sentry.js";import"../utils/is-type.js";import{throttle as o}from"../utils/throttle.js";import{pub as i}from"./bus.js";import{pubFetch as s,pubXhr as c}from"./decorate-http.js";import{pubHistory as a}from"./decorate-route.js";function l(){}function u(u){switch(u){case e.Click:return function(){const t=o(i,n.options.clickThrottleDelay),s=function(n){t(e.Click,{...r(),type:e.Click,extra:n})};return document.addEventListener("click",s),()=>{document.removeEventListener("click",s)}}();case e.Error:return function(){const n=function(t){i(e.Error,{...r(),type:e.Error,extra:t})};globalThis.addEventListener("error",n,!0);let o=!1;const s=t(console,"error",t=>function(...n){if(!o){o=!0;try{i(e.Error,{...r(),type:e.Error,extra:n.find(e=>e instanceof Error)??n.join(" ")})}finally{o=!1}}t.call(this,...n)});return()=>{globalThis.removeEventListener("error",n,!0),s()}}();case e.Xhr:return c();case e.Fetch:return s();case e.History:return a();case e.UnhandledRejection:return function(){const t=function(t){i(e.UnhandledRejection,{...r(),type:e.UnhandledRejection,extra:t})};return globalThis.addEventListener("unhandledrejection",t),()=>{globalThis.removeEventListener("unhandledrejection",t)}}();case e.HashChange:return function(){const t=function(t){i(e.HashChange,{...r(),type:e.HashChange,extra:t})};return globalThis.addEventListener("hashchange",t),()=>{globalThis.removeEventListener("hashchange",t)}}();case e.WhiteScreen:return i(e.WhiteScreen,{...r(),type:e.WhiteScreen,extra:"WhiteScreen"}),l;default:return l}}export{u as default};
@@ -1 +1 @@
1
- "use strict";var r=require("../reporter/index.cjs"),e=require("../types/enums.cjs");require("../constants/index.cjs");var t=require("../utils/get-base-data.cjs");function n(r){if(r instanceof Error)return r.name;if(null===r)return"null";if(void 0===r)return"undefined";if("object"==typeof r){const e=Object.getPrototypeOf(r),t=e?.constructor?.name;return t??"Object"}return typeof r}function o(r){if(r instanceof Error)return r.message;if("string"==typeof r)return r;if(null===r)return"null";if(void 0===r)return"undefined";try{return JSON.stringify(r)}catch{return String(r)}}function u(r){if(r instanceof Error)return r.stack;if(null!==r&&"object"==typeof r){const e=Reflect.get(r,"stack");return"string"==typeof e?e:void 0}}require("../utils/sentry.cjs"),exports.reportFrameworkError=function(i){r.default.send({...t.default(),type:i.type,name:n(i.error),message:o(i.error),status:e.Status.Error,extra:{error:i.error,stack:u(i.error),context:i.context}})};
1
+ "use strict";var r=require("../reporter/index.cjs"),e=require("../types/enums.cjs");require("../constants/index.cjs");var t=require("../utils/get-base-data.cjs");function n(r){if(r instanceof Error)return r.name;if(null===r)return"null";if(void 0===r)return"undefined";if("object"==typeof r){const e=Object.getPrototypeOf(r),t=e?.constructor?.name;return t??"Object"}return typeof r}function i(r){if(r instanceof Error)return r.message;if("string"==typeof r)return r;if(null===r)return"null";if(void 0===r)return"undefined";try{return JSON.stringify(r)}catch{return String(r)}}function o(r){if(r instanceof Error)return r.stack;if(null!==r&&"object"==typeof r){const e=Reflect.get(r,"stack");return"string"==typeof e?e:void 0}}require("../utils/sentry.cjs"),require("../utils/is-type.cjs"),exports.reportFrameworkError=function(u){r.default.send({...t.default(),type:u.type,name:n(u.error),message:i(u.error),status:e.Status.Error,extra:{error:u.error,stack:o(u.error),context:u.context}})};
@@ -0,0 +1,32 @@
1
+ import { EventType } from '../types/enums.js';
2
+
3
+ /**
4
+ * Copyright (c) 2026 hangtiancheng
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ interface FrameworkErrorInput {
26
+ readonly type: EventType.React | EventType.Vue | EventType.OtherFrameworks;
27
+ readonly error: unknown;
28
+ readonly context: unknown;
29
+ }
30
+ declare function reportFrameworkError(input: FrameworkErrorInput): void;
31
+
32
+ export { reportFrameworkError };
@@ -1 +1 @@
1
- import r from"../reporter/index.js";import{Status as t}from"../types/enums.js";import"../constants/index.js";import e from"../utils/get-base-data.js";import"../utils/sentry.js";function n(r){if(r instanceof Error)return r.name;if(null===r)return"null";if(void 0===r)return"undefined";if("object"==typeof r){const t=Object.getPrototypeOf(r),e=t?.constructor?.name;return e??"Object"}return typeof r}function o(r){if(r instanceof Error)return r.message;if("string"==typeof r)return r;if(null===r)return"null";if(void 0===r)return"undefined";try{return JSON.stringify(r)}catch{return String(r)}}function i(r){if(r instanceof Error)return r.stack;if(null!==r&&"object"==typeof r){const t=Reflect.get(r,"stack");return"string"==typeof t?t:void 0}}function s(s){r.send({...e(),type:s.type,name:n(s.error),message:o(s.error),status:t.Error,extra:{error:s.error,stack:i(s.error),context:s.context}})}export{s as reportFrameworkError};
1
+ import r from"../reporter/index.js";import{Status as t}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 n(r){if(r instanceof Error)return r.name;if(null===r)return"null";if(void 0===r)return"undefined";if("object"==typeof r){const t=Object.getPrototypeOf(r),e=t?.constructor?.name;return e??"Object"}return typeof r}function o(r){if(r instanceof Error)return r.message;if("string"==typeof r)return r;if(null===r)return"null";if(void 0===r)return"undefined";try{return JSON.stringify(r)}catch{return String(r)}}function i(r){if(r instanceof Error)return r.stack;if(null!==r&&"object"==typeof r){const t=Reflect.get(r,"stack");return"string"==typeof t?t:void 0}}function s(s){r.send({...e(),type:s.type,name:n(s.error),message:o(s.error),status:t.Error,extra:{error:s.error,stack:i(s.error),context:s.context}})}export{s as reportFrameworkError};
@@ -1 +1 @@
1
- "use strict";var e=require("../types/enums.cjs"),r=require("../utils/base64.cjs"),t=require("../constants/index.cjs"),s=require("../utils/event2breadcrumb.cjs"),o=require("../utils/get-base-data.cjs"),i=require("../utils/sentry.cjs"),u=require("../utils/is-ignored-error.cjs"),a=require("../reporter/index.cjs"),c=require("./breadcrumb.cjs");const n=new class{cacheError=[];timeoutID;push(e){this.cacheError.push(e),this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=setTimeout(()=>this.flush(),2e3)}destroy(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=void 0),this.cacheError=[]}flush(){if(0===this.cacheError.length)return;const e={};for(const r of this.cacheError){const t=`${r.type}-${r.name}-${r.message}`;e[t]=[...e[t]??[],r]}this.cacheError=[];for(const[,r]of Object.entries(e))this.reportGroup(r)}reportGroup(e){if(e.length<5)return void e.forEach(e=>a.default.send(e));const r=e[0];if(!r)return;const t={...r,batchError:!0,batchErrorLength:e.length,batchErrorLastHappenTime:e.at(-1)?.timestamp??r.timestamp};a.default.send(t)}};exports.destroyBatchErrorManager=function(){n.destroy()},exports.handleCodeError=function(a){const{filename:h,colno:d,lineno:l,message:m}=a;if(u.default(m))return;const f={...o.default(),type:e.EventType.Error,name:h,message:m,status:e.Status.Error},p={...f,column:d,line:l};c.default.push({...f,userAction:s.default(e.EventType.Error)});const E=!h||h===t.UNKNOWN,b=r.base64v2(`${e.EventType.Error}-${m}-${h}-${l}-${d}`);(E||i.default.options.repeatCodeError||!i.default.codeErrors.has(b))&&(i.default.codeErrors.add(b),n.push(p))};
1
+ "use strict";var e=require("../types/enums.cjs"),r=require("../utils/base64.cjs"),t=require("../constants/index.cjs"),s=require("../utils/event2breadcrumb.cjs"),o=require("../utils/get-base-data.cjs"),i=require("../utils/sentry.cjs"),u=require("../utils/is-ignored-error.cjs");require("../utils/is-type.cjs");var a=require("../reporter/index.cjs"),c=require("./breadcrumb.cjs");const n=new class{cacheError=[];timeoutID;push(e){this.cacheError.push(e),this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=setTimeout(()=>this.flush(),2e3)}destroy(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=void 0),this.cacheError=[]}flush(){if(0===this.cacheError.length)return;const e={};for(const r of this.cacheError){const t=`${r.type}-${r.name}-${r.message}`;e[t]=[...e[t]??[],r]}this.cacheError=[];for(const[,r]of Object.entries(e))this.reportGroup(r)}reportGroup(e){if(e.length<5)return void e.forEach(e=>a.default.send(e));const r=e[0];if(!r)return;const t={...r,batchError:!0,batchErrorLength:e.length,batchErrorLastHappenTime:e.at(-1)?.timestamp??r.timestamp};a.default.send(t)}};exports.destroyBatchErrorManager=function(){n.destroy()},exports.handleCodeError=function(a){const{filename:h,colno:d,lineno:l,message:m}=a;if(u.default(m))return;const p={...o.default(),type:e.EventType.Error,name:h,message:m,status:e.Status.Error},f={...p,column:d,line:l};c.default.push({...p,userAction:s.default(e.EventType.Error)});const E=!h||h===t.UNKNOWN,b=r.base64v2(`${e.EventType.Error}-${m}-${h}-${l}-${d}`);(E||i.default.options.repeatCodeError||!i.default.codeErrors.has(b))&&(i.default.codeErrors.add(b),n.push(f))};
@@ -1 +1 @@
1
- import{Status as r,EventType as t}from"../types/enums.js";import{base64v2 as o}from"../utils/base64.js";import{UNKNOWN as e}from"../constants/index.js";import s from"../utils/event2breadcrumb.js";import i from"../utils/get-base-data.js";import n from"../utils/sentry.js";import m from"../utils/is-ignored-error.js";import c from"../reporter/index.js";import a from"./breadcrumb.js";const u=new class{cacheError=[];timeoutID;push(r){this.cacheError.push(r),this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=setTimeout(()=>this.flush(),2e3)}destroy(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=void 0),this.cacheError=[]}flush(){if(0===this.cacheError.length)return;const r={};for(const t of this.cacheError){const o=`${t.type}-${t.name}-${t.message}`;r[o]=[...r[o]??[],t]}this.cacheError=[];for(const[,t]of Object.entries(r))this.reportGroup(t)}reportGroup(r){if(r.length<5)return void r.forEach(r=>c.send(r));const t=r[0];if(!t)return;const o={...t,batchError:!0,batchErrorLength:r.length,batchErrorLastHappenTime:r.at(-1)?.timestamp??t.timestamp};c.send(o)}};function h(){u.destroy()}function p(c){const{filename:h,colno:p,lineno:f,message:l}=c;if(m(l))return;const d={...i(),type:t.Error,name:h,message:l,status:r.Error},E={...d,column:p,line:f};a.push({...d,userAction:s(t.Error)});const b=!h||h===e,j=o(`${t.Error}-${l}-${h}-${f}-${p}`);(b||n.options.repeatCodeError||!n.codeErrors.has(j))&&(n.codeErrors.add(j),u.push(E))}export{h as destroyBatchErrorManager,p as handleCodeError};
1
+ import{Status as r,EventType as t}from"../types/enums.js";import{base64v2 as o}from"../utils/base64.js";import{UNKNOWN as e}from"../constants/index.js";import s from"../utils/event2breadcrumb.js";import i from"../utils/get-base-data.js";import n from"../utils/sentry.js";import m from"../utils/is-ignored-error.js";import"../utils/is-type.js";import c from"../reporter/index.js";import u from"./breadcrumb.js";const a=new class{cacheError=[];timeoutID;push(r){this.cacheError.push(r),this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=setTimeout(()=>this.flush(),2e3)}destroy(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=void 0),this.cacheError=[]}flush(){if(0===this.cacheError.length)return;const r={};for(const t of this.cacheError){const o=`${t.type}-${t.name}-${t.message}`;r[o]=[...r[o]??[],t]}this.cacheError=[];for(const[,t]of Object.entries(r))this.reportGroup(t)}reportGroup(r){if(r.length<5)return void r.forEach(r=>c.send(r));const t=r[0];if(!t)return;const o={...t,batchError:!0,batchErrorLength:r.length,batchErrorLastHappenTime:r.at(-1)?.timestamp??t.timestamp};c.send(o)}};function h(){a.destroy()}function p(c){const{filename:h,colno:p,lineno:f,message:l}=c;if(m(l))return;const d={...i(),type:t.Error,name:h,message:l,status:r.Error},E={...d,column:p,line:f};u.push({...d,userAction:s(t.Error)});const j=!h||h===e,b=o(`${t.Error}-${l}-${h}-${f}-${p}`);(j||n.options.repeatCodeError||!n.codeErrors.has(b))&&(n.codeErrors.add(b),a.push(E))}export{h as destroyBatchErrorManager,p as handleCodeError};
@@ -1 +1 @@
1
- "use strict";var e=require("../types/enums.cjs"),r=require("../utils/base64.cjs");require("../constants/index.cjs");var s=require("../utils/event2breadcrumb.cjs"),t=require("../utils/sentry.cjs"),o=require("../utils/is-ignored-error.cjs"),a=require("../utils/is-type.cjs"),n=require("../utils/logger.cjs"),u=require("../reporter/index.cjs"),c=require("./breadcrumb.cjs"),d=require("./handle-code-error.cjs");function i(o){const a={...o,status:e.Status.Error};c.default.push({...a,userAction:s.default(e.EventType.Error)});const n=r.base64v2(`${e.EventType.Error}-${a.name}-${a.message}`);!t.default.options.repeatCodeError&&t.default.codeErrors.has(n)||(t.default.codeErrors.add(n),u.default.send(a))}exports.handleError=({extra:E,...l})=>{n.sentryLogger.error("Error captured",E),a.isErrorEvent(E)?o.default(E.message)||d.handleCodeError(E):a.isIExtendedErrorEvent(E)?function(o,a){const{localName:n,src:d,href:i}=o.target,E={...a,type:e.EventType.Resource,status:e.Status.Error,name:n,src:d,href:i,message:o.message};c.default.push({...E,userAction:s.default(e.EventType.Resource)});const l=r.base64v2(`${e.EventType.Resource}-${n}-${d||i}`);!t.default.options.repeatCodeError&&t.default.codeErrors.has(l)||(t.default.codeErrors.add(l),u.default.send(E))}(E,l):a.isError(E)?function(r,s){const{name:t,message:a,stack:n}=r;if(o.default(a))return;i({...s,type:e.EventType.Error,name:t,message:a,extra:n||r})}(E,l):function(r,s){const t="string"==typeof r?r:JSON.stringify(r);if(o.default(t))return;i({...s,type:e.EventType.Error,name:"Unknown Error",message:t,extra:r})}(E,l)};
1
+ "use strict";var e=require("../types/enums.cjs"),r=require("../utils/base64.cjs");require("../constants/index.cjs");var t=require("../utils/event2breadcrumb.cjs"),s=require("../utils/sentry.cjs"),o=require("../utils/is-ignored-error.cjs"),a=require("../utils/is-type.cjs"),n=require("../utils/logger.cjs"),u=require("../reporter/index.cjs"),d=require("./breadcrumb.cjs"),c=require("./handle-code-error.cjs");function i(o){const a={...o,status:e.Status.Error};d.default.push({...a,userAction:t.default(e.EventType.Error)});const n=r.base64v2(`${e.EventType.Error}-${a.name}-${a.message}`);!s.default.options.repeatCodeError&&s.default.codeErrors.has(n)||(s.default.codeErrors.add(n),u.default.send(a))}exports.handleError=({extra:l,...E})=>{n.sentryLogger.error("Error captured",l),a.isErrorEvent(l)?o.default(l.message)||c.handleCodeError(l):a.isIExtendedErrorEvent(l)?function(o,a){const{localName:n}=o.target,c=o.target.src??"",i=o.target.href??"",l={...a,type:e.EventType.Resource,status:e.Status.Error,name:n,src:c,href:i,message:`Failed to load ${n}: ${c||i}`};d.default.push({...l,userAction:t.default(e.EventType.Resource)});const E=r.base64v2(`${e.EventType.Resource}-${n}-${c||i}`);!s.default.options.repeatCodeError&&s.default.codeErrors.has(E)||(s.default.codeErrors.add(E),u.default.send(l))}(l,E):a.isError(l)?function(r,t){const{name:s,message:a,stack:n}=r;if(o.default(a))return;i({...t,type:e.EventType.Error,name:s,message:a,extra:n||r})}(l,E):function(r,t){const s="string"==typeof r?r:JSON.stringify(r);if(o.default(s))return;i({...t,type:e.EventType.Error,name:"Unknown Error",message:s,extra:r})}(l,E)};
@@ -1 +1 @@
1
- import{Status as r,EventType as e}from"../types/enums.js";import{base64v2 as o}from"../utils/base64.js";import"../constants/index.js";import s from"../utils/event2breadcrumb.js";import t from"../utils/sentry.js";import n from"../utils/is-ignored-error.js";import{isErrorEvent as m,isIExtendedErrorEvent as i,isError as a}from"../utils/is-type.js";import{sentryLogger as c}from"../utils/logger.js";import p from"../reporter/index.js";import u from"./breadcrumb.js";import{handleCodeError as d}from"./handle-code-error.js";const f=({extra:f,...g})=>{c.error("Error captured",f),m(f)?n(f.message)||d(f):i(f)?function(n,m){const{localName:i,src:a,href:c}=n.target,d={...m,type:e.Resource,status:r.Error,name:i,src:a,href:c,message:n.message};u.push({...d,userAction:s(e.Resource)});const f=o(`${e.Resource}-${i}-${a||c}`);!t.options.repeatCodeError&&t.codeErrors.has(f)||(t.codeErrors.add(f),p.send(d))}(f,g):a(f)?function(r,o){const{name:s,message:t,stack:m}=r;if(n(t))return;E({...o,type:e.Error,name:s,message:t,extra:m||r})}(f,g):function(r,o){const s="string"==typeof r?r:JSON.stringify(r);if(n(s))return;E({...o,type:e.Error,name:"Unknown Error",message:s,extra:r})}(f,g)};function E(n){const m={...n,status:r.Error};u.push({...m,userAction:s(e.Error)});const i=o(`${e.Error}-${m.name}-${m.message}`);!t.options.repeatCodeError&&t.codeErrors.has(i)||(t.codeErrors.add(i),p.send(m))}export{f as handleError};
1
+ import{Status as r,EventType as e}from"../types/enums.js";import{base64v2 as o}from"../utils/base64.js";import"../constants/index.js";import s from"../utils/event2breadcrumb.js";import t from"../utils/sentry.js";import n from"../utils/is-ignored-error.js";import{isErrorEvent as a,isIExtendedErrorEvent as i,isError as m}from"../utils/is-type.js";import{sentryLogger as c}from"../utils/logger.js";import p from"../reporter/index.js";import u from"./breadcrumb.js";import{handleCodeError as d}from"./handle-code-error.js";const f=({extra:f,...E})=>{c.error("Error captured",f),a(f)?n(f.message)||d(f):i(f)?function(n,a){const{localName:i}=n.target,m=n.target.src??"",c=n.target.href??"",d={...a,type:e.Resource,status:r.Error,name:i,src:m,href:c,message:`Failed to load ${i}: ${m||c}`};u.push({...d,userAction:s(e.Resource)});const f=o(`${e.Resource}-${i}-${m||c}`);!t.options.repeatCodeError&&t.codeErrors.has(f)||(t.codeErrors.add(f),p.send(d))}(f,E):m(f)?function(r,o){const{name:s,message:t,stack:a}=r;if(n(t))return;g({...o,type:e.Error,name:s,message:t,extra:a||r})}(f,E):function(r,o){const s="string"==typeof r?r:JSON.stringify(r);if(n(s))return;g({...o,type:e.Error,name:"Unknown Error",message:s,extra:r})}(f,E)};function g(n){const a={...n,status:r.Error};u.push({...a,userAction:s(e.Error)});const i=o(`${e.Error}-${a.name}-${a.message}`);!t.options.repeatCodeError&&t.codeErrors.has(i)||(t.codeErrors.add(i),p.send(a))}export{f as handleError};
@@ -1 +1 @@
1
- "use strict";var e=require("../types/enums.cjs");require("../constants/index.cjs");var r=require("../utils/click-data.cjs"),t=require("../utils/event2breadcrumb.cjs"),s=require("../utils/sentry.cjs"),n=require("../utils/is-type.cjs"),a=require("../utils/logger.cjs"),i=require("../reporter/index.cjs"),u=require("./breadcrumb.cjs"),c=require("./white-screen.cjs"),d=require("./handle-code-error.cjs"),l=require("./handle-error.cjs");exports.handleClick=({extra:n,...a})=>{if(!(n instanceof MouseEvent))return;const c=r.getDeclarativeClickData(n);if(!c)return;const d={...a,type:e.EventType.Click,name:c.ev||c.msg,message:c.msg||c.ev,status:e.Status.OK,extra:c};u.default.push({...d,userAction:t.default(e.EventType.Click)}),s.default.options.enableClick&&i.default.send(d)},exports.handleUnhandledRejection=e=>{a.sentryLogger.error("Unhandled rejection captured",e.extra),n.isIExtendedErrorEvent(e.extra)?d.handleCodeError(e.extra):l.handleError(e)},exports.handleWhiteScreen=e=>{c.default(()=>{i.default.send(e)})};
1
+ "use strict";var e=require("../types/enums.cjs");require("../constants/index.cjs");var r=require("../utils/click-data.cjs"),t=require("../utils/event2breadcrumb.cjs"),s=require("../utils/sentry.cjs"),n=require("../utils/is-type.cjs"),a=require("../utils/logger.cjs"),i=require("../reporter/index.cjs"),u=require("./breadcrumb.cjs"),c=require("./white-screen.cjs"),l=require("./handle-code-error.cjs"),d=require("./handle-error.cjs");exports.handleClick=({extra:n,...a})=>{if(!(n instanceof MouseEvent))return;const c=r.getDeclarativeClickData(n);if(!c)return;const l={...a,type:e.EventType.Click,name:c.ev||c.msg,message:c.msg||c.ev,status:e.Status.OK,extra:c};u.default.push({...l,userAction:t.default(e.EventType.Click)}),s.default.options.enableClick&&i.default.send(l)},exports.handleUnhandledRejection=e=>{a.sentryLogger.error("Unhandled rejection captured",e.extra),n.isErrorEvent(e.extra)?l.handleCodeError(e.extra):d.handleError(e)},exports.handleWhiteScreen=e=>{c.default(()=>{i.default.send(e)})};
@@ -1 +1 @@
1
- import{Status as r,EventType as e}from"../types/enums.js";import"../constants/index.js";import{getDeclarativeClickData as t}from"../utils/click-data.js";import o from"../utils/event2breadcrumb.js";import s from"../utils/sentry.js";import{isIExtendedErrorEvent as i}from"../utils/is-type.js";import{sentryLogger as m}from"../utils/logger.js";import n from"../reporter/index.js";import p from"./breadcrumb.js";import a from"./white-screen.js";import{handleCodeError as c}from"./handle-code-error.js";import{handleError as u}from"./handle-error.js";const f=r=>{m.error("Unhandled rejection captured",r.extra),i(r.extra)?c(r.extra):u(r)},l=r=>{a(()=>{n.send(r)})},d=({extra:i,...m})=>{if(!(i instanceof MouseEvent))return;const a=t(i);if(!a)return;const c={...m,type:e.Click,name:a.ev||a.msg,message:a.msg||a.ev,status:r.OK,extra:a};p.push({...c,userAction:o(e.Click)}),s.options.enableClick&&n.send(c)};export{d as handleClick,f as handleUnhandledRejection,l as handleWhiteScreen};
1
+ import{Status as r,EventType as e}from"../types/enums.js";import"../constants/index.js";import{getDeclarativeClickData as t}from"../utils/click-data.js";import o from"../utils/event2breadcrumb.js";import s from"../utils/sentry.js";import{isErrorEvent as i}from"../utils/is-type.js";import{sentryLogger as m}from"../utils/logger.js";import n from"../reporter/index.js";import p from"./breadcrumb.js";import a from"./white-screen.js";import{handleCodeError as c}from"./handle-code-error.js";import{handleError as u}from"./handle-error.js";const f=r=>{m.error("Unhandled rejection captured",r.extra),i(r.extra)?c(r.extra):u(r)},l=r=>{a(()=>{n.send(r)})},d=({extra:i,...m})=>{if(!(i instanceof MouseEvent))return;const a=t(i);if(!a)return;const c={...m,type:e.Click,name:a.ev||a.msg,message:a.msg||a.ev,status:r.OK,extra:a};p.push({...c,userAction:o(e.Click)}),s.options.enableClick&&n.send(c)};export{d as handleClick,f as handleUnhandledRejection,l as handleWhiteScreen};
@@ -1 +1 @@
1
- "use strict";var e=require("../types/enums.cjs");require("../constants/index.cjs");var t=require("../utils/event2breadcrumb.cjs"),s=require("../utils/get-base-data.cjs"),r=require("../utils/sentry.cjs"),a=require("../utils/transform-http-data.cjs"),u=require("../utils/logger.cjs"),i=require("../reporter/index.cjs"),n=require("./breadcrumb.cjs");exports.handleHttp=d=>{const o=a.default(d),{id:m,name:l,time:c,timestamp:p,message:f,status:g,type:q}=o;g===e.Status.Error?u.sentryLogger.error(`Request error: ${l}`,d):u.sentryLogger.info(`Request complete: ${l}`,d),o.api.includes(r.default.options.dsn)||n.default.push({id:m,name:l,time:c,timestamp:p,message:f,status:g,type:q,userAction:t.default(q)}),g!==e.Status.Error?r.default.options.enableHttpPerformance&&i.default.send({...s.default(),type:e.EventType.Performance,name:`HTTP ${o.method}`,message:o.api,status:e.Status.OK,value:o.elapsedTime,extra:{method:o.method,statusCode:o.statusCode,serverTiming:o.serverTiming??[]}}):i.default.send(o)};
1
+ "use strict";var e=require("../types/enums.cjs");require("../constants/index.cjs");var t=require("../utils/event2breadcrumb.cjs"),s=require("../utils/get-base-data.cjs"),r=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var a=require("../utils/transform-http-data.cjs"),u=require("../utils/logger.cjs"),i=require("../reporter/index.cjs"),n=require("./breadcrumb.cjs");exports.handleHttp=d=>{const o=a.default(d),{id:m,name:l,time:c,timestamp:p,message:f,status:g,type:q}=o;g===e.Status.Error?u.sentryLogger.error(`Request error: ${l}`,d):u.sentryLogger.info(`Request complete: ${l}`,d),o.api.includes(r.default.options.dsn)||n.default.push({id:m,name:l,time:c,timestamp:p,message:f,status:g,type:q,userAction:t.default(q)}),g!==e.Status.Error?r.default.options.enableHttpPerformance&&i.default.send({...s.default(),type:e.EventType.Performance,name:`HTTP ${o.method}`,message:o.api,status:e.Status.OK,value:o.elapsedTime,extra:{method:o.method,statusCode:o.statusCode,serverTiming:o.serverTiming??[]}}):i.default.send(o)};
@@ -1 +1 @@
1
- import{Status as e,EventType as t}from"../types/enums.js";import"../constants/index.js";import s from"../utils/event2breadcrumb.js";import r from"../utils/get-base-data.js";import m from"../utils/sentry.js";import o from"../utils/transform-http-data.js";import{sentryLogger as i}from"../utils/logger.js";import a from"../reporter/index.js";import n from"./breadcrumb.js";const p=p=>{const u=o(p),{id:d,name:f,time:l,timestamp:c,message:j,status:g,type:b}=u;g===e.Error?i.error(`Request error: ${f}`,p):i.info(`Request complete: ${f}`,p),u.api.includes(m.options.dsn)||n.push({id:d,name:f,time:l,timestamp:c,message:j,status:g,type:b,userAction:s(b)}),g!==e.Error?m.options.enableHttpPerformance&&a.send({...r(),type:t.Performance,name:`HTTP ${u.method}`,message:u.api,status:e.OK,value:u.elapsedTime,extra:{method:u.method,statusCode:u.statusCode,serverTiming:u.serverTiming??[]}}):a.send(u)};export{p as handleHttp};
1
+ import{Status as e,EventType as t}from"../types/enums.js";import"../constants/index.js";import s from"../utils/event2breadcrumb.js";import r from"../utils/get-base-data.js";import m from"../utils/sentry.js";import"../utils/is-type.js";import o from"../utils/transform-http-data.js";import{sentryLogger as i}from"../utils/logger.js";import a from"../reporter/index.js";import p from"./breadcrumb.js";const n=n=>{const u=o(n),{id:d,name:f,time:l,timestamp:c,message:j,status:g,type:b}=u;g===e.Error?i.error(`Request error: ${f}`,n):i.info(`Request complete: ${f}`,n),u.api.includes(m.options.dsn)||p.push({id:d,name:f,time:l,timestamp:c,message:j,status:g,type:b,userAction:s(b)}),g!==e.Error?m.options.enableHttpPerformance&&a.send({...r(),type:t.Performance,name:`HTTP ${u.method}`,message:u.api,status:e.OK,value:u.elapsedTime,extra:{method:u.method,statusCode:u.statusCode,serverTiming:u.serverTiming??[]}}):a.send(u)};export{n as handleHttp};
@@ -1 +1 @@
1
- "use strict";var e=require("../types/enums.cjs"),t=require("../constants/index.cjs"),r=require("../utils/event2breadcrumb.cjs");require("../utils/sentry.cjs");var s=require("./breadcrumb.cjs"),n=require("./pv-lifecycle.cjs");function a(e){return e instanceof HashChangeEvent}exports.handleHashChange=({extra:o,...u})=>{const i=a(o)?o.oldURL:t.UNKNOWN,c=a(o)?o.newURL:t.UNKNOWN,h=`${i} => ${c}`,y={...u,name:h,message:h,type:e.EventType.HashChange,from:i,to:c};s.default.push({...y,userAction:r.default(e.EventType.HashChange)}),n.recordRoutePageView(c,i,"HashChange")},exports.handleHistory=({from:t,to:a,...o})=>{const u=`${t} => ${a}`,i={...o,name:u,message:u,type:e.EventType.History,from:t,to:a};s.default.push({...i,userAction:r.default(e.EventType.History)}),n.recordRoutePageView(a,t,"HistoryChange")};
1
+ "use strict";var e=require("../types/enums.cjs"),t=require("../constants/index.cjs"),r=require("../utils/event2breadcrumb.cjs");require("../utils/sentry.cjs"),require("../utils/is-type.cjs");var s=require("./breadcrumb.cjs"),n=require("./pv-lifecycle.cjs");function a(e){return e instanceof HashChangeEvent}exports.handleHashChange=({extra:u,...i})=>{const o=a(u)?u.oldURL:t.UNKNOWN,c=a(u)?u.newURL:t.UNKNOWN,h=`${o} => ${c}`,y={...i,name:h,message:h,type:e.EventType.HashChange,from:o,to:c};s.default.push({...y,userAction:r.default(e.EventType.HashChange)}),n.recordRoutePageView(c,o,"HashChange")},exports.handleHistory=({from:t,to:a,...u})=>{const i=`${t} => ${a}`,o={...u,name:i,message:i,type:e.EventType.History,from:t,to:a};s.default.push({...o,userAction:r.default(e.EventType.History)}),n.recordRoutePageView(a,t,"HistoryChange")};
@@ -1 +1 @@
1
- import{EventType as s}from"../types/enums.js";import{UNKNOWN as t}from"../constants/index.js";import e from"../utils/event2breadcrumb.js";import"../utils/sentry.js";import o from"./breadcrumb.js";import{recordRoutePageView as r}from"./pv-lifecycle.js";function n(s){return s instanceof HashChangeEvent}const m=({from:t,to:n,...m})=>{const a=`${t} => ${n}`,i={...m,name:a,message:a,type:s.History,from:t,to:n};o.push({...i,userAction:e(s.History)}),r(n,t,"HistoryChange")},a=({extra:m,...a})=>{const i=n(m)?m.oldURL:t,p=n(m)?m.newURL:t,c=`${i} => ${p}`,f={...a,name:c,message:c,type:s.HashChange,from:i,to:p};o.push({...f,userAction:e(s.HashChange)}),r(p,i,"HashChange")};export{a as handleHashChange,m as handleHistory};
1
+ import{EventType as s}from"../types/enums.js";import{UNKNOWN as t}from"../constants/index.js";import e from"../utils/event2breadcrumb.js";import"../utils/sentry.js";import"../utils/is-type.js";import o from"./breadcrumb.js";import{recordRoutePageView as r}from"./pv-lifecycle.js";function n(s){return s instanceof HashChangeEvent}const m=({from:t,to:n,...m})=>{const i=`${t} => ${n}`,a={...m,name:i,message:i,type:s.History,from:t,to:n};o.push({...a,userAction:e(s.History)}),r(n,t,"HistoryChange")},i=({extra:m,...i})=>{const a=n(m)?m.oldURL:t,p=n(m)?m.newURL:t,c=`${a} => ${p}`,u={...i,name:c,message:c,type:s.HashChange,from:a,to:p};o.push({...u,userAction:e(s.HashChange)}),r(p,a,"HashChange")};export{i as handleHashChange,m as handleHistory};
@@ -1 +1 @@
1
- "use strict";var t=require("../constants/index.cjs");require("../types/enums.cjs");var e=require("../utils/sentry.cjs"),s=require("../utils/logger.cjs");const n="swifty_sentry_anonymous_id";exports.getIdentity=function(){const{anonymousId:s,visitorId:n,userId:r}=e.default.options;return{anonymousId:s,visitorId:n,userId:r,hasAnonymousId:s!==t.UNKNOWN,hasVisitorId:n!==t.UNKNOWN}},exports.initIdentity=async function(){if(!e.default.options.enableFingerprint)return;const t=function(){try{return localStorage.getItem(n)??""}catch{return""}}();if(t)e.default.setOptions({anonymousId:t});else try{const t=await async function(){const t=await import("@fingerprintjs/fingerprintjs"),e=await t.default.load();return(await e.get()).visitorId}();!function(t){try{localStorage.setItem(n,t)}catch{s.sentryLogger.error("Failed to persist anonymous id")}}(t),e.default.setOptions({anonymousId:t})}catch(t){s.sentryLogger.error("Failed to collect fingerprint.js visitor id",t)}},exports.setUserId=function(t){e.default.setOptions({userId:t})},exports.setVisitorId=function(t){e.default.setOptions({visitorId:t})};
1
+ "use strict";var t=require("../constants/index.cjs");require("../types/enums.cjs");var e=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var s=require("../utils/logger.cjs");const r="swifty_sentry_anonymous_id";exports.getIdentity=function(){const{anonymousId:s,visitorId:r,userId:n}=e.default.options;return{anonymousId:s,visitorId:r,userId:n,hasAnonymousId:s!==t.UNKNOWN,hasVisitorId:r!==t.UNKNOWN}},exports.initIdentity=async function(){if(!e.default.options.enableFingerprint)return;const t=function(){try{return localStorage.getItem(r)??""}catch{return""}}();if(t)e.default.setOptions({anonymousId:t});else try{const t=await async function(){const t=await import("@fingerprintjs/fingerprintjs"),e=await t.default.load();return(await e.get()).visitorId}();!function(t){try{localStorage.setItem(r,t)}catch{s.sentryLogger.error("Failed to persist anonymous id")}}(t),e.default.setOptions({anonymousId:t})}catch(t){s.sentryLogger.error("Failed to collect fingerprint.js visitor id",t)}},exports.setUserId=function(t){e.default.setOptions({userId:t})},exports.setVisitorId=function(t){e.default.setOptions({visitorId:t})};
@@ -1 +1 @@
1
- import{UNKNOWN as t}from"../constants/index.js";import"../types/enums.js";import n from"../utils/sentry.js";import{sentryLogger as o}from"../utils/logger.js";const s="swifty_sentry_anonymous_id";async function i(){if(!n.options.enableFingerprint)return;const t=function(){try{return localStorage.getItem(s)??""}catch{return""}}();if(t)n.setOptions({anonymousId:t});else try{const t=await async function(){const t=await import("@fingerprintjs/fingerprintjs"),n=await t.default.load();return(await n.get()).visitorId}();!function(t){try{localStorage.setItem(s,t)}catch{o.error("Failed to persist anonymous id")}}(t),n.setOptions({anonymousId:t})}catch(t){o.error("Failed to collect fingerprint.js visitor id",t)}}function r(t){n.setOptions({visitorId:t})}function e(t){n.setOptions({userId:t})}function a(){const{anonymousId:o,visitorId:s,userId:i}=n.options;return{anonymousId:o,visitorId:s,userId:i,hasAnonymousId:o!==t,hasVisitorId:s!==t}}export{a as getIdentity,i as initIdentity,e as setUserId,r as setVisitorId};
1
+ import{UNKNOWN as t}from"../constants/index.js";import"../types/enums.js";import o from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as n}from"../utils/logger.js";const s="swifty_sentry_anonymous_id";async function i(){if(!o.options.enableFingerprint)return;const t=function(){try{return localStorage.getItem(s)??""}catch{return""}}();if(t)o.setOptions({anonymousId:t});else try{const t=await async function(){const t=await import("@fingerprintjs/fingerprintjs"),o=await t.default.load();return(await o.get()).visitorId}();!function(t){try{localStorage.setItem(s,t)}catch{n.error("Failed to persist anonymous id")}}(t),o.setOptions({anonymousId:t})}catch(t){n.error("Failed to collect fingerprint.js visitor id",t)}}function r(t){o.setOptions({visitorId:t})}function e(t){o.setOptions({userId:t})}function a(){const{anonymousId:n,visitorId:s,userId:i}=o.options;return{anonymousId:n,visitorId:s,userId:i,hasAnonymousId:n!==t,hasVisitorId:s!==t}}export{a as getIdentity,i as initIdentity,e as setUserId,r as setVisitorId};
package/dist/core/ip.d.ts CHANGED
@@ -1,3 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2026 hangtiancheng
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
1
22
  declare function getIPs(timeout?: number): Promise<readonly string[]>;
2
23
 
3
24
  export { getIPs };
@@ -1 +1 @@
1
- "use strict";var e=require("../types/enums.cjs");require("../constants/index.cjs");var r=require("../utils/get-base-data.cjs");require("../utils/sentry.cjs");var t=require("../reporter/index.cjs");let a=null;function n(a,n){t.default.send({...r.default(),type:e.EventType.PV,name:a.name,message:a.url,status:e.Status.OK,extra:{url:a.url,referrer:a.referrer,entryTime:a.startedAt}},n)}function s(a,n,s){n<=100||t.default.send({...r.default(),type:e.EventType.PV,name:"PageDwell",message:a.url,status:e.Status.OK,extra:{url:a.url,referrer:a.referrer,duration:n}},s)}function u(e,r,t){return{url:e,referrer:r,name:t,startedAt:Date.now()}}exports.flushCurrentPageDwell=function(e){a&&s(a,Date.now()-a.startedAt,e)},exports.initPageView=function(){a=u(globalThis.location?.href??"",globalThis.document?.referrer??"","PageLoad"),n(a,!0)},exports.recordRoutePageView=function(e,r,t){const l=globalThis.location?.href??"http://localhost",o=new URL(e,l).href,i=new URL(r,l).href;a?.url!==o&&(a&&s(a,Date.now()-a.startedAt,!1),a=u(o,i,t),n(a,!1))},exports.resetPageView=function(){a=null};
1
+ "use strict";var e=require("../types/enums.cjs");require("../constants/index.cjs");var r=require("../utils/get-base-data.cjs");require("../utils/sentry.cjs"),require("../utils/is-type.cjs");var t=require("../reporter/index.cjs");let s=null;function a(s,a){t.default.send({...r.default(),type:e.EventType.PV,name:s.name,message:s.url,status:e.Status.OK,extra:{url:s.url,referrer:s.referrer,entryTime:s.startedAt}},a)}function n(s,a,n){a<=100||t.default.send({...r.default(),type:e.EventType.PV,name:"PageDwell",message:s.url,status:e.Status.OK,extra:{url:s.url,referrer:s.referrer,duration:a}},n)}function u(e,r,t){return{url:e,referrer:r,name:t,startedAt:Date.now()}}exports.flushCurrentPageDwell=function(e){s&&n(s,Date.now()-s.startedAt,e)},exports.initPageView=function(){s=u(globalThis.location?.href??"",globalThis.document?.referrer??"","PageLoad"),a(s,!0)},exports.recordRoutePageView=function(e,r,t){const l=globalThis.location?.href??"http://localhost",i=new URL(e,l).href,o=new URL(r,l).href;s?.url!==i&&(s&&n(s,Date.now()-s.startedAt,!1),s=u(i,o,t),a(s,!1))},exports.resetPageView=function(){s=null};
@@ -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"../utils/sentry.js";import n from"../reporter/index.js";let o=null;function s(o,s){n.send({...t(),type:r.PV,name:o.name,message:o.url,status:e.OK,extra:{url:o.url,referrer:o.referrer,entryTime:o.startedAt}},s)}function a(o,s,a){s<=100||n.send({...t(),type:r.PV,name:"PageDwell",message:o.url,status:e.OK,extra:{url:o.url,referrer:o.referrer,duration:s}},a)}function l(e,r,t){return{url:e,referrer:r,name:t,startedAt:Date.now()}}function u(){o=l(globalThis.location?.href??"",globalThis.document?.referrer??"","PageLoad"),s(o,!0)}function i(e,r,t){const n=globalThis.location?.href??"http://localhost",u=new URL(e,n).href,i=new URL(r,n).href;o?.url!==u&&(o&&a(o,Date.now()-o.startedAt,!1),o=l(u,i,t),s(o,!1))}function f(e){o&&a(o,Date.now()-o.startedAt,e)}function m(){o=null}export{f as flushCurrentPageDwell,u as initPageView,i as recordRoutePageView,m as resetPageView};
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"../utils/sentry.js";import"../utils/is-type.js";import n from"../reporter/index.js";let o=null;function s(o,s){n.send({...t(),type:r.PV,name:o.name,message:o.url,status:e.OK,extra:{url:o.url,referrer:o.referrer,entryTime:o.startedAt}},s)}function a(o,s,a){s<=100||n.send({...t(),type:r.PV,name:"PageDwell",message:o.url,status:e.OK,extra:{url:o.url,referrer:o.referrer,duration:s}},a)}function l(e,r,t){return{url:e,referrer:r,name:t,startedAt:Date.now()}}function i(){o=l(globalThis.location?.href??"",globalThis.document?.referrer??"","PageLoad"),s(o,!0)}function u(e,r,t){const n=globalThis.location?.href??"http://localhost",i=new URL(e,n).href,u=new URL(r,n).href;o?.url!==i&&(o&&a(o,Date.now()-o.startedAt,!1),o=l(i,u,t),s(o,!1))}function f(e){o&&a(o,Date.now()-o.startedAt,e)}function m(){o=null}export{f as flushCurrentPageDwell,i as initPageView,u as recordRoutePageView,m as resetPageView};
@@ -1 +1 @@
1
- "use strict";var e=require("../constants/index.cjs");require("../types/enums.cjs");var r=require("../utils/sentry.cjs"),i=require("../utils/logger.cjs"),t=require("./identity.cjs"),n=require("./options-schema.cjs"),s=require("./plugin-registry.cjs"),o=require("./setup.cjs"),u=require("./handle-code-error.cjs"),l=require("../reporter/index.cjs");let a=null;function d(){return null!==a}exports.destroy=function(){s.destroyPlugins(),a?.(),a=null,u.destroyBatchErrorManager(),l.resetReporter()},exports.enablePlugin=function(e){return e.init(),s.registerPlugin(e),e},exports.init=function(s){const u=n.optionsSchema.parse({...e.DEFAULT_OPTIONS,...s});r.default.setOptions(u);const{dsn:l}=r.default.options;r.default.options.disabled?i.sentryLogger.info("SDK disabled by options"):""!==l?d()?i.sentryLogger.info("SDK already initialized"):(i.sentryLogger.info("SDK initialized",{options:r.default.options}),a=o.default(),t.initIdentity()):i.sentryLogger.error("Initialization failed: DSN is empty")},exports.isInitialized=d;
1
+ "use strict";var e=require("../constants/index.cjs");require("../types/enums.cjs");var r=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var i=require("../utils/logger.cjs"),t=require("./identity.cjs"),s=require("./options-schema.cjs"),n=require("./plugin-registry.cjs"),o=require("./setup.cjs"),u=require("./handle-code-error.cjs"),l=require("../reporter/index.cjs");let a=null;function d(){return null!==a}exports.destroy=function(){n.destroyPlugins(),a?.(),a=null,u.destroyBatchErrorManager(),l.resetReporter()},exports.enablePlugin=function(e){return e.init(),n.registerPlugin(e),e},exports.init=function(n){const u=s.optionsSchema.parse({...e.DEFAULT_OPTIONS,...n});r.default.setOptions(u);const{dsn:l}=r.default.options;r.default.options.disabled?i.sentryLogger.info("SDK disabled by options"):""!==l?d()?i.sentryLogger.info("SDK already initialized"):(i.sentryLogger.info("SDK initialized",{options:r.default.options}),a=o.default(),t.initIdentity()):i.sentryLogger.error("Initialization failed: DSN is empty")},exports.isInitialized=d;
@@ -1,6 +1,28 @@
1
1
  import { SentryPlugin } from '../types/plugin.js';
2
2
  import { InitOptions } from './options-schema.js';
3
3
 
4
+ /**
5
+ * Copyright (c) 2026 hangtiancheng
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in
15
+ * all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
4
26
  declare function isInitialized(): boolean;
5
27
  declare function destroy(): void;
6
28
  declare function init(options: InitOptions): void;
@@ -1 +1 @@
1
- import{DEFAULT_OPTIONS as i}from"../constants/index.js";import"../types/enums.js";import o from"../utils/sentry.js";import{sentryLogger as t}from"../utils/logger.js";import{initIdentity as n}from"./identity.js";import{optionsSchema as r}from"./options-schema.js";import{destroyPlugins as s,registerPlugin as e}from"./plugin-registry.js";import p from"./setup.js";import{destroyBatchErrorManager as m}from"./handle-code-error.js";import{resetReporter as l}from"../reporter/index.js";let f=null;function d(){return null!==f}function u(){s(),f?.(),f=null,m(),l()}function a(s){const e=r.parse({...i,...s});o.setOptions(e);const{dsn:m}=o.options;o.options.disabled?t.info("SDK disabled by options"):""!==m?d()?t.info("SDK already initialized"):(t.info("SDK initialized",{options:o.options}),f=p(),n()):t.error("Initialization failed: DSN is empty")}function j(i){return i.init(),e(i),i}export{u as destroy,j as enablePlugin,a as init,d as isInitialized};
1
+ import{DEFAULT_OPTIONS as i}from"../constants/index.js";import"../types/enums.js";import o from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as t}from"../utils/logger.js";import{initIdentity as n}from"./identity.js";import{optionsSchema as r}from"./options-schema.js";import{destroyPlugins as s,registerPlugin as e}from"./plugin-registry.js";import p from"./setup.js";import{destroyBatchErrorManager as m}from"./handle-code-error.js";import{resetReporter as l}from"../reporter/index.js";let f=null;function u(){return null!==f}function d(){s(),f?.(),f=null,m(),l()}function a(s){const e=r.parse({...i,...s});o.setOptions(e);const{dsn:m}=o.options;o.options.disabled?t.info("SDK disabled by options"):""!==m?u()?t.info("SDK already initialized"):(t.info("SDK initialized",{options:o.options}),f=p(),n()):t.error("Initialization failed: DSN is empty")}function j(i){return i.init(),e(i),i}export{d as destroy,j as enablePlugin,a as init,u as isInitialized};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../types/enums.cjs");require("../constants/index.cjs");var n=require("../utils/sentry.cjs"),t=require("../utils/logger.cjs"),r=require("./bus.cjs"),s=require("./pv-lifecycle.cjs"),a=require("./handle-error.cjs"),i=require("./handle-route.cjs"),l=require("./handle-http.cjs"),u=require("./handle-events.cjs"),o=require("./decorate-publish.cjs");exports.default=function(){t.sentryLogger.info("Initializing SDK event subscriptions...");const c=[{enabled:n.default.options.enableXhr,type:e.EventType.Xhr,subscribe:()=>r.sub(e.EventType.Xhr,l.handleHttp),name:"Xhr"},{enabled:n.default.options.enableFetch,type:e.EventType.Fetch,subscribe:()=>r.sub(e.EventType.Fetch,l.handleHttp),name:"Fetch"},{enabled:n.default.options.enableError,type:e.EventType.Error,subscribe:()=>r.sub(e.EventType.Error,a.handleError),name:"Error"},{enabled:n.default.options.enableHistory,type:e.EventType.History,subscribe:()=>r.sub(e.EventType.History,i.handleHistory),name:"History"},{enabled:n.default.options.enableHashChange,type:e.EventType.HashChange,subscribe:()=>r.sub(e.EventType.HashChange,i.handleHashChange),name:"HashChange"},{enabled:n.default.options.enableUnhandledRejection,type:e.EventType.UnhandledRejection,subscribe:()=>r.sub(e.EventType.UnhandledRejection,u.handleUnhandledRejection),name:"UnhandledRejection"},{enabled:n.default.options.enableClick,type:e.EventType.Click,subscribe:()=>r.sub(e.EventType.Click,u.handleClick),name:"Click"},{enabled:n.default.options.enableWhiteScreen,type:e.EventType.WhiteScreen,subscribe:()=>r.sub(e.EventType.WhiteScreen,u.handleWhiteScreen),name:"WhiteScreen"}].filter(({enabled:e})=>e),b=[];c.forEach(({type:e,subscribe:n})=>{b.push(n()),b.push(o.default(e))}),s.initPageView();const p=()=>{s.flushCurrentPageDwell(!0)};return globalThis.addEventListener("beforeunload",p),b.push(()=>{globalThis.removeEventListener("beforeunload",p)}),t.sentryLogger.success("SDK setup completed",c.map(e=>({event:e.name,type:e.type}))),()=>{b.toReversed().forEach(e=>{e()}),s.resetPageView(),r.clearSubscriptions()}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../types/enums.cjs");require("../constants/index.cjs");var n=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var t=require("../utils/logger.cjs"),r=require("./bus.cjs"),s=require("./pv-lifecycle.cjs"),a=require("./handle-error.cjs"),i=require("./handle-route.cjs"),l=require("./handle-http.cjs"),u=require("./handle-events.cjs"),o=require("./decorates.cjs");exports.default=function(){t.sentryLogger.info("Initializing SDK event subscriptions...");const c=[{enabled:n.default.options.enableXhr,type:e.EventType.Xhr,subscribe:()=>r.sub(e.EventType.Xhr,l.handleHttp),name:"Xhr"},{enabled:n.default.options.enableFetch,type:e.EventType.Fetch,subscribe:()=>r.sub(e.EventType.Fetch,l.handleHttp),name:"Fetch"},{enabled:n.default.options.enableError,type:e.EventType.Error,subscribe:()=>r.sub(e.EventType.Error,a.handleError),name:"Error"},{enabled:n.default.options.enableHistory,type:e.EventType.History,subscribe:()=>r.sub(e.EventType.History,i.handleHistory),name:"History"},{enabled:n.default.options.enableHashChange,type:e.EventType.HashChange,subscribe:()=>r.sub(e.EventType.HashChange,i.handleHashChange),name:"HashChange"},{enabled:n.default.options.enableUnhandledRejection,type:e.EventType.UnhandledRejection,subscribe:()=>r.sub(e.EventType.UnhandledRejection,u.handleUnhandledRejection),name:"UnhandledRejection"},{enabled:n.default.options.enableClick,type:e.EventType.Click,subscribe:()=>r.sub(e.EventType.Click,u.handleClick),name:"Click"},{enabled:n.default.options.enableWhiteScreen,type:e.EventType.WhiteScreen,subscribe:()=>r.sub(e.EventType.WhiteScreen,u.handleWhiteScreen),name:"WhiteScreen"}].filter(({enabled:e})=>e),p=[];c.forEach(({type:e,subscribe:n})=>{p.push(n()),p.push(o.default(e))}),s.initPageView();const b=()=>{s.flushCurrentPageDwell(!0)};return globalThis.addEventListener("beforeunload",b),p.push(()=>{globalThis.removeEventListener("beforeunload",b)}),t.sentryLogger.success("SDK setup completed",c.map(e=>({event:e.name,type:e.type}))),()=>{p.toReversed().forEach(e=>{e()}),s.resetPageView(),r.clearSubscriptions()}};
@@ -1 +1 @@
1
- import{EventType as e}from"../types/enums.js";import"../constants/index.js";import n from"../utils/sentry.js";import{sentryLogger as t}from"../utils/logger.js";import{sub as r,clearSubscriptions as s}from"./bus.js";import{initPageView as o,flushCurrentPageDwell as i,resetPageView as a}from"./pv-lifecycle.js";import{handleError as l}from"./handle-error.js";import{handleHistory as b,handleHashChange as p}from"./handle-route.js";import{handleHttp as c}from"./handle-http.js";import{handleUnhandledRejection as h,handleClick as m,handleWhiteScreen as d}from"./handle-events.js";import u from"./decorate-publish.js";function f(){t.info("Initializing SDK event subscriptions...");const f=[{enabled:n.options.enableXhr,type:e.Xhr,subscribe:()=>r(e.Xhr,c),name:"Xhr"},{enabled:n.options.enableFetch,type:e.Fetch,subscribe:()=>r(e.Fetch,c),name:"Fetch"},{enabled:n.options.enableError,type:e.Error,subscribe:()=>r(e.Error,l),name:"Error"},{enabled:n.options.enableHistory,type:e.History,subscribe:()=>r(e.History,b),name:"History"},{enabled:n.options.enableHashChange,type:e.HashChange,subscribe:()=>r(e.HashChange,p),name:"HashChange"},{enabled:n.options.enableUnhandledRejection,type:e.UnhandledRejection,subscribe:()=>r(e.UnhandledRejection,h),name:"UnhandledRejection"},{enabled:n.options.enableClick,type:e.Click,subscribe:()=>r(e.Click,m),name:"Click"},{enabled:n.options.enableWhiteScreen,type:e.WhiteScreen,subscribe:()=>r(e.WhiteScreen,d),name:"WhiteScreen"}].filter(({enabled:e})=>e),y=[];f.forEach(({type:e,subscribe:n})=>{y.push(n()),y.push(u(e))}),o();const j=()=>{i(!0)};return globalThis.addEventListener("beforeunload",j),y.push(()=>{globalThis.removeEventListener("beforeunload",j)}),t.success("SDK setup completed",f.map(e=>({event:e.name,type:e.type}))),()=>{y.toReversed().forEach(e=>{e()}),a(),s()}}export{f as default};
1
+ import{EventType as e}from"../types/enums.js";import"../constants/index.js";import n from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as t}from"../utils/logger.js";import{sub as s,clearSubscriptions as r}from"./bus.js";import{initPageView as o,flushCurrentPageDwell as i,resetPageView as a}from"./pv-lifecycle.js";import{handleError as l}from"./handle-error.js";import{handleHistory as p,handleHashChange as b}from"./handle-route.js";import{handleHttp as c}from"./handle-http.js";import{handleUnhandledRejection as h,handleClick as m,handleWhiteScreen as d}from"./handle-events.js";import u from"./decorates.js";function f(){t.info("Initializing SDK event subscriptions...");const f=[{enabled:n.options.enableXhr,type:e.Xhr,subscribe:()=>s(e.Xhr,c),name:"Xhr"},{enabled:n.options.enableFetch,type:e.Fetch,subscribe:()=>s(e.Fetch,c),name:"Fetch"},{enabled:n.options.enableError,type:e.Error,subscribe:()=>s(e.Error,l),name:"Error"},{enabled:n.options.enableHistory,type:e.History,subscribe:()=>s(e.History,p),name:"History"},{enabled:n.options.enableHashChange,type:e.HashChange,subscribe:()=>s(e.HashChange,b),name:"HashChange"},{enabled:n.options.enableUnhandledRejection,type:e.UnhandledRejection,subscribe:()=>s(e.UnhandledRejection,h),name:"UnhandledRejection"},{enabled:n.options.enableClick,type:e.Click,subscribe:()=>s(e.Click,m),name:"Click"},{enabled:n.options.enableWhiteScreen,type:e.WhiteScreen,subscribe:()=>s(e.WhiteScreen,d),name:"WhiteScreen"}].filter(({enabled:e})=>e),y=[];f.forEach(({type:e,subscribe:n})=>{y.push(n()),y.push(u(e))}),o();const j=()=>{i(!0)};return globalThis.addEventListener("beforeunload",j),y.push(()=>{globalThis.removeEventListener("beforeunload",j)}),t.success("SDK setup completed",f.map(e=>({event:e.name,type:e.type}))),()=>{y.toReversed().forEach(e=>{e()}),a(),r()}}export{f as default};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../constants/index.cjs"),t=require("../types/enums.cjs"),r=require("../utils/get-css-selectors.cjs"),n=require("../utils/get-base-data.cjs"),i=require("../utils/sentry.cjs"),s=require("../utils/logger.cjs");exports.default=function(o){const{hasSkeleton:l,rootCssSelectors:a}=i.default.options;let c=0;const u=new Set,d=new Set,f=e=>{const t=r.default(e),[n,i,s]=t;return l&&(1===c?t.forEach(e=>u.add(e)):t.forEach(e=>d.add(e))),a.includes(n)||a.includes(i)||a.includes(s)},m=()=>{if(c++,l&&d.clear(),c>e.MAX_WHITE_SCREEN_SAMPLE_COUNT)return void S();const{innerWidth:t,innerHeight:r}=globalThis;let n=0;for(let e=1;e<=9;e++){const i=document.elementFromPoint(t*e/10,r/2),s=document.elementFromPoint(t/2,r*e/10);i&&!f(i)||n++,s&&!f(s)||n++}if(!l){if(n>=18)return void h();S()}if(l){if(1===c)return;if(Array.from(d).sort().join(",")===Array.from(u).sort().join(","))return void h();S()}},h=()=>{const e={...n.default(),type:t.EventType.WhiteScreen,status:t.Status.Error,name:"WhiteScreen",message:`sample count ${c}`,extra:"WhiteScreen"};s.sentryLogger.error("White screen detected",e),o(e),S()},S=()=>{i.default.whiteScreenTimer&&(clearInterval(i.default.whiteScreenTimer),i.default.whiteScreenTimer=null)},T=()=>{i.default.whiteScreenTimer||(i.default.whiteScreenTimer=globalThis.setInterval(()=>{"requestIdleCallback"in globalThis?requestIdleCallback(e=>{(e.timeRemaining()>0||e.didTimeout)&&m()}):m()},e.WHITE_SCREEN_SAMPLE_INTERVAL))};return"complete"===document.readyState?T():globalThis.addEventListener("load",T,{once:!0}),{stop:S}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../constants/index.cjs"),t=require("../types/enums.cjs"),r=require("../utils/get-css-selectors.cjs"),i=require("../utils/get-base-data.cjs"),n=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var s=require("../utils/logger.cjs");exports.default=function(o){const{hasSkeleton:l,rootCssSelectors:a}=n.default.options;let c=0;const u=new Set,d=new Set,f=e=>{const t=r.default(e),[i,n,s]=t;return l&&(1===c?t.forEach(e=>u.add(e)):t.forEach(e=>d.add(e))),a.includes(i)||a.includes(n)||a.includes(s)},m=()=>{if(c++,l&&d.clear(),c>e.MAX_WHITE_SCREEN_SAMPLE_COUNT)return void S();const{innerWidth:t,innerHeight:r}=globalThis;let i=0;for(let e=1;e<=9;e++){const n=document.elementFromPoint(t*e/10,r/2),s=document.elementFromPoint(t/2,r*e/10);n&&!f(n)||i++,s&&!f(s)||i++}if(!l){if(i>=18)return void h();S()}if(l){if(1===c)return;if(Array.from(d).sort().join(",")===Array.from(u).sort().join(","))return void h();S()}},h=()=>{const e={...i.default(),type:t.EventType.WhiteScreen,status:t.Status.Error,name:"WhiteScreen",message:`sample count ${c}`,extra:"WhiteScreen"};s.sentryLogger.error("White screen detected",e),o(e),S()},S=()=>{n.default.whiteScreenTimer&&(clearInterval(n.default.whiteScreenTimer),n.default.whiteScreenTimer=null)},T=()=>{n.default.whiteScreenTimer||(n.default.whiteScreenTimer=globalThis.setInterval(()=>{"requestIdleCallback"in globalThis?requestIdleCallback(e=>{(e.timeRemaining()>0||e.didTimeout)&&m()}):m()},e.WHITE_SCREEN_SAMPLE_INTERVAL))};return"complete"===document.readyState?T():globalThis.addEventListener("load",T,{once:!0}),{stop:S}};
@@ -1 +1 @@
1
- import{WHITE_SCREEN_SAMPLE_INTERVAL as e,MAX_WHITE_SCREEN_SAMPLE_COUNT as t}from"../constants/index.js";import{Status as r,EventType as o}from"../types/enums.js";import n from"../utils/get-css-selectors.js";import i from"../utils/get-base-data.js";import s from"../utils/sentry.js";import{sentryLogger as l}from"../utils/logger.js";function c(c){const{hasSkeleton:a,rootCssSelectors:m}=s.options;let d=0;const u=new Set,f=new Set,h=e=>{const t=n(e),[r,o,i]=t;return a&&(1===d?t.forEach(e=>u.add(e)):t.forEach(e=>f.add(e))),m.includes(r)||m.includes(o)||m.includes(i)},p=()=>{if(d++,a&&f.clear(),d>t)return void g();const{innerWidth:e,innerHeight:r}=globalThis;let o=0;for(let t=1;t<=9;t++){const n=document.elementFromPoint(e*t/10,r/2),i=document.elementFromPoint(e/2,r*t/10);n&&!h(n)||o++,i&&!h(i)||o++}if(!a){if(o>=18)return void S();g()}if(a){if(1===d)return;if(Array.from(f).sort().join(",")===Array.from(u).sort().join(","))return void S();g()}},S=()=>{const e={...i(),type:o.WhiteScreen,status:r.Error,name:"WhiteScreen",message:`sample count ${d}`,extra:"WhiteScreen"};l.error("White screen detected",e),c(e),g()},g=()=>{s.whiteScreenTimer&&(clearInterval(s.whiteScreenTimer),s.whiteScreenTimer=null)},T=()=>{s.whiteScreenTimer||(s.whiteScreenTimer=globalThis.setInterval(()=>{"requestIdleCallback"in globalThis?requestIdleCallback(e=>{(e.timeRemaining()>0||e.didTimeout)&&p()}):p()},e))};return"complete"===document.readyState?T():globalThis.addEventListener("load",T,{once:!0}),{stop:g}}export{c as default};
1
+ import{WHITE_SCREEN_SAMPLE_INTERVAL as e,MAX_WHITE_SCREEN_SAMPLE_COUNT as t}from"../constants/index.js";import{Status as r,EventType as i}from"../types/enums.js";import o from"../utils/get-css-selectors.js";import n from"../utils/get-base-data.js";import s from"../utils/sentry.js";import"../utils/is-type.js";import{sentryLogger as l}from"../utils/logger.js";function c(c){const{hasSkeleton:a,rootCssSelectors:m}=s.options;let d=0;const u=new Set,f=new Set,h=e=>{const t=o(e),[r,i,n]=t;return a&&(1===d?t.forEach(e=>u.add(e)):t.forEach(e=>f.add(e))),m.includes(r)||m.includes(i)||m.includes(n)},p=()=>{if(d++,a&&f.clear(),d>t)return void g();const{innerWidth:e,innerHeight:r}=globalThis;let i=0;for(let t=1;t<=9;t++){const o=document.elementFromPoint(e*t/10,r/2),n=document.elementFromPoint(e/2,r*t/10);o&&!h(o)||i++,n&&!h(n)||i++}if(!a){if(i>=18)return void S();g()}if(a){if(1===d)return;if(Array.from(f).sort().join(",")===Array.from(u).sort().join(","))return void S();g()}},S=()=>{const e={...n(),type:i.WhiteScreen,status:r.Error,name:"WhiteScreen",message:`sample count ${d}`,extra:"WhiteScreen"};l.error("White screen detected",e),c(e),g()},g=()=>{s.whiteScreenTimer&&(clearInterval(s.whiteScreenTimer),s.whiteScreenTimer=null)},T=()=>{s.whiteScreenTimer||(s.whiteScreenTimer=globalThis.setInterval(()=>{"requestIdleCallback"in globalThis?requestIdleCallback(e=>{(e.timeRemaining()>0||e.didTimeout)&&p()}):p()},e))};return"complete"===document.readyState?T():globalThis.addEventListener("load",T,{once:!0}),{stop:g}}export{c as default};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("./core/sdk-lifecycle.cjs"),t=require("./core/identity.cjs"),r=require("./core/api.cjs"),s=require("./types/enums.cjs"),n=require("./types/plugin.cjs"),o=require("./core/ip.cjs");exports.destroy=e.destroy,exports.enablePlugin=e.enablePlugin,exports.init=e.init,exports.isInitialized=e.isInitialized,exports.getIdentity=t.getIdentity,exports.setUserId=t.setUserId,exports.setVisitorId=t.setVisitorId,exports.afterSendData=r.afterSendData,exports.beforePushEventList=r.beforePushEventList,exports.beforeSendData=r.beforeSendData,exports.getBaseInfo=r.getBaseInfo,exports.getUserId=r.getUserId,exports.sendLocal=r.sendLocal,exports.traceCustomEvent=r.traceCustomEvent,exports.traceError=r.traceError,exports.tracePageView=r.tracePageView,exports.tracePerformance=r.tracePerformance,Object.defineProperty(exports,"BreadcrumbType",{enumerable:!0,get:function(){return s.BreadcrumbType}}),Object.defineProperty(exports,"EventType",{enumerable:!0,get:function(){return s.EventType}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function(){return s.HttpMethod}}),Object.defineProperty(exports,"HttpStatus",{enumerable:!0,get:function(){return s.HttpStatus}}),Object.defineProperty(exports,"HttpStatusCode",{enumerable:!0,get:function(){return s.HttpStatusCode}}),Object.defineProperty(exports,"HttpType",{enumerable:!0,get:function(){return s.HttpType}}),Object.defineProperty(exports,"Status",{enumerable:!0,get:function(){return s.Status}}),exports.SentryPlugin=n.SentryPlugin,exports.getIPs=o.getIPs;
1
+ "use strict";var e=require("./core/sdk-lifecycle.cjs"),t=require("./core/identity.cjs"),r=require("./core/api.cjs"),o=require("./core/framework-error.cjs"),s=require("./types/enums.cjs"),n=require("./types/plugin.cjs"),p=require("./core/ip.cjs");exports.destroy=e.destroy,exports.enablePlugin=e.enablePlugin,exports.init=e.init,exports.isInitialized=e.isInitialized,exports.getIdentity=t.getIdentity,exports.setUserId=t.setUserId,exports.setVisitorId=t.setVisitorId,exports.afterSendData=r.afterSendData,exports.beforePushEventList=r.beforePushEventList,exports.beforeSendData=r.beforeSendData,exports.getBaseInfo=r.getBaseInfo,exports.getUserId=r.getUserId,exports.sendLocal=r.sendLocal,exports.traceCustomEvent=r.traceCustomEvent,exports.traceError=r.traceError,exports.tracePageView=r.tracePageView,exports.tracePerformance=r.tracePerformance,exports.reportFrameworkError=o.reportFrameworkError,Object.defineProperty(exports,"BreadcrumbType",{enumerable:!0,get:function(){return s.BreadcrumbType}}),Object.defineProperty(exports,"EventType",{enumerable:!0,get:function(){return s.EventType}}),Object.defineProperty(exports,"HttpMethod",{enumerable:!0,get:function(){return s.HttpMethod}}),Object.defineProperty(exports,"HttpStatus",{enumerable:!0,get:function(){return s.HttpStatus}}),Object.defineProperty(exports,"HttpStatusCode",{enumerable:!0,get:function(){return s.HttpStatusCode}}),Object.defineProperty(exports,"HttpType",{enumerable:!0,get:function(){return s.HttpType}}),Object.defineProperty(exports,"Status",{enumerable:!0,get:function(){return s.Status}}),exports.SentryPlugin=n.SentryPlugin,exports.getIPs=p.getIPs;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { destroy, enablePlugin, init, isInitialized } from './core/sdk-lifecycle.js';
2
2
  export { getIdentity, setUserId, setVisitorId } from './core/identity.js';
3
3
  export { afterSendData, beforePushEventList, beforeSendData, getBaseInfo, getUserId, sendLocal, traceCustomEvent, traceError, tracePageView, tracePerformance } from './core/api.js';
4
+ export { reportFrameworkError } from './core/framework-error.js';
5
+ export { InitOptions } from './core/options-schema.js';
4
6
  export { IBaseDataWithEvent, IBatchErrorData, IBreadcrumbItem, ICodeError, IDataReporter, IDeviceInfo, IExposureData, IExtendedErrorEvent, IHttpData, IPerformanceData, IPerformanceResourceTiming, IReportData, IReportPayload, IResourceError, IRouteData, IScreenRecordData, ISentry, TOnReportPerformanceData, TOnReportWhiteScreenData, TReportPayload, TUnknownError } from './types/common.js';
5
7
  export { BreadcrumbType, EventType, HttpMethod, HttpStatus, HttpStatusCode, HttpType, Status } from './types/enums.js';
6
8
  export { IPub, ISub, TEventHandler } from './types/handlers.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export{destroy,enablePlugin,init,isInitialized}from"./core/sdk-lifecycle.js";export{getIdentity,setUserId,setVisitorId}from"./core/identity.js";export{afterSendData,beforePushEventList,beforeSendData,getBaseInfo,getUserId,sendLocal,traceCustomEvent,traceError,tracePageView,tracePerformance}from"./core/api.js";export{BreadcrumbType,EventType,HttpMethod,HttpStatus,HttpStatusCode,HttpType,Status}from"./types/enums.js";export{SentryPlugin}from"./types/plugin.js";export{getIPs}from"./core/ip.js";
1
+ export{destroy,enablePlugin,init,isInitialized}from"./core/sdk-lifecycle.js";export{getIdentity,setUserId,setVisitorId}from"./core/identity.js";export{afterSendData,beforePushEventList,beforeSendData,getBaseInfo,getUserId,sendLocal,traceCustomEvent,traceError,tracePageView,tracePerformance}from"./core/api.js";export{reportFrameworkError}from"./core/framework-error.js";export{BreadcrumbType,EventType,HttpMethod,HttpStatus,HttpStatusCode,HttpType,Status}from"./types/enums.js";export{SentryPlugin}from"./types/plugin.js";export{getIPs}from"./core/ip.js";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="0.0.1",r={version:e};exports.default=r,exports.version=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="0.0.3",r={version:e};exports.default=r,exports.version=e;
@@ -1 +1 @@
1
- var a="0.0.1",e={version:a};export{e as default,a as version};
1
+ var a="0.0.3",e={version:a};export{e as default,a as version};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../types/enums.cjs"),t=require("../../types/plugin.cjs"),s=require("../../reporter/index.cjs");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs");require("../../utils/sentry.cjs");var i=require("../../utils/logger.cjs"),a=require("zod");const o=a.z.object({target:a.z.custom(e=>"Element"in globalThis&&e instanceof globalThis.Element),threshold:a.z.number().min(0).max(1).optional(),params:a.z.record(a.z.string(),a.z.unknown()).optional()});class n extends t.SentryPlugin{ioMap=new Map;targetMap=new Map;constructor(){super(e.EventType.Exposure)}init(){i.sentryLogger.info("Exposure plugin initialized")}initObserver(e){return new IntersectionObserver(e=>{e.forEach(e=>{const t=this.targetMap.get(e.target);if(t)if(e.isIntersecting)t.showTime=Date.now();else{if(!t.showTime)return;const e=Date.now();this.sendEvent(t,e),delete t.showTime}})},{threshold:e})}sendEvent(t,i){t.showTime&&s.default.send({...r.default(),type:e.EventType.Exposure,name:"Exposure",message:"Element Exposure",status:e.Status.OK,extra:{threshold:t.threshold,observeTime:t.observeTime,showTime:t.showTime,showEndTime:i,duration:i-t.showTime,params:t.params}})}observe(e){(Array.isArray(e)?e:[e]).map(e=>o.parse(e)).forEach(e=>{const t=e.threshold||.5,s=this.ioMap.get(t)??this.initObserver(t);this.ioMap.set(t,s),this.targetMap.has(e.target)||(s.observe(e.target),this.targetMap.set(e.target,{threshold:t,observeTime:Date.now(),params:e.params??{}}))})}unobserve(e){(Array.isArray(e)?e:[e]).forEach(e=>this.unobserveOne(e))}unobserveOne(e){const t=this.targetMap.get(e);if(!t)return;const s=this.ioMap.get(t.threshold);s&&s.unobserve(e),this.targetMap.delete(e)}destroy(){this.ioMap.forEach(e=>{e.disconnect()}),this.ioMap.clear(),this.targetMap.clear()}}exports.default=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../types/enums.cjs"),t=require("../../types/plugin.cjs"),s=require("../../reporter/index.cjs");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs");require("../../utils/sentry.cjs"),require("../../utils/is-type.cjs");var i=require("../../utils/logger.cjs"),a=require("zod");const o=a.z.object({target:a.z.custom(e=>"Element"in globalThis&&e instanceof globalThis.Element),threshold:a.z.number().min(0).max(1).optional(),params:a.z.record(a.z.string(),a.z.unknown()).optional()});class n extends t.SentryPlugin{ioMap=new Map;targetMap=new Map;constructor(){super(e.EventType.Exposure)}init(){i.sentryLogger.info("Exposure plugin initialized")}initObserver(e){return new IntersectionObserver(e=>{e.forEach(e=>{const t=this.targetMap.get(e.target);if(t)if(e.isIntersecting)t.showTime=Date.now();else{if(!t.showTime)return;const e=Date.now();this.sendEvent(t,e),delete t.showTime}})},{threshold:e})}sendEvent(t,i){t.showTime&&s.default.send({...r.default(),type:e.EventType.Exposure,name:"Exposure",message:"Element Exposure",status:e.Status.OK,extra:{threshold:t.threshold,observeTime:t.observeTime,showTime:t.showTime,showEndTime:i,duration:i-t.showTime,params:t.params}})}observe(e){(Array.isArray(e)?e:[e]).map(e=>o.parse(e)).forEach(e=>{const t=e.threshold||.5,s=this.ioMap.get(t)??this.initObserver(t);this.ioMap.set(t,s),this.targetMap.has(e.target)||(s.observe(e.target),this.targetMap.set(e.target,{threshold:t,observeTime:Date.now(),params:e.params??{}}))})}unobserve(e){(Array.isArray(e)?e:[e]).forEach(e=>this.unobserveOne(e))}unobserveOne(e){const t=this.targetMap.get(e);if(!t)return;const s=this.ioMap.get(t.threshold);s&&s.unobserve(e),this.targetMap.delete(e)}destroy(){this.ioMap.forEach(e=>{e.disconnect()}),this.ioMap.clear(),this.targetMap.clear()}}exports.default=n;