Skip to content

Commit

Permalink
Merge pull request #177 from WideChat/chat_close_event
Browse files Browse the repository at this point in the history
Add SNS event on chat close
  • Loading branch information
ear-dev authored Nov 9, 2022
2 parents 3ec783a + 7211a45 commit 9b4f6f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions enum/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum EventName {
ESCALATION_FAILED_DUE_TO_SAME_TARGET_DEPARTMENT = 'escalation_failed_due_to_same_target_department',
ESCALATION_FAILED_DUE_TO_LIVEAGENT_BOT_OFFLINE_OR_DISABLED = 'escalation_failed_due_to_liveagent_bot_offline_or_disabled',
ESCALATION_FAILED_DUE_TO_NETWORK_OR_APP_ERROR = 'escalation_failed_due_to_network_or_app_error',
CHAT_CLOSED_BY_DF_BOT = 'chat_closed_by_df_bot',
}

export enum EventCatagory {
Expand Down Expand Up @@ -64,4 +65,12 @@ export const Events: Record<string, IAnalyticsEvent> = {
failure_reason: 'network/app error in DF app',
},
},
[EventName.CHAT_CLOSED_BY_DF_BOT]: {
category: EventCatagory.CHAT_SESSION,
eventType: EventType.SESSION,
action: 'closed',
properties: {
close_method: 'df_bot',
},
},
};
1 change: 1 addition & 0 deletions lib/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ 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: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"ignore-pattern": "^import | *export .*? {"
}
],
"no-bitwise": false
"no-bitwise": false,
"indent": [true, "tabs", 4]
}
}

0 comments on commit 9b4f6f5

Please sign in to comment.