Files
fleet/website/api/controllers/deliver-webinar-access-request.js
Eric 85692f8238 Website: set historical event source (#50546)
Changes:
- Updated the website's createHistoricalEvent helper to accept an
eventSource input that is used to set the historical event source on
created records.
- Updated places where we create historical events to set a historical
event source
- Updated the accepted contact sources values in the receive-from-clay
webhook
- Updated the deliver-gitops-workshop-request action to log a warning
when a campaign member record cannot be created

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Improvements**
- Improved activity tracking for newsletter subscriptions, signups,
contact forms, workshop requests, webinars, gated content, and page
views.
- Added clearer source details to records for more accurate attribution.
- Expanded support for website, webinar, event, LinkedIn, prospecting,
and GitHub activity sources.
- **Bug Fixes**
- Workshop requests now continue successfully if campaign updates
encounter an error.
- Corrected warning messages and preserved relevant submission details
for troubleshooting.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-04 18:26:14 -05:00

79 lines
2.9 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'Deliver webinar access request',
description: '',
inputs: {
firstName: {type: 'string', required: true },
lastName: {type: 'string', required: true },
emailAddress: {type: 'string', required: true, isEmail: true, },
webinarName: {type: 'string', required: true },
},
exits: {
success: {description: 'A users webinar access request was successfully submitted.'},
invalidEmailDomain: {
description: 'This email address is on a denylist of domains and was not delivered.',
responseType: 'badRequest'
},
},
fn: async function ({firstName, lastName, emailAddress, webinarName}) {
let emailDomain = emailAddress.split('@')[1];
if(_.includes(sails.config.custom.bannedEmailDomainsForWebsiteSubmissions, emailDomain.toLowerCase())){
throw 'invalidEmailDomain';
}
// If the submitter has a marketing attribution cookie, send the details when creating/updating a contact/account/historical record.
let attributionCookieOrUndefined = this.req.cookies.marketingAttribution;
sails.helpers.flow.build(async ()=>{
let recordIds = await sails.helpers.salesforce.updateOrCreateContactAndAccount.with({
emailAddress: emailAddress,
firstName: firstName,
lastName: lastName,
contactSource: 'Website - Gated video',
description: `Submitted a form to watch the ${webinarName} webinar.`,
marketingAttributionCookie: attributionCookieOrUndefined
}).intercept((err)=>{
return new Error(`Could not create/update a contact or account. Full error: ${require('util').inspect(err)}`);
});
// If the Contact record returned by the updateOrCreateContactAndAccount does not have a parent Account record, throw an error to stop the build helper.
if(!recordIds.salesforceAccountId) {
throw new Error(`Could not create historical event. The contact record (ID: ${recordIds.salesforceContactId}) returned by the updateOrCreateContactAndAccount helper is missing a parent account record.`);
}
// Create the new Fleet website page view record.
await sails.helpers.salesforce.createHistoricalEvent.with({
salesforceAccountId: recordIds.salesforceAccountId,
salesforceContactId: recordIds.salesforceContactId,
eventType: 'Intent signal',
intentSignal: 'Requested webinar recording',
eventContent: webinarName,
eventSource: 'Website - Gated video',
}).intercept((err)=>{
return new Error(`Could not create an historical event. Full error: ${require('util').inspect(err)}`);
});
}).exec((err)=>{
if(err){
sails.log.warn(`Background task failed: When a user (email: ${emailAddress} submitted a form to watch the ${webinarName} webinar, a Contact/Account/website activity record could not be created/updated in the CRM.`, require('util').inspect(err));
}
return;
});//_∏_
// All done.
return;
}
};