feat: Add analytics event for OpenAI (#7074)
* Add analytics event for OpenAI * Add more variations
This commit is contained in:
@@ -74,6 +74,7 @@ import { mapGetters } from 'vuex';
|
|||||||
import { mixin as clickaway } from 'vue-clickaway';
|
import { mixin as clickaway } from 'vue-clickaway';
|
||||||
import OpenAPI from 'dashboard/api/integrations/openapi';
|
import OpenAPI from 'dashboard/api/integrations/openapi';
|
||||||
import alertMixin from 'shared/mixins/alertMixin';
|
import alertMixin from 'shared/mixins/alertMixin';
|
||||||
|
import { OPEN_AI_EVENTS } from 'dashboard/helper/AnalyticsHelper/events';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [alertMixin, clickaway],
|
mixins: [alertMixin, clickaway],
|
||||||
@@ -144,6 +145,15 @@ export default {
|
|||||||
closeDropdown() {
|
closeDropdown() {
|
||||||
this.showDropdown = false;
|
this.showDropdown = false;
|
||||||
},
|
},
|
||||||
|
async recordAnalytics({ type, tone }) {
|
||||||
|
const event = OPEN_AI_EVENTS[type.toUpperCase()];
|
||||||
|
if (event) {
|
||||||
|
this.$track(event, {
|
||||||
|
type,
|
||||||
|
tone,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
async processEvent(type = 'rephrase') {
|
async processEvent(type = 'rephrase') {
|
||||||
this.uiFlags[type] = true;
|
this.uiFlags[type] = true;
|
||||||
try {
|
try {
|
||||||
@@ -159,6 +169,7 @@ export default {
|
|||||||
} = result;
|
} = result;
|
||||||
this.$emit('replace-text', generatedMessage || this.message);
|
this.$emit('replace-text', generatedMessage || this.message);
|
||||||
this.closeDropdown();
|
this.closeDropdown();
|
||||||
|
this.recordAnalytics({ type, tone: this.activeTone });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.showAlert(this.$t('INTEGRATION_SETTINGS.OPEN_AI.GENERATE_ERROR'));
|
this.showAlert(this.$t('INTEGRATION_SETTINGS.OPEN_AI.GENERATE_ERROR'));
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -76,3 +76,9 @@ export const PORTALS_EVENTS = Object.freeze({
|
|||||||
DELETE_ARTICLE: 'Deleted an article',
|
DELETE_ARTICLE: 'Deleted an article',
|
||||||
PREVIEW_ARTICLE: 'Previewed article',
|
PREVIEW_ARTICLE: 'Previewed article',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const OPEN_AI_EVENTS = Object.freeze({
|
||||||
|
SUMMARIZE: 'OpenAI: Used summarize',
|
||||||
|
REPLY_SUGGESTION: 'OpenAI: Used reply suggestion',
|
||||||
|
REPHRASE: 'OpenAI: Used rephrase',
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user