feat: more events tracking for SaaS (#6234)

This commit is contained in:
Shivam Mishra
2023-01-18 11:23:40 +05:30
committed by GitHub
parent 1df1b1f8e4
commit 37b9816827
40 changed files with 539 additions and 50 deletions

View File

@@ -1,6 +1,8 @@
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
import types from '../mutation-types';
import CampaignsAPI from '../../api/campaigns';
import AnalyticsHelper from '../../helper/AnalyticsHelper';
import { CAMPAIGNS_EVENTS } from '../../helper/AnalyticsHelper/events';
export const state = {
records: [],
@@ -51,6 +53,7 @@ export const actions = {
commit(types.SET_CAMPAIGN_UI_FLAG, { isUpdating: true });
try {
const response = await CampaignsAPI.update(id, updateObj);
AnalyticsHelper.track(CAMPAIGNS_EVENTS.UPDATE_CAMPAIGN);
commit(types.EDIT_CAMPAIGN, response.data);
} catch (error) {
throw new Error(error);
@@ -62,6 +65,7 @@ export const actions = {
commit(types.SET_CAMPAIGN_UI_FLAG, { isDeleting: true });
try {
await CampaignsAPI.delete(id);
AnalyticsHelper.track(CAMPAIGNS_EVENTS.DELETE_CAMPAIGN);
commit(types.DELETE_CAMPAIGN, id);
} catch (error) {
throw new Error(error);

View File

@@ -5,6 +5,8 @@ import {
import types from '../../mutation-types';
import ContactAPI from '../../../api/contacts';
import AccountActionsAPI from '../../../api/accountActions';
import AnalyticsHelper from '../../../helper/AnalyticsHelper';
import { CONTACTS_EVENTS } from '../../../helper/AnalyticsHelper/events';
const buildContactFormData = contactParams => {
const formData = new FormData();
@@ -104,6 +106,8 @@ export const actions = {
const response = await ContactAPI.create(
isFormData ? buildContactFormData(contactParams) : contactParams
);
AnalyticsHelper.track(CONTACTS_EVENTS.CREATE_CONTACT);
commit(types.SET_CONTACT_ITEM, response.data.payload.contact);
commit(types.SET_CONTACT_UI_FLAG, { isCreating: false });
} catch (error) {

View File

@@ -10,9 +10,8 @@ import {
isOnUnattendedView,
} from './helpers/actionHelpers';
import messageReadActions from './actions/messageReadActions';
import AnalyticsHelper, {
ANALYTICS_EVENTS,
} from '../../../helper/AnalyticsHelper';
import AnalyticsHelper from '../../../helper/AnalyticsHelper';
import { CONVERSATION_EVENTS } from '../../../helper/AnalyticsHelper/events';
// actions
const actions = {
getConversation: async ({ commit }, conversationId) => {
@@ -176,8 +175,8 @@ const actions = {
const response = await MessageApi.create(pendingMessage);
AnalyticsHelper.track(
pendingMessage.private
? ANALYTICS_EVENTS.SENT_PRIVATE_NOTE
: ANALYTICS_EVENTS.SENT_MESSAGE
? CONVERSATION_EVENTS.CONVERSATION.SENT_PRIVATE_NOTE
: CONVERSATION_EVENTS.CONVERSATION.SENT_MESSAGE
);
commit(types.ADD_MESSAGE, {
...response.data,

View File

@@ -2,6 +2,8 @@ import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
import types from '../mutation-types';
import CSATReports from '../../api/csatReports';
import { downloadCsvFile } from '../../helper/downloadHelper';
import AnalyticsHelper from '../../helper/AnalyticsHelper';
import { REPORTS_EVENTS } from '../../helper/AnalyticsHelper/events';
const computeDistribution = (value, total) =>
((value * 100) / total).toFixed(2);
@@ -111,6 +113,9 @@ export const actions = {
downloadCSATReports(_, params) {
return CSATReports.download(params).then(response => {
downloadCsvFile(params.fileName, response.data);
AnalyticsHelper.track(REPORTS_EVENTS.DOWNLOAD_REPORT, {
reportType: 'csat',
});
});
},
};

View File

@@ -6,9 +6,8 @@ import WebChannel from '../../api/channel/webChannel';
import FBChannel from '../../api/channel/fbChannel';
import TwilioChannel from '../../api/channel/twilioChannel';
import { throwErrorMessage } from '../utils/api';
import AnalyticsHelper, {
ANALYTICS_EVENTS,
} from '../../helper/AnalyticsHelper';
import AnalyticsHelper from '../../helper/AnalyticsHelper';
import { ACCOUNT_EVENTS } from '../../helper/AnalyticsHelper/events';
const buildInboxData = inboxParams => {
const formData = new FormData();
@@ -121,7 +120,7 @@ export const getters = {
};
const sendAnalyticsEvent = channelType => {
AnalyticsHelper.track(ANALYTICS_EVENTS.ADDED_AN_INBOX, {
AnalyticsHelper.track(ACCOUNT_EVENTS.ADDED_AN_INBOX, {
channelType,
});
};

View File

@@ -1,6 +1,8 @@
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
import types from '../mutation-types';
import LabelsAPI from '../../api/labels';
import AnalyticsHelper from '../../helper/AnalyticsHelper';
import { LABEL_EVENTS } from '../../helper/AnalyticsHelper/events';
export const state = {
records: [],
@@ -43,6 +45,7 @@ export const actions = {
commit(types.SET_LABEL_UI_FLAG, { isCreating: true });
try {
const response = await LabelsAPI.create(cannedObj);
AnalyticsHelper.track(LABEL_EVENTS.CREATE);
commit(types.ADD_LABEL, response.data);
} catch (error) {
const errorMessage = error?.response?.data?.message;
@@ -56,6 +59,7 @@ export const actions = {
commit(types.SET_LABEL_UI_FLAG, { isUpdating: true });
try {
const response = await LabelsAPI.update(id, updateObj);
AnalyticsHelper.track(LABEL_EVENTS.UPDATE);
commit(types.EDIT_LABEL, response.data);
} catch (error) {
throw new Error(error);
@@ -68,6 +72,7 @@ export const actions = {
commit(types.SET_LABEL_UI_FLAG, { isDeleting: true });
try {
await LabelsAPI.delete(id);
AnalyticsHelper.track(LABEL_EVENTS.DELETED);
commit(types.DELETE_LABEL, id);
} catch (error) {
throw new Error(error);

View File

@@ -2,6 +2,8 @@
import * as types from '../mutation-types';
import Report from '../../api/reports';
import { downloadCsvFile } from '../../helper/downloadHelper';
import AnalyticsHelper from '../../helper/AnalyticsHelper';
import { REPORTS_EVENTS } from '../../helper/AnalyticsHelper/events';
const state = {
fetchingStatus: false,
@@ -116,6 +118,10 @@ export const actions = {
return Report.getAgentReports(reportObj)
.then(response => {
downloadCsvFile(reportObj.fileName, response.data);
AnalyticsHelper.track(REPORTS_EVENTS.DOWNLOAD_REPORT, {
reportType: 'agent',
businessHours: reportObj?.businessHours,
});
})
.catch(error => {
console.error(error);
@@ -125,6 +131,10 @@ export const actions = {
return Report.getLabelReports(reportObj)
.then(response => {
downloadCsvFile(reportObj.fileName, response.data);
AnalyticsHelper.track(REPORTS_EVENTS.DOWNLOAD_REPORT, {
reportType: 'label',
businessHours: reportObj?.businessHours,
});
})
.catch(error => {
console.error(error);
@@ -134,6 +144,10 @@ export const actions = {
return Report.getInboxReports(reportObj)
.then(response => {
downloadCsvFile(reportObj.fileName, response.data);
AnalyticsHelper.track(REPORTS_EVENTS.DOWNLOAD_REPORT, {
reportType: 'inbox',
businessHours: reportObj?.businessHours,
});
})
.catch(error => {
console.error(error);
@@ -143,6 +157,10 @@ export const actions = {
return Report.getTeamReports(reportObj)
.then(response => {
downloadCsvFile(reportObj.fileName, response.data);
AnalyticsHelper.track(REPORTS_EVENTS.DOWNLOAD_REPORT, {
reportType: 'team',
businessHours: reportObj?.businessHours,
});
})
.catch(error => {
console.error(error);