Website: Update /start questionnaire to update leads (#18120)

Changes: 
- Updated the `save-questionnaire-progress` to send a request to Zapier
when a user completes the "What are you using Fleet for" step of the
/start questionnaire.
This commit is contained in:
Eric 2024-04-08 10:51:15 -05:00 committed by GitHub
parent b9ef0290b9
commit d89af24955
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

@ -59,6 +59,22 @@ module.exports = {
await User.updateOne({id: this.req.me.id}).set({
primaryBuyingSituation
});
// Send a POST request to Zapier
await sails.helpers.http.post.with({
url: 'https://hooks.zapier.com/hooks/catch/3627242/3pl7yt1/',
data: {
primaryBuyingSituation,
emailAddress: this.req.me.emailAddress,
webhookSecret: sails.config.custom.zapierSandboxWebhookSecret,
}
})
.timeout(5000)
.tolerate(['non200Response', 'requestFailed'], (err)=>{
// Note that Zapier responds with a 2xx status code even if something goes wrong, so just because this message is not logged doesn't mean everything is hunky dory. More info: https://github.com/fleetdm/fleet/pull/6380#issuecomment-1204395762
sails.log.warn(`When a user completed the 'What are you using Fleet for' questionnaire step, a lead/contact could not be updated in the CRM for this email address: ${this.req.me.emailAddress}. Raw error: ${err}`);
return;
});
// Set the primary buying situation in the user's session.
this.req.session.primaryBuyingSituation = primaryBuyingSituation;
}

View file

@ -75,7 +75,7 @@ parasails.registerPage('start', {
}
// If this user has not completed the 'what are you using fleet for' step, and has a primaryBuyingSituation set by an ad. prefill the formData for this step.
if(this.primaryBuyingSituation && _.isEmpty(this.formData['what-are-you-using-fleet-for'])){
this.formData['what-are-you-using-fleet-for'].primaryBuyingSituation = _.clone(this.primaryBuyingSituation);
this.formData['what-are-you-using-fleet-for'] = {primaryBuyingSituation: this.primaryBuyingSituation};
}
},
mounted: async function() {