1
export async function main(
2
workspace_id: string,
3
job_id: string, // The UUID of the job that errored
4
path: string, // The path of the script or flow that errored
5
is_flow: boolean, // Whether the runnable is a flow
6
error: object, // The error details
7
started_at: string, // The start datetime of the latest job that failed
8
trigger_path?: string, // The path of the trigger that errored in the format <trigger_type>/<trigger_path>
9
) {
10
const baseUrl = process.env["BASE_INTERNAL_URL"];
11
const token = process.env["WM_TOKEN"]
12
const fullUrl = `${baseUrl}/send_email_with_instance_smtp/${workspace_id}`
13
const body = JSON.stringify({ workspace_id, job_id, is_flow, error, started_at, path, trigger_path })
14
try {
15
await fetch(fullUrl, {
16
method: "POST",
17
headers: {
18
"Content-Type": "application/json",
19
"Authorization": `Bearer ${token}`
20
},
21
body
22
})
23
} catch (error) {
24
console.error(`Error: ${error}`)
25
}
26