feat(editor): Migrate debounce mixin to useDebounce composable (no-changelog) (#8244)

This commit is contained in:
Alex Grozav
2024-01-08 14:00:49 +02:00
committed by GitHub
parent 8affdf680d
commit 8c8caac4e8
19 changed files with 136 additions and 106 deletions

View File

@@ -8,7 +8,7 @@ import { useSettingsStore } from '@/stores/settings.store';
import type { FeatureFlags, IDataObject } from 'n8n-workflow';
import { EXPERIMENTS_TO_TRACK, LOCAL_STORAGE_EXPERIMENT_OVERRIDES } from '@/constants';
import { useTelemetryStore } from './telemetry.store';
import { debounce } from 'lodash-es';
import { useDebounce } from '@/composables/useDebounce';
const EVENTS = {
IS_PART_OF_EXPERIMENT: 'User is part of experiment',
@@ -21,6 +21,7 @@ export const usePostHog = defineStore('posthog', () => {
const settingsStore = useSettingsStore();
const telemetryStore = useTelemetryStore();
const rootStore = useRootStore();
const { debounce } = useDebounce();
const featureFlags: Ref<FeatureFlags | null> = ref(null);
const trackedDemoExp: Ref<FeatureFlags> = ref({});
@@ -116,7 +117,9 @@ export const usePostHog = defineStore('posthog', () => {
const trackExperiments = (featFlags: FeatureFlags) => {
EXPERIMENTS_TO_TRACK.forEach((name) => trackExperiment(featFlags, name));
};
const trackExperimentsDebounced = debounce(trackExperiments, 2000);
const trackExperimentsDebounced = debounce(trackExperiments, {
debounceTime: 2000,
});
const init = (evaluatedFeatureFlags?: FeatureFlags) => {
if (!window.posthog) {