Skip to content

Commit fb8bc3b

Browse files
committed
feat(svelte-integration): hawk catcher added in svelte playground
1 parent 8f7960d commit fb8bc3b

File tree

5 files changed

+691
-7
lines changed

5 files changed

+691
-7
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_HAWK_TOKEN=your_integration_token_here

packages/svelte/playground/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Test playground for Hawk Error Tracker integration with SvelteKit and Svelte.
55
## Table of Contents
66

77
- [Getting Started](#getting-started)
8+
- [Hawk Integration](#hawk-integration)
89

910
## Getting Started
1011

@@ -21,3 +22,25 @@ yarn install
2122
```shell
2223
yarn dev
2324
```
25+
26+
## Hawk Integration
27+
28+
Current integration in `hooks.client.ts`:
29+
30+
```typescript
31+
import HawkCatcher from '@hawk.so/javascript';
32+
33+
if (import.meta.env.VITE_HAWK_TOKEN) {
34+
new HawkCatcher({
35+
token: import.meta.env.VITE_HAWK_TOKEN
36+
});
37+
}
38+
```
39+
40+
Hawk automatically registers global error handlers for:
41+
42+
- `window.onerror`
43+
- `window.onunhandledrejection`
44+
45+
**Note:** HawkCatcher is browser-only and cannot run on the server (uses `localStorage`, `window`, etc.). Server-side
46+
errors are not tracked automatically.

packages/svelte/playground/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "hawk-svelte-playground",
3+
"private": true,
34
"version": "1.0.0",
45
"description": "SvelteKit playground for testing Hawk.so error handling integration",
56
"type": "module",
@@ -8,6 +9,9 @@
89
"build": "vite build",
910
"preview": "vite preview"
1011
},
12+
"dependencies": {
13+
"@hawk.so/javascript": "*"
14+
},
1115
"devDependencies": {
1216
"@sveltejs/kit": "^2.48.5",
1317
"@sveltejs/vite-plugin-svelte": "^6.2.1",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import HawkCatcher from '@hawk.so/javascript';
2+
3+
if (import.meta.env.VITE_HAWK_TOKEN) {
4+
new HawkCatcher({
5+
token: import.meta.env.VITE_HAWK_TOKEN
6+
});
7+
}

0 commit comments

Comments
 (0)