@@ -48,22 +48,18 @@ import { featureFlagLogic as enabledFeaturesLogic } from 'lib/logic/featureFlagL
4848import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
4949import { Label } from 'lib/ui/Label/Label'
5050import { capitalizeFirstLetter } from 'lib/utils'
51- import { addProductIntent } from 'lib/utils/product-intents'
5251import { FeatureFlagPermissions } from 'scenes/FeatureFlagPermissions'
5352import { Dashboard } from 'scenes/dashboard/Dashboard'
5453import { EmptyDashboardComponent } from 'scenes/dashboard/EmptyDashboardComponent'
5554import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
5655import { UTM_TAGS } from 'scenes/feature-flags/FeatureFlagSnippets'
5756import { JSONEditorInput } from 'scenes/feature-flags/JSONEditorInput'
58- import { useMaxTool } from 'scenes/max/useMaxTool'
5957import { SceneExport } from 'scenes/sceneTypes'
60- import { SURVEY_CREATED_SOURCE } from 'scenes/surveys/constants'
61- import { captureMaxAISurveyCreationException } from 'scenes/surveys/utils'
58+ import { QuickSurveyModal } from 'scenes/surveys/QuickSurveyModal'
6259import { teamLogic } from 'scenes/teamLogic'
6360import { urls } from 'scenes/urls'
6461import { userLogic } from 'scenes/userLogic'
6562
66- import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
6763import {
6864 ScenePanel ,
6965 ScenePanelActionsSection ,
@@ -101,6 +97,7 @@ import { FeatureFlagAutoRollback } from './FeatureFlagAutoRollout'
10197import { FeatureFlagCodeExample } from './FeatureFlagCodeExample'
10298import { FeatureFlagConditionWarning } from './FeatureFlagConditionWarning'
10399import { FeatureFlagEvaluationTags } from './FeatureFlagEvaluationTags'
100+ import { FeedbackTab } from './FeatureFlagFeedbackTab'
104101import FeatureFlagProjects from './FeatureFlagProjects'
105102import { FeatureFlagReleaseConditions } from './FeatureFlagReleaseConditions'
106103import FeatureFlagSchedule from './FeatureFlagSchedule'
@@ -112,85 +109,6 @@ import { FeatureFlagsTab, featureFlagsLogic } from './featureFlagsLogic'
112109
113110const RESOURCE_TYPE = 'feature_flag'
114111
115- // Utility function to create MaxTool configuration for feature flag survey creation
116- export function createMaxToolSurveyConfig (
117- featureFlag : FeatureFlagType ,
118- user : any ,
119- multivariateEnabled : boolean ,
120- variants : any [ ]
121- ) : {
122- identifier : 'create_survey'
123- active : boolean
124- initialMaxPrompt : string
125- suggestions : string [ ]
126- context : Record < string , any >
127- contextDescription : {
128- text : string
129- icon : JSX . Element
130- }
131- callback : ( toolOutput : { survey_id ?: string ; survey_name ?: string ; error ?: string } ) => void
132- } {
133- return {
134- identifier : 'create_survey' as const ,
135- active : Boolean ( user ?. uuid ) ,
136- initialMaxPrompt : `Create a survey to collect feedback about the "${ featureFlag . key } " feature flag${ featureFlag . name ? ` (${ featureFlag . name } )` : '' } ${ multivariateEnabled && variants ?. length > 0 ? ` which has variants: ${ variants . map ( ( v ) => `"${ v . key } "` ) . join ( ', ' ) } ` : '' } ` ,
137- suggestions :
138- multivariateEnabled && variants ?. length > 0
139- ? [
140- `Create a feedback survey comparing variants of the "${ featureFlag . key } " feature flag` ,
141- `Create a survey for users who saw the "${ variants [ 0 ] ?. key } " variant of the "${ featureFlag . key } " feature flag` ,
142- `Create an A/B test survey asking users to compare the "${ featureFlag . key } " feature flag variants` ,
143- `Create a survey to understand which variant of the "${ featureFlag . key } " feature flag performs better` ,
144- `Create a survey targeting all variants of the "${ featureFlag . key } " feature flag to gather overall feedback` ,
145- ]
146- : [
147- `Create a feedback survey for users who see the "${ featureFlag . key } " feature flag` ,
148- `Create an NPS survey for users exposed to the "${ featureFlag . key } " feature flag` ,
149- `Create a satisfaction survey asking about the "${ featureFlag . key } " feature flag experience` ,
150- `Create a survey to understand user reactions to the "${ featureFlag . key } " feature flag` ,
151- ] ,
152- context : {
153- feature_flag_key : featureFlag . key ,
154- feature_flag_id : featureFlag . id ,
155- feature_flag_name : featureFlag . name ,
156- target_feature_flag : featureFlag . key ,
157- survey_purpose : 'collect_feedback_for_feature_flag' ,
158- is_multivariate : multivariateEnabled ,
159- variants :
160- multivariateEnabled && variants ?. length > 0
161- ? variants . map ( ( v ) => ( {
162- key : v . key ,
163- name : v . name || '' ,
164- rollout_percentage : v . rollout_percentage ,
165- } ) )
166- : [ ] ,
167- variant_count : variants ?. length || 0 ,
168- } ,
169- contextDescription : {
170- text : featureFlag . name ,
171- icon : iconForType ( 'feature_flag' ) ,
172- } ,
173- callback : ( toolOutput : { survey_id ?: string ; survey_name ?: string ; error ?: string } ) => {
174- addProductIntent ( {
175- product_type : ProductKey . SURVEYS ,
176- intent_context : ProductIntentContext . SURVEY_CREATED ,
177- metadata : {
178- survey_id : toolOutput . survey_id ,
179- source : SURVEY_CREATED_SOURCE . FEATURE_FLAGS ,
180- created_successfully : ! toolOutput ?. error ,
181- } ,
182- } )
183-
184- if ( toolOutput ?. error || ! toolOutput ?. survey_id ) {
185- return captureMaxAISurveyCreationException ( toolOutput . error , SURVEY_CREATED_SOURCE . FEATURE_FLAGS )
186- }
187-
188- // Redirect to the new survey
189- router . actions . push ( urls . survey ( toolOutput . survey_id ) )
190- } ,
191- }
192- }
193-
194112export const scene : SceneExport < FeatureFlagLogicProps > = {
195113 component : FeatureFlag ,
196114 logic : featureFlagLogic ,
@@ -209,8 +127,6 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
209127 isEditingFlag,
210128 activeTab,
211129 accessDeniedToFeatureFlag,
212- multivariateEnabled,
213- variants,
214130 experiment,
215131 } = useValues ( featureFlagLogic )
216132 const { featureFlags } = useValues ( enabledFeaturesLogic )
@@ -229,14 +145,13 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
229145 const { earlyAccessFeaturesList } = useValues ( featureFlagLogic )
230146
231147 const { tags } = useValues ( tagsModel )
232- const { hasAvailableFeature, user } = useValues ( userLogic )
148+ const { hasAvailableFeature } = useValues ( userLogic )
233149 const { currentTeamId } = useValues ( teamLogic )
234150
235151 // whether the key for an existing flag is being changed
236152 const [ hasKeyChanged , setHasKeyChanged ] = useState ( false )
237153
238- // Initialize MaxTool hook for survey creation
239- const { openMax } = useMaxTool ( createMaxToolSurveyConfig ( featureFlag , user , multivariateEnabled , variants ) )
154+ const [ isQuickSurveyModalOpen , setIsQuickSurveyModalOpen ] = useState ( false )
240155
241156 const [ advancedSettingsExpanded , setAdvancedSettingsExpanded ] = useState ( false )
242157
@@ -340,7 +255,7 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
340255 label : (
341256 < div className = "flex flex-row" >
342257 < div > Analysis</ div >
343- < LemonTag className = "ml-1 float-right uppercase" type = "warning" >
258+ < LemonTag className = "ml-2 float-right uppercase" type = "warning" >
344259 { ' ' }
345260 Beta
346261 </ LemonTag >
@@ -371,6 +286,22 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
371286 } )
372287 }
373288
289+ if ( featureFlags [ FEATURE_FLAGS . SURVEYS_FF_CROSS_SELL ] ) {
290+ tabs . push ( {
291+ label : (
292+ < div className = "flex flex-row" >
293+ < div > User feedback</ div >
294+ < LemonTag className = "ml-2 float-right uppercase" type = "primary" >
295+ { ' ' }
296+ New
297+ </ LemonTag >
298+ </ div >
299+ ) ,
300+ key : FeatureFlagsTab . FEEDBACK ,
301+ content : < FeedbackTab featureFlag = { featureFlag } /> ,
302+ } )
303+ }
304+
374305 return (
375306 < >
376307 < div className = "feature-flag" >
@@ -820,16 +751,14 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
820751 Create cohort
821752 </ ButtonPrimitive >
822753 ) }
823- { openMax && (
824- < ButtonPrimitive
825- menuItem
826- data-attr = { `${ RESOURCE_TYPE } -create-survey` }
827- onClick = { ( ) => openMax ( ) }
828- >
829- < IconPlusSmall />
830- Create survey
831- </ ButtonPrimitive >
832- ) }
754+ < ButtonPrimitive
755+ menuItem
756+ data-attr = { `${ RESOURCE_TYPE } -create-survey` }
757+ onClick = { ( ) => setIsQuickSurveyModalOpen ( true ) }
758+ >
759+ < IconPlusSmall />
760+ Create survey
761+ </ ButtonPrimitive >
833762 </ ScenePanelActionsSection >
834763 < ScenePanelDivider />
835764 < ScenePanelActionsSection >
@@ -926,6 +855,11 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
926855 </ >
927856 ) }
928857 </ div >
858+ < QuickSurveyModal
859+ flag = { featureFlag }
860+ isOpen = { isQuickSurveyModalOpen }
861+ onClose = { ( ) => setIsQuickSurveyModalOpen ( false ) }
862+ />
929863 </ >
930864 )
931865}
0 commit comments