Website: update error handling in receive-from-clay webhook (#29359)

Changes:
- Added two exits to the receive-from-clay webhook that are used when a
contact or account cannot be created/updated.
- Added an exit to the receive-from-clay webhook that is used when a
historical event record cannot be created.
This commit is contained in:
Eric 2025-05-21 17:00:10 -05:00 committed by GitHub
parent 661d7de783
commit 83de20b31f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -51,6 +51,9 @@ module.exports = {
exits: {
success: { description: 'Information about LinkedIn activity has successfully been received.' },
duplicateContactOrAccountFound: {description: 'A contact or account could not be created because a duplicate record exists.', statusCode: 409 },
couldNotCreateContactOrAccount: { description: 'A contact or account could not be created in the CRM using the provided information.' },
couldNotCreateActivity: { description: 'An error occured when trying to create a historical event record in the CRM' },
},
@ -73,10 +76,14 @@ module.exports = {
contactSource,
jobTitle,
}).intercept((err)=>{
return new Error(`When the receive-from-clay webhook received information about LinkedIn activity, a contact/account could not be created or updated. Full error: ${require('util').inspect(err)}`);
sails.log.warn(`When the receive-from-clay webhook received information about LinkedIn activity, a contact/account could not be created or updated. Full error: ${require('util').inspect(err)}`);
if(typeof err.errorCode !== 'undefined' && err.errorCode === 'DUPLICATES_DETECTED') {
return 'duplicateContactOrAccountFound';
} else {
return 'couldNotCreateContactOrAccount';
}
});
let trimmedLinkedinUrl = linkedinUrl.replace(sails.config.custom.RX_PROTOCOL_AND_COMMON_SUBDOMAINS, '');
// Create the new Fleet website page view record.
@ -101,7 +108,8 @@ module.exports = {
Interactor_profile_url__c: trimmedLinkedinUrl,// eslint-disable-line camelcase
});
}).intercept((err)=>{
return new Error(`When the receive-from-clay webhook received information about linkedIn activity, a historical event record could not be created. Full error: ${require('util').inspect(err)}`);
sails.log.warn(`When the receive-from-clay webhook received information about LinkedIn activity, a historical event record could not be created. Full error: ${require('util').inspect(err)}`);
return 'couldNotCreateActivity';
});
// All done.