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 navigate = useNavigate();
 | 
			
		||||
 | 
			
		||||
    const [previousTitle] = useState<string>('');
 | 
			
		||||
    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 {
 | 
			
		||||
        segments: allSegments,
 | 
			
		||||
        refetchSegments: refetchSavedStrategySegments,
 | 
			
		||||
@ -110,10 +73,12 @@ const EditDefaultStrategy = ({ strategy }: EditDefaultStrategyProps) => {
 | 
			
		||||
    ) => {
 | 
			
		||||
        await updateDefaultStrategy(projectId, environmentId, payload);
 | 
			
		||||
 | 
			
		||||
        if (uiConfig?.flags?.strategyImprovements && strategy.title) {
 | 
			
		||||
            // NOTE: remove tracking when feature flag is removed
 | 
			
		||||
            trackTitle(strategy.title);
 | 
			
		||||
        }
 | 
			
		||||
        trackEvent('default_strategy', {
 | 
			
		||||
            props: {
 | 
			
		||||
                action: 'edit',
 | 
			
		||||
                hasTitle: Boolean(payload.title),
 | 
			
		||||
            },
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        await refetchSavedStrategySegments();
 | 
			
		||||
        setToastData({
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,8 @@ export type CustomEvents =
 | 
			
		||||
    | 'notifications'
 | 
			
		||||
    | 'batch_operations'
 | 
			
		||||
    | 'strategyTitle'
 | 
			
		||||
    | 'demo';
 | 
			
		||||
    | 'demo'
 | 
			
		||||
    | 'default_strategy';
 | 
			
		||||
 | 
			
		||||
export const usePlausibleTracker = () => {
 | 
			
		||||
    const plausible = useContext(PlausibleContext);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user