Website: Update psychologicalStage changes in save-questionnaire-progress.js (#18498)

Closes: https://github.com/fleetdm/confidential/issues/6215

Changes:
- Updated how psychological stages are set when a user completes a step
of the get started questionnaire

> Note: I'm creating this as a draft PR until I review these changes to
make sure this is what we want to do.
This commit is contained in:
Eric 2024-04-26 12:42:48 -05:00 committed by GitHub
parent b75545ba26
commit d74f5cd6ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -80,30 +80,32 @@ module.exports = {
// - 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': No change // TODO (see above -- instead of no change there should be a change)
// 'will-you-be-self-hosting': No change // TODO (see above -- instead of no change there should maybe be a change, sometimes)
// 'how-many-hosts': Stage 6
// 'will-you-be-self-hosting': Stage 6
// 'what-are-you-working-on-eo-security'
// - no-use-case-yet: » No change // TODO (see above -- instead of no change there should maybe be a change, sometimes)
// - no-use-case-yet: » Stage 2/3 (depends on answer from 'have-you-ever-used-fleet' step)
// - All other options » Stage 4
// 'what-does-your-team-manage-eo-it'
// - no-use-case-yet: » No change // TODO (see above -- instead of no change there should maybe be a change, sometimes)
// - no-use-case-yet: » Stage 2/3 (depends on answer from 'have-you-ever-used-fleet' step)
// - All other options » Stage 4
// 'what-does-your-team-manage-vm'
// - no-use-case-yet: » No change // TODO (see above -- instead of no change there should maybe be a change, sometimes)
// - no-use-case-yet: » Stage 2/3 (depends on answer from 'have-you-ever-used-fleet' step)
// - All other options » Stage 4
// 'what-do-you-manage-mdm'
// - no-use-case-yet: » No change // TODO (see above -- instead of no change there should maybe be a change, sometimes)
// - no-use-case-yet: » Stage 2/3 (depends on answer from 'have-you-ever-used-fleet' step)
// - All other options » Stage 4
// 'is-it-any-good': // TODO (see above -- instead of no change there should maybe be a change, sometimes)
// '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
// - let-me-think-about-it » // TODO (see above -- instead of no change there should maybe be a change, sometimes)
// - 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)
let psychologicalStage = userRecord.psychologicalStage;
// Get the value of the submitted formData, we do this so we only need to check one variable, instead of (formData.attribute === 'foo');
let valueFromFormData = _.values(formData)[0];
if(currentStep === 'what-are-you-using-fleet-for') {
if(currentStep === 'start') {
// There is change when the user completes the start step.
} 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)) {
@ -116,19 +118,60 @@ module.exports = {
// Otherwise, we'll just assume liu're only aware. Maybe liu don't fully grasp what Fleet can do.
psychologicalStage = '2 - Aware';
}
} else if(['what-are-you-working-on-eo-security','what-does-your-team-manage-eo-it','what-does-your-team-manage-vm','what-do-you-manage-mdm'].includes(currentStep)){
if(valueFromFormData === 'no-use-case-yet') {
// If this user doe not have a use case for Fleet yet, set their psyStage to 3
psychologicalStage = '3 - Intrigued';
} else {// Otherwise, they have a use case and will be set to stage 4.
psychologicalStage = '4 - Has use case';
}
} else if(currentStep === 'what-did-you-think') {
// 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.
if(valueFromFormData === 'deploy-fleet-in-environment') {
psychologicalStage = '5 - Personally confident';
}
// If the user selects let me think about it, their stage will not change.
} else {
// If the user submitted any other step, we'll set variables using the answers to the previous questions.
// Get the user's selected primaryBuyingSiutation.
let currentSelectedBuyingSituation = questionnaireProgress['what-are-you-using-fleet-for'].primaryBuyingSituation;
// Get the user's answer to the "Have you ever used Fleet?" question.
let hasUsedFleetAnswer = questionnaireProgress['have-you-ever-used-fleet'].fleetUseStatus;
if(['what-are-you-working-on-eo-security','what-does-your-team-manage-eo-it','what-does-your-team-manage-vm','what-do-you-manage-mdm'].includes(currentStep)){
if(valueFromFormData === 'no-use-case-yet') {
// Check the user's answer to the previous question
if(hasUsedFleetAnswer === 'yes-deployed-local'){
// If they've tried Fleet locally, set their stage to 3.
psychologicalStage = '3 - Intrigued';
} else {
psychologicalStage = '2 - Aware';
}
} else {// Otherwise, they have a use case and will be set to stage 4.
psychologicalStage = '4 - Has use case';
}
} 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
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') {
// If they've tried Fleet locally, set their stage to 3.
psychologicalStage = '3 - Intrigued';
} else {
psychologicalStage = '2 - Aware';
}
} else {
psychologicalStage = '4 - Has use case';
}
} else {// For any other selected primary buying situation, since a use case will have been selected, set their psyStage to 4
psychologicalStage = '4 - Has use case';
// FUTURE: check previous answers for other selected buying situations.
}
} else if(currentStep === 'what-did-you-think') {
// 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.
if(valueFromFormData === 'deploy-fleet-in-environment') {
psychologicalStage = '5 - Personally confident';
} else if(valueFromFormData === 'let-me-think-about-it') {
// If the user selects "Let me think about it", their stage change to 2
psychologicalStage = '2 - Aware';
}
// If the user selects "Id like you to host Fleet for me", the form is not submitted, and they are taken to the /contact page instead. FUTURE: set stage to stage 5.
} else if(currentStep === 'how-many-hosts') {
// If they have Fleet deployed, they have team buy-in
psychologicalStage = '6 - Has team buy-in';
} else if(currentStep === 'will-you-be-self-hosting') {
// If they have Fleet deployed, they have team buy-in
psychologicalStage = '6 - Has team buy-in';
}//fi
}//fi