diff --git a/frontend/libs/console/legacy-ce/src/lib/features/FeatureFlags/hooks/useSetFeatureFlagEnabled.ts b/frontend/libs/console/legacy-ce/src/lib/features/FeatureFlags/hooks/useSetFeatureFlagEnabled.ts index 091cd627f6e..5721c57fb78 100644 --- a/frontend/libs/console/legacy-ce/src/lib/features/FeatureFlags/hooks/useSetFeatureFlagEnabled.ts +++ b/frontend/libs/console/legacy-ce/src/lib/features/FeatureFlags/hooks/useSetFeatureFlagEnabled.ts @@ -1,6 +1,8 @@ import { useMutation, useQueryClient } from 'react-query'; import { FeatureFlagId, useFeatureFlags } from '@/features/FeatureFlags'; import { saveFeatureFlagsStateToLocalStorage } from '../utils'; +import { sendTelemetryEvent, SetFeatureFlagEvent } from '@/telemetry'; +import { availableFeatureFlags } from '@/features/FeatureFlags/availableFeatureFlags'; export function useSetFeatureFlagEnabled() { const queryClient = useQueryClient(); @@ -17,6 +19,18 @@ export function useSetFeatureFlagEnabled() { if (isError || isLoading || !data) { throw new Error('Feature flags not loaded'); } + + const setFeatureFlagEvent: SetFeatureFlagEvent = { + type: 'SET_FEATURE_FLAG', + data: { + feature_flag: + availableFeatureFlags.find(x => x.id === flagId)?.title || + 'Unknown', + value: newState, + }, + }; + sendTelemetryEvent(setFeatureFlagEvent); + const newFlags = data.map(item => { if (item.id !== flagId) { return item; diff --git a/frontend/libs/console/legacy-ce/src/lib/telemetry/index.ts b/frontend/libs/console/legacy-ce/src/lib/telemetry/index.ts index 834ffb41f39..d90528f49a6 100644 --- a/frontend/libs/console/legacy-ce/src/lib/telemetry/index.ts +++ b/frontend/libs/console/legacy-ce/src/lib/telemetry/index.ts @@ -20,7 +20,18 @@ export type ConnectDBEvent = { }; }; -export type TelemetryEvent = RunTimeErrorEvent | ConnectDBEvent; +export type SetFeatureFlagEvent = { + type: 'SET_FEATURE_FLAG'; + data: { + feature_flag: string; + value: boolean; + }; +}; + +export type TelemetryEvent = + | RunTimeErrorEvent + | ConnectDBEvent + | SetFeatureFlagEvent; export type TelemetryPayload = { server_version: string;