debug logs added

This commit is contained in:
Syed Ali Shahbaz
2022-06-12 11:43:26 +05:30
parent 4cac1328d1
commit ecce02ebbf
2 changed files with 6 additions and 0 deletions
+1
View File
@@ -18,6 +18,7 @@ function jsonParse(jsonString: string) {
return JSON.parse(jsonString);
} catch (e) {
// don't do anything.
console.error(`error jsonParsing in sendPayload`);
}
return false;
}
+5
View File
@@ -94,6 +94,7 @@ async function createOrlistAllBookings(
.catch((e: Error) => {
console.error(`Event type with ID: ${booking.eventTypeId} not found`, e);
});
console.log(`eventType: ${eventType}`);
const evt = {
type: eventType?.title || booking.title,
title: booking.title,
@@ -117,16 +118,20 @@ async function createOrlistAllBookings(
uid: booking.uid,
metadata: {},
};
console.log(`evt: ${evt}`);
// Send Webhook call if hooked to BOOKING_CREATED
const triggerEvent = WebhookTriggerEvents.BOOKING_CREATED;
console.log(`Trigger Event: ${triggerEvent}`);
const subscriberOptions = {
userId,
eventTypeId: booking.eventTypeId as number,
triggerEvent,
};
console.log(`subscriberOptions: ${subscriberOptions}`);
const subscribers = await getWebhooks(subscriberOptions);
console.log(`subscribers: ${subscribers}`);
const bookingId = booking?.id;
const promises = subscribers.map((sub) =>
sendPayload(triggerEvent, new Date().toISOString(), sub, {