Skip to content

Commit ca82ad2

Browse files
committed
feat(svelte-integration): hawk catcher added in svelte playground
1 parent d5a9048 commit ca82ad2

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
"name": "hawk.javascript",
44
"type": "commonjs",
55
"version": "0.0.0",
6-
"workspaces": [
7-
"packages/*",
8-
"packages/svelte/playground"
9-
],
6+
"workspaces": {
7+
"packages": [
8+
"packages/*",
9+
"packages/svelte/playground"
10+
],
11+
"nohoist": [
12+
"packages/svelte/playground"
13+
]
14+
},
1015
"scripts": {
1116
"dev": "yarn workspace @hawk.so/javascript dev",
1217
"build": "yarn workspace @hawk.so/javascript build",
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"build": "vite build",
1010
"preview": "vite preview"
1111
},
12+
"dependencies": {
13+
"@hawk.so/svelte": "*"
14+
},
1215
"devDependencies": {
1316
"@sveltejs/kit": "^2.48.5",
1417
"@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 Hawk from '@hawk.so/svelte';
2+
3+
if (import.meta.env.VITE_HAWK_TOKEN) {
4+
new Hawk({
5+
token: import.meta.env.VITE_HAWK_TOKEN,
6+
});
7+
}

0 commit comments

Comments
 (0)