Scheduling infrastructure for absolutely everyone.
Adding debugging info (#3706)
Leo Giovanetti7747b3d9a007
diff --git a/packages/app-store/hubspotothercalendar/lib/CalendarService.ts b/packages/app-store/hubspotothercalendar/lib/CalendarService.tsindex 7ff8896bb90..b1faff7d418 100644--- a/packages/app-store/hubspotothercalendar/lib/CalendarService.ts+++ b/packages/app-store/hubspotothercalendar/lib/CalendarService.ts@@ -188,8 +188,10 @@ export default class HubspotOtherCalendarService implements Calendar {async handleMeetingCreation(event: CalendarEvent, contacts: SimplePublicObjectInput[]) {const meetingEvent = await this.hubspotCreateMeeting(event);if (meetingEvent) {+ this.log.debug("meeting:creation:ok", { meetingEvent });const associatedMeeting = await this.hubspotAssociate(meetingEvent, contacts);if (associatedMeeting) {+ this.log.debug("association:creation:ok", { associatedMeeting });return Promise.resolve({uid: meetingEvent.id,id: meetingEvent.id,@@ -201,6 +203,7 @@ export default class HubspotOtherCalendarService implements Calendar {}return Promise.reject("Something went wrong when associating the meeting and attendees in HubSpot");}+ this.log.debug("meeting:creation:notOk", { meetingEvent, event, contacts });return Promise.reject("Something went wrong when creating a meeting in HubSpot");}@@ -211,26 +214,35 @@ export default class HubspotOtherCalendarService implements Calendar {if (contacts.length) {if (contacts.length == event.attendees.length) {// All attendees do exist in HubSpot+ this.log.debug("contact:search:all", { event, contacts });return await this.handleMeetingCreation(event, contacts);} else {// Some attendees don't exist in HubSpot// Get the existing contacts' email to filter out+ this.log.debug("contact:search:notAll", { event, contacts });const existingContacts = contacts.map((contact) => contact.properties.email);+ this.log.debug("contact:filter:existing", { existingContacts });// Get non existing contacts filtering out existing from attendeesconst nonExistingContacts = event.attendees.filter((attendee) => !existingContacts.includes(attendee.email));+ this.log.debug("contact:filter:nonExisting", { nonExistingContacts });// Only create contacts in HubSpot that were not present in the previous contact searchconst createContacts = await this.hubspotContactCreate(nonExistingContacts);+ this.log.debug("contact:created", { createContacts });// Continue with meeting creation and association only when all contacts are present in HubSpotif (createContacts.length) {+ this.log.debug("contact:creation:ok");return await this.handleMeetingCreation(event, createContacts.concat(contacts));}return Promise.reject("Something went wrong when creating non-existing attendees in HubSpot");}} else {+ this.log.debug("contact:search:none", { event, contacts });const createContacts = await this.hubspotContactCreate(event.attendees);+ this.log.debug("contact:created", { createContacts });if (createContacts.length) {+ this.log.debug("contact:creation:ok");return await this.handleMeetingCreation(event, createContacts);}}