-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(survey): Randomize questions & choices in surveys (#22227)
Users want to remove biases in the survey responses by shuffling around the questions when their customers get survey requests. To support this, we will add options to the API that allow us to save values specific to questions `shuffleOptions`, and a boolean flag `shuffleQuestions` to the survey object so that posthog-js can do the right thing based on these flags. 1. Adds a `shuffle options` checkbox to the UI that adds additional options to the questions. 2. Adds a `Shuffle questions` checkbox to the `Customization` section of the survey edit UI.
- Loading branch information
Showing
11 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+104 KB
...d/__snapshots__/scenes-app-surveys--new-multi-question-survey-section--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+105 KB
.../__snapshots__/scenes-app-surveys--new-multi-question-survey-section--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.21 KB
(100%)
...nd/__snapshots__/scenes-app-surveys--new-survey-customisation-section--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.23 KB
(100%)
...d/__snapshots__/scenes-app-surveys--new-survey-customisation-section--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.4 KB
(110%)
frontend/__snapshots__/scenes-app-surveys--surveys-list--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+10.4 KB
(110%)
frontend/__snapshots__/scenes-app-surveys--surveys-list--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { mswDecorator } from '~/mocks/browser' | |
import { toPaginatedResponse } from '~/mocks/handlers' | ||
import { | ||
FeatureFlagBasicType, | ||
MultipleSurveyQuestion, | ||
PropertyFilterType, | ||
PropertyOperator, | ||
Survey, | ||
|
@@ -43,6 +44,44 @@ const MOCK_BASIC_SURVEY: Survey = { | |
responses_limit: null, | ||
} | ||
|
||
const MOCK_SURVEY_WITH_MULTIPLE_OPTIONS: Survey = { | ||
id: '998FE805-F9EF-4F25-A5D1-B9549C4E2143', | ||
name: 'survey with multiple options', | ||
description: 'survey with multiple options description', | ||
type: SurveyType.Popover, | ||
created_at: '2023-04-27T10:04:37.977401Z', | ||
created_by: { | ||
id: 1, | ||
uuid: '01863799-062b-0000-8a61-b2842d5f8642', | ||
distinct_id: 'Sopz9Z4NMIfXGlJe6W1XF98GOqhHNui5J5eRe0tBGTE', | ||
first_name: 'Employee 427', | ||
email: '[email protected]', | ||
}, | ||
questions: [ | ||
{ | ||
type: SurveyQuestionType.MultipleChoice, | ||
question: "We're sorry to see you go. What's your reason for unsubscribing?", | ||
choices: [ | ||
'I no longer need the product', | ||
'I found a better product', | ||
'I found the product too difficult to use', | ||
'Other', | ||
], | ||
shuffleOptions: true, | ||
}, | ||
], | ||
conditions: null, | ||
linked_flag: null, | ||
linked_flag_id: null, | ||
targeting_flag: null, | ||
targeting_flag_filters: undefined, | ||
appearance: { backgroundColor: 'white', submitButtonColor: '#2C2C2C' }, | ||
start_date: null, | ||
end_date: null, | ||
archived: false, | ||
responses_limit: null, | ||
} | ||
|
||
const MOCK_SURVEY_WITH_RELEASE_CONS: Survey = { | ||
id: '0187c279-bcae-0000-34f5-4f121921f006', | ||
name: 'survey with release conditions', | ||
|
@@ -154,9 +193,12 @@ const meta: Meta = { | |
'/api/projects/:team_id/surveys/': toPaginatedResponse([ | ||
MOCK_BASIC_SURVEY, | ||
MOCK_SURVEY_WITH_RELEASE_CONS, | ||
MOCK_SURVEY_WITH_MULTIPLE_OPTIONS, | ||
]), | ||
'/api/projects/:team_id/surveys/0187c279-bcae-0000-34f5-4f121921f005/': MOCK_BASIC_SURVEY, | ||
'/api/projects/:team_id/surveys/0187c279-bcae-0000-34f5-4f121921f006/': MOCK_SURVEY_WITH_RELEASE_CONS, | ||
'/api/projects/:team_id/surveys/998FE805-F9EF-4F25-A5D1-B9549C4E2143/': | ||
MOCK_SURVEY_WITH_MULTIPLE_OPTIONS, | ||
'/api/projects/:team_id/surveys/responses_count/': MOCK_RESPONSES_COUNT, | ||
[`/api/projects/:team_id/feature_flags/${ | ||
(MOCK_SURVEY_WITH_RELEASE_CONS.linked_flag as FeatureFlagBasicType).id | ||
|
@@ -206,6 +248,27 @@ export const NewSurveyCustomisationSection: StoryFn = () => { | |
return <App /> | ||
} | ||
|
||
export const NewMultiQuestionSurveySection: StoryFn = () => { | ||
useEffect(() => { | ||
router.actions.push(urls.survey('new')) | ||
surveyLogic({ id: 'new' }).mount() | ||
surveyLogic({ id: 'new' }).actions.setSelectedSection(SurveyEditSection.Steps) | ||
surveyLogic({ id: 'new' }).actions.setSurveyValue('questions', [ | ||
{ | ||
type: SurveyQuestionType.MultipleChoice, | ||
question: "We're sorry to see you go. What's your reason for unsubscribing?", | ||
choices: [ | ||
'I no longer need the product', | ||
'I found a better product', | ||
'I found the product too difficult to use', | ||
'Other', | ||
], | ||
} as MultipleSurveyQuestion, | ||
]) | ||
}, []) | ||
return <App /> | ||
} | ||
|
||
export const NewSurveyPresentationSection: StoryFn = () => { | ||
useEffect(() => { | ||
router.actions.push(urls.survey('new')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters