mirror of
https://github.com/fleetdm/fleet
synced 2026-05-05 14:28:46 +00:00
## Summary - Adds `'Registered for a conference'` to the `intentSignal` `isIn` array in three files: - `website/api/helpers/salesforce/create-historical-event.js` — between `'Signed up for Fleet event'` and `'Engaged with Fleetie at event'` - `website/api/controllers/webhooks/receive-from-clay.js` — between `'Signed up for Fleet event'` and `'Engaged with Fleetie at event'` - `website/api/helpers/salesforce/update-or-create-contact-and-account.js` — added to the `isIn` array - This replaces the incorrect approach in PR #41918, which added the signal to the handbook markdown table instead of the code where intent signals are validated. --- Built for [Sam Pfluger](https://fleetdm.slack.com/archives/D0AF8QFBVHB/p1773789580384389?thread_ts=1773788922.891409&cid=D0AF8QFBVHB) by [Kilo for Slack](https://kilo.ai/features/slack-integration) --------- Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com> Co-authored-by: Sam Pfluger <[email protected]>
161 lines
5.3 KiB
JavaScript
Vendored
161 lines
5.3 KiB
JavaScript
Vendored
module.exports = {
|
|
|
|
|
|
friendlyName: 'Create Historical event',
|
|
|
|
|
|
description: 'Create a historical event related to a particular contact and account in Salesforce.',
|
|
|
|
|
|
inputs: {
|
|
// Required values on new historical event records.
|
|
salesforceAccountId: {
|
|
type: 'string',
|
|
required: true,
|
|
extendedDescription: 'This ID of the account associated with this historical event'
|
|
},
|
|
salesforceContactId: {
|
|
type: 'string',
|
|
required: true,
|
|
extendedDescription: 'This ID of the contact associated with this historical event'
|
|
},
|
|
eventType: {
|
|
type: 'string',
|
|
required: true,
|
|
isIn: [
|
|
'Intent signal',
|
|
'Website page view',
|
|
],
|
|
},
|
|
|
|
// For "Website page view" type historical events:
|
|
fleetWebsitePageUrl: {
|
|
type: 'string',
|
|
description: 'The url of the page this user viewed.',
|
|
extendedDescription: 'This input is required when the event type is "Website page view".'
|
|
},
|
|
websiteVisitReason: {
|
|
type: 'string',
|
|
description: ''
|
|
},
|
|
|
|
// For "Intent signal" type historical events:
|
|
intentSignal: {
|
|
type: 'string',
|
|
isIn: [
|
|
'Followed the Fleet LinkedIn company page',
|
|
'LinkedIn comment',
|
|
'LinkedIn share',
|
|
'LinkedIn reaction',
|
|
'Fleet channel member in MacAdmins Slack',
|
|
'Fleet channel member in osquery Slack',
|
|
'Implemented a trial key',
|
|
'Signed up for Fleet event',
|
|
'Registered for a conference',
|
|
'Engaged with Fleetie at event',
|
|
'Attended a Fleet happy hour',
|
|
'Stared the fleetdm/fleet repo on GitHub',
|
|
'Forked the fleetdm/fleet repo on GitHub',
|
|
'Contributed to the fleetdm/fleet repo on GitHub',
|
|
'Subscribed to the Fleet newsletter',
|
|
'Attended a Fleet training course',
|
|
'Submitted the "Send a message" form',
|
|
'Scheduled a "Talk to us" meeting',
|
|
'Scheduled a "Let\'s get you set up" meeting',
|
|
'Submitted the "GitOps workshop request" form',
|
|
'Signed up for a fleetdm.com account',
|
|
'Requested whitepaper download',
|
|
]
|
|
},
|
|
eventContent: {
|
|
type: 'string',
|
|
},
|
|
eventContentUrl: {
|
|
type: 'string',
|
|
},
|
|
linkedinUrl: {
|
|
type: 'string',
|
|
},
|
|
relatedCampaign: {
|
|
type: 'string',
|
|
}
|
|
},
|
|
|
|
|
|
exits: {
|
|
|
|
success: {
|
|
outputType: {
|
|
salesforceHistoricalEventId: 'string',
|
|
},
|
|
},
|
|
|
|
},
|
|
|
|
|
|
fn: async function ({ salesforceAccountId, salesforceContactId, eventType, linkedinUrl, intentSignal, eventContent, eventContentUrl, fleetWebsitePageUrl, websiteVisitReason, relatedCampaign}) {
|
|
// Return undefined if we're not running in a production environment.
|
|
if(sails.config.environment !== 'production') {
|
|
sails.log.verbose('Skipping Salesforce integration...');
|
|
return {
|
|
salesforceHistoricalEventId: undefined
|
|
};
|
|
}
|
|
|
|
require('assert')(sails.config.custom.salesforceIntegrationPasskey);
|
|
require('assert')(sails.config.custom.salesforceIntegrationUsername);
|
|
require('assert')(sails.config.custom.RX_PROTOCOL_AND_COMMON_SUBDOMAINS);
|
|
|
|
// Normalize the provided linkedin url.
|
|
if(linkedinUrl){
|
|
linkedinUrl = linkedinUrl.replace(sails.config.custom.RX_PROTOCOL_AND_COMMON_SUBDOMAINS, '');
|
|
}
|
|
// Check for required values depending on the eventType value.
|
|
if(eventType === 'Intent signal') {
|
|
if(!intentSignal) {
|
|
throw new Error(`A intentSignal value is required when creating "Intent signal" type historical events`);
|
|
}
|
|
} else if(eventType === 'Website page view') {
|
|
if(!fleetWebsitePageUrl){
|
|
throw new Error(`A fleetWebsitePageUrl value is required when creating "Website page view" type historical events`);
|
|
}
|
|
}
|
|
|
|
// Use sails.helpers.flow.build to login to salesforce and create the new histrocial event record.
|
|
let newHistoricalRecord = await sails.helpers.flow.build(async ()=>{
|
|
|
|
|
|
// login to Salesforce
|
|
let jsforce = require('jsforce');
|
|
let salesforceConnection = new jsforce.Connection({
|
|
loginUrl : 'https://fleetdm.my.salesforce.com'
|
|
});
|
|
await salesforceConnection.login(sails.config.custom.salesforceIntegrationUsername, sails.config.custom.salesforceIntegrationPasskey);
|
|
|
|
return await salesforceConnection.sobject('fleet_website_page_views__c')
|
|
.create({
|
|
Contact__c: salesforceContactId,// eslint-disable-line camelcase
|
|
Account__c: salesforceAccountId,// eslint-disable-line camelcase
|
|
Event_type__c: eventType,// eslint-disable-line camelcase
|
|
|
|
Intent_signal__c: intentSignal,// eslint-disable-line camelcase
|
|
Content__c: eventContent,// eslint-disable-line camelcase
|
|
Content_url__c: eventContentUrl,// eslint-disable-line camelcase
|
|
Interactor_profile_url__c: linkedinUrl,// eslint-disable-line camelcase
|
|
|
|
Page_URL__c: fleetWebsitePageUrl,// eslint-disable-line camelcase
|
|
Website_visit_reason__c: websiteVisitReason,// eslint-disable-line camelcase
|
|
Related_campaign__c: relatedCampaign// eslint-disable-line camelcase
|
|
});
|
|
}).intercept((err)=>{
|
|
return new Error(`An error occured when creating a new Historical event record in Salesforce. full error ${require('util').inspect(err, {depth: null})}`);
|
|
});
|
|
|
|
|
|
|
|
return newHistoricalRecord.id;
|
|
|
|
}
|
|
|
|
|
|
};
|