@microsoft/omnichannel-chat-widget 1.5.1-main.76c6a71 → 1.5.1-main.8614a75
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 +15 -8
- package/lib/cjs/common/telemetry/TelemetryConstants.js +1 -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 +16 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +16 -84
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +205 -0
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.spec.js +282 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +13 -16
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/cjs/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +68 -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 +0 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
- package/lib/cjs/contexts/common/ConversationState.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +1 -0
- package/lib/cjs/controller/componentController.js +5 -1
- package/lib/esm/common/Constants.js +11 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +1 -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 +14 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +17 -85
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +198 -0
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.spec.js +280 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +15 -18
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/esm/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +57 -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 +0 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
- package/lib/esm/contexts/common/ConversationState.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +1 -0
- package/lib/esm/controller/componentController.js +3 -0
- package/lib/types/common/Constants.d.ts +13 -4
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +1 -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/common/startChatErrorHandler.spec.d.ts +1 -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 +10 -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 +1 -0
- package/lib/types/controller/componentController.d.ts +1 -0
- package/package.json +3 -3
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +0 -4
- package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +0 -4
- /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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.shouldShowWebChatContainer = exports.shouldShowReconnectChatPane = exports.shouldShowProactiveChatPane = exports.shouldShowPreChatSurveyPane = exports.shouldShowPostChatSurveyPane = exports.shouldShowPostChatLoadingPane = exports.shouldShowOutOfOfficeHoursPane = exports.shouldShowLoadingPane = exports.shouldShowHeader = exports.shouldShowFooter = exports.shouldShowEmailTranscriptPane = exports.shouldShowConfirmationPane = exports.shouldShowChatButton = exports.shouldShowCallingContainer = void 0;
|
|
6
|
+
exports.shouldShowWebChatContainer = exports.shouldShowStartChatErrorPane = exports.shouldShowReconnectChatPane = exports.shouldShowProactiveChatPane = exports.shouldShowPreChatSurveyPane = exports.shouldShowPostChatSurveyPane = exports.shouldShowPostChatLoadingPane = exports.shouldShowOutOfOfficeHoursPane = exports.shouldShowLoadingPane = exports.shouldShowHeader = exports.shouldShowFooter = exports.shouldShowEmailTranscriptPane = exports.shouldShowConfirmationPane = exports.shouldShowChatButton = exports.shouldShowCallingContainer = void 0;
|
|
7
7
|
var _ConversationState = require("../contexts/common/ConversationState");
|
|
8
8
|
const shouldShowChatButton = state => {
|
|
9
9
|
var _state$appStates;
|
|
@@ -34,6 +34,10 @@ const shouldShowLoadingPane = state => {
|
|
|
34
34
|
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
|
|
35
35
|
};
|
|
36
36
|
exports.shouldShowLoadingPane = shouldShowLoadingPane;
|
|
37
|
+
const shouldShowStartChatErrorPane = state => {
|
|
38
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Error;
|
|
39
|
+
};
|
|
40
|
+
exports.shouldShowStartChatErrorPane = shouldShowStartChatErrorPane;
|
|
37
41
|
const shouldShowReconnectChatPane = state => {
|
|
38
42
|
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat;
|
|
39
43
|
};
|
|
@@ -174,11 +174,6 @@ export let ElementType;
|
|
|
174
174
|
(function (ElementType) {
|
|
175
175
|
ElementType["CallingContainerSDK"] = "CallingContainerSDK";
|
|
176
176
|
})(ElementType || (ElementType = {}));
|
|
177
|
-
export let ChatSDKError;
|
|
178
|
-
(function (ChatSDKError) {
|
|
179
|
-
ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
|
|
180
|
-
ChatSDKError["AuthContactIdNotFoundFailure"] = "AuthContactIdNotFoundFailure";
|
|
181
|
-
})(ChatSDKError || (ChatSDKError = {}));
|
|
182
177
|
export let EnvironmentVersion;
|
|
183
178
|
(function (EnvironmentVersion) {
|
|
184
179
|
EnvironmentVersion["prod"] = "prod";
|
|
@@ -252,6 +247,10 @@ _defineProperty(NotificationPaneConstants, "IconText", "Notification Icon");
|
|
|
252
247
|
_defineProperty(NotificationPaneConstants, "ChatDisconnectTitleText", "Chat disconnected");
|
|
253
248
|
_defineProperty(NotificationPaneConstants, "ChatDisconnectSubtitleText", "For additional assistance, please close the chat and try again.");
|
|
254
249
|
_defineProperty(NotificationPaneConstants, "ChromeCloseIconName", "ChromeClose");
|
|
250
|
+
export class StartChatErrorPaneConstants {}
|
|
251
|
+
_defineProperty(StartChatErrorPaneConstants, "DefaultStartChatErrorPaneId", "oc-lcw-start-chat-error-pane");
|
|
252
|
+
_defineProperty(StartChatErrorPaneConstants, "DefaultStartChatErrorTitleText", "We are unable to load chat at this time.");
|
|
253
|
+
_defineProperty(StartChatErrorPaneConstants, "DefaultStartChatErrorSubtitleText", "Please try again later.");
|
|
255
254
|
export class AriaTelemetryConstants {}
|
|
256
255
|
// Aria Endpoint for different environment types.
|
|
257
256
|
_defineProperty(AriaTelemetryConstants, "GERMANY_ENDPOINT", "https://de.pipe.aria.microsoft.com/Collector/3.0/");
|
|
@@ -265,4 +264,10 @@ _defineProperty(AriaTelemetryConstants, "MOONCAKE_ENDPOINT", "");
|
|
|
265
264
|
_defineProperty(AriaTelemetryConstants, "Public", "Public");
|
|
266
265
|
_defineProperty(AriaTelemetryConstants, "EU", "Europe");
|
|
267
266
|
// EUR: crm4; FRA: crm12; GER: crm16; CHE: crm17; NOR: crm19
|
|
268
|
-
_defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
|
|
267
|
+
_defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
|
|
268
|
+
export class WidgetLoadTelemetryMessage {}
|
|
269
|
+
_defineProperty(WidgetLoadTelemetryMessage, "OOOHMessage", "Widget is OOOH");
|
|
270
|
+
_defineProperty(WidgetLoadTelemetryMessage, "PersistedStateRetrievedMessage", "Persisted state retrieved");
|
|
271
|
+
export class WidgetLoadCustomErrorString {}
|
|
272
|
+
_defineProperty(WidgetLoadCustomErrorString, "AuthenticationFailedErrorString", "Authentication was not successful");
|
|
273
|
+
_defineProperty(WidgetLoadCustomErrorString, "NetworkErrorString", "Network Error");
|
|
@@ -127,10 +127,10 @@ export let TelemetryEvent;
|
|
|
127
127
|
TelemetryEvent["ErrorUIPaneLoaded"] = "ErrorUIPaneLoaded";
|
|
128
128
|
TelemetryEvent["DownloadTranscriptFailed"] = "DownloadTranscriptFailed";
|
|
129
129
|
TelemetryEvent["StartChatFailed"] = "StartChatFailed";
|
|
130
|
-
TelemetryEvent["IC3ThreadUpdateEventReceived"] = "IC3ThreadUpdateEventReceived";
|
|
131
130
|
TelemetryEvent["ConfirmationCancelButtonClicked"] = "ConfirmationCancelButtonClicked";
|
|
132
131
|
TelemetryEvent["ConfirmationConfirmButtonClicked"] = "ConfirmationConfirmButtonClicked";
|
|
133
132
|
TelemetryEvent["LoadingPaneLoaded"] = "LoadingPaneLoaded";
|
|
133
|
+
TelemetryEvent["StartChatErrorPaneLoaded"] = "StartChatErrorPaneLoaded";
|
|
134
134
|
TelemetryEvent["EmailTranscriptLoaded"] = "EmailTranscriptLoaded";
|
|
135
135
|
TelemetryEvent["OutOfOfficePaneLoaded"] = "OutOfOfficePaneLoaded";
|
|
136
136
|
TelemetryEvent["ConfirmationPaneLoaded"] = "ConfirmationPaneLoaded";
|
|
@@ -244,7 +244,6 @@ export class TelemetryConstants {
|
|
|
244
244
|
case TelemetryEvent.EmailTranscriptSent:
|
|
245
245
|
case TelemetryEvent.EmailTranscriptFailed:
|
|
246
246
|
case TelemetryEvent.DownloadTranscriptFailed:
|
|
247
|
-
case TelemetryEvent.IC3ThreadUpdateEventReceived:
|
|
248
247
|
case TelemetryEvent.ConfirmationCancelButtonClicked:
|
|
249
248
|
case TelemetryEvent.ConfirmationConfirmButtonClicked:
|
|
250
249
|
case TelemetryEvent.PreChatSurveyStartChatMethodFailed:
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
var _this = this;
|
|
2
|
-
import { AriaTelemetryConstants,
|
|
2
|
+
import { AriaTelemetryConstants, Constants, HtmlAttributeNames, LocaleConstants } from "./Constants";
|
|
3
3
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "./telemetry/TelemetryConstants";
|
|
4
4
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
5
5
|
import { DataStoreManager } from "./contextDataStore/DataStoreManager";
|
|
6
6
|
import { KeyCodes } from "./KeyCodes";
|
|
7
7
|
import { Md5 } from "md5-typescript";
|
|
8
8
|
import { TelemetryHelper } from "./telemetry/TelemetryHelper";
|
|
9
|
+
import { ChatSDKErrorName } from "@microsoft/omnichannel-chat-sdk";
|
|
9
10
|
const getElementBySelector = selector => {
|
|
10
11
|
let element;
|
|
11
12
|
if (typeof selector === "string") {
|
|
@@ -373,7 +374,7 @@ export const getConversationDetailsCall = async chatSDK => {
|
|
|
373
374
|
|
|
374
375
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
375
376
|
export const checkContactIdError = e => {
|
|
376
|
-
if ((e === null || e === void 0 ? void 0 : e.message) ===
|
|
377
|
+
if ((e === null || e === void 0 ? void 0 : e.message) === ChatSDKErrorName.AuthContactIdNotFoundFailure) {
|
|
377
378
|
const contactIdNotFoundErrorEvent = {
|
|
378
379
|
eventName: BroadcastEvent.ContactIdNotFound,
|
|
379
380
|
payload: {
|
|
@@ -5,23 +5,38 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
|
|
|
5
5
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
7
|
const handleChatDisconnect = (props, state, setWebChatStyles) => {
|
|
8
|
-
var _state$appStates;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
var _state$appStates, _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
|
|
9
|
+
const chatDisconnectState = state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived;
|
|
10
|
+
const chatDisconnectMessage = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$m = _state$domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_BANNER_CHAT_DISCONNECT) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_CHAT_DISCONNECT;
|
|
11
|
+
const hideSendBoxOnConversationEnd = props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd;
|
|
12
|
+
switch (chatDisconnectState) {
|
|
13
|
+
case true:
|
|
14
|
+
if (hideSendBoxOnConversationEnd !== false) {
|
|
15
|
+
setWebChatStyles(styles => {
|
|
16
|
+
return {
|
|
17
|
+
...styles,
|
|
18
|
+
hideSendBox: true
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
NotificationHandler.notifyWarning(NotificationScenarios.ChatDisconnect, chatDisconnectMessage);
|
|
23
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
24
|
+
Event: TelemetryEvent.ChatDisconnectThreadEventReceived,
|
|
25
|
+
Description: "Chat disconnected due to timeout, left or removed."
|
|
18
26
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
break;
|
|
28
|
+
case false:
|
|
29
|
+
if (hideSendBoxOnConversationEnd !== false) {
|
|
30
|
+
setWebChatStyles(styles => {
|
|
31
|
+
return {
|
|
32
|
+
...styles,
|
|
33
|
+
hideSendBox: false
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
break;
|
|
25
40
|
}
|
|
26
41
|
};
|
|
27
42
|
export { handleChatDisconnect };
|
|
@@ -10,6 +10,7 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
|
10
10
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
11
11
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
12
12
|
import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
13
|
+
import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
|
|
13
14
|
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
16
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
@@ -145,7 +146,7 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
145
146
|
});
|
|
146
147
|
}
|
|
147
148
|
};
|
|
148
|
-
export const callingStateCleanUp =
|
|
149
|
+
export const callingStateCleanUp = dispatch => {
|
|
149
150
|
dispatch({
|
|
150
151
|
type: LiveChatWidgetActionType.SHOW_CALLING_CONTAINER,
|
|
151
152
|
payload: false
|
|
@@ -167,7 +168,7 @@ export const callingStateCleanUp = async dispatch => {
|
|
|
167
168
|
payload: true
|
|
168
169
|
});
|
|
169
170
|
};
|
|
170
|
-
export const endChatStateCleanUp =
|
|
171
|
+
export const endChatStateCleanUp = dispatch => {
|
|
171
172
|
// Need to clear these states immediately when chat ended from OC.
|
|
172
173
|
dispatch({
|
|
173
174
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
@@ -182,7 +183,7 @@ export const endChatStateCleanUp = async dispatch => {
|
|
|
182
183
|
payload: false
|
|
183
184
|
});
|
|
184
185
|
};
|
|
185
|
-
export const closeChatStateCleanUp =
|
|
186
|
+
export const closeChatStateCleanUp = dispatch => {
|
|
186
187
|
dispatch({
|
|
187
188
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
188
189
|
payload: undefined
|
|
@@ -218,6 +219,16 @@ export const closeChatStateCleanUp = async dispatch => {
|
|
|
218
219
|
});
|
|
219
220
|
};
|
|
220
221
|
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
223
|
+
export const chatSDKStateCleanUp = chatSDK => {
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
|
+
chatSDK.requestId = uuidv4();
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
227
|
+
chatSDK.chatToken = {};
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
+
chatSDK.reconnectId = null;
|
|
230
|
+
};
|
|
231
|
+
|
|
221
232
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
222
233
|
export const endVoiceVideoCallIfOngoing = async (chatSDK, dispatch) => {
|
|
223
234
|
let callId = "";
|
|
@@ -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,198 @@
|
|
|
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 { WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSuccessful) => {
|
|
14
|
+
var _props$controlProps;
|
|
15
|
+
if (!ex) {
|
|
16
|
+
logWidgetLoadFailed();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Handle internal or misc errors
|
|
21
|
+
if (ex.message === WidgetLoadCustomErrorString.AuthenticationFailedErrorString || ex.message === WidgetLoadCustomErrorString.NetworkErrorString) {
|
|
22
|
+
logWidgetLoadCompleteWithError(ex);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Handle ChatSDK errors
|
|
26
|
+
if (ex instanceof ChatSDKError) {
|
|
27
|
+
switch (ex.message) {
|
|
28
|
+
case ChatSDKErrorName.WidgetUseOutsideOperatingHour:
|
|
29
|
+
handleWidgetUseOutsideOperatingHour(dispatch);
|
|
30
|
+
return;
|
|
31
|
+
case ChatSDKErrorName.PersistentChatConversationRetrievalFailure:
|
|
32
|
+
handlePersistentChatConversationRetrievalFailure(ex);
|
|
33
|
+
break;
|
|
34
|
+
case ChatSDKErrorName.ConversationInitializationFailure:
|
|
35
|
+
handleConversationInitializationFailure(ex);
|
|
36
|
+
break;
|
|
37
|
+
case ChatSDKErrorName.ChatTokenRetrievalFailure:
|
|
38
|
+
handleChatTokenRetrievalFailure(ex);
|
|
39
|
+
break;
|
|
40
|
+
case ChatSDKErrorName.UninitializedChatSDK:
|
|
41
|
+
handleUninitializedChatSDK(ex);
|
|
42
|
+
break;
|
|
43
|
+
case ChatSDKErrorName.InvalidConversation:
|
|
44
|
+
case ChatSDKErrorName.ClosedConversation:
|
|
45
|
+
handleInvalidOrClosedConversation(dispatch, chatSDK, props, ex);
|
|
46
|
+
return;
|
|
47
|
+
default:
|
|
48
|
+
logWidgetLoadFailed(ex);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Show the error UI pane
|
|
53
|
+
dispatch({
|
|
54
|
+
type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
55
|
+
payload: true
|
|
56
|
+
});
|
|
57
|
+
if (!(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideErrorUIPane)) {
|
|
58
|
+
// New flow of leveraging ConversationState.Error
|
|
59
|
+
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
60
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
61
|
+
Event: TelemetryEvent.ErrorUIPaneLoaded,
|
|
62
|
+
Description: "Error UI Pane Loaded"
|
|
63
|
+
});
|
|
64
|
+
dispatch({
|
|
65
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
66
|
+
payload: ConversationState.Error
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
// Old flow of leveraging ConversationState.Loading
|
|
70
|
+
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
71
|
+
dispatch({
|
|
72
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
73
|
+
payload: ConversationState.Loading
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
78
|
+
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
79
|
+
if (isStartChatSuccessful === true) {
|
|
80
|
+
forceEndChat(chatSDK);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const logWidgetLoadFailed = ex => {
|
|
84
|
+
var _TelemetryTimers$Widg;
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
const exDetails = {
|
|
87
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
88
|
+
};
|
|
89
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
90
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
91
|
+
}
|
|
92
|
+
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
93
|
+
Event: TelemetryEvent.WidgetLoadFailed,
|
|
94
|
+
ExceptionDetails: exDetails,
|
|
95
|
+
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
export const logWidgetLoadComplete = additionalMessage => {
|
|
99
|
+
var _TelemetryTimers$Widg2;
|
|
100
|
+
let descriptionString = "Widget load complete";
|
|
101
|
+
if (additionalMessage) {
|
|
102
|
+
descriptionString += `. ${additionalMessage}`;
|
|
103
|
+
}
|
|
104
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
105
|
+
Event: TelemetryEvent.WidgetLoadComplete,
|
|
106
|
+
Description: descriptionString,
|
|
107
|
+
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const logWidgetLoadCompleteWithError = ex => {
|
|
111
|
+
var _TelemetryTimers$Widg3;
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
+
const exDetails = {
|
|
114
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
115
|
+
};
|
|
116
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
117
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
118
|
+
}
|
|
119
|
+
TelemetryHelper.logLoadingEvent(LogLevel.WARN, {
|
|
120
|
+
Event: TelemetryEvent.WidgetLoadComplete,
|
|
121
|
+
Description: "Widget load complete with error",
|
|
122
|
+
ExceptionDetails: exDetails,
|
|
123
|
+
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
const forceEndChat = chatSDK => {
|
|
129
|
+
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
130
|
+
Event: TelemetryEvent.WidgetLoadFailed,
|
|
131
|
+
ExceptionDetails: {
|
|
132
|
+
Exception: "SessionInit was successful, but widget load failed."
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
136
|
+
};
|
|
137
|
+
const handleWidgetUseOutsideOperatingHour = dispatch => {
|
|
138
|
+
dispatch({
|
|
139
|
+
type: LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
140
|
+
payload: true
|
|
141
|
+
});
|
|
142
|
+
dispatch({
|
|
143
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
144
|
+
payload: ConversationState.OutOfOffice
|
|
145
|
+
});
|
|
146
|
+
logWidgetLoadComplete(WidgetLoadTelemetryMessage.OOOHMessage);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
|
+
const handlePersistentChatConversationRetrievalFailure = ex => {
|
|
151
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
152
|
+
logWidgetLoadFailed(ex);
|
|
153
|
+
} else {
|
|
154
|
+
logWidgetLoadCompleteWithError(ex);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
|
+
const handleConversationInitializationFailure = 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 handleChatTokenRetrievalFailure = 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 handleUninitializedChatSDK = ex => {
|
|
178
|
+
logWidgetLoadCompleteWithError(ex);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
|
+
const handleInvalidOrClosedConversation = (dispatch, chatSDK, props, ex) => {
|
|
183
|
+
var _DataStoreManager$cli;
|
|
184
|
+
logWidgetLoadCompleteWithError(ex);
|
|
185
|
+
|
|
186
|
+
// Reset all internal states
|
|
187
|
+
callingStateCleanUp(dispatch);
|
|
188
|
+
endChatStateCleanUp(dispatch);
|
|
189
|
+
closeChatStateCleanUp(dispatch);
|
|
190
|
+
chatSDKStateCleanUp(chatSDK);
|
|
191
|
+
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(getWidgetCacheIdfromProps(props));
|
|
192
|
+
|
|
193
|
+
// Starts new chat
|
|
194
|
+
dispatch({
|
|
195
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
196
|
+
payload: ConversationState.Closed
|
|
197
|
+
});
|
|
198
|
+
};
|