mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
Website: reduce time to submit steps of the /start questionnaire. (#18721)
Related to: https://github.com/fleetdm/confidential/issues/6357 Changes: - wrapped the `updateOrCreateContactAndAccount` helper call in `save-questionnaire-progress` in `setImmediate()` to allow users to progress through the form without waiting for CRM updates.
This commit is contained in:
parent
3846d2aca8
commit
7c3f029f78
1 changed files with 14 additions and 8 deletions
|
|
@ -208,14 +208,20 @@ module.exports = {
|
|||
}//fi
|
||||
|
||||
// Only update CRM records if the user's psychological stage changes.
|
||||
if(psychologicalStage !== userRecord.psychologicalStage){
|
||||
await sails.helpers.salesforce.updateOrCreateContactAndAccount.with({
|
||||
emailAddress: this.req.me.emailAddress,
|
||||
firstName: this.req.me.firstName,
|
||||
lastName: this.req.me.lastName,
|
||||
primaryBuyingSituation: primaryBuyingSituation === 'eo-security' ? 'Endpoint operations - Security' : primaryBuyingSituation === 'eo-it' ? 'Endpoint operations - IT' : primaryBuyingSituation === 'mdm' ? 'Device management (MDM)' : primaryBuyingSituation === 'vm' ? 'Vulnerability management' : undefined,
|
||||
organization: this.req.me.organization,
|
||||
psychologicalStage,
|
||||
if(psychologicalStage !== userRecord.psychologicalStage) {
|
||||
// Use setImmediate to queue CRM updates.
|
||||
// [?]: https://nodejs.org/api/timers.html#setimmediatecallback-args
|
||||
require('timers').setImmediate(async ()=>{
|
||||
await sails.helpers.salesforce.updateOrCreateContactAndAccount.with({
|
||||
emailAddress: this.req.me.emailAddress,
|
||||
firstName: this.req.me.firstName,
|
||||
lastName: this.req.me.lastName,
|
||||
primaryBuyingSituation: primaryBuyingSituation === 'eo-security' ? 'Endpoint operations - Security' : primaryBuyingSituation === 'eo-it' ? 'Endpoint operations - IT' : primaryBuyingSituation === 'mdm' ? 'Device management (MDM)' : primaryBuyingSituation === 'vm' ? 'Vulnerability management' : undefined,
|
||||
organization: this.req.me.organization,
|
||||
psychologicalStage,
|
||||
}).catch((err)=>{
|
||||
sails.log.warn(`When a user (email: ${this.req.me.emailAddress} submitted a step of the get started questionnaire, a Contact and Account record could not be created/updated in the CRM. Full error:`, err);
|
||||
});
|
||||
});
|
||||
}
|
||||
// TODO: send all other answers to Salesforce (when there are fields for them)
|
||||
|
|
|
|||
Loading…
Reference in a new issue