11# Hawk Error Tracker - SvelteKit Playground
22
3- Test playground for Hawk Error Tracker integration with SvelteKit and Svelte 5 .
3+ Test playground for Hawk Error Tracker integration with SvelteKit and Svelte.
44
55## Table of Contents
66
77- [ Getting Started] ( #getting-started )
8- - [ What Hawk Catches] ( #what-hawk-catches )
9- - [ Error Test Scenarios] ( #error-test-scenarios )
10- - [ Testing Guide] ( #testing-guide )
118
129## Getting Started
1310
14- ### Prerequisites
15-
16- - Node.js 18+
17- - Yarn 1.x
18-
1911### Setup
2012
21131 . Install dependencies:
@@ -24,130 +16,8 @@ Test playground for Hawk Error Tracker integration with SvelteKit and Svelte 5.
2416yarn install
2517```
2618
27- 2 . Configure Hawk token:
28-
29- ``` shell
30- cp .env.example .env
31- ```
32-
33- Then add your token from [ hawk.so] ( https://garage.hawk.so ) to ` .env ` :
34-
35- ``` env
36- VITE_HAWK_TOKEN=your_integration_token_here
37- ```
38-
39- 3 . Start development server:
19+ 2 . Start development server:
4020
4121``` shell
4222yarn dev
4323```
44-
45- ## What Hawk Catches
46-
47- ### ✅ Automatically Caught
48-
49- Hawk automatically catches these errors via ` window.onerror ` and ` window.onunhandledrejection ` :
50-
51- - Event handler errors (` onclick ` , ` onsubmit ` , etc.)
52- - Lifecycle errors (` onMount ` , ` onDestroy ` )
53- - Reactive errors (` $effect ` , ` $derived ` )
54- - Async errors (` setTimeout ` , ` setInterval ` )
55- - Unhandled promise rejections
56- - Component rendering errors
57-
58- ### ❌ Not Caught
59-
60- - Form validation errors (intentional, use ` fail() ` )
61- - Errors caught by ` <svelte:boundary> ` (requires manual ` hawk.send() ` )
62- - SvelteKit ` handleError ` hook errors (requires manual ` hawk.send() ` )
63-
64- ## Error Test Scenarios
65-
66- Visit ` /errors ` to test 14 error scenarios:
67-
68- ### Load Functions
69-
70- - ** Load Expected** - ` error() ` helper in ` +page.ts `
71- - ** Load Unexpected** - Direct throw in ` +page.ts `
72- - ** Server Load** - Error in ` +page.server.ts `
73-
74- ### Component Lifecycle
75-
76- - ** onMount Error** - Error in ` onMount() ` hook
77- - ** $effect Error** - Error in Svelte 5 ` $effect ` rune
78-
79- ### Event Handlers
80-
81- - ** Click Handler** - Error in ` onclick `
82- - ** Submit Handler** - Error in form ` onsubmit `
83-
84- ### Async Errors
85-
86- - ** setTimeout Error** - Error inside ` setTimeout `
87- - ** Promise Rejection** - Unhandled promise rejection
88-
89- ### Form Actions
90-
91- - ** Form Validation** - ` fail() ` helper (not tracked)
92- - ** Form Unexpected** - Unexpected form action error
93-
94- ### Error Boundaries
95-
96- - ** Boundary Render** - Component rendering error
97- - ** Boundary Effect** - ` $effect ` error inside boundary
98-
99- ### Stores
100-
101- - ** Store Subscription** - Error in store callback
102-
103- ## Testing Guide
104-
105- ### Manual Testing
106-
107- ``` bash
108- yarn dev
109- ```
110-
111- 1 . Open ` http://localhost:5173/errors `
112- 2 . Open DevTools Console (F12)
113- 3 . Click each test card
114- 4 . Trigger the error
115- 5 . Check Hawk dashboard for tracked errors
116-
117- ### Console Markers
118-
119- | Marker | Handler | Description |
120- | --------| ---------------------| ------------------------------|
121- | 🔴 | ` handleError ` hook | Load/form action errors |
122- | 🟡 | Global handlers | Event/async/lifecycle errors |
123- | 🟢 | ` <svelte:boundary> ` | Component rendering errors |
124-
125- ### Expected Behavior
126-
127- | Error Type | Caught by Hawk | Notes |
128- | ------------------| ----------------| ----------------------------|
129- | Event handlers | ✅ | Auto via ` window.onerror ` |
130- | Lifecycle hooks | ✅ | Auto via ` window.onerror ` |
131- | Async errors | ✅ | Auto via global handlers |
132- | Load functions | ❌ | Needs manual ` hawk.send() ` |
133- | Form actions | ❌ | Needs manual ` hawk.send() ` |
134- | Error boundaries | ❌ | Needs manual ` hawk.send() ` |
135-
136- ## Integration
137-
138- Current integration in ` hooks.client.ts ` :
139-
140- ``` typescript
141- import HawkCatcher from ' @hawk.so/javascript' ;
142-
143- if (import .meta .env .VITE_HAWK_TOKEN ) {
144- new HawkCatcher (import .meta .env .VITE_HAWK_TOKEN );
145- }
146- ```
147-
148- Hawk automatically registers global error handlers for:
149-
150- - ` window.onerror `
151- - ` window.onunhandledrejection `
152-
153- ** Note:** HawkCatcher is browser-only and cannot run on the server (uses ` localStorage ` , ` window ` , etc.). Server-side errors are not tracked automatically.
0 commit comments