refactor: move computed methods to aiMixin

This commit is contained in:
Shivam Mishra
2023-07-10 15:04:08 +05:30
parent fe87285a30
commit 43de536475
2 changed files with 37 additions and 30 deletions
@@ -0,0 +1,34 @@
import { mapGetters } from 'vuex';
import { OPEN_AI_EVENTS } from '../helper/AnalyticsHelper/events';
export default {
mounted() {
if (!this.appIntegrations.length) {
this.$store.dispatch('integrations/get');
}
},
computed: {
...mapGetters({ appIntegrations: 'integrations/getAppIntegrations' }),
isAIIntegrationEnabled() {
return this.appIntegrations.find(
integration => integration.id === 'openai' && !!integration.hooks.length
);
},
hookId() {
return this.appIntegrations.find(
integration => integration.id === 'openai' && !!integration.hooks.length
).hooks[0].id;
},
},
methods: {
async recordAnalytics(type, payload) {
const event = OPEN_AI_EVENTS[type.toUpperCase()];
if (event) {
this.$track(event, {
type,
...payload,
});
}
},
},
};