@microsoft/omnichannel-chat-widget 1.7.4-main.c3fef22 → 1.7.4-main.e66bbe9
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 +10 -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/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 +21 -22
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +2 -2
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +2 -3
- 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 +41 -35
- 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 +43 -39
- 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 +10 -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/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 +21 -22
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +2 -2
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +2 -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 +41 -35
- 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 +43 -39
- 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 +6 -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/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 +1 -1
|
@@ -4,21 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createAdapter = void 0;
|
|
7
|
+
var _BotAuthActivitySubscriber = require("./ActivitySubscriber/BotAuthActivitySubscriber");
|
|
8
|
+
var _ChatAdapterShim = require("./ChatAdapterShim");
|
|
9
|
+
var _HiddenAdaptiveCardActivitySubscriber = require("./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber");
|
|
10
|
+
var _mockchatsdk = require("../../webchatcontainerstateful/common/mockchatsdk");
|
|
7
11
|
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
8
12
|
var _NotificationLevel = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationLevel");
|
|
9
13
|
var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
|
|
10
|
-
var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
11
|
-
var _ChatAdapterShim = require("./ChatAdapterShim");
|
|
12
14
|
var _PauseActivitySubscriber = require("./ActivitySubscriber/PauseActivitySubscriber");
|
|
13
|
-
var
|
|
14
|
-
var _HiddenAdaptiveCardActivitySubscriber = require("./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber");
|
|
15
|
+
var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
15
16
|
const defaultBotAuthConfig = {
|
|
16
17
|
fetchBotAuthConfigRetries: 3,
|
|
17
18
|
fetchBotAuthConfigRetryInterval: 1000
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
const createAdapter = async (chatSDK, props) => {
|
|
20
|
+
const createAdapter = async (facadeChatSDK, props) => {
|
|
22
21
|
const chatAdapterOptionalParams = {
|
|
23
22
|
IC3Adapter: {
|
|
24
23
|
options: {
|
|
@@ -41,9 +40,10 @@ const createAdapter = async (chatSDK, props) => {
|
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
};
|
|
44
|
-
let adapter = await
|
|
43
|
+
let adapter = await facadeChatSDK.createChatAdapter(chatAdapterOptionalParams);
|
|
45
44
|
//so far, there is no need to convert to the shim adapter when using visual tests
|
|
46
|
-
|
|
45
|
+
const isMocked = facadeChatSDK.getChatSDK() instanceof _mockchatsdk.MockChatSDK;
|
|
46
|
+
if (isMocked !== true) {
|
|
47
47
|
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4;
|
|
48
48
|
const botAuthActivitySubscriberOptionalParams = {
|
|
49
49
|
fetchBotAuthConfigRetries: (props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.botAuthConfig) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.fetchBotAuthConfigRetries) || defaultBotAuthConfig.fetchBotAuthConfigRetries,
|
|
@@ -16,11 +16,10 @@ var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
|
16
16
|
var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
|
|
17
17
|
var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
18
18
|
var _createReducer = require("../../../contexts/createReducer");
|
|
19
|
-
var _authHelper = require("./authHelper");
|
|
20
19
|
var _reconnectChatHelper = require("./reconnectChatHelper");
|
|
21
20
|
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
22
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
-
const prepareEndChat = async (props,
|
|
22
|
+
const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
24
23
|
try {
|
|
25
24
|
var _conversationDetails$, _state$domainStates, _state$appStates3;
|
|
26
25
|
const {
|
|
@@ -28,8 +27,8 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
28
27
|
} = props;
|
|
29
28
|
|
|
30
29
|
// Use Case: If call is ongoing, end the call by simulating end call button click
|
|
31
|
-
endVoiceVideoCallIfOngoing(
|
|
32
|
-
const conversationDetails = await (0, _utils.getConversationDetailsCall)(
|
|
30
|
+
endVoiceVideoCallIfOngoing(facadeChatSDK, dispatch);
|
|
31
|
+
const conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK);
|
|
33
32
|
|
|
34
33
|
// Use Case: When post chat is not configured
|
|
35
34
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : (_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === _Constants.Constants.false) {
|
|
@@ -40,7 +39,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
40
39
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
41
40
|
Description: _Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithoutPostChat
|
|
42
41
|
});
|
|
43
|
-
await endChat(props,
|
|
42
|
+
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
// Use Case: If ended by Agent, stay chat in InActive state
|
|
@@ -57,7 +56,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
57
56
|
|
|
58
57
|
// Use Case: Can render post chat scenarios
|
|
59
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
-
const postchatContext = (await (0, _renderSurveyHelpers.getPostChatContext)(
|
|
59
|
+
const postchatContext = (await (0, _renderSurveyHelpers.getPostChatContext)(facadeChatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
|
|
61
60
|
if (postchatContext === undefined) {
|
|
62
61
|
var _state$appStates2;
|
|
63
62
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
@@ -73,7 +72,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
73
72
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
74
73
|
Description: _Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat
|
|
75
74
|
});
|
|
76
|
-
await endChat(props,
|
|
75
|
+
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
77
76
|
return;
|
|
78
77
|
}
|
|
79
78
|
|
|
@@ -103,7 +102,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
103
102
|
const endedByCustomer = (appStates === null || appStates === void 0 ? void 0 : appStates.conversationEndedBy) === "Customer";
|
|
104
103
|
|
|
105
104
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
-
const commonParams = [props,
|
|
105
|
+
const commonParams = [props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter];
|
|
107
106
|
if (persistentEnabled && endedByCustomer) {
|
|
108
107
|
await endChat(...commonParams, true, false, true);
|
|
109
108
|
} else {
|
|
@@ -128,7 +127,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
128
127
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
129
128
|
Description: _Constants.PrepareEndChatDescriptionConstants.PrepareEndChatError
|
|
130
129
|
});
|
|
131
|
-
await endChat(props,
|
|
130
|
+
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
132
131
|
}
|
|
133
132
|
} finally {
|
|
134
133
|
//Chat token clean up
|
|
@@ -138,8 +137,9 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
138
137
|
|
|
139
138
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
139
|
exports.prepareEndChat = prepareEndChat;
|
|
141
|
-
const endChat = async (props,
|
|
142
|
-
|
|
140
|
+
const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
|
|
141
|
+
var _facadeChatSDK$getCha;
|
|
142
|
+
if (!skipEndChatSDK && facadeChatSDK !== null && facadeChatSDK !== void 0 && (_facadeChatSDK$getCha = facadeChatSDK.getChatSDK()) !== null && _facadeChatSDK$getCha !== void 0 && _facadeChatSDK$getCha.conversation) {
|
|
143
143
|
var _inMemoryState$appSta;
|
|
144
144
|
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
145
145
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
@@ -152,9 +152,7 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
152
152
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
153
153
|
Event: _TelemetryConstants.TelemetryEvent.EndChatSDKCall
|
|
154
154
|
});
|
|
155
|
-
|
|
156
|
-
await (0, _authHelper.handleAuthentication)(chatSDK, props.chatConfig, props.getAuthToken);
|
|
157
|
-
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat(endChatOptionalParameters));
|
|
155
|
+
await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.endChat(endChatOptionalParameters));
|
|
158
156
|
} catch (ex) {
|
|
159
157
|
var _inMemoryState$appSta2;
|
|
160
158
|
// if the chat was disconnected or ended by the agent, we don't want to log the error
|
|
@@ -176,6 +174,7 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
176
174
|
postMessageToOtherTab = false;
|
|
177
175
|
} finally {
|
|
178
176
|
endChatStateCleanUp(dispatch);
|
|
177
|
+
facadeChatSDK.destroy();
|
|
179
178
|
}
|
|
180
179
|
}
|
|
181
180
|
if (!skipCloseChat) {
|
|
@@ -211,10 +210,11 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
211
210
|
});
|
|
212
211
|
// Always allow to close the chat for embedded mode irrespective of end chat errors
|
|
213
212
|
closeChatWidget(dispatch, props, state);
|
|
213
|
+
facadeChatSDK.destroy();
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
if (postMessageToOtherTab) {
|
|
217
|
-
const endChatEventName = await getEndChatEventName(
|
|
217
|
+
const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
|
|
218
218
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
219
219
|
eventName: endChatEventName,
|
|
220
220
|
payload: {
|
|
@@ -314,11 +314,11 @@ const chatSDKStateCleanUp = chatSDK => {
|
|
|
314
314
|
|
|
315
315
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
316
316
|
exports.chatSDKStateCleanUp = chatSDKStateCleanUp;
|
|
317
|
-
const endVoiceVideoCallIfOngoing = async (
|
|
317
|
+
const endVoiceVideoCallIfOngoing = async (facadeChatSDK, dispatch) => {
|
|
318
318
|
let callId = "";
|
|
319
319
|
try {
|
|
320
|
-
if (
|
|
321
|
-
const voiceVideoCallingSdk = await
|
|
320
|
+
if (facadeChatSDK.getChatSDK().isVoiceVideoCallingEnabled()) {
|
|
321
|
+
const voiceVideoCallingSdk = await facadeChatSDK.getVoiceVideoCalling();
|
|
322
322
|
if (voiceVideoCallingSdk && voiceVideoCallingSdk.isInACall()) {
|
|
323
323
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
324
324
|
callId = voiceVideoCallingSdk.callId;
|
|
@@ -372,8 +372,7 @@ const chatTokenCleanUp = async dispatch => {
|
|
|
372
372
|
// Need to keep liveChatContext until chat is fully closed to for transcript download/email
|
|
373
373
|
};
|
|
374
374
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
return (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.widgetInstanceId) ?? "");
|
|
375
|
+
const getEndChatEventName = async (facadeChatSDK, props) => {
|
|
376
|
+
var _facadeChatSDK$getCha2, _facadeChatSDK$getCha3, _facadeChatSDK$getCha4, _facadeChatSDK$getCha5, _props$controlProps4;
|
|
377
|
+
return (0, _utils.getWidgetEndChatEventName)((_facadeChatSDK$getCha2 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha2 === void 0 ? void 0 : (_facadeChatSDK$getCha3 = _facadeChatSDK$getCha2.omnichannelConfig) === null || _facadeChatSDK$getCha3 === void 0 ? void 0 : _facadeChatSDK$getCha3.orgId, (_facadeChatSDK$getCha4 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha4 === void 0 ? void 0 : (_facadeChatSDK$getCha5 = _facadeChatSDK$getCha4.omnichannelConfig) === null || _facadeChatSDK$getCha5 === void 0 ? void 0 : _facadeChatSDK$getCha5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.widgetInstanceId) ?? "");
|
|
379
378
|
};
|
|
@@ -7,12 +7,12 @@ exports.initCallingSdk = void 0;
|
|
|
7
7
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
8
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
const initCallingSdk = async (
|
|
10
|
+
const initCallingSdk = async (facadeChatSDK, setVoiceVideoCallingSDK) => {
|
|
11
11
|
try {
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
-
if (
|
|
13
|
+
if (facadeChatSDK.getChatSDK().getVoiceVideoCalling) {
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const callingSDK = await
|
|
15
|
+
const callingSDK = await facadeChatSDK.getChatSDK().getVoiceVideoCalling();
|
|
16
16
|
setVoiceVideoCallingSDK(callingSDK);
|
|
17
17
|
_TelemetryHelper.TelemetryHelper.logCallingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
18
18
|
Event: _TelemetryConstants.TelemetryEvent.CallingSDKLoadSuccess
|
|
@@ -39,7 +39,7 @@ var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcont
|
|
|
39
39
|
var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
|
|
40
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
41
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
const initWebChatComposer = (props, state, dispatch,
|
|
42
|
+
const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
|
|
43
43
|
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain13, _props$webChatContain14, _defaultWebChatContai, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai2, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai3, _props$webChatContain23, _props$webChatContain24;
|
|
44
44
|
// Add a hook to make all links open a new window
|
|
45
45
|
postDomPurifyActivities();
|
|
@@ -58,7 +58,7 @@ const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) => {
|
|
|
58
58
|
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
|
|
59
59
|
const conversationEndCallback = async () => {
|
|
60
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
-
const conversationDetails = await (0, _utils.getConversationDetailsCall)(
|
|
61
|
+
const conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK);
|
|
62
62
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.ParticipantType.Bot) {
|
|
63
63
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
64
64
|
Event: _TelemetryConstants.TelemetryEvent.ConversationEndedThreadEventReceived,
|
|
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = void 0;
|
|
7
7
|
var _Constants = require("../../../common/Constants");
|
|
8
8
|
var _utils = require("../../../common/utils");
|
|
9
|
-
|
|
10
|
-
const isPostChatSurveyEnabled = async chatSDK => {
|
|
9
|
+
const isPostChatSurveyEnabled = async facadeChatSDK => {
|
|
11
10
|
var _chatConfig$LiveWSAnd;
|
|
12
|
-
const chatConfig = await
|
|
11
|
+
const chatConfig = await facadeChatSDK.getLiveChatConfig();
|
|
13
12
|
const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
|
|
14
13
|
return postChatEnabled === "true";
|
|
15
14
|
};
|
|
@@ -6,23 +6,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.isReconnectEnabled = exports.isPersistentEnabled = exports.handleChatReconnect = exports.getChatReconnectContext = void 0;
|
|
7
7
|
require("regenerator-runtime/runtime");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
+
var _Constants = require("../../../common/Constants");
|
|
9
10
|
var _utils = require("../../../common/utils");
|
|
10
11
|
var _authHelper = require("./authHelper");
|
|
11
12
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
12
|
-
var _Constants = require("../../../common/Constants");
|
|
13
13
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
14
14
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
15
15
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
16
16
|
var _startChatErrorHandler = require("./startChatErrorHandler");
|
|
17
17
|
// Return value: should start normal chat flow when reconnect is enabled
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
const handleChatReconnect = async (
|
|
19
|
+
const handleChatReconnect = async (facadeChatSDK, props, dispatch, setAdapter, initStartChat, state) => {
|
|
20
20
|
var _props$chatConfig, _props$chatConfig$Liv;
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
const isAuthenticatedChat = (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
|
|
23
|
-
|
|
24
23
|
// Get chat reconnect context
|
|
25
|
-
const reconnectChatContext = await getChatReconnectContext(
|
|
24
|
+
const reconnectChatContext = (await getChatReconnectContext(facadeChatSDK, props.chatConfig, props, isAuthenticatedChat, dispatch)) ?? {};
|
|
26
25
|
|
|
27
26
|
// Redirect if enabled
|
|
28
27
|
if (reconnectChatContext !== null && reconnectChatContext !== void 0 && reconnectChatContext.redirectURL) {
|
|
@@ -34,7 +33,7 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
|
|
|
34
33
|
var _props$reconnectChatP2, _props$reconnectChatP3, _props$controlProps;
|
|
35
34
|
//if reconnect id is provided in props, or hideReconnectChatPane is true, don't show reconnect pane
|
|
36
35
|
if ((_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.reconnectId && !(0, _utils.isNullOrEmptyString)((_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId) || (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideReconnectChatPane) {
|
|
37
|
-
await setReconnectIdAndStartChat(isAuthenticatedChat,
|
|
36
|
+
await setReconnectIdAndStartChat(isAuthenticatedChat, facadeChatSDK, state, props, dispatch, setAdapter, reconnectChatContext.reconnectId ?? "", initStartChat);
|
|
38
37
|
return false;
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -58,7 +57,7 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
|
|
|
58
57
|
|
|
59
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
59
|
exports.handleChatReconnect = handleChatReconnect;
|
|
61
|
-
const getChatReconnectContext = async (
|
|
60
|
+
const getChatReconnectContext = async (facadeChatSDK, chatConfig, props, isAuthenticatedChat, dispatch) => {
|
|
62
61
|
try {
|
|
63
62
|
var _props$reconnectChatP4;
|
|
64
63
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -71,13 +70,13 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
71
70
|
// Get auth token for getting chat reconnect context
|
|
72
71
|
if (isAuthenticatedChat) {
|
|
73
72
|
// handle authentication will throw error if auth token is not available, so no need to check for response
|
|
74
|
-
await (0, _authHelper.handleAuthentication)(
|
|
73
|
+
await (0, _authHelper.handleAuthentication)(facadeChatSDK.getChatSDK(), chatConfig, props.getAuthToken);
|
|
75
74
|
}
|
|
76
|
-
const reconnectChatContext = await (
|
|
75
|
+
const reconnectChatContext = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getChatReconnectContext(chatReconnectOptionalParams));
|
|
77
76
|
if (isAuthenticatedChat) {
|
|
78
77
|
// remove auth token after reconnectId is fetched
|
|
79
78
|
// AuthToken will be reset later at start chat
|
|
80
|
-
(0, _authHelper.removeAuthTokenProvider)(
|
|
79
|
+
(0, _authHelper.removeAuthTokenProvider)(facadeChatSDK.getChatSDK());
|
|
81
80
|
}
|
|
82
81
|
return reconnectChatContext;
|
|
83
82
|
}
|
|
@@ -93,7 +92,7 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
93
92
|
|
|
94
93
|
// when auth token is not available, propagate the error to stop the execution and ensure error pane is loaded
|
|
95
94
|
if ((error === null || error === void 0 ? void 0 : error.message) == _Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString) {
|
|
96
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch,
|
|
95
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, facadeChatSDK, props, new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString), false);
|
|
97
96
|
throw error;
|
|
98
97
|
}
|
|
99
98
|
}
|
|
@@ -101,7 +100,7 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
101
100
|
|
|
102
101
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
102
|
exports.getChatReconnectContext = getChatReconnectContext;
|
|
104
|
-
const setReconnectIdAndStartChat = async (isAuthenticatedChat,
|
|
103
|
+
const setReconnectIdAndStartChat = async (isAuthenticatedChat, facadeChatSDK, state, props, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
105
104
|
if (!isAuthenticatedChat) {
|
|
106
105
|
const startUnauthenticatedReconnectChat = {
|
|
107
106
|
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
@@ -119,7 +118,7 @@ const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, state, p
|
|
|
119
118
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
120
119
|
payload: _ConversationState.ConversationState.Loading
|
|
121
120
|
});
|
|
122
|
-
await initStartChat(
|
|
121
|
+
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
|
|
123
122
|
};
|
|
124
123
|
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
125
124
|
const redirectPageRequest = {
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.setWidgetStateToInactive = exports.initiatePostChat = exports.getPostChatContext = exports.checkPostChatEnabled = void 0;
|
|
7
7
|
var _Constants = require("../../../common/Constants");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
-
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
10
|
-
var _utils = require("../../../common/utils");
|
|
11
9
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
12
10
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
13
11
|
var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostChatSurveyMode");
|
|
12
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
13
|
+
var _utils = require("../../../common/utils");
|
|
14
14
|
var _liveChatConfigUtils = require("./liveChatConfigUtils");
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
16
|
let conversationDetails = undefined;
|
|
@@ -107,14 +107,14 @@ const isPostChatEnabled = (props, state) => {
|
|
|
107
107
|
|
|
108
108
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
109
|
exports.checkPostChatEnabled = isPostChatEnabled;
|
|
110
|
-
const getPostChatContext = async (
|
|
110
|
+
const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
|
|
111
111
|
try {
|
|
112
|
-
const postChatEnabled = await (0, _liveChatConfigUtils.isPostChatSurveyEnabled)(
|
|
112
|
+
const postChatEnabled = await (0, _liveChatConfigUtils.isPostChatSurveyEnabled)(facadeChatSDK);
|
|
113
113
|
if (postChatEnabled) {
|
|
114
114
|
var _state$domainStates2;
|
|
115
115
|
if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
|
|
116
116
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
|
-
const context = await
|
|
117
|
+
const context = await facadeChatSDK.getPostChatSurveyContext();
|
|
118
118
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
119
119
|
Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
|
|
120
120
|
Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
|
|
@@ -8,17 +8,17 @@ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants"
|
|
|
8
8
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
9
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
10
10
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
11
|
-
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
12
11
|
var _Constants = require("../../../common/Constants");
|
|
12
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
13
13
|
var _liveChatConfigUtils = require("./liveChatConfigUtils");
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const setPostChatContextAndLoadSurvey = async (
|
|
15
|
+
const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persistedChat) => {
|
|
16
16
|
try {
|
|
17
|
-
const postChatEnabled = await (0, _liveChatConfigUtils.isPostChatSurveyEnabled)(
|
|
17
|
+
const postChatEnabled = await (0, _liveChatConfigUtils.isPostChatSurveyEnabled)(facadeChatSDK);
|
|
18
18
|
if (postChatEnabled) {
|
|
19
19
|
if (!persistedChat) {
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
const context = await
|
|
21
|
+
const context = await facadeChatSDK.getPostChatSurveyContext();
|
|
22
22
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
23
23
|
Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
|
|
24
24
|
Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
|
|
@@ -31,27 +31,27 @@ let widgetInstanceId;
|
|
|
31
31
|
let popoutWidgetInstanceId;
|
|
32
32
|
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
const setAuthenticationIfApplicable = async (props,
|
|
34
|
+
const setAuthenticationIfApplicable = async (props, facadeChatSDK) => {
|
|
35
35
|
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
36
36
|
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
37
37
|
const authClientFunction = (0, _authHelper.getAuthClientFunction)(chatConfig);
|
|
38
38
|
if (getAuthToken && authClientFunction) {
|
|
39
39
|
// set auth token to chat sdk before start chat
|
|
40
|
-
const authSuccess = await (0, _authHelper.handleAuthentication)(
|
|
41
|
-
if (!authSuccess) {
|
|
40
|
+
const authSuccess = await (0, _authHelper.handleAuthentication)(facadeChatSDK.getChatSDK(), chatConfig, getAuthToken);
|
|
41
|
+
if (!authSuccess.result) {
|
|
42
42
|
throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
-
const prepareStartChat = async (props,
|
|
48
|
+
const prepareStartChat = async (props, facadeChatSDK, state, dispatch, setAdapter) => {
|
|
49
49
|
optionalParams = {}; //Resetting to ensure no stale values
|
|
50
50
|
widgetInstanceId = (0, _utils.getWidgetCacheIdfromProps)(props);
|
|
51
51
|
|
|
52
52
|
// reconnect > chat from cache
|
|
53
53
|
if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true && !(0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
|
|
54
|
-
const shouldStartChatNormally = await (0, _reconnectChatHelper.handleChatReconnect)(
|
|
54
|
+
const shouldStartChatNormally = await (0, _reconnectChatHelper.handleChatReconnect)(facadeChatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
55
55
|
if (!shouldStartChatNormally) {
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
@@ -63,7 +63,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// Can connect to existing chat session
|
|
66
|
-
if (await canConnectToExistingChat(props,
|
|
66
|
+
if (await canConnectToExistingChat(props, facadeChatSDK, state, dispatch, setAdapter)) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -73,31 +73,31 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
73
73
|
|
|
74
74
|
// Setting auth settings to OC API to retrieve existing persistent chat session before start chat if any
|
|
75
75
|
if ((0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
|
|
76
|
-
await setAuthenticationIfApplicable(props,
|
|
76
|
+
await setAuthenticationIfApplicable(props, facadeChatSDK);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
//Setting PreChat and intiate chat
|
|
80
|
-
await setPreChatAndInitiateChat(
|
|
80
|
+
await setPreChatAndInitiateChat(facadeChatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
84
|
exports.prepareStartChat = prepareStartChat;
|
|
85
|
-
const setPreChatAndInitiateChat = async (
|
|
85
|
+
const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState, state, props) => {
|
|
86
86
|
var _props$preChatSurveyP, _props$preChatSurveyP2, _props$controlProps, _state$domainStates, _state$domainStates$l, _state$domainStates$l2;
|
|
87
87
|
// This reset needs to be done before to load prechat, because the conversation state changes from close to prechat
|
|
88
88
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
89
89
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
90
|
-
(0, _endChat.chatSDKStateCleanUp)(
|
|
90
|
+
(0, _endChat.chatSDKStateCleanUp)(facadeChatSDK.getChatSDK());
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
// Getting prechat Survey Context
|
|
94
94
|
const parseToJson = false;
|
|
95
|
-
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
|
|
95
|
+
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));
|
|
96
96
|
let showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse && !(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hidePreChatSurveyPane);
|
|
97
|
-
showPrechat = await (0, _persistentChatHelper.shouldSetPreChatIfPersistentChat)(
|
|
97
|
+
showPrechat = await (0, _persistentChatHelper.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);
|
|
98
98
|
if (showPrechat) {
|
|
99
99
|
var _state$domainStates2, _state$domainStates2$, _state$domainStates2$2, _state$domainStates2$3;
|
|
100
|
-
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";
|
|
100
|
+
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";
|
|
101
101
|
if (isOutOfOperatingHours) {
|
|
102
102
|
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
103
103
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -148,15 +148,19 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
148
148
|
const optionalParams = {
|
|
149
149
|
isProactiveChat
|
|
150
150
|
};
|
|
151
|
-
await initStartChat(
|
|
151
|
+
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
155
155
|
exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
156
|
-
const initStartChat = async (
|
|
156
|
+
const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
157
157
|
var _state$domainStates5, _state$domainStates5$, _state$domainStates5$2;
|
|
158
158
|
let isStartChatSuccessful = false;
|
|
159
159
|
const persistentChatEnabled = await (0, _liveChatConfigUtils.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);
|
|
160
|
+
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
161
|
+
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
162
|
+
(0, _endChat.chatSDKStateCleanUp)(facadeChatSDK.getChatSDK());
|
|
163
|
+
}
|
|
160
164
|
try {
|
|
161
165
|
var _state$appStates2;
|
|
162
166
|
// Clear disconnect state on start chat
|
|
@@ -173,7 +177,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
173
177
|
});
|
|
174
178
|
|
|
175
179
|
// Auth token retrieval needs to happen during start chat to support pop-out chat
|
|
176
|
-
await setAuthenticationIfApplicable(props,
|
|
180
|
+
await setAuthenticationIfApplicable(props, facadeChatSDK);
|
|
177
181
|
|
|
178
182
|
//Check if chat retrieved from cache
|
|
179
183
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
@@ -196,7 +200,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
196
200
|
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
|
|
197
201
|
};
|
|
198
202
|
const startChatOptionalParams = Object.assign({}, params, optionalParams, defaultOptionalParams);
|
|
199
|
-
await
|
|
203
|
+
await facadeChatSDK.startChat(startChatOptionalParams);
|
|
200
204
|
isStartChatSuccessful = true;
|
|
201
205
|
} catch (error) {
|
|
202
206
|
(0, _utils.checkContactIdError)(error);
|
|
@@ -215,7 +219,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
215
219
|
isStartChatSuccessful = false;
|
|
216
220
|
throw error;
|
|
217
221
|
}
|
|
218
|
-
await createAdapterAndSubscribe(
|
|
222
|
+
await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, props);
|
|
219
223
|
|
|
220
224
|
// Set app state to Active
|
|
221
225
|
if (isStartChatSuccessful) {
|
|
@@ -237,14 +241,14 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
237
241
|
});
|
|
238
242
|
(0, _startChatErrorHandler.logWidgetLoadComplete)(_Constants.WidgetLoadTelemetryMessage.PersistedStateRetrievedMessage);
|
|
239
243
|
// Set post chat context in state, load in background to do not block the load
|
|
240
|
-
(0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(
|
|
244
|
+
(0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(facadeChatSDK, dispatch, true);
|
|
241
245
|
return;
|
|
242
246
|
}
|
|
243
247
|
|
|
244
248
|
// Persistent Chat relies on the `reconnectId` retrieved from reconnectablechats API to reconnect upon start chat and not `liveChatContext`
|
|
245
249
|
if (!persistentChatEnabled) {
|
|
246
250
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
247
|
-
const liveChatContext = await (
|
|
251
|
+
const liveChatContext = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getCurrentLiveChatContext());
|
|
248
252
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
249
253
|
dispatch({
|
|
250
254
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
@@ -253,11 +257,11 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
253
257
|
}
|
|
254
258
|
(0, _startChatErrorHandler.logWidgetLoadComplete)();
|
|
255
259
|
// Set post chat context in state, load in background to do not block the load
|
|
256
|
-
(0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(
|
|
260
|
+
(0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(facadeChatSDK, dispatch);
|
|
257
261
|
// Updating chat session detail for telemetry
|
|
258
|
-
await (0, _updateSessionDataForTelemetry.updateTelemetryData)(
|
|
262
|
+
await (0, _updateSessionDataForTelemetry.updateTelemetryData)(facadeChatSDK, dispatch);
|
|
259
263
|
} catch (ex) {
|
|
260
|
-
(0, _startChatErrorHandler.handleStartChatError)(dispatch,
|
|
264
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, facadeChatSDK, props, ex, isStartChatSuccessful);
|
|
261
265
|
} finally {
|
|
262
266
|
optionalParams = {};
|
|
263
267
|
widgetInstanceId = "";
|
|
@@ -266,20 +270,22 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
266
270
|
|
|
267
271
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
268
272
|
exports.initStartChat = initStartChat;
|
|
269
|
-
const createAdapterAndSubscribe = async (
|
|
270
|
-
var _newAdapter$activity$;
|
|
273
|
+
const createAdapterAndSubscribe = async (facadeChatSDK, dispatch, setAdapter, props) => {
|
|
271
274
|
// New adapter creation
|
|
272
|
-
const newAdapter = await (0, _createAdapter.createAdapter)(
|
|
275
|
+
const newAdapter = await (0, _createAdapter.createAdapter)(facadeChatSDK, props);
|
|
273
276
|
setAdapter(newAdapter);
|
|
274
|
-
const chatToken = await
|
|
277
|
+
const chatToken = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getChatToken());
|
|
275
278
|
dispatch({
|
|
276
279
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
277
280
|
payload: chatToken
|
|
278
281
|
});
|
|
279
|
-
|
|
282
|
+
if (chatToken !== null && chatToken !== void 0 && chatToken.chatId && chatToken !== null && chatToken !== void 0 && chatToken.visitorId) {
|
|
283
|
+
var _newAdapter$activity$;
|
|
284
|
+
newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe((0, _newMessageEventHandler.createOnNewAdapterActivityHandler)(chatToken.chatId, chatToken.visitorId));
|
|
285
|
+
}
|
|
280
286
|
};
|
|
281
287
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
282
|
-
const canConnectToExistingChat = async (props,
|
|
288
|
+
const canConnectToExistingChat = async (props, facadeChatSDK, state, dispatch, setAdapter) => {
|
|
283
289
|
var _state$appStates3, _persistedState$domai6, _persistedState$appSt;
|
|
284
290
|
// By pass this function in case of popout chat
|
|
285
291
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.hideStartChatButton) === true) {
|
|
@@ -297,7 +303,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
297
303
|
const optionalParams = {
|
|
298
304
|
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
299
305
|
};
|
|
300
|
-
await initStartChat(
|
|
306
|
+
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
|
|
301
307
|
return true;
|
|
302
308
|
}
|
|
303
309
|
return false;
|
|
@@ -362,28 +368,28 @@ const canStartPopoutChat = async props => {
|
|
|
362
368
|
};
|
|
363
369
|
|
|
364
370
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
365
|
-
const checkIfConversationStillValid = async (
|
|
371
|
+
const checkIfConversationStillValid = async (facadeChatSDK, dispatch, state) => {
|
|
366
372
|
var _state$domainStates8, _state$domainStates8$, _state$domainStates9;
|
|
367
373
|
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;
|
|
368
374
|
const liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates9 = state.domainStates) === null || _state$domainStates9 === void 0 ? void 0 : _state$domainStates9.liveChatContext;
|
|
369
375
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
370
376
|
let conversationDetails = undefined;
|
|
371
377
|
// Preserve current requestId
|
|
372
|
-
const currentRequestId =
|
|
378
|
+
const currentRequestId = facadeChatSDK.getChatSDK().requestId ?? "";
|
|
373
379
|
dispatch({
|
|
374
380
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_INITIAL_CHAT_SDK_REQUEST_ID,
|
|
375
381
|
payload: currentRequestId
|
|
376
382
|
});
|
|
377
383
|
try {
|
|
378
|
-
|
|
379
|
-
conversationDetails = await (0, _utils.getConversationDetailsCall)(
|
|
384
|
+
facadeChatSDK.getChatSDK().requestId = requestIdFromCache;
|
|
385
|
+
conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK, liveChatContext);
|
|
380
386
|
if (Object.keys(conversationDetails).length === 0 || (0, _utils.isNullOrUndefined)(conversationDetails.state) || conversationDetails.state === _Constants.LiveWorkItemState.Closed || conversationDetails.state === _Constants.LiveWorkItemState.WrapUp) {
|
|
381
387
|
dispatch({
|
|
382
388
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
383
389
|
payload: undefined
|
|
384
390
|
});
|
|
385
391
|
if (currentRequestId) {
|
|
386
|
-
|
|
392
|
+
facadeChatSDK.getChatSDK().requestId = currentRequestId;
|
|
387
393
|
}
|
|
388
394
|
return false;
|
|
389
395
|
}
|