@swifty.js/sentry 0.0.1
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/README.md +785 -0
- package/dist/constants/index.cjs +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/core/api.cjs +1 -0
- package/dist/core/api.d.ts +27 -0
- package/dist/core/api.js +1 -0
- package/dist/core/breadcrumb.cjs +1 -0
- package/dist/core/breadcrumb.js +1 -0
- package/dist/core/bus.cjs +1 -0
- package/dist/core/bus.js +1 -0
- package/dist/core/decorate-http-publish.cjs +1 -0
- package/dist/core/decorate-http-publish.js +1 -0
- package/dist/core/decorate-publish.cjs +1 -0
- package/dist/core/decorate-publish.js +1 -0
- package/dist/core/decorate-route-publish.cjs +1 -0
- package/dist/core/decorate-route-publish.js +1 -0
- package/dist/core/framework-error.cjs +1 -0
- package/dist/core/framework-error.js +1 -0
- package/dist/core/handle-code-error.cjs +1 -0
- package/dist/core/handle-code-error.js +1 -0
- package/dist/core/handle-error.cjs +1 -0
- package/dist/core/handle-error.js +1 -0
- package/dist/core/handle-events.cjs +1 -0
- package/dist/core/handle-events.js +1 -0
- package/dist/core/handle-http.cjs +1 -0
- package/dist/core/handle-http.js +1 -0
- package/dist/core/handle-route.cjs +1 -0
- package/dist/core/handle-route.js +1 -0
- package/dist/core/identity.cjs +1 -0
- package/dist/core/identity.d.ts +11 -0
- package/dist/core/identity.js +1 -0
- package/dist/core/ip.cjs +1 -0
- package/dist/core/ip.d.ts +3 -0
- package/dist/core/ip.js +1 -0
- package/dist/core/options-schema.cjs +1 -0
- package/dist/core/options-schema.d.ts +52 -0
- package/dist/core/options-schema.js +1 -0
- package/dist/core/plugin-registry.cjs +1 -0
- package/dist/core/plugin-registry.js +1 -0
- package/dist/core/pv-lifecycle.cjs +1 -0
- package/dist/core/pv-lifecycle.js +1 -0
- package/dist/core/sdk-lifecycle.cjs +1 -0
- package/dist/core/sdk-lifecycle.d.ts +9 -0
- package/dist/core/sdk-lifecycle.js +1 -0
- package/dist/core/setup.cjs +1 -0
- package/dist/core/setup.js +1 -0
- package/dist/core/white-screen.cjs +1 -0
- package/dist/core/white-screen.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -0
- package/dist/package.json.cjs +1 -0
- package/dist/package.json.js +1 -0
- package/dist/plugins/exposure/index.cjs +1 -0
- package/dist/plugins/exposure/index.d.ts +23 -0
- package/dist/plugins/exposure/index.js +1 -0
- package/dist/plugins/index.cjs +1 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/performance/first-screen-paint.cjs +1 -0
- package/dist/plugins/performance/first-screen-paint.js +1 -0
- package/dist/plugins/performance/index.cjs +1 -0
- package/dist/plugins/performance/index.d.ts +16 -0
- package/dist/plugins/performance/index.js +1 -0
- package/dist/plugins/performance/navigation-timing.cjs +1 -0
- package/dist/plugins/performance/navigation-timing.js +1 -0
- package/dist/plugins/performance/perf.cjs +1 -0
- package/dist/plugins/performance/perf.js +1 -0
- package/dist/plugins/performance/performance-observer-support.cjs +1 -0
- package/dist/plugins/performance/performance-observer-support.js +1 -0
- package/dist/plugins/performance/resource-element-fallback.cjs +1 -0
- package/dist/plugins/performance/resource-element-fallback.js +1 -0
- package/dist/plugins/performance/resource-timing.cjs +1 -0
- package/dist/plugins/performance/resource-timing.js +1 -0
- package/dist/plugins/screen-record/index.cjs +1 -0
- package/dist/plugins/screen-record/index.d.ts +18 -0
- package/dist/plugins/screen-record/index.js +1 -0
- package/dist/plugins/screen-record/recorder.cjs +1 -0
- package/dist/plugins/screen-record/recorder.d.ts +3 -0
- package/dist/plugins/screen-record/recorder.js +1 -0
- package/dist/react.cjs +1 -0
- package/dist/react.d.ts +103 -0
- package/dist/react.js +1 -0
- package/dist/reporter/batch.cjs +1 -0
- package/dist/reporter/batch.js +1 -0
- package/dist/reporter/flush-scheduler.cjs +1 -0
- package/dist/reporter/flush-scheduler.js +1 -0
- package/dist/reporter/index.cjs +1 -0
- package/dist/reporter/index.js +1 -0
- package/dist/reporter/network-listener.cjs +1 -0
- package/dist/reporter/network-listener.js +1 -0
- package/dist/reporter/offline-cache.cjs +1 -0
- package/dist/reporter/offline-cache.js +1 -0
- package/dist/reporter/promise.cjs +1 -0
- package/dist/reporter/promise.js +1 -0
- package/dist/reporter/report-data-schema.cjs +1 -0
- package/dist/reporter/report-data-schema.js +1 -0
- package/dist/reporter/report-data.cjs +1 -0
- package/dist/reporter/report-data.js +1 -0
- package/dist/reporter/send-preflight.cjs +1 -0
- package/dist/reporter/send-preflight.js +1 -0
- package/dist/reporter/server-recovery.cjs +1 -0
- package/dist/reporter/server-recovery.js +1 -0
- package/dist/reporter/timer.cjs +1 -0
- package/dist/reporter/timer.js +1 -0
- package/dist/reporter/transports.cjs +1 -0
- package/dist/reporter/transports.js +1 -0
- package/dist/types/common.d.ts +140 -0
- package/dist/types/enums.cjs +1 -0
- package/dist/types/enums.d.ts +77 -0
- package/dist/types/enums.js +1 -0
- package/dist/types/handlers.d.ts +11 -0
- package/dist/types/options.d.ts +51 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.ts +15 -0
- package/dist/types/plugin.js +1 -0
- package/dist/utils/base64.cjs +1 -0
- package/dist/utils/base64.js +1 -0
- package/dist/utils/click-data.cjs +1 -0
- package/dist/utils/click-data.js +1 -0
- package/dist/utils/data-structures.cjs +1 -0
- package/dist/utils/data-structures.js +1 -0
- package/dist/utils/decorate-prop.cjs +1 -0
- package/dist/utils/decorate-prop.d.ts +3 -0
- package/dist/utils/decorate-prop.js +1 -0
- package/dist/utils/event2breadcrumb.cjs +1 -0
- package/dist/utils/event2breadcrumb.js +1 -0
- package/dist/utils/get-base-data.cjs +1 -0
- package/dist/utils/get-base-data.js +1 -0
- package/dist/utils/get-css-selectors.cjs +1 -0
- package/dist/utils/get-css-selectors.js +1 -0
- package/dist/utils/is-excluded-api.cjs +1 -0
- package/dist/utils/is-excluded-api.js +1 -0
- package/dist/utils/is-ignored-error.cjs +1 -0
- package/dist/utils/is-ignored-error.js +1 -0
- package/dist/utils/is-type.cjs +1 -0
- package/dist/utils/is-type.js +1 -0
- package/dist/utils/logger.cjs +1 -0
- package/dist/utils/logger.js +1 -0
- package/dist/utils/metric2perf-data.cjs +1 -0
- package/dist/utils/metric2perf-data.js +1 -0
- package/dist/utils/sentry.cjs +1 -0
- package/dist/utils/sentry.js +1 -0
- package/dist/utils/server-timing.cjs +1 -0
- package/dist/utils/server-timing.js +1 -0
- package/dist/utils/session.cjs +1 -0
- package/dist/utils/session.js +1 -0
- package/dist/utils/throttle.cjs +1 -0
- package/dist/utils/throttle.js +1 -0
- package/dist/utils/transform-http-data.cjs +1 -0
- package/dist/utils/transform-http-data.js +1 -0
- package/dist/vite.cjs +1 -0
- package/dist/vite.d.ts +11 -0
- package/dist/vite.js +1 -0
- package/dist/vue.cjs +1 -0
- package/dist/vue.d.ts +5 -0
- package/dist/vue.js +1 -0
- package/dist/webpack.cjs +1 -0
- package/dist/webpack.d.ts +55 -0
- package/dist/webpack.js +1 -0
- package/package.json +128 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e){if(!e||1!==e.nodeType)return["","",""];const t=["id","class","style"];return[e.id?`#${e.id}`:"",Array.from(e.classList).map(e=>`.${e}`).join("")+Array.from(e.attributes).filter(e=>!t.includes(e.name)).map(e=>`[${e.name}="${e.value}"]`).join(""),e.tagName.toLowerCase()]}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=e,exports.getCssSelectors=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){if(!e||1!==e.nodeType)return["","",""];const a=["id","class","style"];return[e.id?`#${e.id}`:"",Array.from(e.classList).map(e=>`.${e}`).join("")+Array.from(e.attributes).filter(e=>!a.includes(e.name)).map(e=>`[${e.name}="${e.value}"]`).join(""),e.tagName.toLowerCase()]}export{e as default,e as getCssSelectors};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./sentry.cjs");exports.default=function(t){for(const r of e.default.options.excludeApis)if("string"==typeof r){if(t===r)return!0}else if(r.test(t))return!0;return!1};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"./sentry.js";function e(e){for(const r of t.options.excludeApis)if("string"==typeof r){if(e===r)return!0}else if(r.test(e))return!0;return!1}export{e as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./sentry.cjs");exports.default=function(r){return e.default.options.ignoreErrors.some(e=>function(e,r){return"string"==typeof r?e.includes(r):r.test(e)}(r,e))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"./sentry.js";function t(t){return r.options.ignoreErrors.some(r=>function(r,t){return"string"==typeof t?r.includes(t):t.test(r)}(t,r))}export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.isError=function(r){return r instanceof Error},exports.isErrorEvent=function(r){return r instanceof ErrorEvent},exports.isHTMLElement=function(r){return r.nodeType===Node.ELEMENT_NODE},exports.isIExtendedErrorEvent=function(r){return r instanceof ErrorEvent&&null!==r.target&&"src"in r.target&&"string"==typeof r.target.src&&"href"in r.target&&"string"==typeof r.target.href&&"localName"in r.target&&"string"==typeof r.target.localName};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t){return t.nodeType===Node.ELEMENT_NODE}function r(t){return t instanceof Error}function n(t){return t instanceof ErrorEvent}function e(t){return t instanceof ErrorEvent&&null!==t.target&&"src"in t.target&&"string"==typeof t.target.src&&"href"in t.target&&"string"==typeof t.target.href&&"localName"in t.target&&"string"==typeof t.target.localName}export{r as isError,n as isErrorEvent,t as isHTMLElement,e as isIExtendedErrorEvent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o={info:"#74d4ff",success:"#bbf450",warn:"#ffb869",error:"#ffa2a2",text:"#62748e"},s="font-family: Iosevka, Maple Mono, Menlo, Cascadia Code;",e=o=>`color: ${o}; ${s}`,r=e=>`color: ${o.text}; background: ${e}; border-radius: 4px; ${s}`,n={info:{message:e(o.info),prefix:r(o.info)},success:{message:e(o.success),prefix:r(o.success)},warn:{message:e(o.warn),prefix:r(o.warn)},error:{message:e(o.error),prefix:r(o.error)}},l={get isEnabled(){return globalThis.__sentry__?.options.debug??!1},info(o,s,e,r="@swifty.js/sentry"){this.isEnabled&&(console.groupCollapsed(`%c ${r} %c ${o} `,n.info.prefix,n.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} `,n.success.prefix,n.success.message),void 0!==e&&console.log(`%c Time cost %c ${e}ms`,n.success.prefix,n.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} `,n.warn.prefix,n.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} `,n.error.prefix,n.error.message),void 0!==s&&(console.group("Error Details"),console.error(s),console.groupEnd()),console.groupEnd())}};exports.sentryLogger=l,exports.themeColors=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o={info:"#74d4ff",success:"#bbf450",warn:"#ffb869",error:"#ffa2a2",text:"#62748e"},s="font-family: Iosevka, Maple Mono, Menlo, Cascadia Code;",e=o=>`color: ${o}; ${s}`,r=e=>`color: ${o.text}; background: ${e}; border-radius: 4px; ${s}`,n={info:{message:e(o.info),prefix:r(o.info)},success:{message:e(o.success),prefix:r(o.success)},warn:{message:e(o.warn),prefix:r(o.warn)},error:{message:e(o.error),prefix:r(o.error)}},l={get isEnabled(){return globalThis.__sentry__?.options.debug??!1},info(o,s,e,r="@swifty.js/sentry"){this.isEnabled&&(console.groupCollapsed(`%c ${r} %c ${o} `,n.info.prefix,n.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} `,n.success.prefix,n.success.message),void 0!==e&&console.log(`%c Time cost %c ${e}ms`,n.success.prefix,n.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} `,n.warn.prefix,n.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} `,n.error.prefix,n.error.message),void 0!==s&&(console.group("Error Details"),console.error(s),console.groupEnd()),console.groupEnd())}};export{l as sentryLogger,o as themeColors};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../types/enums.cjs"),t=require("./get-base-data.cjs");exports.default=function(r){const{id:a,name:n,value:u,rating:s}=r;return{...t.default(),id:a,name:n,value:u,rating:s,type:e.EventType.Performance}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EventType as e}from"../types/enums.js";import t from"./get-base-data.js";function a(a){const{id:r,name:n,value:m,rating:o}=a;return{...t(),id:r,name:n,value:m,rating:o,type:e.Performance}}export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../constants/index.cjs"),t=require("./data-structures.cjs"),n=require("ua-parser-js");const r=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e})();function s(){try{const e=document.createElement("canvas"),t=e.getContext("2d");if(t){t.textBaseline="top",t.font="14px 'Arial'",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText("@swifty.js/sentry",2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText("@swifty.js/sentry",4,17);const n=e.toDataURL().replace("data:image/png;base64,","");return function(e){let t=4294967295;for(let n=0;n<e.length;n++)t=r[255&(t^e.charCodeAt(n))]^t>>>8;return(4294967295^t)>>>0}(atob(n)).toString(16)}}catch{return o()}return o()}function o(){return globalThis.crypto&&"function"==typeof globalThis.crypto.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`}class i{static#e;static get instance(){return this.#e||(this.#e=new i,globalThis.__sentry__=this.#e),this.#e}codeErrors=new t.BoundedSet(1e3);whiteScreenTimer=null;options=e.DEFAULT_OPTIONS;deviceInfo;shouldScreenRecord=!1;constructor(){const t=(new n.UAParser).getResult();this.deviceInfo={browserName:t.browser.name??e.UNKNOWN,browserVersion:t.browser.version??e.UNKNOWN,osName:t.os.name??e.UNKNOWN,osVersion:t.os.version??e.UNKNOWN,userAgent:t.ua,deviceModel:t.device.model??e.UNKNOWN,deviceType:t.device.type??e.UNKNOWN,fingerprint:s(),language:"navigator"in globalThis&&globalThis.navigator.language||e.UNKNOWN,screenResolution:"screen"in globalThis?`${globalThis.screen.width}x${globalThis.screen.height}`:e.UNKNOWN}}setOptions(e){i.#e.options={...this.options,...e}}}var a=i.instance;exports.default=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{DEFAULT_OPTIONS as e,UNKNOWN as t}from"../constants/index.js";import{BoundedSet as n}from"./data-structures.js";import{UAParser as o}from"ua-parser-js";const s=(()=>{const e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e})();function r(){try{const e=document.createElement("canvas"),t=e.getContext("2d");if(t){t.textBaseline="top",t.font="14px 'Arial'",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText("@swifty.js/sentry",2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText("@swifty.js/sentry",4,17);const n=e.toDataURL().replace("data:image/png;base64,","");return function(e){let t=4294967295;for(let n=0;n<e.length;n++)t=s[255&(t^e.charCodeAt(n))]^t>>>8;return(4294967295^t)>>>0}(atob(n)).toString(16)}}catch{return i()}return i()}function i(){return globalThis.crypto&&"function"==typeof globalThis.crypto.randomUUID?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`}class a{static#e;static get instance(){return this.#e||(this.#e=new a,globalThis.__sentry__=this.#e),this.#e}codeErrors=new n(1e3);whiteScreenTimer=null;options=e;deviceInfo;shouldScreenRecord=!1;constructor(){const e=(new o).getResult();this.deviceInfo={browserName:e.browser.name??t,browserVersion:e.browser.version??t,osName:e.os.name??t,osVersion:e.os.version??t,userAgent:e.ua,deviceModel:e.device.model??t,deviceType:e.device.type??t,fingerprint:r(),language:"navigator"in globalThis&&globalThis.navigator.language||t,screenResolution:"screen"in globalThis?`${globalThis.screen.width}x${globalThis.screen.height}`:t}}setOptions(e){a.#e.options={...this.options,...e}}}var l=a.instance;export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e){return e?e.split(",").map(e=>e.trim()).filter(e=>e.length>0):[]}exports.getServerTimingFromHeaders=function(r){return e(r?.get("server-timing")??null)},exports.parseServerTiming=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t){return t?t.split(",").map(t=>t.trim()).filter(t=>t.length>0):[]}function n(n){return t(n?.get("server-timing")??null)}export{n as getServerTimingFromHeaders,t as parseServerTiming};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t="swifty_sentry_device_id",e="swifty_sentry_session_id";exports.getDeviceId=function(){try{let e=localStorage.getItem(t);return e||(e=crypto.randomUUID(),localStorage.setItem(t,e)),e}catch{return crypto.randomUUID()}},exports.getSessionId=function(){try{let t=sessionStorage.getItem(e);return t||(t=crypto.randomUUID(),sessionStorage.setItem(e,t)),t}catch{return crypto.randomUUID()}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t="swifty_sentry_device_id",e="swifty_sentry_session_id";function r(){try{let e=localStorage.getItem(t);return e||(e=crypto.randomUUID(),localStorage.setItem(t,e)),e}catch{return crypto.randomUUID()}}function o(){try{let t=sessionStorage.getItem(e);return t||(t=crypto.randomUUID(),sessionStorage.setItem(e,t)),t}catch{return crypto.randomUUID()}}export{r as getDeviceId,o as getSessionId};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.throttle=function(t,e=300){let n=0;return function(...o){if(Date.now()-n>e)return n=Date.now(),void t.apply(this,o)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t,n=300){let e=0;return function(...o){if(Date.now()-e>n)return e=Date.now(),void t.apply(this,o)}}export{t as throttle};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../types/enums.cjs");exports.default=function(s){const{statusCode:r}=s;let t,o;return r>=100&&r<200?(t="Informational response",o=e.Status.OK):r>=200&&r<300?(t="Successful responses",o=e.Status.OK):r>=300&&r<400?(t="Redirection messages",o=e.Status.OK):r>=400&&r<500?(t="Client error responses",o=e.Status.Error):r>=500&&r<600?(t="Server error responses",o=e.Status.Error):(t="Invalid status code",o=e.Status.Error),{...s,message:t,status:o}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Status as s}from"../types/enums.js";function e(e){const{statusCode:r}=e;let o,t;return r>=100&&r<200?(o="Informational response",t=s.OK):r>=200&&r<300?(o="Successful responses",t=s.OK):r>=300&&r<400?(o="Redirection messages",t=s.OK):r>=400&&r<500?(o="Client error responses",t=s.Error):r>=500&&r<600?(o="Server error responses",t=s.Error):(o="Invalid status code",t=s.Error),{...e,message:o,status:t}}export{e as default};
|
package/dist/vite.cjs
ADDED
|
@@ -0,0 +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"),s=require("./utils/logger.cjs");function i(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 o(e){return JSON.parse(e)}const l=(e,t)=>n=>{n.middlewares.use((n,r,s)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=i(e,t)}),n.on("end",()=>{if(e)try{const n=o(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}r.setHeader("Content-Type","application/json"),r.statusCode=200,r.end(JSON.stringify({code:0,message:"success"}))})}else s()})},u=(e,t)=>n=>{n.middlewares.use((n,r,s)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=i(e,t)}),n.on("end",()=>{if(e)try{const n=o(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}r.setHeader("Content-Type","application/json"),r.statusCode=200,r.end(JSON.stringify({code:0,message:"success"}))})}else s()})};function c(){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 a({dsn:e}){const{fileStream:t,logFile:n}=c();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()}}}exports.default=a,exports.sentryPlugin=a,exports.sentryPlugin7=function({dsn:e}={}){const{fileStream:t,logFile:n}=c();return s.sentryLogger.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:l(e||r.default.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}};
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Plugin as Plugin$1 } from 'vite7';
|
|
2
|
+
import { Plugin } from 'vite';
|
|
3
|
+
|
|
4
|
+
interface ISentryPluginOptions {
|
|
5
|
+
dsn?: string;
|
|
6
|
+
}
|
|
7
|
+
declare function sentryPlugin7({ dsn }?: ISentryPluginOptions): Plugin$1;
|
|
8
|
+
declare function sentryPlugin({ dsn }: ISentryPluginOptions): Plugin;
|
|
9
|
+
|
|
10
|
+
export { sentryPlugin as default, sentryPlugin, sentryPlugin7 };
|
|
11
|
+
export type { ISentryPluginOptions };
|
package/dist/vite.js
ADDED
|
@@ -0,0 +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 o}from"node:fs";import"./constants/index.js";import"./types/enums.js";import s from"./utils/sentry.js";import{sentryLogger as r}from"./utils/logger.js";function l(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((n,i,o)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=l(e,t)}),n.on("end",()=>{if(e)try{const n=c(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}i.setHeader("Content-Type","application/json"),i.statusCode=200,i.end(JSON.stringify({code:0,message:"success"}))})}else o()})},a=(e,t)=>n=>{n.middlewares.use((n,i,o)=>{if(n.url===e&&"POST"===n.method){let e="";n.on("data",t=>{e=l(e,t)}),n.on("end",()=>{if(e)try{const n=c(e);t.write(JSON.stringify(n)+"\n")}catch{t.write(e+"\n")}i.setHeader("Content-Type","application/json"),i.statusCode=200,i.end(JSON.stringify({code:0,message:"success"}))})}else o()})};function u(){const e=t(process.cwd(),"logs");n(e)||i(e,{recursive:!0});const s=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),r=t(e,`sentry_${s}.jsonl`);return{fileStream:o(r,{flags:"a"}),logFile:r}}function d({dsn:e}={}){const{fileStream:t,logFile:n}=u();return r.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:f(e||s.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}function m({dsn:e}){const{fileStream:t,logFile:n}=u();return r.info(`Sentry mock plugin initialized, logs will be written to ${n}`),{name:"vite-plugin-sentry",configureServer:a(e||s.options.dsn||"/sentry",t),closeBundle(){t&&t.close()}}}export{m as default,m as sentryPlugin,d as sentryPlugin7};
|
package/dist/vue.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=require("./core/sdk-lifecycle.cjs"),e=require("./types/enums.cjs"),o=require("./core/framework-error.cjs");exports.vuePlugin=(c,n)=>{const t=c.config.errorHandler;c.config.errorHandler=(r,c,n)=>{o.reportFrameworkError({type:e.EventType.Vue,error:r,context:{vueInstance:c,info:n}}),t?.call(null,r,c,n)},r.init(n)};
|
package/dist/vue.d.ts
ADDED
package/dist/vue.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{init as r}from"./core/sdk-lifecycle.js";import{EventType as o}from"./types/enums.js";import{reportFrameworkError as e}from"./core/framework-error.js";const n=(n,c)=>{const t=n.config.errorHandler;n.config.errorHandler=(r,n,c)=>{e({type:o.Vue,error:r,context:{vueInstance:n,info:c}}),t?.call(null,r,n,c)},r(c)};export{n as vuePlugin};
|
package/dist/webpack.cjs
ADDED
|
@@ -0,0 +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"),s=require("./utils/logger.cjs");function i(t,n){return(r,s,i)=>{if(r.url===t&&"POST"===r.method){let t="";r.on("data",n=>{t=function(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}(t,n)}),r.on("end",()=>{if(t)try{const e=function(e){return JSON.parse(e)}(t);n.write(JSON.stringify(e)+"\n")}catch{n.write(t+"\n")}s.setHeader("Content-Type","application/json"),s.statusCode=200,s.end(JSON.stringify({code:0,message:"success"}))})}else i()}}function o(){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}}class u{dsn;constructor(e={}){this.dsn=e.dsn}apply(e){const t=e.options.devServer;if(!1===(n=t)||null==n||"object"!=typeof n)return void s.sentryLogger.info("devServer is not configured, skipping SentryWebpackPlugin (production builds remain untouched)");var n;const{fileStream:u,logFile:c}=o(),l=i(this.dsn||r.default.options.dsn||"/sentry",u);s.sentryLogger.info(`Sentry mock plugin initialized, logs will be written to ${c}`);const d=t.setupMiddlewares;t.setupMiddlewares=(e,t)=>{const n=d?d(e,t):e,r={name:"sentry-mock",middleware:l};return n.unshift(r),n},e.hooks.shutdown.tap("SentryWebpackPlugin",()=>{u&&!u.destroyed&&u.close()})}}function c(e={}){return new u(e)}exports.SentryWebpackPlugin=u,exports.default=c,exports.sentryMiddleware=function(e={}){const{fileStream:t,logFile:n}=o();return s.sentryLogger.info(`Sentry mock middleware initialized, logs will be written to ${n}`),i(e.dsn||r.default.options.dsn||"/sentry",t)},exports.sentryPlugin=c;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { WebpackPluginInstance, Compiler } from 'webpack';
|
|
3
|
+
import DevServer from 'webpack-dev-server';
|
|
4
|
+
|
|
5
|
+
type SentryDevMiddleware = (req: IncomingMessage, res: ServerResponse, next: DevServer.NextFunction) => void;
|
|
6
|
+
interface ISentryWebpackPluginOptions {
|
|
7
|
+
dsn?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Connect/express-style middleware that mocks the sentry report endpoint
|
|
11
|
+
* during webpack-dev-server development. Mount it manually inside the
|
|
12
|
+
* `setupMiddlewares` option of webpack-dev-server.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { sentryMiddleware } from "@swifty.js/sentry/webpack";
|
|
17
|
+
*
|
|
18
|
+
* export default {
|
|
19
|
+
* devServer: {
|
|
20
|
+
* setupMiddlewares(middlewares) {
|
|
21
|
+
* middlewares.unshift({
|
|
22
|
+
* name: "sentry-mock",
|
|
23
|
+
* middleware: sentryMiddleware({ dsn: "/api/log" }),
|
|
24
|
+
* });
|
|
25
|
+
* return middlewares;
|
|
26
|
+
* },
|
|
27
|
+
* },
|
|
28
|
+
* };
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare function sentryMiddleware(options?: ISentryWebpackPluginOptions): SentryDevMiddleware;
|
|
32
|
+
/**
|
|
33
|
+
* Webpack plugin that automatically wires the sentry log-collection middleware
|
|
34
|
+
* into webpack-dev-server. It only takes effect when
|
|
35
|
+
* `compiler.options.devServer` exists, so production builds remain untouched.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { sentryPlugin } from "@swifty.js/sentry/webpack";
|
|
40
|
+
*
|
|
41
|
+
* export default {
|
|
42
|
+
* plugins: [sentryPlugin({ dsn: "/api/log" })],
|
|
43
|
+
* devServer: { ... },
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare class SentryWebpackPlugin implements WebpackPluginInstance {
|
|
48
|
+
private readonly dsn;
|
|
49
|
+
constructor(options?: ISentryWebpackPluginOptions);
|
|
50
|
+
apply(compiler: Compiler): void;
|
|
51
|
+
}
|
|
52
|
+
declare function sentryPlugin(options?: ISentryWebpackPluginOptions): SentryWebpackPlugin;
|
|
53
|
+
|
|
54
|
+
export { SentryWebpackPlugin, sentryPlugin as default, sentryMiddleware, sentryPlugin };
|
|
55
|
+
export type { ISentryWebpackPluginOptions, SentryDevMiddleware };
|
package/dist/webpack.js
ADDED
|
@@ -0,0 +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 r}from"node:fs";import"./constants/index.js";import"./types/enums.js";import i from"./utils/sentry.js";import{sentryLogger as s}from"./utils/logger.js";function l(e,n){return(o,r,i)=>{if(o.url===e&&"POST"===o.method){let e="";o.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)}),o.on("end",()=>{if(e)try{const t=function(t){return JSON.parse(t)}(e);n.write(JSON.stringify(t)+"\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 c(){const t=e(process.cwd(),"logs");n(t)||o(t,{recursive:!0});const i=(new Date).toISOString().replace(/[-:.]/g,"").slice(0,14),s=e(t,`sentry_${i}.jsonl`);return{fileStream:r(s,{flags:"a"}),logFile:s}}function d(t={}){const{fileStream:e,logFile:n}=c();s.info(`Sentry mock middleware initialized, logs will be written to ${n}`);return l(t.dsn||i.options.dsn||"/sentry",e)}class u{dsn;constructor(t={}){this.dsn=t.dsn}apply(t){const e=t.options.devServer;if(!1===(n=e)||null==n||"object"!=typeof n)return void s.info("devServer is not configured, skipping SentryWebpackPlugin (production builds remain untouched)");var n;const{fileStream:o,logFile:r}=c(),d=l(this.dsn||i.options.dsn||"/sentry",o);s.info(`Sentry mock plugin initialized, logs will be written to ${r}`);const u=e.setupMiddlewares;e.setupMiddlewares=(t,e)=>{const n=u?u(t,e):t,o={name:"sentry-mock",middleware:d};return n.unshift(o),n},t.hooks.shutdown.tap("SentryWebpackPlugin",()=>{o&&!o.destroyed&&o.close()})}}function f(t={}){return new u(t)}export{u as SentryWebpackPlugin,f as default,d as sentryMiddleware,f as sentryPlugin};
|
package/package.json
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@swifty.js/sentry",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "sentry sdk",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"sdk",
|
|
7
|
+
"sentry"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "https://github.com/hangtiancheng",
|
|
11
|
+
"homepage": "https://github.com/hangtiancheng/swifty-sentry/tree/main/sentry#readme",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/hangtiancheng/swifty-sentry.git",
|
|
15
|
+
"directory": "sentry"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/hangtiancheng/swifty-sentry/issues"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/index.cjs",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./plugins": {
|
|
35
|
+
"types": "./dist/plugins/index.d.ts",
|
|
36
|
+
"import": "./dist/plugins/index.js",
|
|
37
|
+
"require": "./dist/plugins/index.cjs"
|
|
38
|
+
},
|
|
39
|
+
"./react": {
|
|
40
|
+
"types": "./dist/react.d.ts",
|
|
41
|
+
"import": "./dist/react.js",
|
|
42
|
+
"require": "./dist/react.cjs"
|
|
43
|
+
},
|
|
44
|
+
"./vue": {
|
|
45
|
+
"types": "./dist/vue.d.ts",
|
|
46
|
+
"import": "./dist/vue.js",
|
|
47
|
+
"require": "./dist/vue.cjs"
|
|
48
|
+
},
|
|
49
|
+
"./vite": {
|
|
50
|
+
"types": "./dist/vite.d.ts",
|
|
51
|
+
"import": "./dist/vite.js",
|
|
52
|
+
"require": "./dist/vite.cjs"
|
|
53
|
+
},
|
|
54
|
+
"./webpack": {
|
|
55
|
+
"types": "./dist/webpack.d.ts",
|
|
56
|
+
"import": "./dist/webpack.js",
|
|
57
|
+
"require": "./dist/webpack.cjs"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"test": "vitest run --config ./vitest.config.ts",
|
|
62
|
+
"test:watch": "vitest --config ./vitest.config.ts",
|
|
63
|
+
"test:coverage": "vitest run --config ./vitest.config.ts --coverage",
|
|
64
|
+
"typecheck": "tsc --noEmit",
|
|
65
|
+
"vite7": "pnpm add -D vite7@npm:vite@7.3.3",
|
|
66
|
+
"format": "oxfmt --write ./",
|
|
67
|
+
"build": "rollup -c ./rollup.config.ts",
|
|
68
|
+
"build:tsup": "tsup --config ./tsup.config.ts"
|
|
69
|
+
},
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@fingerprintjs/fingerprintjs": "^5.2.0",
|
|
72
|
+
"@rrweb/record": "2.1.0",
|
|
73
|
+
"pako": "^2.2.0",
|
|
74
|
+
"ua-parser-js": "^2.0.10",
|
|
75
|
+
"web-vitals": "^5.3.0",
|
|
76
|
+
"zod": "^4.4.3"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
80
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
81
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
82
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
83
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
84
|
+
"@rrweb/record": "2.1.0",
|
|
85
|
+
"@types/jsdom": "^28.0.3",
|
|
86
|
+
"@types/node": "^25.9.4",
|
|
87
|
+
"@types/pako": "^2.0.4",
|
|
88
|
+
"@types/react": "^19.2.17",
|
|
89
|
+
"@types/react-dom": "^19.2.3",
|
|
90
|
+
"@vitest/coverage-v8": "^1.6.1",
|
|
91
|
+
"jsdom": "^24.1.3",
|
|
92
|
+
"oxfmt": "^0.54.0",
|
|
93
|
+
"react": "^19.2.7",
|
|
94
|
+
"rollup": "^4.62.2",
|
|
95
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
96
|
+
"tsup": "^8.5.1",
|
|
97
|
+
"typescript": "^6.0.3",
|
|
98
|
+
"vite": "^8.1.3",
|
|
99
|
+
"vite7": "npm:vite@7.3.3",
|
|
100
|
+
"vitest": "^1.6.1",
|
|
101
|
+
"vue": "^3.5.39",
|
|
102
|
+
"webpack": "^5.108.3",
|
|
103
|
+
"webpack-dev-server": "^5.2.6"
|
|
104
|
+
},
|
|
105
|
+
"peerDependencies": {
|
|
106
|
+
"react": "^19.0.0",
|
|
107
|
+
"vite": "^7.0.0 || ^8.0.0",
|
|
108
|
+
"vue": "^3.0.0",
|
|
109
|
+
"webpack": "^4.0.0 || ^5.0.0"
|
|
110
|
+
},
|
|
111
|
+
"peerDependenciesMeta": {
|
|
112
|
+
"react": {
|
|
113
|
+
"optional": true
|
|
114
|
+
},
|
|
115
|
+
"vite": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
118
|
+
"vue": {
|
|
119
|
+
"optional": true
|
|
120
|
+
},
|
|
121
|
+
"webpack": {
|
|
122
|
+
"optional": true
|
|
123
|
+
},
|
|
124
|
+
"webpack-dev-server": {
|
|
125
|
+
"optional": true
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|