@uncaughtdev/svelte 0.1.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.
- package/dist/index.d.mts +71 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +58 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as _uncaughtdev_core from '@uncaughtdev/core';
|
|
2
|
+
import { UncaughtConfig } from '@uncaughtdev/core';
|
|
3
|
+
export { Breadcrumb, EnvironmentInfo, UncaughtClient, UncaughtConfig, UncaughtEvent, getClient, initUncaught } from '@uncaughtdev/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Initializes the Uncaught error monitoring client for Svelte applications.
|
|
7
|
+
* Automatically sets up global error handlers (`window.onerror` and
|
|
8
|
+
* `unhandledrejection`) on the client side.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```ts
|
|
12
|
+
* // In your Svelte app entry point (e.g., +layout.ts or main.ts)
|
|
13
|
+
* import { setupUncaught } from '@uncaughtdev/svelte';
|
|
14
|
+
*
|
|
15
|
+
* setupUncaught({ dsn: 'your-dsn', environment: 'production' });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param config - Partial Uncaught configuration.
|
|
19
|
+
* @returns The initialized UncaughtClient instance.
|
|
20
|
+
*/
|
|
21
|
+
declare function setupUncaught(config?: Partial<UncaughtConfig>): _uncaughtdev_core.UncaughtClient;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Type definitions for SvelteKit error hook parameters.
|
|
25
|
+
* Defined locally to avoid requiring @sveltejs/kit at runtime
|
|
26
|
+
* when it is an optional peer dependency.
|
|
27
|
+
*/
|
|
28
|
+
interface ServerErrorInput {
|
|
29
|
+
error: unknown;
|
|
30
|
+
event: {
|
|
31
|
+
request: {
|
|
32
|
+
method: string;
|
|
33
|
+
};
|
|
34
|
+
url: {
|
|
35
|
+
toString: () => string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
interface ClientErrorInput {
|
|
40
|
+
error: unknown;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a SvelteKit `handleError` hook for server-side error capturing.
|
|
44
|
+
* Reports unhandled server errors to Uncaught with request context.
|
|
45
|
+
*
|
|
46
|
+
* Usage in `src/hooks.server.ts`:
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { handleError } from '@uncaughtdev/svelte';
|
|
49
|
+
*
|
|
50
|
+
* export const handleError = handleError();
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @returns A SvelteKit HandleServerError function.
|
|
54
|
+
*/
|
|
55
|
+
declare function handleError(): ({ error, event }: ServerErrorInput) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a SvelteKit `handleError` hook for client-side error capturing.
|
|
58
|
+
* Reports unhandled client errors to Uncaught.
|
|
59
|
+
*
|
|
60
|
+
* Usage in `src/hooks.client.ts`:
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { handleClientError } from '@uncaughtdev/svelte';
|
|
63
|
+
*
|
|
64
|
+
* export const handleError = handleClientError();
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @returns A SvelteKit HandleClientError function.
|
|
68
|
+
*/
|
|
69
|
+
declare function handleClientError(): ({ error }: ClientErrorInput) => void;
|
|
70
|
+
|
|
71
|
+
export { handleClientError, handleError, setupUncaught };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as _uncaughtdev_core from '@uncaughtdev/core';
|
|
2
|
+
import { UncaughtConfig } from '@uncaughtdev/core';
|
|
3
|
+
export { Breadcrumb, EnvironmentInfo, UncaughtClient, UncaughtConfig, UncaughtEvent, getClient, initUncaught } from '@uncaughtdev/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Initializes the Uncaught error monitoring client for Svelte applications.
|
|
7
|
+
* Automatically sets up global error handlers (`window.onerror` and
|
|
8
|
+
* `unhandledrejection`) on the client side.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* ```ts
|
|
12
|
+
* // In your Svelte app entry point (e.g., +layout.ts or main.ts)
|
|
13
|
+
* import { setupUncaught } from '@uncaughtdev/svelte';
|
|
14
|
+
*
|
|
15
|
+
* setupUncaught({ dsn: 'your-dsn', environment: 'production' });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @param config - Partial Uncaught configuration.
|
|
19
|
+
* @returns The initialized UncaughtClient instance.
|
|
20
|
+
*/
|
|
21
|
+
declare function setupUncaught(config?: Partial<UncaughtConfig>): _uncaughtdev_core.UncaughtClient;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Type definitions for SvelteKit error hook parameters.
|
|
25
|
+
* Defined locally to avoid requiring @sveltejs/kit at runtime
|
|
26
|
+
* when it is an optional peer dependency.
|
|
27
|
+
*/
|
|
28
|
+
interface ServerErrorInput {
|
|
29
|
+
error: unknown;
|
|
30
|
+
event: {
|
|
31
|
+
request: {
|
|
32
|
+
method: string;
|
|
33
|
+
};
|
|
34
|
+
url: {
|
|
35
|
+
toString: () => string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
interface ClientErrorInput {
|
|
40
|
+
error: unknown;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a SvelteKit `handleError` hook for server-side error capturing.
|
|
44
|
+
* Reports unhandled server errors to Uncaught with request context.
|
|
45
|
+
*
|
|
46
|
+
* Usage in `src/hooks.server.ts`:
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { handleError } from '@uncaughtdev/svelte';
|
|
49
|
+
*
|
|
50
|
+
* export const handleError = handleError();
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @returns A SvelteKit HandleServerError function.
|
|
54
|
+
*/
|
|
55
|
+
declare function handleError(): ({ error, event }: ServerErrorInput) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a SvelteKit `handleError` hook for client-side error capturing.
|
|
58
|
+
* Reports unhandled client errors to Uncaught.
|
|
59
|
+
*
|
|
60
|
+
* Usage in `src/hooks.client.ts`:
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { handleClientError } from '@uncaughtdev/svelte';
|
|
63
|
+
*
|
|
64
|
+
* export const handleError = handleClientError();
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @returns A SvelteKit HandleClientError function.
|
|
68
|
+
*/
|
|
69
|
+
declare function handleClientError(): ({ error }: ClientErrorInput) => void;
|
|
70
|
+
|
|
71
|
+
export { handleClientError, handleError, setupUncaught };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var core=require('@uncaughtdev/core');function i(r){let e=core.initUncaught(r??{});return typeof window<"u"&&(window.addEventListener("error",n=>{try{e.captureError(n.error||new Error(n.message));}catch(t){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to capture window error:",t);}}),window.addEventListener("unhandledrejection",n=>{try{e.captureError(n.reason instanceof Error?n.reason:new Error(String(n.reason)));}catch(t){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to capture unhandled rejection:",t);}})),e}function a(){return ({error:r,event:e})=>{try{core.getClient()?.captureError(r instanceof Error?r:new Error(String(r)),{request:{method:e.request.method,url:e.url.toString()}});}catch(n){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to capture server error:",n);}}}function u(){return ({error:r})=>{try{core.getClient()?.captureError(r instanceof Error?r:new Error(String(r)));}catch(e){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to capture client error:",e);}}}Object.defineProperty(exports,"getClient",{enumerable:true,get:function(){return core.getClient}});Object.defineProperty(exports,"initUncaught",{enumerable:true,get:function(){return core.initUncaught}});exports.handleClientError=u;exports.handleError=a;exports.setupUncaught=i;//# sourceMappingURL=index.js.map
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/hooks.ts"],"names":["setupUncaught","config","client","initUncaught","event","e","handleError","error","getClient","handleClientError"],"mappings":"mDAkBO,SAASA,EAAcC,CAAAA,CAAkC,CAC9D,IAAMC,CAAAA,CAASC,iBAAAA,CAAcF,GAAU,EAAqB,EAG5D,OAAI,OAAO,OAAW,GAAA,GACpB,MAAA,CAAO,iBAAiB,OAAA,CAAUG,CAAAA,EAAsB,CACtD,GAAI,CACFF,EAAO,YAAA,CACLE,CAAAA,CAAM,OAAS,IAAI,KAAA,CAAMA,EAAM,OAAO,CACxC,EACF,CAAA,MAASC,CAAAA,CAAG,CAEN,OAAA,CAAQ,GAAA,CAAI,WAAa,aAAA,EAC3B,OAAA,CAAQ,KAAA,CAAM,4CAAA,CAA8CA,CAAC,EAEjE,CACF,CAAC,CAAA,CAED,OAAO,gBAAA,CACL,oBAAA,CACCD,GAAiC,CAChC,GAAI,CACFF,CAAAA,CAAO,YAAA,CACLE,EAAM,MAAA,YAAkB,KAAA,CACpBA,EAAM,MAAA,CACN,IAAI,MAAM,MAAA,CAAOA,CAAAA,CAAM,MAAM,CAAC,CACpC,EACF,CAAA,MAASC,CAAAA,CAAG,CAEN,OAAA,CAAQ,GAAA,CAAI,WAAa,aAAA,EAC3B,OAAA,CAAQ,MACN,mDAAA,CACAA,CACF,EAEJ,CACF,CACF,GAGKH,CACT,CC3BO,SAASI,CAAAA,EAAc,CAC5B,OAAO,CAAC,CAAE,MAAAC,CAAAA,CAAO,KAAA,CAAAH,CAAM,CAAA,GAAwB,CAC7C,GAAI,CACaI,cAAAA,IACP,YAAA,CACND,CAAAA,YAAiB,MAAQA,CAAAA,CAAQ,IAAI,MAAM,MAAA,CAAOA,CAAK,CAAC,CAAA,CACxD,CACE,QAAS,CACP,MAAA,CAAQH,EAAM,OAAA,CAAQ,MAAA,CACtB,IAAKA,CAAAA,CAAM,GAAA,CAAI,UACjB,CACF,CACF,EACF,CAAA,MAASC,EAAG,CAEN,OAAA,CAAQ,IAAI,QAAA,GAAa,aAAA,EAC3B,OAAA,CAAQ,KAAA,CAAM,4CAAA,CAA8CA,CAAC,EAEjE,CACF,CACF,CAeO,SAASI,CAAAA,EAAoB,CAClC,OAAO,CAAC,CAAE,KAAA,CAAAF,CAAM,IAAwB,CACtC,GAAI,CACaC,cAAAA,EAAU,EACjB,aACND,CAAAA,YAAiB,KAAA,CAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAK,CAAC,CAC1D,EACF,CAAA,MAAS,CAAA,CAAG,CAEN,OAAA,CAAQ,GAAA,CAAI,WAAa,aAAA,EAC3B,OAAA,CAAQ,MAAM,4CAAA,CAA8C,CAAC,EAEjE,CACF,CACF","file":"index.js","sourcesContent":["import { initUncaught, type UncaughtConfig } from '@uncaughtdev/core';\n\n/**\n * Initializes the Uncaught error monitoring client for Svelte applications.\n * Automatically sets up global error handlers (`window.onerror` and\n * `unhandledrejection`) on the client side.\n *\n * Usage:\n * ```ts\n * // In your Svelte app entry point (e.g., +layout.ts or main.ts)\n * import { setupUncaught } from '@uncaughtdev/svelte';\n *\n * setupUncaught({ dsn: 'your-dsn', environment: 'production' });\n * ```\n *\n * @param config - Partial Uncaught configuration.\n * @returns The initialized UncaughtClient instance.\n */\nexport function setupUncaught(config?: Partial<UncaughtConfig>) {\n const client = initUncaught((config ?? {}) as UncaughtConfig);\n\n // Set up global error listeners on the client side\n if (typeof window !== 'undefined') {\n window.addEventListener('error', (event: ErrorEvent) => {\n try {\n client.captureError(\n event.error || new Error(event.message)\n );\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to capture window error:', e);\n }\n }\n });\n\n window.addEventListener(\n 'unhandledrejection',\n (event: PromiseRejectionEvent) => {\n try {\n client.captureError(\n event.reason instanceof Error\n ? event.reason\n : new Error(String(event.reason))\n );\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to capture unhandled rejection:',\n e\n );\n }\n }\n }\n );\n }\n\n return client;\n}\n","import { getClient } from '@uncaughtdev/core';\n\n/**\n * Type definitions for SvelteKit error hook parameters.\n * Defined locally to avoid requiring @sveltejs/kit at runtime\n * when it is an optional peer dependency.\n */\ninterface ServerErrorInput {\n error: unknown;\n event: {\n request: { method: string };\n url: { toString: () => string };\n };\n}\n\ninterface ClientErrorInput {\n error: unknown;\n}\n\n/**\n * Creates a SvelteKit `handleError` hook for server-side error capturing.\n * Reports unhandled server errors to Uncaught with request context.\n *\n * Usage in `src/hooks.server.ts`:\n * ```ts\n * import { handleError } from '@uncaughtdev/svelte';\n *\n * export const handleError = handleError();\n * ```\n *\n * @returns A SvelteKit HandleServerError function.\n */\nexport function handleError() {\n return ({ error, event }: ServerErrorInput) => {\n try {\n const client = getClient();\n client?.captureError(\n error instanceof Error ? error : new Error(String(error)),\n {\n request: {\n method: event.request.method,\n url: event.url.toString(),\n },\n }\n );\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to capture server error:', e);\n }\n }\n };\n}\n\n/**\n * Creates a SvelteKit `handleError` hook for client-side error capturing.\n * Reports unhandled client errors to Uncaught.\n *\n * Usage in `src/hooks.client.ts`:\n * ```ts\n * import { handleClientError } from '@uncaughtdev/svelte';\n *\n * export const handleError = handleClientError();\n * ```\n *\n * @returns A SvelteKit HandleClientError function.\n */\nexport function handleClientError() {\n return ({ error }: ClientErrorInput) => {\n try {\n const client = getClient();\n client?.captureError(\n error instanceof Error ? error : new Error(String(error))\n );\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to capture client error:', e);\n }\n }\n };\n}\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {initUncaught,getClient}from'@uncaughtdev/core';export{getClient,initUncaught}from'@uncaughtdev/core';function i(r){let e=initUncaught(r??{});return typeof window<"u"&&(window.addEventListener("error",n=>{try{e.captureError(n.error||new Error(n.message));}catch(t){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to capture window error:",t);}}),window.addEventListener("unhandledrejection",n=>{try{e.captureError(n.reason instanceof Error?n.reason:new Error(String(n.reason)));}catch(t){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to capture unhandled rejection:",t);}})),e}function a(){return ({error:r,event:e})=>{try{getClient()?.captureError(r instanceof Error?r:new Error(String(r)),{request:{method:e.request.method,url:e.url.toString()}});}catch(n){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to capture server error:",n);}}}function u(){return ({error:r})=>{try{getClient()?.captureError(r instanceof Error?r:new Error(String(r)));}catch(e){process.env.NODE_ENV==="development"&&console.error("[Uncaught] Failed to capture client error:",e);}}}export{u as handleClientError,a as handleError,i as setupUncaught};//# sourceMappingURL=index.mjs.map
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/hooks.ts"],"names":["setupUncaught","config","client","initUncaught","event","e","handleError","error","getClient","handleClientError"],"mappings":"6GAkBO,SAASA,EAAcC,CAAAA,CAAkC,CAC9D,IAAMC,CAAAA,CAASC,YAAAA,CAAcF,GAAU,EAAqB,EAG5D,OAAI,OAAO,OAAW,GAAA,GACpB,MAAA,CAAO,iBAAiB,OAAA,CAAUG,CAAAA,EAAsB,CACtD,GAAI,CACFF,EAAO,YAAA,CACLE,CAAAA,CAAM,OAAS,IAAI,KAAA,CAAMA,EAAM,OAAO,CACxC,EACF,CAAA,MAASC,CAAAA,CAAG,CAEN,OAAA,CAAQ,GAAA,CAAI,WAAa,aAAA,EAC3B,OAAA,CAAQ,KAAA,CAAM,4CAAA,CAA8CA,CAAC,EAEjE,CACF,CAAC,CAAA,CAED,OAAO,gBAAA,CACL,oBAAA,CACCD,GAAiC,CAChC,GAAI,CACFF,CAAAA,CAAO,YAAA,CACLE,EAAM,MAAA,YAAkB,KAAA,CACpBA,EAAM,MAAA,CACN,IAAI,MAAM,MAAA,CAAOA,CAAAA,CAAM,MAAM,CAAC,CACpC,EACF,CAAA,MAASC,CAAAA,CAAG,CAEN,OAAA,CAAQ,GAAA,CAAI,WAAa,aAAA,EAC3B,OAAA,CAAQ,MACN,mDAAA,CACAA,CACF,EAEJ,CACF,CACF,GAGKH,CACT,CC3BO,SAASI,CAAAA,EAAc,CAC5B,OAAO,CAAC,CAAE,MAAAC,CAAAA,CAAO,KAAA,CAAAH,CAAM,CAAA,GAAwB,CAC7C,GAAI,CACaI,SAAAA,IACP,YAAA,CACND,CAAAA,YAAiB,MAAQA,CAAAA,CAAQ,IAAI,MAAM,MAAA,CAAOA,CAAK,CAAC,CAAA,CACxD,CACE,QAAS,CACP,MAAA,CAAQH,EAAM,OAAA,CAAQ,MAAA,CACtB,IAAKA,CAAAA,CAAM,GAAA,CAAI,UACjB,CACF,CACF,EACF,CAAA,MAASC,EAAG,CAEN,OAAA,CAAQ,IAAI,QAAA,GAAa,aAAA,EAC3B,OAAA,CAAQ,KAAA,CAAM,4CAAA,CAA8CA,CAAC,EAEjE,CACF,CACF,CAeO,SAASI,CAAAA,EAAoB,CAClC,OAAO,CAAC,CAAE,KAAA,CAAAF,CAAM,IAAwB,CACtC,GAAI,CACaC,SAAAA,EAAU,EACjB,aACND,CAAAA,YAAiB,KAAA,CAAQA,CAAAA,CAAQ,IAAI,KAAA,CAAM,MAAA,CAAOA,CAAK,CAAC,CAC1D,EACF,CAAA,MAAS,CAAA,CAAG,CAEN,OAAA,CAAQ,GAAA,CAAI,WAAa,aAAA,EAC3B,OAAA,CAAQ,MAAM,4CAAA,CAA8C,CAAC,EAEjE,CACF,CACF","file":"index.mjs","sourcesContent":["import { initUncaught, type UncaughtConfig } from '@uncaughtdev/core';\n\n/**\n * Initializes the Uncaught error monitoring client for Svelte applications.\n * Automatically sets up global error handlers (`window.onerror` and\n * `unhandledrejection`) on the client side.\n *\n * Usage:\n * ```ts\n * // In your Svelte app entry point (e.g., +layout.ts or main.ts)\n * import { setupUncaught } from '@uncaughtdev/svelte';\n *\n * setupUncaught({ dsn: 'your-dsn', environment: 'production' });\n * ```\n *\n * @param config - Partial Uncaught configuration.\n * @returns The initialized UncaughtClient instance.\n */\nexport function setupUncaught(config?: Partial<UncaughtConfig>) {\n const client = initUncaught((config ?? {}) as UncaughtConfig);\n\n // Set up global error listeners on the client side\n if (typeof window !== 'undefined') {\n window.addEventListener('error', (event: ErrorEvent) => {\n try {\n client.captureError(\n event.error || new Error(event.message)\n );\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to capture window error:', e);\n }\n }\n });\n\n window.addEventListener(\n 'unhandledrejection',\n (event: PromiseRejectionEvent) => {\n try {\n client.captureError(\n event.reason instanceof Error\n ? event.reason\n : new Error(String(event.reason))\n );\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error(\n '[Uncaught] Failed to capture unhandled rejection:',\n e\n );\n }\n }\n }\n );\n }\n\n return client;\n}\n","import { getClient } from '@uncaughtdev/core';\n\n/**\n * Type definitions for SvelteKit error hook parameters.\n * Defined locally to avoid requiring @sveltejs/kit at runtime\n * when it is an optional peer dependency.\n */\ninterface ServerErrorInput {\n error: unknown;\n event: {\n request: { method: string };\n url: { toString: () => string };\n };\n}\n\ninterface ClientErrorInput {\n error: unknown;\n}\n\n/**\n * Creates a SvelteKit `handleError` hook for server-side error capturing.\n * Reports unhandled server errors to Uncaught with request context.\n *\n * Usage in `src/hooks.server.ts`:\n * ```ts\n * import { handleError } from '@uncaughtdev/svelte';\n *\n * export const handleError = handleError();\n * ```\n *\n * @returns A SvelteKit HandleServerError function.\n */\nexport function handleError() {\n return ({ error, event }: ServerErrorInput) => {\n try {\n const client = getClient();\n client?.captureError(\n error instanceof Error ? error : new Error(String(error)),\n {\n request: {\n method: event.request.method,\n url: event.url.toString(),\n },\n }\n );\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to capture server error:', e);\n }\n }\n };\n}\n\n/**\n * Creates a SvelteKit `handleError` hook for client-side error capturing.\n * Reports unhandled client errors to Uncaught.\n *\n * Usage in `src/hooks.client.ts`:\n * ```ts\n * import { handleClientError } from '@uncaughtdev/svelte';\n *\n * export const handleError = handleClientError();\n * ```\n *\n * @returns A SvelteKit HandleClientError function.\n */\nexport function handleClientError() {\n return ({ error }: ClientErrorInput) => {\n try {\n const client = getClient();\n client?.captureError(\n error instanceof Error ? error : new Error(String(error))\n );\n } catch (e) {\n // Never crash the host app\n if (process.env.NODE_ENV === 'development') {\n console.error('[Uncaught] Failed to capture client error:', e);\n }\n }\n };\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uncaughtdev/svelte",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Svelte and SvelteKit SDK for Uncaught error monitoring",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Uncaught",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/AjeeshDevops/uncaught.git",
|
|
10
|
+
"directory": "packages/svelte"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/AjeeshDevops/uncaught#readme",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"svelte",
|
|
15
|
+
"sveltekit",
|
|
16
|
+
"error-monitoring",
|
|
17
|
+
"error-handler",
|
|
18
|
+
"debugging",
|
|
19
|
+
"vibe-coding"
|
|
20
|
+
],
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"module": "./dist/index.mjs",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.mjs",
|
|
28
|
+
"require": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"files": ["dist"],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsup",
|
|
35
|
+
"dev": "tsup --watch",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"clean": "rm -rf dist"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"svelte": ">=4.0.0",
|
|
41
|
+
"@sveltejs/kit": ">=1.0.0",
|
|
42
|
+
"@uncaughtdev/core": "workspace:*"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"@sveltejs/kit": {
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@uncaughtdev/core": "workspace:*"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"svelte": "^4.0.0",
|
|
54
|
+
"@sveltejs/kit": "^2.0.0",
|
|
55
|
+
"tsup": "^8.0.0",
|
|
56
|
+
"typescript": "^5.4.0"
|
|
57
|
+
}
|
|
58
|
+
}
|