chore: Salesforce - Add additional logging and error checks (#18448)
This commit is contained in:
@@ -190,13 +190,23 @@ export default class SalesforceCRMService implements CRM {
|
||||
confirmedCustomFieldInputs[field.name] = appOptions.onBookingWriteToEventObjectMap[field.name];
|
||||
}
|
||||
|
||||
const ownerId = await this.getSalesforceUserIdFromEmail(event.organizer.email);
|
||||
let ownerId = null;
|
||||
if (event?.organizer?.email) {
|
||||
ownerId = await this.getSalesforceUserIdFromEmail(event.organizer.email);
|
||||
} else {
|
||||
this.log.warn("salesforceCreateEvent: No organizer email found for event", event.uid, event?.organizer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current code assume that contacts is not empty.
|
||||
* I'm not going to reject the promise since I don't know if this is a valid assumption.
|
||||
**/
|
||||
const [firstContact] = contacts;
|
||||
|
||||
if (!firstContact?.id) {
|
||||
this.log.warn("salesforceCreateEvent: No contacts found for event", event.uid, contacts);
|
||||
}
|
||||
|
||||
const createdEvent = await this.salesforceCreateEventApiCall(event, {
|
||||
EventWhoIds: contacts.map((contact) => contact.id),
|
||||
...confirmedCustomFieldInputs,
|
||||
@@ -226,7 +236,7 @@ export default class SalesforceCRMService implements CRM {
|
||||
// TODO: firstContact id is assumed to not be undefined. But current code doesn't check for it.
|
||||
firstContact.id,
|
||||
event.startTime,
|
||||
event.organizer.email,
|
||||
event.organizer?.email,
|
||||
event.responses,
|
||||
event?.uid
|
||||
);
|
||||
@@ -548,6 +558,10 @@ export default class SalesforceCRMService implements CRM {
|
||||
);
|
||||
}
|
||||
|
||||
if (contactsToCreate[0]?.email) {
|
||||
this.log.warn(`createContact: no attendee email found `, contactsToCreate);
|
||||
}
|
||||
|
||||
if (createEventOn === SalesforceRecordEnum.LEAD) {
|
||||
// Base this off of the first contact
|
||||
const attendee = contactsToCreate[0];
|
||||
@@ -926,7 +940,7 @@ export default class SalesforceCRMService implements CRM {
|
||||
private async writeToPersonRecord(
|
||||
contactId: string,
|
||||
startTime: string,
|
||||
organizerEmail: string,
|
||||
organizerEmail?: string,
|
||||
calEventResponses?: CalEventResponses | null,
|
||||
bookingUid?: string | null
|
||||
) {
|
||||
@@ -982,7 +996,7 @@ export default class SalesforceCRMService implements CRM {
|
||||
onBookingWriteToRecordFields: Record<string, any>;
|
||||
startTime: string;
|
||||
bookingUid?: string | null;
|
||||
organizerEmail: string;
|
||||
organizerEmail?: string;
|
||||
calEventResponses?: CalEventResponses | null;
|
||||
}): Promise<Record<string, any>> {
|
||||
const writeOnRecordBody: Record<string, any> = {};
|
||||
@@ -1104,6 +1118,9 @@ export default class SalesforceCRMService implements CRM {
|
||||
return new Date(startTime).toISOString();
|
||||
}
|
||||
if (fieldValue === DateFieldTypeData.BOOKING_CREATED_DATE && bookingUid) {
|
||||
if (!organizerEmail) {
|
||||
this.log.warn(`No organizer email found for bookingUid ${bookingUid}`);
|
||||
}
|
||||
const booking = await prisma.booking.findFirst({
|
||||
where: { uid: bookingUid },
|
||||
select: { createdAt: true },
|
||||
|
||||
Reference in New Issue
Block a user