@microsoft/omnichannel-chat-widget 0.1.0-main.488d6f1 → 0.1.0-main.63cfb47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -11
- package/lib/cjs/common/Constants.js +4 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +34 -5
- package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +11 -6
- package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -41
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -2
- package/lib/cjs/components/headerstateful/HeaderStateful.js +1 -7
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +5 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +39 -3
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +1 -1
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +17 -5
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +105 -20
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +7 -6
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -5
- package/lib/cjs/components/livechatwidget/common/startChat.js +43 -30
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +68 -24
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +9 -46
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +44 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +15 -16
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +5 -1
- package/lib/cjs/contexts/createReducer.js +0 -10
- package/lib/cjs/plugins/newMessageEventHandler.js +102 -0
- package/lib/esm/common/Constants.js +4 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +30 -4
- package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +10 -6
- package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -36
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -2
- package/lib/esm/components/headerstateful/HeaderStateful.js +1 -7
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +5 -3
- package/lib/esm/components/livechatwidget/common/endChat.js +40 -6
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +1 -1
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -4
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +94 -20
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +4 -3
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -5
- package/lib/esm/components/livechatwidget/common/startChat.js +43 -31
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +62 -22
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +3 -3
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -44
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +31 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +15 -16
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +5 -1
- package/lib/esm/contexts/createReducer.js +0 -9
- package/lib/esm/plugins/newMessageEventHandler.js +84 -0
- package/lib/types/common/Constants.d.ts +2 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +21 -3
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +4 -4
- package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +15 -16
- package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
- package/package.json +6 -5
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
4
|
import { BroadcastService, decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
4
5
|
import { Stack } from "@fluentui/react";
|
|
5
6
|
import React, { useEffect, useRef, useState } from "react";
|
|
6
7
|
import { createTimer, getLocaleDirection } from "../../../common/utils";
|
|
7
|
-
import { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat } from "../common/reconnectChatHelper";
|
|
8
|
+
import { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat } from "../common/reconnectChatHelper";
|
|
8
9
|
import { initStartChat, prepareStartChat } from "../common/startChat";
|
|
9
10
|
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
10
11
|
import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
|
|
@@ -12,6 +13,7 @@ import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
|
|
|
12
13
|
import { Components } from "botframework-webchat";
|
|
13
14
|
import ConfirmationPaneStateful from "../../confirmationpanestateful/ConfirmationPaneStateful";
|
|
14
15
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
16
|
+
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
15
17
|
import { ElementType } from "@microsoft/omnichannel-chat-components";
|
|
16
18
|
import EmailTranscriptPaneStateful from "../../emailtranscriptpanestateful/EmailTranscriptPaneStateful";
|
|
17
19
|
import HeaderStateful from "../../headerstateful/HeaderStateful";
|
|
@@ -23,12 +25,14 @@ import PostChatSurveyPaneStateful from "../../postchatsurveypanestateful/PostCha
|
|
|
23
25
|
import PreChatSurveyPaneStateful from "../../prechatsurveypanestateful/PreChatSurveyPaneStateful";
|
|
24
26
|
import ProactiveChatPaneStateful from "../../proactivechatpanestateful/ProactiveChatPaneStateful";
|
|
25
27
|
import ReconnectChatPaneStateful from "../../reconnectchatpanestateful/ReconnectChatPaneStateful";
|
|
28
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
26
29
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
27
30
|
import WebChatContainerStateful from "../../webchatcontainerstateful/WebChatContainerStateful";
|
|
28
31
|
import { createFooter } from "../common/createFooter";
|
|
29
32
|
import { createInternetConnectionChangeHandler } from "../common/createInternetConnectionChangeHandler";
|
|
30
33
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
31
|
-
import {
|
|
34
|
+
import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
|
|
35
|
+
import { endChat, prepareEndChat } from "../common/endChat";
|
|
32
36
|
import { getGeneralStylesForButton } from "../common/getGeneralStylesForButton";
|
|
33
37
|
import { initCallingSdk } from "../common/initCallingSdk";
|
|
34
38
|
import { initConfirmationPropsComposer } from "../common/initConfirmationPropsComposer";
|
|
@@ -39,12 +43,8 @@ import { startProactiveChat } from "../common/startProactiveChat";
|
|
|
39
43
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
40
44
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
41
45
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
42
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
43
|
-
import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
|
|
44
|
-
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
45
|
-
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
46
46
|
export const LiveChatWidgetStateful = props => {
|
|
47
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$controlProps6, _props$componentOverr2, _props$controlProps7, _props$componentOverr3, _props$controlProps8, _props$componentOverr4, _props$controlProps9, _props$componentOverr5, _props$controlProps10, _props$componentOverr6, _props$controlProps11, _props$controlProps12, _props$controlProps13, _props$
|
|
47
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$controlProps6, _props$componentOverr2, _props$controlProps7, _props$componentOverr3, _props$controlProps8, _props$componentOverr4, _props$controlProps9, _props$componentOverr5, _props$controlProps10, _props$componentOverr6, _props$controlProps11, _props$componentOverr7, _props$controlProps12, _props$controlProps13, _props$componentOverr8, _props$controlProps14, _props$componentOverr9, _props$controlProps15, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
48
48
|
|
|
49
49
|
const [state, dispatch] = useChatContextStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
50
|
|
|
@@ -58,7 +58,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
58
58
|
const {
|
|
59
59
|
Composer
|
|
60
60
|
} = Components;
|
|
61
|
-
const canStartProactiveChat = useRef(true);
|
|
61
|
+
const canStartProactiveChat = useRef(true);
|
|
62
|
+
const canEndChat = useRef(true); // Process general styles
|
|
62
63
|
|
|
63
64
|
const generalStyles = {
|
|
64
65
|
root: Object.assign({}, getGeneralStylesForButton(state), (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyles)
|
|
@@ -90,7 +91,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
90
91
|
if (!((_props$controlProps3 = props.controlProps) !== null && _props$controlProps3 !== void 0 && _props$controlProps3.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
91
92
|
var _props$reconnectChatP2;
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
startUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
|
|
94
95
|
} // Initialize global dir
|
|
95
96
|
|
|
96
97
|
|
|
@@ -116,9 +117,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
116
117
|
var _props$reconnectChatP3;
|
|
117
118
|
|
|
118
119
|
if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
|
|
119
|
-
var _props$reconnectChatP4;
|
|
120
|
+
var _props$reconnectChatP4, _props$reconnectChatP5;
|
|
120
121
|
|
|
121
|
-
handleUnauthenticatedReconnectChat(dispatch, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, initStartChat);
|
|
122
|
+
handleUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
|
|
122
123
|
} else {
|
|
123
124
|
getReconnectIdForAuthenticatedChat(props, chatSDK).then(authReconnectId => {
|
|
124
125
|
if (authReconnectId && !state.appStates.reconnectId) {
|
|
@@ -131,6 +132,10 @@ export const LiveChatWidgetStateful = props => {
|
|
|
131
132
|
payload: ConversationState.ReconnectChat
|
|
132
133
|
});
|
|
133
134
|
} else {
|
|
135
|
+
const chatStartedSkippingChatButtonRendering = {
|
|
136
|
+
eventName: BroadcastEvent.StartChatSkippingChatButtonRendering
|
|
137
|
+
};
|
|
138
|
+
BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
134
139
|
dispatch({
|
|
135
140
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
136
141
|
payload: ConversationState.Loading
|
|
@@ -158,8 +163,39 @@ export const LiveChatWidgetStateful = props => {
|
|
|
158
163
|
Description: "Start proactive chat method called, when chat was already triggered."
|
|
159
164
|
});
|
|
160
165
|
}
|
|
166
|
+
}); // start chat from SDK Event
|
|
167
|
+
|
|
168
|
+
BroadcastService.getMessageByEventName("StartChat").subscribe(() => {
|
|
169
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
170
|
+
Event: TelemetryEvent.StartChatEventRecevied,
|
|
171
|
+
Description: "Start chat event received."
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
if (state.appStates.isMinimized) {
|
|
175
|
+
dispatch({
|
|
176
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
177
|
+
payload: false
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
|
|
181
|
+
}
|
|
182
|
+
}); // end chat from SDK Event
|
|
183
|
+
|
|
184
|
+
BroadcastService.getMessageByEventName("EndChat").subscribe(async () => {
|
|
185
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
186
|
+
Event: TelemetryEvent.EndChatEventReceived,
|
|
187
|
+
Description: "End chat event received."
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
if (canEndChat.current) {
|
|
191
|
+
prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
192
|
+
} else {
|
|
193
|
+
const skipEndChatSDK = true;
|
|
194
|
+
const skipCloseChat = false;
|
|
195
|
+
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
196
|
+
}
|
|
161
197
|
});
|
|
162
|
-
window.addEventListener("beforeunload",
|
|
198
|
+
window.addEventListener("beforeunload", () => {
|
|
163
199
|
disposeTelemetryLoggers();
|
|
164
200
|
});
|
|
165
201
|
|
|
@@ -169,11 +205,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
169
205
|
}, []);
|
|
170
206
|
useEffect(() => {
|
|
171
207
|
canStartProactiveChat.current = state.appStates.conversationState === ConversationState.Closed;
|
|
208
|
+
canEndChat.current = state.appStates.conversationState === ConversationState.Active;
|
|
172
209
|
|
|
173
210
|
if (state.appStates.conversationState === ConversationState.Active) {
|
|
174
211
|
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
175
212
|
BroadcastService.postMessage({
|
|
176
|
-
eventName:
|
|
213
|
+
eventName: BroadcastEvent.NewMessageNotification
|
|
177
214
|
});
|
|
178
215
|
});
|
|
179
216
|
} // Track the message count
|
|
@@ -198,7 +235,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
198
235
|
});
|
|
199
236
|
const customEvent = {
|
|
200
237
|
elementType: ElementType.Custom,
|
|
201
|
-
eventName:
|
|
238
|
+
eventName: BroadcastEvent.UnreadMessageCount,
|
|
202
239
|
payload: 0
|
|
203
240
|
};
|
|
204
241
|
BroadcastService.postMessage(customEvent);
|
|
@@ -208,7 +245,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
208
245
|
if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
|
|
209
246
|
const customEvent = {
|
|
210
247
|
elementType: ElementType.Custom,
|
|
211
|
-
eventName:
|
|
248
|
+
eventName: BroadcastEvent.UnreadMessageCount,
|
|
212
249
|
payload: `${state.appStates.unreadMessageCount}`
|
|
213
250
|
};
|
|
214
251
|
BroadcastService.postMessage(customEvent);
|
|
@@ -226,7 +263,10 @@ export const LiveChatWidgetStateful = props => {
|
|
|
226
263
|
const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
227
264
|
|
|
228
265
|
|
|
229
|
-
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat) => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
266
|
+
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat) => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
const prepareEndChatRelay = (adapter, state) => prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
230
270
|
|
|
231
271
|
const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
272
|
|
|
@@ -237,7 +277,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
237
277
|
|
|
238
278
|
useEffect(() => {
|
|
239
279
|
const chatWidgetStateChangeEvent = {
|
|
240
|
-
eventName:
|
|
280
|
+
eventName: BroadcastEvent.ChatWidgetStateChanged,
|
|
241
281
|
payload: { ...state
|
|
242
282
|
}
|
|
243
283
|
};
|
|
@@ -264,14 +304,14 @@ export const LiveChatWidgetStateful = props => {
|
|
|
264
304
|
})), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, props.loadingPaneProps)), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, props.outOfOfficeHoursPaneProps)), !((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
|
|
265
305
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
266
306
|
initStartChat: initStartChatRelay
|
|
267
|
-
})), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
|
|
307
|
+
})), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
|
|
268
308
|
surveyProps: props.preChatSurveyPaneProps,
|
|
269
309
|
initStartChat: initStartChatRelay
|
|
270
|
-
}), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
|
|
310
|
+
})), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
|
|
271
311
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
272
|
-
}, props.callingContainerProps)), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$
|
|
312
|
+
}, props.callingContainerProps)), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
|
|
273
313
|
setPostChatContext: setPostChatContextRelay,
|
|
274
|
-
|
|
275
|
-
}))), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$
|
|
314
|
+
prepareEndChat: prepareEndChatRelay
|
|
315
|
+
}))), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane))));
|
|
276
316
|
};
|
|
277
317
|
export default LiveChatWidgetStateful;
|
|
@@ -3,6 +3,8 @@ import { LoadingPane } from "@microsoft/omnichannel-chat-components";
|
|
|
3
3
|
import { defaultGeneralPostChatLoadingPaneStyleProps } from "./common/defaultgeneralPostChatLoadingPaneStyleProps";
|
|
4
4
|
import { findAllFocusableElement } from "../../common/utils";
|
|
5
5
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
6
|
+
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
7
|
+
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
6
8
|
export const PostChatLoadingPaneStateful = props => {
|
|
7
9
|
var _props$styleProps;
|
|
8
10
|
|
|
@@ -28,6 +30,10 @@ export const PostChatLoadingPaneStateful = props => {
|
|
|
28
30
|
if (firstElement && firstElement[0]) {
|
|
29
31
|
firstElement[0].focus();
|
|
30
32
|
}
|
|
33
|
+
|
|
34
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
35
|
+
Event: TelemetryEvent.PostChatSurveyLoadingPaneLoaded
|
|
36
|
+
});
|
|
31
37
|
}, []);
|
|
32
38
|
return /*#__PURE__*/React.createElement(LoadingPane, {
|
|
33
39
|
componentOverrides: props.componentOverrides,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import React, { useEffect, useState } from "react";
|
|
3
3
|
import { createTimer, setFocusOnElement } from "../../common/utils";
|
|
4
4
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
@@ -51,7 +51,7 @@ export const ProactiveChatPaneStateful = props => {
|
|
|
51
51
|
if (state.appStates.proactiveChatStates.proactiveChatInNewWindow) {
|
|
52
52
|
// TODO: BroadcastService: replace with the sdk broadcast service, when in place
|
|
53
53
|
const startPopoutChatEvent = {
|
|
54
|
-
eventName:
|
|
54
|
+
eventName: BroadcastEvent.ProactiveChatStartPopoutChat
|
|
55
55
|
};
|
|
56
56
|
BroadcastService.postMessage(startPopoutChatEvent);
|
|
57
57
|
dispatch({
|
|
@@ -69,7 +69,7 @@ export const ProactiveChatPaneStateful = props => {
|
|
|
69
69
|
});
|
|
70
70
|
} else {
|
|
71
71
|
const proactiveChatStarted = {
|
|
72
|
-
eventName:
|
|
72
|
+
eventName: BroadcastEvent.ProactiveChatStartChat
|
|
73
73
|
};
|
|
74
74
|
BroadcastService.postMessage(proactiveChatStarted);
|
|
75
75
|
await startChat();
|
|
@@ -5,59 +5,19 @@
|
|
|
5
5
|
* 1. Renders system messages differently, according to Microsoft LiveChatWidget styles
|
|
6
6
|
* 2. Changes the font size of user messages
|
|
7
7
|
* 3. Decodes certain html characters that came through from chat services
|
|
8
|
-
* 4. Triggers end conversation sequence when the chat thread is deleted
|
|
9
8
|
******/
|
|
10
|
-
import
|
|
9
|
+
import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
|
|
11
10
|
import { Constants } from "../../../../../common/Constants";
|
|
12
11
|
import { DirectLineActivityType } from "../../enums/DirectLineActivityType";
|
|
13
12
|
import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
|
|
14
13
|
import { MessageTypes } from "../../enums/MessageType";
|
|
14
|
+
import React from "react";
|
|
15
|
+
import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
|
|
15
16
|
import { defaultSystemMessageStyles } from "./defaultStyles/defaultSystemMessageStyles";
|
|
16
17
|
import { defaultUserMessageStyles } from "./defaultStyles/defaultUserMessageStyles";
|
|
17
18
|
import { escapeHtml } from "../../../../../common/utils";
|
|
18
|
-
import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
|
|
19
|
-
import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
|
|
20
19
|
const loggedSystemMessages = new Array(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
20
|
|
|
22
|
-
const handleThreadUpdate = channelData => {
|
|
23
|
-
var _channelData$properti, _channelData$properti2;
|
|
24
|
-
|
|
25
|
-
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
26
|
-
Event: TelemetryEvent.IC3ThreadUpdateEventReceived,
|
|
27
|
-
Description: "IC3 ThreadUpdateEvent Received"
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const postConversationEndedAction = () => {
|
|
31
|
-
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
32
|
-
Event: TelemetryEvent.ConversationEndedThreadEventReceived,
|
|
33
|
-
Description: "Conversation is ended by agent side or by timeout."
|
|
34
|
-
});
|
|
35
|
-
}; // If the Thread is deleted, then display post conversation survey if enabled.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const isThreadDeleted = (channelData === null || channelData === void 0 ? void 0 : (_channelData$properti = channelData.properties) === null || _channelData$properti === void 0 ? void 0 : (_channelData$properti2 = _channelData$properti.isdeleted) === null || _channelData$properti2 === void 0 ? void 0 : _channelData$properti2.toLowerCase()) === Constants.true;
|
|
39
|
-
|
|
40
|
-
if (isThreadDeleted) {
|
|
41
|
-
postConversationEndedAction();
|
|
42
|
-
return;
|
|
43
|
-
} //check if customer is still in the thread
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (channelData.members && channelData.members.length > 0) {
|
|
47
|
-
for (let i = 0; i < channelData.members.length; i++) {
|
|
48
|
-
const id = channelData.members[i].id;
|
|
49
|
-
const tag = channelData.members[i].tag; // In case of ACS customer is not removed from thread and has "left" tag
|
|
50
|
-
|
|
51
|
-
if (id.startsWith(Constants.visitorIdPrefix) && tag !== Constants.left) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
postConversationEndedAction();
|
|
58
|
-
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
-
|
|
60
|
-
|
|
61
21
|
const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
|
|
62
22
|
var _card$activity, _card$activity$channe, _card$activity$channe2, _card$activity2, _card$activity2$chann, _card$activity3, _card$activity3$chann, _card$activity3$chann2, _card$activity4, _card$activity4$chann, _card$activity5, _card$activity5$chann, _card$nextVisibleActi, _card$nextVisibleActi2, _card$activity6, _card$activity6$chann, _card$activity7, _card$nextVisibleActi3, _card$activity8;
|
|
63
23
|
|
|
@@ -108,7 +68,10 @@ export const createActivityMiddleware = (systemMessageStyleProps, userMessageSty
|
|
|
108
68
|
var _card$activity$channe3;
|
|
109
69
|
|
|
110
70
|
if (((_card$activity$channe3 = card.activity.channelData) === null || _card$activity$channe3 === void 0 ? void 0 : _card$activity$channe3.type) === MessageTypes.Thread) {
|
|
111
|
-
|
|
71
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
72
|
+
Event: TelemetryEvent.IC3ThreadUpdateEventReceived,
|
|
73
|
+
Description: "IC3 ThreadUpdateEvent Received"
|
|
74
|
+
});
|
|
112
75
|
}
|
|
113
76
|
|
|
114
77
|
return () => false;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { Constants, MimeTypes, WebChatMiddlewareConstants } from "../../../../../common/Constants";
|
|
9
9
|
import React from "react";
|
|
10
10
|
import { getFileAttachmentIconData, isInlineMediaSupported } from "../../../common/utils/FileAttachmentIconManager";
|
|
11
|
+
import { BroadcastEvent } from "../../../../../common/telemetry/TelemetryConstants";
|
|
11
12
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
12
13
|
import { WebChatActionType } from "../../enums/WebChatActionType";
|
|
13
14
|
import { defaultAttachmentAdaptiveCardStyles } from "./defaultStyles/defaultAtttachmentAdaptiveCardStyles";
|
|
@@ -187,7 +188,7 @@ const createAttachmentMiddleware = enableInlinePlaying => {
|
|
|
187
188
|
} catch (e) {
|
|
188
189
|
const errorData = "Unable to parse the adaptive card format";
|
|
189
190
|
BroadcastService.postMessage({
|
|
190
|
-
eventName:
|
|
191
|
+
eventName: BroadcastEvent.InvalidAdaptiveCardFormat,
|
|
191
192
|
payload: {
|
|
192
193
|
Message: errorData,
|
|
193
194
|
ExceptionDetails: e
|
|
@@ -17,22 +17,22 @@ const createConversationEndMiddleware = conversationEndCallback => _ref => {
|
|
|
17
17
|
var _action$payload;
|
|
18
18
|
|
|
19
19
|
if ((action === null || action === void 0 ? void 0 : action.type) == WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
|
|
20
|
-
var _activity$from, _activity$from2, _activity$
|
|
20
|
+
var _activity$from, _activity$from2, _activity$channelData7, _activity$channelData8;
|
|
21
21
|
|
|
22
22
|
const activity = action.payload.activity;
|
|
23
23
|
|
|
24
24
|
if (((_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) === DirectLineSenderRole.Bot && activity.channelId === "ACS_CHANNEL") {
|
|
25
|
-
var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4;
|
|
25
|
+
var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6;
|
|
26
26
|
|
|
27
27
|
// ACS
|
|
28
|
-
if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(Constants.systemMessageTag) && (_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && (_activity$channelData4 = _activity$channelData3.tags) !== null && _activity$channelData4 !== void 0 && _activity$channelData4.includes(Constants.agentEndConversationMessageTag)) {
|
|
28
|
+
if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(Constants.systemMessageTag) && ((_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && (_activity$channelData4 = _activity$channelData3.tags) !== null && _activity$channelData4 !== void 0 && _activity$channelData4.includes(Constants.agentEndConversationMessageTag) || (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(Constants.supervisorForceCloseMessageTag))) {
|
|
29
29
|
conversationEndCallback();
|
|
30
30
|
}
|
|
31
|
-
} else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === DirectLineSenderRole.Channel && ((_activity$
|
|
32
|
-
var _activity$
|
|
31
|
+
} else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === DirectLineSenderRole.Channel && ((_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : _activity$channelData7.type) === MessageTypes.Thread && (_activity$channelData8 = activity.channelData) !== null && _activity$channelData8 !== void 0 && _activity$channelData8.properties) {
|
|
32
|
+
var _activity$channelData9, _activity$channelData10, _activity$channelData11, _activity$channelData12;
|
|
33
33
|
|
|
34
34
|
// IC3
|
|
35
|
-
if (((_activity$
|
|
35
|
+
if (((_activity$channelData9 = activity.channelData) === null || _activity$channelData9 === void 0 ? void 0 : (_activity$channelData10 = _activity$channelData9.properties) === null || _activity$channelData10 === void 0 ? void 0 : _activity$channelData10.isdeleted) === Constants.truePascal || !((_activity$channelData11 = activity.channelData) !== null && _activity$channelData11 !== void 0 && (_activity$channelData12 = _activity$channelData11.properties) !== null && _activity$channelData12 !== void 0 && _activity$channelData12.containsExternalEntitiesListeningAll)) {
|
|
36
36
|
conversationEndCallback();
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LogLevel } from "../../../../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
3
|
+
export function createWebChatTelemetry() {
|
|
4
|
+
const handleTelemetry = event => {
|
|
5
|
+
const {
|
|
6
|
+
level
|
|
7
|
+
} = event;
|
|
8
|
+
const loglevel = level ? level.toUpperCase() : "";
|
|
9
|
+
|
|
10
|
+
switch (loglevel) {
|
|
11
|
+
case LogLevel.DEBUG:
|
|
12
|
+
TelemetryHelper.logWebChatEvent(LogLevel.DEBUG, event);
|
|
13
|
+
break;
|
|
14
|
+
|
|
15
|
+
case LogLevel.WARN:
|
|
16
|
+
TelemetryHelper.logWebChatEvent(LogLevel.WARN, event);
|
|
17
|
+
break;
|
|
18
|
+
|
|
19
|
+
case LogLevel.ERROR:
|
|
20
|
+
TelemetryHelper.logWebChatEvent(LogLevel.ERROR, event);
|
|
21
|
+
break;
|
|
22
|
+
|
|
23
|
+
case LogLevel.INFO:
|
|
24
|
+
default:
|
|
25
|
+
TelemetryHelper.logWebChatEvent(LogLevel.INFO, event);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return handleTelemetry;
|
|
31
|
+
}
|
|
@@ -16,20 +16,19 @@ export let LiveChatWidgetActionType;
|
|
|
16
16
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_AUDIO_NOTIFICATION"] = 12] = "SET_AUDIO_NOTIFICATION";
|
|
17
17
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_E2VV_ENABLED"] = 13] = "SET_E2VV_ENABLED";
|
|
18
18
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_CONTEXT"] = 14] = "SET_POST_CHAT_CONTEXT";
|
|
19
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
20
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
21
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
22
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
23
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
24
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
25
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
26
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
27
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
28
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
29
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
30
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
31
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
32
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
33
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
34
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
|
|
19
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SHOW_CALLING_CONTAINER"] = 15] = "SHOW_CALLING_CONTAINER";
|
|
20
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INCOMING_CALL"] = 16] = "SET_INCOMING_CALL";
|
|
21
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_VIDEO_CALL"] = 17] = "DISABLE_VIDEO_CALL";
|
|
22
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_LOCAL_VIDEO"] = 18] = "DISABLE_LOCAL_VIDEO";
|
|
23
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_REMOTE_VIDEO"] = 19] = "DISABLE_REMOTE_VIDEO";
|
|
24
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CHAT_TOKEN"] = 20] = "SET_CHAT_TOKEN";
|
|
25
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SKIP_CHAT_BUTTON_RENDERING"] = 21] = "SET_SKIP_CHAT_BUTTON_RENDERING";
|
|
26
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PROACTIVE_CHAT_PARAMS"] = 22] = "SET_PROACTIVE_CHAT_PARAMS";
|
|
27
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_TELEMETRY_DATA"] = 23] = "SET_TELEMETRY_DATA";
|
|
28
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_RECONNECT_ID"] = 24] = "SET_RECONNECT_ID";
|
|
29
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_UNREAD_MESSAGE_COUNT"] = 25] = "SET_UNREAD_MESSAGE_COUNT";
|
|
30
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_FOCUS_CHAT_BUTTON"] = 26] = "SET_FOCUS_CHAT_BUTTON";
|
|
31
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT"] = 27] = "SET_CONVERSATION_ENDED_BY_AGENT";
|
|
32
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 28] = "SET_WIDGET_STATE";
|
|
33
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 29] = "SET_LIVE_CHAT_CONTEXT";
|
|
35
34
|
})(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
|
|
@@ -3,6 +3,10 @@ import { defaultMiddlewareLocalizedTexts } from "../../components/webchatcontain
|
|
|
3
3
|
export const getLiveChatWidgetContextInitialState = props => {
|
|
4
4
|
var _props$webChatContain;
|
|
5
5
|
|
|
6
|
+
if (props !== null && props !== void 0 && props.liveChatContextFromCache) {
|
|
7
|
+
return props === null || props === void 0 ? void 0 : props.liveChatContextFromCache;
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
const LiveChatWidgetContextInitialState = {
|
|
7
11
|
domainStates: {
|
|
8
12
|
liveChatConfig: props.chatConfig,
|
|
@@ -47,5 +51,5 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
47
51
|
focusChatButton: false
|
|
48
52
|
}
|
|
49
53
|
};
|
|
50
|
-
return
|
|
54
|
+
return LiveChatWidgetContextInitialState;
|
|
51
55
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable indent */
|
|
2
2
|
import { LiveChatWidgetActionType } from "./common/LiveChatWidgetActionType";
|
|
3
|
-
import { TelemetryManager } from "../common/telemetry/TelemetryManager";
|
|
4
3
|
export const createReducer = () => {
|
|
5
4
|
const reducer = (state, action) => {
|
|
6
5
|
var _action$payload, _action$payload2, _action$payload3;
|
|
@@ -84,13 +83,6 @@ export const createReducer = () => {
|
|
|
84
83
|
}
|
|
85
84
|
};
|
|
86
85
|
|
|
87
|
-
case LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT:
|
|
88
|
-
return { ...state,
|
|
89
|
-
appStates: { ...state.appStates,
|
|
90
|
-
shouldShowPostChat: action.payload
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
86
|
case LiveChatWidgetActionType.SHOW_CALLING_CONTAINER:
|
|
95
87
|
return { ...state,
|
|
96
88
|
uiStates: { ...state.uiStates,
|
|
@@ -188,7 +180,6 @@ export const createReducer = () => {
|
|
|
188
180
|
};
|
|
189
181
|
|
|
190
182
|
case LiveChatWidgetActionType.SET_TELEMETRY_DATA:
|
|
191
|
-
TelemetryManager.InternalTelemetryData = action.payload;
|
|
192
183
|
return { ...state,
|
|
193
184
|
domainStates: { ...state.domainStates,
|
|
194
185
|
telemetryInternalData: action.payload
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
3
|
+
import { Constants } from "../common/Constants";
|
|
4
|
+
import { TelemetryHelper } from "../common/telemetry/TelemetryHelper";
|
|
5
|
+
import { TelemetryManager } from "../common/telemetry/TelemetryManager";
|
|
6
|
+
export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
7
|
+
const onNewAdapterActivityHandler = activity => {
|
|
8
|
+
var _activity$channelData, _activity$channelData2, _activity$channelData3;
|
|
9
|
+
|
|
10
|
+
const isActivityMessage = (activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message;
|
|
11
|
+
const isNotHistoryMessage = isActivityMessage && !(activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(Constants.historyMessageTag)) && !(activity !== null && activity !== void 0 && (_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && _activity$channelData3.fromList);
|
|
12
|
+
|
|
13
|
+
if (isNotHistoryMessage) {
|
|
14
|
+
raiseMessageEvent(activity);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const raiseMessageEvent = activity => {
|
|
19
|
+
if ((activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message) {
|
|
20
|
+
var _TelemetryManager$Int, _activity$from;
|
|
21
|
+
|
|
22
|
+
const payload = {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
text: activity === null || activity === void 0 ? void 0 : activity.text,
|
|
25
|
+
id: activity === null || activity === void 0 ? void 0 : activity.id,
|
|
26
|
+
type: activity === null || activity === void 0 ? void 0 : activity.type,
|
|
27
|
+
timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
|
|
28
|
+
chatId: chatId,
|
|
29
|
+
userId: userId,
|
|
30
|
+
conversationId: ((_TelemetryManager$Int = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.conversationId) ?? "",
|
|
31
|
+
channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
|
|
32
|
+
messageType: ""
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if ((activity === null || activity === void 0 ? void 0 : (_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) === Constants.userMessageTag) {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
payload.messageType = Constants.userMessageTag;
|
|
38
|
+
const newMessageSentEvent = {
|
|
39
|
+
eventName: BroadcastEvent.NewMessageSent,
|
|
40
|
+
payload: payload
|
|
41
|
+
};
|
|
42
|
+
BroadcastService.postMessage(newMessageSentEvent);
|
|
43
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
44
|
+
Event: TelemetryEvent.MessageSent,
|
|
45
|
+
Description: "New message sent"
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
var _activity$channelData4, _activity$channelData5;
|
|
49
|
+
|
|
50
|
+
if (activity !== null && activity !== void 0 && (_activity$channelData4 = activity.channelData) !== null && _activity$channelData4 !== void 0 && (_activity$channelData5 = _activity$channelData4.tags) !== null && _activity$channelData5 !== void 0 && _activity$channelData5.includes(Constants.systemMessageTag)) {
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
payload.messageType = Constants.systemMessageTag;
|
|
53
|
+
} else {
|
|
54
|
+
var _activity$channelData6, _activity$channelData7, _activity$channelData8;
|
|
55
|
+
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
|
|
59
|
+
const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData6 = activity.channelData) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : (_activity$channelData8 = _activity$channelData7.tags) === null || _activity$channelData8 === void 0 ? void 0 : _activity$channelData8.length) === 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
|
|
61
|
+
const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
|
|
62
|
+
|
|
63
|
+
if (messageHasNoTags && messageHasNoText && messageHasNoAttachments) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
payload.messageType = Constants.userMessageTag;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const newMessageReceivedEvent = {
|
|
71
|
+
eventName: BroadcastEvent.NewMessageReceived,
|
|
72
|
+
payload: payload
|
|
73
|
+
};
|
|
74
|
+
BroadcastService.postMessage(newMessageReceivedEvent);
|
|
75
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
76
|
+
Event: TelemetryEvent.MessageReceived,
|
|
77
|
+
Description: "New message received"
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return onNewAdapterActivityHandler;
|
|
84
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export declare class Constants {
|
|
2
2
|
static readonly systemMessageTag = "system";
|
|
3
3
|
static readonly userMessageTag = "user";
|
|
4
|
+
static readonly historyMessageTag = "history";
|
|
4
5
|
static readonly agentEndConversationMessageTag = "agentendconversation";
|
|
6
|
+
static readonly supervisorForceCloseMessageTag = "supervisorforceclosedconversation";
|
|
5
7
|
static readonly receivedMessageClassName = "ms_lcw_webchat_received_message";
|
|
6
8
|
static readonly sentMessageClassName = "ms_lcw_webchat_sent_message";
|
|
7
9
|
static readonly webchatChannelId = "webchat";
|
|
@@ -56,7 +58,6 @@ export declare class Constants {
|
|
|
56
58
|
static readonly ProactiveChatInviteTimeoutInMs = 60000;
|
|
57
59
|
static readonly InputSubmit = "InputSubmit";
|
|
58
60
|
static readonly ReconnectIdAttributeName = "oc.reconnectid";
|
|
59
|
-
static readonly redirectPageRequest = "redirectPageRequest";
|
|
60
61
|
static readonly LiveChatWidget = "LiveChatWidgetNew";
|
|
61
62
|
static readonly GuidPattern = "xx-x-4m-ym-xxx";
|
|
62
63
|
static readonly Default = "default";
|