Skip to content

Commit

Permalink
Merge pull request #178 from WideChat/fix/close_chat_event
Browse files Browse the repository at this point in the history
Fix close chat event tracking
  • Loading branch information
ear-dev authored Nov 16, 2022
2 parents 9b4f6f5 + 8327f1e commit 0c82edf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export const closeChat = async (modify: IModify, read: IRead, rid: string, app:

export const sendCloseChatMessage = async (read: IRead, modify: IModify, app: IApp, rid: string) => {
const closeChatMessage: string = await getLivechatAgentConfig(read, rid, AppSetting.DialogflowCloseChatMessage);
modify.getAnalytics().sendEvent(getEventData(rid, EventName.CHAT_CLOSED_BY_DF_BOT));
if (closeChatMessage?.length > 0) {
await createMessage(rid, read, modify, { text: closeChatMessage }, app);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/payloadAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IApp } from '@rocket.chat/apps-engine/definition/IApp';
import { ILivechatRoom } from '@rocket.chat/apps-engine/definition/livechat';
import { AppSetting } from '../config/Settings';
import { ActionIds } from '../enum/ActionIds';
import { EventName } from '../enum/Analytics';
import {
CloseChatDescription,
DialogflowRequestType,
Expand All @@ -27,6 +28,7 @@ import {
updatePersistentData,
} from '../lib/Persistence';
import { closeChat, performHandover, updateRoomCustomFields } from '../lib/Room';
import { getEventData } from './Analytics';
import { Dialogflow } from './Dialogflow';
import { createDialogflowMessage, createMessage } from './Message';
import { getLivechatAgentConfig } from './Settings';
Expand Down Expand Up @@ -80,6 +82,7 @@ export const handlePayloadActions = async (
if (livechatRoom && livechatRoom.isOpen) {
await closeChat(modify, read, rid, app, CloseChatDescription.CLOSED_BY_AGENT);
}
modify.getAnalytics().sendEvent(getEventData(rid, EventName.CHAT_CLOSED_BY_DF_BOT));
} else if (actionName === ActionIds.NEW_WELCOME_EVENT) {
const livechatRoom = (await read.getRoomReader().getById(rid)) as ILivechatRoom;
if (!livechatRoom) {
Expand Down

0 comments on commit 0c82edf

Please sign in to comment.