@microsoft/omnichannel-chat-widget 1.5.1-main.76c6a71 → 1.5.1-main.7897747
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/lib/cjs/common/Constants.js +31 -8
- package/lib/cjs/common/telemetry/TelemetryConstants.js +3 -2
- package/lib/cjs/common/utils.js +2 -1
- package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +31 -16
- package/lib/cjs/components/livechatwidget/common/endChat.js +41 -7
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +16 -84
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +220 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +52 -16
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/cjs/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +82 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.js +15 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.js +17 -0
- package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
- package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
- package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -11
- package/lib/cjs/contexts/common/ConversationState.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +37 -36
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +4 -1
- package/lib/cjs/contexts/common/StartChatFailureType.js +13 -0
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/cjs/controller/componentController.js +5 -1
- package/lib/esm/common/Constants.js +26 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +3 -2
- package/lib/esm/common/utils.js +3 -2
- package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +31 -16
- package/lib/esm/components/livechatwidget/common/endChat.js +40 -7
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +17 -85
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +213 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +55 -19
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/esm/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +71 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.js +8 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.js +10 -0
- package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
- package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
- package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -11
- package/lib/esm/contexts/common/ConversationState.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +37 -36
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +4 -1
- package/lib/esm/contexts/common/StartChatFailureType.js +6 -0
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/esm/controller/componentController.js +3 -0
- package/lib/types/common/Constants.d.ts +29 -4
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +5 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -1
- package/lib/types/components/startchaterrorpanestateful/StartChatErrorPaneStateful.d.ts +3 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.d.ts +2 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.d.ts +5 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.d.ts +6 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +14 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +8 -0
- package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.d.ts +10 -0
- package/lib/types/contexts/common/ConversationState.d.ts +2 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +3 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +37 -36
- package/lib/types/contexts/common/StartChatFailureType.d.ts +5 -0
- package/lib/types/controller/componentController.d.ts +1 -0
- package/package.json +5 -5
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +0 -71
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +0 -56
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +0 -190
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +0 -82
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.spec.js +0 -342
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +0 -69
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +0 -54
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +0 -188
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +0 -80
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.spec.js +0 -338
- package/lib/types/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.d.ts +0 -1
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.d.ts +0 -1
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +0 -4
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +0 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.spec.d.ts +0 -1
- /package/lib/cjs/components/{loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.js} +0 -0
- /package/lib/cjs/components/{loadingpanestateful/interfaces/IStartChatErrorPaneProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.js} +0 -0
- /package/lib/esm/components/{loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.js} +0 -0
- /package/lib/esm/components/{loadingpanestateful/interfaces/IStartChatErrorPaneProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.js} +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import {
|
|
2
|
+
import { Constants, LiveWorkItemState, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
3
3
|
import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
4
4
|
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
5
5
|
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
6
6
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
7
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
8
8
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
9
|
-
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
10
|
-
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
11
9
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
12
10
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
13
11
|
import { createAdapter } from "./createAdapter";
|
|
@@ -15,7 +13,8 @@ import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEv
|
|
|
15
13
|
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
|
|
16
14
|
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
17
15
|
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
18
|
-
import {
|
|
16
|
+
import { logWidgetLoadComplete, handleStartChatError } from "./startChatErrorHandler";
|
|
17
|
+
import { chatSDKStateCleanUp } from "./endChat";
|
|
19
18
|
|
|
20
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
20
|
let optionalParams = {};
|
|
@@ -108,19 +107,21 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
108
107
|
|
|
109
108
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
109
|
const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
111
|
-
var _props$controlProps2;
|
|
112
110
|
let isStartChatSuccessful = false;
|
|
113
111
|
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
114
112
|
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
115
|
-
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideErrorUIPane;
|
|
116
113
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === ConversationState.Closed) {
|
|
117
114
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
118
|
-
chatSDK
|
|
119
|
-
chatSDK.chatToken = {};
|
|
120
|
-
chatSDK.reconnectId = null;
|
|
115
|
+
chatSDKStateCleanUp(chatSDK);
|
|
121
116
|
}
|
|
122
117
|
try {
|
|
123
|
-
var _newAdapter$activity
|
|
118
|
+
var _state$appStates, _newAdapter$activity$;
|
|
119
|
+
// Clear disconnect state on start chat
|
|
120
|
+
(state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived) && dispatch({
|
|
121
|
+
type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
122
|
+
payload: false
|
|
123
|
+
});
|
|
124
|
+
|
|
124
125
|
//Start widget load timer
|
|
125
126
|
TelemetryTimers.WidgetLoadTimer = createTimer();
|
|
126
127
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
@@ -132,8 +133,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
132
133
|
// set auth token to chat sdk before start chat
|
|
133
134
|
const authSuccess = await handleAuthentication(chatSDK, chatConfig, getAuthToken);
|
|
134
135
|
if (!authSuccess) {
|
|
135
|
-
|
|
136
|
-
throw new Error("Authentication was not successful");
|
|
136
|
+
throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
@@ -196,16 +196,11 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
if (persistedState) {
|
|
199
|
-
var _TelemetryTimers$Widg;
|
|
200
199
|
dispatch({
|
|
201
200
|
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
202
201
|
payload: persistedState
|
|
203
202
|
});
|
|
204
|
-
|
|
205
|
-
Event: TelemetryEvent.WidgetLoadComplete,
|
|
206
|
-
Description: "Widget load complete. Persisted state retrieved",
|
|
207
|
-
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
208
|
-
});
|
|
203
|
+
logWidgetLoadComplete(WidgetLoadTelemetryMessage.PersistedStateRetrievedMessage);
|
|
209
204
|
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
210
205
|
return;
|
|
211
206
|
}
|
|
@@ -216,11 +211,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
216
211
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
217
212
|
payload: liveChatContext
|
|
218
213
|
});
|
|
219
|
-
|
|
220
|
-
Event: TelemetryEvent.WidgetLoadComplete,
|
|
221
|
-
Description: "Widget load complete",
|
|
222
|
-
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
|
|
223
|
-
});
|
|
214
|
+
logWidgetLoadComplete();
|
|
224
215
|
|
|
225
216
|
// Set post chat context in state
|
|
226
217
|
// Commenting this for now as post chat context is fetched during end chat
|
|
@@ -229,77 +220,18 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
229
220
|
// Updating chat session detail for telemetry
|
|
230
221
|
await updateSessionDataForTelemetry(chatSDK, dispatch);
|
|
231
222
|
} catch (ex) {
|
|
232
|
-
|
|
233
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
|
-
if (ex.message === ChatSDKError.WidgetUseOutsideOperatingHour) {
|
|
235
|
-
var _TelemetryTimers$Widg3;
|
|
236
|
-
dispatch({
|
|
237
|
-
type: LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
238
|
-
payload: true
|
|
239
|
-
});
|
|
240
|
-
dispatch({
|
|
241
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
242
|
-
payload: ConversationState.OutOfOffice
|
|
243
|
-
});
|
|
244
|
-
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
245
|
-
Event: TelemetryEvent.WidgetLoadComplete,
|
|
246
|
-
Description: "Widget load complete. Widget is OOOH.",
|
|
247
|
-
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
248
|
-
});
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
252
|
-
Event: TelemetryEvent.WidgetLoadFailed,
|
|
253
|
-
ExceptionDetails: {
|
|
254
|
-
Exception: `Widget load Failed: ${ex}`
|
|
255
|
-
},
|
|
256
|
-
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
|
|
257
|
-
});
|
|
258
|
-
NotificationHandler.notifyError(NotificationScenarios.Connection, "Start Chat Failed: " + ex);
|
|
259
|
-
dispatch({
|
|
260
|
-
type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
261
|
-
payload: true
|
|
262
|
-
});
|
|
263
|
-
if (!hideErrorUIPane) {
|
|
264
|
-
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
265
|
-
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
266
|
-
Event: TelemetryEvent.ErrorUIPaneLoaded,
|
|
267
|
-
Description: "Error UI Pane Loaded"
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
271
|
-
dispatch({
|
|
272
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
273
|
-
payload: ConversationState.Loading
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
277
|
-
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
278
|
-
if (isStartChatSuccessful === true) {
|
|
279
|
-
await forceEndChat(chatSDK);
|
|
280
|
-
}
|
|
223
|
+
handleStartChatError(dispatch, chatSDK, props, ex, isStartChatSuccessful);
|
|
281
224
|
} finally {
|
|
282
225
|
optionalParams = {};
|
|
283
226
|
widgetInstanceId = "";
|
|
284
227
|
}
|
|
285
228
|
};
|
|
286
229
|
|
|
287
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
288
|
-
const forceEndChat = async chatSDK => {
|
|
289
|
-
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
290
|
-
Event: TelemetryEvent.WidgetLoadFailed,
|
|
291
|
-
ExceptionDetails: {
|
|
292
|
-
Exception: "SessionInit was successful, but widget load failed."
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
296
|
-
};
|
|
297
|
-
|
|
298
230
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
299
231
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
300
|
-
var _state$
|
|
232
|
+
var _state$appStates2, _persistedState$domai6, _persistedState$appSt;
|
|
301
233
|
// By pass this function in case of popout chat
|
|
302
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
234
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.hideStartChatButton) === true) {
|
|
303
235
|
return false;
|
|
304
236
|
}
|
|
305
237
|
const persistedState = getStateFromCache(getWidgetCacheIdfromProps(props));
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { ChatSDKErrorName, ChatSDKError } from "@microsoft/omnichannel-chat-sdk";
|
|
2
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
|
+
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
5
|
+
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
6
|
+
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
7
|
+
import { callingStateCleanUp, endChatStateCleanUp, closeChatStateCleanUp, chatSDKStateCleanUp } from "./endChat";
|
|
8
|
+
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
9
|
+
import { getWidgetCacheIdfromProps } from "../../../common/utils";
|
|
10
|
+
import { PrepareEndChatDescriptionConstants, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
11
|
+
import { StartChatFailureType } from "../../../contexts/common/StartChatFailureType";
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSuccessful) => {
|
|
15
|
+
var _props$controlProps;
|
|
16
|
+
if (!ex) {
|
|
17
|
+
logWidgetLoadFailed();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Handle internal or misc errors
|
|
22
|
+
if (ex.message === WidgetLoadCustomErrorString.AuthenticationFailedErrorString) {
|
|
23
|
+
dispatch({
|
|
24
|
+
type: LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
25
|
+
payload: StartChatFailureType.AuthSetupError
|
|
26
|
+
});
|
|
27
|
+
logWidgetLoadCompleteWithError(ex);
|
|
28
|
+
}
|
|
29
|
+
if (ex.message === WidgetLoadCustomErrorString.NetworkErrorString) {
|
|
30
|
+
logWidgetLoadCompleteWithError(ex);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Handle ChatSDK errors
|
|
34
|
+
if (ex instanceof ChatSDKError) {
|
|
35
|
+
switch (ex.message) {
|
|
36
|
+
case ChatSDKErrorName.WidgetUseOutsideOperatingHour:
|
|
37
|
+
handleWidgetUseOutsideOperatingHour(dispatch);
|
|
38
|
+
return;
|
|
39
|
+
case ChatSDKErrorName.PersistentChatConversationRetrievalFailure:
|
|
40
|
+
handlePersistentChatConversationRetrievalFailure(ex);
|
|
41
|
+
break;
|
|
42
|
+
case ChatSDKErrorName.ConversationInitializationFailure:
|
|
43
|
+
handleConversationInitializationFailure(ex);
|
|
44
|
+
break;
|
|
45
|
+
case ChatSDKErrorName.ChatTokenRetrievalFailure:
|
|
46
|
+
handleChatTokenRetrievalFailure(dispatch, ex);
|
|
47
|
+
break;
|
|
48
|
+
case ChatSDKErrorName.UninitializedChatSDK:
|
|
49
|
+
handleUninitializedChatSDK(ex);
|
|
50
|
+
break;
|
|
51
|
+
case ChatSDKErrorName.InvalidConversation:
|
|
52
|
+
case ChatSDKErrorName.ClosedConversation:
|
|
53
|
+
handleInvalidOrClosedConversation(dispatch, chatSDK, props, ex);
|
|
54
|
+
return;
|
|
55
|
+
default:
|
|
56
|
+
logWidgetLoadFailed(ex);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Show the error UI pane
|
|
61
|
+
dispatch({
|
|
62
|
+
type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
63
|
+
payload: true
|
|
64
|
+
});
|
|
65
|
+
if (!(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideErrorUIPane)) {
|
|
66
|
+
// New flow of leveraging ConversationState.Error
|
|
67
|
+
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
68
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
69
|
+
Event: TelemetryEvent.ErrorUIPaneLoaded,
|
|
70
|
+
Description: "Error UI Pane Loaded"
|
|
71
|
+
});
|
|
72
|
+
dispatch({
|
|
73
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
74
|
+
payload: ConversationState.Error
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
// Old flow of leveraging ConversationState.Loading
|
|
78
|
+
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
79
|
+
dispatch({
|
|
80
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
81
|
+
payload: ConversationState.Loading
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
86
|
+
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
87
|
+
if (isStartChatSuccessful === true) {
|
|
88
|
+
forceEndChat(chatSDK);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const logWidgetLoadFailed = ex => {
|
|
92
|
+
var _TelemetryTimers$Widg;
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
+
const exDetails = {
|
|
95
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
96
|
+
};
|
|
97
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
98
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
99
|
+
}
|
|
100
|
+
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
101
|
+
Event: TelemetryEvent.WidgetLoadFailed,
|
|
102
|
+
ExceptionDetails: exDetails,
|
|
103
|
+
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
export const logWidgetLoadComplete = additionalMessage => {
|
|
107
|
+
var _TelemetryTimers$Widg2;
|
|
108
|
+
let descriptionString = "Widget load complete";
|
|
109
|
+
if (additionalMessage) {
|
|
110
|
+
descriptionString += `. ${additionalMessage}`;
|
|
111
|
+
}
|
|
112
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
113
|
+
Event: TelemetryEvent.WidgetLoadComplete,
|
|
114
|
+
Description: descriptionString,
|
|
115
|
+
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
const logWidgetLoadCompleteWithError = ex => {
|
|
119
|
+
var _TelemetryTimers$Widg3;
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
121
|
+
const exDetails = {
|
|
122
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
123
|
+
};
|
|
124
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
125
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
126
|
+
}
|
|
127
|
+
TelemetryHelper.logLoadingEvent(LogLevel.WARN, {
|
|
128
|
+
Event: TelemetryEvent.WidgetLoadComplete,
|
|
129
|
+
Description: "Widget load complete with error",
|
|
130
|
+
ExceptionDetails: exDetails,
|
|
131
|
+
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
|
+
const forceEndChat = chatSDK => {
|
|
137
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
138
|
+
Event: TelemetryEvent.PrepareEndChat,
|
|
139
|
+
Description: PrepareEndChatDescriptionConstants.WidgetLoadFailedAfterSessionInit
|
|
140
|
+
});
|
|
141
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
142
|
+
Event: TelemetryEvent.EndChatSDKCall
|
|
143
|
+
});
|
|
144
|
+
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
145
|
+
};
|
|
146
|
+
const handleWidgetUseOutsideOperatingHour = dispatch => {
|
|
147
|
+
dispatch({
|
|
148
|
+
type: LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
149
|
+
payload: true
|
|
150
|
+
});
|
|
151
|
+
dispatch({
|
|
152
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
153
|
+
payload: ConversationState.OutOfOffice
|
|
154
|
+
});
|
|
155
|
+
logWidgetLoadComplete(WidgetLoadTelemetryMessage.OOOHMessage);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
|
+
const handlePersistentChatConversationRetrievalFailure = ex => {
|
|
160
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
161
|
+
logWidgetLoadFailed(ex);
|
|
162
|
+
} else {
|
|
163
|
+
logWidgetLoadCompleteWithError(ex);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
|
+
const handleConversationInitializationFailure = ex => {
|
|
169
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
170
|
+
logWidgetLoadFailed(ex);
|
|
171
|
+
} else {
|
|
172
|
+
logWidgetLoadCompleteWithError(ex);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
177
|
+
const handleChatTokenRetrievalFailure = (dispatch, ex) => {
|
|
178
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
179
|
+
logWidgetLoadFailed(ex);
|
|
180
|
+
} else {
|
|
181
|
+
if (ex.httpResponseStatusCode === 401) {
|
|
182
|
+
dispatch({
|
|
183
|
+
type: LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
184
|
+
payload: StartChatFailureType.Unauthorized
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
logWidgetLoadCompleteWithError(ex);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
192
|
+
const handleUninitializedChatSDK = ex => {
|
|
193
|
+
logWidgetLoadCompleteWithError(ex);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
197
|
+
const handleInvalidOrClosedConversation = (dispatch, chatSDK, props, ex) => {
|
|
198
|
+
var _DataStoreManager$cli;
|
|
199
|
+
logWidgetLoadCompleteWithError(ex);
|
|
200
|
+
|
|
201
|
+
// Reset all internal states
|
|
202
|
+
callingStateCleanUp(dispatch);
|
|
203
|
+
endChatStateCleanUp(dispatch);
|
|
204
|
+
closeChatStateCleanUp(dispatch);
|
|
205
|
+
chatSDKStateCleanUp(chatSDK);
|
|
206
|
+
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(getWidgetCacheIdfromProps(props));
|
|
207
|
+
|
|
208
|
+
// Starts new chat
|
|
209
|
+
dispatch({
|
|
210
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
211
|
+
payload: ConversationState.Closed
|
|
212
|
+
});
|
|
213
|
+
};
|
|
@@ -2,15 +2,15 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
2
2
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { BroadcastService, BroadcastServiceInitialize, decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { Components } from "botframework-webchat";
|
|
5
|
-
import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveWorkItemState, StorageType } from "../../../common/Constants";
|
|
5
|
+
import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveWorkItemState, PrepareEndChatDescriptionConstants, StorageType } from "../../../common/Constants";
|
|
6
6
|
import { Stack } from "@fluentui/react";
|
|
7
7
|
import React, { useEffect, useRef, useState } from "react";
|
|
8
8
|
import { checkIfConversationStillValid, initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
|
|
9
9
|
import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty } from "../../../common/utils";
|
|
10
10
|
import { defaultClientDataStoreProvider, isCookieAllowed } from "../../../common/storage/default/defaultClientDataStoreProvider";
|
|
11
|
-
import { endChat, endChatStateCleanUp, prepareEndChat } from "../common/endChat";
|
|
11
|
+
import { chatSDKStateCleanUp, endChat, endChatStateCleanUp, prepareEndChat } from "../common/endChat";
|
|
12
12
|
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "../common/reconnectChatHelper";
|
|
13
|
-
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
13
|
+
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowStartChatErrorPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
14
14
|
import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
|
|
15
15
|
import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
|
|
16
16
|
import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
|
|
@@ -51,9 +51,10 @@ import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
|
51
51
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
52
52
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
53
53
|
import { defaultAdaptiveCardStyles } from "../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles";
|
|
54
|
-
import
|
|
54
|
+
import StartChatErrorPaneStateful from "../../startchaterrorpanestateful/StartChatErrorPaneStateful";
|
|
55
|
+
import { StartChatFailureType } from "../../../contexts/common/StartChatFailureType";
|
|
55
56
|
export const LiveChatWidgetStateful = props => {
|
|
56
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$
|
|
57
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
57
58
|
const [state, dispatch] = useChatContextStore();
|
|
58
59
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
60
|
const [adapter, setAdapter] = useChatAdapterStore();
|
|
@@ -186,6 +187,14 @@ export const LiveChatWidgetStateful = props => {
|
|
|
186
187
|
};
|
|
187
188
|
useEffect(() => {
|
|
188
189
|
var _props$controlProps5, _props$controlProps6, _props$controlProps7, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps9, _props$chatConfig2, _props$chatConfig2$Ch, _state$appStates5;
|
|
190
|
+
dispatch({
|
|
191
|
+
type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
192
|
+
payload: false
|
|
193
|
+
});
|
|
194
|
+
dispatch({
|
|
195
|
+
type: LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
196
|
+
payload: StartChatFailureType.Generic
|
|
197
|
+
});
|
|
189
198
|
state.domainStates.confirmationPaneConfirmedOptionClicked = false;
|
|
190
199
|
state.domainStates.confirmationState = ConfirmationState.NotSet;
|
|
191
200
|
setupClientDataStore();
|
|
@@ -396,9 +405,23 @@ export const LiveChatWidgetStateful = props => {
|
|
|
396
405
|
|
|
397
406
|
// End chat
|
|
398
407
|
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
408
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
409
|
+
Event: TelemetryEvent.EndChatEventReceived,
|
|
410
|
+
Description: "Received InitiateEndChat BroadcastEvent."
|
|
411
|
+
});
|
|
412
|
+
|
|
399
413
|
// This is to ensure to get latest state from cache in multitab
|
|
400
414
|
const persistedState = getStateFromCache(getWidgetCacheIdfromProps(props));
|
|
401
415
|
if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
|
|
416
|
+
// We need to simulate states for closing chat, in order to messup with close confirmation pane.
|
|
417
|
+
dispatch({
|
|
418
|
+
type: LiveChatWidgetActionType.SET_CONFIRMATION_STATE,
|
|
419
|
+
payload: ConfirmationState.Ok
|
|
420
|
+
});
|
|
421
|
+
dispatch({
|
|
422
|
+
type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
|
|
423
|
+
payload: false
|
|
424
|
+
});
|
|
402
425
|
dispatch({
|
|
403
426
|
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
404
427
|
payload: ConversationEndEntity.Customer
|
|
@@ -406,6 +429,10 @@ export const LiveChatWidgetStateful = props => {
|
|
|
406
429
|
} else {
|
|
407
430
|
const skipEndChatSDK = true;
|
|
408
431
|
const skipCloseChat = false;
|
|
432
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
433
|
+
Event: TelemetryEvent.PrepareEndChat,
|
|
434
|
+
Description: PrepareEndChatDescriptionConstants.InitiateEndChatReceived
|
|
435
|
+
});
|
|
409
436
|
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
410
437
|
}
|
|
411
438
|
BroadcastService.postMessage({
|
|
@@ -423,14 +450,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
423
450
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
424
451
|
var _msg$payload9;
|
|
425
452
|
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
453
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
454
|
+
Event: TelemetryEvent.PrepareEndChat,
|
|
455
|
+
Description: "Received EndChat BroadcastEvent from other tabs. Closing this chat."
|
|
456
|
+
});
|
|
426
457
|
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
427
458
|
endChatStateCleanUp(dispatch);
|
|
428
|
-
|
|
429
|
-
chatSDK.requestId = uuidv4();
|
|
430
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
431
|
-
chatSDK.chatToken = {};
|
|
432
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
433
|
-
chatSDK.reconnectId = null;
|
|
459
|
+
chatSDKStateCleanUp(chatSDK);
|
|
434
460
|
return;
|
|
435
461
|
}
|
|
436
462
|
});
|
|
@@ -558,12 +584,20 @@ export const LiveChatWidgetStateful = props => {
|
|
|
558
584
|
|
|
559
585
|
// If start chat failed, and C2 is trying to close chat widget
|
|
560
586
|
if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed || (state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === ConversationState.Postchat) {
|
|
587
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
588
|
+
Event: TelemetryEvent.PrepareEndChat,
|
|
589
|
+
Description: PrepareEndChatDescriptionConstants.CustomerCloseChatOnFailureOrPostChat
|
|
590
|
+
});
|
|
561
591
|
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true);
|
|
562
592
|
return;
|
|
563
593
|
}
|
|
564
594
|
|
|
565
595
|
// Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
|
|
566
596
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === ConversationState.InActive) {
|
|
597
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
598
|
+
Event: TelemetryEvent.PrepareEndChat,
|
|
599
|
+
Description: PrepareEndChatDescriptionConstants.CustomerCloseInactiveChat
|
|
600
|
+
});
|
|
567
601
|
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
568
602
|
return;
|
|
569
603
|
}
|
|
@@ -608,9 +642,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
608
642
|
|
|
609
643
|
// Handle Chat disconnect cases
|
|
610
644
|
useEffect(() => {
|
|
611
|
-
|
|
612
|
-
handleChatDisconnect(props, state, setWebChatStyles);
|
|
613
|
-
}
|
|
645
|
+
handleChatDisconnect(props, state, setWebChatStyles);
|
|
614
646
|
}, [state.appStates.chatDisconnectEventReceived]);
|
|
615
647
|
const initiateEndChatOnBrowserUnload = () => {
|
|
616
648
|
var _DataStoreManager$cli;
|
|
@@ -618,6 +650,10 @@ export const LiveChatWidgetStateful = props => {
|
|
|
618
650
|
Event: TelemetryEvent.BrowserUnloadEventStarted,
|
|
619
651
|
Description: "Browser unload event received."
|
|
620
652
|
});
|
|
653
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
654
|
+
Event: TelemetryEvent.PrepareEndChat,
|
|
655
|
+
Description: PrepareEndChatDescriptionConstants.BrowserUnload
|
|
656
|
+
});
|
|
621
657
|
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, false);
|
|
622
658
|
// Clean local storage
|
|
623
659
|
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventId);
|
|
@@ -707,17 +743,17 @@ export const LiveChatWidgetStateful = props => {
|
|
|
707
743
|
}, headerDraggableConfig))), !((_livechatProps$contro5 = livechatProps.controlProps) !== null && _livechatProps$contro5 !== void 0 && _livechatProps$contro5.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_livechatProps$compon4 = livechatProps.componentOverrides) === null || _livechatProps$compon4 === void 0 ? void 0 : _livechatProps$compon4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, {
|
|
708
744
|
loadingPaneProps: livechatProps.loadingPaneProps,
|
|
709
745
|
startChatErrorPaneProps: livechatProps.startChatErrorPaneProps
|
|
710
|
-
})), !((_livechatProps$contro6 = livechatProps.controlProps) !== null && _livechatProps$contro6 !== void 0 && _livechatProps$contro6.
|
|
746
|
+
})), !((_livechatProps$contro6 = livechatProps.controlProps) !== null && _livechatProps$contro6 !== void 0 && _livechatProps$contro6.hideErrorUIPane) && shouldShowStartChatErrorPane(state) && (decodeComponentString((_livechatProps$compon5 = livechatProps.componentOverrides) === null || _livechatProps$compon5 === void 0 ? void 0 : _livechatProps$compon5.startChatErrorPane) || /*#__PURE__*/React.createElement(StartChatErrorPaneStateful, livechatProps.startChatErrorPaneProps)), !((_livechatProps$contro7 = livechatProps.controlProps) !== null && _livechatProps$contro7 !== void 0 && _livechatProps$contro7.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_livechatProps$compon6 = livechatProps.componentOverrides) === null || _livechatProps$compon6 === void 0 ? void 0 : _livechatProps$compon6.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, livechatProps.outOfOfficeHoursPaneProps)), !((_livechatProps$contro8 = livechatProps.controlProps) !== null && _livechatProps$contro8 !== void 0 && _livechatProps$contro8.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_livechatProps$compon7 = livechatProps.componentOverrides) === null || _livechatProps$compon7 === void 0 ? void 0 : _livechatProps$compon7.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
|
|
711
747
|
reconnectChatProps: livechatProps.reconnectChatPaneProps,
|
|
712
748
|
initStartChat: initStartChatRelay
|
|
713
|
-
})), !((_livechatProps$
|
|
749
|
+
})), !((_livechatProps$contro9 = livechatProps.controlProps) !== null && _livechatProps$contro9 !== void 0 && _livechatProps$contro9.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_livechatProps$compon8 = livechatProps.componentOverrides) === null || _livechatProps$compon8 === void 0 ? void 0 : _livechatProps$compon8.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
|
|
714
750
|
surveyProps: livechatProps.preChatSurveyPaneProps,
|
|
715
751
|
initStartChat: initStartChatRelay
|
|
716
|
-
})), !((_livechatProps$
|
|
752
|
+
})), !((_livechatProps$contro10 = livechatProps.controlProps) !== null && _livechatProps$contro10 !== void 0 && _livechatProps$contro10.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
|
|
717
753
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
718
|
-
}, livechatProps.callingContainerProps)), !((_livechatProps$
|
|
754
|
+
}, livechatProps.callingContainerProps)), !((_livechatProps$contro11 = livechatProps.controlProps) !== null && _livechatProps$contro11 !== void 0 && _livechatProps$contro11.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_livechatProps$compon9 = livechatProps.componentOverrides) === null || _livechatProps$compon9 === void 0 ? void 0 : _livechatProps$compon9.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, livechatProps)), !((_livechatProps$contro12 = livechatProps.controlProps) !== null && _livechatProps$contro12 !== void 0 && _livechatProps$contro12.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_livechatProps$compon10 = livechatProps.componentOverrides) === null || _livechatProps$compon10 === void 0 ? void 0 : _livechatProps$compon10.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
|
|
719
755
|
setPostChatContext: setPostChatContextRelay,
|
|
720
756
|
prepareEndChat: prepareEndChatRelay
|
|
721
|
-
}))), !((_livechatProps$
|
|
757
|
+
}))), !((_livechatProps$contro13 = livechatProps.controlProps) !== null && _livechatProps$contro13 !== void 0 && _livechatProps$contro13.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, livechatProps.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK))), createFooter(livechatProps, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_livechatProps$compon13 = livechatProps.componentOverrides) === null || _livechatProps$compon13 === void 0 ? void 0 : _livechatProps$compon13.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, livechatProps.emailTranscriptPane))))));
|
|
722
758
|
};
|
|
723
759
|
export default LiveChatWidgetStateful;
|
|
@@ -3,10 +3,10 @@ import React, { useEffect } from "react";
|
|
|
3
3
|
import { LoadingPane } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
5
5
|
import { defaultGeneralLoadingPaneStyleProps } from "./common/defaultStyleProps/defaultgeneralLoadingPaneStyleProps";
|
|
6
|
-
import { errorUILoadingPaneStyleProps } from "./common/errorUIStyleProps/errorUILoadingPaneStyleProps";
|
|
7
6
|
import { findAllFocusableElement } from "../../common/utils";
|
|
8
7
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
9
8
|
import useWindowDimensions from "../../hooks/useWindowDimensions";
|
|
9
|
+
import { errorUILoadingPaneStyleProps } from "./common/errorUIStyleProps/errorUILoadingPaneStyleProps";
|
|
10
10
|
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
12
|
export const LoadingPaneStateful = props => {
|