@microsoft/omnichannel-chat-widget 1.7.4-main.f0f5d34 → 1.7.4
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 +7 -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 +15 -13
- 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 +40 -30
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +10 -6
- 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 +54 -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 +63 -40
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -6
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +8 -0
- 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 +7 -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 +15 -13
- 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 +40 -30
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +10 -6
- 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 +55 -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 +63 -40
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -6
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +8 -0
- 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 +9 -2
- 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/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/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
- 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,7 +1,7 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
3
|
-
import { isNullOrEmptyString } from "../../../common/utils";
|
|
4
3
|
import { WidgetLoadCustomErrorString } from "../../../common/Constants";
|
|
4
|
+
import { isNullOrEmptyString } from "../../../common/utils";
|
|
5
5
|
const getAuthClientFunction = chatConfig => {
|
|
6
6
|
let authClientFunction = undefined;
|
|
7
7
|
if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
|
|
@@ -10,8 +10,6 @@ const getAuthClientFunction = chatConfig => {
|
|
|
10
10
|
}
|
|
11
11
|
return authClientFunction;
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
13
|
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
16
14
|
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
17
15
|
if (getAuthToken && authClientFunction) {
|
|
@@ -24,7 +22,10 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
24
22
|
chatSDK.setAuthTokenProvider(async () => {
|
|
25
23
|
return token;
|
|
26
24
|
});
|
|
27
|
-
return
|
|
25
|
+
return {
|
|
26
|
+
"result": true,
|
|
27
|
+
"token": token
|
|
28
|
+
};
|
|
28
29
|
} else {
|
|
29
30
|
// instead of returning false, it's more appropiate to thrown an error to force error handling on the caller side
|
|
30
31
|
// this will help to avoid the error to be ignored and the chat to be started
|
|
@@ -34,7 +35,15 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
34
35
|
throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
return
|
|
38
|
+
return {
|
|
39
|
+
"result": false,
|
|
40
|
+
"token": null,
|
|
41
|
+
"error": {
|
|
42
|
+
"message": "No auth client function or getAuthToken function provided",
|
|
43
|
+
"getAuthTokenPresent": getAuthToken ? true : false,
|
|
44
|
+
"authClientFunctionPresent": authClientFunction ? true : false
|
|
45
|
+
}
|
|
46
|
+
};
|
|
38
47
|
};
|
|
39
48
|
|
|
40
49
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
+
import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
|
|
2
|
+
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
3
|
+
import { HiddenAdaptiveCardActivitySubscriber } from "./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber";
|
|
4
|
+
import { MockChatSDK } from "../../webchatcontainerstateful/common/mockchatsdk";
|
|
1
5
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
2
6
|
import { NotificationLevel } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationLevel";
|
|
3
7
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
4
|
-
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
5
|
-
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
6
8
|
import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber";
|
|
7
|
-
import {
|
|
8
|
-
import { HiddenAdaptiveCardActivitySubscriber } from "./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber";
|
|
9
|
+
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
9
10
|
const defaultBotAuthConfig = {
|
|
10
11
|
fetchBotAuthConfigRetries: 3,
|
|
11
12
|
fetchBotAuthConfigRetryInterval: 1000
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
export const createAdapter = async (chatSDK, props) => {
|
|
14
|
+
export const createAdapter = async (facadeChatSDK, props) => {
|
|
16
15
|
const chatAdapterOptionalParams = {
|
|
17
16
|
IC3Adapter: {
|
|
18
17
|
options: {
|
|
@@ -35,9 +34,10 @@ export const createAdapter = async (chatSDK, props) => {
|
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
};
|
|
38
|
-
let adapter = await
|
|
37
|
+
let adapter = await facadeChatSDK.createChatAdapter(chatAdapterOptionalParams);
|
|
39
38
|
//so far, there is no need to convert to the shim adapter when using visual tests
|
|
40
|
-
|
|
39
|
+
const isMocked = facadeChatSDK.getChatSDK() instanceof MockChatSDK;
|
|
40
|
+
if (isMocked !== true) {
|
|
41
41
|
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4;
|
|
42
42
|
const botAuthActivitySubscriberOptionalParams = {
|
|
43
43
|
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,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
1
2
|
import { ConfirmationState, Constants, ConversationEndEntity, ParticipantType, PrepareEndChatDescriptionConstants } from "../../../common/Constants";
|
|
2
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { getConversationDetailsCall, getWidgetEndChatEventName } from "../../../common/utils";
|
|
4
4
|
import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
|
|
5
5
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
@@ -10,12 +10,11 @@ import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
|
10
10
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
11
11
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
12
12
|
import { executeReducer } from "../../../contexts/createReducer";
|
|
13
|
-
import { handleAuthentication } from "./authHelper";
|
|
14
13
|
import { isPersistentEnabled } from "./reconnectChatHelper";
|
|
15
14
|
import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
|
|
16
15
|
|
|
17
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
const prepareEndChat = async (props,
|
|
17
|
+
const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
19
18
|
try {
|
|
20
19
|
var _conversationDetails$, _state$domainStates, _state$appStates3;
|
|
21
20
|
const {
|
|
@@ -23,8 +22,8 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
23
22
|
} = props;
|
|
24
23
|
|
|
25
24
|
// Use Case: If call is ongoing, end the call by simulating end call button click
|
|
26
|
-
endVoiceVideoCallIfOngoing(
|
|
27
|
-
const conversationDetails = await getConversationDetailsCall(
|
|
25
|
+
endVoiceVideoCallIfOngoing(facadeChatSDK, dispatch);
|
|
26
|
+
const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
|
|
28
27
|
|
|
29
28
|
// Use Case: When post chat is not configured
|
|
30
29
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : (_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === Constants.false) {
|
|
@@ -35,7 +34,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
35
34
|
Event: TelemetryEvent.PrepareEndChat,
|
|
36
35
|
Description: PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithoutPostChat
|
|
37
36
|
});
|
|
38
|
-
await endChat(props,
|
|
37
|
+
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
// Use Case: If ended by Agent, stay chat in InActive state
|
|
@@ -52,16 +51,23 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
52
51
|
|
|
53
52
|
// Use Case: Can render post chat scenarios
|
|
54
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
const postchatContext = (await getPostChatContext(
|
|
54
|
+
const postchatContext = (await 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);
|
|
56
55
|
if (postchatContext === undefined) {
|
|
57
56
|
var _state$appStates2;
|
|
57
|
+
BroadcastService.postMessage({
|
|
58
|
+
eventName: BroadcastEvent.OnWidgetError,
|
|
59
|
+
payload: {
|
|
60
|
+
errorMessage: "Widget did not display post chat survey as getPostChatContext returned undefined."
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
58
64
|
// For Customer intiated conversations, just close chat widget
|
|
59
65
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Customer) {
|
|
60
66
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
61
67
|
Event: TelemetryEvent.PrepareEndChat,
|
|
62
68
|
Description: PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat
|
|
63
69
|
});
|
|
64
|
-
await endChat(props,
|
|
70
|
+
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
65
71
|
return;
|
|
66
72
|
}
|
|
67
73
|
|
|
@@ -91,7 +97,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
91
97
|
const endedByCustomer = (appStates === null || appStates === void 0 ? void 0 : appStates.conversationEndedBy) === "Customer";
|
|
92
98
|
|
|
93
99
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
-
const commonParams = [props,
|
|
100
|
+
const commonParams = [props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter];
|
|
95
101
|
if (persistentEnabled && endedByCustomer) {
|
|
96
102
|
await endChat(...commonParams, true, false, true);
|
|
97
103
|
} else {
|
|
@@ -116,7 +122,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
116
122
|
Event: TelemetryEvent.PrepareEndChat,
|
|
117
123
|
Description: PrepareEndChatDescriptionConstants.PrepareEndChatError
|
|
118
124
|
});
|
|
119
|
-
await endChat(props,
|
|
125
|
+
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
120
126
|
}
|
|
121
127
|
} finally {
|
|
122
128
|
//Chat token clean up
|
|
@@ -125,23 +131,26 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
125
131
|
};
|
|
126
132
|
|
|
127
133
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
-
const endChat = async (props,
|
|
129
|
-
|
|
134
|
+
const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
|
|
135
|
+
var _facadeChatSDK$getCha;
|
|
136
|
+
if (!skipEndChatSDK && facadeChatSDK !== null && facadeChatSDK !== void 0 && (_facadeChatSDK$getCha = facadeChatSDK.getChatSDK()) !== null && _facadeChatSDK$getCha !== void 0 && _facadeChatSDK$getCha.conversation) {
|
|
137
|
+
var _inMemoryState$appSta;
|
|
138
|
+
const inMemoryState = executeReducer(state, {
|
|
139
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
140
|
+
payload: null
|
|
141
|
+
});
|
|
142
|
+
const endChatOptionalParameters = {
|
|
143
|
+
isSessionEnded: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.chatDisconnectEventReceived
|
|
144
|
+
};
|
|
130
145
|
try {
|
|
131
146
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
132
147
|
Event: TelemetryEvent.EndChatSDKCall
|
|
133
148
|
});
|
|
134
|
-
|
|
135
|
-
await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
|
|
136
|
-
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
149
|
+
await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.endChat(endChatOptionalParameters));
|
|
137
150
|
} catch (ex) {
|
|
138
|
-
var _inMemoryState$
|
|
139
|
-
const inMemoryState = executeReducer(state, {
|
|
140
|
-
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
141
|
-
payload: null
|
|
142
|
-
});
|
|
151
|
+
var _inMemoryState$appSta2;
|
|
143
152
|
// if the chat was disconnected or ended by the agent, we don't want to log the error
|
|
144
|
-
if (!(inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$
|
|
153
|
+
if (!(inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$appSta2 = inMemoryState.appStates) !== null && _inMemoryState$appSta2 !== void 0 && _inMemoryState$appSta2.chatDisconnectEventReceived)) {
|
|
145
154
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
146
155
|
Event: TelemetryEvent.EndChatSDKCallFailed,
|
|
147
156
|
ExceptionDetails: {
|
|
@@ -158,7 +167,8 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
158
167
|
}
|
|
159
168
|
postMessageToOtherTab = false;
|
|
160
169
|
} finally {
|
|
161
|
-
|
|
170
|
+
endChatStateCleanUp(dispatch);
|
|
171
|
+
facadeChatSDK.destroy();
|
|
162
172
|
}
|
|
163
173
|
}
|
|
164
174
|
if (!skipCloseChat) {
|
|
@@ -194,10 +204,11 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
194
204
|
});
|
|
195
205
|
// Always allow to close the chat for embedded mode irrespective of end chat errors
|
|
196
206
|
closeChatWidget(dispatch, props, state);
|
|
207
|
+
facadeChatSDK.destroy();
|
|
197
208
|
}
|
|
198
209
|
}
|
|
199
210
|
if (postMessageToOtherTab) {
|
|
200
|
-
const endChatEventName = await getEndChatEventName(
|
|
211
|
+
const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
|
|
201
212
|
BroadcastService.postMessage({
|
|
202
213
|
eventName: endChatEventName,
|
|
203
214
|
payload: {
|
|
@@ -292,11 +303,11 @@ export const chatSDKStateCleanUp = chatSDK => {
|
|
|
292
303
|
};
|
|
293
304
|
|
|
294
305
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
295
|
-
export const endVoiceVideoCallIfOngoing = async (
|
|
306
|
+
export const endVoiceVideoCallIfOngoing = async (facadeChatSDK, dispatch) => {
|
|
296
307
|
let callId = "";
|
|
297
308
|
try {
|
|
298
|
-
if (
|
|
299
|
-
const voiceVideoCallingSdk = await
|
|
309
|
+
if (facadeChatSDK.getChatSDK().isVoiceVideoCallingEnabled()) {
|
|
310
|
+
const voiceVideoCallingSdk = await facadeChatSDK.getVoiceVideoCalling();
|
|
300
311
|
if (voiceVideoCallingSdk && voiceVideoCallingSdk.isInACall()) {
|
|
301
312
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
302
313
|
callId = voiceVideoCallingSdk.callId;
|
|
@@ -349,9 +360,8 @@ const chatTokenCleanUp = async dispatch => {
|
|
|
349
360
|
// Need to keep liveChatContext until chat is fully closed to for transcript download/email
|
|
350
361
|
};
|
|
351
362
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
return 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) ?? "");
|
|
363
|
+
const getEndChatEventName = async (facadeChatSDK, props) => {
|
|
364
|
+
var _facadeChatSDK$getCha2, _facadeChatSDK$getCha3, _facadeChatSDK$getCha4, _facadeChatSDK$getCha5, _props$controlProps4;
|
|
365
|
+
return 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) ?? "");
|
|
356
366
|
};
|
|
357
367
|
export { prepareEndChat, endChat };
|
|
@@ -2,12 +2,12 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
|
|
|
2
2
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
-
export const initCallingSdk = async (
|
|
5
|
+
export const initCallingSdk = async (facadeChatSDK, setVoiceVideoCallingSDK) => {
|
|
6
6
|
try {
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
-
if (
|
|
8
|
+
if (facadeChatSDK.getChatSDK().getVoiceVideoCalling) {
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
const callingSDK = await
|
|
10
|
+
const callingSDK = await facadeChatSDK.getChatSDK().getVoiceVideoCalling();
|
|
11
11
|
setVoiceVideoCallingSDK(callingSDK);
|
|
12
12
|
TelemetryHelper.logCallingEvent(LogLevel.INFO, {
|
|
13
13
|
Event: TelemetryEvent.CallingSDKLoadSuccess
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConversationEndEntity, ParticipantType } from "../../../common/Constants";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { changeLanguageCodeFormatForWebChat, getConversationDetailsCall } from "../../../common/utils";
|
|
4
|
+
import DOMPurify from "dompurify";
|
|
4
5
|
import HyperlinkTextOverrideRenderer from "../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer";
|
|
5
6
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
6
7
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
@@ -16,8 +17,10 @@ import createConversationEndMiddleware from "../../webchatcontainerstateful/webc
|
|
|
16
17
|
import createDataMaskingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware";
|
|
17
18
|
import { createMarkdown } from "./createMarkdown";
|
|
18
19
|
import createMaxMessageSizeValidator from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator";
|
|
20
|
+
import createMessageSequenceIdOverrideMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware";
|
|
19
21
|
import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
|
|
20
22
|
import { createStore } from "botframework-webchat";
|
|
23
|
+
import createToastMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware";
|
|
21
24
|
import { createWebChatTelemetry } from "../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
|
|
22
25
|
import { defaultAttachmentProps } from "../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps";
|
|
23
26
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
@@ -28,12 +31,9 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
|
|
|
28
31
|
import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
|
|
29
32
|
import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
|
|
30
33
|
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
31
|
-
import DOMPurify from "dompurify";
|
|
32
|
-
import createMessageSequenceIdOverrideMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware";
|
|
33
|
-
import createToastMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware";
|
|
34
34
|
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
-
export const initWebChatComposer = (props, state, dispatch,
|
|
36
|
+
export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
|
|
37
37
|
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;
|
|
38
38
|
// Add a hook to make all links open a new window
|
|
39
39
|
postDomPurifyActivities();
|
|
@@ -52,7 +52,7 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
|
|
|
52
52
|
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
|
|
53
53
|
const conversationEndCallback = async () => {
|
|
54
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
const conversationDetails = await getConversationDetailsCall(
|
|
55
|
+
const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
|
|
56
56
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot) {
|
|
57
57
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
58
58
|
Event: TelemetryEvent.ConversationEndedThreadEventReceived,
|
|
@@ -100,7 +100,11 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
|
|
|
100
100
|
markdownRenderers.forEach(renderer => {
|
|
101
101
|
text = renderer.render(text);
|
|
102
102
|
});
|
|
103
|
-
|
|
103
|
+
const config = {
|
|
104
|
+
FORBID_TAGS: ["form", "button", "script", "div", "input"],
|
|
105
|
+
FORBID_ATTR: ["action"]
|
|
106
|
+
};
|
|
107
|
+
text = DOMPurify.sanitize(text, config);
|
|
104
108
|
return text;
|
|
105
109
|
};
|
|
106
110
|
function postDomPurifyActivities() {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { ConversationMode } from "../../../common/Constants";
|
|
2
2
|
import { isNullOrUndefined } from "../../../common/utils";
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
-
export const isPostChatSurveyEnabled = async chatSDK => {
|
|
3
|
+
export const isPostChatSurveyEnabled = async facadeChatSDK => {
|
|
6
4
|
var _chatConfig$LiveWSAnd;
|
|
7
|
-
const chatConfig = await
|
|
5
|
+
const chatConfig = await facadeChatSDK.getLiveChatConfig();
|
|
8
6
|
const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
|
|
9
7
|
return postChatEnabled === "true";
|
|
10
8
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "regenerator-runtime/runtime";
|
|
2
2
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
+
import { ConversationMode, WidgetLoadCustomErrorString } from "../../../common/Constants";
|
|
3
4
|
import { checkContactIdError, isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
|
|
4
5
|
import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
|
|
5
6
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
6
|
-
import { ConversationMode, WidgetLoadCustomErrorString } from "../../../common/Constants";
|
|
7
7
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
8
8
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
9
9
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
@@ -11,13 +11,12 @@ import { handleStartChatError } from "./startChatErrorHandler";
|
|
|
11
11
|
|
|
12
12
|
// Return value: should start normal chat flow when reconnect is enabled
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
const handleChatReconnect = async (
|
|
14
|
+
const handleChatReconnect = async (facadeChatSDK, props, dispatch, setAdapter, initStartChat, state) => {
|
|
15
15
|
var _props$chatConfig, _props$chatConfig$Liv;
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
17
|
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;
|
|
18
|
-
|
|
19
18
|
// Get chat reconnect context
|
|
20
|
-
const reconnectChatContext = await getChatReconnectContext(
|
|
19
|
+
const reconnectChatContext = (await getChatReconnectContext(facadeChatSDK, props.chatConfig, props, isAuthenticatedChat, dispatch)) ?? {};
|
|
21
20
|
|
|
22
21
|
// Redirect if enabled
|
|
23
22
|
if (reconnectChatContext !== null && reconnectChatContext !== void 0 && reconnectChatContext.redirectURL) {
|
|
@@ -29,7 +28,7 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
|
|
|
29
28
|
var _props$reconnectChatP2, _props$reconnectChatP3, _props$controlProps;
|
|
30
29
|
//if reconnect id is provided in props, or hideReconnectChatPane is true, don't show reconnect pane
|
|
31
30
|
if ((_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.reconnectId && !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) {
|
|
32
|
-
await setReconnectIdAndStartChat(isAuthenticatedChat,
|
|
31
|
+
await setReconnectIdAndStartChat(isAuthenticatedChat, facadeChatSDK, state, props, dispatch, setAdapter, reconnectChatContext.reconnectId ?? "", initStartChat);
|
|
33
32
|
return false;
|
|
34
33
|
}
|
|
35
34
|
|
|
@@ -52,7 +51,7 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
|
|
|
52
51
|
};
|
|
53
52
|
|
|
54
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
const getChatReconnectContext = async (
|
|
54
|
+
const getChatReconnectContext = async (facadeChatSDK, chatConfig, props, isAuthenticatedChat, dispatch) => {
|
|
56
55
|
try {
|
|
57
56
|
var _props$reconnectChatP4;
|
|
58
57
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
@@ -65,13 +64,13 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
65
64
|
// Get auth token for getting chat reconnect context
|
|
66
65
|
if (isAuthenticatedChat) {
|
|
67
66
|
// handle authentication will throw error if auth token is not available, so no need to check for response
|
|
68
|
-
await handleAuthentication(
|
|
67
|
+
await handleAuthentication(facadeChatSDK.getChatSDK(), chatConfig, props.getAuthToken);
|
|
69
68
|
}
|
|
70
|
-
const reconnectChatContext = await (
|
|
69
|
+
const reconnectChatContext = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getChatReconnectContext(chatReconnectOptionalParams));
|
|
71
70
|
if (isAuthenticatedChat) {
|
|
72
71
|
// remove auth token after reconnectId is fetched
|
|
73
72
|
// AuthToken will be reset later at start chat
|
|
74
|
-
removeAuthTokenProvider(
|
|
73
|
+
removeAuthTokenProvider(facadeChatSDK.getChatSDK());
|
|
75
74
|
}
|
|
76
75
|
return reconnectChatContext;
|
|
77
76
|
}
|
|
@@ -87,14 +86,14 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
87
86
|
|
|
88
87
|
// when auth token is not available, propagate the error to stop the execution and ensure error pane is loaded
|
|
89
88
|
if ((error === null || error === void 0 ? void 0 : error.message) == WidgetLoadCustomErrorString.AuthenticationFailedErrorString) {
|
|
90
|
-
handleStartChatError(dispatch,
|
|
89
|
+
handleStartChatError(dispatch, facadeChatSDK, props, new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString), false);
|
|
91
90
|
throw error;
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
};
|
|
95
94
|
|
|
96
95
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
-
const setReconnectIdAndStartChat = async (isAuthenticatedChat,
|
|
96
|
+
const setReconnectIdAndStartChat = async (isAuthenticatedChat, facadeChatSDK, state, props, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
98
97
|
if (!isAuthenticatedChat) {
|
|
99
98
|
const startUnauthenticatedReconnectChat = {
|
|
100
99
|
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
@@ -112,7 +111,7 @@ const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, state, p
|
|
|
112
111
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
113
112
|
payload: ConversationState.Loading
|
|
114
113
|
});
|
|
115
|
-
await initStartChat(
|
|
114
|
+
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
|
|
116
115
|
};
|
|
117
116
|
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
118
117
|
const redirectPageRequest = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Constants, ParticipantType, PostChatSurveyTelemetryMessage } from "../../../common/Constants";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
-
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
|
-
import { addDelayInMs } from "../../../common/utils";
|
|
5
3
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
6
4
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
7
5
|
import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
|
|
6
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
7
|
+
import { addDelayInMs } from "../../../common/utils";
|
|
8
8
|
import { isPostChatSurveyEnabled } from "./liveChatConfigUtils";
|
|
9
9
|
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -100,14 +100,14 @@ const isPostChatEnabled = (props, state) => {
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
-
const getPostChatContext = async (
|
|
103
|
+
const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
|
|
104
104
|
try {
|
|
105
|
-
const postChatEnabled = await isPostChatSurveyEnabled(
|
|
105
|
+
const postChatEnabled = await isPostChatSurveyEnabled(facadeChatSDK);
|
|
106
106
|
if (postChatEnabled) {
|
|
107
107
|
var _state$domainStates2;
|
|
108
108
|
if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
|
|
109
109
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
|
-
const context = await
|
|
110
|
+
const context = await facadeChatSDK.getPostChatSurveyContext();
|
|
111
111
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
112
112
|
Event: TelemetryEvent.PostChatContextCallSucceed,
|
|
113
113
|
Description: PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
|
|
@@ -2,18 +2,18 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
|
|
|
2
2
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
3
3
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
4
4
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
5
|
-
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
5
|
import { PostChatSurveyTelemetryMessage } from "../../../common/Constants";
|
|
6
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
7
7
|
import { isPostChatSurveyEnabled } from "./liveChatConfigUtils";
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
export const setPostChatContextAndLoadSurvey = async (
|
|
10
|
+
export const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persistedChat) => {
|
|
11
11
|
try {
|
|
12
|
-
const postChatEnabled = await isPostChatSurveyEnabled(
|
|
12
|
+
const postChatEnabled = await isPostChatSurveyEnabled(facadeChatSDK);
|
|
13
13
|
if (postChatEnabled) {
|
|
14
14
|
if (!persistedChat) {
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
const context = await
|
|
16
|
+
const context = await facadeChatSDK.getPostChatSurveyContext();
|
|
17
17
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
18
18
|
Event: TelemetryEvent.PostChatContextCallSucceed,
|
|
19
19
|
Description: PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
|