mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
console: send telemetry event on feature flag enable/disable
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7948 GitOrigin-RevId: 0dbb12e0bd291249f447ac58968b63c960630c49
This commit is contained in:
parent
fc40739f62
commit
2e57bfe0ea
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user