n8n/packages/editor-ui/src/stores/telemetry.store.ts
Iván Ovejero d5c44987f4
refactor(editor): Add infix to Pinia stores (no-changelog) (#6149)
*  Add infix to Pinia stores

*  Fix paths in mocks

* 🐛 Fix import
2023-05-05 10:41:54 +02:00

23 lines
562 B
TypeScript

import type { Telemetry } from '@/plugins/telemetry';
import type { ITelemetryTrackProperties } from 'n8n-workflow';
import { defineStore } from 'pinia';
import type { Ref } from 'vue';
import { ref } from 'vue';
export const useTelemetryStore = defineStore('telemetry', () => {
const telemetry: Ref<Telemetry | undefined> = ref();
const init = (tel: Telemetry) => {
telemetry.value = tel;
};
const track = (event: string, properties?: ITelemetryTrackProperties) => {
telemetry.value?.track(event, properties);
};
return {
init,
track,
};
});