@@ -232,6 +232,8 @@ export async function deliverAlertEvent(
232232 }
233233
234234 const { claimId } = claim ;
235+ let channelType : ChannelInfo [ "type" ] | undefined ;
236+ let channelId : string | undefined ;
235237
236238 try {
237239 if ( delivery . notifier . type === "chat" ) {
@@ -259,6 +261,9 @@ export async function deliverAlertEvent(
259261 continue ;
260262 }
261263
264+ channelType = channel . type ;
265+ channelId = channel . id ;
266+
262267 if ( ! channel . enabled ) {
263268 await markDeliveryFailed ( db , {
264269 id : delivery . id ,
@@ -272,6 +277,14 @@ export async function deliverAlertEvent(
272277 const rateLimitResult = await checkRateLimit ( channel . id ) ;
273278 if ( rateLimitResult && ! rateLimitResult . allowed ) {
274279 await releaseDelivery ( db , { id : delivery . id , eventAt, claimId, refundAttempt : true } ) ;
280+ logger . warn ( "[deliverAlertEvent] Delivery rate limited" , {
281+ deliveryId : delivery . id ,
282+ eventId,
283+ alertId : alert . id ,
284+ channelType,
285+ channelId,
286+ attempts : claim . delivery . attempts ,
287+ } ) ;
275288 retryableErrors . push ( new Error ( "rate_limited" ) ) ;
276289 continue ;
277290 }
@@ -326,6 +339,15 @@ export async function deliverAlertEvent(
326339 }
327340
328341 await releaseDelivery ( db , { id : delivery . id , eventAt, claimId } ) ;
342+ logger . warn ( "[deliverAlertEvent] Delivery failed, will retry" , {
343+ deliveryId : delivery . id ,
344+ eventId,
345+ alertId : alert . id ,
346+ channelType,
347+ channelId,
348+ attempts : claim . delivery . attempts ,
349+ error,
350+ } ) ;
329351 retryableErrors . push ( error ) ;
330352 }
331353 }
0 commit comments