-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger.config.ts
More file actions
85 lines (82 loc) · 2.45 KB
/
trigger.config.ts
File metadata and controls
85 lines (82 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { sentryEsbuildPlugin } from '@sentry/esbuild-plugin'
import { defineConfig } from '@trigger.dev/sdk/v3'
import { z } from 'zod'
import dotenv from 'dotenv'
import * as Sentry from '@sentry/nextjs'
import { esbuildPlugin } from '@trigger.dev/build/extensions'
dotenv.config()
const vercelEnv = process.env.VERCEL_ENV
const isProd = vercelEnv === 'production'
const project = z.string().min(1).parse(process.env.TRIGGER_PROJECT_ID)
const org = isProd ? z.string().min(1).parse(process.env.SENTRY_ORG) : ''
const sentryProject = isProd
? z.string().min(1).parse(process.env.SENTRY_PROJECT)
: ''
const sentryAuthToken = isProd
? z.string().min(1).parse(process.env.SENTRY_AUTH_TOKEN)
: ''
const dsn = isProd
? z.string().min(1).parse(process.env.NEXT_PUBLIC_SENTRY_DSN)
: ''
export default defineConfig({
project,
runtime: 'node',
logLevel: 'log',
// The max compute seconds a task is allowed to run. If the task run exceeds this duration, it will be stopped.
// You can override this on an individual task.
// See https://trigger.dev/docs/runs/max-duration
maxDuration: 3600,
retries: {
enabledInDev: true,
default: {
maxAttempts: 3,
minTimeoutInMs: 1000,
maxTimeoutInMs: 10000,
factor: 2,
randomize: true,
},
},
dirs: ['./src/trigger'],
build: {
extensions: [
esbuildPlugin(
sentryEsbuildPlugin({
org,
project: sentryProject,
// Find this auth token in settings -> developer settings -> auth tokens
authToken: sentryAuthToken,
}),
{ placement: 'last', target: 'deploy' },
),
],
},
init: () => {
Sentry.init({
defaultIntegrations: false,
// The Data Source Name (DSN) is a unique identifier for your Sentry project.
dsn,
// Update this to match the environment you want to track errors for
environment: vercelEnv,
beforeSend(event) {
if (
event.request?.headers?.['user-agent']?.includes(
'vercel-screenshot', // using 'vercel-screenshot' specifically as cron jobs have 'vercel-cron' user-agent in the header.
) ||
event.request?.headers?.['x-vercel-firewall-bypass']
) {
return null
}
return event
},
})
},
onFailure: ({ payload, error, ctx }) => {
console.error({ payload, error, ctx })
Sentry.captureException(error, {
extra: {
payload,
ctx,
},
})
},
})