mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: strategy variants events (#4430)
This commit is contained in:
		
							parent
							
								
									43935932d9
								
							
						
					
					
						commit
						4914cd07e3
					
				@ -32,6 +32,7 @@ import { useHasProjectEnvironmentAccess } from 'hooks/useHasAccess';
 | 
				
			|||||||
import { FeatureStrategyTitle } from './FeatureStrategyTitle/FeatureStrategyTitle';
 | 
					import { FeatureStrategyTitle } from './FeatureStrategyTitle/FeatureStrategyTitle';
 | 
				
			||||||
import { FeatureStrategyEnabledDisabled } from './FeatureStrategyEnabledDisabled/FeatureStrategyEnabledDisabled';
 | 
					import { FeatureStrategyEnabledDisabled } from './FeatureStrategyEnabledDisabled/FeatureStrategyEnabledDisabled';
 | 
				
			||||||
import { StrategyVariants } from 'component/feature/StrategyTypes/StrategyVariants';
 | 
					import { StrategyVariants } from 'component/feature/StrategyTypes/StrategyVariants';
 | 
				
			||||||
 | 
					import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IFeatureStrategyFormProps {
 | 
					interface IFeatureStrategyFormProps {
 | 
				
			||||||
    feature: IFeatureToggle;
 | 
					    feature: IFeatureToggle;
 | 
				
			||||||
@ -86,6 +87,7 @@ export const FeatureStrategyForm = ({
 | 
				
			|||||||
    errors,
 | 
					    errors,
 | 
				
			||||||
    isChangeRequest,
 | 
					    isChangeRequest,
 | 
				
			||||||
}: IFeatureStrategyFormProps) => {
 | 
					}: IFeatureStrategyFormProps) => {
 | 
				
			||||||
 | 
					    const { trackEvent } = usePlausibleTracker();
 | 
				
			||||||
    const [showProdGuard, setShowProdGuard] = useState(false);
 | 
					    const [showProdGuard, setShowProdGuard] = useState(false);
 | 
				
			||||||
    const hasValidConstraints = useConstraintsValidation(strategy.constraints);
 | 
					    const hasValidConstraints = useConstraintsValidation(strategy.constraints);
 | 
				
			||||||
    const enableProdGuard = useFeatureStrategyProdGuard(feature, environmentId);
 | 
					    const enableProdGuard = useFeatureStrategyProdGuard(feature, environmentId);
 | 
				
			||||||
@ -158,6 +160,13 @@ export const FeatureStrategyForm = ({
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const onSubmitWithValidation = async (event: React.FormEvent) => {
 | 
					    const onSubmitWithValidation = async (event: React.FormEvent) => {
 | 
				
			||||||
 | 
					        if (Array.isArray(strategy.variants) && strategy.variants?.length > 0) {
 | 
				
			||||||
 | 
					            trackEvent('strategy-variants', {
 | 
				
			||||||
 | 
					                props: {
 | 
				
			||||||
 | 
					                    eventType: 'submitted',
 | 
				
			||||||
 | 
					                },
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        event.preventDefault();
 | 
					        event.preventDefault();
 | 
				
			||||||
        if (!validateAllParameters()) {
 | 
					        if (!validateAllParameters()) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
 | 
				
			|||||||
@ -6,13 +6,12 @@ import PermissionButton from '../../common/PermissionButton/PermissionButton';
 | 
				
			|||||||
import { UPDATE_FEATURE_ENVIRONMENT_VARIANTS } from '../../providers/AccessProvider/permissions';
 | 
					import { UPDATE_FEATURE_ENVIRONMENT_VARIANTS } from '../../providers/AccessProvider/permissions';
 | 
				
			||||||
import { v4 as uuidv4 } from 'uuid';
 | 
					import { v4 as uuidv4 } from 'uuid';
 | 
				
			||||||
import { WeightType } from '../../../constants/variantTypes';
 | 
					import { WeightType } from '../../../constants/variantTypes';
 | 
				
			||||||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
 | 
					 | 
				
			||||||
import { Link, styled, Typography, useTheme } from '@mui/material';
 | 
					import { Link, styled, Typography, useTheme } from '@mui/material';
 | 
				
			||||||
import { useRequiredQueryParam } from 'hooks/useRequiredQueryParam';
 | 
					 | 
				
			||||||
import { IFeatureStrategy } from 'interfaces/strategy';
 | 
					import { IFeatureStrategy } from 'interfaces/strategy';
 | 
				
			||||||
import SplitPreviewSlider from './SplitPreviewSlider/SplitPreviewSlider';
 | 
					import SplitPreviewSlider from './SplitPreviewSlider/SplitPreviewSlider';
 | 
				
			||||||
import { HelpIcon } from '../../common/HelpIcon/HelpIcon';
 | 
					import { HelpIcon } from '../../common/HelpIcon/HelpIcon';
 | 
				
			||||||
import { StrategyVariantsUpgradeAlert } from '../../common/StrategyVariantsUpgradeAlert/StrategyVariantsUpgradeAlert';
 | 
					import { StrategyVariantsUpgradeAlert } from '../../common/StrategyVariantsUpgradeAlert/StrategyVariantsUpgradeAlert';
 | 
				
			||||||
 | 
					import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const StyledVariantForms = styled('div')({
 | 
					const StyledVariantForms = styled('div')({
 | 
				
			||||||
    display: 'flex',
 | 
					    display: 'flex',
 | 
				
			||||||
@ -27,6 +26,7 @@ export const StrategyVariants: FC<{
 | 
				
			|||||||
    projectId: string;
 | 
					    projectId: string;
 | 
				
			||||||
    environment: string;
 | 
					    environment: string;
 | 
				
			||||||
}> = ({ strategy, setStrategy, projectId, environment }) => {
 | 
					}> = ({ strategy, setStrategy, projectId, environment }) => {
 | 
				
			||||||
 | 
					    const { trackEvent } = usePlausibleTracker();
 | 
				
			||||||
    const [variantsEdit, setVariantsEdit] = useState<IFeatureVariantEdit[]>([]);
 | 
					    const [variantsEdit, setVariantsEdit] = useState<IFeatureVariantEdit[]>([]);
 | 
				
			||||||
    const theme = useTheme();
 | 
					    const theme = useTheme();
 | 
				
			||||||
    const stickiness =
 | 
					    const stickiness =
 | 
				
			||||||
@ -84,6 +84,11 @@ export const StrategyVariants: FC<{
 | 
				
			|||||||
                id,
 | 
					                id,
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
 | 
					        trackEvent('strategy-variants', {
 | 
				
			||||||
 | 
					            props: {
 | 
				
			||||||
 | 
					                eventType: 'variant added',
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
 | 
				
			|||||||
@ -41,7 +41,8 @@ export type CustomEvents =
 | 
				
			|||||||
    | 'segment-usage'
 | 
					    | 'segment-usage'
 | 
				
			||||||
    | 'strategy-add'
 | 
					    | 'strategy-add'
 | 
				
			||||||
    | 'playground'
 | 
					    | 'playground'
 | 
				
			||||||
    | 'feature-type-edit';
 | 
					    | 'feature-type-edit'
 | 
				
			||||||
 | 
					    | 'strategy-variants';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const usePlausibleTracker = () => {
 | 
					export const usePlausibleTracker = () => {
 | 
				
			||||||
    const plausible = useContext(PlausibleContext);
 | 
					    const plausible = useContext(PlausibleContext);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user