@swifty.js/sentry 0.0.3 → 0.0.5
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.
- package/LICENSE +21 -0
- package/README.md +24 -42
- package/dist/core/breadcrumb.cjs +1 -1
- package/dist/core/breadcrumb.js +1 -1
- package/dist/core/decorate-route.cjs +1 -1
- package/dist/core/decorate-route.js +1 -1
- package/dist/core/identity.cjs +1 -1
- package/dist/core/identity.js +1 -1
- package/dist/core/options-schema.d.ts +0 -1
- package/dist/core/pv-lifecycle.cjs +1 -1
- package/dist/core/pv-lifecycle.js +1 -1
- package/dist/core/sdk-lifecycle.cjs +1 -1
- package/dist/core/sdk-lifecycle.d.ts +1 -1
- package/dist/core/sdk-lifecycle.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/plugins/performance/resource-timing.cjs +1 -1
- package/dist/plugins/performance/resource-timing.js +1 -1
- package/dist/plugins/screen-record/recorder.cjs +1 -1
- package/dist/plugins/screen-record/recorder.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +1 -0
- package/dist/react.js +1 -1
- package/dist/reporter/report-data-schema.cjs +1 -1
- package/dist/reporter/report-data-schema.js +1 -1
- package/dist/reporter/report-data.cjs +1 -1
- package/dist/reporter/report-data.js +1 -1
- package/dist/source-map/vite.cjs +1 -0
- package/dist/source-map/vite.js +1 -0
- package/dist/source-map/webpack.cjs +1 -0
- package/dist/source-map/webpack.js +1 -0
- package/dist/types/common.d.ts +1 -1
- package/dist/types/enums.cjs +1 -1
- package/dist/types/enums.d.ts +20 -22
- package/dist/types/enums.js +1 -1
- package/dist/utils/click-data.cjs +1 -1
- package/dist/utils/click-data.js +1 -1
- package/dist/utils/dom2str.cjs +1 -0
- package/dist/utils/dom2str.js +1 -0
- package/dist/utils/logger.cjs +1 -1
- package/dist/utils/logger.js +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +26 -36
- package/dist/preact.cjs +0 -1
- package/dist/preact.d.ts +0 -74
- package/dist/preact.js +0 -1
- package/dist/sourcemap/vite.cjs +0 -1
- package/dist/sourcemap/vite.js +0 -1
- package/dist/sourcemap/webpack.cjs +0 -1
- package/dist/sourcemap/webpack.js +0 -1
- /package/dist/{sourcemap/sourcemap.cjs → source-map/source-map.cjs} +0 -0
- /package/dist/{sourcemap/sourcemap.js → source-map/source-map.js} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 hangtiancheng
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npm install vue
|
|
|
23
23
|
## Package Exports
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
|
-
import { init, destroy, isInitialized,
|
|
26
|
+
import { init, destroy, isInitialized, enablePlugin } from "@swifty.js/sentry";
|
|
27
27
|
import { PerformancePlugin, ScreenRecordPlugin, ExposurePlugin } from "@swifty.js/sentry/plugins";
|
|
28
28
|
import { ReactErrorBoundary } from "@swifty.js/sentry/react";
|
|
29
29
|
import { vuePlugin } from "@swifty.js/sentry/vue";
|
|
@@ -34,7 +34,7 @@ Each public export provides ESM, CJS, and TypeScript declaration files.
|
|
|
34
34
|
## Quick Start
|
|
35
35
|
|
|
36
36
|
```ts
|
|
37
|
-
import { init,
|
|
37
|
+
import { init, enablePlugin } from "@swifty.js/sentry";
|
|
38
38
|
import { PerformancePlugin, ScreenRecordPlugin, ExposurePlugin } from "@swifty.js/sentry/plugins";
|
|
39
39
|
|
|
40
40
|
init({
|
|
@@ -43,9 +43,9 @@ init({
|
|
|
43
43
|
userId: "anonymous",
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
enablePlugin(PerformancePlugin);
|
|
47
|
+
enablePlugin(ScreenRecordPlugin);
|
|
48
|
+
enablePlugin(ExposurePlugin);
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
`dsn` must be a non-empty string. If `dsn` is empty, initialization is rejected.
|
|
@@ -317,16 +317,16 @@ Custom `swifty-sentry-*` attributes become `params`.
|
|
|
317
317
|
|
|
318
318
|
The reported click payload (`DeclarativeClickData`) includes:
|
|
319
319
|
|
|
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` |
|
|
329
|
-
| `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` | CSS-selector-like ancestor path (nearest 5 levels with id/class, max 128 chars). |
|
|
329
|
+
| `triggerTime` | `number` | `Date.now()` at click time. |
|
|
330
330
|
|
|
331
331
|
## White-Screen Detection
|
|
332
332
|
|
|
@@ -541,10 +541,10 @@ const ips = await getIPs();
|
|
|
541
541
|
Plugins extend the SDK without coupling optional capabilities to the core entry. A plugin class extends `SentryPlugin`, implements `init`, and can implement `destroy` for cleanup.
|
|
542
542
|
|
|
543
543
|
```ts
|
|
544
|
-
import {
|
|
544
|
+
import { enablePlugin } from "@swifty.js/sentry";
|
|
545
545
|
import { PerformancePlugin } from "@swifty.js/sentry/plugins";
|
|
546
546
|
|
|
547
|
-
const plugin =
|
|
547
|
+
const plugin = enablePlugin(PerformancePlugin);
|
|
548
548
|
```
|
|
549
549
|
|
|
550
550
|
Enabled plugins are stored in the plugin registry. `destroy()` calls each plugin's `destroy()` method when available.
|
|
@@ -552,10 +552,10 @@ Enabled plugins are stored in the plugin registry. `destroy()` calls each plugin
|
|
|
552
552
|
## PerformancePlugin
|
|
553
553
|
|
|
554
554
|
```ts
|
|
555
|
-
import {
|
|
555
|
+
import { enablePlugin } from "@swifty.js/sentry";
|
|
556
556
|
import { PerformancePlugin } from "@swifty.js/sentry/plugins";
|
|
557
557
|
|
|
558
|
-
|
|
558
|
+
enablePlugin(PerformancePlugin);
|
|
559
559
|
```
|
|
560
560
|
|
|
561
561
|
The plugin collects:
|
|
@@ -572,12 +572,12 @@ Unsupported browser capabilities are skipped safely.
|
|
|
572
572
|
## ScreenRecordPlugin
|
|
573
573
|
|
|
574
574
|
```ts
|
|
575
|
-
import {
|
|
575
|
+
import { enablePlugin } from "@swifty.js/sentry";
|
|
576
576
|
import { ScreenRecordPlugin, unzipScreenRecord } from "@swifty.js/sentry/plugins";
|
|
577
577
|
|
|
578
|
-
|
|
578
|
+
enablePlugin(ScreenRecordPlugin);
|
|
579
579
|
|
|
580
|
-
|
|
580
|
+
enablePlugin(ScreenRecordPlugin, {
|
|
581
581
|
durationMs: 5000,
|
|
582
582
|
});
|
|
583
583
|
```
|
|
@@ -593,10 +593,10 @@ const events = unzipScreenRecord(recordPayload);
|
|
|
593
593
|
## ExposurePlugin
|
|
594
594
|
|
|
595
595
|
```ts
|
|
596
|
-
import {
|
|
596
|
+
import { enablePlugin } from "@swifty.js/sentry";
|
|
597
597
|
import { ExposurePlugin } from "@swifty.js/sentry/plugins";
|
|
598
598
|
|
|
599
|
-
const exposure =
|
|
599
|
+
const exposure = enablePlugin(ExposurePlugin);
|
|
600
600
|
```
|
|
601
601
|
|
|
602
602
|
Observe one element:
|
|
@@ -750,21 +750,3 @@ pnpm build
|
|
|
750
750
|
```
|
|
751
751
|
|
|
752
752
|
Coverage thresholds are 70 for lines, functions, branches, and statements.
|
|
753
|
-
|
|
754
|
-
## Build and Publish
|
|
755
|
-
|
|
756
|
-
```bash
|
|
757
|
-
pnpm build
|
|
758
|
-
pnpm build:tsup
|
|
759
|
-
python3 publish.py --dry-run
|
|
760
|
-
```
|
|
761
|
-
|
|
762
|
-
Publish after npm login:
|
|
763
|
-
|
|
764
|
-
```bash
|
|
765
|
-
python3 publish.py --publish --registry https://registry.npmjs.org/
|
|
766
|
-
```
|
|
767
|
-
|
|
768
|
-
The publish script validates lint, typecheck, tests, coverage, build output, ESM imports, CJS requires, package exports, absence of sourcemaps, absence of `dist/node_modules`, and absence of package tarball residue.
|
|
769
|
-
|
|
770
|
-
Published npm files are limited to `dist` and package metadata. Source files, tests, sourcemaps, and temporary tarballs are not published.
|
package/dist/core/breadcrumb.cjs
CHANGED
|
@@ -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");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.
|
|
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.default=r;
|
package/dist/core/breadcrumb.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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{
|
|
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{n as default};
|
|
@@ -1 +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)
|
|
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)return e.call(this,n,u,l);const a=o,c=function(t){return new URL(t.toString(),i()).href}(l),p=e.call(this,n,u,l);return a!==c&&(o=c,r.pub(t.EventType.History,{...s.default(),type:t.EventType.History,from:a,to:c})),p},l=e.default(globalThis.history,"pushState",u),a=e.default(globalThis.history,"replaceState",u);return()=>{globalThis.onpopstate=n,a(),l()}};
|
|
@@ -1 +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)
|
|
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)return o.call(this,e,l,a);const p=r,u=function(t){return new URL(t.toString(),n()).href}(a),c=o.call(this,e,l,a);return p!==u&&(r=u,i(t.History,{...s(),type:t.History,from:p,to:u})),c},a=o(globalThis.history,"pushState",l),p=o(globalThis.history,"replaceState",l);return()=>{globalThis.onpopstate=e,p(),a()}}export{e as pubHistory};
|
package/dist/core/identity.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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})};
|
package/dist/core/identity.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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};
|
|
@@ -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"),require("../utils/is-type.cjs");var t=require("../reporter/index.cjs");let
|
|
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 n=null;function s(n,s){t.default.send({...r.default(),type:e.EventType.PV,name:n.name,message:n.url,status:e.Status.OK,extra:{url:n.url,referrer:n.referrer,entryTime:n.startedAt}},s)}function a(n,s,a){s<=100||t.default.send({...r.default(),type:e.EventType.PV,name:"PageDwell",message:n.url,status:e.Status.OK,extra:{url:n.url,referrer:n.referrer,duration:s}},a)}function u(e,r,t){return{url:e,referrer:r,name:t,startedAt:Date.now()}}exports.flushCurrentPageDwell=function(e){n&&a(n,Date.now()-n.startedAt,e)},exports.initPageView=function(){n=u(globalThis.location?.href??"",globalThis.document?.referrer??"","PageLoad"),s(n,!0)},exports.recordRoutePageView=function(e,r,t){const l=globalThis.location.href,i=new URL(e,l).href,o=new URL(r,l).href;n?.url!==i&&(n&&a(n,Date.now()-n.startedAt,!1),n=u(i,o,t),s(n,!1))},exports.resetPageView=function(){n=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"../utils/is-type.js";import n from"../reporter/index.js";let
|
|
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 s=null;function o(s,o){n.send({...t(),type:r.PV,name:s.name,message:s.url,status:e.OK,extra:{url:s.url,referrer:s.referrer,entryTime:s.startedAt}},o)}function a(s,o,a){o<=100||n.send({...t(),type:r.PV,name:"PageDwell",message:s.url,status:e.OK,extra:{url:s.url,referrer:s.referrer,duration:o}},a)}function i(e,r,t){return{url:e,referrer:r,name:t,startedAt:Date.now()}}function l(){s=i(globalThis.location?.href??"",globalThis.document?.referrer??"","PageLoad"),o(s,!0)}function u(e,r,t){const n=globalThis.location.href,l=new URL(e,n).href,u=new URL(r,n).href;s?.url!==l&&(s&&a(s,Date.now()-s.startedAt,!1),s=i(l,u,t),o(s,!1))}function f(e){s&&a(s,Date.now()-s.startedAt,e)}function m(){s=null}export{f as flushCurrentPageDwell,l 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");require("../utils/is-type.cjs");var i=require("../utils/logger.cjs"),t=require("./identity.cjs"),s=require("./options-schema.cjs"),
|
|
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("./breadcrumb.cjs"),n=require("./options-schema.cjs"),o=require("./plugin-registry.cjs"),u=require("./setup.cjs"),a=require("./handle-code-error.cjs"),l=require("../reporter/index.cjs");let c=null;function d(){return null!==c}exports.destroy=function(){o.destroyPlugins(),c?.(),c=null,a.destroyBatchErrorManager(),l.resetReporter()},exports.enablePlugin=function(...e){for(const r of e)r.init(),o.registerPlugin(r)},exports.init=function(o){if(d())return void i.sentryLogger.info("SDK already initialized");const a=n.optionsSchema.parse({...e.DEFAULT_OPTIONS,...o});r.default.setOptions(a);const{dsn:l}=r.default.options;r.default.options.disabled?i.sentryLogger.info("SDK disabled by options"):""!==l?(i.sentryLogger.info("SDK initialized",{options:r.default.options}),s.default.capacity=r.default.options.maxBreadcrumbs,c=u.default(),t.initIdentity()):i.sentryLogger.error("Initialization failed: DSN is empty")},exports.isInitialized=d;
|
|
@@ -26,6 +26,6 @@ import { InitOptions } from './options-schema.js';
|
|
|
26
26
|
declare function isInitialized(): boolean;
|
|
27
27
|
declare function destroy(): void;
|
|
28
28
|
declare function init(options: InitOptions): void;
|
|
29
|
-
declare function enablePlugin(
|
|
29
|
+
declare function enablePlugin(...plugins: SentryPlugin[]): void;
|
|
30
30
|
|
|
31
31
|
export { destroy, enablePlugin, init, isInitialized };
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 r}from"./identity.js";import n from"./breadcrumb.js";import{optionsSchema as s}from"./options-schema.js";import{destroyPlugins as e,registerPlugin as p}from"./plugin-registry.js";import m from"./setup.js";import{destroyBatchErrorManager as f}from"./handle-code-error.js";import{resetReporter as l}from"../reporter/index.js";let a=null;function d(){return null!==a}function u(){e(),a?.(),a=null,f(),l()}function c(e){if(d())return void t.info("SDK already initialized");const p=s.parse({...i,...e});o.setOptions(p);const{dsn:f}=o.options;o.options.disabled?t.info("SDK disabled by options"):""!==f?(t.info("SDK initialized",{options:o.options}),n.capacity=o.options.maxBreadcrumbs,a=m(),r()):t.error("Initialization failed: DSN is empty")}function j(...i){for(const o of i)o.init(),p(o)}export{u as destroy,j as enablePlugin,c as init,d as isInitialized};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./core/sdk-lifecycle.cjs"),
|
|
1
|
+
"use strict";var e=require("./core/sdk-lifecycle.cjs"),r=require("./core/identity.cjs"),t=require("./core/api.cjs"),o=require("./core/framework-error.cjs"),s=require("./types/enums.cjs"),n=require("./types/plugin.cjs"),i=require("./core/ip.cjs");exports.destroy=e.destroy,exports.enablePlugin=e.enablePlugin,exports.init=e.init,exports.isInitialized=e.isInitialized,exports.getIdentity=r.getIdentity,exports.setUserId=r.setUserId,exports.setVisitorId=r.setVisitorId,exports.afterSendData=t.afterSendData,exports.beforePushEventList=t.beforePushEventList,exports.beforeSendData=t.beforeSendData,exports.getBaseInfo=t.getBaseInfo,exports.getUserId=t.getUserId,exports.sendLocal=t.sendLocal,exports.traceCustomEvent=t.traceCustomEvent,exports.traceError=t.traceError,exports.tracePageView=t.tracePageView,exports.tracePerformance=t.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,"HttpStatusCode",{enumerable:!0,get:function(){return s.HttpStatusCode}}),Object.defineProperty(exports,"Status",{enumerable:!0,get:function(){return s.Status}}),exports.SentryPlugin=n.SentryPlugin,exports.getIPs=i.getIPs;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { afterSendData, beforePushEventList, beforeSendData, getBaseInfo, getUse
|
|
|
4
4
|
export { reportFrameworkError } from './core/framework-error.js';
|
|
5
5
|
export { InitOptions } from './core/options-schema.js';
|
|
6
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';
|
|
7
|
-
export { BreadcrumbType, EventType, HttpMethod,
|
|
7
|
+
export { BreadcrumbType, EventType, HttpMethod, HttpStatusCode, Status } from './types/enums.js';
|
|
8
8
|
export { IPub, ISub, TEventHandler } from './types/handlers.js';
|
|
9
9
|
export { AfterSendDataHook, IOptions, ReportBatchHook, ReportDataHook } from './types/options.js';
|
|
10
10
|
export { SentryPlugin, WithSentry } from './types/plugin.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{reportFrameworkError}from"./core/framework-error.js";export{BreadcrumbType,EventType,HttpMethod,
|
|
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,HttpStatusCode,Status}from"./types/enums.js";export{SentryPlugin}from"./types/plugin.js";export{getIPs}from"./core/ip.js";
|
package/dist/package.json.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="0.0.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="0.0.5",r={version:e};exports.default=r,exports.version=e;
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a="0.0.
|
|
1
|
+
var a="0.0.5",e={version:a};export{e as default,a as version};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../types/enums.cjs");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs"),t=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs");var n=require("./performance-observer-support.cjs");const s=new Set(["fetch","xmlhttprequest","beacon"]);function i(e){return"resource"===e.entryType&&"initiatorType"in e}function o(e){return!s.has(e.initiatorType)&&!function(e){return""!==t.default.options.dsn&&e.name.includes(t.default.options.dsn)}(e)}function a(e){return{name:e.name,initiatorType:e.initiatorType,startTime:Math.round(e.startTime),responseEnd:Math.round(e.responseEnd),duration:Math.round(e.duration),transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize,fromCache:c(e)}}function u(t){return{...r.default(),type:e.EventType.Performance,name:"ResourceTiming",message:t.name,status:e.Status.OK,value:t.duration,extra:{resource:t}}}function c(e){return 0===e.transferSize||0!==e.transferSize&&0===e.encodedBodySize}function
|
|
1
|
+
"use strict";var e=require("../../types/enums.cjs");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs"),t=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs");var n=require("./performance-observer-support.cjs");const s=new Set(["fetch","xmlhttprequest","beacon"]);function i(e){return"resource"===e.entryType&&"initiatorType"in e}function o(e){return!s.has(e.initiatorType)&&!function(e){return""!==t.default.options.dsn&&e.name.includes(t.default.options.dsn)}(e)}function a(e){return{name:e.name,initiatorType:e.initiatorType,startTime:Math.round(e.startTime),responseEnd:Math.round(e.responseEnd),duration:Math.round(e.duration),transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize,fromCache:c(e)}}function u(t){return{...r.default(),type:e.EventType.Performance,name:"ResourceTiming",message:t.name,status:e.Status.OK,value:t.duration,extra:{resource:t}}}function c(e){return 0===e.transferSize||0!==e.transferSize&&0===e.encodedBodySize}function d(){return"performance"in globalThis&&"function"==typeof globalThis.performance.getEntriesByType?globalThis.performance.getEntriesByType("resource").filter(i).filter(o).map(a):[]}exports.createResourceTimingData=u,exports.getInitialResourceListData=function(){return{...r.default(),name:"ResourceList",type:e.EventType.Performance,status:e.Status.OK,resourceList:d()}},exports.getResourceList=d,exports.observeResourceTimings=function(e){if(!n.supportsPerformanceEntryType("resource"))return()=>{};const r=new globalThis.PerformanceObserver(r=>{r.getEntries().filter(i).filter(o).map(a).forEach(r=>{e(u(r))})});return r.observe({entryTypes:["resource"]}),()=>{r.disconnect()}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Status as e,EventType as r}from"../../types/enums.js";import"../../constants/index.js";import t from"../../utils/get-base-data.js";import n from"../../utils/sentry.js";import"../../utils/is-type.js";import{supportsPerformanceEntryType as o}from"./performance-observer-support.js";const i=new Set(["fetch","xmlhttprequest","beacon"]);function s(e){return"resource"===e.entryType&&"initiatorType"in e}function a(e){return!i.has(e.initiatorType)&&!function(e){return""!==n.options.dsn&&e.name.includes(n.options.dsn)}(e)}function u(e){return{name:e.name,initiatorType:e.initiatorType,startTime:Math.round(e.startTime),responseEnd:Math.round(e.responseEnd),duration:Math.round(e.duration),transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize,fromCache:f(e)}}function c(n){return{...t(),type:r.Performance,name:"ResourceTiming",message:n.name,status:e.OK,value:n.duration,extra:{resource:n}}}function f(e){return 0===e.transferSize||0!==e.transferSize&&0===e.encodedBodySize}function p(){return"performance"in globalThis&&"function"==typeof globalThis.performance.getEntriesByType?globalThis.performance.getEntriesByType("resource").filter(s).filter(a).map(u):[]}function m(){return{...t(),name:"ResourceList",type:r.Performance,status:e.OK,resourceList:p()}}function d(e){if(!o("resource"))return()=>{};const r=new globalThis.PerformanceObserver(r=>{r.getEntries().filter(s).filter(a).map(u).forEach(r=>{e(c(r))})});return r.observe({entryTypes:["resource"]}),()=>{r.disconnect()}}export{c as createResourceTimingData,m as getInitialResourceListData,p as getResourceList,
|
|
1
|
+
import{Status as e,EventType as r}from"../../types/enums.js";import"../../constants/index.js";import t from"../../utils/get-base-data.js";import n from"../../utils/sentry.js";import"../../utils/is-type.js";import{supportsPerformanceEntryType as o}from"./performance-observer-support.js";const i=new Set(["fetch","xmlhttprequest","beacon"]);function s(e){return"resource"===e.entryType&&"initiatorType"in e}function a(e){return!i.has(e.initiatorType)&&!function(e){return""!==n.options.dsn&&e.name.includes(n.options.dsn)}(e)}function u(e){return{name:e.name,initiatorType:e.initiatorType,startTime:Math.round(e.startTime),responseEnd:Math.round(e.responseEnd),duration:Math.round(e.duration),transferSize:e.transferSize,encodedBodySize:e.encodedBodySize,decodedBodySize:e.decodedBodySize,fromCache:f(e)}}function c(n){return{...t(),type:r.Performance,name:"ResourceTiming",message:n.name,status:e.OK,value:n.duration,extra:{resource:n}}}function f(e){return 0===e.transferSize||0!==e.transferSize&&0===e.encodedBodySize}function p(){return"performance"in globalThis&&"function"==typeof globalThis.performance.getEntriesByType?globalThis.performance.getEntriesByType("resource").filter(s).filter(a).map(u):[]}function m(){return{...t(),name:"ResourceList",type:r.Performance,status:e.OK,resourceList:p()}}function d(e){if(!o("resource"))return()=>{};const r=new globalThis.PerformanceObserver(r=>{r.getEntries().filter(s).filter(a).map(u).forEach(r=>{e(c(r))})});return r.observe({entryTypes:["resource"]}),()=>{r.disconnect()}}export{c as createResourceTimingData,m as getInitialResourceListData,p as getResourceList,d as observeResourceTimings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../types/enums.cjs");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs"),t=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs");var n=require("../../utils/logger.cjs"),o=require("zod");let s=null;const c=o.z.
|
|
1
|
+
"use strict";var e=require("../../types/enums.cjs");require("../../constants/index.cjs");var r=require("../../utils/get-base-data.cjs"),t=require("../../utils/sentry.cjs");require("../../utils/is-type.cjs");var n=require("../../utils/logger.cjs"),o=require("zod");let s=null;const c=o.z.looseObject({timestamp:o.z.number()});function i(){}function u(e,r){const n=r-t.default.options.screenRecordDurationMs;return e.filter(e=>e.timestamp>=n)}function a(e){if(!e||!s)return"";const r=JSON.stringify(e);return function(e){let r="";return e.forEach(e=>{r+=String.fromCharCode(e)}),btoa(r)}(s.gzip(r))}exports.recorder=async function(o){n.sentryLogger.info("Initializing web recorder...");try{const[{record:d},l]=await Promise.all([import("@rrweb/record"),import("pako")]);s=l.default;let f=[];const p=d({emit(s,i){const d=c.safeParse(s);if(d.success&&(f=u([...f,d.data],d.data.timestamp),i&&(f=u(f,d.data.timestamp)),t.default.shouldScreenRecord&&f.length>0)){const s={...r.default(),name:"ScreenRecord",type:e.EventType.ScreenRecord,event:a(f),eventCount:f.length};n.sentryLogger.success("Screen record window packaged and sent",{eventCount:s.eventCount}),o.send(s),t.default.shouldScreenRecord=!1}},recordCanvas:!0,checkoutEveryNms:t.default.options.screenRecordDurationMs});return"function"==typeof p?p:i}catch(e){return n.sentryLogger.error("Failed to load web recorder",e),i}},exports.unzipScreenRecord=function(e){if(!e||!s)return null;const r=s.ungzip(function(e){const r=atob(e);return Uint8Array.from(r,e=>e.charCodeAt(0))}(e),{to:"string"});return JSON.parse(r)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EventType as t}from"../../types/enums.js";import"../../constants/index.js";import e from"../../utils/get-base-data.js";import r from"../../utils/sentry.js";import"../../utils/is-type.js";import{sentryLogger as n}from"../../utils/logger.js";import{z as o}from"zod";let s=null;const i=o.
|
|
1
|
+
import{EventType as t}from"../../types/enums.js";import"../../constants/index.js";import e from"../../utils/get-base-data.js";import r from"../../utils/sentry.js";import"../../utils/is-type.js";import{sentryLogger as n}from"../../utils/logger.js";import{z as o}from"zod";let s=null;const i=o.looseObject({timestamp:o.number()});function c(){}function a(t,e){const n=e-r.options.screenRecordDurationMs;return t.filter(t=>t.timestamp>=n)}async function u(o){n.info("Initializing web recorder...");try{const[{record:u},d]=await Promise.all([import("@rrweb/record"),import("pako")]);s=d.default;let f=[];const p=u({emit(s,c){const u=i.safeParse(s);if(u.success&&(f=a([...f,u.data],u.data.timestamp),c&&(f=a(f,u.data.timestamp)),r.shouldScreenRecord&&f.length>0)){const s={...e(),name:"ScreenRecord",type:t.ScreenRecord,event:m(f),eventCount:f.length};n.success("Screen record window packaged and sent",{eventCount:s.eventCount}),o.send(s),r.shouldScreenRecord=!1}},recordCanvas:!0,checkoutEveryNms:r.options.screenRecordDurationMs});return"function"==typeof p?p:c}catch(t){return n.error("Failed to load web recorder",t),c}}function m(t){if(!t||!s)return"";const e=JSON.stringify(t);return function(t){let e="";return t.forEach(t=>{e+=String.fromCharCode(t)}),btoa(e)}(s.gzip(e))}function d(t){if(!t||!s)return null;const e=s.ungzip(function(t){const e=atob(t);return Uint8Array.from(e,t=>t.charCodeAt(0))}(t),{to:"string"});return JSON.parse(e)}export{u as recorder,d as unzipScreenRecord};
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var r=require("react"),e=require("./types/enums.cjs"),t=require("./core/framework-error.cjs");class o extends r.Component{state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),t.reportFrameworkError({type:e.EventType.React,error:r,context:o})}render(){const{error:r,errorInfo:e}=this.state;if(r){const{fallback:t}=this.props;return"function"==typeof t?t(r,e):t??null}return this.props.children??null}}exports.ReactErrorBoundary=o;
|
|
1
|
+
"use strict";var r=require("react"),e=require("./types/enums.cjs"),t=require("./core/framework-error.cjs");class o extends r.Component{static displayName="ReactErrorBoundary";state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),t.reportFrameworkError({type:e.EventType.React,error:r,context:o})}render(){const{error:r,errorInfo:e}=this.state;if(r){const{fallback:t}=this.props;return"function"==typeof t?t(r,e):t??null}return this.props.children??null}}exports.ReactErrorBoundary=o;
|
package/dist/react.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ interface ReactErrorBoundaryState {
|
|
|
76
76
|
* ```
|
|
77
77
|
*/
|
|
78
78
|
declare class ReactErrorBoundary extends Component<ReactErrorBoundaryProps, ReactErrorBoundaryState> {
|
|
79
|
+
static displayName: string;
|
|
79
80
|
state: ReactErrorBoundaryState;
|
|
80
81
|
/**
|
|
81
82
|
* Called by React during the **render phase** when a descendant throws.
|
package/dist/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Component as r}from"react";import{EventType as t}from"./types/enums.js";import{reportFrameworkError as e}from"./core/framework-error.js";class o extends r{state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),e({type:t.React,error:r,context:o})}render(){const{error:r,errorInfo:t}=this.state;if(r){const{fallback:e}=this.props;return"function"==typeof e?e(r,t):e??null}return this.props.children??null}}export{o as ReactErrorBoundary};
|
|
1
|
+
import{Component as r}from"react";import{EventType as t}from"./types/enums.js";import{reportFrameworkError as e}from"./core/framework-error.js";class o extends r{static displayName="ReactErrorBoundary";state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),e({type:t.React,error:r,context:o})}render(){const{error:r,errorInfo:t}=this.state;if(r){const{fallback:e}=this.props;return"function"==typeof e?e(r,t):e??null}return this.props.children??null}}export{o as ReactErrorBoundary};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("zod"),t=require("../types/enums.cjs");const r=e.z.object({browserName:e.z.string(),browserVersion:e.z.string(),osName:e.z.string(),osVersion:e.z.string(),userAgent:e.z.string(),deviceType:e.z.string(),deviceModel:e.z.string(),fingerprint:e.z.string(),language:e.z.string(),screenResolution:e.z.string()}),s=e.z.object({id:e.z.string(),type:e.z.enum(t.EventType),name:e.z.string(),time:e.z.string(),timestamp:e.z.number(),message:e.z.string(),status:e.z.enum(t.Status),url:e.z.string(),userId:e.z.string(),projectId:e.z.string(),sdkVersion:e.z.string(),deviceInfo:r,payload:e.z.custom(e=>"object"==typeof e&&null!==e,"Expected a report payload object")}),n=e.z.array(s);exports.
|
|
1
|
+
"use strict";var e=require("zod"),t=require("../types/enums.cjs");const r=e.z.object({browserName:e.z.string(),browserVersion:e.z.string(),osName:e.z.string(),osVersion:e.z.string(),userAgent:e.z.string(),deviceType:e.z.string(),deviceModel:e.z.string(),fingerprint:e.z.string(),language:e.z.string(),screenResolution:e.z.string()}),s=e.z.object({id:e.z.string(),type:e.z.enum(t.EventType),name:e.z.string(),time:e.z.string(),timestamp:e.z.number(),message:e.z.string(),status:e.z.enum(t.Status),url:e.z.string(),userId:e.z.string(),projectId:e.z.string(),sdkVersion:e.z.string(),breadcrumbs:e.z.array(e.z.custom(e=>"object"==typeof e&&null!==e,"Expected a breadcrumb item object")).optional(),deviceInfo:r,payload:e.z.custom(e=>"object"==typeof e&&null!==e,"Expected a report payload object")}),n=e.z.array(s);exports.reportDataListSchema=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";import{Status as r,EventType as t}from"../types/enums.js";const s=e.object({browserName:e.string(),browserVersion:e.string(),osName:e.string(),osVersion:e.string(),userAgent:e.string(),deviceType:e.string(),deviceModel:e.string(),fingerprint:e.string(),language:e.string(),screenResolution:e.string()}),n=e.object({id:e.string(),type:e.enum(t),name:e.string(),time:e.string(),timestamp:e.number(),message:e.string(),status:e.enum(r),url:e.string(),userId:e.string(),projectId:e.string(),sdkVersion:e.string(),deviceInfo:s,payload:e.custom(e=>"object"==typeof e&&null!==e,"Expected a report payload object")}),i=e.array(n);export{
|
|
1
|
+
import{z as e}from"zod";import{Status as r,EventType as t}from"../types/enums.js";const s=e.object({browserName:e.string(),browserVersion:e.string(),osName:e.string(),osVersion:e.string(),userAgent:e.string(),deviceType:e.string(),deviceModel:e.string(),fingerprint:e.string(),language:e.string(),screenResolution:e.string()}),n=e.object({id:e.string(),type:e.enum(t),name:e.string(),time:e.string(),timestamp:e.number(),message:e.string(),status:e.enum(r),url:e.string(),userId:e.string(),projectId:e.string(),sdkVersion:e.string(),breadcrumbs:e.array(e.custom(e=>"object"==typeof e&&null!==e,"Expected a breadcrumb item object")).optional(),deviceInfo:s,payload:e.custom(e=>"object"==typeof e&&null!==e,"Expected a report payload object")}),i=e.array(n);export{i as reportDataListSchema};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../constants/index.cjs")
|
|
1
|
+
"use strict";var e=require("../constants/index.cjs"),t=require("../core/breadcrumb.cjs"),r=require("../types/enums.cjs"),s=require("../utils/sentry.cjs");require("../utils/is-type.cjs");var n=require("./promise.cjs");const o=new Set([r.EventType.Error,r.EventType.UnhandledRejection,r.EventType.Resource,r.EventType.Vue,r.EventType.React,r.EventType.OtherFrameworks]);function u(e){return!1===e?null:e}exports.runBeforeReportHook=function(r,i){const a=function(r,n){const{type:u,name:i,time:a,timestamp:c,message:p,status:d}=n,m={type:u,name:i,time:a,timestamp:c,message:p,status:d,id:r,url:location.href,userId:s.default.options.userId,projectId:s.default.options.projectId,sdkVersion:e.SDK_VERSION,deviceInfo:s.default.deviceInfo,payload:n};return o.has(u)&&(m.breadcrumbs=t.default.dump()),m}(r,i);if(!s.default.options.onBeforeReportData)return a;const c=s.default.options.onBeforeReportData(a);return n.isPromise(c)?c.then(u):u(c)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SDK_VERSION as
|
|
1
|
+
import{SDK_VERSION as e}from"../constants/index.js";import t from"../core/breadcrumb.js";import{EventType as o}from"../types/enums.js";import r from"../utils/sentry.js";import"../utils/is-type.js";import{isPromise as s}from"./promise.js";const n=new Set([o.Error,o.UnhandledRejection,o.Resource,o.Vue,o.React,o.OtherFrameworks]);function i(o,i){const p=function(o,s){const{type:i,name:m,time:p,timestamp:a,message:u,status:c}=s,d={type:i,name:m,time:p,timestamp:a,message:u,status:c,id:o,url:location.href,userId:r.options.userId,projectId:r.options.projectId,sdkVersion:e,deviceInfo:r.deviceInfo,payload:s};return n.has(i)&&(d.breadcrumbs=t.dump()),d}(o,i);if(!r.options.onBeforeReportData)return p;const a=r.options.onBeforeReportData(p);return s(a)?a.then(m):m(a)}function m(e){return!1===e?null:e}export{i as runBeforeReportHook};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=require("./source-map.cjs");exports.enrichReportData=async function(t,e){return r.enrichReportData(function(t){return async e=>{const{pathname:a,search:n}=r.splitScriptUrl(e),u=await t.moduleGraph.getModuleByUrl(a+n)??await t.moduleGraph.getModuleByUrl(a);return u?.transformResult?.map??null}}(t),e)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{enrichReportData as r,splitScriptUrl as a}from"./source-map.js";async function t(t,e){return r(function(r){return async t=>{const{pathname:e,search:n}=a(t),o=await r.moduleGraph.getModuleByUrl(e+n)??await r.moduleGraph.getModuleByUrl(e);return o?.transformResult?.map??null}}(t),e)}export{t as enrichReportData};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("./source-map.cjs");function e(t){return t.replace(/\\/g,"/").replace(/^\/+/,"")}exports.enrichReportData=t.enrichReportData,exports.createAssetMapStore=function(){const r=new Map;return{put:(t,n)=>{const a=e(t);a.endsWith(".map")&&r.set(a,n)},loadMap:async n=>{const{pathname:a}=t.splitScriptUrl(n),p=e(a);if(!p)return null;let s=r.get(`${p}.map`);if(void 0===s){const t=`${p.split("/").pop()}.map`;for(const[e,n]of r)if(e===t||e.endsWith(`/${t}`)){s=n;break}}if(void 0===s)return null;try{return JSON.parse(s)}catch{return null}}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{splitScriptUrl as t}from"./source-map.js";export{enrichReportData}from"./source-map.js";function r(t){return t.replace(/\\/g,"/").replace(/^\/+/,"")}function e(){const e=new Map;return{put:(t,n)=>{const o=r(t);o.endsWith(".map")&&e.set(o,n)},loadMap:async n=>{const{pathname:o}=t(n),p=r(o);if(!p)return null;let a=e.get(`${p}.map`);if(void 0===a){const t=`${p.split("/").pop()}.map`;for(const[r,n]of e)if(r===t||r.endsWith(`/${t}`)){a=n;break}}if(void 0===a)return null;try{return JSON.parse(a)}catch{return null}}}}export{e as createAssetMapStore};
|
package/dist/types/common.d.ts
CHANGED
|
@@ -142,7 +142,7 @@ interface IReportData<T extends TReportPayload = TReportPayload> extends IReport
|
|
|
142
142
|
userId: string;
|
|
143
143
|
projectId: string;
|
|
144
144
|
sdkVersion: string;
|
|
145
|
-
breadcrumbs?: IBreadcrumbItem[];
|
|
145
|
+
breadcrumbs?: IBreadcrumbItem[] | undefined;
|
|
146
146
|
deviceInfo: IDeviceInfo;
|
|
147
147
|
payload: T;
|
|
148
148
|
}
|
package/dist/types/enums.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t,o,
|
|
1
|
+
"use strict";var e,t,r,o,a;exports.BreadcrumbType=void 0,(e=exports.BreadcrumbType||(exports.BreadcrumbType={})).Http="Http",e.Click="Click",e.Route="Route",e.Resource="Resource",e.CodeError="Code Error",e.Custom="Custom",exports.Status=void 0,(t=exports.Status||(exports.Status={})).Error="Error",t.OK="OK",exports.EventType=void 0,(r=exports.EventType||(exports.EventType={})).Xhr="XMLHttpRequest",r.Fetch="fetch",r.Click="Click",r.HashChange="Event hashchange",r.History="History",r.Resource="Resource",r.UnhandledRejection="Event unhandledrejection",r.Error="Error",r.Vue="Vue",r.React="React",r.OtherFrameworks="OtherFrameworks",r.Performance="Performance",r.ScreenRecord="ScreenRecord",r.Exposure="Exposure",r.WhiteScreen="WhiteScreen",r.Custom="Custom",r.PV="PV",exports.HttpStatusCode=void 0,(o=exports.HttpStatusCode||(exports.HttpStatusCode={}))[o.OK=200]="OK",o[o.InternalServerError=500]="InternalServerError",o[o.BadRequest=400]="BadRequest",o[o.Unauthorized=401]="Unauthorized",o[o.Forbidden=403]="Forbidden",o[o.NotFound=404]="NotFound",o[o.Conflict=409]="Conflict",o[o.PayloadTooLarge=413]="PayloadTooLarge",o[o.TooManyRequests=429]="TooManyRequests",o[o.NotImplemented=501]="NotImplemented",o[o.ServiceUnavailable=503]="ServiceUnavailable",o[o.GatewayTimeout=504]="GatewayTimeout",exports.HttpMethod=void 0,(a=exports.HttpMethod||(exports.HttpMethod={})).Get="GET",a.Post="POST",a.Head="HEAD",a.Put="PUT",a.Delete="DELETE",a.Connect="CONNECT",a.Options="OPTIONS",a.Trace="TRACE",a.Patch="PATCH";
|
package/dist/types/enums.d.ts
CHANGED
|
@@ -19,21 +19,6 @@
|
|
|
19
19
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
20
|
* SOFTWARE.
|
|
21
21
|
*/
|
|
22
|
-
declare enum HttpStatus {
|
|
23
|
-
OK = "OK",// 200
|
|
24
|
-
BadRequest = "Bad Request",// 400
|
|
25
|
-
Unauthorized = "Unauthorized",// 401
|
|
26
|
-
Forbidden = "Forbidden",// 403
|
|
27
|
-
NotFound = "NotFound",// 404
|
|
28
|
-
Conflict = "Conflict",// 409
|
|
29
|
-
PayloadTooLarge = "Payload Too Large",// 413
|
|
30
|
-
TooManyRequests = "Too Many Requests",// 429
|
|
31
|
-
InternalServerError = "Internal Server Error",// 500
|
|
32
|
-
NotImplemented = "Not Implemented",// 501
|
|
33
|
-
ServiceUnavailable = "Service Unavailable",// 503
|
|
34
|
-
GatewayTimeout = "Gateway Timeout",// 504
|
|
35
|
-
UnknownError = "Unknown Error"
|
|
36
|
-
}
|
|
37
22
|
declare enum BreadcrumbType {
|
|
38
23
|
Http = "Http",
|
|
39
24
|
Click = "Click",
|
|
@@ -65,34 +50,47 @@ declare enum EventType {
|
|
|
65
50
|
Custom = "Custom",
|
|
66
51
|
PV = "PV"
|
|
67
52
|
}
|
|
68
|
-
declare enum HttpType {
|
|
69
|
-
Xhr = "XMLHttpRequest",
|
|
70
|
-
Fetch = "fetch"
|
|
71
|
-
}
|
|
72
53
|
declare enum HttpStatusCode {
|
|
73
54
|
OK = 200,
|
|
55
|
+
InternalServerError = 500,
|
|
56
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
74
57
|
BadRequest = 400,
|
|
58
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
75
59
|
Unauthorized = 401,
|
|
60
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
76
61
|
Forbidden = 403,
|
|
62
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
77
63
|
NotFound = 404,
|
|
64
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
78
65
|
Conflict = 409,
|
|
66
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
79
67
|
PayloadTooLarge = 413,
|
|
68
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
80
69
|
TooManyRequests = 429,
|
|
81
|
-
|
|
70
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
82
71
|
NotImplemented = 501,
|
|
72
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
83
73
|
ServiceUnavailable = 503,
|
|
74
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
84
75
|
GatewayTimeout = 504
|
|
85
76
|
}
|
|
86
77
|
declare enum HttpMethod {
|
|
87
78
|
Get = "GET",
|
|
88
|
-
Head = "HEAD",
|
|
89
79
|
Post = "POST",
|
|
80
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
81
|
+
Head = "HEAD",
|
|
82
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
90
83
|
Put = "PUT",
|
|
84
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
91
85
|
Delete = "DELETE",
|
|
86
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
92
87
|
Connect = "CONNECT",
|
|
88
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
93
89
|
Options = "OPTIONS",
|
|
90
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
94
91
|
Trace = "TRACE",
|
|
92
|
+
/** @deprecated Unreferenced in the SDK; kept as public API. */
|
|
95
93
|
Patch = "PATCH"
|
|
96
94
|
}
|
|
97
95
|
|
|
98
|
-
export { BreadcrumbType, EventType, HttpMethod,
|
|
96
|
+
export { BreadcrumbType, EventType, HttpMethod, HttpStatusCode, Status };
|
package/dist/types/enums.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,o,
|
|
1
|
+
var e,r,o,t,n;!function(e){e.Http="Http",e.Click="Click",e.Route="Route",e.Resource="Resource",e.CodeError="Code Error",e.Custom="Custom"}(e||(e={})),function(e){e.Error="Error",e.OK="OK"}(r||(r={})),function(e){e.Xhr="XMLHttpRequest",e.Fetch="fetch",e.Click="Click",e.HashChange="Event hashchange",e.History="History",e.Resource="Resource",e.UnhandledRejection="Event unhandledrejection",e.Error="Error",e.Vue="Vue",e.React="React",e.OtherFrameworks="OtherFrameworks",e.Performance="Performance",e.ScreenRecord="ScreenRecord",e.Exposure="Exposure",e.WhiteScreen="WhiteScreen",e.Custom="Custom",e.PV="PV"}(o||(o={})),function(e){e[e.OK=200]="OK",e[e.InternalServerError=500]="InternalServerError",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.Conflict=409]="Conflict",e[e.PayloadTooLarge=413]="PayloadTooLarge",e[e.TooManyRequests=429]="TooManyRequests",e[e.NotImplemented=501]="NotImplemented",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"}(t||(t={})),function(e){e.Get="GET",e.Post="POST",e.Head="HEAD",e.Put="PUT",e.Delete="DELETE",e.Connect="CONNECT",e.Options="OPTIONS",e.Trace="TRACE",e.Patch="PATCH"}(n||(n={}));export{e as BreadcrumbType,o as EventType,n as HttpMethod,t as HttpStatusCode,r as Status};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";var t=require("./dom2str.cjs");const e="swifty-sentry-",n=new Set(["view","msg","ev"]);function r(t){return t.hasAttribute("swifty-sentry-el")||t.hasAttribute("swifty-sentry-ev")||t.hasAttribute("swifty-sentry-msg")}function s(t){const e=(n=t)?n.getAttribute("swifty-sentry-msg")??n.title:"";var n;if(e)return e;const r=t.textContent?.trim();return r||t.getAttribute("aria-label")||t.tagName.toLowerCase()}function i(t,e){for(const n of t){const t=n.getAttribute(e);if(t)return t}return null}function o(t){const e=i(t,"swifty-sentry-ev");if(e)return e;const n=i(t,"title");if(n)return n;const r=i(t,"swifty-sentry-el");return r||(t[0]?.tagName.toLowerCase()??"unknown")}function a(t){const r=t.find(t=>Array.from(t.attributes).some(t=>t.name.startsWith(e)));return r?Array.from(r.attributes).reduce((t,r)=>{if(!r.name.startsWith(e))return t;const s=r.name.replace(e,"");return n.has(s)||(t[s]=r.value||null),t},{}):{}}exports.getDeclarativeClickData=function(e){const n=function(t){return t.composedPath().filter(t=>t instanceof HTMLElement)}(e),i=n.length>0?n:function(t){if(!(t instanceof HTMLElement))return[];const e=[];let n=t;for(;n;)e.push(n),n=n.parentElement;return e}(e.target),u=i.find(r);if(!u)return null;const c=e.target instanceof HTMLElement?e.target:u,{top:f,left:l}=c.getBoundingClientRect(),{scrollTop:m,scrollLeft:g}=document.documentElement;return{ev:o(i),msg:s(u),triggerPageUrl:location.href,x:l+g,y:f+m,params:a(i),elementPath:t.default(u),triggerTime:Date.now()}};
|
package/dist/utils/click-data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import t from"./dom2str.js";const e="swifty-sentry-",n=new Set(["view","msg","ev"]);function r(t){return t.hasAttribute("swifty-sentry-el")||t.hasAttribute("swifty-sentry-ev")||t.hasAttribute("swifty-sentry-msg")}function s(t){const e=(n=t)?n.getAttribute("swifty-sentry-msg")??n.title:"";var n;if(e)return e;const r=t.textContent?.trim();return r||t.getAttribute("aria-label")||t.tagName.toLowerCase()}function o(t,e){for(const n of t){const t=n.getAttribute(e);if(t)return t}return null}function i(t){const e=o(t,"swifty-sentry-ev");if(e)return e;const n=o(t,"title");if(n)return n;const r=o(t,"swifty-sentry-el");return r||(t[0]?.tagName.toLowerCase()??"unknown")}function u(t){const r=t.find(t=>Array.from(t.attributes).some(t=>t.name.startsWith(e)));return r?Array.from(r.attributes).reduce((t,r)=>{if(!r.name.startsWith(e))return t;const s=r.name.replace(e,"");return n.has(s)||(t[s]=r.value||null),t},{}):{}}function a(e){const n=function(t){return t.composedPath().filter(t=>t instanceof HTMLElement)}(e),o=n.length>0?n:function(t){if(!(t instanceof HTMLElement))return[];const e=[];let n=t;for(;n;)e.push(n),n=n.parentElement;return e}(e.target),a=o.find(r);if(!a)return null;const f=e.target instanceof HTMLElement?e.target:a,{top:c,left:l}=f.getBoundingClientRect(),{scrollTop:m,scrollLeft:g}=document.documentElement;return{ev:i(o),msg:s(a),triggerPageUrl:location.href,x:l+g,y:c+m,params:u(o),elementPath:t(a),triggerTime:Date.now()}}export{a as getDeclarativeClickData};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function e(e){let t=e.tagName.toLowerCase();e.id&&(t+=`#${e.id}`);const{className:n}=e;if(n&&"string"==typeof n)for(const e of n.split(/\s+/))e&&(t+=`.${e}`);return t}exports.default=function(t){try{const n=[];let r=0,o=0,s=t;for(;s&&o++<5;){const t=e(s),l=r+3*n.length+t.length;if("html"===t||o>1&&l>=128)break;n.push(t),r+=t.length,s=s.parentElement}return n.reverse().join(" > ")}catch{return"<unknown>"}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t){let e=t.tagName.toLowerCase();t.id&&(e+=`#${t.id}`);const{className:n}=t;if(n&&"string"==typeof n)for(const t of n.split(/\s+/))t&&(e+=`.${t}`);return e}function e(e){try{const n=[];let r=0,o=0,s=e;for(;s&&o++<5;){const e=t(s),a=r+3*n.length+e.length;if("html"===e||o>1&&a>=128)break;n.push(e),r+=e.length,s=s.parentElement}return n.reverse().join(" > ")}catch{return"<unknown>"}}export{e as default};
|
package/dist/utils/logger.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=
|
|
1
|
+
"use strict";const o="#74d4ff",s="#bbf450",e="#ffb869",r="#ffa2a2",l="#62748e",n="font-family: Iosevka, Maple Mono, Menlo, Cascadia Code;",c=o=>`color: ${o}; ${n}`,a=o=>`color: ${l}; background: ${o}; border-radius: 4px; ${n}`,i={info:{message:c(o),prefix:a(o)},success:{message:c(s),prefix:a(s)},warn:{message:c(e),prefix:a(e)},error:{message:c(r),prefix:a(r)}},g={get isEnabled(){return globalThis.__sentry__?.options.debug??!1},info(o,s,e,r="@swifty.js/sentry"){this.isEnabled&&(console.groupCollapsed(`%c ${r} %c ${o} `,i.info.prefix,i.info.message),void 0!==s&&(Array.isArray(s)?e?console.table(s,e):console.table(s):"object"==typeof s&&null!==s?(console.group("Details"),console.log(s),console.groupEnd()):console.log(s)),console.groupEnd())},success(o,s,e,r="@swifty.js/sentry"){this.isEnabled&&(console.groupCollapsed(`%c ${r} %c ${o} `,i.success.prefix,i.success.message),void 0!==e&&console.log(`%c Time cost %c ${e}ms`,i.success.prefix,i.success.message),void 0!==s&&(Array.isArray(s)?console.table(s):"object"==typeof s&&null!==s?(console.group("Response Data"),console.log(s),console.groupEnd()):console.log(s)),console.groupEnd())},warn(o,s,e="@swifty.js/sentry"){this.isEnabled&&(console.groupCollapsed(`%c ${e} %c ${o} `,i.warn.prefix,i.warn.message),void 0!==s&&(Array.isArray(s)?console.table(s):"object"==typeof s&&null!==s?(console.group("Warning Details"),console.log(s),console.groupEnd()):console.log(s)),console.groupEnd())},error(o,s,e="@swifty.js/sentry"){this.isEnabled&&(console.groupCollapsed(`%c ${e} %c ${o} `,i.error.prefix,i.error.message),void 0!==s&&(console.group("Error Details"),console.error(s),console.groupEnd()),console.groupEnd())}};exports.sentryLogger=g;
|
package/dist/utils/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o=
|
|
1
|
+
const o="#74d4ff",e="#bbf450",s="#ffb869",r="#ffa2a2",l="#62748e",n="font-family: Iosevka, Maple Mono, Menlo, Cascadia Code;",c=o=>`color: ${o}; ${n}`,a=o=>`color: ${l}; background: ${o}; border-radius: 4px; ${n}`,i={info:{message:c(o),prefix:a(o)},success:{message:c(e),prefix:a(e)},warn:{message:c(s),prefix:a(s)},error:{message:c(r),prefix:a(r)}},g={get isEnabled(){return globalThis.__sentry__?.options.debug??!1},info(o,e,s,r="@swifty.js/sentry"){this.isEnabled&&(console.groupCollapsed(`%c ${r} %c ${o} `,i.info.prefix,i.info.message),void 0!==e&&(Array.isArray(e)?s?console.table(e,s):console.table(e):"object"==typeof e&&null!==e?(console.group("Details"),console.log(e),console.groupEnd()):console.log(e)),console.groupEnd())},success(o,e,s,r="@swifty.js/sentry"){this.isEnabled&&(console.groupCollapsed(`%c ${r} %c ${o} `,i.success.prefix,i.success.message),void 0!==s&&console.log(`%c Time cost %c ${s}ms`,i.success.prefix,i.success.message),void 0!==e&&(Array.isArray(e)?console.table(e):"object"==typeof e&&null!==e?(console.group("Response Data"),console.log(e),console.groupEnd()):console.log(e)),console.groupEnd())},warn(o,e,s="@swifty.js/sentry"){this.isEnabled&&(console.groupCollapsed(`%c ${s} %c ${o} `,i.warn.prefix,i.warn.message),void 0!==e&&(Array.isArray(e)?console.table(e):"object"==typeof e&&null!==e?(console.group("Warning Details"),console.log(e),console.groupEnd()):console.log(e)),console.groupEnd())},error(o,e,s="@swifty.js/sentry"){this.isEnabled&&(console.groupCollapsed(`%c ${s} %c ${o} `,i.error.prefix,i.error.message),void 0!==e&&(console.group("Error Details"),console.error(e),console.groupEnd()),console.groupEnd())}};export{g as sentryLogger};
|
package/dist/vite.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("node:buffer"),t=require("node:path"),n=require("node:fs");require("./constants/index.cjs"),require("./types/enums.cjs");var r=require("./utils/sentry.cjs");require("./utils/is-type.cjs");var s=require("./utils/logger.cjs"),i=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("node:buffer"),t=require("node:path"),n=require("node:fs");require("./constants/index.cjs"),require("./types/enums.cjs");var r=require("./utils/sentry.cjs");require("./utils/is-type.cjs");var s=require("./utils/logger.cjs"),i=require("./source-map/vite.cjs");function o(t,n){return"string"==typeof n?t+n:e.Buffer.isBuffer(n)?t+n.toString("utf8"):n instanceof Uint8Array?t+e.Buffer.from(n).toString("utf8"):t}function c(e){return JSON.parse(e)}const u=(e,t)=>n=>{n.middlewares.use((r,s,u)=>{if(r.url===e&&"POST"===r.method){let e="";r.on("data",t=>{e=o(e,t)}),r.on("end",async()=>{if(e)try{const r=c(e),s=await i.enrichReportData(n,r);t.write(JSON.stringify(s)+"\n")}catch{t.write(e+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else u()})},a=(e,t)=>n=>{n.middlewares.use((r,s,u)=>{if(r.url===e&&"POST"===r.method){let e="";r.on("data",t=>{e=o(e,t)}),r.on("end",async()=>{if(e)try{const r=c(e),s=await i.enrichReportData(n,r);t.write(JSON.stringify(s)+"\n")}catch{t.write(e+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else u()})};function l(){const e=t.join(process.cwd(),"logs");n.existsSync(e)||n.mkdirSync(e,{recursive:!0});const r=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),s=t.join(e,`sentry_${r}.jsonl`);return{fileStream:n.createWriteStream(s,{flags:"a"}),logFile:s}}function f({dsn:e}){const{fileStream:t,logFile:n}=l();return s.sentryLogger.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:a(e||r.default.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}exports.default=f,exports.sentryPlugin=f,exports.sentryPlugin7=function({dsn:e}={}){const{fileStream:t,logFile:n}=l();return s.sentryLogger.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:u(e||r.default.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}};
|
package/dist/vite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Buffer as e}from"node:buffer";import{join as t}from"node:path";import{existsSync as n,mkdirSync as i,createWriteStream as s}from"node:fs";import"./constants/index.js";import"./types/enums.js";import o from"./utils/sentry.js";import"./utils/is-type.js";import{sentryLogger as r}from"./utils/logger.js";import{enrichReportData as l}from"./
|
|
1
|
+
import{Buffer as e}from"node:buffer";import{join as t}from"node:path";import{existsSync as n,mkdirSync as i,createWriteStream as s}from"node:fs";import"./constants/index.js";import"./types/enums.js";import o from"./utils/sentry.js";import"./utils/is-type.js";import{sentryLogger as r}from"./utils/logger.js";import{enrichReportData as l}from"./source-map/vite.js";function a(t,n){return"string"==typeof n?t+n:e.isBuffer(n)?t+n.toString("utf8"):n instanceof Uint8Array?t+e.from(n).toString("utf8"):t}function c(e){return JSON.parse(e)}const f=(e,t)=>n=>{n.middlewares.use((i,s,o)=>{if(i.url===e&&"POST"===i.method){let e="";i.on("data",t=>{e=a(e,t)}),i.on("end",async()=>{if(e)try{const i=c(e),s=await l(n,i);t.write(JSON.stringify(s)+"\n")}catch{t.write(e+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else o()})},u=(e,t)=>n=>{n.middlewares.use((i,s,o)=>{if(i.url===e&&"POST"===i.method){let e="";i.on("data",t=>{e=a(e,t)}),i.on("end",async()=>{if(e)try{const i=c(e),s=await l(n,i);t.write(JSON.stringify(s)+"\n")}catch{t.write(e+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else o()})};function d(){const e=t(process.cwd(),"logs");n(e)||i(e,{recursive:!0});const o=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),r=t(e,`sentry_${o}.jsonl`);return{fileStream:s(r,{flags:"a"}),logFile:r}}function m({dsn:e}={}){const{fileStream:t,logFile:n}=d();return r.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:f(e||o.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}function p({dsn:e}){const{fileStream:t,logFile:n}=d();return r.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:u(e||o.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}export{p as default,p as sentryPlugin,m as sentryPlugin7};
|
package/dist/webpack.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("node:buffer"),t=require("node:path"),r=require("node:fs");require("./constants/index.cjs"),require("./types/enums.cjs");var n=require("./utils/sentry.cjs");require("./utils/is-type.cjs");var s=require("./utils/logger.cjs"),i=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("node:buffer"),t=require("node:path"),r=require("node:fs");require("./constants/index.cjs"),require("./types/enums.cjs");var n=require("./utils/sentry.cjs");require("./utils/is-type.cjs");var s=require("./utils/logger.cjs"),i=require("./source-map/webpack.cjs"),o=require("./source-map/source-map.cjs");function a(t,r,n){return(s,i,a)=>{if(s.url===t&&"POST"===s.method){let t="";s.on("data",r=>{t=function(t,r){return"string"==typeof r?t+r:e.Buffer.isBuffer(r)?t+r.toString("utf8"):r instanceof Uint8Array?t+e.Buffer.from(r).toString("utf8"):t}(t,r)}),s.on("end",async()=>{if(t)try{const e=function(e){return JSON.parse(e)}(t),s=n?await o.enrichReportData(n,e):e;r.write(JSON.stringify(s)+"\n")}catch{r.write(t+"\n")}i.setHeader("Content-Type","application/json"),i.statusCode=200,i.end(JSON.stringify({code:0,message:"success"}))})}else a()}}function u(){const e=t.join(process.cwd(),"logs");r.existsSync(e)||r.mkdirSync(e,{recursive:!0});const n=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),s=t.join(e,`sentry_${n}.jsonl`);return{fileStream:r.createWriteStream(s,{flags:"a"}),logFile:s}}class c{dsn;constructor(e={}){this.dsn=e.dsn}apply(e){if(!e.options.devServer)return;const t=e.options.devServer,{fileStream:r,logFile:o}=u(),c=this.dsn||n.default.options.dsn||"/sentry",l=i.createAssetMapStore(),d=a(c,r,l.loadMap);e.hooks.assetEmitted.tap("SentryWebpackPlugin",(e,{content:t})=>{e.endsWith(".map")&&l.put(e,t.toString("utf8"))}),s.sentryLogger.info(`Sentry mock plugin initialized, logs will be written to ${o}`);const p=t.setupMiddlewares;t.setupMiddlewares=(e,t)=>{const r=p?p(e,t):e,n={name:"sentry-mock",middleware:d};return r.unshift(n),r},e.hooks.shutdown.tap("SentryWebpackPlugin",()=>{r&&!r.destroyed&&r.close()})}}function l(e={}){return new c(e)}exports.SentryWebpackPlugin=c,exports.default=l,exports.sentryMiddleware=function(e={}){const{fileStream:t,logFile:r}=u();return s.sentryLogger.info(`Sentry mock middleware initialized, logs will be written to ${r}`),a(e.dsn||n.default.options.dsn||"/sentry",t)},exports.sentryPlugin=l;
|
package/dist/webpack.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Buffer as t}from"node:buffer";import{join as e}from"node:path";import{existsSync as n,mkdirSync as o,createWriteStream as
|
|
1
|
+
import{Buffer as t}from"node:buffer";import{join as e}from"node:path";import{existsSync as n,mkdirSync as o,createWriteStream as s}from"node:fs";import"./constants/index.js";import"./types/enums.js";import r from"./utils/sentry.js";import"./utils/is-type.js";import{sentryLogger as i}from"./utils/logger.js";import{createAssetMapStore as a}from"./source-map/webpack.js";import{enrichReportData as l}from"./source-map/source-map.js";function c(e,n,o){return(s,r,i)=>{if(s.url===e&&"POST"===s.method){let e="";s.on("data",n=>{e=function(e,n){return"string"==typeof n?e+n:t.isBuffer(n)?e+n.toString("utf8"):n instanceof Uint8Array?e+t.from(n).toString("utf8"):e}(e,n)}),s.on("end",async()=>{if(e)try{const t=function(t){return JSON.parse(t)}(e),s=o?await l(o,t):t;n.write(JSON.stringify(s)+"\n")}catch{n.write(e+"\n")}r.setHeader("Content-Type","application/json"),r.statusCode=200,r.end(JSON.stringify({code:0,message:"success"}))})}else i()}}function p(){const t=e(process.cwd(),"logs");n(t)||o(t,{recursive:!0});const r=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),i=e(t,`sentry_${r}.jsonl`);return{fileStream:s(i,{flags:"a"}),logFile:i}}function u(t={}){const{fileStream:e,logFile:n}=p();i.info(`Sentry mock middleware initialized, logs will be written to ${n}`);return c(t.dsn||r.options.dsn||"/sentry",e)}class d{dsn;constructor(t={}){this.dsn=t.dsn}apply(t){if(!t.options.devServer)return;const e=t.options.devServer,{fileStream:n,logFile:o}=p(),s=this.dsn||r.options.dsn||"/sentry",l=a(),u=c(s,n,l.loadMap);t.hooks.assetEmitted.tap("SentryWebpackPlugin",(t,{content:e})=>{t.endsWith(".map")&&l.put(t,e.toString("utf8"))}),i.info(`Sentry mock plugin initialized, logs will be written to ${o}`);const d=e.setupMiddlewares;e.setupMiddlewares=(t,e)=>{const n=d?d(t,e):t,o={name:"sentry-mock",middleware:u};return n.unshift(o),n},t.hooks.shutdown.tap("SentryWebpackPlugin",()=>{n&&!n.destroyed&&n.close()})}}function f(t={}){return new d(t)}export{d as SentryWebpackPlugin,f as default,u as sentryMiddleware,f as sentryPlugin};
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swifty.js/sentry",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Framework-agnostic sentry sdk with first-class support for react
|
|
3
|
+
"version": "0.0.5",
|
|
4
|
+
"description": "Framework-agnostic sentry sdk with first-class support for react and vue3+",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
6
|
+
"error-tracking",
|
|
7
|
+
"monitoring",
|
|
7
8
|
"react",
|
|
8
9
|
"sdk",
|
|
9
10
|
"sentry",
|
|
@@ -44,11 +45,6 @@
|
|
|
44
45
|
"import": "./dist/react.js",
|
|
45
46
|
"require": "./dist/react.cjs"
|
|
46
47
|
},
|
|
47
|
-
"./preact": {
|
|
48
|
-
"types": "./dist/preact.d.ts",
|
|
49
|
-
"import": "./dist/preact.js",
|
|
50
|
-
"require": "./dist/preact.cjs"
|
|
51
|
-
},
|
|
52
48
|
"./vue": {
|
|
53
49
|
"types": "./dist/vue.d.ts",
|
|
54
50
|
"import": "./dist/vue.js",
|
|
@@ -65,18 +61,6 @@
|
|
|
65
61
|
"require": "./dist/webpack.cjs"
|
|
66
62
|
}
|
|
67
63
|
},
|
|
68
|
-
"scripts": {
|
|
69
|
-
"test": "vitest run --config ./vitest.config.ts",
|
|
70
|
-
"test:watch": "vitest --config ./vitest.config.ts",
|
|
71
|
-
"test:coverage": "vitest run --config ./vitest.config.ts --coverage",
|
|
72
|
-
"typecheck": "tsc --noEmit",
|
|
73
|
-
"vite7": "pnpm add -D vite7@npm:vite@7.3.3",
|
|
74
|
-
"format": "oxfmt --write ./",
|
|
75
|
-
"prepublishOnly": "pnpm build",
|
|
76
|
-
"build": "rollup -c ./rollup.config.ts",
|
|
77
|
-
"build:watch": "rollup -c ./rollup.config.ts -w",
|
|
78
|
-
"build:tsup": "tsup --config ./tsup.config.ts"
|
|
79
|
-
},
|
|
80
64
|
"dependencies": {
|
|
81
65
|
"@fingerprintjs/fingerprintjs": "^5.2.0",
|
|
82
66
|
"@rrweb/record": "2.1.0",
|
|
@@ -94,37 +78,32 @@
|
|
|
94
78
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
95
79
|
"@rrweb/record": "2.1.0",
|
|
96
80
|
"@types/jsdom": "^28.0.3",
|
|
97
|
-
"@types/node": "^25.9.
|
|
81
|
+
"@types/node": "^25.9.5",
|
|
98
82
|
"@types/pako": "^2.0.4",
|
|
99
|
-
"@types/react": "^19.2.
|
|
100
|
-
"@types/react-dom": "^19.2.
|
|
83
|
+
"@types/react": "^19.2.18",
|
|
84
|
+
"@types/react-dom": "^19.2.4",
|
|
101
85
|
"@vitest/coverage-v8": "^1.6.1",
|
|
102
86
|
"jsdom": "^24.1.3",
|
|
103
87
|
"oxfmt": "^0.54.0",
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"rollup": "^
|
|
107
|
-
"rollup-plugin-dts": "^6.4.1",
|
|
88
|
+
"react": "^19.2.8",
|
|
89
|
+
"rollup": "^4.62.4",
|
|
90
|
+
"rollup-plugin-dts": "^6.5.1",
|
|
108
91
|
"tsup": "^8.5.1",
|
|
109
92
|
"typescript": "^6.0.3",
|
|
110
|
-
"vite": "^8.1
|
|
93
|
+
"vite": "^8.2.1",
|
|
111
94
|
"vite7": "npm:vite@7.3.3",
|
|
112
95
|
"vitest": "^1.6.1",
|
|
113
|
-
"vue": "^3.5.
|
|
114
|
-
"webpack": "^5.
|
|
96
|
+
"vue": "^3.5.41",
|
|
97
|
+
"webpack": "^5.109.2",
|
|
115
98
|
"webpack-dev-server": "^5.2.6"
|
|
116
99
|
},
|
|
117
100
|
"peerDependencies": {
|
|
118
|
-
"
|
|
119
|
-
"react": "^19.0.0",
|
|
101
|
+
"react": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
120
102
|
"vite": "^7.0.0 || ^8.0.0",
|
|
121
103
|
"vue": "^3.0.0",
|
|
122
104
|
"webpack": "^4.0.0 || ^5.0.0"
|
|
123
105
|
},
|
|
124
106
|
"peerDependenciesMeta": {
|
|
125
|
-
"preact": {
|
|
126
|
-
"optional": true
|
|
127
|
-
},
|
|
128
107
|
"react": {
|
|
129
108
|
"optional": true
|
|
130
109
|
},
|
|
@@ -140,5 +119,16 @@
|
|
|
140
119
|
"webpack-dev-server": {
|
|
141
120
|
"optional": true
|
|
142
121
|
}
|
|
122
|
+
},
|
|
123
|
+
"scripts": {
|
|
124
|
+
"test": "vitest run --config ./vitest.config.ts",
|
|
125
|
+
"test:watch": "vitest --config ./vitest.config.ts",
|
|
126
|
+
"test:coverage": "vitest run --config ./vitest.config.ts --coverage",
|
|
127
|
+
"typecheck": "tsc --noEmit",
|
|
128
|
+
"vite7": "pnpm add -D vite7@npm:vite@7.3.3",
|
|
129
|
+
"format": "oxfmt --write ./",
|
|
130
|
+
"build": "rollup -c ./rollup.config.ts",
|
|
131
|
+
"build:watch": "rollup -c ./rollup.config.ts -w",
|
|
132
|
+
"build:tsup": "tsup --config ./tsup.config.ts"
|
|
143
133
|
}
|
|
144
|
-
}
|
|
134
|
+
}
|
package/dist/preact.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var r=require("preact"),e=require("./types/enums.cjs"),t=require("./core/framework-error.cjs");class o extends r.Component{state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),t.reportFrameworkError({type:e.EventType.React,error:r,context:o})}render(){const{error:r,errorInfo:e}=this.state;if(r){const{fallback:t}=this.props;return"function"==typeof t?t(r,e):t??null}return this.props.children??null}}exports.PreactErrorBoundary=o;
|
package/dist/preact.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Component, ComponentChildren, ErrorInfo } from 'preact';
|
|
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
|
-
/**
|
|
26
|
-
* Props for the {@link PreactErrorBoundary} component.
|
|
27
|
-
*
|
|
28
|
-
* The boundary renders `children` normally. When a descendant throws during
|
|
29
|
-
* rendering, it switches to rendering {@link fallback} and reports the error
|
|
30
|
-
* to the Sentry SDK.
|
|
31
|
-
*/
|
|
32
|
-
interface PreactErrorBoundaryProps {
|
|
33
|
-
/**
|
|
34
|
-
* The subtree to render when no error has occurred. When an error is
|
|
35
|
-
* caught, this is replaced by {@link fallback}.
|
|
36
|
-
*/
|
|
37
|
-
readonly children?: ComponentChildren;
|
|
38
|
-
/**
|
|
39
|
-
* The UI to display when a descendant throws.
|
|
40
|
-
*
|
|
41
|
-
* Can be a static `ComponentChildren` (no access to the error) or a render
|
|
42
|
-
* function that receives the caught error and Preact's component-stack info.
|
|
43
|
-
*
|
|
44
|
-
* @param error - The Error thrown by the descendant component.
|
|
45
|
-
* @param errorInfo - Preact's {@link ErrorInfo}, containing `componentStack`.
|
|
46
|
-
* `undefined` on the first render after the error is caught.
|
|
47
|
-
* @returns The fallback Preact subtree to render.
|
|
48
|
-
*/
|
|
49
|
-
readonly fallback?: ComponentChildren | ((error: Error, errorInfo?: ErrorInfo) => ComponentChildren);
|
|
50
|
-
}
|
|
51
|
-
/** Internal state tracking the caught error and component-stack info. */
|
|
52
|
-
interface PreactErrorBoundaryState {
|
|
53
|
-
readonly error?: Error;
|
|
54
|
-
readonly errorInfo?: ErrorInfo;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* A Preact Error Boundary that reports caught errors to the Sentry SDK.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```tsx
|
|
61
|
-
* <PreactErrorBoundary fallback={<div>Something went wrong</div>}>
|
|
62
|
-
* <Page />
|
|
63
|
-
* </PreactErrorBoundary>
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
declare class PreactErrorBoundary extends Component<PreactErrorBoundaryProps, PreactErrorBoundaryState> {
|
|
67
|
-
state: PreactErrorBoundaryState;
|
|
68
|
-
static getDerivedStateFromError(error: Error): PreactErrorBoundaryState;
|
|
69
|
-
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
70
|
-
render(): ComponentChildren;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export { PreactErrorBoundary };
|
|
74
|
-
export type { PreactErrorBoundaryProps };
|
package/dist/preact.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Component as r}from"preact";import{EventType as t}from"./types/enums.js";import{reportFrameworkError as e}from"./core/framework-error.js";class o extends r{state={};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,o){this.setState({error:r,errorInfo:o}),e({type:t.React,error:r,context:o})}render(){const{error:r,errorInfo:t}=this.state;if(r){const{fallback:e}=this.props;return"function"==typeof e?e(r,t):e??null}return this.props.children??null}}export{o as PreactErrorBoundary};
|
package/dist/sourcemap/vite.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var r=require("./sourcemap.cjs");exports.parseStack=r.parseStack,exports.enrichReportData=async function(t,e){return r.enrichReportData(function(t){return async e=>{const{pathname:a,search:n}=r.splitScriptUrl(e),s=await t.moduleGraph.getModuleByUrl(a+n)??await t.moduleGraph.getModuleByUrl(a);return s?.transformResult?.map??null}}(t),e)};
|
package/dist/sourcemap/vite.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{enrichReportData as r,splitScriptUrl as a}from"./sourcemap.js";export{parseStack}from"./sourcemap.js";async function e(e,t){return r(function(r){return async e=>{const{pathname:t,search:o}=a(e),n=await r.moduleGraph.getModuleByUrl(t+o)??await r.moduleGraph.getModuleByUrl(t);return n?.transformResult?.map??null}}(e),t)}export{e as enrichReportData};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("./sourcemap.cjs");function r(e){return e.replace(/\\/g,"/").replace(/^\/+/,"")}exports.enrichReportData=e.enrichReportData,exports.parseStack=e.parseStack,exports.resolveFrame=e.resolveFrame,exports.resolveStack=e.resolveStack,exports.createAssetMapStore=function(){const t=new Map;return{put:(e,a)=>{const s=r(e);s.endsWith(".map")&&t.set(s,a)},loadMap:async a=>{const{pathname:s}=e.splitScriptUrl(a),o=r(s);if(!o)return null;let p=t.get(`${o}.map`);if(void 0===p){const e=`${o.split("/").pop()}.map`;for(const[r,a]of t)if(r===e||r.endsWith(`/${e}`)){p=a;break}}if(void 0===p)return null;try{return JSON.parse(p)}catch{return null}}}};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{splitScriptUrl as e}from"./sourcemap.js";export{enrichReportData,parseStack,resolveFrame,resolveStack}from"./sourcemap.js";function r(e){return e.replace(/\\/g,"/").replace(/^\/+/,"")}function t(){const t=new Map;return{put:(e,n)=>{const o=r(e);o.endsWith(".map")&&t.set(o,n)},loadMap:async n=>{const{pathname:o}=e(n),a=r(o);if(!a)return null;let p=t.get(`${a}.map`);if(void 0===p){const e=`${a.split("/").pop()}.map`;for(const[r,n]of t)if(r===e||r.endsWith(`/${e}`)){p=n;break}}if(void 0===p)return null;try{return JSON.parse(p)}catch{return null}}}}export{t as createAssetMapStore};
|
|
File without changes
|
|
File without changes
|