mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-16 01:24:05 -08:00
62c096710f
- Fix autofixable violations - Remove unused directives - Allow for PascalCased variables - needed for dynamically imported or assigned classes, decorators, routers, etc.
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 { externalHooks } from '@/mixins/externalHooks';
|
|
|
|
export default defineComponent({
|
|
name: 'Telemetry',
|
|
mixins: [externalHooks],
|
|
data() {
|
|
return {
|
|
isTelemetryInitialized: false,
|
|
};
|
|
},
|
|
computed: {
|
|
...mapStores(useRootStore, useSettingsStore, useUsersStore),
|
|
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;
|
|
},
|
|
},
|
|
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,
|
|
versionCli: this.rootStore.versionCli,
|
|
});
|
|
|
|
this.isTelemetryInitialized = true;
|
|
},
|
|
},
|
|
watch: {
|
|
telemetry() {
|
|
this.init();
|
|
},
|
|
currentUserId(userId) {
|
|
if (this.isTelemetryEnabled) {
|
|
this.$telemetry.identify(this.rootStore.instanceId, userId);
|
|
}
|
|
},
|
|
isTelemetryEnabledOnRoute(enabled) {
|
|
if (enabled) {
|
|
this.init();
|
|
}
|
|
},
|
|
},
|
|
});
|
|
</script>
|