@trigger.dev/sdk 4.5.0-rc.6 → 4.5.0-rc.7

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 (191) hide show
  1. package/dist/commonjs/v3/ai.d.ts +171 -5
  2. package/dist/commonjs/v3/ai.js +309 -22
  3. package/dist/commonjs/v3/ai.js.map +1 -1
  4. package/dist/commonjs/v3/chat-server.d.ts +8 -0
  5. package/dist/commonjs/v3/chat-server.js +32 -10
  6. package/dist/commonjs/v3/chat-server.js.map +1 -1
  7. package/dist/commonjs/v3/chat-server.test.js +51 -0
  8. package/dist/commonjs/v3/chat-server.test.js.map +1 -1
  9. package/dist/commonjs/v3/createStartSessionAction.test.js +30 -0
  10. package/dist/commonjs/v3/createStartSessionAction.test.js.map +1 -1
  11. package/dist/commonjs/v3/sessions.d.ts +3 -2
  12. package/dist/commonjs/v3/sessions.js +3 -2
  13. package/dist/commonjs/v3/sessions.js.map +1 -1
  14. package/dist/commonjs/version.js +1 -1
  15. package/dist/esm/v3/ai.d.ts +171 -5
  16. package/dist/esm/v3/ai.js +309 -22
  17. package/dist/esm/v3/ai.js.map +1 -1
  18. package/dist/esm/v3/chat-server.d.ts +8 -0
  19. package/dist/esm/v3/chat-server.js +32 -10
  20. package/dist/esm/v3/chat-server.js.map +1 -1
  21. package/dist/esm/v3/chat-server.test.js +51 -0
  22. package/dist/esm/v3/chat-server.test.js.map +1 -1
  23. package/dist/esm/v3/createStartSessionAction.test.js +30 -0
  24. package/dist/esm/v3/createStartSessionAction.test.js.map +1 -1
  25. package/dist/esm/v3/sessions.d.ts +3 -2
  26. package/dist/esm/v3/sessions.js +3 -2
  27. package/dist/esm/v3/sessions.js.map +1 -1
  28. package/dist/esm/version.js +1 -1
  29. package/docs/ai/prompts.mdx +430 -0
  30. package/docs/ai-chat/actions.mdx +115 -0
  31. package/docs/ai-chat/anatomy.mdx +71 -0
  32. package/docs/ai-chat/backend.mdx +817 -0
  33. package/docs/ai-chat/background-injection.mdx +221 -0
  34. package/docs/ai-chat/changelog.mdx +850 -0
  35. package/docs/ai-chat/chat-local.mdx +174 -0
  36. package/docs/ai-chat/client-protocol.mdx +1081 -0
  37. package/docs/ai-chat/compaction.mdx +411 -0
  38. package/docs/ai-chat/custom-agents.mdx +364 -0
  39. package/docs/ai-chat/error-handling.mdx +415 -0
  40. package/docs/ai-chat/fast-starts.mdx +672 -0
  41. package/docs/ai-chat/frontend.mdx +580 -0
  42. package/docs/ai-chat/how-it-works.mdx +230 -0
  43. package/docs/ai-chat/lifecycle-hooks.mdx +530 -0
  44. package/docs/ai-chat/mcp.mdx +101 -0
  45. package/docs/ai-chat/overview.mdx +90 -0
  46. package/docs/ai-chat/patterns/branching-conversations.mdx +284 -0
  47. package/docs/ai-chat/patterns/code-sandbox.mdx +126 -0
  48. package/docs/ai-chat/patterns/database-persistence.mdx +414 -0
  49. package/docs/ai-chat/patterns/human-in-the-loop.mdx +275 -0
  50. package/docs/ai-chat/patterns/large-payloads.mdx +169 -0
  51. package/docs/ai-chat/patterns/oom-resilience.mdx +120 -0
  52. package/docs/ai-chat/patterns/persistence-and-replay.mdx +211 -0
  53. package/docs/ai-chat/patterns/recovery-boot.mdx +230 -0
  54. package/docs/ai-chat/patterns/skills.mdx +221 -0
  55. package/docs/ai-chat/patterns/sub-agents.mdx +383 -0
  56. package/docs/ai-chat/patterns/tool-result-auditing.mdx +148 -0
  57. package/docs/ai-chat/patterns/trusted-edge-signals.mdx +337 -0
  58. package/docs/ai-chat/patterns/version-upgrades.mdx +172 -0
  59. package/docs/ai-chat/pending-messages.mdx +343 -0
  60. package/docs/ai-chat/prompt-caching.mdx +206 -0
  61. package/docs/ai-chat/quick-start.mdx +161 -0
  62. package/docs/ai-chat/reference.mdx +909 -0
  63. package/docs/ai-chat/server-chat.mdx +263 -0
  64. package/docs/ai-chat/sessions.mdx +333 -0
  65. package/docs/ai-chat/testing.mdx +682 -0
  66. package/docs/ai-chat/tools.mdx +191 -0
  67. package/docs/ai-chat/types.mdx +242 -0
  68. package/docs/ai-chat/upgrade-guide.mdx +515 -0
  69. package/docs/apikeys.mdx +54 -0
  70. package/docs/building-with-ai.mdx +261 -0
  71. package/docs/bulk-actions.mdx +49 -0
  72. package/docs/changelog.mdx +6 -0
  73. package/docs/cli-deploy-commands.mdx +9 -0
  74. package/docs/cli-dev-commands.mdx +9 -0
  75. package/docs/cli-dev.mdx +8 -0
  76. package/docs/cli-init-commands.mdx +58 -0
  77. package/docs/cli-introduction.mdx +25 -0
  78. package/docs/cli-list-profiles-commands.mdx +42 -0
  79. package/docs/cli-login-commands.mdx +33 -0
  80. package/docs/cli-logout-commands.mdx +33 -0
  81. package/docs/cli-preview-archive.mdx +59 -0
  82. package/docs/cli-promote-commands.mdx +9 -0
  83. package/docs/cli-switch.mdx +43 -0
  84. package/docs/cli-update-commands.mdx +42 -0
  85. package/docs/cli-whoami-commands.mdx +33 -0
  86. package/docs/community.mdx +6 -0
  87. package/docs/config/config-file.mdx +602 -0
  88. package/docs/config/extensions/additionalFiles.mdx +38 -0
  89. package/docs/config/extensions/additionalPackages.mdx +40 -0
  90. package/docs/config/extensions/aptGet.mdx +34 -0
  91. package/docs/config/extensions/audioWaveform.mdx +20 -0
  92. package/docs/config/extensions/custom.mdx +380 -0
  93. package/docs/config/extensions/emitDecoratorMetadata.mdx +29 -0
  94. package/docs/config/extensions/esbuildPlugin.mdx +31 -0
  95. package/docs/config/extensions/ffmpeg.mdx +45 -0
  96. package/docs/config/extensions/lightpanda.mdx +56 -0
  97. package/docs/config/extensions/overview.mdx +67 -0
  98. package/docs/config/extensions/playwright.mdx +195 -0
  99. package/docs/config/extensions/prismaExtension.mdx +1014 -0
  100. package/docs/config/extensions/puppeteer.mdx +30 -0
  101. package/docs/config/extensions/pythonExtension.mdx +182 -0
  102. package/docs/config/extensions/syncEnvVars.mdx +291 -0
  103. package/docs/context.mdx +235 -0
  104. package/docs/database-connections.mdx +213 -0
  105. package/docs/deploy-environment-variables.mdx +435 -0
  106. package/docs/deployment/atomic-deployment.mdx +172 -0
  107. package/docs/deployment/overview.mdx +257 -0
  108. package/docs/deployment/preview-branches.mdx +224 -0
  109. package/docs/errors-retrying.mdx +379 -0
  110. package/docs/github-actions.mdx +222 -0
  111. package/docs/github-integration.mdx +136 -0
  112. package/docs/github-repo.mdx +8 -0
  113. package/docs/help-email.mdx +6 -0
  114. package/docs/help-slack.mdx +11 -0
  115. package/docs/hidden-tasks.mdx +56 -0
  116. package/docs/how-it-works.mdx +454 -0
  117. package/docs/how-to-reduce-your-spend.mdx +217 -0
  118. package/docs/idempotency.mdx +504 -0
  119. package/docs/introduction.mdx +223 -0
  120. package/docs/limits.mdx +241 -0
  121. package/docs/logging.mdx +195 -0
  122. package/docs/machines.mdx +952 -0
  123. package/docs/manual-setup.mdx +632 -0
  124. package/docs/mcp-agent-rules.mdx +41 -0
  125. package/docs/mcp-introduction.mdx +385 -0
  126. package/docs/mcp-tools.mdx +273 -0
  127. package/docs/migrating-from-v3.mdx +334 -0
  128. package/docs/observability/dashboards.mdx +102 -0
  129. package/docs/observability/query.mdx +585 -0
  130. package/docs/open-source-contributing.mdx +16 -0
  131. package/docs/open-source-self-hosting.mdx +541 -0
  132. package/docs/private-networking/aws-console-setup.mdx +304 -0
  133. package/docs/private-networking/overview.mdx +144 -0
  134. package/docs/private-networking/troubleshooting.mdx +78 -0
  135. package/docs/queue-concurrency.mdx +354 -0
  136. package/docs/quick-start.mdx +97 -0
  137. package/docs/realtime/auth.mdx +208 -0
  138. package/docs/realtime/backend/overview.mdx +45 -0
  139. package/docs/realtime/backend/streams.mdx +418 -0
  140. package/docs/realtime/backend/subscribe.mdx +225 -0
  141. package/docs/realtime/how-it-works.mdx +94 -0
  142. package/docs/realtime/overview.mdx +63 -0
  143. package/docs/realtime/react-hooks/overview.mdx +73 -0
  144. package/docs/realtime/react-hooks/streams.mdx +449 -0
  145. package/docs/realtime/react-hooks/subscribe.mdx +674 -0
  146. package/docs/realtime/react-hooks/swr.mdx +87 -0
  147. package/docs/realtime/react-hooks/triggering.mdx +194 -0
  148. package/docs/realtime/react-hooks/use-wait-token.mdx +34 -0
  149. package/docs/realtime/run-object.mdx +174 -0
  150. package/docs/replaying.mdx +72 -0
  151. package/docs/request-feature.mdx +6 -0
  152. package/docs/roadmap.mdx +6 -0
  153. package/docs/run-tests.mdx +20 -0
  154. package/docs/run-usage.mdx +113 -0
  155. package/docs/runs/heartbeats.mdx +38 -0
  156. package/docs/runs/max-duration.mdx +139 -0
  157. package/docs/runs/metadata.mdx +734 -0
  158. package/docs/runs/priority.mdx +31 -0
  159. package/docs/runs.mdx +396 -0
  160. package/docs/self-hosting/docker.mdx +458 -0
  161. package/docs/self-hosting/env/supervisor.mdx +74 -0
  162. package/docs/self-hosting/env/webapp.mdx +276 -0
  163. package/docs/self-hosting/kubernetes.mdx +601 -0
  164. package/docs/self-hosting/overview.mdx +108 -0
  165. package/docs/skills.mdx +85 -0
  166. package/docs/tags.mdx +120 -0
  167. package/docs/tasks/overview.mdx +697 -0
  168. package/docs/tasks/scheduled.mdx +382 -0
  169. package/docs/tasks/schemaTask.mdx +413 -0
  170. package/docs/tasks/streams.mdx +884 -0
  171. package/docs/triggering.mdx +1320 -0
  172. package/docs/troubleshooting-alerts.mdx +385 -0
  173. package/docs/troubleshooting-debugging-in-vscode.mdx +8 -0
  174. package/docs/troubleshooting-github-issues.mdx +6 -0
  175. package/docs/troubleshooting-uptime-status.mdx +6 -0
  176. package/docs/troubleshooting.mdx +398 -0
  177. package/docs/upgrading-packages.mdx +80 -0
  178. package/docs/vercel-integration.mdx +207 -0
  179. package/docs/versioning.mdx +56 -0
  180. package/docs/video-walkthrough.mdx +23 -0
  181. package/docs/wait-for-token.mdx +540 -0
  182. package/docs/wait-for.mdx +42 -0
  183. package/docs/wait-until.mdx +53 -0
  184. package/docs/wait.mdx +18 -0
  185. package/docs/writing-tasks-introduction.mdx +33 -0
  186. package/package.json +8 -5
  187. package/skills/trigger-authoring-chat-agent/SKILL.md +296 -0
  188. package/skills/trigger-authoring-tasks/SKILL.md +254 -0
  189. package/skills/trigger-chat-agent-advanced/SKILL.md +368 -0
  190. package/skills/trigger-cost-savings/SKILL.md +116 -0
  191. package/skills/trigger-realtime-and-frontend/SKILL.md +276 -0
