Skip to content

Open-source status page, incident response and uptime monitoring

chore: notification messages (#998)

Maximilian Kaskea49ddf89e62c
diff --git a/apps/server/src/checker/alerting.ts b/apps/server/src/checker/alerting.ts
index d2c937fb1..16cafd13f 100644
--- a/apps/server/src/checker/alerting.ts
+++ b/apps/server/src/checker/alerting.ts
@@ -17,12 +17,14 @@ export const triggerNotifications = async ({
statusCode,
message,
notifType,
+ cronTimestamp,
incidentId,
}: {
monitorId: string;
statusCode?: number;
message?: string;
notifType: "alert" | "recovery" | "degraded";
+ cronTimestamp: number;
incidentId?: string;
}) => {
console.log(`πŸ’Œ triggerAlerting for ${monitorId}`);
@@ -61,6 +63,7 @@ export const triggerNotifications = async ({
statusCode,
message,
incidentId,
+ cronTimestamp,
});
break;
case "recovery":
@@ -70,6 +73,7 @@ export const triggerNotifications = async ({
statusCode,
message,
incidentId,
+ cronTimestamp,
});
break;
case "degraded":
@@ -78,6 +82,7 @@ export const triggerNotifications = async ({
notification: selectNotificationSchema.parse(notif.notification),
statusCode,
message,
+ cronTimestamp,
});
break;
}
diff --git a/apps/server/src/checker/index.ts b/apps/server/src/checker/index.ts
index 7788c3e65..06dc15bac 100644
--- a/apps/server/src/checker/index.ts
+++ b/apps/server/src/checker/index.ts
@@ -101,6 +101,7 @@ checkerRoute.post("/updateStatus", async (c) => {
statusCode,
message,
notifType: "degraded",
+ cronTimestamp,
});
}
}
@@ -176,6 +177,7 @@ checkerRoute.post("/updateStatus", async (c) => {
statusCode,
message,
notifType: "alert",
+ cronTimestamp,
});
if (newIncident.length > 0) {
@@ -265,6 +267,7 @@ checkerRoute.post("/updateStatus", async (c) => {
statusCode,
message,
notifType: "recovery",
+ cronTimestamp,
});
const monitor = await db
diff --git a/apps/server/src/checker/utils.ts b/apps/server/src/checker/utils.ts
index b36b3b8ca..ed0f7f1ee 100644
--- a/apps/server/src/checker/utils.ts
+++ b/apps/server/src/checker/utils.ts
@@ -36,12 +36,14 @@ type SendNotification = ({
statusCode,
message,
incidentId,
+ cronTimestamp,
}: {
monitor: Monitor;
notification: Notification;
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => Promise<void>;
type Notif = {
@@ -49,6 +51,7 @@ type Notif = {
sendRecovery: SendNotification;
sendDegraded: SendNotification;
};
+
export const providerToFunction = {
email: {
sendAlert: sendEmailAlert,
diff --git a/packages/db/src/schema/notifications/validation.ts b/packages/db/src/schema/notifications/validation.ts
index 21444b57a..f050cbe3a 100644
--- a/packages/db/src/schema/notifications/validation.ts
+++ b/packages/db/src/schema/notifications/validation.ts
@@ -36,12 +36,16 @@ export const phoneSchema = z.string().regex(phoneRegex, "Invalid Number!");
export const emailSchema = z.string().email();
export const urlSchema = z.string().url();
+export const emailDataSchema = z.object({ email: emailSchema });
+export const phoneDataSchema = z.object({ sms: phoneSchema });
+export const slackDataSchema = z.object({ slack: urlSchema });
+export const discordDataSchema = z.object({ discord: urlSchema });
+export const pagerdutyDataSchema = z.object({ pagerduty: z.string() });
+
export const NotificationDataSchema = z.union([
- z.object({ sms: phoneSchema }),
- z.object({ email: emailSchema }),
- z.object({ slack: urlSchema }),
- z.object({ discord: urlSchema }),
- z.object({
- pagerduty: z.string(),
- }),
+ emailDataSchema,
+ phoneDataSchema,
+ slackDataSchema,
+ discordDataSchema,
+ pagerdutyDataSchema,
]);
diff --git a/packages/notifications/discord/src/index.ts b/packages/notifications/discord/src/index.ts
index 6ff42d96a..0f1fa9a3c 100644
--- a/packages/notifications/discord/src/index.ts
+++ b/packages/notifications/discord/src/index.ts
@@ -20,12 +20,14 @@ export const sendAlert = async ({
notification,
statusCode,
message,
+ cronTimestamp,
}: {
monitor: Monitor;
notification: Notification;
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = JSON.parse(notification.data);
const { discord: webhookUrl } = notificationData; // webhook url
@@ -33,11 +35,7 @@ export const sendAlert = async ({
try {
await postToWebhook(
- `Your monitor ${name} is down 🚨
-
- Your monitor with url ${monitor.url} is down with ${
- statusCode ? `status code ${statusCode}` : `error message ${message}`
- }.`,
+ `**🚨 Alert [${name}](<${monitor.url}>)**\nStatus Code: ${statusCode || "_empty_"}\nMessage: ${message || "_empty_"}\nCron Timestamp: ${cronTimestamp} (${new Date(cronTimestamp).toISOString()})\n> Check your [Dashboard](<https://www.openstatus.dev/app/>).\n`,
webhookUrl,
);
} catch (err) {
@@ -61,6 +59,7 @@ export const sendRecovery = async ({
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = JSON.parse(notification.data);
const { discord: webhookUrl } = notificationData; // webhook url
@@ -68,7 +67,7 @@ export const sendRecovery = async ({
try {
await postToWebhook(
- `Your monitor ${name}|${monitor.url} is up again πŸŽ‰`,
+ `**βœ… Recovered [${name}](<${monitor.url}>)**\n> Check your [Dashboard](<https://www.openstatus.dev/app/>).\n`,
webhookUrl,
);
} catch (err) {
@@ -92,6 +91,7 @@ export const sendDegraded = async ({
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = JSON.parse(notification.data);
const { discord: webhookUrl } = notificationData; // webhook url
@@ -99,7 +99,7 @@ export const sendDegraded = async ({
try {
await postToWebhook(
- `Your monitor ${name}|${monitor.url} is degraded ⚠️`,
+ `**⚠️ Degraded [${name}](<${monitor.url}>)**\n> Check your [Dashboard](<https://www.openstatus.dev/app/>).\n`,
webhookUrl,
);
} catch (err) {
@@ -114,7 +114,7 @@ export const sendTestDiscordMessage = async (webhookUrl: string) => {
}
try {
await postToWebhook(
- "This is a test notification from OpenStatus. \nIf you see this, it means that your webhook is working! πŸŽ‰",
+ "**πŸ§ͺ Test [OpenStatus](<https://www.openstatus.dev/>)**\nIf you can read this, your Slack webhook is functioning correctly!\n> Check your [Dashboard](<https://www.openstatus.dev/app/>).\n",
webhookUrl,
);
return true;
diff --git a/packages/notifications/discord/src/mock.ts b/packages/notifications/discord/src/mock.ts
new file mode 100644
index 000000000..63701fce6
--- /dev/null
+++ b/packages/notifications/discord/src/mock.ts
@@ -0,0 +1,65 @@
+import type { Monitor, Notification } from "@openstatus/db/src/schema";
+import {
+ sendAlert,
+ sendDegraded,
+ sendRecovery,
+ sendTestDiscordMessage,
+} from "./index";
+
+const monitor: Monitor = {
+ id: 1,
+ name: "OpenStatus Docs",
+ url: "https://docs.openstatus.dev",
+ periodicity: "10m",
+ jobType: "website",
+ active: true,
+ public: true,
+ createdAt: null,
+ updatedAt: null,
+ regions: ["ams", "fra"],
+ description: "Monitor Description",
+ headers: [],
+ body: "",
+ workspaceId: 1,
+ timeout: 45000,
+ degradedAfter: null,
+ assertions: null,
+ status: "active",
+ method: "GET",
+ deletedAt: null,
+};
+
+const notification: Notification = {
+ id: 1,
+ name: "Discord",
+ data: `{ "discord": "${process.env.DISCORD_WEBHOOK}" }`,
+ createdAt: null,
+ updatedAt: null,
+ workspaceId: 1,
+ provider: "discord",
+};
+
+const cronTimestamp = Date.now();
+
+if (process.env.NODE_ENV === "development") {
+ await sendDegraded({
+ monitor,
+ notification,
+ cronTimestamp,
+ });
+
+ await sendAlert({
+ monitor,
+ notification,
+ statusCode: 500,
+ cronTimestamp,
+ });
+
+ await sendRecovery({
+ monitor,
+ notification,
+ cronTimestamp,
+ });
+
+ await sendTestDiscordMessage(process.env.DISCORD_WEBHOOK);
+}
diff --git a/packages/notifications/email/src/index.ts b/packages/notifications/email/src/index.ts
index 14a65e560..bb31334af 100644
--- a/packages/notifications/email/src/index.ts
+++ b/packages/notifications/email/src/index.ts
@@ -1,26 +1,24 @@
-import type { Monitor, Notification } from "@openstatus/db/src/schema";
+import {
+ type Monitor,
+ type Notification,
+ emailDataSchema,
+} from "@openstatus/db/src/schema";
import { env } from "../env";
-import { EmailConfigurationSchema } from "./schema/config";
-export const sendAlert = async ({
- monitor,
- notification,
- statusCode,
- message,
- // biome-ignore lint/correctness/noUnusedVariables: <explanation>
- incidentId,
+async function send({
+ subject,
+ html,
+ email,
+ id,
+ type,
}: {
- monitor: Monitor;
- notification: Notification;
- statusCode?: number;
- message?: string;
- incidentId?: string;
-}) => {
- // FIXME:
- const config = EmailConfigurationSchema.parse(JSON.parse(notification.data));
- const { email } = config;
-
+ subject: string;
+ html: string;
+ email: string;
+ id: number;
+ type: "recovered" | "alert" | "degraded";
+}) {
const res = await fetch("https://api.resend.com/emails", {
method: "POST",
headers: {
@@ -30,15 +28,8 @@ export const sendAlert = async ({
body: JSON.stringify({
to: email,
from: "Notifications <[email protected]>",
-
- subject: `Your monitor ${monitor.name} is down 🚨`,
- html: `<p>Hi,<br><br>Your monitor ${monitor.name} is down. </p><p>URL : ${
- monitor.url
- }</p> ${
- statusCode
- ? `<p>Status Code: ${statusCode}</p>`
- : `<p>Error message: ${message}</p>`
- }<p>OpenStatus πŸ“ </p>`,
+ subject,
+ html,
}),
});
@@ -48,93 +39,100 @@ export const sendAlert = async ({
// return NextResponse.json(data);
}
if (!res.ok) {
- console.log(`Error sending recovery email ${monitor.id}`);
+ console.log(`Error sending ${type} email ${id}`);
}
-};
+}
-export const sendRecovery = async ({
+export const sendAlert = async ({
monitor,
notification,
- // biome-ignore lint/correctness/noUnusedVariables: <explanation>
statusCode,
- // biome-ignore lint/correctness/noUnusedVariables: <explanation>
message,
- // biome-ignore lint/correctness/noUnusedVariables: <explanation>
- incidentId,
+ cronTimestamp,
}: {
monitor: Monitor;
notification: Notification;
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
- // FIXME:
- const config = EmailConfigurationSchema.parse(JSON.parse(notification.data));
- const { email } = config;
+ const config = emailDataSchema.safeParse(JSON.parse(notification.data));
- const res = await fetch("https://api.resend.com/emails", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${env.RESEND_API_KEY}`,
- },
- body: JSON.stringify({
- to: email,
- from: "Notifications <[email protected]>",
+ if (!config.success) return;
- subject: `Your monitor ${monitor.name} is back up πŸŽ‰`,
- html: `<p>Hi,<br><br>Your monitor ${monitor.name} is up again </p><p>URL : ${monitor.url}</p> <p>OpenStatus πŸ“ </p>`,
- }),
+ await send({
+ id: monitor.id,
+ type: "alert",
+ email: config.data.email,
+ subject: `🚨 Alert ${monitor.name}`,
+ html: `
+ <p>Hi,</p>
+ <p>Your monitor <strong>${monitor.name}</strong> is down.</p>
+ <p>URL: ${monitor.url}</p>
+ ${
+ statusCode
+ ? `<p>Status Code: ${statusCode}</p>`
+ : `<p>Error message: ${message}</p>`
+ }
+ <p>Cron Timestamp: ${cronTimestamp} (${new Date(cronTimestamp).toISOString()})</p>
+ <p>OpenStatus πŸ“</p>`,
});
+};
- if (res.ok) {
- const data = await res.json();
- console.log(data);
- // return NextResponse.json(data);
- }
- if (!res.ok) {
- console.log(`Error sending recovery email ${monitor.id}`);
- }
+export const sendRecovery = async ({
+ monitor,
+ notification,
+}: {
+ monitor: Monitor;
+ notification: Notification;
+ statusCode?: number;
+ message?: string;
+ incidentId?: string;
+ cronTimestamp: number;
+}) => {
+ const config = emailDataSchema.safeParse(JSON.parse(notification.data));
+
+ if (!config.success) return;
+
+ send({
+ id: monitor.id,
+ type: "recovered",
+ email: config.data.email,
+ subject: `βœ… Recovered ${monitor.name}`,
+ html: `
+ <p>Hi,</p>
+ <p>Your monitor <strong>${monitor.name}</strong> is up again.</p>
+ <p>URL: ${monitor.url}</p>
+ <p>OpenStatus πŸ“</p>
+ `,
+ });
};
export const sendDegraded = async ({
monitor,
notification,
- // biome-ignore lint/correctness/noUnusedVariables: <explanation>
- statusCode,
- // biome-ignore lint/correctness/noUnusedVariables: <explanation>
- message,
}: {
monitor: Monitor;
notification: Notification;
statusCode?: number;
message?: string;
+ cronTimestamp: number;
}) => {
- // FIXME:
- const config = EmailConfigurationSchema.parse(JSON.parse(notification.data));
- const { email } = config;
+ const config = emailDataSchema.safeParse(JSON.parse(notification.data));
- const res = await fetch("https://api.resend.com/emails", {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${env.RESEND_API_KEY}`,
- },
- body: JSON.stringify({
- to: email,
- from: "Notifications <[email protected]>",
+ if (!config.success) return;
- subject: `Your monitor ${monitor.name} is degraded ⚠️`,
- html: `<p>Hi,<br><br>Your monitor ${monitor.name} is taking longer than expected to respond</p><p>URL : ${monitor.url}</p> <p>OpenStatus πŸ“ </p>`,
- }),
+ send({
+ id: monitor.id,
+ type: "degraded",
+ email: config.data.email,
+ subject: `⚠️ Degraded ${monitor.name}`,
+ html: `
+ <p>Hi,</p>
+ <p>Your monitor <strong>${monitor.name}</strong> is taking longer than expected to respond</p>
+ <p>URL: ${monitor.url}</p>
+ <p>OpenStatus πŸ“</p>
+ `,
});
-
- if (res.ok) {
- const data = await res.json();
- console.log(data);
- // return NextResponse.json(data);
- }
- if (!res.ok) {
- console.log(`Error sending recovery email ${monitor.id}`);
- }
};
diff --git a/packages/notifications/email/src/mock.ts b/packages/notifications/email/src/mock.ts
new file mode 100644
index 000000000..c05c2648e
--- /dev/null
+++ b/packages/notifications/email/src/mock.ts
@@ -0,0 +1,58 @@
+import type { Monitor, Notification } from "@openstatus/db/src/schema";
+import { sendAlert, sendDegraded, sendRecovery } from "./index";
+
+const monitor: Monitor = {
+ id: 1,
+ name: "OpenStatus Docs",
+ url: "https://docs.openstatus.dev",
+ periodicity: "10m",
+ jobType: "website",
+ active: true,
+ public: true,
+ createdAt: null,
+ updatedAt: null,
+ regions: ["ams", "fra"],
+ description: "Monitor Description",
+ headers: [],
+ body: "",
+ workspaceId: 1,
+ timeout: 45000,
+ degradedAfter: null,
+ assertions: null,
+ status: "active",
+ method: "GET",
+ deletedAt: null,
+};
+
+const notification: Notification = {
+ id: 1,
+ name: "Email",
+ data: '{ "email": "[email protected]" }',
+ createdAt: null,
+ updatedAt: null,
+ workspaceId: 1,
+ provider: "email",
+};
+
+const cronTimestamp = Date.now();
+
+if (process.env.NODE_ENV === "development") {
+ sendDegraded({
+ monitor,
+ notification,
+ cronTimestamp,
+ });
+
+ sendAlert({
+ monitor,
+ notification,
+ statusCode: 500,
+ cronTimestamp,
+ });
+
+ sendRecovery({
+ monitor,
+ notification,
+ cronTimestamp,
+ });
+}
diff --git a/packages/notifications/email/src/schema/config.ts b/packages/notifications/email/src/schema/config.ts
deleted file mode 100644
index 07914f852..000000000
--- a/packages/notifications/email/src/schema/config.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { z } from "zod";
-
-export const EmailConfigurationSchema = z.object({
- email: z.string().email(),
-});
diff --git a/packages/notifications/pagerduty/src/index.ts b/packages/notifications/pagerduty/src/index.ts
index 8682768a0..ff023f4a3 100644
--- a/packages/notifications/pagerduty/src/index.ts
+++ b/packages/notifications/pagerduty/src/index.ts
@@ -12,12 +12,14 @@ export const sendAlert = async ({
statusCode,
message,
incidentId,
+ cronTimestamp,
}: {
monitor: Monitor;
notification: Notification;
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = PagerDutySchema.parse(JSON.parse(notification.data));
const { name } = monitor;
@@ -30,7 +32,7 @@ export const sendAlert = async ({
summary: `${name} is down`,
source: "Open Status",
severity: "error",
- timestamp: new Date().toISOString(),
+ timestamp: new Date(cronTimestamp).toISOString(),
custom_details: {
statusCode,
message,
@@ -65,6 +67,7 @@ export const sendDegraded = async ({
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = PagerDutySchema.parse(JSON.parse(notification.data));
const { name } = monitor;
@@ -115,6 +118,7 @@ export const sendRecovery = async ({
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = PagerDutySchema.parse(JSON.parse(notification.data));
diff --git a/packages/notifications/slack/src/index.ts b/packages/notifications/slack/src/index.ts
index a591234ea..ee82ae76f 100644
--- a/packages/notifications/slack/src/index.ts
+++ b/packages/notifications/slack/src/index.ts
@@ -20,12 +20,14 @@ export const sendAlert = async ({
message,
// biome-ignore lint/correctness/noUnusedVariables: <explanation>
incidentId,
+ cronTimestamp,
}: {
monitor: Monitor;
notification: Notification;
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = JSON.parse(notification.data);
const { slack: webhookUrl } = notificationData; // webhook url
@@ -35,26 +37,29 @@ export const sendAlert = async ({
await postToWebhook(
{
blocks: [
+ {
+ type: "divider",
+ },
{
type: "section",
text: {
type: "mrkdwn",
- text: `Your monitor <${monitor.url}/|${name}> with ${
- statusCode
- ? `status code ${statusCode}`
- : `error message ${message}`
- } 🚨 \n\n Powered by <https://www.openstatus.dev/|OpenStatus>.`,
+ text: `
+*🚨 Alert <${monitor.url}/|${name}>*\n\n
+Status Code: ${statusCode || "_empty_"}\n
+Message: ${message || "_empty_"}\n
+Cron Timestamp: ${cronTimestamp} (${new Date(cronTimestamp).toISOString()})
+`,
},
- accessory: {
- type: "button",
- text: {
- type: "plain_text",
- text: "Open Monitor",
- emoji: true,
+ },
+ {
+ type: "context",
+ elements: [
+ {
+ type: "mrkdwn",
+ text: "Check your <https://www.openstatus.dev/app|Dashboard>.",
},
- value: `monitor_url_${monitor.url}`,
- url: monitor.url,
- },
+ ],
},
],
},
@@ -81,6 +86,7 @@ export const sendRecovery = async ({
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = JSON.parse(notification.data);
const { slack: webhookUrl } = notificationData; // webhook url
@@ -90,23 +96,24 @@ export const sendRecovery = async ({
await postToWebhook(
{
blocks: [
+ {
+ type: "divider",
+ },
{
type: "section",
text: {
type: "mrkdwn",
- text: `Your monitor <${monitor.url}/|${name}> is up again
- πŸš€ \n\n Powered by <https://www.openstatus.dev/|OpenStatus>.`,
+ text: `*βœ… Recovered <${monitor.url}/|${name}>*`,
},
- accessory: {
- type: "button",
- text: {
- type: "plain_text",
- text: "Open Monitor",
- emoji: true,
+ },
+ {
+ type: "context",
+ elements: [
+ {
+ type: "mrkdwn",
+ text: "Check your <https://www.openstatus.dev/app|Dashboard>.",
},
- value: `monitor_url_${monitor.url}`,
- url: monitor.url,
- },
+ ],
},
],
},
@@ -130,6 +137,7 @@ export const sendDegraded = async ({
notification: Notification;
statusCode?: number;
message?: string;
+ cronTimestamp: number;
}) => {
const notificationData = JSON.parse(notification.data);
const { slack: webhookUrl } = notificationData; // webhook url
@@ -139,23 +147,24 @@ export const sendDegraded = async ({
await postToWebhook(
{
blocks: [
+ {
+ type: "divider",
+ },
{
type: "section",
text: {
type: "mrkdwn",
- text: `Your monitor <${monitor.url}/|${name}> is degraded
- ⚠️ \n\n Powered by <https://www.openstatus.dev/|OpenStatus>.`,
+ text: `*⚠️ Degraded <${monitor.url}/|${name}>*`,
},
- accessory: {
- type: "button",
- text: {
- type: "plain_text",
- text: "Open Monitor",
- emoji: true,
+ },
+ {
+ type: "context",
+ elements: [
+ {
+ type: "mrkdwn",
+ text: "Check your <https://www.openstatus.dev/app|Dashboard>.",
},
- value: `monitor_url_${monitor.url}`,
- url: monitor.url,
- },
+ ],
},
],
},
@@ -172,13 +181,25 @@ export const sendTestSlackMessage = async (webhookUrl: string) => {
await postToWebhook(
{
blocks: [
+ {
+ type: "divider",
+ },
{
type: "section",
text: {
type: "mrkdwn",
- text: "This is a test notification from <https://www.openstatus.dev/|OpenStatus>.\n If you can read this, your Slack webhook is functioning correctly!",
+ text: "*πŸ§ͺ Test <https://www.openstatus.dev/|OpenStatus>*\n\nIf you can read this, your Slack webhook is functioning correctly!",
},
},
+ {
+ type: "context",
+ elements: [
+ {
+ type: "mrkdwn",
+ text: "Check your <https://www.openstatus.dev/app|Dashboard>.",
+ },
+ ],
+ },
],
},
webhookUrl,
diff --git a/packages/notifications/slack/src/mock.ts b/packages/notifications/slack/src/mock.ts
new file mode 100644
index 000000000..5c50f74c9
--- /dev/null
+++ b/packages/notifications/slack/src/mock.ts
@@ -0,0 +1,65 @@
+import type { Monitor, Notification } from "@openstatus/db/src/schema";
+import {
+ sendAlert,
+ sendDegraded,
+ sendRecovery,
+ sendTestSlackMessage,
+} from "./index";
+
+const monitor: Monitor = {
+ id: 1,
+ name: "OpenStatus Docs",
+ url: "https://docs.openstatus.dev",
+ periodicity: "10m",
+ jobType: "website",
+ active: true,
+ public: true,
+ createdAt: null,
+ updatedAt: null,
+ regions: ["ams", "fra"],
+ description: "Monitor Description",
+ headers: [],
+ body: "",
+ workspaceId: 1,
+ timeout: 45000,
+ degradedAfter: null,
+ assertions: null,
+ status: "active",
+ method: "GET",
+ deletedAt: null,
+};
+
+const notification: Notification = {
+ id: 1,
+ name: "Slack",
+ data: `{ "slack": "${process.env.SLACK_WEBHOOK}" }`,
+ createdAt: null,
+ updatedAt: null,
+ workspaceId: 1,
+ provider: "slack",
+};
+
+const cronTimestamp = Date.now();
+
+if (process.env.NODE_ENV === "development") {
+ await sendDegraded({
+ monitor,
+ notification,
+ cronTimestamp,
+ });
+
+ await sendAlert({
+ monitor,
+ notification,
+ statusCode: 500,
+ cronTimestamp,
+ });
+
+ await sendRecovery({
+ monitor,
+ notification,
+ cronTimestamp,
+ });
+
+ await sendTestSlackMessage(process.env.SLACK_WEBHOOK);
+}
diff --git a/packages/notifications/twillio-sms/src/index.ts b/packages/notifications/twillio-sms/src/index.ts
index 14867205d..0b845a18c 100644
--- a/packages/notifications/twillio-sms/src/index.ts
+++ b/packages/notifications/twillio-sms/src/index.ts
@@ -16,6 +16,7 @@ export const sendAlert = async ({
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = SmsConfigurationSchema.parse(
JSON.parse(notification.data),
@@ -66,6 +67,7 @@ export const sendRecovery = async ({
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = SmsConfigurationSchema.parse(
JSON.parse(notification.data),
@@ -109,6 +111,7 @@ export const sendDegraded = async ({
statusCode?: number;
message?: string;
incidentId?: string;
+ cronTimestamp: number;
}) => {
const notificationData = SmsConfigurationSchema.parse(
JSON.parse(notification.data),