@microsoft/omnichannel-chat-widget 1.7.4-main.a36bdf2 → 1.7.4-main.b7b6783
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/facades/FacadeChatSDK.js +298 -0
- package/lib/cjs/common/facades/types/IFacadeChatSDKInput.js +1 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +5 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +12 -0
- package/lib/cjs/common/utils.js +2 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
- package/lib/cjs/components/footerstateful/FooterStateful.js +4 -5
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +26 -3
- package/lib/cjs/components/livechatwidget/common/authHelper.js +14 -5
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +9 -9
- package/lib/cjs/components/livechatwidget/common/endChat.js +33 -30
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +3 -3
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +2 -3
- package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +4 -4
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -12
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +45 -39
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +7 -7
- package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +33 -33
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
- package/lib/cjs/contexts/FacadeChatSDKStore.js +10 -0
- package/lib/cjs/hooks/useFacadeChatSDKStore.js +17 -0
- package/lib/cjs/index.js +9 -2
- package/lib/cjs/plugins/createChatTranscript.js +2 -2
- package/lib/esm/common/facades/FacadeChatSDK.js +291 -0
- package/lib/esm/common/facades/types/IFacadeChatSDKInput.js +1 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +5 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +12 -0
- package/lib/esm/common/utils.js +2 -2
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
- package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +26 -3
- package/lib/esm/components/livechatwidget/common/authHelper.js +14 -5
- package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -9
- package/lib/esm/components/livechatwidget/common/endChat.js +33 -30
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +3 -3
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +2 -4
- package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +4 -4
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -12
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +46 -40
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
- package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +33 -33
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
- package/lib/esm/contexts/FacadeChatSDKStore.js +4 -0
- package/lib/esm/hooks/useFacadeChatSDKStore.js +10 -0
- package/lib/esm/index.js +5 -4
- package/lib/esm/plugins/createChatTranscript.js +2 -2
- package/lib/types/common/facades/FacadeChatSDK.d.ts +71 -0
- package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +13 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -1
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +7 -0
- package/lib/types/common/utils.d.ts +2 -1
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +3 -2
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +14 -1
- package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/initCallingSdk.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/persistentChatHelper.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +3 -2
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -1
- package/lib/types/contexts/FacadeChatSDKStore.d.ts +1 -0
- package/lib/types/hooks/useFacadeChatSDKStore.d.ts +3 -0
- package/lib/types/index.d.ts +4 -3
- package/lib/types/plugins/createChatTranscript.d.ts +2 -1
- package/package.json +4 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import { Constants, LiveWorkItemState, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
3
|
-
import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
3
|
+
import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty } from "../../../common/utils";
|
|
4
4
|
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
5
5
|
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
|
|
6
6
|
import { handleStartChatError, logWidgetLoadComplete } from "./startChatErrorHandler";
|
|
@@ -26,27 +26,27 @@ let widgetInstanceId;
|
|
|
26
26
|
let popoutWidgetInstanceId;
|
|
27
27
|
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
const setAuthenticationIfApplicable = async (props,
|
|
29
|
+
const setAuthenticationIfApplicable = async (props, facadeChatSDK) => {
|
|
30
30
|
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
31
31
|
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
32
32
|
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
33
33
|
if (getAuthToken && authClientFunction) {
|
|
34
34
|
// set auth token to chat sdk before start chat
|
|
35
|
-
const authSuccess = await handleAuthentication(
|
|
36
|
-
if (!authSuccess) {
|
|
35
|
+
const authSuccess = await handleAuthentication(facadeChatSDK.getChatSDK(), chatConfig, getAuthToken);
|
|
36
|
+
if (!authSuccess.result) {
|
|
37
37
|
throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
-
const prepareStartChat = async (props,
|
|
43
|
+
const prepareStartChat = async (props, facadeChatSDK, state, dispatch, setAdapter) => {
|
|
44
44
|
optionalParams = {}; //Resetting to ensure no stale values
|
|
45
45
|
widgetInstanceId = getWidgetCacheIdfromProps(props);
|
|
46
46
|
|
|
47
47
|
// reconnect > chat from cache
|
|
48
48
|
if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
|
|
49
|
-
const shouldStartChatNormally = await handleChatReconnect(
|
|
49
|
+
const shouldStartChatNormally = await handleChatReconnect(facadeChatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
50
50
|
if (!shouldStartChatNormally) {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
@@ -58,7 +58,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Can connect to existing chat session
|
|
61
|
-
if (await canConnectToExistingChat(props,
|
|
61
|
+
if (await canConnectToExistingChat(props, facadeChatSDK, state, dispatch, setAdapter)) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -68,26 +68,30 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
68
68
|
|
|
69
69
|
// Setting auth settings to OC API to retrieve existing persistent chat session before start chat if any
|
|
70
70
|
if (isPersistentEnabled(props.chatConfig)) {
|
|
71
|
-
await setAuthenticationIfApplicable(props,
|
|
71
|
+
await setAuthenticationIfApplicable(props, facadeChatSDK);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
//Setting PreChat and intiate chat
|
|
75
|
-
await setPreChatAndInitiateChat(
|
|
75
|
+
await setPreChatAndInitiateChat(facadeChatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
-
const setPreChatAndInitiateChat = async (
|
|
79
|
+
const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState, state, props) => {
|
|
80
80
|
var _props$preChatSurveyP, _props$preChatSurveyP2, _props$controlProps, _state$domainStates, _state$domainStates$l, _state$domainStates$l2;
|
|
81
|
-
//
|
|
81
|
+
// This reset needs to be done before to load prechat, because the conversation state changes from close to prechat
|
|
82
|
+
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === ConversationState.Closed) {
|
|
83
|
+
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
84
|
+
chatSDKStateCleanUp(facadeChatSDK.getChatSDK());
|
|
85
|
+
}
|
|
82
86
|
|
|
83
87
|
// Getting prechat Survey Context
|
|
84
88
|
const parseToJson = false;
|
|
85
|
-
const preChatSurveyResponse = (props === null || props === void 0 ? void 0 : (_props$preChatSurveyP = props.preChatSurveyPaneProps) === null || _props$preChatSurveyP === void 0 ? void 0 : (_props$preChatSurveyP2 = _props$preChatSurveyP.controlProps) === null || _props$preChatSurveyP2 === void 0 ? void 0 : _props$preChatSurveyP2.payload) ?? (await
|
|
89
|
+
const preChatSurveyResponse = (props === null || props === void 0 ? void 0 : (_props$preChatSurveyP = props.preChatSurveyPaneProps) === null || _props$preChatSurveyP === void 0 ? void 0 : (_props$preChatSurveyP2 = _props$preChatSurveyP.controlProps) === null || _props$preChatSurveyP2 === void 0 ? void 0 : _props$preChatSurveyP2.payload) ?? (await facadeChatSDK.getPreChatSurvey(parseToJson));
|
|
86
90
|
let showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse && !(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hidePreChatSurveyPane);
|
|
87
|
-
showPrechat = await shouldSetPreChatIfPersistentChat(
|
|
91
|
+
showPrechat = await shouldSetPreChatIfPersistentChat(facadeChatSDK.getChatSDK(), state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l = _state$domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_conversationmode, showPrechat);
|
|
88
92
|
if (showPrechat) {
|
|
89
93
|
var _state$domainStates2, _state$domainStates2$, _state$domainStates2$2, _state$domainStates2$3;
|
|
90
|
-
const isOutOfOperatingHours = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.liveChatConfig) === null || _state$domainStates2$ === void 0 ? void 0 : (_state$domainStates2$2 = _state$domainStates2$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates2$2 === void 0 ? void 0 : (_state$domainStates2$3 = _state$domainStates2$2.OutOfOperatingHours) === null || _state$domainStates2$3 === void 0 ? void 0 : _state$domainStates2$3.toLowerCase()) === "true";
|
|
94
|
+
const isOutOfOperatingHours = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.liveChatConfig) === null || _state$domainStates2$ === void 0 ? void 0 : (_state$domainStates2$2 = _state$domainStates2$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates2$2 === void 0 ? void 0 : (_state$domainStates2$3 = _state$domainStates2$2.OutOfOperatingHours) === null || _state$domainStates2$3 === void 0 ? void 0 : _state$domainStates2$3.toString().toLowerCase()) === "true";
|
|
91
95
|
if (isOutOfOperatingHours) {
|
|
92
96
|
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
93
97
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -138,17 +142,17 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
138
142
|
const optionalParams = {
|
|
139
143
|
isProactiveChat
|
|
140
144
|
};
|
|
141
|
-
await initStartChat(
|
|
145
|
+
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
|
|
142
146
|
};
|
|
143
147
|
|
|
144
148
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
|
-
const initStartChat = async (
|
|
149
|
+
const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
146
150
|
var _state$domainStates5, _state$domainStates5$, _state$domainStates5$2;
|
|
147
151
|
let isStartChatSuccessful = false;
|
|
148
152
|
const persistentChatEnabled = await isPersistentChatEnabled(state === null || state === void 0 ? void 0 : (_state$domainStates5 = state.domainStates) === null || _state$domainStates5 === void 0 ? void 0 : (_state$domainStates5$ = _state$domainStates5.liveChatConfig) === null || _state$domainStates5$ === void 0 ? void 0 : (_state$domainStates5$2 = _state$domainStates5$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates5$2 === void 0 ? void 0 : _state$domainStates5$2.msdyn_conversationmode);
|
|
149
153
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === ConversationState.Closed) {
|
|
150
154
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
151
|
-
chatSDKStateCleanUp(
|
|
155
|
+
chatSDKStateCleanUp(facadeChatSDK.getChatSDK());
|
|
152
156
|
}
|
|
153
157
|
try {
|
|
154
158
|
var _state$appStates2;
|
|
@@ -166,7 +170,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
166
170
|
});
|
|
167
171
|
|
|
168
172
|
// Auth token retrieval needs to happen during start chat to support pop-out chat
|
|
169
|
-
await setAuthenticationIfApplicable(props,
|
|
173
|
+
await setAuthenticationIfApplicable(props, facadeChatSDK);
|
|
170
174
|
|
|
171
175
|
//Check if chat retrieved from cache
|
|
172
176
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
@@ -189,7 +193,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
189
193
|
portalContactId: (_window$Microsoft = window.Microsoft) === null || _window$Microsoft === void 0 ? void 0 : (_window$Microsoft$Dyn = _window$Microsoft.Dynamic365) === null || _window$Microsoft$Dyn === void 0 ? void 0 : (_window$Microsoft$Dyn2 = _window$Microsoft$Dyn.Portal) === null || _window$Microsoft$Dyn2 === void 0 ? void 0 : (_window$Microsoft$Dyn3 = _window$Microsoft$Dyn2.User) === null || _window$Microsoft$Dyn3 === void 0 ? void 0 : _window$Microsoft$Dyn3.contactId
|
|
190
194
|
};
|
|
191
195
|
const startChatOptionalParams = Object.assign({}, params, optionalParams, defaultOptionalParams);
|
|
192
|
-
await
|
|
196
|
+
await facadeChatSDK.startChat(startChatOptionalParams);
|
|
193
197
|
isStartChatSuccessful = true;
|
|
194
198
|
} catch (error) {
|
|
195
199
|
checkContactIdError(error);
|
|
@@ -208,7 +212,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
208
212
|
isStartChatSuccessful = false;
|
|
209
213
|
throw error;
|
|
210
214
|
}
|
|
211
|
-
await createAdapterAndSubscribe(
|
|
215
|
+
await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, props);
|
|
212
216
|
|
|
213
217
|
// Set app state to Active
|
|
214
218
|
if (isStartChatSuccessful) {
|
|
@@ -230,14 +234,14 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
230
234
|
});
|
|
231
235
|
logWidgetLoadComplete(WidgetLoadTelemetryMessage.PersistedStateRetrievedMessage);
|
|
232
236
|
// Set post chat context in state, load in background to do not block the load
|
|
233
|
-
setPostChatContextAndLoadSurvey(
|
|
237
|
+
setPostChatContextAndLoadSurvey(facadeChatSDK, dispatch, true);
|
|
234
238
|
return;
|
|
235
239
|
}
|
|
236
240
|
|
|
237
241
|
// Persistent Chat relies on the `reconnectId` retrieved from reconnectablechats API to reconnect upon start chat and not `liveChatContext`
|
|
238
242
|
if (!persistentChatEnabled) {
|
|
239
243
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
|
-
const liveChatContext = await (
|
|
244
|
+
const liveChatContext = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getCurrentLiveChatContext());
|
|
241
245
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
246
|
dispatch({
|
|
243
247
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
@@ -246,11 +250,11 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
246
250
|
}
|
|
247
251
|
logWidgetLoadComplete();
|
|
248
252
|
// Set post chat context in state, load in background to do not block the load
|
|
249
|
-
setPostChatContextAndLoadSurvey(
|
|
253
|
+
setPostChatContextAndLoadSurvey(facadeChatSDK, dispatch);
|
|
250
254
|
// Updating chat session detail for telemetry
|
|
251
|
-
await updateTelemetryData(
|
|
255
|
+
await updateTelemetryData(facadeChatSDK, dispatch);
|
|
252
256
|
} catch (ex) {
|
|
253
|
-
handleStartChatError(dispatch,
|
|
257
|
+
handleStartChatError(dispatch, facadeChatSDK, props, ex, isStartChatSuccessful);
|
|
254
258
|
} finally {
|
|
255
259
|
optionalParams = {};
|
|
256
260
|
widgetInstanceId = "";
|
|
@@ -258,20 +262,22 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
258
262
|
};
|
|
259
263
|
|
|
260
264
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
261
|
-
const createAdapterAndSubscribe = async (
|
|
262
|
-
var _newAdapter$activity$;
|
|
265
|
+
const createAdapterAndSubscribe = async (facadeChatSDK, dispatch, setAdapter, props) => {
|
|
263
266
|
// New adapter creation
|
|
264
|
-
const newAdapter = await createAdapter(
|
|
267
|
+
const newAdapter = await createAdapter(facadeChatSDK, props);
|
|
265
268
|
setAdapter(newAdapter);
|
|
266
|
-
const chatToken = await
|
|
269
|
+
const chatToken = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getChatToken());
|
|
267
270
|
dispatch({
|
|
268
271
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
269
272
|
payload: chatToken
|
|
270
273
|
});
|
|
271
|
-
|
|
274
|
+
if (chatToken !== null && chatToken !== void 0 && chatToken.chatId && chatToken !== null && chatToken !== void 0 && chatToken.visitorId) {
|
|
275
|
+
var _newAdapter$activity$;
|
|
276
|
+
newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe(createOnNewAdapterActivityHandler(chatToken.chatId, chatToken.visitorId));
|
|
277
|
+
}
|
|
272
278
|
};
|
|
273
279
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
274
|
-
const canConnectToExistingChat = async (props,
|
|
280
|
+
const canConnectToExistingChat = async (props, facadeChatSDK, state, dispatch, setAdapter) => {
|
|
275
281
|
var _state$appStates3, _persistedState$domai6, _persistedState$appSt;
|
|
276
282
|
// By pass this function in case of popout chat
|
|
277
283
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.hideStartChatButton) === true) {
|
|
@@ -289,7 +295,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
289
295
|
const optionalParams = {
|
|
290
296
|
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
291
297
|
};
|
|
292
|
-
await initStartChat(
|
|
298
|
+
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
|
|
293
299
|
return true;
|
|
294
300
|
}
|
|
295
301
|
return false;
|
|
@@ -354,29 +360,29 @@ const canStartPopoutChat = async props => {
|
|
|
354
360
|
};
|
|
355
361
|
|
|
356
362
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
357
|
-
const checkIfConversationStillValid = async (
|
|
363
|
+
const checkIfConversationStillValid = async (facadeChatSDK, dispatch, state) => {
|
|
358
364
|
var _state$domainStates8, _state$domainStates8$, _state$domainStates9;
|
|
359
365
|
const requestIdFromCache = (_state$domainStates8 = state.domainStates) === null || _state$domainStates8 === void 0 ? void 0 : (_state$domainStates8$ = _state$domainStates8.liveChatContext) === null || _state$domainStates8$ === void 0 ? void 0 : _state$domainStates8$.requestId;
|
|
360
366
|
const liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates9 = state.domainStates) === null || _state$domainStates9 === void 0 ? void 0 : _state$domainStates9.liveChatContext;
|
|
361
367
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
362
368
|
let conversationDetails = undefined;
|
|
363
369
|
// Preserve current requestId
|
|
364
|
-
const currentRequestId =
|
|
370
|
+
const currentRequestId = facadeChatSDK.getChatSDK().requestId ?? "";
|
|
365
371
|
dispatch({
|
|
366
372
|
type: LiveChatWidgetActionType.SET_INITIAL_CHAT_SDK_REQUEST_ID,
|
|
367
373
|
payload: currentRequestId
|
|
368
374
|
});
|
|
369
375
|
try {
|
|
370
|
-
|
|
371
|
-
conversationDetails = await getConversationDetailsCall(
|
|
372
|
-
if (Object.keys(conversationDetails).length === 0) {
|
|
373
|
-
return false;
|
|
374
|
-
}
|
|
375
|
-
if (conversationDetails.state === LiveWorkItemState.Closed || conversationDetails.state === LiveWorkItemState.WrapUp) {
|
|
376
|
+
facadeChatSDK.getChatSDK().requestId = requestIdFromCache;
|
|
377
|
+
conversationDetails = await getConversationDetailsCall(facadeChatSDK, liveChatContext);
|
|
378
|
+
if (Object.keys(conversationDetails).length === 0 || isNullOrUndefined(conversationDetails.state) || conversationDetails.state === LiveWorkItemState.Closed || conversationDetails.state === LiveWorkItemState.WrapUp) {
|
|
376
379
|
dispatch({
|
|
377
380
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
378
381
|
payload: undefined
|
|
379
382
|
});
|
|
383
|
+
if (currentRequestId) {
|
|
384
|
+
facadeChatSDK.getChatSDK().requestId = currentRequestId;
|
|
385
|
+
}
|
|
380
386
|
return false;
|
|
381
387
|
}
|
|
382
388
|
return true;
|
|
@@ -11,7 +11,7 @@ import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
|
11
11
|
import { getWidgetCacheIdfromProps } from "../../../common/utils";
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
export const handleStartChatError = (dispatch,
|
|
14
|
+
export const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStartChatSuccessful) => {
|
|
15
15
|
var _props$controlProps;
|
|
16
16
|
if (!ex) {
|
|
17
17
|
logWidgetLoadFailed();
|
|
@@ -59,7 +59,7 @@ export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSu
|
|
|
59
59
|
break;
|
|
60
60
|
case ChatSDKErrorName.InvalidConversation:
|
|
61
61
|
case ChatSDKErrorName.ClosedConversation:
|
|
62
|
-
handleInvalidOrClosedConversation(dispatch,
|
|
62
|
+
handleInvalidOrClosedConversation(dispatch, facadeChatSDK, props, ex);
|
|
63
63
|
return;
|
|
64
64
|
default:
|
|
65
65
|
logWidgetLoadFailed(ex);
|
|
@@ -94,7 +94,7 @@ export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSu
|
|
|
94
94
|
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
95
95
|
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
96
96
|
if (isStartChatSuccessful === true) {
|
|
97
|
-
forceEndChat(
|
|
97
|
+
forceEndChat(facadeChatSDK);
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
const logWidgetLoadFailed = ex => {
|
|
@@ -142,7 +142,7 @@ const logWidgetLoadCompleteWithError = ex => {
|
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
|
-
const forceEndChat =
|
|
145
|
+
const forceEndChat = facadeChatSDK => {
|
|
146
146
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
147
147
|
Event: TelemetryEvent.PrepareEndChat,
|
|
148
148
|
Description: PrepareEndChatDescriptionConstants.WidgetLoadFailedAfterSessionInit
|
|
@@ -150,7 +150,7 @@ const forceEndChat = chatSDK => {
|
|
|
150
150
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
151
151
|
Event: TelemetryEvent.EndChatSDKCall
|
|
152
152
|
});
|
|
153
|
-
|
|
153
|
+
facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getChatSDK().endChat();
|
|
154
154
|
};
|
|
155
155
|
const handleWidgetUseOutsideOperatingHour = dispatch => {
|
|
156
156
|
dispatch({
|
|
@@ -203,7 +203,7 @@ const handleUninitializedChatSDK = ex => {
|
|
|
203
203
|
};
|
|
204
204
|
|
|
205
205
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
206
|
-
const handleInvalidOrClosedConversation = (dispatch,
|
|
206
|
+
const handleInvalidOrClosedConversation = (dispatch, facadeChatSDK, props, ex) => {
|
|
207
207
|
var _DataStoreManager$cli;
|
|
208
208
|
logWidgetLoadCompleteWithError(ex);
|
|
209
209
|
|
|
@@ -211,7 +211,7 @@ const handleInvalidOrClosedConversation = (dispatch, chatSDK, props, ex) => {
|
|
|
211
211
|
callingStateCleanUp(dispatch);
|
|
212
212
|
endChatStateCleanUp(dispatch);
|
|
213
213
|
closeChatStateCleanUp(dispatch);
|
|
214
|
-
chatSDKStateCleanUp(
|
|
214
|
+
chatSDKStateCleanUp(facadeChatSDK.getChatSDK());
|
|
215
215
|
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(getWidgetCacheIdfromProps(props));
|
|
216
216
|
|
|
217
217
|
// Starts new chat
|
|
@@ -6,16 +6,16 @@ import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
|
6
6
|
import { getConversationDetailsCall } from "../../../common/utils";
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
export const updateTelemetryData = async (
|
|
9
|
+
export const updateTelemetryData = async (facadeChatSDK, dispatch) => {
|
|
10
10
|
// load it concurrently, this will reduce the load time
|
|
11
|
-
await Promise.all([updateSessionDataForTelemetry(
|
|
11
|
+
await Promise.all([updateSessionDataForTelemetry(facadeChatSDK, dispatch), updateConversationDataForTelemetry(facadeChatSDK, dispatch)]);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const updateSessionDataForTelemetry = async (
|
|
16
|
-
if (
|
|
15
|
+
const updateSessionDataForTelemetry = async (facadeChatSDK, dispatch) => {
|
|
16
|
+
if (facadeChatSDK && facadeChatSDK.getChatSDK()) {
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
const chatSession = await
|
|
18
|
+
const chatSession = await facadeChatSDK.getCurrentLiveChatContext();
|
|
19
19
|
const telemetryData = TelemetryHelper.addSessionDataToTelemetry(chatSession, TelemetryManager.InternalTelemetryData);
|
|
20
20
|
dispatch({
|
|
21
21
|
type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
|
|
@@ -31,10 +31,10 @@ const updateSessionDataForTelemetry = async (chatSDK, dispatch) => {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
const updateConversationDataForTelemetry = async (
|
|
35
|
-
if (
|
|
34
|
+
const updateConversationDataForTelemetry = async (facadeChatSDK, dispatch) => {
|
|
35
|
+
if (facadeChatSDK && facadeChatSDK.getChatSDK()) {
|
|
36
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
const liveWorkItem = await getConversationDetailsCall(
|
|
37
|
+
const liveWorkItem = await getConversationDetailsCall(facadeChatSDK);
|
|
38
38
|
const telemetryData = TelemetryHelper.addConversationDataToTelemetry(liveWorkItem, TelemetryManager.InternalTelemetryData);
|
|
39
39
|
dispatch({
|
|
40
40
|
type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
|
|
@@ -53,7 +53,7 @@ import { setPostChatContextAndLoadSurvey } from "../common/setPostChatContextAnd
|
|
|
53
53
|
import { startProactiveChat } from "../common/startProactiveChat";
|
|
54
54
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
55
55
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
56
|
-
import
|
|
56
|
+
import useFacadeSDKStore from "../../../hooks/useFacadeChatSDKStore";
|
|
57
57
|
export const LiveChatWidgetStateful = props => {
|
|
58
58
|
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain7, _props$webChatContain8, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain9, _props$webChatContain10, _props$webChatContain11, _props$webChatContain12, _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;
|
|
59
59
|
const [state, dispatch] = useChatContextStore();
|
|
@@ -64,7 +64,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
64
64
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
|
|
65
65
|
});
|
|
66
66
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
-
const
|
|
67
|
+
const [facadeChatSDK] = useFacadeSDKStore();
|
|
68
68
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
69
|
const [voiceVideoCallingSDK, setVoiceVideoCallingSDK] = useState(undefined);
|
|
70
70
|
const {
|
|
@@ -82,8 +82,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
82
82
|
|
|
83
83
|
// In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
|
|
84
84
|
if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
|
|
85
|
-
var
|
|
86
|
-
const broadcastServiceChannelName = getBroadcastChannelName(
|
|
85
|
+
var _facadeChatSDK$getCha, _facadeChatSDK$getCha2, _props$controlProps2;
|
|
86
|
+
const broadcastServiceChannelName = getBroadcastChannelName((_facadeChatSDK$getCha = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha === void 0 ? void 0 : (_facadeChatSDK$getCha2 = _facadeChatSDK$getCha.omnichannelConfig) === null || _facadeChatSDK$getCha2 === void 0 ? void 0 : _facadeChatSDK$getCha2.widgetId, ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.widgetInstanceId) ?? "");
|
|
87
87
|
BroadcastServiceInitialize(broadcastServiceChannelName);
|
|
88
88
|
}
|
|
89
89
|
TelemetryTimers.LcwLoadToChatButtonTimer = createTimer();
|
|
@@ -118,7 +118,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
118
118
|
const startChat = async (props, localState) => {
|
|
119
119
|
const isReconnectTriggered = async () => {
|
|
120
120
|
if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
|
|
121
|
-
const noValidReconnectId = await handleChatReconnect(
|
|
121
|
+
const noValidReconnectId = await handleChatReconnect(facadeChatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
122
122
|
const inMemoryState = executeReducer(state, {
|
|
123
123
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
124
124
|
payload: null
|
|
@@ -139,11 +139,11 @@ export const LiveChatWidgetStateful = props => {
|
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
//Check if conversation state is not in wrapup or closed state
|
|
142
|
-
isChatValid = await checkIfConversationStillValid(
|
|
142
|
+
isChatValid = await checkIfConversationStillValid(facadeChatSDK, dispatch, state);
|
|
143
143
|
if (isChatValid === true) {
|
|
144
144
|
const reconnectTriggered = await isReconnectTriggered();
|
|
145
145
|
if (!reconnectTriggered) {
|
|
146
|
-
await initStartChat(
|
|
146
|
+
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
|
|
147
147
|
}
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
@@ -163,7 +163,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
163
163
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
164
164
|
payload: null
|
|
165
165
|
});
|
|
166
|
-
await setPreChatAndInitiateChat(
|
|
166
|
+
await setPreChatAndInitiateChat(facadeChatSDK, dispatch, setAdapter, undefined, undefined, inMemoryState, props);
|
|
167
167
|
}
|
|
168
168
|
return;
|
|
169
169
|
} else {
|
|
@@ -233,7 +233,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
235
|
if (((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_callingoptions) !== E2VVOptions.NoCalling) {
|
|
236
|
-
initCallingSdk(
|
|
236
|
+
initCallingSdk(facadeChatSDK, setVoiceVideoCallingSDK).then(sdkCreated => {
|
|
237
237
|
sdkCreated && dispatch({
|
|
238
238
|
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
239
239
|
payload: true
|
|
@@ -265,9 +265,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
265
265
|
useEffect(() => {
|
|
266
266
|
var _state$appStates6;
|
|
267
267
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.hideStartChatButton) === true) {
|
|
268
|
-
var _props$chatConfig3, _props$chatConfig3$Li;
|
|
268
|
+
var _props$chatConfig3, _props$chatConfig3$Li, _props$chatConfig4, _props$chatConfig4$Li;
|
|
269
269
|
//handle OOH pane
|
|
270
|
-
if ((props === null || props === void 0 ? void 0 : (_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
270
|
+
if (typeof (props === null || props === void 0 ? void 0 : (_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.OutOfOperatingHours) === "string" && (props === null || props === void 0 ? void 0 : (_props$chatConfig4 = props.chatConfig) === null || _props$chatConfig4 === void 0 ? void 0 : (_props$chatConfig4$Li = _props$chatConfig4.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig4$Li === void 0 ? void 0 : _props$chatConfig4$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
271
271
|
dispatch({
|
|
272
272
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
273
273
|
payload: ConversationState.OutOfOffice
|
|
@@ -290,7 +290,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
290
290
|
|
|
291
291
|
// useEffect for custom context
|
|
292
292
|
useEffect(() => {
|
|
293
|
-
var
|
|
293
|
+
var _facadeChatSDK$getCha3, _facadeChatSDK$getCha4, _facadeChatSDK$getCha5, _facadeChatSDK$getCha6, _props$controlProps11;
|
|
294
294
|
// Add the custom context on receiving the SetCustomContext event
|
|
295
295
|
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
296
296
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
@@ -343,7 +343,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
343
343
|
if (callInProgress.current === false && dateNow - lastLWICheckTimeRef.current > Constants.LWICheckOnVisibilityTimeout) {
|
|
344
344
|
lastLWICheckTimeRef.current = dateNow;
|
|
345
345
|
callInProgress.current = true;
|
|
346
|
-
const conversationDetails = await getConversationDetailsCall(
|
|
346
|
+
const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
|
|
347
347
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.WrapUp || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.Closed) {
|
|
348
348
|
dispatch({
|
|
349
349
|
type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
@@ -363,7 +363,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
363
363
|
if (isThisSessionPopout((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$location = _window2.location) === null || _window2$location === void 0 ? void 0 : _window2$location.href)) {
|
|
364
364
|
return;
|
|
365
365
|
}
|
|
366
|
-
const conversationDetails = await getConversationDetailsCall(
|
|
366
|
+
const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
|
|
367
367
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.WrapUp || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.Closed) {
|
|
368
368
|
dispatch({
|
|
369
369
|
type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
@@ -397,9 +397,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
397
397
|
|
|
398
398
|
// Start chat from SDK Event
|
|
399
399
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
|
|
400
|
-
var _props$
|
|
400
|
+
var _props$chatConfig5, _props$chatConfig5$Li, _props$chatConfig6, _props$chatConfig6$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
401
401
|
// If chat is out of operating hours chat widget sets the conversation state to OutOfOffice.
|
|
402
|
-
if ((props === null || props === void 0 ? void 0 : (_props$
|
|
402
|
+
if (typeof (props === null || props === void 0 ? void 0 : (_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.OutOfOperatingHours) === "string" && (props === null || props === void 0 ? void 0 : (_props$chatConfig6 = props.chatConfig) === null || _props$chatConfig6 === void 0 ? void 0 : (_props$chatConfig6$Li = _props$chatConfig6.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig6$Li === void 0 ? void 0 : _props$chatConfig6$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
403
403
|
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
404
404
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
405
405
|
payload: false
|
|
@@ -440,7 +440,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
440
440
|
BroadcastService.postMessage({
|
|
441
441
|
eventName: BroadcastEvent.ChatInitiated
|
|
442
442
|
});
|
|
443
|
-
prepareStartChat(props,
|
|
443
|
+
prepareStartChat(props, facadeChatSDK, inMemoryState, dispatch, setAdapter);
|
|
444
444
|
return;
|
|
445
445
|
}
|
|
446
446
|
|
|
@@ -492,7 +492,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
492
492
|
Event: TelemetryEvent.PrepareEndChat,
|
|
493
493
|
Description: PrepareEndChatDescriptionConstants.InitiateEndChatReceived
|
|
494
494
|
});
|
|
495
|
-
endChat(props,
|
|
495
|
+
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
496
496
|
}
|
|
497
497
|
BroadcastService.postMessage({
|
|
498
498
|
eventName: BroadcastEvent.CloseChat
|
|
@@ -505,7 +505,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
505
505
|
});
|
|
506
506
|
|
|
507
507
|
// Listen to end chat event from other tabs
|
|
508
|
-
const endChatEventName = getWidgetEndChatEventName(
|
|
508
|
+
const endChatEventName = getWidgetEndChatEventName((_facadeChatSDK$getCha3 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha3 === void 0 ? void 0 : (_facadeChatSDK$getCha4 = _facadeChatSDK$getCha3.omnichannelConfig) === null || _facadeChatSDK$getCha4 === void 0 ? void 0 : _facadeChatSDK$getCha4.orgId, (_facadeChatSDK$getCha5 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha5 === void 0 ? void 0 : (_facadeChatSDK$getCha6 = _facadeChatSDK$getCha5.omnichannelConfig) === null || _facadeChatSDK$getCha6 === void 0 ? void 0 : _facadeChatSDK$getCha6.widgetId, ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
509
509
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
510
510
|
var _msg$payload10;
|
|
511
511
|
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload10 = msg.payload) === null || _msg$payload10 === void 0 ? void 0 : _msg$payload10.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
@@ -513,9 +513,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
513
513
|
Event: TelemetryEvent.PrepareEndChat,
|
|
514
514
|
Description: "Received EndChat BroadcastEvent from other tabs. Closing this chat."
|
|
515
515
|
});
|
|
516
|
-
endChat(props,
|
|
516
|
+
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
517
517
|
endChatStateCleanUp(dispatch);
|
|
518
|
-
chatSDKStateCleanUp(
|
|
518
|
+
chatSDKStateCleanUp(facadeChatSDK.getChatSDK());
|
|
519
519
|
return;
|
|
520
520
|
}
|
|
521
521
|
});
|
|
@@ -557,7 +557,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
557
557
|
useEffect(() => {
|
|
558
558
|
// On new message
|
|
559
559
|
if (state.appStates.conversationState === ConversationState.Active) {
|
|
560
|
-
|
|
560
|
+
facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.onNewMessage(() => {
|
|
561
561
|
// Track the message count
|
|
562
562
|
currentMessageCountRef.current++;
|
|
563
563
|
dispatch({
|
|
@@ -645,7 +645,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
645
645
|
Event: TelemetryEvent.PrepareEndChat,
|
|
646
646
|
Description: PrepareEndChatDescriptionConstants.CustomerCloseChatOnFailureOrPostChat
|
|
647
647
|
});
|
|
648
|
-
endChat(props,
|
|
648
|
+
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true);
|
|
649
649
|
return;
|
|
650
650
|
}
|
|
651
651
|
|
|
@@ -655,7 +655,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
655
655
|
Event: TelemetryEvent.PrepareEndChat,
|
|
656
656
|
Description: PrepareEndChatDescriptionConstants.CustomerCloseInactiveChat
|
|
657
657
|
});
|
|
658
|
-
endChat(props,
|
|
658
|
+
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
659
659
|
return;
|
|
660
660
|
}
|
|
661
661
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === ConversationEndEntity.Bot) {
|
|
@@ -666,7 +666,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
666
666
|
}
|
|
667
667
|
|
|
668
668
|
// All other cases
|
|
669
|
-
prepareEndChat(props,
|
|
669
|
+
prepareEndChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
|
|
670
670
|
}, [state === null || state === void 0 ? void 0 : (_state$appStates14 = state.appStates) === null || _state$appStates14 === void 0 ? void 0 : _state$appStates14.conversationEndedBy]);
|
|
671
671
|
|
|
672
672
|
// Publish chat widget state
|
|
@@ -737,7 +737,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
737
737
|
Event: TelemetryEvent.PrepareEndChat,
|
|
738
738
|
Description: PrepareEndChatDescriptionConstants.BrowserUnload
|
|
739
739
|
});
|
|
740
|
-
endChat(props,
|
|
740
|
+
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, false);
|
|
741
741
|
// Clean local storage
|
|
742
742
|
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventId);
|
|
743
743
|
|
|
@@ -750,16 +750,16 @@ export const LiveChatWidgetStateful = props => {
|
|
|
750
750
|
eventName: BroadcastEvent.ClosePopoutWindow
|
|
751
751
|
});
|
|
752
752
|
};
|
|
753
|
-
const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(
|
|
753
|
+
const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(facadeChatSDK, dispatch);
|
|
754
754
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
755
|
-
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props,
|
|
756
|
-
const prepareStartChatRelay = () => prepareStartChat(props,
|
|
755
|
+
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab);
|
|
756
|
+
const prepareStartChatRelay = () => prepareStartChat(props, facadeChatSDK, state, dispatch, setAdapter);
|
|
757
757
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
758
|
-
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(
|
|
758
|
+
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
|
|
759
759
|
const confirmationPaneProps = initConfirmationPropsComposer(props);
|
|
760
760
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
761
|
-
const prepareEndChatRelay = () => prepareEndChat(props,
|
|
762
|
-
const webChatProps = initWebChatComposer(props, state, dispatch,
|
|
761
|
+
const prepareEndChatRelay = () => prepareEndChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
|
|
762
|
+
const webChatProps = initWebChatComposer(props, state, dispatch, facadeChatSDK, endChatRelay);
|
|
763
763
|
const downloadTranscriptProps = createDownloadTranscriptProps(props.downloadTranscriptProps, {
|
|
764
764
|
...(defaultWebChatContainerStatefulProps === null || defaultWebChatContainerStatefulProps === void 0 ? void 0 : defaultWebChatContainerStatefulProps.webChatStyles),
|
|
765
765
|
...((_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.webChatStyles)
|
|
@@ -785,7 +785,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
785
785
|
};
|
|
786
786
|
|
|
787
787
|
// Add 'omnichannel-chat-widget' OC User Agent if not already set
|
|
788
|
-
setOcUserAgent(
|
|
788
|
+
setOcUserAgent(facadeChatSDK.getChatSDK());
|
|
789
789
|
const directLine = ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? defaultWebChatContainerStatefulProps.directLine;
|
|
790
790
|
const userID = directLine.getState ? directLine === null || directLine === void 0 ? void 0 : directLine.getState("acs.userId") : "teamsvisitor";
|
|
791
791
|
|
|
@@ -6,11 +6,13 @@ import { ReconnectChatPane } from "@microsoft/omnichannel-chat-components";
|
|
|
6
6
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
7
7
|
import { setFocusOnElement } from "../../common/utils";
|
|
8
8
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
9
|
-
import
|
|
9
|
+
import useFacadeChatSDKStore from "../../hooks/useFacadeChatSDKStore";
|
|
10
10
|
export const ReconnectChatPaneStateful = props => {
|
|
11
11
|
const [state, dispatch] = useChatContextStore();
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
const chatSDK = useChatSDKStore();
|
|
13
|
+
//const chatSDK: any = useChatSDKStore();
|
|
14
|
+
const [facadeChatSDK] = useFacadeChatSDKStore();
|
|
15
|
+
const chatSDK = facadeChatSDK.getChatSDK();
|
|
14
16
|
const {
|
|
15
17
|
reconnectChatProps,
|
|
16
18
|
initStartChat
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
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; }
|
|
2
2
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
3
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
-
import { ParticipantType } from "../../../common/Constants";
|
|
5
4
|
import MockAdapter from "./mockadapter";
|
|
5
|
+
import { ParticipantType } from "../../../common/Constants";
|
|
6
6
|
export class MockChatSDK {
|
|
7
7
|
constructor() {
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -59,6 +59,9 @@ export class MockChatSDK {
|
|
|
59
59
|
getVoiceVideoCalling() {
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
|
+
setAuthTokenProvider() {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
62
65
|
getLiveChatConfig() {
|
|
63
66
|
return {
|
|
64
67
|
LiveWSAndLiveChatEngJoin: {
|