Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/svelte-playground/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_HAWK_TOKEN=your_integration_token_here
20 changes: 20 additions & 0 deletions packages/svelte-playground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -21,3 +22,22 @@ yarn install
```shell
yarn dev
```

## Hawk Integration

Current integration in `hooks.client.ts`:

```typescript
import Hawk from '@hawk.so/svelte';

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`
7 changes: 7 additions & 0 deletions packages/svelte-playground/src/hooks.client.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it should be inside "svelte" package?

/packages
   /svelte
      /playground
      /src
   ...

Copy link
Member Author

@Reversean Reversean Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried it first, but it seems some problem with yarn or vite:

If I put playground directory into packages/svelte and define it as workspace (I need it because i need to add dependency on @hawk.so/svelte somehow) yarn workspace @hawk.so/svelte-playground build breaks with an error due to the fact that it does not understand some svelte syntax constructs.

Usually it output something like this:

error during build:
[vite-plugin-svelte:compile] [plugin vite-plugin-svelte:compile] src/routes/+layout.svelte (3:9)
1 | <script lang="ts">
2 | import '../app.css';
3 | import favicon from '$lib/assets/favicon.svg';
           ^
4 |
5 | let {children} = $props();

which shouldn't happen at all.

It seems that vitePreprocess from @sveltejs/vite-plugin-svelte stopped working in this case, but I still don't understand why.

Original file line number Diff line number Diff line change
@@ -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,
});
}
Loading