From 60d2176efac5a4a06fd245231923de00887d4688 Mon Sep 17 00:00:00 2001 From: Fredrik Strand Oseberg Date: Mon, 22 Jan 2024 13:14:27 +0100 Subject: [PATCH] feat: add option to use variants with feedback (#5986) This PR will allow us to use a feature flag with variants to control whether or not we should show the comments field of the feedback form. This will allow us to see whether we can increase feedback collection if we reduce the load on the customer. --- .../feedbackNew/FeedbackComponent.tsx | 143 ++++++++++++------ frontend/src/interfaces/uiConfig.ts | 1 + .../__snapshots__/create-config.test.ts.snap | 8 + src/lib/routes/admin-api/config.ts | 1 + src/lib/types/experimental.ts | 16 +- 5 files changed, 124 insertions(+), 45 deletions(-) diff --git a/frontend/src/component/feedbackNew/FeedbackComponent.tsx b/frontend/src/component/feedbackNew/FeedbackComponent.tsx index 41aeaa0522..28db21f045 100644 --- a/frontend/src/component/feedbackNew/FeedbackComponent.tsx +++ b/frontend/src/component/feedbackNew/FeedbackComponent.tsx @@ -20,6 +20,7 @@ import { IToast } from 'interfaces/toast'; import { useTheme } from '@mui/material/styles'; import { FeedbackData, FeedbackMode } from './FeedbackContext'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; +import { useUiFlag } from 'hooks/useUiFlag'; export const ParentContainer = styled('div')(({ theme }) => ({ position: 'relative', @@ -206,6 +207,7 @@ export const FeedbackComponent = ({ const { setHasSubmittedFeedback } = useUserSubmittedFeedback( feedbackData.category, ); + const feedbackComments = useUiFlag('feedbackComments'); function isProvideFeedbackSchema(data: any): data is ProvideFeedbackSchema { data.difficultyScore = data.difficultyScore @@ -349,50 +351,103 @@ export const FeedbackComponent = ({ - - - {feedbackData.positiveLabel} - - - - - - { - feedbackData.areasForImprovementsLabel - } - - - + + {feedbackComments !== false && + feedbackComments.enabled && + feedbackComments.name === + 'withoutComments' ? ( + <> + + + + + + ) : ( + <> + + + {feedbackData.positiveLabel} + + + + + + { + feedbackData.areasForImprovementsLabel + } + + + + + )} + ; @@ -208,6 +209,19 @@ const flags: IFlags = { process.env.UNLEASH_EXPERIMENTAL_EXECUTIVE_DASHBOARD, false, ), + feedbackComments: { + name: 'feedbackComments', + enabled: parseEnvVarBoolean( + process.env.UNLEASH_EXPERIMENTAL_FEEDBACK_COMMENTS, + false, + ), + payload: { + type: PayloadType.JSON, + value: + process.env.UNLEASH_EXPERIMENTAL_FEEDBACK_COMMENTS_PAYLOAD ?? + '', + }, + }, }; export const defaultExperimentalOptions: IExperimentalOptions = {