mirror of
https://github.com/fleetdm/fleet
synced 2026-05-06 06:48:54 +00:00
Website: Update "Talk to us" form (#33384)
Related to: https://github.com/fleetdm/confidential/issues/11779 Changes: - Updated the `deliver-talk-to-us-form-submission` to use information returned by the getEnriched helper to determine the Calendly event users are taken to when they submit the form.
This commit is contained in:
parent
6cf3593ba7
commit
eafb0e1b83
3 changed files with 43 additions and 16 deletions
|
|
@ -63,17 +63,21 @@ module.exports = {
|
|||
description: 'This email address is on a denylist of domains and was not delivered.',
|
||||
responseType: 'badRequest'
|
||||
},
|
||||
success: {
|
||||
decription: 'A user successfully submitted the "Talk to us" form.',
|
||||
outputType: 'string',
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
fn: async function ({emailAddress, firstName, lastName, organization, numberOfHosts, primaryBuyingSituation}) {
|
||||
|
||||
|
||||
let emailDomain = emailAddress.split('@')[1];
|
||||
if(_.includes(sails.config.custom.bannedEmailDomainsForWebsiteSubmissions, emailDomain.toLowerCase())){
|
||||
throw 'invalidEmailDomain';
|
||||
}
|
||||
|
||||
let contactInformation = {
|
||||
emailAddress: emailAddress,
|
||||
firstName: firstName,
|
||||
|
|
@ -84,6 +88,8 @@ module.exports = {
|
|||
psychologicalStage: '4 - Has use case',
|
||||
psychologicalStageChangeReason: 'Website - Contact forms'
|
||||
};
|
||||
|
||||
// If the user said they have 700+ hosts, Update/create a contact and account, and send them to the "Talk to us" Calendly event.
|
||||
if(numberOfHosts >= 700){
|
||||
contactInformation.description = `Submitted the "Talk to us" form and was taken to the Calendly page for the "Talk to us" event. Number of hosts: ${numberOfHosts}`;
|
||||
sails.helpers.salesforce.updateOrCreateContactAndAccount.with(contactInformation).exec((err)=>{
|
||||
|
|
@ -91,17 +97,40 @@ module.exports = {
|
|||
sails.log.warn(`Background task failed: When a user submitted the "Talk to us" form, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err);
|
||||
}
|
||||
});
|
||||
return `https://calendly.com/fleetdm/talk-to-us?email=${encodeURIComponent(emailAddress)}&name=${encodeURIComponent(firstName+' '+lastName)}`;
|
||||
} else {
|
||||
contactInformation.description = `Submitted the "Talk to us" form and was taken to the Calendly page for the "Let\'s get you set up!" event. Number of hosts: ${numberOfHosts}`;
|
||||
sails.helpers.salesforce.updateOrCreateContactAndAccount.with(contactInformation).exec((err)=>{
|
||||
if(err) {
|
||||
sails.log.warn(`Background task failed: When a user submitted the "Talk to us" form, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err);
|
||||
}
|
||||
// If the user has <700 hosts, use the get-enriched helper to try to find the number of employees at their organization.
|
||||
let enrichmentInformation = await sails.helpers.iq.getEnriched.with({
|
||||
emailAddress,
|
||||
firstName,
|
||||
lastName,
|
||||
organization,
|
||||
}).tolerate((err)=>{
|
||||
sails.log.warn(`When a user (${emailAddress}) submitted the "Talk to us form", an error occured while getting enrichment information for this user. Error from get-enriched helper: ${require('util').inspect(err)}`);
|
||||
return {};
|
||||
});
|
||||
// FUTURE: create POV here
|
||||
}
|
||||
|
||||
return;
|
||||
// If we got a employer.numberOfEmployees value from the getEnriched helper, send the user to the "talk to us" calendly event if it is 700+.
|
||||
if(enrichmentInformation.employer && enrichmentInformation.employer.numberOfEmployees && enrichmentInformation.employer.numberOfEmployees >= 700) {
|
||||
contactInformation.description = `Submitted the "Talk to us" form and was taken to the Calendly page for the "Talk to us" event because of the number of employees (${enrichmentInformation.employer.numberOfEmployees}) returned by Coresignal. Number of hosts: ${numberOfHosts}`;
|
||||
sails.helpers.salesforce.updateOrCreateContactAndAccount.with(contactInformation).exec((err)=>{
|
||||
if(err) {
|
||||
sails.log.warn(`Background task failed: When a user submitted the "Talk to us" form, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err);
|
||||
}
|
||||
});
|
||||
return `https://calendly.com/fleetdm/talk-to-us?email=${encodeURIComponent(emailAddress)}&name=${encodeURIComponent(firstName+' '+lastName)}`;
|
||||
} else {
|
||||
// If the enrichment helper didn't return a employer.numberOfEmployees value and this user has <700 hosts, send them to the "Let's get you set up!" Calendly event
|
||||
contactInformation.description = `Submitted the "Talk to us" form and was taken to the Calendly page for the "Let\'s get you set up!" event. Number of hosts: ${numberOfHosts}`;
|
||||
sails.helpers.salesforce.updateOrCreateContactAndAccount.with(contactInformation).exec((err)=>{
|
||||
if(err) {
|
||||
sails.log.warn(`Background task failed: When a user submitted the "Talk to us" form, a lead/contact could not be updated in the CRM for this email address: ${emailAddress}.`, err);
|
||||
}
|
||||
});
|
||||
return `https://calendly.com/fleetdm/chat?email=${encodeURIComponent(emailAddress)}&name=${encodeURIComponent(firstName+' '+lastName)}`;
|
||||
// FUTURE: create POV here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
10
website/assets/js/pages/contact.page.js
vendored
10
website/assets/js/pages/contact.page.js
vendored
|
|
@ -98,7 +98,7 @@ parasails.registerPage('contact', {
|
|||
this.cloudSuccess = true;
|
||||
|
||||
},
|
||||
submittedTalkToUsForm: async function() {
|
||||
handleSubmittingTalkToUsForm: async function(argins) {
|
||||
this.syncing = true;
|
||||
if(typeof gtag !== 'undefined'){
|
||||
gtag('event','fleet_website__contact_forms');
|
||||
|
|
@ -109,11 +109,9 @@ parasails.registerPage('contact', {
|
|||
if(typeof analytics !== 'undefined'){
|
||||
analytics.track('fleet_website__contact_forms');
|
||||
}
|
||||
if(this.formData.numberOfHosts >= 700){
|
||||
this.goto(`https://calendly.com/fleetdm/talk-to-us?email=${encodeURIComponent(this.formData.emailAddress)}&name=${encodeURIComponent(this.formData.firstName+' '+this.formData.lastName)}`);
|
||||
} else {
|
||||
this.goto(`https://calendly.com/fleetdm/chat?email=${encodeURIComponent(this.formData.emailAddress)}&name=${encodeURIComponent(this.formData.firstName+' '+this.formData.lastName)}`);
|
||||
}
|
||||
let eventUrl = await Cloud.deliverTalkToUsFormSubmission.with(argins);
|
||||
|
||||
this.goto(eventUrl);
|
||||
},
|
||||
|
||||
clickSwitchForms: function(form) {
|
||||
|
|
|
|||
2
website/views/pages/contact.ejs
vendored
2
website/views/pages/contact.ejs
vendored
|
|
@ -66,7 +66,7 @@
|
|||
</ajax-form>
|
||||
</div>
|
||||
<div v-else>
|
||||
<ajax-form action="deliverTalkToUsFormSubmission" class="contact" :form-errors.sync="formErrors" :form-data="formData" :form-rules="talkToUsFormRules" :syncing.sync="syncing" :cloud-error.sync="cloudError" @submitted="submittedTalkToUsForm()">
|
||||
<ajax-form :handle-submitting="handleSubmittingTalkToUsForm" class="contact" :form-errors.sync="formErrors" :form-data="formData" :form-rules="talkToUsFormRules" :cloud-error.sync="cloudError">
|
||||
<div class="form-group">
|
||||
<label for="email-address">Work email *</label>
|
||||
<input class="form-control" id="email-address" name="email-address" type="email" :class="[formErrors.emailAddress ? 'is-invalid' : '']" v-model.trim="formData.emailAddress" autocomplete="email" focus-first>
|
||||
|
|
|
|||
Loading…
Reference in a new issue