Skip to content

Commit afe7f41

Browse files
authored
v3 docs improvements (#993)
* WIP on adding versioning to the docs to make it less confusing * Link to v3 from v2 and vice versa. Also added a warning to the v2 docs * Make v3 the default * Trigger config docs about bundling * Next stpe to triggering guide from tasks overview * Server actions guidance for triggering * Moved the trigger.config docs to the end of fundamentals
1 parent 28837f3 commit afe7f41

File tree

10 files changed

+251
-25
lines changed

10 files changed

+251
-25
lines changed

docs/documentation/introduction.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
2-
title: "Getting Started: Introduction"
2+
title: "v2: Introduction"
33
sidebarTitle: "Introduction"
4-
description: "Welcome to the Trigger.dev documentation."
4+
description: "Welcome to the Trigger.dev (v2) documentation."
55
---
66

7+
<Warning>These are the docs for Trigger.dev v2. You probably want [the v3 docs](/v3).</Warning>
8+
79
Trigger.dev is an open source framework for creating long-running Jobs directly in your app with API Integrations, webhooks, scheduling and delays. You can reliably run Jobs that wouldn't normally work in serverless environments (like Vercel) because of timeouts.
810

911
You can use [Trigger.dev Cloud](https://cloud.trigger.dev) or [Self-host Trigger.dev](/documentation/guides/self-hosting) on your own infrastructure.
105 KB
Loading

docs/mint.json

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://mintlify.com/schema.json",
33
"name": "Trigger.dev",
44
"openapi": ["/openapi.yml"],
5+
"versions": ["v3 (Developer Preview)", "v2"],
56
"logo": {
67
"dark": "/logo/dark.png",
78
"light": "/logo/light.png",
@@ -37,22 +38,34 @@
3738
"url": "https://discord.gg/kA47vcd8P6"
3839
}
3940
],
41+
"primaryTab": {
42+
"name": "Home"
43+
},
4044
"tabs": [
4145
{
4246
"name": "Integrations",
43-
"url": "integrations"
47+
"url": "integrations",
48+
"version": "v2"
4449
},
4550
{
4651
"name": "Reference",
47-
"url": "sdk"
52+
"url": "sdk",
53+
"version": "v2"
4854
},
4955
{
5056
"name": "Examples",
51-
"url": "https://trigger.dev/apis"
57+
"url": "https://trigger.dev/apis",
58+
"version": "v2"
5259
},
5360
{
5461
"name": "v3 Developer Preview",
55-
"url": "v3"
62+
"url": "https://trigger.dev/docs/v3",
63+
"version": "v2"
64+
},
65+
{
66+
"name": "v2",
67+
"url": "https://trigger.dev/docs",
68+
"version": "v3 (Developer Preview)"
5669
}
5770
],
5871
"redirects": [
@@ -76,6 +89,7 @@
7689
"navigation": [
7790
{
7891
"group": "Getting Started",
92+
"version": "v2",
7993
"pages": [
8094
"documentation/introduction",
8195
{
@@ -107,6 +121,7 @@
107121
},
108122
{
109123
"group": "Concepts",
124+
"version": "v2",
110125
"pages": [
111126
"documentation/concepts/what-is-triggerdotdev",
112127
"documentation/concepts/limits",
@@ -142,6 +157,7 @@
142157
},
143158
{
144159
"group": "Guides",
160+
"version": "v2",
145161
"pages": [
146162
{
147163
"group": "Frameworks",
@@ -226,6 +242,7 @@
226242
},
227243
{
228244
"group": "Community & Support",
245+
"version": "v2",
229246
"pages": [
230247
"documentation/get-help",
231248
"documentation/faq",
@@ -430,14 +447,17 @@
430447
},
431448
{
432449
"group": "Overview",
450+
"version": "v2",
433451
"pages": ["examples/introduction"]
434452
},
435453
{
436454
"group": "",
455+
"version": "v3 (Developer Preview)",
437456
"pages": ["v3/introduction"]
438457
},
439458
{
440459
"group": "Getting Started",
460+
"version": "v3 (Developer Preview)",
441461
"pages": [
442462
"v3/quick-start",
443463
"v3/upgrading-from-v2",
@@ -448,6 +468,7 @@
448468
},
449469
{
450470
"group": "Fundamentals",
471+
"version": "v3 (Developer Preview)",
451472
"pages": [
452473
"v3/trigger-folder",
453474
"v3/tasks-overview",
@@ -456,15 +477,18 @@
456477
{
457478
"group": "Task types",
458479
"pages": ["v3/tasks-regular", "v3/tasks-scheduled", "v3/tasks-zod", "v3/tasks-webhooks"]
459-
}
480+
},
481+
"v3/trigger-config"
460482
]
461483
},
462484
{
463485
"group": "Development",
486+
"version": "v3 (Developer Preview)",
464487
"pages": ["v3/cli-dev", "v3/run-tests"]
465488
},
466489
{
467490
"group": "Deployment",
491+
"version": "v3 (Developer Preview)",
468492
"pages": [
469493
"v3/deploy-environment-variables",
470494
"v3/cli-deploy",
@@ -477,6 +501,7 @@
477501
},
478502
{
479503
"group": "Writing tasks",
504+
"version": "v3 (Developer Preview)",
480505
"pages": [
481506
"v3/writing-tasks-introduction",
482507
"v3/logging",
@@ -506,6 +531,7 @@
506531
},
507532
{
508533
"group": "Dashboard",
534+
"version": "v3 (Developer Preview)",
509535
"pages": [
510536
"v3/dashboard-overview",
511537
"v3/dashboard-runs",
@@ -515,6 +541,7 @@
515541
},
516542
{
517543
"group": "API reference",
544+
"version": "v3 (Developer Preview)",
518545
"pages": [
519546
{
520547
"group": "Functions",
@@ -558,12 +585,12 @@
558585
"v3/reference-cli-build",
559586
"v3/reference-cli-who-am-i"
560587
]
561-
},
562-
"v3/reference-trigger-config"
588+
}
563589
]
564590
},
565591
{
566592
"group": "Architecture",
593+
"version": "v3 (Developer Preview)",
567594
"pages": [
568595
"v3/architecture-how-it-works",
569596
"v3/architecture-multi-tenant-queue",
@@ -572,10 +599,12 @@
572599
},
573600
{
574601
"group": "Open source",
602+
"version": "v3 (Developer Preview)",
575603
"pages": ["v3/github-repo", "v3/open-source-self-hosting", "v3/open-source-contributing"]
576604
},
577605
{
578606
"group": "Help",
607+
"version": "v3 (Developer Preview)",
579608
"pages": [
580609
"v3/help-faqs",
581610
"v3/community",

docs/v3/errors-retrying.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ When an uncaught error is thrown inside your task, that task attempt will fail.
77

88
You can configure retrying in two ways:
99

10-
1. In your [trigger.config file](/v3/reference-trigger-config) you can set the default retrying behavior for all tasks.
10+
1. In your [trigger.config file](/v3/trigger-config) you can set the default retrying behavior for all tasks.
1111
2. On each task you can set the retrying behavior.
1212

1313
<Note>
1414
By default when you create your project using the CLI init command we disabled retrying in the DEV
15-
environment. You can enable it in your [trigger.config file](/v3/reference-trigger-config).
15+
environment. You can enable it in your [trigger.config file](/v3/trigger-config).
1616
</Note>
1717

1818
## A simple example with OpenAI

docs/v3/logging.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,20 @@ Tracing is a way to follow the flow of your code. It's very useful for debugging
3838

3939
Trigger.dev uses OpenTelemetry tracing under the hood. With automatic tracing for many things like task triggering, task attempts, HTTP requests, and more.
4040

41-
### Automatic instrumentation
42-
4341
| Name | Description |
4442
| ------------- | -------------------------------- |
4543
| Task triggers | Task triggers. |
4644
| Task attempts | Task attempts. |
4745
| HTTP requests | HTTP requests made by your code. |
48-
| OpenAI | OpenAI SDK calls. |
4946

50-
We want to provide automatic instrumentation for as many things as possible. Please do [request any automatic instrumentation](https://github.com/triggerdotdev/trigger.dev/issues/new?template=instrumentation_request.yml) you would like to see.
47+
### Adding instrumentations
48+
49+
![The run log
50+
](/images/v3/auto-instrumentation.png)
51+
52+
You can [add instrumentations](/v3/trigger-config#instrumentations). The Prisma one above will automatically trace all Prisma queries.
5153

52-
## Add custom traces
54+
### Add custom traces
5355

5456
If you want to add custom traces to your code, you can use the `logger.trace` function. It will create a new OTEL trace and you can set attributes on it.
5557

docs/v3/reference-trigger-config.mdx

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/v3/tasks-overview.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ When a task attempt fails, the `onError` function is called. It's useful for sen
149149
## Next steps
150150

151151
<CardGroup>
152+
<Card title="Triggering" icon="bolt" href="/v3/triggering">
153+
Learn how to trigger your tasks from your code.
154+
</Card>
152155
<Card title="Writing tasks" icon="wand-magic-sparkles" href="/v3/writing-tasks-introduction">
153156
Tasks are the core of Trigger.dev. Learn how to write them.
154157
</Card>

docs/v3/trigger-config.mdx

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
title: "The trigger.config.ts file"
3+
sidebarTitle: "trigger.config file"
4+
description: "This file is used to configure your project and how it's bundled."
5+
---
6+
7+
Let's take a look at a basic `trigger.config.ts` file. This is generated for you when you follow [the quick start guide](/v3/quick-start). This file is used to configure your project and how it's bundled.
8+
9+
```ts trigger.config.ts
10+
import type { TriggerConfig } from "@trigger.dev/sdk/v3";
11+
12+
export const config: TriggerConfig = {
13+
//Your project ref (you can see it on the Project settings page in the dashboard)
14+
project: "proj_gtcwttqhhtlasxgfuhxs",
15+
retries: {
16+
//If you want to retry a task in dev mode (when using the CLI)
17+
enabledInDev: false,
18+
//the default retry settings. Used if you don't specify on a task.
19+
default: {
20+
maxAttempts: 3,
21+
minTimeoutInMs: 1000,
22+
maxTimeoutInMs: 10000,
23+
factor: 2,
24+
randomize: true,
25+
},
26+
},
27+
//The paths for your trigger folders
28+
triggerDirectories: ["./trigger"],
29+
};
30+
```
31+
32+
Most of the time you don't need to change anything in this file, or if you do then we will tell you when you the run the CLI command.
33+
34+
## Instrumentations
35+
36+
We use OpenTelemetry (OTEL) for our run logs. This means you get a lot of information about your tasks with no effort. But you probably want to add more information to your logs. For example, here's all the Prisma calls automatically logged:
37+
38+
![The run log
39+
](/images/v3/auto-instrumentation.png)
40+
41+
Here we add Prisma and OpenAI instrumentations to your `trigger.config.ts` file.
42+
43+
```ts trigger.config.ts
44+
import type { TriggerConfig } from "@trigger.dev/sdk/v3";
45+
import { PrismaInstrumentation } from "@prisma/instrumentation";
46+
import { OpenAIInstrumentation } from "@traceloop/instrumentation-openai";
47+
48+
export const config: TriggerConfig = {
49+
//..other stuff
50+
instrumentations: [new PrismaInstrumentation(), new OpenAIInstrumentation()],
51+
};
52+
```
53+
54+
## ESM-only packages
55+
56+
We'll let you know when run the CLI dev command if this is a problem. Some packages are ESM-only so they don't work directly from CJS when using Node.js. In that case you need to add them to the `dependenciesToBundle` array in your `trigger.config.ts` file.
57+
58+
```ts trigger.config.ts
59+
import type { TriggerConfig } from "@trigger.dev/sdk/v3";
60+
61+
export const config: TriggerConfig = {
62+
//..other stuff
63+
//either regex or strings of package names
64+
dependenciesToBundle: [/@sindresorhus/, "escape-string-regexp"],
65+
};
66+
```
67+
68+
## Prisma (and other generators)
69+
70+
<Accordion title="The Prisma error you might see">
71+
72+
```bash
73+
✘ [ERROR] Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
74+
75+
In case this error is unexpected for you, please report it in
76+
https://pris.ly/prisma-prisma-bug-report
77+
at new PrismaClient (/app/node_modules/.prisma/client/default.js:43:11)
78+
at Object.<anonymous> (/lib/prisma.ts:7:33)
79+
at Module.\_compile (node:internal/modules/cjs/loader:1356:14)
80+
at Object.Module.\_extensions..js (node:internal/modules/cjs/loader:1414:10)
81+
at Module.load (node:internal/modules/cjs/loader:1197:32)
82+
at Function.Module.\_load (node:internal/modules/cjs/loader:1013:12)
83+
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
84+
at node:internal/main/run_main_module:28:49
85+
```
86+
87+
</Accordion>
88+
89+
Prisma works by generating a client from your `prisma.schema` file. This means you need to do a couple of things to get it to work with Trigger:
90+
91+
<Steps>
92+
93+
<Step title="package.json postinstall `prisma generate`">
94+
95+
```json
96+
{
97+
"scripts": {
98+
"postinstall": "prisma generate"
99+
}
100+
}
101+
```
102+
103+
Anything you put in `postinstall` will be run as part of the install step. This is how Next.js recommends you set up Prisma anyway.
104+
105+
</Step>
106+
107+
<Step title="Add prisma and the schema to trigger.config.ts">
108+
109+
```ts trigger.config.ts
110+
import type { TriggerConfig } from "@trigger.dev/sdk/v3";
111+
112+
export const config: TriggerConfig = {
113+
//..other stuff
114+
additionalFiles: ["./prisma/schema.prisma"],
115+
additionalPackages: ["[email protected]"],
116+
};
117+
```
118+
119+
This tells Trigger to bundle the Prisma client and the schema file.
120+
121+
</Step>
122+
123+
</Steps>
124+
125+
## Troubleshooting
126+
127+
If you have an issue with bundling let us know on [Discord](https://trigger.dev/discord) or [via email](https://trigger.dev/contact).

docs/v3/trigger-folder.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ We automatically bundle everything for your tasks. This includes:
1111
- Imported npm packages.
1212
- Other imports from your code.
1313

14-
This means you shouldn't need to think about what gets bundled. Just write your tasks and we'll take care of the rest.
14+
Mostly this means you shouldn't need to think about what gets bundled. Just write your tasks and we'll take care of the rest. If you need to alter the bundling you use the [trigger.config file](/v3/trigger-config).
1515

1616
## Multiple `/trigger` folders
1717

@@ -22,4 +22,4 @@ You can have multiple `/trigger` folders in your repository.
2222

2323
### (Optional) configuration
2424

25-
It is possible to manually set one or more folders as `/trigger` folders in your `trigger.config` file. View the [trigger.config documentation](/v3/referece-trigger-config) for more information.
25+
It is possible to manually set one or more folders as `/trigger` folders in your [trigger.config file](/v3/trigger-config).

0 commit comments

Comments
 (0)