diff --git a/packages/svelte-playground/.env.example b/packages/svelte-playground/.env.example new file mode 100644 index 0000000..24fe108 --- /dev/null +++ b/packages/svelte-playground/.env.example @@ -0,0 +1 @@ +VITE_HAWK_TOKEN=your_integration_token_here diff --git a/packages/svelte-playground/README.md b/packages/svelte-playground/README.md index 1766c37..69d7159 100644 --- a/packages/svelte-playground/README.md +++ b/packages/svelte-playground/README.md @@ -5,6 +5,7 @@ Test playground for Hawk Error Tracker integration with SvelteKit and Svelte. ## Table of Contents - [Getting Started](#getting-started) +- [Hawk Integration](#hawk-integration) ## Getting Started @@ -21,3 +22,22 @@ yarn install ```shell yarn dev ``` + +## Hawk Integration + +Current integration in `hooks.client.ts`: + +```typescript +import Hawk from '@hawk.so/javascript'; + +if (import.meta.env.VITE_HAWK_TOKEN) { + new Hawk({ + token: import.meta.env.VITE_HAWK_TOKEN + }); +} +``` + +Hawk automatically registers global error handlers for: + +- `window.onerror` +- `window.onunhandledrejection` diff --git a/packages/svelte-playground/src/hooks.client.ts b/packages/svelte-playground/src/hooks.client.ts new file mode 100644 index 0000000..96918d0 --- /dev/null +++ b/packages/svelte-playground/src/hooks.client.ts @@ -0,0 +1,7 @@ +import Hawk from '@hawk.so/svelte'; + +if (import.meta.env.VITE_HAWK_TOKEN) { + new Hawk({ + token: import.meta.env.VITE_HAWK_TOKEN, + }); +}