mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Tracking for default strategy (#3800)
This commit is contained in:
		
							parent
							
								
									896b63616d
								
							
						
					
					
						commit
						d1c3be3b9e
					
				| @ -42,45 +42,8 @@ const EditDefaultStrategy = ({ strategy }: EditDefaultStrategyProps) => { | |||||||
|     const { unleashUrl } = uiConfig; |     const { unleashUrl } = uiConfig; | ||||||
|     const navigate = useNavigate(); |     const navigate = useNavigate(); | ||||||
| 
 | 
 | ||||||
|     const [previousTitle] = useState<string>(''); |  | ||||||
|     const { trackEvent } = usePlausibleTracker(); |     const { trackEvent } = usePlausibleTracker(); | ||||||
| 
 | 
 | ||||||
|     const trackTitle = (title: string = '') => { |  | ||||||
|         // don't expose the title, just if it was added, removed, or edited
 |  | ||||||
|         if (title === previousTitle) { |  | ||||||
|             trackEvent('strategyTitle', { |  | ||||||
|                 props: { |  | ||||||
|                     action: 'none', |  | ||||||
|                     on: 'edit', |  | ||||||
|                 }, |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|         if (previousTitle === '' && title !== '') { |  | ||||||
|             trackEvent('strategyTitle', { |  | ||||||
|                 props: { |  | ||||||
|                     action: 'added', |  | ||||||
|                     on: 'edit', |  | ||||||
|                 }, |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|         if (previousTitle !== '' && title === '') { |  | ||||||
|             trackEvent('strategyTitle', { |  | ||||||
|                 props: { |  | ||||||
|                     action: 'removed', |  | ||||||
|                     on: 'edit', |  | ||||||
|                 }, |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|         if (previousTitle !== '' && title !== '' && title !== previousTitle) { |  | ||||||
|             trackEvent('strategyTitle', { |  | ||||||
|                 props: { |  | ||||||
|                     action: 'edited', |  | ||||||
|                     on: 'edit', |  | ||||||
|                 }, |  | ||||||
|             }); |  | ||||||
|         } |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     const { |     const { | ||||||
|         segments: allSegments, |         segments: allSegments, | ||||||
|         refetchSegments: refetchSavedStrategySegments, |         refetchSegments: refetchSavedStrategySegments, | ||||||
| @ -110,10 +73,12 @@ const EditDefaultStrategy = ({ strategy }: EditDefaultStrategyProps) => { | |||||||
|     ) => { |     ) => { | ||||||
|         await updateDefaultStrategy(projectId, environmentId, payload); |         await updateDefaultStrategy(projectId, environmentId, payload); | ||||||
| 
 | 
 | ||||||
|         if (uiConfig?.flags?.strategyImprovements && strategy.title) { |         trackEvent('default_strategy', { | ||||||
|             // NOTE: remove tracking when feature flag is removed
 |             props: { | ||||||
|             trackTitle(strategy.title); |                 action: 'edit', | ||||||
|         } |                 hasTitle: Boolean(payload.title), | ||||||
|  |             }, | ||||||
|  |         }); | ||||||
| 
 | 
 | ||||||
|         await refetchSavedStrategySegments(); |         await refetchSavedStrategySegments(); | ||||||
|         setToastData({ |         setToastData({ | ||||||
|  | |||||||
| @ -25,7 +25,8 @@ export type CustomEvents = | |||||||
|     | 'notifications' |     | 'notifications' | ||||||
|     | 'batch_operations' |     | 'batch_operations' | ||||||
|     | 'strategyTitle' |     | 'strategyTitle' | ||||||
|     | 'demo'; |     | 'demo' | ||||||
|  |     | 'default_strategy'; | ||||||
| 
 | 
 | ||||||
| export const usePlausibleTracker = () => { | export const usePlausibleTracker = () => { | ||||||
|     const plausible = useContext(PlausibleContext); |     const plausible = useContext(PlausibleContext); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user