@@ -0,0 +1,334 @@
1
+ ---
2
+ title: "Migrating from v3"
3
+ description: "What's new in v4, how to migrate, and breaking changes."
4
+ ---
5
+
6
+ import NodeVersions from "/snippets/node-versions.mdx";
7
+ import MigrateV4UsingAi from "/snippets/migrate-v4-using-ai.mdx";
8
+
9
+ <Warning>
10
+ **Action required: Trigger.dev v3 deprecation**
11
+
12
+ We're retiring Trigger.dev v3. **New v3 deploys will stop working from 1 April 2026.** Trigger.dev v4 is stable, fully supported, and recommended for all users.
13
+
14
+ **Key dates:**
15
+
16
+ - **1 April 2026** — New v3 deploys will no longer work. Existing v3 runs will continue to execute.
17
+ - **1 July 2026** — v3 will be fully shut down. All v3 runs will stop executing.
18
+
19
+ **What you need to do:** Migrate to v4 before April to avoid disruption to your task executions. The migration takes about 2 minutes — follow the steps on this page below. If you have questions or need help, [contact us](https://trigger.dev/contact) or reach out in our [Discord](https://trigger.dev/discord).
20
+
21
+ </Warning>
22
+
23
+ ## What's new in v4?
24
+
25
+ | Feature | Description |
26
+ | :------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
27
+ | [Wait for token](/wait-for-token) | Create and wait for tokens to be completed, enabling approval workflows and waiting for arbitrary external conditions. |
28
+ | Wait idempotency | Skip waits if the same idempotency key is used again when using [wait for](/wait-for#wait-idempotency), [wait until](/wait-until#wait-idempotency), or [wait for token](/wait-for-token#wait-idempotency). |
29
+ | [Priority](/runs/priority) | Specify a priority when triggering a task. |
30
+ | [Global lifecycle hooks](/tasks/overview#global-lifecycle-hooks) | Register global lifecycle hooks that are executed for all runs, regardless of the task. |
31
+ | [onWait and onResume](/tasks/overview#onwait-and-onresume-functions) | Run code when a run is paused or resumed because of a wait. |
32
+ | [onComplete](/tasks/overview#oncomplete-function) | Run code when a run completes, regardless of whether it succeeded or failed. |
33
+ | [onCancel](/tasks/overview#oncancel-function) | Run code when a run is cancelled. |
34
+ | [Hidden tasks](/hidden-tasks) | Create tasks that are not exported from your trigger files but can still be executed. |
35
+ | [Middleware & locals](#middleware-and-locals) | The middleware system runs at the top level, executing before and after all lifecycle hooks. The locals API allows sharing data between middleware and hooks. |
36
+ | [useWaitToken](/realtime/react-hooks/use-wait-token) | Use the useWaitToken hook to complete a wait token from a React component. |
37
+ | [Task-backed AI tools](/tasks/schemaTask#task-backed-ai-tools) | Use `schemaTask` with AI SDK `tool()` and `ai.toolExecute()` (legacy `ai.tool` is deprecated). |
38
+
39
+ ## Node.js support
40
+
41
+ <NodeVersions />
42
+
43
+ ## How to migrate to v4
44
+
45
+ First read the deprecations and breaking changes sections below.
46
+
47
+ We recommend the following steps to migrate to v4:
48
+
49
+ 1. Install the v4 package.
50
+ 2. Run the `trigger dev` CLI command and test your tasks locally, fixing any breaking changes.
51
+ 3. Deploy to the staging environment and test your tasks in staging, fixing any breaking changes. (this step is optional, but highly recommended)
52
+ 4. Once you've verified that v4 is working as expected, you should deploy your application backend with the updated v4 package.
53
+ 5. Once you've deployed your application backend, you should deploy your tasks to the production environment.
54
+
55
+ Note that between steps 4 and 5, runs triggered with the v4 package will continue using v3, and only new runs triggered after step 5 is complete will use v4.
56
+
57
+ <Warning>
58
+ Once v4 is activated in your environment, there will be a period of time where old runs will
59
+ continue to execute using v3, while new runs will use v4. Because these engines use completely
60
+ different underlying queues and concurrency models, it's possible you may have up to double the
61
+ amount of concurrently executing runs. Once the runs drain from the old run engine, the
62
+ concurrency will return to normal.
63
+ </Warning>
64
+
65
+ <Note>
66
+ When migrating from v3 to v4, our infrastructure IPs may change. If you use IP allowlisting (e.g. for databases or APIs), [update your allowlists](https://trigger.dev/changelog/static-ips) with the current static IPs before or immediately after switching to v4 to avoid connectivity issues or downtime.
67
+ </Note>
68
+
69
+ ## Migrate using AI
70
+
71
+ Use the prompt in the accordion below to help you migrate your v3 tasks to v4. The prompt gives good results when using Claude 4 Sonnet. You’ll need a relatively large token limit.
72
+
73
+ <MigrateV4UsingAi />
74
+
75
+ ## Installation
76
+
77
+ To opt-in to using v4, you will need to update your dependencies to the latest version:
78
+
79
+ <CodeGroup>
80
+
81
+ ```bash npx
82
+ npx trigger.dev@latest update
83
+ ```
84
+
85
+ ```bash yarn
86
+ yarn dlx trigger.dev@latest update
87
+ ```
88
+
89
+ ```bash pnpm
90
+ pnpm dlx trigger.dev@latest update
91
+ ```
92
+
93
+ </CodeGroup>
94
+
95
+ This command should update all of your `@trigger.dev/*` packages to a `4.x` version.
96
+
97
+ ## Deprecations
98
+
99
+ We've deprecated the following APIs:
100
+
101
+ ### @trigger.dev/sdk/v3
102
+
103
+ We've deprecated the `@trigger.dev/sdk/v3` import path and moved to a new path:
104
+
105
+ ```ts
106
+ // This still works, but will be removed in a future version
107
+ import { task } from "@trigger.dev/sdk/v3";
108
+
109
+ // This is the new path
110
+ import { task } from "@trigger.dev/sdk";
111
+ ```
112
+
113
+ ### `handleError` and `init`
114
+
115
+ We've renamed the `handleError` hook to `catchError` to better reflect that it can catch and react to errors. `handleError` will be removed in a future version.
116
+
117
+ `init` was previously used to initialize data used in the run function:
118
+
119
+ ```ts
120
+ import { task } from "@trigger.dev/sdk";
121
+
122
+ const myTask = task({
123
+ init: async () => {
124
+ return {
125
+ myClient: new MyClient(),
126
+ };
127
+ },
128
+ run: async (payload: any, { ctx, init }) => {
129
+ const client = init.myClient;
130
+ await client.doSomething();
131
+ },
132
+ });
133
+ ```
134
+
135
+ This has now been deprecated in favor of the `locals` API and middleware. See the [Improved middleware and locals](/tasks/overview#middleware-and-locals-functions) section for more details.
136
+
137
+ ### toolTask
138
+
139
+ We've deprecated the `toolTask` function, which created both a Trigger.dev task and a tool compatible with the Vercel [AI SDK](https://vercel.com/docs/ai-sdk):
140
+
141
+ ```ts
142
+ import { toolTask, schemaTask } from "@trigger.dev/sdk";
143
+ import { z } from "zod";
144
+ import { generateText } from "ai";
145
+
146
+ const myToolTask = toolTask({
147
+ id: "my-tool-task",
148
+ run: async (payload: any, { ctx }) => {},
149
+ });
150
+
151
+ export const myAiTask = schemaTask({
152
+ id: "my-ai-task",
153
+ schema: z.object({
154
+ text: z.string(),
155
+ }),
156
+ run: async (payload, { ctx }) => {
157
+ const { text } = await generateText({
158
+ prompt: payload.text,
159
+ model: openai("gpt-4o"),
160
+ tools: {
161
+ myToolTask,
162
+ },
163
+ });
164
+ },
165
+ });
166
+ ```
167
+
168
+ We've replaced the `toolTask` function with `schemaTask` plus AI SDK `tool()` and `ai.toolExecute()` (the older `ai.tool()` wrapper is deprecated). See [Task-backed AI tools](/tasks/schemaTask#task-backed-ai-tools).
169
+
170
+ ## Breaking changes
171
+
172
+ ### Queue changes
173
+
174
+ Previously, it was possible to specify a queue name of a queue that did not exist, along with a concurrency limit. The queue would then be created "on-demand" with the specified concurrency limit. If the queue did exist, the concurrency limit of the queue would be updated to the specified value:
175
+
176
+ ```ts
177
+ await myTask.trigger({ foo: "bar" }, { queue: { name: "my-queue", concurrencyLimit: 10 } });
178
+ ```
179
+
180
+ This is no longer possible, and queues must now be defined ahead of time using the `queue` function:
181
+
182
+ ```ts
183
+ import { queue } from "@trigger.dev/sdk";
184
+
185
+ const myQueue = queue({
186
+ name: "my-queue",
187
+ concurrencyLimit: 10,
188
+ });
189
+ ```
190
+
191
+ Now when you trigger a task, you can only specify the queue by name:
192
+
193
+ ```ts
194
+ await myTask.trigger({ foo: "bar" }, { queue: "my-queue" });
195
+ ```
196
+
197
+ Or you can set the queue on the task:
198
+
199
+ ```ts
200
+ import { queue, task } from "@trigger.dev/sdk";
201
+
202
+ const myQueue = queue({
203
+ name: "my-queue",
204
+ concurrencyLimit: 10,
205
+ });
206
+
207
+ export const myTask = task({
208
+ id: "my-task",
209
+ queue: myQueue,
210
+ run: async (payload: any, { ctx }) => {},
211
+ });
212
+
213
+ // You can optionally specify the queue directly on the task
214
+ export const myTask2 = task({
215
+ id: "my-task-2",
216
+ queue: {
217
+ name: "my-queue-2",
218
+ concurrencyLimit: 50,
219
+ },
220
+ run: async (payload: any, { ctx }) => {},
221
+ });
222
+ ```
223
+
224
+ Now you can trigger these tasks without having to specify the queue name in the trigger options:
225
+
226
+ ```ts
227
+ await myTask.trigger({ foo: "bar" }); // Will use the queue defined on the task
228
+ await myTask2.trigger({ foo: "bar" }); // Will use the queue defined on the task
229
+ ```
230
+
231
+ If you're using `concurrencyKey` you can specify the `queue` and `concurrencyKey` like this:
232
+
233
+ ```ts
234
+ const handle = await generatePullRequest.trigger(data, {
235
+ queue: "paid-users",
236
+ concurrencyKey: data.userId,
237
+ });
238
+ ```
239
+
240
+ For each unique value of `concurrencyKey`, a new queue will be created using the `concurrencyLimit` from the queue. This allows you to have a queue per user.
241
+
242
+ ### Lifecycle hooks
243
+
244
+ We've changed the function signatures of the lifecycle hooks to be more consistent and easier to use, by unifying all the parameters into a single object that can be destructured.
245
+
246
+ Previously, hooks received a payload as the first argument and then an additional object as the second argument:
247
+
248
+ ```ts
249
+ import { task } from "@trigger.dev/sdk";
250
+
251
+ export const myTask = task({
252
+ id: "my-task",
253
+ onStart: ({ payload, ctx }) => {},
254
+ run: async (payload, { ctx }) => {},
255
+ });
256
+ ```
257
+
258
+ Now, all the parameters are passed in a single object:
259
+
260
+ ```ts
261
+ import { task } from "@trigger.dev/sdk";
262
+
263
+ export const myTask = task({
264
+ id: "my-task",
265
+ onStart: ({ payload, ctx }) => {},
266
+ // The run function still uses separate parameters
267
+ run: async (payload, { ctx }) => {},
268
+ });
269
+ ```
270
+
271
+ This is true for all the lifecycle hooks:
272
+
273
+ ```ts
274
+ import { task } from "@trigger.dev/sdk";
275
+
276
+ export const myTask = task({
277
+ id: "my-task",
278
+ onStart: ({ payload, ctx, task }) => {},
279
+ onSuccess: ({ payload, ctx, task, output }) => {},
280
+ onFailure: ({ payload, ctx, task, error }) => {},
281
+ onWait: ({ payload, ctx, task, wait }) => {},
282
+ onResume: ({ payload, ctx, task, wait }) => {},
283
+ onComplete: ({ payload, ctx, task, result }) => {},
284
+ catchError: ({ payload, ctx, task, error, retry, retryAt, retryDelayInMs }) => {},
285
+ run: async (payload, { ctx }) => {},
286
+ });
287
+ ```
288
+
289
+ ### Context changes
290
+
291
+ We've made a few small changes to the `ctx` object:
292
+
293
+ - `ctx.attempt.id` and `ctx.attempt.status` have been removed. `ctx.attempt.number` is still available.
294
+ - `ctx.task.exportName` has been removed (since we no longer require tasks to be exported to be triggered).
295
+
296
+ ### BatchTrigger changes
297
+
298
+ The `batchTrigger` function no longer returns a `runs` list directly. In v3, you could access the runs directly from the batch handle:
299
+
300
+ ```ts
301
+ // In v3
302
+ const batchHandle = await tasks.batchTrigger([
303
+ [myTask, { foo: "bar" }],
304
+ [myOtherTask, { baz: "qux" }],
305
+ ]);
306
+
307
+ // You could access runs directly
308
+ console.log(batchHandle.runs);
309
+ ```
310
+
311
+ In v4, you now need to use the `batch.retrieve()` method to get the batch with its runs:
312
+
313
+ ```ts
314
+ // In v4
315
+ const batchHandle = await tasks.batchTrigger([
316
+ [myTask, { foo: "bar" }],
317
+ [myOtherTask, { baz: "qux" }],
318
+ ]);
319
+
320
+ // Now you need to retrieve the batch to get the runs
321
+ const batch = await batch.retrieve(batchHandle.batchId);
322
+ console.log(batch.runs);
323
+ ```
324
+
325
+ ### OpenTelemetry
326
+
327
+ We are now using newer versions of the OpenTelemetry packages. This means that if you're using custom exporters you may need to update the packages:
328
+
329
+ | Package | Previous Version | New Version | Change Type |
330
+ | ----------------------------------------- | ---------------- | ----------- | ------------ |
331
+ | `@opentelemetry/api-logs` | 0.52.1 | 0.203.0 | Major update |
332
+ | `@opentelemetry/exporter-logs-otlp-http` | 0.52.1 | 0.203.0 | Major update |
333
+ | `@opentelemetry/exporter-trace-otlp-http` | 0.52.1 | 0.203.0 | Major update |
334
+ | `@opentelemetry/instrumentation` | 0.52.1 | 0.203.0 | Major update |
@@ -0,0 +1,102 @@
1
+ ---
2
+ title: "Dashboards"
3
+ description: "Create custom dashboards with real-time metrics powered by TRQL queries."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ In the Trigger.dev dashboard we have built-in dashboards and you can create your own.
9
+
10
+ Dashboards are powered by [TRQL queries](/observability/query) with widgets that can be displayed as charts, tables, or single values. They automatically refresh to show the latest data.
11
+
12
+ ### Available metrics data
13
+
14
+ Trigger.dev automatically collects process metrics (CPU, memory) and Node.js runtime metrics (event loop, heap) for all deployed tasks -- no configuration needed. Requires SDK version **4.4.1 or later**. You can also create custom metrics using the `otel.metrics` API from the SDK.
15
+
16
+ All of this data is available in the `metrics` table for use in dashboard widgets. See [Logging, tracing & metrics](/logging#metrics) for the full list of automatic metrics and how to create custom ones, or the [Query page](/observability/query#metrics-table-columns) for the `metrics` table schema.
17
+
18
+ ![The built-in Metrics dashboard](/images/metrics-built-in.png)
19
+
20
+ ### Visualization types
21
+
22
+ - **Line chart** - Show trends over time
23
+ - **Bar chart** - Compare values across categories
24
+ - **Area chart** - Display cumulative trends
25
+ - **Table** - Show detailed data in rows
26
+ - **Single value** - Display a single metric (count, sum, average, etc.)
27
+
28
+ You can also add Titles to your dashboard.
29
+
30
+ ## Filtering and time ranges
31
+
32
+ All widgets on a dashboard use the time range filter applied to the dashboard.
33
+
34
+ You can also filter the data by:
35
+
36
+ - Scope: Environment, Project, Organization
37
+ - Tasks
38
+ - Queues
39
+
40
+ ## Creating custom dashboards
41
+
42
+ 1. In the sidebar click the + icon next to "Dashboards".
43
+ 2. Name your custom dashboard.
44
+ 3. From the top-right you can "Add chart" or "Add title".
45
+ 4. For charts you write [TRQL queries](/observability/query) and choose a visualization type.
46
+ 5. You can resize and reposition widgets on your dashboards.
47
+
48
+ ## Performance considerations
49
+
50
+ ### Optimize queries for metrics
51
+
52
+ 1. **Use time bucketing** - `timeBucket()` automatically groups by appropriate intervals
53
+ 2. **Limit result size** - Add `LIMIT` clauses, especially for table widgets
54
+ 3. **Use approximate functions** - `uniq()` instead of `uniqExact()` for faster approximate counts
55
+
56
+ ## Exporting metric data
57
+
58
+ Export data from any metric widget:
59
+
60
+ 1. Click the widget menu (three dots)
61
+ 2. Select "Copy JSON" or "Copy CSV"
62
+
63
+ ## Best practices
64
+
65
+ 1. **Start simple** - Begin with basic metrics and iterate based on insights
66
+ 2. **Use meaningful names** - Give widgets clear, descriptive titles
67
+ 3. **Group related metrics** - Organize dashboards by theme (performance, costs, errors)
68
+ 4. **Test queries first** - Use the Query page to develop and test before adding to dashboards
69
+
70
+ ## Troubleshooting
71
+
72
+ ### Widget shows "No data"
73
+
74
+ - Check that your query returns results in the Query page
75
+ - Verify time filters include the period with data
76
+ - Ensure task/queue filters match existing runs
77
+
78
+ ### Widget is slow to load
79
+
80
+ - Add time range filters to your query
81
+ - Use `LIMIT` clauses
82
+ - Simplify aggregations
83
+ - Check query execution time in Query page
84
+
85
+ ### Chart displays incorrectly
86
+
87
+ - Verify column names match visualization config
88
+ - Check data types (numbers for charts, dates for time series)
89
+ - Ensure `timeBucket()` is used for time-series charts
90
+ - Review that series columns exist in query results
91
+
92
+ ## Limits
93
+
94
+ Dashboards are powered by Query so have [the same limits](/observability/query#limits) as Query.
95
+
96
+ There is a separate concurrency limits for metric widgets.
97
+
98
+ | Limit | Details |
99
+ | :------------------------ | :------------- |
100
+ | Concurrent widget queries | 30 per project |
101
+
102
+ See [Limits](/limits) for details.