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