@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
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
var _StartChatFailureType = require("../../../contexts/common/StartChatFailureType");
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSuccessful) => {
|
|
20
|
+
var _props$controlProps;
|
|
21
|
+
if (!ex) {
|
|
22
|
+
logWidgetLoadFailed();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Handle internal or misc errors
|
|
27
|
+
if (ex.message === _Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString) {
|
|
28
|
+
dispatch({
|
|
29
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
30
|
+
payload: _StartChatFailureType.StartChatFailureType.AuthSetupError
|
|
31
|
+
});
|
|
32
|
+
logWidgetLoadCompleteWithError(ex);
|
|
33
|
+
}
|
|
34
|
+
if (ex.message === _Constants.WidgetLoadCustomErrorString.NetworkErrorString) {
|
|
35
|
+
logWidgetLoadCompleteWithError(ex);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Handle ChatSDK errors
|
|
39
|
+
if (ex instanceof _omnichannelChatSdk.ChatSDKError) {
|
|
40
|
+
switch (ex.message) {
|
|
41
|
+
case _omnichannelChatSdk.ChatSDKErrorName.WidgetUseOutsideOperatingHour:
|
|
42
|
+
handleWidgetUseOutsideOperatingHour(dispatch);
|
|
43
|
+
return;
|
|
44
|
+
case _omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure:
|
|
45
|
+
handlePersistentChatConversationRetrievalFailure(ex);
|
|
46
|
+
break;
|
|
47
|
+
case _omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure:
|
|
48
|
+
handleConversationInitializationFailure(ex);
|
|
49
|
+
break;
|
|
50
|
+
case _omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure:
|
|
51
|
+
handleChatTokenRetrievalFailure(dispatch, ex);
|
|
52
|
+
break;
|
|
53
|
+
case _omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK:
|
|
54
|
+
handleUninitializedChatSDK(ex);
|
|
55
|
+
break;
|
|
56
|
+
case _omnichannelChatSdk.ChatSDKErrorName.InvalidConversation:
|
|
57
|
+
case _omnichannelChatSdk.ChatSDKErrorName.ClosedConversation:
|
|
58
|
+
handleInvalidOrClosedConversation(dispatch, chatSDK, props, ex);
|
|
59
|
+
return;
|
|
60
|
+
default:
|
|
61
|
+
logWidgetLoadFailed(ex);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Show the error UI pane
|
|
66
|
+
dispatch({
|
|
67
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
68
|
+
payload: true
|
|
69
|
+
});
|
|
70
|
+
if (!(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideErrorUIPane)) {
|
|
71
|
+
// New flow of leveraging ConversationState.Error
|
|
72
|
+
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
73
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
74
|
+
Event: _TelemetryConstants.TelemetryEvent.ErrorUIPaneLoaded,
|
|
75
|
+
Description: "Error UI Pane Loaded"
|
|
76
|
+
});
|
|
77
|
+
dispatch({
|
|
78
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
79
|
+
payload: _ConversationState.ConversationState.Error
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
// Old flow of leveraging ConversationState.Loading
|
|
83
|
+
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
84
|
+
dispatch({
|
|
85
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
86
|
+
payload: _ConversationState.ConversationState.Loading
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
91
|
+
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
92
|
+
if (isStartChatSuccessful === true) {
|
|
93
|
+
forceEndChat(chatSDK);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
exports.handleStartChatError = handleStartChatError;
|
|
97
|
+
const logWidgetLoadFailed = ex => {
|
|
98
|
+
var _TelemetryTimers$Widg;
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
|
+
const exDetails = {
|
|
101
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
102
|
+
};
|
|
103
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
104
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
105
|
+
}
|
|
106
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
107
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
108
|
+
ExceptionDetails: exDetails,
|
|
109
|
+
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
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
const logWidgetLoadComplete = additionalMessage => {
|
|
113
|
+
var _TelemetryTimers$Widg2;
|
|
114
|
+
let descriptionString = "Widget load complete";
|
|
115
|
+
if (additionalMessage) {
|
|
116
|
+
descriptionString += `. ${additionalMessage}`;
|
|
117
|
+
}
|
|
118
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
119
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
120
|
+
Description: descriptionString,
|
|
121
|
+
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
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
exports.logWidgetLoadComplete = logWidgetLoadComplete;
|
|
125
|
+
const logWidgetLoadCompleteWithError = ex => {
|
|
126
|
+
var _TelemetryTimers$Widg3;
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
const exDetails = {
|
|
129
|
+
Exception: `Widget load complete with error: ${ex}`
|
|
130
|
+
};
|
|
131
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
132
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
133
|
+
}
|
|
134
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
135
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
136
|
+
Description: "Widget load complete with error",
|
|
137
|
+
ExceptionDetails: exDetails,
|
|
138
|
+
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
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
143
|
+
const forceEndChat = chatSDK => {
|
|
144
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
145
|
+
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
146
|
+
Description: _Constants.PrepareEndChatDescriptionConstants.WidgetLoadFailedAfterSessionInit
|
|
147
|
+
});
|
|
148
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
149
|
+
Event: _TelemetryConstants.TelemetryEvent.EndChatSDKCall
|
|
150
|
+
});
|
|
151
|
+
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
152
|
+
};
|
|
153
|
+
const handleWidgetUseOutsideOperatingHour = dispatch => {
|
|
154
|
+
dispatch({
|
|
155
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
156
|
+
payload: true
|
|
157
|
+
});
|
|
158
|
+
dispatch({
|
|
159
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
160
|
+
payload: _ConversationState.ConversationState.OutOfOffice
|
|
161
|
+
});
|
|
162
|
+
logWidgetLoadComplete(_Constants.WidgetLoadTelemetryMessage.OOOHMessage);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
166
|
+
const handlePersistentChatConversationRetrievalFailure = 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 handleConversationInitializationFailure = 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 handleChatTokenRetrievalFailure = (dispatch, ex) => {
|
|
185
|
+
if (ex.httpResponseStatusCode === 400) {
|
|
186
|
+
logWidgetLoadFailed(ex);
|
|
187
|
+
} else {
|
|
188
|
+
if (ex.httpResponseStatusCode === 401) {
|
|
189
|
+
dispatch({
|
|
190
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
191
|
+
payload: _StartChatFailureType.StartChatFailureType.Unauthorized
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
logWidgetLoadCompleteWithError(ex);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
199
|
+
const handleUninitializedChatSDK = ex => {
|
|
200
|
+
logWidgetLoadCompleteWithError(ex);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
204
|
+
const handleInvalidOrClosedConversation = (dispatch, chatSDK, props, ex) => {
|
|
205
|
+
var _DataStoreManager$cli;
|
|
206
|
+
logWidgetLoadCompleteWithError(ex);
|
|
207
|
+
|
|
208
|
+
// Reset all internal states
|
|
209
|
+
(0, _endChat.callingStateCleanUp)(dispatch);
|
|
210
|
+
(0, _endChat.endChatStateCleanUp)(dispatch);
|
|
211
|
+
(0, _endChat.closeChatStateCleanUp)(dispatch);
|
|
212
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
213
|
+
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
214
|
+
|
|
215
|
+
// Starts new chat
|
|
216
|
+
dispatch({
|
|
217
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
218
|
+
payload: _ConversationState.ConversationState.Closed
|
|
219
|
+
});
|
|
220
|
+
};
|
|
@@ -55,13 +55,14 @@ var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useCha
|
|
|
55
55
|
var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
|
|
56
56
|
var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
|
|
57
57
|
var _defaultAdaptiveCardStyles = require("../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles");
|
|
58
|
-
var
|
|
58
|
+
var _StartChatErrorPaneStateful = _interopRequireDefault(require("../../startchaterrorpanestateful/StartChatErrorPaneStateful"));
|
|
59
|
+
var _StartChatFailureType = require("../../../contexts/common/StartChatFailureType");
|
|
59
60
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
60
61
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
61
62
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
62
63
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
63
64
|
const LiveChatWidgetStateful = props => {
|
|
64
|
-
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$
|
|
65
|
+
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;
|
|
65
66
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
66
67
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
68
|
const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
|
|
@@ -194,6 +195,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
194
195
|
};
|
|
195
196
|
(0, _react2.useEffect)(() => {
|
|
196
197
|
var _props$controlProps5, _props$controlProps6, _props$controlProps7, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps9, _props$chatConfig2, _props$chatConfig2$Ch, _state$appStates5;
|
|
198
|
+
dispatch({
|
|
199
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
200
|
+
payload: false
|
|
201
|
+
});
|
|
202
|
+
dispatch({
|
|
203
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
204
|
+
payload: _StartChatFailureType.StartChatFailureType.Generic
|
|
205
|
+
});
|
|
197
206
|
state.domainStates.confirmationPaneConfirmedOptionClicked = false;
|
|
198
207
|
state.domainStates.confirmationState = _Constants.ConfirmationState.NotSet;
|
|
199
208
|
setupClientDataStore();
|
|
@@ -404,9 +413,23 @@ const LiveChatWidgetStateful = props => {
|
|
|
404
413
|
|
|
405
414
|
// End chat
|
|
406
415
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
416
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
417
|
+
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
418
|
+
Description: "Received InitiateEndChat BroadcastEvent."
|
|
419
|
+
});
|
|
420
|
+
|
|
407
421
|
// This is to ensure to get latest state from cache in multitab
|
|
408
422
|
const persistedState = (0, _utils.getStateFromCache)((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
409
423
|
if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
424
|
+
// We need to simulate states for closing chat, in order to messup with close confirmation pane.
|
|
425
|
+
dispatch({
|
|
426
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONFIRMATION_STATE,
|
|
427
|
+
payload: _Constants.ConfirmationState.Ok
|
|
428
|
+
});
|
|
429
|
+
dispatch({
|
|
430
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
|
|
431
|
+
payload: false
|
|
432
|
+
});
|
|
410
433
|
dispatch({
|
|
411
434
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
412
435
|
payload: _Constants.ConversationEndEntity.Customer
|
|
@@ -414,6 +437,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
414
437
|
} else {
|
|
415
438
|
const skipEndChatSDK = true;
|
|
416
439
|
const skipCloseChat = false;
|
|
440
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
441
|
+
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
442
|
+
Description: _Constants.PrepareEndChatDescriptionConstants.InitiateEndChatReceived
|
|
443
|
+
});
|
|
417
444
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
418
445
|
}
|
|
419
446
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
@@ -431,14 +458,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
431
458
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
432
459
|
var _msg$payload9;
|
|
433
460
|
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
461
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
462
|
+
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
463
|
+
Description: "Received EndChat BroadcastEvent from other tabs. Closing this chat."
|
|
464
|
+
});
|
|
434
465
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
435
466
|
(0, _endChat.endChatStateCleanUp)(dispatch);
|
|
436
|
-
|
|
437
|
-
chatSDK.requestId = (0, _omnichannelChatSdk.uuidv4)();
|
|
438
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
439
|
-
chatSDK.chatToken = {};
|
|
440
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
441
|
-
chatSDK.reconnectId = null;
|
|
467
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
442
468
|
return;
|
|
443
469
|
}
|
|
444
470
|
});
|
|
@@ -566,12 +592,20 @@ const LiveChatWidgetStateful = props => {
|
|
|
566
592
|
|
|
567
593
|
// If start chat failed, and C2 is trying to close chat widget
|
|
568
594
|
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.ConversationState.Postchat) {
|
|
595
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
596
|
+
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
597
|
+
Description: _Constants.PrepareEndChatDescriptionConstants.CustomerCloseChatOnFailureOrPostChat
|
|
598
|
+
});
|
|
569
599
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true);
|
|
570
600
|
return;
|
|
571
601
|
}
|
|
572
602
|
|
|
573
603
|
// Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
|
|
574
604
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === _ConversationState.ConversationState.InActive) {
|
|
605
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
606
|
+
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
607
|
+
Description: _Constants.PrepareEndChatDescriptionConstants.CustomerCloseInactiveChat
|
|
608
|
+
});
|
|
575
609
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
576
610
|
return;
|
|
577
611
|
}
|
|
@@ -616,9 +650,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
616
650
|
|
|
617
651
|
// Handle Chat disconnect cases
|
|
618
652
|
(0, _react2.useEffect)(() => {
|
|
619
|
-
|
|
620
|
-
(0, _chatDisconnectHelper.handleChatDisconnect)(props, state, setWebChatStyles);
|
|
621
|
-
}
|
|
653
|
+
(0, _chatDisconnectHelper.handleChatDisconnect)(props, state, setWebChatStyles);
|
|
622
654
|
}, [state.appStates.chatDisconnectEventReceived]);
|
|
623
655
|
const initiateEndChatOnBrowserUnload = () => {
|
|
624
656
|
var _DataStoreManager$cli;
|
|
@@ -626,6 +658,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
626
658
|
Event: _TelemetryConstants.TelemetryEvent.BrowserUnloadEventStarted,
|
|
627
659
|
Description: "Browser unload event received."
|
|
628
660
|
});
|
|
661
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
662
|
+
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
663
|
+
Description: _Constants.PrepareEndChatDescriptionConstants.BrowserUnload
|
|
664
|
+
});
|
|
629
665
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, false);
|
|
630
666
|
// Clean local storage
|
|
631
667
|
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventId);
|
|
@@ -715,18 +751,18 @@ const LiveChatWidgetStateful = props => {
|
|
|
715
751
|
}, headerDraggableConfig))), !((_livechatProps$contro5 = livechatProps.controlProps) !== null && _livechatProps$contro5 !== void 0 && _livechatProps$contro5.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon4 = livechatProps.componentOverrides) === null || _livechatProps$compon4 === void 0 ? void 0 : _livechatProps$compon4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, {
|
|
716
752
|
loadingPaneProps: livechatProps.loadingPaneProps,
|
|
717
753
|
startChatErrorPaneProps: livechatProps.startChatErrorPaneProps
|
|
718
|
-
})), !((_livechatProps$contro6 = livechatProps.controlProps) !== null && _livechatProps$contro6 !== void 0 && _livechatProps$contro6.
|
|
754
|
+
})), !((_livechatProps$contro6 = livechatProps.controlProps) !== null && _livechatProps$contro6 !== void 0 && _livechatProps$contro6.hideErrorUIPane) && (0, _componentController.shouldShowStartChatErrorPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon5 = livechatProps.componentOverrides) === null || _livechatProps$compon5 === void 0 ? void 0 : _livechatProps$compon5.startChatErrorPane) || /*#__PURE__*/_react2.default.createElement(_StartChatErrorPaneStateful.default, livechatProps.startChatErrorPaneProps)), !((_livechatProps$contro7 = livechatProps.controlProps) !== null && _livechatProps$contro7 !== void 0 && _livechatProps$contro7.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon6 = livechatProps.componentOverrides) === null || _livechatProps$compon6 === void 0 ? void 0 : _livechatProps$compon6.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, livechatProps.outOfOfficeHoursPaneProps)), !((_livechatProps$contro8 = livechatProps.controlProps) !== null && _livechatProps$contro8 !== void 0 && _livechatProps$contro8.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon7 = livechatProps.componentOverrides) === null || _livechatProps$compon7 === void 0 ? void 0 : _livechatProps$compon7.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
|
|
719
755
|
reconnectChatProps: livechatProps.reconnectChatPaneProps,
|
|
720
756
|
initStartChat: initStartChatRelay
|
|
721
|
-
})), !((_livechatProps$
|
|
757
|
+
})), !((_livechatProps$contro9 = livechatProps.controlProps) !== null && _livechatProps$contro9 !== void 0 && _livechatProps$contro9.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon8 = livechatProps.componentOverrides) === null || _livechatProps$compon8 === void 0 ? void 0 : _livechatProps$compon8.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
|
|
722
758
|
surveyProps: livechatProps.preChatSurveyPaneProps,
|
|
723
759
|
initStartChat: initStartChatRelay
|
|
724
|
-
})), !((_livechatProps$
|
|
760
|
+
})), !((_livechatProps$contro10 = livechatProps.controlProps) !== null && _livechatProps$contro10 !== void 0 && _livechatProps$contro10.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
725
761
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
726
|
-
}, livechatProps.callingContainerProps)), !((_livechatProps$
|
|
762
|
+
}, livechatProps.callingContainerProps)), !((_livechatProps$contro11 = livechatProps.controlProps) !== null && _livechatProps$contro11 !== void 0 && _livechatProps$contro11.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon9 = livechatProps.componentOverrides) === null || _livechatProps$compon9 === void 0 ? void 0 : _livechatProps$compon9.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, livechatProps)), !((_livechatProps$contro12 = livechatProps.controlProps) !== null && _livechatProps$contro12 !== void 0 && _livechatProps$contro12.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon10 = livechatProps.componentOverrides) === null || _livechatProps$compon10 === void 0 ? void 0 : _livechatProps$compon10.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
|
|
727
763
|
setPostChatContext: setPostChatContextRelay,
|
|
728
764
|
prepareEndChat: prepareEndChatRelay
|
|
729
|
-
}))), !((_livechatProps$
|
|
765
|
+
}))), !((_livechatProps$contro13 = livechatProps.controlProps) !== null && _livechatProps$contro13 !== void 0 && _livechatProps$contro13.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, livechatProps.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK))), (0, _createFooter.createFooter)(livechatProps, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon13 = livechatProps.componentOverrides) === null || _livechatProps$compon13 === void 0 ? void 0 : _livechatProps$compon13.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, livechatProps.emailTranscriptPane))))));
|
|
730
766
|
};
|
|
731
767
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
732
768
|
var _default = LiveChatWidgetStateful;
|
|
@@ -9,10 +9,10 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
10
10
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
11
11
|
var _defaultgeneralLoadingPaneStyleProps = require("./common/defaultStyleProps/defaultgeneralLoadingPaneStyleProps");
|
|
12
|
-
var _errorUILoadingPaneStyleProps = require("./common/errorUIStyleProps/errorUILoadingPaneStyleProps");
|
|
13
12
|
var _utils = require("../../common/utils");
|
|
14
13
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
15
14
|
var _useWindowDimensions = _interopRequireDefault(require("../../hooks/useWindowDimensions"));
|
|
15
|
+
var _errorUILoadingPaneStyleProps = require("./common/errorUIStyleProps/errorUILoadingPaneStyleProps");
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.StartChatErrorPaneStateful = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
|
+
var _utils = require("../../common/utils");
|
|
10
|
+
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
11
|
+
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
12
|
+
var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
|
|
13
|
+
var _defaultStartChatErrorPaneGeneralStyleProps = require("./common/defaultStartChatErrorPaneGeneralStyleProps");
|
|
14
|
+
var _defaultStartChatErrorPaneTitleStyleProps = require("./common/defaultStartChatErrorPaneTitleStyleProps");
|
|
15
|
+
var _defaultStartChatErrorPaneSubtitleStyleProps = require("./common/defaultStartChatErrorPaneSubtitleStyleProps");
|
|
16
|
+
var _defaultStartChatErrorPaneIconStyleProps = require("./common/defaultStartChatErrorPaneIconStyleProps");
|
|
17
|
+
var _defaultStartChatErrorPaneIconImageProps = require("./common/defaultStartChatErrorPaneIconImageProps");
|
|
18
|
+
var _Constants = require("../../common/Constants");
|
|
19
|
+
var _StartChatFailureType = require("../../contexts/common/StartChatFailureType");
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
const StartChatErrorPaneStateful = startChatErrorPaneProps => {
|
|
24
|
+
var _startChatErrorPanePr, _startChatErrorPanePr2, _startChatErrorPanePr3, _startChatErrorPanePr4, _startChatErrorPanePr5, _startChatErrorPanePr6, _startChatErrorPanePr7, _startChatErrorPanePr8, _startChatErrorPanePr9, _startChatErrorPanePr10, _startChatErrorPanePr11;
|
|
25
|
+
const [state] = (0, _useChatContextStore.default)();
|
|
26
|
+
const generalStyleProps = Object.assign({}, _defaultStartChatErrorPaneGeneralStyleProps.defaultStartChatErrorPaneGeneralStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr === void 0 ? void 0 : _startChatErrorPanePr.generalStyleProps);
|
|
27
|
+
const titleStyleProps = Object.assign({}, _defaultStartChatErrorPaneTitleStyleProps.defaultStartChatErrorPaneTitleStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr2 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr2 === void 0 ? void 0 : _startChatErrorPanePr2.titleStyleProps);
|
|
28
|
+
const subtitleStyleProps = Object.assign({}, _defaultStartChatErrorPaneSubtitleStyleProps.defaultStartChatErrorPaneSubtitleStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr3 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr3 === void 0 ? void 0 : _startChatErrorPanePr3.subtitleStyleProps);
|
|
29
|
+
const iconStyleProps = Object.assign({}, _defaultStartChatErrorPaneIconStyleProps.defaultStartChatErrorPaneIconStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr4 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr4 === void 0 ? void 0 : _startChatErrorPanePr4.iconStyleProps);
|
|
30
|
+
const iconImageProps = Object.assign({}, _defaultStartChatErrorPaneIconImageProps.defaultStartChatErrorPaneIconImageStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr5 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr5 === void 0 ? void 0 : _startChatErrorPanePr5.iconImageProps);
|
|
31
|
+
const errorUIStyleProps = {
|
|
32
|
+
generalStyleProps: generalStyleProps,
|
|
33
|
+
titleStyleProps: titleStyleProps,
|
|
34
|
+
subtitleStyleProps: subtitleStyleProps,
|
|
35
|
+
iconStyleProps: iconStyleProps,
|
|
36
|
+
iconImageProps: iconImageProps
|
|
37
|
+
};
|
|
38
|
+
let errorPaneTitleText;
|
|
39
|
+
let errorPaneSubtitleText;
|
|
40
|
+
switch (state.domainStates.startChatFailureType) {
|
|
41
|
+
case _StartChatFailureType.StartChatFailureType.Unauthorized:
|
|
42
|
+
errorPaneTitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr6 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr6 === void 0 ? void 0 : _startChatErrorPanePr6.unauthorizedTitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorUnauthorizedTitleText;
|
|
43
|
+
errorPaneSubtitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr7 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr7 === void 0 ? void 0 : _startChatErrorPanePr7.unauthorizedSubtitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorUnauthorizedSubtitleText;
|
|
44
|
+
break;
|
|
45
|
+
case _StartChatFailureType.StartChatFailureType.AuthSetupError:
|
|
46
|
+
errorPaneTitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr8 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr8 === void 0 ? void 0 : _startChatErrorPanePr8.authSetupErrorTitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorAuthSetupErrorTitleText;
|
|
47
|
+
errorPaneSubtitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr9 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr9 === void 0 ? void 0 : _startChatErrorPanePr9.authSetupErrorSubtitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorAuthSetupErrorSubtitleText;
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
errorPaneTitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr10 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr10 === void 0 ? void 0 : _startChatErrorPanePr10.titleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorTitleText;
|
|
51
|
+
errorPaneSubtitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr11 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr11 === void 0 ? void 0 : _startChatErrorPanePr11.subtitleText) ?? _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorSubtitleText;
|
|
52
|
+
}
|
|
53
|
+
const errorUIControlProps = {
|
|
54
|
+
id: _Constants.StartChatErrorPaneConstants.DefaultStartChatErrorPaneId,
|
|
55
|
+
dir: state.domainStates.globalDir,
|
|
56
|
+
hideSpinner: true,
|
|
57
|
+
hideSpinnerText: true,
|
|
58
|
+
...(startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : startChatErrorPaneProps.controlProps),
|
|
59
|
+
titleText: errorPaneTitleText,
|
|
60
|
+
subtitleText: errorPaneSubtitleText
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// Move focus to the first button
|
|
64
|
+
(0, _react.useEffect)(() => {
|
|
65
|
+
const firstElement = (0, _utils.findAllFocusableElement)(`#${state.domainStates.widgetElementId}`);
|
|
66
|
+
if (firstElement && firstElement[0]) {
|
|
67
|
+
firstElement[0].focus();
|
|
68
|
+
}
|
|
69
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
70
|
+
Event: _TelemetryConstants.TelemetryEvent.StartChatErrorPaneLoaded,
|
|
71
|
+
Description: "Start chat error pane loaded."
|
|
72
|
+
});
|
|
73
|
+
}, []);
|
|
74
|
+
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.LoadingPane, {
|
|
75
|
+
componentOverrides: startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : startChatErrorPaneProps.componentOverrides,
|
|
76
|
+
controlProps: errorUIControlProps,
|
|
77
|
+
styleProps: errorUIStyleProps
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
exports.StartChatErrorPaneStateful = StartChatErrorPaneStateful;
|
|
81
|
+
var _default = StartChatErrorPaneStateful;
|
|
82
|
+
exports.default = _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStartChatErrorPaneGeneralStyleProps = void 0;
|
|
7
|
+
const defaultStartChatErrorPaneGeneralStyleProps = {
|
|
8
|
+
position: "initial",
|
|
9
|
+
width: "100%",
|
|
10
|
+
height: "100%",
|
|
11
|
+
left: "0%",
|
|
12
|
+
top: "0%",
|
|
13
|
+
borderRadius: "0 0 4px 4px",
|
|
14
|
+
borderWidth: "0px",
|
|
15
|
+
backgroundColor: "#FFFFFF"
|
|
16
|
+
};
|
|
17
|
+
exports.defaultStartChatErrorPaneGeneralStyleProps = defaultStartChatErrorPaneGeneralStyleProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStartChatErrorPaneIconImageStyleProps = void 0;
|
|
7
|
+
var _react = require("@fluentui/react");
|
|
8
|
+
var _Icons = require("../../../assets/Icons");
|
|
9
|
+
const defaultStartChatErrorPaneIconImageStyleProps = {
|
|
10
|
+
src: _Icons.AlertIcon,
|
|
11
|
+
imageFit: _react.ImageFit.centerContain,
|
|
12
|
+
width: "86px",
|
|
13
|
+
height: "86px",
|
|
14
|
+
shouldFadeIn: false,
|
|
15
|
+
shouldStartVisible: true
|
|
16
|
+
};
|
|
17
|
+
exports.defaultStartChatErrorPaneIconImageStyleProps = defaultStartChatErrorPaneIconImageStyleProps;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStartChatErrorPaneIconStyleProps = void 0;
|
|
7
|
+
const defaultStartChatErrorPaneIconStyleProps = {
|
|
8
|
+
display: "flex",
|
|
9
|
+
order: 1,
|
|
10
|
+
alignSelf: "auto",
|
|
11
|
+
backgroundColor: "#FFFFFF",
|
|
12
|
+
boxShadow: "#FFFFFF 0px 0px 0px 0px",
|
|
13
|
+
margin: "0px 0px 0px 0px"
|
|
14
|
+
};
|
|
15
|
+
exports.defaultStartChatErrorPaneIconStyleProps = defaultStartChatErrorPaneIconStyleProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStartChatErrorPaneSubtitleStyleProps = void 0;
|
|
7
|
+
const defaultStartChatErrorPaneSubtitleStyleProps = {
|
|
8
|
+
fontFamily: "'Segoe UI',Arial,sans-serif",
|
|
9
|
+
fontWeight: "normal",
|
|
10
|
+
fontSize: "18px",
|
|
11
|
+
color: "#36454F",
|
|
12
|
+
textAlign: "center",
|
|
13
|
+
display: "flex",
|
|
14
|
+
order: 3,
|
|
15
|
+
alignSelf: "auto"
|
|
16
|
+
};
|
|
17
|
+
exports.defaultStartChatErrorPaneSubtitleStyleProps = defaultStartChatErrorPaneSubtitleStyleProps;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultStartChatErrorPaneTitleStyleProps = void 0;
|
|
7
|
+
const defaultStartChatErrorPaneTitleStyleProps = {
|
|
8
|
+
fontFamily: "'Segoe UI',Arial,sans-serif",
|
|
9
|
+
fontWeight: "normal",
|
|
10
|
+
fontSize: "18px",
|
|
11
|
+
color: "#36454F",
|
|
12
|
+
textAlign: "center",
|
|
13
|
+
display: "flex",
|
|
14
|
+
order: 2,
|
|
15
|
+
alignSelf: "auto"
|
|
16
|
+
};
|
|
17
|
+
exports.defaultStartChatErrorPaneTitleStyleProps = defaultStartChatErrorPaneTitleStyleProps;
|
package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -8,7 +8,6 @@ var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryCons
|
|
|
8
8
|
var _Constants = require("../../../../../common/Constants");
|
|
9
9
|
var _DirectLineActivityType = require("../../enums/DirectLineActivityType");
|
|
10
10
|
var _DirectLineSenderRole = require("../../enums/DirectLineSenderRole");
|
|
11
|
-
var _MessageType = require("../../enums/MessageType");
|
|
12
11
|
var _react = _interopRequireDefault(require("react"));
|
|
13
12
|
var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
|
|
14
13
|
var _defaultSystemMessageStyles = require("./defaultStyles/defaultSystemMessageStyles");
|
|
@@ -55,7 +54,7 @@ const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
|
|
|
55
54
|
return () => /*#__PURE__*/_react.default.createElement("div", {
|
|
56
55
|
key: card.activity.id,
|
|
57
56
|
style: systemMessageStyles,
|
|
58
|
-
"aria-hidden": "
|
|
57
|
+
"aria-hidden": "false",
|
|
59
58
|
dangerouslySetInnerHTML: {
|
|
60
59
|
__html: (0, _utils.escapeHtml)(card.activity.text)
|
|
61
60
|
}
|
|
@@ -81,13 +80,6 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
|
|
|
81
80
|
if (card.activity) {
|
|
82
81
|
var _card$activity$from;
|
|
83
82
|
if (((_card$activity$from = card.activity.from) === null || _card$activity$from === void 0 ? void 0 : _card$activity$from.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel) {
|
|
84
|
-
var _card$activity$channe3;
|
|
85
|
-
if (((_card$activity$channe3 = card.activity.channelData) === null || _card$activity$channe3 === void 0 ? void 0 : _card$activity$channe3.type) === _MessageType.MessageTypes.Thread) {
|
|
86
|
-
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
87
|
-
Event: _TelemetryConstants.TelemetryEvent.IC3ThreadUpdateEventReceived,
|
|
88
|
-
Description: "IC3 ThreadUpdateEvent Received"
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
83
|
return () => false;
|
|
92
84
|
}
|
|
93
85
|
if (isTagIncluded(card, _Constants.Constants.hiddenTag)) {
|
|
@@ -108,8 +100,7 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
|
|
|
108
100
|
return function () {
|
|
109
101
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
110
102
|
className: card.activity.from.role === _DirectLineSenderRole.DirectLineSenderRole.User ? _Constants.Constants.sentMessageClassName : _Constants.Constants.receivedMessageClassName,
|
|
111
|
-
style: userMessageStyles
|
|
112
|
-
"aria-hidden": "true"
|
|
103
|
+
style: userMessageStyles
|
|
113
104
|
}, next(...args)(...arguments));
|
|
114
105
|
};
|
|
115
106
|
}
|