diff --git a/website/api/controllers/save-questionnaire-progress.js b/website/api/controllers/save-questionnaire-progress.js index 62faf37929..2571eb1fd1 100644 --- a/website/api/controllers/save-questionnaire-progress.js +++ b/website/api/controllers/save-questionnaire-progress.js @@ -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({ diff --git a/website/assets/js/pages/start.page.js b/website/assets/js/pages/start.page.js index 3b95e7218b..50b3dbdc21 100644 --- a/website/assets/js/pages/start.page.js +++ b/website/assets/js/pages/start.page.js @@ -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': diff --git a/website/views/pages/start.ejs b/website/views/pages/start.ejs index d012d01748..8326f87bf1 100644 --- a/website/views/pages/start.ejs +++ b/website/views/pages/start.ejs @@ -399,8 +399,8 @@ <%// ╔═╗╦═╗╔═╗╔═╗╔═╗ ╔═╗╦ ╔═╗╔╦╗╔═╗╔═╗╦═╗╔╦╗ ╔╦╗╔╦╗╔╦╗ // ║ ╠╦╝║ ║╚═╗╚═╗ ╠═╝║ ╠═╣ ║ ╠╣ ║ ║╠╦╝║║║ ║║║ ║║║║║ // ╚═╝╩╚═╚═╝╚═╝╚═╝ ╩ ╩═╝╩ ╩ ╩ ╚ ╚═╝╩╚═╩ ╩ ╩ ╩═╩╝╩ ╩%> -
- +
+
🚀