feat: Add support for incident episode notification rule type and update default title generation to use 'Untitled Episode'

This commit is contained in:
Nawaz Dhandala
2026-02-01 15:28:38 +00:00
parent 9751dd0d5f
commit 8e1b6859f5
3 changed files with 19 additions and 6 deletions

View File

@@ -376,6 +376,13 @@ export class Service extends DatabaseService<Model> {
return NotificationRuleType.ON_CALL_EXECUTED_ALERT_EPISODE;
}
if (
userNotificationEventType ===
UserNotificationEventType.IncidentEpisodeCreated
) {
return NotificationRuleType.ON_CALL_EXECUTED_INCIDENT_EPISODE;
}
// Invalid user notification event type.
throw new BadDataException("Invalid user notification event type.");
}

View File

@@ -461,8 +461,9 @@ describe("Template Variable Replacement Logic", () => {
describe("Default Title Generation", () => {
test("should use monitor name when no template provided", () => {
const defaultTitle: string = `Alert Episode: ${mockAlert.monitor?.name || mockAlert.title || "Alert Episode"}`;
expect(defaultTitle).toBe("Alert Episode: API Server");
const defaultTitle: string =
mockAlert.monitor?.name || mockAlert.title || "Untitled Episode";
expect(defaultTitle).toBe("API Server");
});
test("should use alert title when no monitor", () => {
@@ -473,8 +474,11 @@ describe("Template Variable Replacement Logic", () => {
alertNoMonitor.title = "High CPU Usage";
// monitor is intentionally not set
const defaultTitle: string = `Alert Episode: ${alertNoMonitor.monitor?.name || alertNoMonitor.title || "Alert Episode"}`;
expect(defaultTitle).toBe("Alert Episode: High CPU Usage");
const defaultTitle: string =
alertNoMonitor.monitor?.name ||
alertNoMonitor.title ||
"Untitled Episode";
expect(defaultTitle).toBe("High CPU Usage");
});
test("should use generic title when no monitor and no alert title", () => {
@@ -484,8 +488,9 @@ describe("Template Variable Replacement Logic", () => {
alertMinimal.id = alertId;
// monitor and title are intentionally not set
const defaultTitle: string = `Alert Episode: ${alertMinimal.monitor?.name || alertMinimal.title || "Alert Episode"}`;
expect(defaultTitle).toBe("Alert Episode: Alert Episode");
const defaultTitle: string =
alertMinimal.monitor?.name || alertMinimal.title || "Untitled Episode";
expect(defaultTitle).toBe("Untitled Episode");
});
});
});

View File

@@ -2,6 +2,7 @@ enum NotificationRuleType {
ON_CALL_EXECUTED_INCIDENT = "When incident on-call policy is executed",
ON_CALL_EXECUTED_ALERT = "When alert on-call policy is executed",
ON_CALL_EXECUTED_ALERT_EPISODE = "When alert episode on-call policy is executed",
ON_CALL_EXECUTED_INCIDENT_EPISODE = "When incident episode on-call policy is executed",
WHEN_USER_GOES_ON_CALL = "When user goes on call",
WHEN_USER_GOES_OFF_CALL = "When user goes off call",
}