feat: skip error change notification option
parent
a1fa753450
commit
e87e350d6d
|
|
@ -58,6 +58,7 @@ export type Notification = {
|
|||
timeZone?: string
|
||||
gracePeriod?: number
|
||||
skipNotificationIds?: string[]
|
||||
skipErrorChangeNotification?: boolean
|
||||
}
|
||||
|
||||
type SingleWebhook = {
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ const workerConfig: WorkerConfig = {
|
|||
gracePeriod: 5,
|
||||
// [Optional] disable notification for monitors with specified ids
|
||||
skipNotificationIds: ['foo_monitor', 'bar_monitor'],
|
||||
// [Optional] suppress extra notifications for error reason changes during an incident, default to false
|
||||
skipErrorChangeNotification: true,
|
||||
},
|
||||
callbacks: {
|
||||
onStatusChange: async (
|
||||
|
|
|
|||
|
|
@ -225,17 +225,21 @@ const Worker = {
|
|||
currentTimeSecond - currentIncident.start[0] <
|
||||
workerConfig.notification.gracePeriod * 60 + 30)
|
||||
) {
|
||||
await formatAndNotify(
|
||||
monitor,
|
||||
false,
|
||||
currentIncident.start[0],
|
||||
currentTimeSecond,
|
||||
status.err
|
||||
)
|
||||
if (currentIncident.start[0] !== currentTimeSecond && workerConfig.notification?.skipErrorChangeNotification) {
|
||||
console.log('Skipping notification for following error reason change due to user config')
|
||||
} else {
|
||||
await formatAndNotify(
|
||||
monitor,
|
||||
false,
|
||||
currentIncident.start[0],
|
||||
currentTimeSecond,
|
||||
status.err
|
||||
)
|
||||
}
|
||||
} else {
|
||||
console.log(
|
||||
`Grace period (${workerConfig.notification
|
||||
?.gracePeriod}m) not met (currently down for ${
|
||||
?.gracePeriod}m) not met or no change (currently down for ${
|
||||
currentTimeSecond - currentIncident.start[0]
|
||||
}s, changed ${monitorStatusChanged}), skipping webhook DOWN notification for ${
|
||||
monitor.name
|
||||
|
|
|
|||
Loading…
Reference in New Issue