From 0ab51d62bc3f24459c2c6d36a8b41af690366be1 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Thu, 16 Nov 2023 14:45:39 +0000 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20send=20notifications=20for=20in?= =?UTF-8?q?ternal=20runs=20and=20add=20isTest=20to=20the=20notification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/services/runs/deliverRunSubscription.server.ts | 1 + .../app/services/runs/performRunExecutionV3.server.ts | 2 +- docs/sdk/run-notification.mdx | 3 +++ packages/core/src/schemas/runs.ts | 4 ++++ references/job-catalog/src/supabase.ts | 8 ++++++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/webapp/app/services/runs/deliverRunSubscription.server.ts b/apps/webapp/app/services/runs/deliverRunSubscription.server.ts index 682b37fec..0d25f321c 100644 --- a/apps/webapp/app/services/runs/deliverRunSubscription.server.ts +++ b/apps/webapp/app/services/runs/deliverRunSubscription.server.ts @@ -178,6 +178,7 @@ export class DeliverRunSubscriptionService { startedAt: run.startedAt, updatedAt: run.updatedAt, completedAt: run.completedAt, + isTest: run.isTest, executionDurationInMs: run.executionDuration, executionCount: run.executionCount, job: { diff --git a/apps/webapp/app/services/runs/performRunExecutionV3.server.ts b/apps/webapp/app/services/runs/performRunExecutionV3.server.ts index 377a5414b..a9f836058 100644 --- a/apps/webapp/app/services/runs/performRunExecutionV3.server.ts +++ b/apps/webapp/app/services/runs/performRunExecutionV3.server.ts @@ -327,7 +327,7 @@ export class PerformRunExecutionV3Service { }); } - if (headers.success && headers.data["x-trigger-run-metadata"]) { + if (headers.success && headers.data["x-trigger-run-metadata"] && !run.internal) { logger.debug("Endpoint responded with run metadata", { metadata: headers.data["x-trigger-run-metadata"], }); diff --git a/docs/sdk/run-notification.mdx b/docs/sdk/run-notification.mdx index bcb7a964b..ae5d66fb7 100644 --- a/docs/sdk/run-notification.mdx +++ b/docs/sdk/run-notification.mdx @@ -40,6 +40,9 @@ This document describes the payload of a Run's completion webhook. When the Run started + + Whether the Run was a test Run + The duration of the Run in milliseconds diff --git a/packages/core/src/schemas/runs.ts b/packages/core/src/schemas/runs.ts index 6b33c0e75..e62c1331b 100644 --- a/packages/core/src/schemas/runs.ts +++ b/packages/core/src/schemas/runs.ts @@ -134,6 +134,8 @@ export type RunNotificationRunMetadata = { updatedAt: Date; /** When the run was completed */ completedAt: Date; + /** If the run was a test or not */ + isTest: boolean; executionDurationInMs: number; executionCount: number; @@ -150,6 +152,8 @@ type RunNotificationCommon = { updatedAt: Date; /** When the run was completed */ completedAt: Date; + /** If the run was a test or not */ + isTest: boolean; executionDurationInMs: number; executionCount: number; diff --git a/references/job-catalog/src/supabase.ts b/references/job-catalog/src/supabase.ts index b640a142c..cad18e622 100644 --- a/references/job-catalog/src/supabase.ts +++ b/references/job-catalog/src/supabase.ts @@ -30,6 +30,14 @@ export const client = new TriggerClient({ ioLogLocalEnabled: true, }); +client.on("runSucceeeded", async (notification) => { + console.log("[client] Run succeeded", notification); +}); + +client.on("runFailed", async (notification) => { + console.log("[client] Run failed", notification); +}); + createExpressServer(client); client.defineJob({