You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/examples/sentry-error-tracking.mdx
+42-20Lines changed: 42 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,12 @@ Automatically send errors and source maps to your Sentry project from your Trigg
13
13
- A [Sentry](https://sentry.io) account and project
14
14
- A [Trigger.dev](https://trigger.dev) account and project
15
15
16
-
## Build configuration
16
+
## Setup
17
17
18
-
To send errors to Sentry when there are errors in your tasks, you'll need to add this build configuration to your `trigger.config.ts` file. This will then run every time you deploy your project.
18
+
This setup involves two files:
19
+
20
+
1.**`trigger.config.ts`** - Configures the build to upload source maps to Sentry during deployment
21
+
2.**`trigger/init.ts`** - Initializes Sentry and registers the error tracking hook at runtime
19
22
20
23
<Note>
21
24
You will need to set the `SENTRY_AUTH_TOKEN` and `SENTRY_DSN` environment variables. You can find
@@ -25,11 +28,14 @@ To send errors to Sentry when there are errors in your tasks, you'll need to add
25
28
dashboard](https://cloud.trigger.dev), under environment variables in your project's sidebar.
26
29
</Note>
27
30
31
+
### Build configuration
32
+
33
+
Add this build configuration to your `trigger.config.ts` file. This uses the Sentry esbuild plugin to upload source maps every time you deploy your project.
deploying). You can use pre-built extensions or create your own.
74
63
</Note>
75
64
65
+
### Runtime initialization
66
+
67
+
Create a `trigger/init.ts` file to initialize Sentry and register the global `onFailure` hook. This file is automatically loaded when your tasks execute.
68
+
69
+
```ts trigger/init.ts
70
+
import { tasks } from"@trigger.dev/sdk";
71
+
import*asSentryfrom"@sentry/node";
72
+
73
+
// Initialize Sentry
74
+
Sentry.init({
75
+
defaultIntegrations: false,
76
+
// The Data Source Name (DSN) is a unique identifier for your Sentry project.
77
+
dsn: process.env.SENTRY_DSN,
78
+
// Update this to match the environment you want to track errors for
0 commit comments