@@ -48,22 +48,19 @@ 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 { ProductIntentContext , addProductIntent } from 'lib/utils/product-intents'
51+ import { ProductIntentContext } from 'lib/utils/product-intents'
5252import { FeatureFlagPermissions } from 'scenes/FeatureFlagPermissions'
5353import { Dashboard } from 'scenes/dashboard/Dashboard'
5454import { EmptyDashboardComponent } from 'scenes/dashboard/EmptyDashboardComponent'
5555import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
5656import { UTM_TAGS } from 'scenes/feature-flags/FeatureFlagSnippets'
5757import { JSONEditorInput } from 'scenes/feature-flags/JSONEditorInput'
58- import { useMaxTool } from 'scenes/max/useMaxTool'
5958import { SceneExport } from 'scenes/sceneTypes'
60- import { SURVEY_CREATED_SOURCE } from 'scenes/surveys/constants'
61- import { captureMaxAISurveyCreationException } from 'scenes/surveys/utils'
59+ import { QuickSurveyModal } from 'scenes/surveys/QuickSurveyModal'
6260import { teamLogic } from 'scenes/teamLogic'
6361import { urls } from 'scenes/urls'
6462import { userLogic } from 'scenes/userLogic'
6563
66- import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
6764import {
6865 ScenePanel ,
6966 ScenePanelActionsSection ,
@@ -101,6 +98,7 @@ import { FeatureFlagAutoRollback } from './FeatureFlagAutoRollout'
10198import { FeatureFlagCodeExample } from './FeatureFlagCodeExample'
10299import { FeatureFlagConditionWarning } from './FeatureFlagConditionWarning'
103100import { FeatureFlagEvaluationTags } from './FeatureFlagEvaluationTags'
101+ import { FeedbackTab } from './FeatureFlagFeedbackTab'
104102import FeatureFlagProjects from './FeatureFlagProjects'
105103import { FeatureFlagReleaseConditions } from './FeatureFlagReleaseConditions'
106104import FeatureFlagSchedule from './FeatureFlagSchedule'
@@ -112,85 +110,6 @@ import { FeatureFlagsTab, featureFlagsLogic } from './featureFlagsLogic'
112110
113111const RESOURCE_TYPE = 'feature_flag'
114112
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-
194113export const scene : SceneExport < FeatureFlagLogicProps > = {
195114 component : FeatureFlag ,
196115 logic : featureFlagLogic ,
@@ -209,8 +128,6 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
209128 isEditingFlag,
210129 activeTab,
211130 accessDeniedToFeatureFlag,
212- multivariateEnabled,
213- variants,
214131 experiment,
215132 } = useValues ( featureFlagLogic )
216133 const { featureFlags } = useValues ( enabledFeaturesLogic )
@@ -229,14 +146,13 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
229146 const { earlyAccessFeaturesList } = useValues ( featureFlagLogic )
230147
231148 const { tags } = useValues ( tagsModel )
232- const { hasAvailableFeature, user } = useValues ( userLogic )
149+ const { hasAvailableFeature } = useValues ( userLogic )
233150 const { currentTeamId } = useValues ( teamLogic )
234151
235152 // whether the key for an existing flag is being changed
236153 const [ hasKeyChanged , setHasKeyChanged ] = useState ( false )
237154
238- // Initialize MaxTool hook for survey creation
239- const { openMax } = useMaxTool ( createMaxToolSurveyConfig ( featureFlag , user , multivariateEnabled , variants ) )
155+ const [ isQuickSurveyModalOpen , setIsQuickSurveyModalOpen ] = useState ( false )
240156
241157 const [ advancedSettingsExpanded , setAdvancedSettingsExpanded ] = useState ( false )
242158
@@ -340,7 +256,7 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
340256 label : (
341257 < div className = "flex flex-row" >
342258 < div > Analysis</ div >
343- < LemonTag className = "ml-1 float-right uppercase" type = "warning" >
259+ < LemonTag className = "ml-2 float-right uppercase" type = "warning" >
344260 { ' ' }
345261 Beta
346262 </ LemonTag >
@@ -371,6 +287,22 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
371287 } )
372288 }
373289
290+ if ( featureFlags [ FEATURE_FLAGS . SURVEYS_FF_CROSS_SELL ] ) {
291+ tabs . push ( {
292+ label : (
293+ < div className = "flex flex-row" >
294+ < div > User feedback</ div >
295+ < LemonTag className = "ml-2 float-right uppercase" type = "primary" >
296+ { ' ' }
297+ New
298+ </ LemonTag >
299+ </ div >
300+ ) ,
301+ key : FeatureFlagsTab . FEEDBACK ,
302+ content : < FeedbackTab featureFlag = { featureFlag } /> ,
303+ } )
304+ }
305+
374306 return (
375307 < >
376308 < div className = "feature-flag" >
@@ -820,16 +752,14 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
820752 Create cohort
821753 </ ButtonPrimitive >
822754 ) }
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- ) }
755+ < ButtonPrimitive
756+ menuItem
757+ data-attr = { `${ RESOURCE_TYPE } -create-survey` }
758+ onClick = { ( ) => setIsQuickSurveyModalOpen ( true ) }
759+ >
760+ < IconPlusSmall />
761+ Create survey
762+ </ ButtonPrimitive >
833763 </ ScenePanelActionsSection >
834764 < ScenePanelDivider />
835765 < ScenePanelActionsSection >
@@ -926,6 +856,11 @@ export function FeatureFlag({ id }: FeatureFlagLogicProps): JSX.Element {
926856 </ >
927857 ) }
928858 </ div >
859+ < QuickSurveyModal
860+ flag = { featureFlag }
861+ isOpen = { isQuickSurveyModalOpen }
862+ onClose = { ( ) => setIsQuickSurveyModalOpen ( false ) }
863+ />
929864 </ >
930865 )
931866}
0 commit comments