@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.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.Regex = exports.ParticipantType = exports.NotificationPaneConstants = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.
|
|
6
|
+
exports.WidgetLoadTelemetryMessage = exports.WidgetLoadCustomErrorString = exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.StartChatErrorPaneConstants = exports.Regex = exports.ParticipantType = exports.NotificationPaneConstants = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.AriaTelemetryConstants = exports.AMSConstants = void 0;
|
|
7
7
|
var _class;
|
|
8
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
9
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
@@ -191,12 +191,6 @@ exports.ElementType = ElementType;
|
|
|
191
191
|
(function (ElementType) {
|
|
192
192
|
ElementType["CallingContainerSDK"] = "CallingContainerSDK";
|
|
193
193
|
})(ElementType || (exports.ElementType = ElementType = {}));
|
|
194
|
-
let ChatSDKError;
|
|
195
|
-
exports.ChatSDKError = ChatSDKError;
|
|
196
|
-
(function (ChatSDKError) {
|
|
197
|
-
ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
|
|
198
|
-
ChatSDKError["AuthContactIdNotFoundFailure"] = "AuthContactIdNotFoundFailure";
|
|
199
|
-
})(ChatSDKError || (exports.ChatSDKError = ChatSDKError = {}));
|
|
200
194
|
let EnvironmentVersion;
|
|
201
195
|
exports.EnvironmentVersion = EnvironmentVersion;
|
|
202
196
|
(function (EnvironmentVersion) {
|
|
@@ -280,6 +274,11 @@ _defineProperty(NotificationPaneConstants, "IconText", "Notification Icon");
|
|
|
280
274
|
_defineProperty(NotificationPaneConstants, "ChatDisconnectTitleText", "Chat disconnected");
|
|
281
275
|
_defineProperty(NotificationPaneConstants, "ChatDisconnectSubtitleText", "For additional assistance, please close the chat and try again.");
|
|
282
276
|
_defineProperty(NotificationPaneConstants, "ChromeCloseIconName", "ChromeClose");
|
|
277
|
+
class StartChatErrorPaneConstants {}
|
|
278
|
+
exports.StartChatErrorPaneConstants = StartChatErrorPaneConstants;
|
|
279
|
+
_defineProperty(StartChatErrorPaneConstants, "DefaultStartChatErrorPaneId", "oc-lcw-start-chat-error-pane");
|
|
280
|
+
_defineProperty(StartChatErrorPaneConstants, "DefaultStartChatErrorTitleText", "We are unable to load chat at this time.");
|
|
281
|
+
_defineProperty(StartChatErrorPaneConstants, "DefaultStartChatErrorSubtitleText", "Please try again later.");
|
|
283
282
|
class AriaTelemetryConstants {}
|
|
284
283
|
exports.AriaTelemetryConstants = AriaTelemetryConstants;
|
|
285
284
|
// Aria Endpoint for different environment types.
|
|
@@ -294,4 +293,12 @@ _defineProperty(AriaTelemetryConstants, "MOONCAKE_ENDPOINT", "");
|
|
|
294
293
|
_defineProperty(AriaTelemetryConstants, "Public", "Public");
|
|
295
294
|
_defineProperty(AriaTelemetryConstants, "EU", "Europe");
|
|
296
295
|
// EUR: crm4; FRA: crm12; GER: crm16; CHE: crm17; NOR: crm19
|
|
297
|
-
_defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
|
|
296
|
+
_defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
|
|
297
|
+
class WidgetLoadTelemetryMessage {}
|
|
298
|
+
exports.WidgetLoadTelemetryMessage = WidgetLoadTelemetryMessage;
|
|
299
|
+
_defineProperty(WidgetLoadTelemetryMessage, "OOOHMessage", "Widget is OOOH");
|
|
300
|
+
_defineProperty(WidgetLoadTelemetryMessage, "PersistedStateRetrievedMessage", "Persisted state retrieved");
|
|
301
|
+
class WidgetLoadCustomErrorString {}
|
|
302
|
+
exports.WidgetLoadCustomErrorString = WidgetLoadCustomErrorString;
|
|
303
|
+
_defineProperty(WidgetLoadCustomErrorString, "AuthenticationFailedErrorString", "Authentication was not successful");
|
|
304
|
+
_defineProperty(WidgetLoadCustomErrorString, "NetworkErrorString", "Network Error");
|
|
@@ -133,10 +133,10 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
133
133
|
TelemetryEvent["ErrorUIPaneLoaded"] = "ErrorUIPaneLoaded";
|
|
134
134
|
TelemetryEvent["DownloadTranscriptFailed"] = "DownloadTranscriptFailed";
|
|
135
135
|
TelemetryEvent["StartChatFailed"] = "StartChatFailed";
|
|
136
|
-
TelemetryEvent["IC3ThreadUpdateEventReceived"] = "IC3ThreadUpdateEventReceived";
|
|
137
136
|
TelemetryEvent["ConfirmationCancelButtonClicked"] = "ConfirmationCancelButtonClicked";
|
|
138
137
|
TelemetryEvent["ConfirmationConfirmButtonClicked"] = "ConfirmationConfirmButtonClicked";
|
|
139
138
|
TelemetryEvent["LoadingPaneLoaded"] = "LoadingPaneLoaded";
|
|
139
|
+
TelemetryEvent["StartChatErrorPaneLoaded"] = "StartChatErrorPaneLoaded";
|
|
140
140
|
TelemetryEvent["EmailTranscriptLoaded"] = "EmailTranscriptLoaded";
|
|
141
141
|
TelemetryEvent["OutOfOfficePaneLoaded"] = "OutOfOfficePaneLoaded";
|
|
142
142
|
TelemetryEvent["ConfirmationPaneLoaded"] = "ConfirmationPaneLoaded";
|
|
@@ -250,7 +250,6 @@ class TelemetryConstants {
|
|
|
250
250
|
case TelemetryEvent.EmailTranscriptSent:
|
|
251
251
|
case TelemetryEvent.EmailTranscriptFailed:
|
|
252
252
|
case TelemetryEvent.DownloadTranscriptFailed:
|
|
253
|
-
case TelemetryEvent.IC3ThreadUpdateEventReceived:
|
|
254
253
|
case TelemetryEvent.ConfirmationCancelButtonClicked:
|
|
255
254
|
case TelemetryEvent.ConfirmationConfirmButtonClicked:
|
|
256
255
|
case TelemetryEvent.PreChatSurveyStartChatMethodFailed:
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -11,6 +11,7 @@ var _DataStoreManager = require("./contextDataStore/DataStoreManager");
|
|
|
11
11
|
var _KeyCodes = require("./KeyCodes");
|
|
12
12
|
var _md5Typescript = require("md5-typescript");
|
|
13
13
|
var _TelemetryHelper = require("./telemetry/TelemetryHelper");
|
|
14
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
14
15
|
var _this = void 0;
|
|
15
16
|
const getElementBySelector = selector => {
|
|
16
17
|
let element;
|
|
@@ -406,7 +407,7 @@ const getConversationDetailsCall = async chatSDK => {
|
|
|
406
407
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
407
408
|
exports.getConversationDetailsCall = getConversationDetailsCall;
|
|
408
409
|
const checkContactIdError = e => {
|
|
409
|
-
if ((e === null || e === void 0 ? void 0 : e.message) ===
|
|
410
|
+
if ((e === null || e === void 0 ? void 0 : e.message) === _omnichannelChatSdk.ChatSDKErrorName.AuthContactIdNotFoundFailure) {
|
|
410
411
|
const contactIdNotFoundErrorEvent = {
|
|
411
412
|
eventName: _TelemetryConstants.BroadcastEvent.ContactIdNotFound,
|
|
412
413
|
payload: {
|
|
@@ -11,23 +11,38 @@ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants"
|
|
|
11
11
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
13
|
const handleChatDisconnect = (props, state, setWebChatStyles) => {
|
|
14
|
-
var _state$appStates;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
var _state$appStates, _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
|
|
15
|
+
const chatDisconnectState = state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived;
|
|
16
|
+
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.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_CHAT_DISCONNECT;
|
|
17
|
+
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;
|
|
18
|
+
switch (chatDisconnectState) {
|
|
19
|
+
case true:
|
|
20
|
+
if (hideSendBoxOnConversationEnd !== false) {
|
|
21
|
+
setWebChatStyles(styles => {
|
|
22
|
+
return {
|
|
23
|
+
...styles,
|
|
24
|
+
hideSendBox: true
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
_NotificationHandler.NotificationHandler.notifyWarning(_NotificationScenarios.NotificationScenarios.ChatDisconnect, chatDisconnectMessage);
|
|
29
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
30
|
+
Event: _TelemetryConstants.TelemetryEvent.ChatDisconnectThreadEventReceived,
|
|
31
|
+
Description: "Chat disconnected due to timeout, left or removed."
|
|
24
32
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
break;
|
|
34
|
+
case false:
|
|
35
|
+
if (hideSendBoxOnConversationEnd !== false) {
|
|
36
|
+
setWebChatStyles(styles => {
|
|
37
|
+
return {
|
|
38
|
+
...styles,
|
|
39
|
+
hideSendBox: false
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
break;
|
|
31
46
|
}
|
|
32
47
|
};
|
|
33
48
|
exports.handleChatDisconnect = handleChatDisconnect;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.prepareEndChat = exports.endVoiceVideoCallIfOngoing = exports.endChatStateCleanUp = exports.endChat = exports.closeChatStateCleanUp = exports.callingStateCleanUp = void 0;
|
|
6
|
+
exports.prepareEndChat = exports.endVoiceVideoCallIfOngoing = exports.endChatStateCleanUp = exports.endChat = exports.closeChatStateCleanUp = exports.chatSDKStateCleanUp = exports.callingStateCleanUp = void 0;
|
|
7
7
|
var _Constants = require("../../../common/Constants");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _authHelper = require("./authHelper");
|
|
@@ -16,6 +16,7 @@ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
|
16
16
|
var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
|
|
17
17
|
var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
18
18
|
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
19
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
19
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
21
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
21
22
|
try {
|
|
@@ -152,7 +153,7 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
152
153
|
}
|
|
153
154
|
};
|
|
154
155
|
exports.endChat = endChat;
|
|
155
|
-
const callingStateCleanUp =
|
|
156
|
+
const callingStateCleanUp = dispatch => {
|
|
156
157
|
dispatch({
|
|
157
158
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SHOW_CALLING_CONTAINER,
|
|
158
159
|
payload: false
|
|
@@ -175,7 +176,7 @@ const callingStateCleanUp = async dispatch => {
|
|
|
175
176
|
});
|
|
176
177
|
};
|
|
177
178
|
exports.callingStateCleanUp = callingStateCleanUp;
|
|
178
|
-
const endChatStateCleanUp =
|
|
179
|
+
const endChatStateCleanUp = dispatch => {
|
|
179
180
|
// Need to clear these states immediately when chat ended from OC.
|
|
180
181
|
dispatch({
|
|
181
182
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
@@ -191,7 +192,7 @@ const endChatStateCleanUp = async dispatch => {
|
|
|
191
192
|
});
|
|
192
193
|
};
|
|
193
194
|
exports.endChatStateCleanUp = endChatStateCleanUp;
|
|
194
|
-
const closeChatStateCleanUp =
|
|
195
|
+
const closeChatStateCleanUp = dispatch => {
|
|
195
196
|
dispatch({
|
|
196
197
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
197
198
|
payload: undefined
|
|
@@ -229,6 +230,17 @@ const closeChatStateCleanUp = async dispatch => {
|
|
|
229
230
|
|
|
230
231
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
231
232
|
exports.closeChatStateCleanUp = closeChatStateCleanUp;
|
|
233
|
+
const chatSDKStateCleanUp = chatSDK => {
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
235
|
+
chatSDK.requestId = (0, _omnichannelChatSdk.uuidv4)();
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
237
|
+
chatSDK.chatToken = {};
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
239
|
+
chatSDK.reconnectId = null;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
243
|
+
exports.chatSDKStateCleanUp = chatSDKStateCleanUp;
|
|
232
244
|
const endVoiceVideoCallIfOngoing = async (chatSDK, dispatch) => {
|
|
233
245
|
let callId = "";
|
|
234
246
|
try {
|
|
@@ -12,8 +12,6 @@ var _ActivityStreamHandler = require("./ActivityStreamHandler");
|
|
|
12
12
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
13
13
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
14
14
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
15
|
-
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
16
|
-
var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
|
|
17
15
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
18
16
|
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
19
17
|
var _createAdapter = require("./createAdapter");
|
|
@@ -21,7 +19,8 @@ var _newMessageEventHandler = require("../../../plugins/newMessageEventHandler")
|
|
|
21
19
|
var _reconnectChatHelper = require("./reconnectChatHelper");
|
|
22
20
|
var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
|
|
23
21
|
var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
|
|
24
|
-
var
|
|
22
|
+
var _startChatErrorHandler = require("./startChatErrorHandler");
|
|
23
|
+
var _endChat = require("./endChat");
|
|
25
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
25
|
let optionalParams = {};
|
|
27
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -115,19 +114,21 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
115
114
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
115
|
exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
117
116
|
const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
118
|
-
var _props$controlProps2;
|
|
119
117
|
let isStartChatSuccessful = false;
|
|
120
118
|
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
121
119
|
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
122
|
-
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideErrorUIPane;
|
|
123
120
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
124
121
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
125
|
-
|
|
126
|
-
chatSDK.chatToken = {};
|
|
127
|
-
chatSDK.reconnectId = null;
|
|
122
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
128
123
|
}
|
|
129
124
|
try {
|
|
130
|
-
var _newAdapter$activity
|
|
125
|
+
var _state$appStates, _newAdapter$activity$;
|
|
126
|
+
// Clear disconnect state on start chat
|
|
127
|
+
(state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived) && dispatch({
|
|
128
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
129
|
+
payload: false
|
|
130
|
+
});
|
|
131
|
+
|
|
131
132
|
//Start widget load timer
|
|
132
133
|
_TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
|
|
133
134
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -139,8 +140,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
139
140
|
// set auth token to chat sdk before start chat
|
|
140
141
|
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, getAuthToken);
|
|
141
142
|
if (!authSuccess) {
|
|
142
|
-
|
|
143
|
-
throw new Error("Authentication was not successful");
|
|
143
|
+
throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -203,16 +203,11 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
if (persistedState) {
|
|
206
|
-
var _TelemetryTimers$Widg;
|
|
207
206
|
dispatch({
|
|
208
207
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
209
208
|
payload: persistedState
|
|
210
209
|
});
|
|
211
|
-
|
|
212
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
213
|
-
Description: "Widget load complete. Persisted state retrieved",
|
|
214
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
215
|
-
});
|
|
210
|
+
(0, _startChatErrorHandler.logWidgetLoadComplete)(_Constants.WidgetLoadTelemetryMessage.PersistedStateRetrievedMessage);
|
|
216
211
|
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
|
|
217
212
|
return;
|
|
218
213
|
}
|
|
@@ -223,11 +218,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
223
218
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
224
219
|
payload: liveChatContext
|
|
225
220
|
});
|
|
226
|
-
|
|
227
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
228
|
-
Description: "Widget load complete",
|
|
229
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
|
|
230
|
-
});
|
|
221
|
+
(0, _startChatErrorHandler.logWidgetLoadComplete)();
|
|
231
222
|
|
|
232
223
|
// Set post chat context in state
|
|
233
224
|
// Commenting this for now as post chat context is fetched during end chat
|
|
@@ -236,55 +227,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
236
227
|
// Updating chat session detail for telemetry
|
|
237
228
|
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch);
|
|
238
229
|
} catch (ex) {
|
|
239
|
-
|
|
240
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
241
|
-
if (ex.message === _Constants.ChatSDKError.WidgetUseOutsideOperatingHour) {
|
|
242
|
-
var _TelemetryTimers$Widg3;
|
|
243
|
-
dispatch({
|
|
244
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
245
|
-
payload: true
|
|
246
|
-
});
|
|
247
|
-
dispatch({
|
|
248
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
249
|
-
payload: _ConversationState.ConversationState.OutOfOffice
|
|
250
|
-
});
|
|
251
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
252
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
253
|
-
Description: "Widget load complete. Widget is OOOH.",
|
|
254
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
255
|
-
});
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
259
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
260
|
-
ExceptionDetails: {
|
|
261
|
-
Exception: `Widget load Failed: ${ex}`
|
|
262
|
-
},
|
|
263
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
|
|
264
|
-
});
|
|
265
|
-
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.Connection, "Start Chat Failed: " + ex);
|
|
266
|
-
dispatch({
|
|
267
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
268
|
-
payload: true
|
|
269
|
-
});
|
|
270
|
-
if (!hideErrorUIPane) {
|
|
271
|
-
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
272
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
273
|
-
Event: _TelemetryConstants.TelemetryEvent.ErrorUIPaneLoaded,
|
|
274
|
-
Description: "Error UI Pane Loaded"
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
278
|
-
dispatch({
|
|
279
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
280
|
-
payload: _ConversationState.ConversationState.Loading
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
284
|
-
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
285
|
-
if (isStartChatSuccessful === true) {
|
|
286
|
-
await forceEndChat(chatSDK);
|
|
287
|
-
}
|
|
230
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, chatSDK, props, ex, isStartChatSuccessful);
|
|
288
231
|
} finally {
|
|
289
232
|
optionalParams = {};
|
|
290
233
|
widgetInstanceId = "";
|
|
@@ -293,21 +236,10 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
293
236
|
|
|
294
237
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
295
238
|
exports.initStartChat = initStartChat;
|
|
296
|
-
const forceEndChat = async chatSDK => {
|
|
297
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
298
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
299
|
-
ExceptionDetails: {
|
|
300
|
-
Exception: "SessionInit was successful, but widget load failed."
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
307
239
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
308
|
-
var _state$
|
|
240
|
+
var _state$appStates2, _persistedState$domai6, _persistedState$appSt;
|
|
309
241
|
// By pass this function in case of popout chat
|
|
310
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
242
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.hideStartChatButton) === true) {
|
|
311
243
|
return false;
|
|
312
244
|
}
|
|
313
245
|
const persistedState = (0, _utils.getStateFromCache)((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.logWidgetLoadComplete = exports.handleStartChatError = void 0;
|
|
7
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
10
|
+
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
11
|
+
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
12
|
+
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
13
|
+
var _endChat = require("./endChat");
|
|
14
|
+
var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
|
|
15
|
+
var _utils = require("../../../common/utils");
|
|
16
|
+
var _Constants = require("../../../common/Constants");
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSuccessful) => {
|
|
19
|
+
var _props$controlProps;
|
|
20
|
+
if (!ex) {
|
|
21
|
+
logWidgetLoadFailed();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Handle internal or misc errors
|
|
26
|
+
if (ex.message === _Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString || ex.message === _Constants.WidgetLoadCustomErrorString.NetworkErrorString) {
|
|
27
|
+
logWidgetLoadCompleteWithError(ex);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Handle ChatSDK errors
|
|
31
|
+
if (ex instanceof _omnichannelChatSdk.ChatSDKError) {
|
|
32
|
+
switch (ex.message) {
|
|
33
|
+
case _omnichannelChatSdk.ChatSDKErrorName.WidgetUseOutsideOperatingHour:
|
|
34
|
+
handleWidgetUseOutsideOperatingHour(dispatch);
|
|
35
|
+
return;
|
|
36
|
+
case _omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure:
|
|
37
|
+
handlePersistentChatConversationRetrievalFailure(ex);
|
|
38
|
+
break;
|
|
39
|
+
case _omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure:
|
|
40
|
+
handleConversationInitializationFailure(ex);
|
|
41
|
+
break;
|
|
42
|
+
case _omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure:
|
|
43
|
+
handleChatTokenRetrievalFailure(ex);
|
|
44
|
+
break;
|
|
45
|
+
case _omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK:
|
|
46
|
+
handleUninitializedChatSDK(ex);
|
|
47
|
+
break;
|
|
48
|
+
case _omnichannelChatSdk.ChatSDKErrorName.InvalidConversation:
|
|
49
|
+
case _omnichannelChatSdk.ChatSDKErrorName.ClosedConversation:
|
|
50
|
+
handleInvalidOrClosedConversation(dispatch, chatSDK, props, ex);
|
|
51
|
+
return;
|
|
52
|
+
default:
|
|
53
|
+
logWidgetLoadFailed(ex);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Show the error UI pane
|
|
58
|
+
dispatch({
|
|
59
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
60
|
+
payload: true
|
|
61
|
+
});
|
|
62
|
+
if (!(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideErrorUIPane)) {
|
|
63
|
+
// New flow of leveraging ConversationState.Error
|
|
64
|
+
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
65
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
66
|
+
Event: _TelemetryConstants.TelemetryEvent.ErrorUIPaneLoaded,
|
|
67
|
+
Description: "Error UI Pane Loaded"
|
|
68
|
+
});
|
|
69
|
+
dispatch({
|
|
70
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
71
|
+
payload: _ConversationState.ConversationState.Error
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
// Old flow of leveraging ConversationState.Loading
|
|
75
|
+
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
76
|
+
dispatch({
|
|
77
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
78
|
+
payload: _ConversationState.ConversationState.Loading
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
83
|
+
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
84
|
+
if (isStartChatSuccessful === true) {
|
|
85
|
+
forceEndChat(chatSDK);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.handleStartChatError = handleStartChatError;
|
|
89
|
+
const logWidgetLoadFailed = ex => {
|
|
90
|
+
var _TelemetryTimers$Widg;
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
const exDetails = {
|
|
93
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
94
|
+
};
|
|
95
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
96
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
97
|
+
}
|
|
98
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
99
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
100
|
+
ExceptionDetails: exDetails,
|
|
101
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const logWidgetLoadComplete = additionalMessage => {
|
|
105
|
+
var _TelemetryTimers$Widg2;
|
|
106
|
+
let descriptionString = "Widget load complete";
|
|
107
|
+
if (additionalMessage) {
|
|
108
|
+
descriptionString += `. ${additionalMessage}`;
|
|
109
|
+
}
|
|
110
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
111
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
112
|
+
Description: descriptionString,
|
|
113
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
exports.logWidgetLoadComplete = logWidgetLoadComplete;
|
|
117
|
+
const logWidgetLoadCompleteWithError = ex => {
|
|
118
|
+
var _TelemetryTimers$Widg3;
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
+
const exDetails = {
|
|
121
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
122
|
+
};
|
|
123
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
124
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
125
|
+
}
|
|
126
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
127
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
128
|
+
Description: "Widget load complete with error",
|
|
129
|
+
ExceptionDetails: exDetails,
|
|
130
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
+
const forceEndChat = chatSDK => {
|
|
136
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
137
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
138
|
+
ExceptionDetails: {
|
|
139
|
+
Exception: "SessionInit was successful, but widget load failed."
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
143
|
+
};
|
|
144
|
+
const handleWidgetUseOutsideOperatingHour = dispatch => {
|
|
145
|
+
dispatch({
|
|
146
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
147
|
+
payload: true
|
|
148
|
+
});
|
|
149
|
+
dispatch({
|
|
150
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
151
|
+
payload: _ConversationState.ConversationState.OutOfOffice
|
|
152
|
+
});
|
|
153
|
+
logWidgetLoadComplete(_Constants.WidgetLoadTelemetryMessage.OOOHMessage);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
|
+
const handlePersistentChatConversationRetrievalFailure = ex => {
|
|
158
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
159
|
+
logWidgetLoadFailed(ex);
|
|
160
|
+
} else {
|
|
161
|
+
logWidgetLoadCompleteWithError(ex);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
166
|
+
const handleConversationInitializationFailure = ex => {
|
|
167
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
168
|
+
logWidgetLoadFailed(ex);
|
|
169
|
+
} else {
|
|
170
|
+
logWidgetLoadCompleteWithError(ex);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
175
|
+
const handleChatTokenRetrievalFailure = ex => {
|
|
176
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
177
|
+
logWidgetLoadFailed(ex);
|
|
178
|
+
} else {
|
|
179
|
+
logWidgetLoadCompleteWithError(ex);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
184
|
+
const handleUninitializedChatSDK = ex => {
|
|
185
|
+
logWidgetLoadCompleteWithError(ex);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
189
|
+
const handleInvalidOrClosedConversation = (dispatch, chatSDK, props, ex) => {
|
|
190
|
+
var _DataStoreManager$cli;
|
|
191
|
+
logWidgetLoadCompleteWithError(ex);
|
|
192
|
+
|
|
193
|
+
// Reset all internal states
|
|
194
|
+
(0, _endChat.callingStateCleanUp)(dispatch);
|
|
195
|
+
(0, _endChat.endChatStateCleanUp)(dispatch);
|
|
196
|
+
(0, _endChat.closeChatStateCleanUp)(dispatch);
|
|
197
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
198
|
+
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
199
|
+
|
|
200
|
+
// Starts new chat
|
|
201
|
+
dispatch({
|
|
202
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
203
|
+
payload: _ConversationState.ConversationState.Closed
|
|
204
|
+
});
|
|
205
|
+
};
|