fix(integrations): skip the ledger page when the watchdog announced it

A failure streak reaching the alert threshold paged the operator even
when the watchdog had already announced an open incident for the same
connection. The ledger now checks for that announced incident first,
stamps the streak as announced and sends nothing; the watchdog's
recovery note still ends it.
This commit is contained in:
Marc-André Bombeck committed 2026-10-15 16:38:12 +02:00
1 parent 3e95755c3b
commit 0e5afe76a4
3 files changed
+103 -1

No files matched your search

+27 -1
View File
@@ -798,7 +798,33 @@ export async function recordSyncFailure(
const alertSignal = Math.max(...Object.values(buckets));
if (alertSignal >= threshold) {
const previouslyAlerted = row.alertedAt != null;
if (!previouslyAlerted) {
// The watchdog may have announced this connection already (it pages a
// day-long provider error streak, a reauth or a silence on its own). Its
// open incident covers this streak too, and its recovery note ends it;
// a second page about the same trouble would only repeat it.
const watchdogAnnounced =
!previouslyAlerted &&
!!(await prisma.integrationWatch.findFirst({
where: {
userId,
integration,
incidentReason: { not: null },
alertedAt: { not: null },
},
select: { id: true },
}));
if (watchdogAnnounced) {
await prisma.integrationStatus.update({
where: { userId_integration: { userId, integration } },
data: { alertedAt: now },
});
annotate({
action: {
name: "integrations.alert.covered_by_watchdog",
details: { integration },
},
});
} else if (!previouslyAlerted) {
const outcome = await maybeAlertAdmins({
userId,
integration,