mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 00:49:03 +00:00
Website: update save-questionnaire-progress (#22586)
Closes: https://github.com/fleetdm/confidential/issues/8237 Closes: https://github.com/fleetdm/confidential/issues/8236 Changes: - Updated `save-questionnaire-progress` to update CRM records whenever a user submits a step of the get started questionnaire. (This previously only happened when a user's psychological stage changed) - Changed the name of the 'cross-platform-mdm' step to 'message-about-cross-platform-mdm'
This commit is contained in:
parent
3813a49db8
commit
d1dde4f190
3 changed files with 31 additions and 28 deletions
|
|
@ -21,7 +21,7 @@ module.exports = {
|
|||
'what-does-your-team-manage-eo-it',
|
||||
'what-does-your-team-manage-vm',
|
||||
'what-do-you-manage-mdm',
|
||||
'cross-platform-mdm',
|
||||
'message-about-cross-platform-mdm',
|
||||
'is-it-any-good',
|
||||
'what-did-you-think',
|
||||
'deploy-fleet-in-your-environment',
|
||||
|
|
@ -57,7 +57,6 @@ module.exports = {
|
|||
} else {// other wise clone it from the user record.
|
||||
questionnaireProgress = _.clone(userRecord.getStartedQuestionnaireAnswers);
|
||||
}
|
||||
|
||||
// Tease out what liur buying situation will now be (or is and was, if it's not changing)
|
||||
let primaryBuyingSituation = formData.primaryBuyingSituation === undefined ? this.req.me.primaryBuyingSituation : formData.primaryBuyingSituation;
|
||||
|
||||
|
|
@ -212,11 +211,23 @@ module.exports = {
|
|||
questionnaireProgressAsAFormattedString = JSON.stringify(getStartedProgress)
|
||||
.replace(/[\{|\}|"]/g, '')// Remove the curly braces and quotation marks wrapping JSON objects
|
||||
.replace(/,/g, '\n')// Replace commas with newlines.
|
||||
.replace(/:\w+:/g, ':\t');// Replace the key from the formData with a color and tab, (e.g., what-are-you-using-fleet-for:primaryBuyingSituation:eo-security, » what-are-you-using-fleet-for: eo-security)
|
||||
.replace(/:\w+:/g, ':\t')// Replace the key from the formData with a colon and tab, (e.g., what-are-you-using-fleet-for:primaryBuyingSituation:eo-security, » what-are-you-using-fleet-for: eo-security)
|
||||
.replace(/(true)/g, 'step completed');// Replace any "true" answers with "step completed".
|
||||
} catch(err){
|
||||
sails.log.warn(`When converting a user's (email: ${this.req.me.emailAddress}) getStartedQuestionnaireAnswers to a formatted string to send to the CRM, and error occurred`, err);
|
||||
}
|
||||
// Only update CRM records if the user's psychological stage changes.
|
||||
// Create a dictionary of values to send to the CRM for this user.
|
||||
let contactInformation = {
|
||||
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,
|
||||
getStartedResponses: questionnaireProgressAsAFormattedString,
|
||||
contactSource: 'Website - Sign up',
|
||||
};
|
||||
// If the user's psychologicalStage changes, add a psychologicalStageChangeReason to the contactInformation dictionary that we'll update the CRM record with.
|
||||
if(psychologicalStage !== userRecord.psychologicalStage) {
|
||||
let psychologicalStageChangeReason = 'Website - Organic start flow'; // Default psystageChangeReason to "Website - Organic start flow"
|
||||
if(this.req.session.adAttributionString && this.req.session.visitedSiteFromAdAt) {
|
||||
|
|
@ -226,25 +237,17 @@ module.exports = {
|
|||
psychologicalStageChangeReason = this.req.session.adAttributionString;
|
||||
}
|
||||
}
|
||||
// Update the psychologicalStageLastChangedAt timestamp if the user's psychological stage
|
||||
contactInformation.psychologicalStageChangeReason = psychologicalStageChangeReason;
|
||||
// Update the psychologicalStageLastChangedAt timestamp if the user's psychological stage has changed (otherwise this is set to the current value)
|
||||
psychologicalStageLastChangedAt = Date.now();
|
||||
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,
|
||||
psychologicalStageChangeReason,
|
||||
getStartedResponses: questionnaireProgressAsAFormattedString,
|
||||
contactSource: 'Website - Sign up',
|
||||
}).exec((err)=>{
|
||||
if(err){
|
||||
sails.log.warn(`Background task failed: 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.`, err);
|
||||
}
|
||||
return;
|
||||
});
|
||||
}//fi
|
||||
// Update the CRM record for this user.
|
||||
sails.helpers.salesforce.updateOrCreateContactAndAccount.with(contactInformation).exec((err)=>{
|
||||
if(err){
|
||||
sails.log.warn(`Background task failed: 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.`, err);
|
||||
}
|
||||
return;
|
||||
});
|
||||
// Update the user's database model.
|
||||
await User.updateOne({id: userRecord.id})
|
||||
.set({
|
||||
|
|
|
|||
10
website/assets/js/pages/start.page.js
vendored
10
website/assets/js/pages/start.page.js
vendored
|
|
@ -18,7 +18,7 @@ parasails.registerPage('start', {
|
|||
'what-does-your-team-manage-eo-it': {},
|
||||
'what-does-your-team-manage-vm': {},
|
||||
'what-do-you-manage-mdm': {},
|
||||
'cross-platform-mdm': {stepCompleted: true},
|
||||
'message-about-cross-platform-mdm': {stepCompleted: true},
|
||||
'is-it-any-good': {stepCompleted: true},
|
||||
'what-did-you-think': {},
|
||||
'deploy-fleet-in-your-environment': {stepCompleted: true},
|
||||
|
|
@ -198,10 +198,10 @@ parasails.registerPage('start', {
|
|||
} else if(primaryBuyingSituation === 'vm') {
|
||||
this.currentStep = 'what-does-your-team-manage-vm';
|
||||
} else if(primaryBuyingSituation === 'mdm') {
|
||||
this.currentStep = 'cross-platform-mdm';
|
||||
this.currentStep = 'message-about-cross-platform-mdm';
|
||||
}
|
||||
break;
|
||||
case 'cross-platform-mdm':
|
||||
case 'message-about-cross-platform-mdm':
|
||||
this.currentStep = 'what-do-you-manage-mdm';
|
||||
break;
|
||||
case 'lets-talk-to-your-team':
|
||||
|
|
@ -300,9 +300,9 @@ parasails.registerPage('start', {
|
|||
nextStepInForm = 'is-it-any-good';
|
||||
break;
|
||||
case 'what-do-you-manage-mdm':
|
||||
nextStepInForm = 'cross-platform-mdm';
|
||||
nextStepInForm = 'message-about-cross-platform-mdm';
|
||||
break;
|
||||
case 'cross-platform-mdm':
|
||||
case 'message-about-cross-platform-mdm':
|
||||
nextStepInForm = 'is-it-any-good';
|
||||
break;
|
||||
case 'is-it-any-good':
|
||||
|
|
|
|||
4
website/views/pages/start.ejs
vendored
4
website/views/pages/start.ejs
vendored
|
|
@ -399,8 +399,8 @@
|
|||
<%// ╔═╗╦═╗╔═╗╔═╗╔═╗ ╔═╗╦ ╔═╗╔╦╗╔═╗╔═╗╦═╗╔╦╗ ╔╦╗╔╦╗╔╦╗
|
||||
// ║ ╠╦╝║ ║╚═╗╚═╗ ╠═╝║ ╠═╣ ║ ╠╣ ║ ║╠╦╝║║║ ║║║ ║║║║║
|
||||
// ╚═╝╩╚═╚═╝╚═╝╚═╝ ╩ ╩═╝╩ ╩ ╩ ╚ ╚═╝╩╚═╩ ╩ ╩ ╩═╩╝╩ ╩%>
|
||||
<div v-if="currentStep === 'cross-platform-mdm'">
|
||||
<ajax-form :handle-submitting="handleSubmittingForm" :form-errors.sync="formErrors" :form-data="formData['cross-platform-mdm']" :form-rules="formRules" :syncing.sync="syncing" :cloud-error.sync="cloudError">
|
||||
<div v-if="currentStep === 'message-about-cross-platform-mdm'">
|
||||
<ajax-form :handle-submitting="handleSubmittingForm" :form-errors.sync="formErrors" :form-data="formData['message-about-cross-platform-mdm']" :form-rules="formRules" :syncing.sync="syncing" :cloud-error.sync="cloudError">
|
||||
<div purpose="progress-bar-container">
|
||||
<div purpose="form-progress-bar"><div purpose="current-progress" style="width: 45%"></div></div>
|
||||
<img purpose="success-icon" alt="🚀" src="/images/icon-form-success-16x16@2x.png">
|
||||
|
|
|
|||
Loading…
Reference in a new issue