@whnz/frontend-experience-error 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ interface Plugin {
2
+ name: string;
3
+ setup(): void;
4
+ }
5
+ declare function errorPlugin(): Plugin;
6
+
7
+ export { type Plugin, errorPlugin };
package/dist/index.mjs ADDED
@@ -0,0 +1,35 @@
1
+ import { report } from '@whnz/frontend-experience-core';
2
+
3
+ // src/index.ts
4
+ function errorPlugin() {
5
+ return {
6
+ name: "error",
7
+ setup() {
8
+ window.addEventListener("error", (event) => {
9
+ report({
10
+ type: "js-error",
11
+ timestamp: Date.now(),
12
+ extra: {
13
+ message: event.message,
14
+ file: event.filename,
15
+ line: event.lineno,
16
+ col: event.colno
17
+ }
18
+ });
19
+ });
20
+ window.addEventListener("unhandledrejection", (event) => {
21
+ report({
22
+ type: "promise-error",
23
+ timestamp: Date.now(),
24
+ extra: {
25
+ reason: String(event.reason)
26
+ }
27
+ });
28
+ });
29
+ }
30
+ };
31
+ }
32
+
33
+ export { errorPlugin };
34
+ //# sourceMappingURL=index.mjs.map
35
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAOO,SAAS,WAAA,GAAsB;AACpC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,OAAA;AAAA,IACN,KAAA,GAAQ;AACN,MAAA,MAAA,CAAO,gBAAA,CAAiB,OAAA,EAAS,CAAC,KAAA,KAAU;AAC1C,QAAA,MAAA,CAAO;AAAA,UACL,IAAA,EAAM,UAAA;AAAA,UACN,SAAA,EAAW,KAAK,GAAA,EAAI;AAAA,UACpB,KAAA,EAAO;AAAA,YACL,SAAS,KAAA,CAAM,OAAA;AAAA,YACf,MAAM,KAAA,CAAM,QAAA;AAAA,YACZ,MAAM,KAAA,CAAM,MAAA;AAAA,YACZ,KAAK,KAAA,CAAM;AAAA;AACb,SACD,CAAA;AAAA,MACH,CAAC,CAAA;AAED,MAAA,MAAA,CAAO,gBAAA,CAAiB,oBAAA,EAAsB,CAAC,KAAA,KAAU;AACvD,QAAA,MAAA,CAAO;AAAA,UACL,IAAA,EAAM,eAAA;AAAA,UACN,SAAA,EAAW,KAAK,GAAA,EAAI;AAAA,UACpB,KAAA,EAAO;AAAA,YACL,MAAA,EAAQ,MAAA,CAAO,KAAA,CAAM,MAAM;AAAA;AAC7B,SACD,CAAA;AAAA,MACH,CAAC,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"index.mjs","sourcesContent":["import { report } from '@whnz/frontend-experience-core';\n\nexport interface Plugin {\n name: string;\n setup(): void;\n}\n\nexport function errorPlugin(): Plugin {\n return {\n name: 'error',\n setup() {\n window.addEventListener('error', (event) => {\n report({\n type: 'js-error',\n timestamp: Date.now(),\n extra: {\n message: event.message,\n file: event.filename,\n line: event.lineno,\n col: event.colno,\n },\n });\n });\n\n window.addEventListener('unhandledrejection', (event) => {\n report({\n type: 'promise-error',\n timestamp: Date.now(),\n extra: {\n reason: String(event.reason),\n },\n });\n });\n },\n };\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@whnz/frontend-experience-error",
3
+ "version": "1.0.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "sideEffects": false,
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "dependencies": {
11
+ "@whnz/frontend-experience-core": "1.0.0"
12
+ },
13
+ "scripts": {
14
+ "build": "tsup"
15
+ }
16
+ }