@tracewayapp/svelte 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +56 -18
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,44 +1,88 @@
1
1
  # @tracewayapp/svelte
2
2
 
3
- Svelte integration for Traceway. Provides context setup and a helper function to capture errors.
3
+ Svelte integration for Traceway. Provides context-based setup and a helper to capture errors.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @tracewayapp/svelte
9
+ ```
4
10
 
5
11
  ## Setup
6
12
 
7
- Call `setupTraceway` in your root component (e.g., `App.svelte`) to initialize Traceway and provide context to child components.
13
+ Call `setupTraceway` in your root component:
8
14
 
9
15
  ```svelte
10
16
  <script>
11
17
  import { setupTraceway } from "@tracewayapp/svelte";
12
18
 
13
19
  setupTraceway({
14
- connectionString: "your-token@https://your-server.com/api/report",
15
- options: { debug: true }, // optional
20
+ connectionString: "your-token@https://traceway.example.com/api/report",
16
21
  });
17
22
  </script>
18
23
 
19
24
  <slot />
20
25
  ```
21
26
 
22
- ## getTraceway Helper
27
+ ## Capture Errors in Components
23
28
 
24
- Access capture methods from any child component.
29
+ Use `getTraceway` in child components:
25
30
 
26
31
  ```svelte
27
32
  <script>
28
33
  import { getTraceway } from "@tracewayapp/svelte";
29
34
 
30
- const { captureException, captureMessage } = getTraceway();
35
+ const { captureException } = getTraceway();
31
36
 
32
- function handleClick() {
37
+ async function handleSubmit() {
33
38
  try {
34
- doSomething();
35
- } catch (err) {
36
- captureException(err);
39
+ await submitForm();
40
+ } catch (error) {
41
+ captureException(error);
37
42
  }
38
43
  }
39
44
  </script>
40
45
 
41
- <button on:click={handleClick}>Do Something</button>
46
+ <button on:click={handleSubmit}>Submit</button>
47
+ ```
48
+
49
+ ## With Options
50
+
51
+ ```svelte
52
+ <script>
53
+ import { setupTraceway } from "@tracewayapp/svelte";
54
+
55
+ setupTraceway({
56
+ connectionString: "your-token@https://traceway.example.com/api/report",
57
+ options: {
58
+ debug: true,
59
+ version: "1.0.0",
60
+ },
61
+ });
62
+ </script>
63
+
64
+ <slot />
65
+ ```
66
+
67
+ ## SvelteKit Setup
68
+
69
+ For SvelteKit, set up Traceway in your root layout:
70
+
71
+ ```svelte
72
+ <!-- src/routes/+layout.svelte -->
73
+ <script>
74
+ import { setupTraceway } from "@tracewayapp/svelte";
75
+ import { browser } from "$app/environment";
76
+
77
+ // Only initialize on client
78
+ if (browser) {
79
+ setupTraceway({
80
+ connectionString: "your-token@https://traceway.example.com/api/report",
81
+ });
82
+ }
83
+ </script>
84
+
85
+ <slot />
42
86
  ```
43
87
 
44
88
  ## API
@@ -60,12 +104,6 @@ Returns `{ captureException, captureExceptionWithAttributes, captureMessage }`.
60
104
 
61
105
  Throws if used outside a component tree where `setupTraceway` has been called.
62
106
 
63
- ## Global Error Handling
64
-
65
- Traceway automatically installs global error handlers (`window.onerror` and `onunhandledrejection`) when initialized. These capture uncaught errors and unhandled promise rejections.
66
-
67
- For Svelte-specific error handling, you can use Svelte's `onError` lifecycle function or wrap error-prone code in try/catch blocks using `captureException`.
68
-
69
107
  ## Requirements
70
108
 
71
109
  - Svelte >= 4.0
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@tracewayapp/svelte",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Traceway Svelte integration with context and helper functions",
5
- "main": "./dist/index.cjs",
6
- "module": "./dist/index.js",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "require": "./dist/index.cjs"
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
13
  }
14
14
  },
15
15
  "files": [
@@ -23,7 +23,7 @@
23
23
  "dev": "tsup --watch"
24
24
  },
25
25
  "dependencies": {
26
- "@tracewayapp/frontend": "0.2.0"
26
+ "@tracewayapp/frontend": "0.3.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "svelte": ">=4.0.0"