@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
|
@@ -8,29 +8,52 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _ChatAdapterStore = require("../../contexts/ChatAdapterStore");
|
|
9
9
|
var _ChatContextStore = require("../../contexts/ChatContextStore");
|
|
10
10
|
var _ChatSDKStore = require("../../contexts/ChatSDKStore");
|
|
11
|
+
var _FacadeChatSDK = require("../../common/facades/FacadeChatSDK");
|
|
12
|
+
var _FacadeChatSDKStore = require("../../contexts/FacadeChatSDKStore");
|
|
11
13
|
var _LiveChatWidgetStateful = _interopRequireDefault(require("./livechatwidgetstateful/LiveChatWidgetStateful"));
|
|
12
14
|
var _createReducer = require("../../contexts/createReducer");
|
|
13
15
|
var _LiveChatWidgetContextInitialState = require("../../contexts/common/LiveChatWidgetContextInitialState");
|
|
14
16
|
var _getMockChatSDKIfApplicable = require("./common/getMockChatSDKIfApplicable");
|
|
17
|
+
var _utils = require("../../common/utils");
|
|
15
18
|
var _overridePropsOnMockIfApplicable = _interopRequireDefault(require("./common/overridePropsOnMockIfApplicable"));
|
|
16
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
22
|
const LiveChatWidget = props => {
|
|
20
|
-
var _props$mock;
|
|
23
|
+
var _props$mock, _props$chatConfig, _props$chatConfig$Liv;
|
|
21
24
|
const reducer = (0, _createReducer.createReducer)();
|
|
22
25
|
const [state, dispatch] = (0, _react.useReducer)(reducer, (0, _LiveChatWidgetContextInitialState.getLiveChatWidgetContextInitialState)(props));
|
|
23
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
27
|
const [adapter, setAdapter] = (0, _react.useState)(undefined);
|
|
28
|
+
const [facadeChatSDK, setFacadeChatSDK] = (0, _react.useState)(undefined);
|
|
25
29
|
const chatSDK = (0, _getMockChatSDKIfApplicable.getMockChatSDKIfApplicable)(props.chatSDK, props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type);
|
|
26
30
|
(0, _overridePropsOnMockIfApplicable.default)(props);
|
|
27
|
-
|
|
31
|
+
if (!props.chatConfig) {
|
|
32
|
+
throw new Error("chatConfig is required");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
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);
|
|
37
|
+
if (!facadeChatSDK) {
|
|
38
|
+
var _props$mock2;
|
|
39
|
+
setFacadeChatSDK(new _FacadeChatSDK.FacadeChatSDK({
|
|
40
|
+
"chatSDK": chatSDK,
|
|
41
|
+
"chatConfig": props.chatConfig,
|
|
42
|
+
"isAuthenticated": isAuthenticatedChat,
|
|
43
|
+
"getAuthToken": props === null || props === void 0 ? void 0 : props.getAuthToken,
|
|
44
|
+
//when type is not undefined, it means the SDK is mocked
|
|
45
|
+
"isSDKMocked": !(0, _utils.isNullOrUndefined)(props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type)
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
return /*#__PURE__*/_react.default.createElement(_FacadeChatSDKStore.FacadeChatSDKStore.Provider, {
|
|
49
|
+
value: [facadeChatSDK, setFacadeChatSDK]
|
|
50
|
+
}, /*#__PURE__*/_react.default.createElement(_ChatSDKStore.ChatSDKStore.Provider, {
|
|
28
51
|
value: chatSDK
|
|
29
52
|
}, /*#__PURE__*/_react.default.createElement(_ChatAdapterStore.ChatAdapterStore.Provider, {
|
|
30
53
|
value: [adapter, setAdapter]
|
|
31
54
|
}, /*#__PURE__*/_react.default.createElement(_ChatContextStore.ChatContextStore.Provider, {
|
|
32
55
|
value: [state, dispatch]
|
|
33
|
-
}, /*#__PURE__*/_react.default.createElement(_LiveChatWidgetStateful.default, props))));
|
|
56
|
+
}, /*#__PURE__*/_react.default.createElement(_LiveChatWidgetStateful.default, props)))));
|
|
34
57
|
};
|
|
35
58
|
exports.LiveChatWidget = LiveChatWidget;
|
|
36
59
|
var _default = LiveChatWidget;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.removeAuthTokenProvider = exports.handleAuthentication = exports.getAuthClientFunction = void 0;
|
|
7
7
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
8
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
9
|
-
var _utils = require("../../../common/utils");
|
|
10
9
|
var _Constants = require("../../../common/Constants");
|
|
10
|
+
var _utils = require("../../../common/utils");
|
|
11
11
|
const getAuthClientFunction = chatConfig => {
|
|
12
12
|
let authClientFunction = undefined;
|
|
13
13
|
if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
|
|
@@ -16,8 +16,6 @@ const getAuthClientFunction = chatConfig => {
|
|
|
16
16
|
}
|
|
17
17
|
return authClientFunction;
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
19
|
exports.getAuthClientFunction = getAuthClientFunction;
|
|
22
20
|
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
23
21
|
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
@@ -31,7 +29,10 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
31
29
|
chatSDK.setAuthTokenProvider(async () => {
|
|
32
30
|
return token;
|
|
33
31
|
});
|
|
34
|
-
return
|
|
32
|
+
return {
|
|
33
|
+
"result": true,
|
|
34
|
+
"token": token
|
|
35
|
+
};
|
|
35
36
|
} else {
|
|
36
37
|
// instead of returning false, it's more appropiate to thrown an error to force error handling on the caller side
|
|
37
38
|
// this will help to avoid the error to be ignored and the chat to be started
|
|
@@ -41,7 +42,15 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
41
42
|
throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
"result": false,
|
|
47
|
+
"token": null,
|
|
48
|
+
"error": {
|
|
49
|
+
"message": "No auth client function or getAuthToken function provided",
|
|
50
|
+
"getAuthTokenPresent": getAuthToken ? true : false,
|
|
51
|
+
"authClientFunctionPresent": authClientFunction ? true : false
|
|
52
|
+
}
|
|
53
|
+
};
|
|
45
54
|
};
|
|
46
55
|
|
|
47
56
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -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,
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.prepareEndChat = exports.endVoiceVideoCallIfOngoing = exports.endChatStateCleanUp = exports.endChat = exports.closeChatStateCleanUp = exports.chatSDKStateCleanUp = exports.callingStateCleanUp = void 0;
|
|
7
|
-
var _Constants = require("../../../common/Constants");
|
|
8
7
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
|
+
var _Constants = require("../../../common/Constants");
|
|
9
9
|
var _utils = require("../../../common/utils");
|
|
10
10
|
var _renderSurveyHelpers = require("./renderSurveyHelpers");
|
|
11
11
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
@@ -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,16 +56,23 @@ 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;
|
|
62
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
63
|
+
eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
|
|
64
|
+
payload: {
|
|
65
|
+
errorMessage: "Widget did not display post chat survey as getPostChatContext returned undefined."
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
63
69
|
// For Customer intiated conversations, just close chat widget
|
|
64
70
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === _Constants.ConversationEndEntity.Customer) {
|
|
65
71
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
66
72
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
67
73
|
Description: _Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat
|
|
68
74
|
});
|
|
69
|
-
await endChat(props,
|
|
75
|
+
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
70
76
|
return;
|
|
71
77
|
}
|
|
72
78
|
|
|
@@ -96,7 +102,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
96
102
|
const endedByCustomer = (appStates === null || appStates === void 0 ? void 0 : appStates.conversationEndedBy) === "Customer";
|
|
97
103
|
|
|
98
104
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
-
const commonParams = [props,
|
|
105
|
+
const commonParams = [props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter];
|
|
100
106
|
if (persistentEnabled && endedByCustomer) {
|
|
101
107
|
await endChat(...commonParams, true, false, true);
|
|
102
108
|
} else {
|
|
@@ -121,7 +127,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
121
127
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
122
128
|
Description: _Constants.PrepareEndChatDescriptionConstants.PrepareEndChatError
|
|
123
129
|
});
|
|
124
|
-
await endChat(props,
|
|
130
|
+
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
125
131
|
}
|
|
126
132
|
} finally {
|
|
127
133
|
//Chat token clean up
|
|
@@ -131,23 +137,26 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
131
137
|
|
|
132
138
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
139
|
exports.prepareEndChat = prepareEndChat;
|
|
134
|
-
const endChat = async (props,
|
|
135
|
-
|
|
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
|
+
var _inMemoryState$appSta;
|
|
144
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
145
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
146
|
+
payload: null
|
|
147
|
+
});
|
|
148
|
+
const endChatOptionalParameters = {
|
|
149
|
+
isSessionEnded: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.chatDisconnectEventReceived
|
|
150
|
+
};
|
|
136
151
|
try {
|
|
137
152
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
138
153
|
Event: _TelemetryConstants.TelemetryEvent.EndChatSDKCall
|
|
139
154
|
});
|
|
140
|
-
|
|
141
|
-
await (0, _authHelper.handleAuthentication)(chatSDK, props.chatConfig, props.getAuthToken);
|
|
142
|
-
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
155
|
+
await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.endChat(endChatOptionalParameters));
|
|
143
156
|
} catch (ex) {
|
|
144
|
-
var _inMemoryState$
|
|
145
|
-
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
146
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
147
|
-
payload: null
|
|
148
|
-
});
|
|
157
|
+
var _inMemoryState$appSta2;
|
|
149
158
|
// if the chat was disconnected or ended by the agent, we don't want to log the error
|
|
150
|
-
if (!(inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$
|
|
159
|
+
if (!(inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$appSta2 = inMemoryState.appStates) !== null && _inMemoryState$appSta2 !== void 0 && _inMemoryState$appSta2.chatDisconnectEventReceived)) {
|
|
151
160
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
152
161
|
Event: _TelemetryConstants.TelemetryEvent.EndChatSDKCallFailed,
|
|
153
162
|
ExceptionDetails: {
|
|
@@ -164,7 +173,8 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
164
173
|
}
|
|
165
174
|
postMessageToOtherTab = false;
|
|
166
175
|
} finally {
|
|
167
|
-
|
|
176
|
+
endChatStateCleanUp(dispatch);
|
|
177
|
+
facadeChatSDK.destroy();
|
|
168
178
|
}
|
|
169
179
|
}
|
|
170
180
|
if (!skipCloseChat) {
|
|
@@ -200,10 +210,11 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
200
210
|
});
|
|
201
211
|
// Always allow to close the chat for embedded mode irrespective of end chat errors
|
|
202
212
|
closeChatWidget(dispatch, props, state);
|
|
213
|
+
facadeChatSDK.destroy();
|
|
203
214
|
}
|
|
204
215
|
}
|
|
205
216
|
if (postMessageToOtherTab) {
|
|
206
|
-
const endChatEventName = await getEndChatEventName(
|
|
217
|
+
const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
|
|
207
218
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
208
219
|
eventName: endChatEventName,
|
|
209
220
|
payload: {
|
|
@@ -303,11 +314,11 @@ const chatSDKStateCleanUp = chatSDK => {
|
|
|
303
314
|
|
|
304
315
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
305
316
|
exports.chatSDKStateCleanUp = chatSDKStateCleanUp;
|
|
306
|
-
const endVoiceVideoCallIfOngoing = async (
|
|
317
|
+
const endVoiceVideoCallIfOngoing = async (facadeChatSDK, dispatch) => {
|
|
307
318
|
let callId = "";
|
|
308
319
|
try {
|
|
309
|
-
if (
|
|
310
|
-
const voiceVideoCallingSdk = await
|
|
320
|
+
if (facadeChatSDK.getChatSDK().isVoiceVideoCallingEnabled()) {
|
|
321
|
+
const voiceVideoCallingSdk = await facadeChatSDK.getVoiceVideoCalling();
|
|
311
322
|
if (voiceVideoCallingSdk && voiceVideoCallingSdk.isInACall()) {
|
|
312
323
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
313
324
|
callId = voiceVideoCallingSdk.callId;
|
|
@@ -361,8 +372,7 @@ const chatTokenCleanUp = async dispatch => {
|
|
|
361
372
|
// Need to keep liveChatContext until chat is fully closed to for transcript download/email
|
|
362
373
|
};
|
|
363
374
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
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) ?? "");
|
|
368
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
|
|
@@ -7,6 +7,7 @@ exports.initWebChatComposer = void 0;
|
|
|
7
7
|
var _Constants = require("../../../common/Constants");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _utils = require("../../../common/utils");
|
|
10
|
+
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
10
11
|
var _HyperlinkTextOverrideRenderer = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer"));
|
|
11
12
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
12
13
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
@@ -22,8 +23,10 @@ var _conversationEndMiddleware = _interopRequireDefault(require("../../webchatco
|
|
|
22
23
|
var _dataMaskingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware"));
|
|
23
24
|
var _createMarkdown = require("./createMarkdown");
|
|
24
25
|
var _maxMessageSizeValidator = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator"));
|
|
26
|
+
var _messageSequenceIdOverrideMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware"));
|
|
25
27
|
var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
|
|
26
28
|
var _botframeworkWebchat = require("botframework-webchat");
|
|
29
|
+
var _toastMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware"));
|
|
27
30
|
var _WebChatLogger = require("../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger");
|
|
28
31
|
var _defaultAttachmentProps = require("../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps");
|
|
29
32
|
var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
@@ -34,12 +37,9 @@ var _htmlPlayerMiddleware = _interopRequireDefault(require("../../webchatcontain
|
|
|
34
37
|
var _htmlTextMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware"));
|
|
35
38
|
var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware"));
|
|
36
39
|
var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
|
|
37
|
-
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
38
|
-
var _messageSequenceIdOverrideMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware"));
|
|
39
|
-
var _toastMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware"));
|
|
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,
|
|
@@ -106,7 +106,11 @@ const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) => {
|
|
|
106
106
|
markdownRenderers.forEach(renderer => {
|
|
107
107
|
text = renderer.render(text);
|
|
108
108
|
});
|
|
109
|
-
|
|
109
|
+
const config = {
|
|
110
|
+
FORBID_TAGS: ["form", "button", "script", "div", "input"],
|
|
111
|
+
FORBID_ATTR: ["action"]
|
|
112
|
+
};
|
|
113
|
+
text = _dompurify.default.sanitize(text, config);
|
|
110
114
|
return text;
|
|
111
115
|
};
|
|
112
116
|
function postDomPurifyActivities() {
|
|
@@ -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
|