Website: Update save-questionnaire-progress.js (#18697)

Eric, I did not test this (coded live w/ mike T). Relying on your eyes.
Also, remember remember the old legacy data that might need to be
migrated, especially since I added some assertions? (whuh ohhh)
This commit is contained in:
Mike McNeil 2024-05-02 11:25:48 -05:00 committed by GitHub
parent ba229a153c
commit 671ad9bf6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -78,12 +78,12 @@ module.exports = {
// - (any option) = stage 2
// 'have-you-ever-used-fleet':
// - yes-deployed: » Stage 6
// - yes-recently-deployed: » Stage 6
// - yes-recently-deployed: » Stage 5
// - yes-deployed-local: » Stage 3 (Tried Fleet but might not have a use case)
// - yes-deployed-long-time: Stage 2 (Tried Fleet long ago but might not fully grasp)
// - no: Stage 2 (Never tried Fleet and might not fully grasp)
// 'how-many-hosts': Stage 6
// 'will-you-be-self-hosting': Stage 6
// 'how-many-hosts': Stage 4/5/6
// 'will-you-be-self-hosting': Stage 5/6
// 'what-are-you-working-on-eo-security'
// - no-use-case-yet: » Stage 2/3 (depends on answer from 'have-you-ever-used-fleet' step)
// - All other options » Stage 4
@ -98,20 +98,21 @@ module.exports = {
// - All other options » Stage 4
// 'is-it-any-good': Stage 2/3/4 (depends on answer from 'have-you-ever-used-fleet' & the buying situation specific step)
// 'what-did-you-think'
// - deploy-fleet-in-environment » Stage 5
// - host-fleet-for-me » Stage 4
// - deploy-fleet-in-environment » Stage 4
// - let-me-think-about-it » Stage 2
// - host-fleet-for-me » N/A (currently not selectable, but should set the user's psychologicalStage to stage 5)
// FUTURE: Should the step about deploying fleet in your env be here? (For same reason is-it-any-good is here: when navigating back then forwards?)
// 'how-was-your-deployment'
// - up-and-running » Stage 6
// - kinda-stuck » No change (Stage 5)
// - havent-gotten-to-it » No change (Stage 5)
// - changed-mind-want-managed-deployment » No change (Stage 5)
// - up-and-running » Stage 5
// - kinda-stuck » Stage 4 (...at best! Still got the use case.)
// - havent-gotten-to-it » Stage 4 (same as above)
// - changed-mind-want-managed-deployment » Stage 4 (same as above)
// - decided-to-not-use-fleet » Stage 2
// 'whats-left-to-get-you-set-up'
// - need-premium-license-key » No change (Stage 6)
// - help-show-fleet-to-my-team » No change (Stage 6)
// - procurement-wants-some-stuff » No change (Stage 6)
// - nothing » No change (Stage 6)
// - need-premium-license-key » No change (Stage ??)
// - help-show-fleet-to-my-team » No change (Stage ??)
// - procurement-wants-some-stuff » No change (Stage ??)
// - nothing » No change (Stage ??)
let psychologicalStage = userRecord.psychologicalStage;
@ -122,9 +123,11 @@ module.exports = {
} else if(currentStep === 'what-are-you-using-fleet-for') {
psychologicalStage = '2 - Aware';
} else if(currentStep === 'have-you-ever-used-fleet') {
if(['yes-deployed', 'yes-recently-deployed'].includes(valueFromFormData)) {
if(['yes-deployed'].includes(valueFromFormData)) {
// If the user has Fleet deployed, set their stage to 6.
psychologicalStage = '6 - Has team buy-in';
} else if(valueFromFormData === 'yes-recently-deployed'){
psychologicalStage = '5 - Personally confident';
} else if(valueFromFormData === 'yes-deployed-local'){
// If they've tried Fleet locally, set their stage to 3.
psychologicalStage = '3 - Intrigued';
@ -152,8 +155,8 @@ module.exports = {
}
} else if(currentStep === 'is-it-any-good') {
if(currentSelectedBuyingSituation === 'mdm') {
// Since the mdm use case question is the only buying situation-sepcific question where a use case can't
// be selected, we'll check the user's previous answers befroe changing their psyStage
// Since the mdm use case question is the only buying situation-specific question where a use case can't
// be selected, we'll check the user's previous answers before changing their psyStage
if(questionnaireProgress['what-do-you-manage-mdm'].mdmUseCase === 'no-use-case-yet'){
// Check the user's answer to the have-you-ever-used-fleet question.
if(hasUsedFleetAnswer === 'yes-deployed-local') {
@ -169,33 +172,38 @@ module.exports = {
psychologicalStage = '4 - Has use case';
// FUTURE: check previous answers for other selected buying situations.
}
} else if(currentStep === 'what-did-you-think') {
} else if(currentStep === 'what-did-you-think') {// (what did you think about [presumably after you actually did...] trying it locally)
// If the user selects "Let me think about it", set their psyStage to 2.
if(valueFromFormData === 'let-me-think-about-it') {
psychologicalStage = '2 - Aware';
} else {// If the user is ready to deploy Fleet in their work environemnt, then they're ready to get buy-in from their team, so set their psyStage to 5.
psychologicalStage = '5 - Personally confident';
}
} else if (['deploy-fleet-in-environment','host-fleet-for-me'].includes(valueFromFormData)) {
psychologicalStage = '4 - Has use case';
} else { require('assert')(false,'This should never happen.'); }
} else if(currentStep === 'how-was-your-deployment') {
if(valueFromFormData === 'decided-to-not-use-fleet') {
psychologicalStage = '2 - Aware';
} else if(valueFromFormData === 'up-and-running'){
psychologicalStage = '6 - Has team buy-in';
}
} else if(currentStep === 'how-many-hosts') {
if(['yes-deployed', 'yes-recently-deployed'].includes(hasUsedFleetAnswer)) {
// If the user has Fleet deployed, set their stage to 6.
psychologicalStage = '6 - Has team buy-in';
} else {
psychologicalStage = '5 - Personally confident';
} else if(['kinda-stuck', 'havent-gotten-to-it', 'changed-mind-want-managed-deployment'].includes(valueFromFormData)){
psychologicalStage = '4 - Has use case';
} else { require('assert')(false,'This should never happen.'); }
} else if (currentStep === 'whats-left-to-get-you-set-up') {
// FUTURE: do more stuff (for now this always acts like 'no change')
} else if(currentStep === 'how-many-hosts') {
if(['yes-deployed'].includes(hasUsedFleetAnswer)) {
psychologicalStage = '6 - Has team buy-in';
} else if(valueFromFormData === 'yes-recently-deployed'){
psychologicalStage = '5 - Personally confident';
} else {
// IWMIH then we want Fleet to host for us (either because we wanted that from the get-go, or we backtracked because deploying looked too time-consuming)
psychologicalStage = '4 - Has use case';
}
} else if(currentStep === 'will-you-be-self-hosting') {
if(['yes-deployed', 'yes-recently-deployed'].includes(hasUsedFleetAnswer)) {
// If the user has Fleet deployed, set their stage to 6.
if(['yes-deployed'].includes(hasUsedFleetAnswer)) {
psychologicalStage = '6 - Has team buy-in';
} else {
} else if(valueFromFormData === 'yes-recently-deployed'){
psychologicalStage = '5 - Personally confident';
}
} else { require('assert')(false, 'This should never happen.'); }
}//fi
}//fi