Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: Val <68596159+valya@users.noreply.github.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> Co-authored-by: Valya Bullions <valya@n8n.io> Co-authored-by: Danny Martini <danny@n8n.io> Co-authored-by: Danny Martini <despair.blue@gmail.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: oleg <me@olegivaniv.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: Elias Meire <elias@meire.dev> Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Giulio Andreini <g.andreini@gmail.com> Co-authored-by: Ayato Hayashi <go12limchangyong@gmail.com>
75 lines
1.7 KiB
Vue
75 lines
1.7 KiB
Vue
<template>
|
|
<span v-show="false" />
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent } from 'vue';
|
|
import { mapStores } from 'pinia';
|
|
import { useRootStore } from '@/stores/n8nRoot.store';
|
|
import { useSettingsStore } from '@/stores/settings.store';
|
|
import { useUsersStore } from '@/stores/users.store';
|
|
import type { ITelemetrySettings } from 'n8n-workflow';
|
|
import { useProjectsStore } from '@/features/projects/projects.store';
|
|
|
|
export default defineComponent({
|
|
name: 'Telemetry',
|
|
data() {
|
|
return {
|
|
isTelemetryInitialized: false,
|
|
};
|
|
},
|
|
computed: {
|
|
...mapStores(useRootStore, useSettingsStore, useUsersStore, useProjectsStore),
|
|
currentUserId(): string {
|
|
return this.usersStore.currentUserId || '';
|
|
},
|
|
isTelemetryEnabledOnRoute(): boolean {
|
|
return this.$route.meta?.telemetry ? !this.$route.meta.telemetry.disabled : true;
|
|
},
|
|
telemetry(): ITelemetrySettings {
|
|
return this.settingsStore.telemetry;
|
|
},
|
|
isTelemetryEnabled(): boolean {
|
|
return !!this.telemetry?.enabled;
|
|
},
|
|
},
|
|
watch: {
|
|
telemetry() {
|
|
this.init();
|
|
},
|
|
currentUserId(userId) {
|
|
if (this.isTelemetryEnabled) {
|
|
this.$telemetry.identify(this.rootStore.instanceId, userId);
|
|
}
|
|
},
|
|
isTelemetryEnabledOnRoute(enabled) {
|
|
if (enabled) {
|
|
this.init();
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
this.init();
|
|
},
|
|
methods: {
|
|
init() {
|
|
if (
|
|
this.isTelemetryInitialized ||
|
|
!this.isTelemetryEnabledOnRoute ||
|
|
!this.isTelemetryEnabled
|
|
)
|
|
return;
|
|
|
|
this.$telemetry.init(this.telemetry, {
|
|
instanceId: this.rootStore.instanceId,
|
|
userId: this.currentUserId,
|
|
projectId: this.projectsStore.personalProject?.id,
|
|
versionCli: this.rootStore.versionCli,
|
|
});
|
|
|
|
this.isTelemetryInitialized = true;
|
|
},
|
|
},
|
|
});
|
|
</script>
|