diff --git a/src/server/queueListener.ts b/src/server/queueListener.ts index 077b0cd6..47d2b22e 100644 --- a/src/server/queueListener.ts +++ b/src/server/queueListener.ts @@ -9,6 +9,15 @@ export async function initializeQueueListener(): Promise { { correlationId: data.correlationId }, async () => { try { + logger.info( + "Processing job", + { + meta: { + data, + id + } + } + ); await webhookEventService.processJob(data); logger.info( "Job processed", diff --git a/src/server/router/webhookEventRouter/webhookEventRouter.ts b/src/server/router/webhookEventRouter/webhookEventRouter.ts index a993d936..59637b15 100644 --- a/src/server/router/webhookEventRouter/webhookEventRouter.ts +++ b/src/server/router/webhookEventRouter/webhookEventRouter.ts @@ -1,12 +1,14 @@ import { Router as createRouter } from "express"; import { JSONBodyParser } from "../../middlewares"; import { webhookEventService } from "../../services"; +import { logger } from "../../adapters"; const webhookEventRouter = createRouter({ mergeParams: true }); webhookEventRouter.post("/", JSONBodyParser, async (req, res, next) => { try { + logger.info("webhookEvent post request received."); const webhookId = req.headers["zeplin-webhook-id"] as string; const deliveryId = req.headers["zeplin-delivery-id"] as string; const signature = req.headers["zeplin-signature"] as string; @@ -20,6 +22,7 @@ webhookEventRouter.post("/", deliveryTimestamp, payload: req.body }); + logger.info("webhookEvent post request handled."); res.send(); } catch (error) { next(error); diff --git a/src/server/services/webhookEventService/webhookEventService.ts b/src/server/services/webhookEventService/webhookEventService.ts index 42b19ac3..dea45db7 100644 --- a/src/server/services/webhookEventService/webhookEventService.ts +++ b/src/server/services/webhookEventService/webhookEventService.ts @@ -1,7 +1,7 @@ import { GONE, UNAUTHORIZED } from "http-status-codes"; import { WebhookEvent } from "@zeplin/sdk"; -import { messageQueue, requester, Zeplin } from "../../adapters"; +import { logger, messageQueue, requester, Zeplin } from "../../adapters"; import { configurationRepo, messageJobRepo, webhookEventRepo } from "../../repos"; import { getNotificationHandler } from "./notificationHandlers"; import { ServerError } from "../../errors"; @@ -62,7 +62,9 @@ class WebhookEventService { const message = notificationHandler.getTeamsMessage(distinctEvents); try { + logger.info("Sending message to teams"); await requester.post(configuration.microsoftTeams.incomingWebhookUrl, message); + logger.info("Message sent to teams"); } catch (error) { if (error instanceof ServerError && error.statusCode === GONE) { await configurationRepo.delete(configuration._id.toHexString()); @@ -125,7 +127,25 @@ class WebhookEventService { } await messageJobRepo.setGroupActiveJobId(groupingKey, deliveryId); + logger.info( + "Active job set", + { + meta: { + groupingKey, + deliveryId + } + } + ); await webhookEventRepo.addEventToGroup(groupingKey, event); + logger.info( + "Event added to group", + { + meta: { + groupingKey, + deliveryId + } + } + ); await messageQueue.add( { @@ -136,6 +156,15 @@ class WebhookEventService { }, { delay: notificationHandler.delay } ); + logger.info( + "Message added to queue", + { + meta: { + groupingKey, + deliveryId + } + } + ); } }