@microsoft/omnichannel-chat-widget 1.0.3-main.527b216 → 1.0.3-main.c925679
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/Constants.js +54 -1
- package/lib/cjs/common/storage/default/defaultCacheManager.js +7 -6
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +9 -7
- package/lib/cjs/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/cjs/common/utils.js +27 -5
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -13
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +2 -3
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +2 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +197 -99
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +29 -27
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -8
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +139 -0
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +2 -255
- package/lib/cjs/components/livechatwidget/common/startChat.js +70 -57
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +162 -100
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +15 -5
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +16 -13
- package/lib/cjs/contexts/createReducer.js +13 -23
- package/lib/cjs/controller/componentController.js +2 -1
- package/lib/cjs/index.js +20 -0
- package/lib/esm/common/Constants.js +49 -0
- package/lib/esm/common/storage/default/defaultCacheManager.js +5 -4
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +9 -7
- package/lib/esm/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/esm/common/utils.js +25 -4
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -6
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +14 -13
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +2 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +2 -1
- package/lib/esm/components/livechatwidget/common/endChat.js +196 -99
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +29 -27
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -8
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +130 -0
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -255
- package/lib/esm/components/livechatwidget/common/startChat.js +71 -58
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +164 -102
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +2 -2
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +15 -5
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -4
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -1
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +8 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +7 -1
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -15
- package/lib/esm/contexts/createReducer.js +13 -23
- package/lib/esm/controller/componentController.js +2 -1
- package/lib/esm/index.js +4 -1
- package/lib/types/common/Constants.d.ts +21 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +3 -3
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +2 -1
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -0
- package/lib/types/common/utils.d.ts +3 -2
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +6 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -6
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +4 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +8 -7
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +2 -1
- package/lib/types/index.d.ts +3 -0
- package/package.json +2 -1
- package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +0 -36
- package/lib/cjs/contexts/common/ConversationEndEntity.js +0 -12
- package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +0 -30
- package/lib/esm/contexts/common/ConversationEndEntity.js +0 -5
- package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +0 -6
- package/lib/types/contexts/common/ConversationEndEntity.d.ts +0 -4
|
@@ -26,11 +26,13 @@ import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontr
|
|
|
26
26
|
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
27
27
|
import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
|
|
28
28
|
import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
|
|
29
|
+
import { ConversationEndEntity, ParticipantType } from "../../../common/Constants";
|
|
30
|
+
import { getConversationDetails } from "./endChat";
|
|
29
31
|
import HyperlinkTextOverrideRenderer from "../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer";
|
|
30
32
|
|
|
31
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
export const initWebChatComposer = (props,
|
|
33
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$
|
|
34
|
+
export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
35
|
+
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, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
34
36
|
const localizedTexts = {
|
|
35
37
|
...defaultMiddlewareLocalizedTexts,
|
|
36
38
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -42,21 +44,21 @@ export const initWebChatComposer = (props, chatSDK, setAdapter, state, dispatch,
|
|
|
42
44
|
// Initialize Web Chat's redux store
|
|
43
45
|
let webChatStore = WebChatStoreLoader.store;
|
|
44
46
|
if (!webChatStore) {
|
|
45
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$
|
|
47
|
+
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
|
|
46
48
|
const conversationEndCallback = async () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
const conversationDetails = await getConversationDetails(chatSDK);
|
|
51
|
+
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot) {
|
|
52
|
+
dispatch({
|
|
53
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
54
|
+
payload: ConversationEndEntity.Bot
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
dispatch({
|
|
58
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
59
|
+
payload: ConversationEndEntity.Agent
|
|
54
60
|
});
|
|
55
61
|
}
|
|
56
|
-
dispatch({
|
|
57
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED,
|
|
58
|
-
payload: true
|
|
59
|
-
});
|
|
60
62
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
61
63
|
Event: TelemetryEvent.ConversationEndedThreadEventReceived,
|
|
62
64
|
Description: "Conversation end by agent side or by timeout event received."
|
|
@@ -66,16 +68,16 @@ export const initWebChatComposer = (props, chatSDK, setAdapter, state, dispatch,
|
|
|
66
68
|
//initial state
|
|
67
69
|
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware,
|
|
68
70
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
-
...(((_props$
|
|
71
|
+
...(((_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.storeMiddlewares) ?? []));
|
|
70
72
|
WebChatStoreLoader.store = webChatStore;
|
|
71
73
|
}
|
|
72
74
|
const hyperlinkTextOverrideRenderer = new HyperlinkTextOverrideRenderer(hyperlinkTextOverride);
|
|
73
75
|
const markdownRenderers = [hyperlinkTextOverrideRenderer];
|
|
74
76
|
const renderMarkdown = text => {
|
|
75
|
-
var _props$
|
|
76
|
-
if ((_props$
|
|
77
|
-
var _props$
|
|
78
|
-
text = (_props$
|
|
77
|
+
var _props$webChatContain6, _props$webChatContain7;
|
|
78
|
+
if ((_props$webChatContain6 = props.webChatContainerProps) !== null && _props$webChatContain6 !== void 0 && (_props$webChatContain7 = _props$webChatContain6.webChatProps) !== null && _props$webChatContain7 !== void 0 && _props$webChatContain7.renderMarkdown) {
|
|
79
|
+
var _props$webChatContain8;
|
|
80
|
+
text = (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.webChatProps.renderMarkdown(text);
|
|
79
81
|
} else {
|
|
80
82
|
const render = disableNewLineMarkdownSupport ? markdown.renderInline.bind(markdown) : markdown.render.bind(markdown);
|
|
81
83
|
text = render(text);
|
|
@@ -92,17 +94,17 @@ export const initWebChatComposer = (props, chatSDK, setAdapter, state, dispatch,
|
|
|
92
94
|
dir: state.domainStates.globalDir,
|
|
93
95
|
locale: changeLanguageCodeFormatForWebChat(getLocaleStringFromId((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
|
|
94
96
|
store: webChatStore,
|
|
95
|
-
activityMiddleware: (_props$
|
|
96
|
-
attachmentMiddleware: (_props$
|
|
97
|
-
activityStatusMiddleware: (_props$
|
|
97
|
+
activityMiddleware: (_props$webChatContain9 = props.webChatContainerProps) !== null && _props$webChatContain9 !== void 0 && (_props$webChatContain10 = _props$webChatContain9.renderingMiddlewareProps) !== null && _props$webChatContain10 !== void 0 && _props$webChatContain10.disableActivityMiddleware ? undefined : createActivityMiddleware((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
|
|
98
|
+
attachmentMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableAttachmentMiddleware ? undefined : createAttachmentMiddleware(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? defaultAttachmentProps.enableInlinePlaying),
|
|
99
|
+
activityStatusMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableActivityStatusMiddleware ? undefined : (_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.activityStatusMiddleware,
|
|
98
100
|
renderMarkdown,
|
|
99
|
-
avatarMiddleware: (_props$
|
|
100
|
-
groupActivitiesMiddleware: (_props$
|
|
101
|
-
typingIndicatorMiddleware: (_props$
|
|
101
|
+
avatarMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableAvatarMiddleware ? undefined : createAvatarMiddleware((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
|
|
102
|
+
groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
103
|
+
typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
102
104
|
onTelemetry: createWebChatTelemetry(),
|
|
103
|
-
cardActionMiddleware: createCardActionMiddleware(((_props$
|
|
105
|
+
cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
104
106
|
sendTypingIndicator: true,
|
|
105
|
-
...((_props$
|
|
107
|
+
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
106
108
|
};
|
|
107
109
|
return webChatProps;
|
|
108
110
|
};
|
|
@@ -17,18 +17,17 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
|
|
|
17
17
|
|
|
18
18
|
// Get chat reconnect context
|
|
19
19
|
const reconnectChatContext = await getChatReconnectContext(chatSDK, props.chatConfig, props, isAuthenticatedChat);
|
|
20
|
+
|
|
21
|
+
//Redirect if enabled
|
|
22
|
+
if (reconnectChatContext !== null && reconnectChatContext !== void 0 && reconnectChatContext.redirectURL) {
|
|
23
|
+
var _props$reconnectChatP;
|
|
24
|
+
redirectPage(reconnectChatContext.redirectURL, (_props$reconnectChatP = props.reconnectChatPaneProps) === null || _props$reconnectChatP === void 0 ? void 0 : _props$reconnectChatP.redirectInSameWindow);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
20
27
|
if (hasReconnectId(reconnectChatContext)) {
|
|
21
28
|
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
22
|
-
//Redirect if enabled
|
|
23
|
-
if (reconnectChatContext.redirectURL && !isNullOrEmptyString(reconnectChatContext.redirectURL)) {
|
|
24
|
-
var _props$reconnectChatP;
|
|
25
|
-
redirectPage(reconnectChatContext.redirectURL, (_props$reconnectChatP = props.reconnectChatPaneProps) === null || _props$reconnectChatP === void 0 ? void 0 : _props$reconnectChatP.redirectInSameWindow);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
29
|
//if reconnect id is provided in props, don't show reconnect pane
|
|
30
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)) {
|
|
31
|
-
const reconnectChatContext = await getChatReconnectContext(chatSDK, props.chatConfig, props, isAuthenticatedChat);
|
|
32
31
|
await setReconnectIdAndStartChat(isAuthenticatedChat, chatSDK, props, dispatch, setAdapter, reconnectChatContext.reconnectId ?? "", initStartChat);
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
@@ -51,6 +50,10 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
|
|
|
51
50
|
const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticatedChat) => {
|
|
52
51
|
try {
|
|
53
52
|
var _props$reconnectChatP4;
|
|
53
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
54
|
+
Event: TelemetryEvent.GetChatReconnectContextSDKCallStarted,
|
|
55
|
+
Description: "Reconnect context SDK call started"
|
|
56
|
+
});
|
|
54
57
|
const chatReconnectOptionalParams = {
|
|
55
58
|
reconnectId: (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId
|
|
56
59
|
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Constants, ParticipantType } from "../../../common/Constants";
|
|
2
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
|
+
import { addDelayInMs } from "../../../common/utils";
|
|
5
|
+
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
6
|
+
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
7
|
+
import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
let conversationDetails = undefined;
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
let postChatSurveyMode = undefined;
|
|
12
|
+
const getBotSurveyMode = (props, state) => {
|
|
13
|
+
var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2;
|
|
14
|
+
return ((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_postconversationsurveybotsurveymode) ?? ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveybotsurveymode);
|
|
15
|
+
};
|
|
16
|
+
const getUserSurveyMode = (props, state) => {
|
|
17
|
+
var _props$chatConfig2, _props$chatConfig2$Li, _props$chatConfig3, _props$chatConfig3$Li;
|
|
18
|
+
if (!((_props$chatConfig2 = props.chatConfig) !== null && _props$chatConfig2 !== void 0 && (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) !== null && _props$chatConfig2$Li !== void 0 && _props$chatConfig2$Li.msdyn_postconversationsurveymode)) {
|
|
19
|
+
var _state$domainStates, _state$domainStates$l3, _state$domainStates$l4;
|
|
20
|
+
return (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l3 = _state$domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode) ?? PostChatSurveyMode.Embed;
|
|
21
|
+
}
|
|
22
|
+
return (_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.msdyn_postconversationsurveymode;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Set Survey mode based on conversation ended by entity
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
const setSurveyMode = async (props, participantType, state, dispatch) => {
|
|
28
|
+
if (participantType === ParticipantType.User) {
|
|
29
|
+
postChatSurveyMode = getUserSurveyMode(props, state);
|
|
30
|
+
dispatch({
|
|
31
|
+
type: LiveChatWidgetActionType.SET_SURVEY_MODE,
|
|
32
|
+
payload: postChatSurveyMode
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (participantType === ParticipantType.Bot) {
|
|
37
|
+
postChatSurveyMode = getBotSurveyMode(props, state);
|
|
38
|
+
dispatch({
|
|
39
|
+
type: LiveChatWidgetActionType.SET_SURVEY_MODE,
|
|
40
|
+
payload: postChatSurveyMode
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const renderSurvey = async (state, dispatch) => {
|
|
46
|
+
if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
47
|
+
setWidgetStateToInactive(dispatch);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
51
|
+
await embedModePostChatWorkflow(state, dispatch);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Function for embed mode postchat workflow which is essentially same for both customer and agent
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
const embedModePostChatWorkflow = async (state, dispatch) => {
|
|
58
|
+
var _state$domainStates2;
|
|
59
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
60
|
+
Event: TelemetryEvent.EmbedModePostChatWorkflowStarted
|
|
61
|
+
});
|
|
62
|
+
if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.postChatContext) {
|
|
63
|
+
dispatch({
|
|
64
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
65
|
+
payload: ConversationState.PostchatLoading
|
|
66
|
+
});
|
|
67
|
+
await addDelayInMs(Constants.PostChatLoadingDurationInMs);
|
|
68
|
+
dispatch({
|
|
69
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
70
|
+
payload: ConversationState.Postchat
|
|
71
|
+
});
|
|
72
|
+
} else {
|
|
73
|
+
const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${state.domainStates.postChatContext}`;
|
|
74
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
75
|
+
Event: TelemetryEvent.AppStatesException,
|
|
76
|
+
ExceptionDetails: {
|
|
77
|
+
exception: error
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
const initiatePostChat = async (props, conversationDetailsParam, state, dispatch) => {
|
|
85
|
+
var _conversationDetails;
|
|
86
|
+
conversationDetails = conversationDetailsParam;
|
|
87
|
+
await setSurveyMode(props, (_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType, state, dispatch);
|
|
88
|
+
await renderSurvey(state, dispatch);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
+
const isPostChatEnabled = (props, state) => {
|
|
93
|
+
var _props$chatConfig4, _props$chatConfig4$Li, _state$domainStates$l5, _state$domainStates$l6;
|
|
94
|
+
const isPostChatEnabled = ((_props$chatConfig4 = props.chatConfig) === null || _props$chatConfig4 === void 0 ? void 0 : (_props$chatConfig4$Li = _props$chatConfig4.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig4$Li === void 0 ? void 0 : _props$chatConfig4$Li.msdyn_postconversationsurveyenable) ?? ((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : (_state$domainStates$l6 = _state$domainStates$l5.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.msdyn_postconversationsurveyenable);
|
|
95
|
+
return isPostChatEnabled === Constants.true;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
const getPostChatContext = async (chatSDK, state, dispatch) => {
|
|
100
|
+
try {
|
|
101
|
+
var _state$domainStates3;
|
|
102
|
+
if ((state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.postChatContext) === undefined) {
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
+
const context = await chatSDK.getPostChatSurveyContext();
|
|
105
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
106
|
+
Event: TelemetryEvent.PostChatContextCallSucceed,
|
|
107
|
+
Description: "Postchat context call succeed."
|
|
108
|
+
});
|
|
109
|
+
dispatch({
|
|
110
|
+
type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
|
|
111
|
+
payload: context
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
116
|
+
Event: TelemetryEvent.PostChatContextCallFailed,
|
|
117
|
+
Description: "Failed to get post chat context."
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Function for link mode postchat workflow which is essentially same for both customer and agent
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
|
+
const setWidgetStateToInactive = async dispatch => {
|
|
125
|
+
dispatch({
|
|
126
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
127
|
+
payload: ConversationState.InActive
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
export { initiatePostChat, setWidgetStateToInactive, getPostChatContext, isPostChatEnabled as checkPostChatEnabled };
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
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
5
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
|
-
import { Constants } from "../../../common/Constants";
|
|
7
|
-
import { endChat } from "./endChat";
|
|
8
|
-
import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
|
|
9
|
-
import { addDelayInMs } from "../../../common/utils";
|
|
10
|
-
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
11
|
-
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
12
|
-
import { ConversationEndEntity } from "../../../contexts/common/ConversationEndEntity";
|
|
13
6
|
|
|
14
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
|
|
8
|
+
export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
|
|
16
9
|
try {
|
|
17
10
|
if (!persistedChat) {
|
|
18
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -42,249 +35,4 @@ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat)
|
|
|
42
35
|
payload: ConversationState.Postchat
|
|
43
36
|
});
|
|
44
37
|
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
-
const checkPostChatEnabled = (props, state) => {
|
|
49
|
-
var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2;
|
|
50
|
-
const isPostChatEnabled = ((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_postconversationsurveyenable) ?? ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable);
|
|
51
|
-
return isPostChatEnabled === Constants.true;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
const initiatePostChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
56
|
-
// Check if Postchat already in progress and handle case where chat is ended by customer
|
|
57
|
-
if (state.appStates.postChatWorkflowInProgress && state.appStates.conversationEndedBy === ConversationEndEntity.Customer) {
|
|
58
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Conversation Details call required by customer as well as agent
|
|
63
|
-
const conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
64
|
-
// Start Postchat workflow
|
|
65
|
-
dispatch({
|
|
66
|
-
type: LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS,
|
|
67
|
-
payload: true
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// Below logic checks if agent or bot or noone joins conversation and handles them separately
|
|
71
|
-
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === Constants.userParticipantTypeTag) {
|
|
72
|
-
if (state.appStates.conversationEndedBy === ConversationEndEntity.Customer) {
|
|
73
|
-
// Set use bot settings to false
|
|
74
|
-
await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
|
|
75
|
-
} else if (state.appStates.conversationEndedBy === ConversationEndEntity.Agent) {
|
|
76
|
-
await postChatInitiatedByAgent(props, setWebChatStyles, dispatch, state);
|
|
77
|
-
} else {
|
|
78
|
-
const error = `Conversation was Ended after agent joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
|
|
79
|
-
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
80
|
-
Event: TelemetryEvent.AppStatesException,
|
|
81
|
-
ExceptionDetails: {
|
|
82
|
-
exception: error
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
throw new Error(error);
|
|
86
|
-
}
|
|
87
|
-
} else if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === Constants.botParticipantTypeTag) {
|
|
88
|
-
// Set Use bot survey to true
|
|
89
|
-
dispatch({
|
|
90
|
-
type: LiveChatWidgetActionType.SET_SHOULD_USE_BOT_SURVEY,
|
|
91
|
-
payload: true
|
|
92
|
-
});
|
|
93
|
-
if (state.appStates.conversationEndedBy === ConversationEndEntity.Customer) {
|
|
94
|
-
// Set use bot settings to true
|
|
95
|
-
await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, true);
|
|
96
|
-
} else if (state.appStates.conversationEndedBy === ConversationEndEntity.Agent) {
|
|
97
|
-
await postChatInitiatedByBot(props, setWebChatStyles, dispatch, state);
|
|
98
|
-
} else {
|
|
99
|
-
const error = `Conversation was Ended after bot joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
|
|
100
|
-
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
101
|
-
Event: TelemetryEvent.AppStatesException,
|
|
102
|
-
ExceptionDetails: {
|
|
103
|
-
exception: error
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
throw new Error(error);
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
if (state.appStates.conversationEndedBy === ConversationEndEntity.Customer) {
|
|
110
|
-
// No one has joined chat will be handled by postChat customer
|
|
111
|
-
await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
|
|
112
|
-
} else {
|
|
113
|
-
const error = `ConversationDetails and App state was not set correctly: conversationDetails = ${JSON.stringify(conversationDetails)} , conversationEndedBy = ${state.appStates.conversationEndedBy}`;
|
|
114
|
-
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
115
|
-
Event: TelemetryEvent.AppStatesException,
|
|
116
|
-
ExceptionDetails: {
|
|
117
|
-
exception: error
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
throw new Error(error);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Function for link mode postchat workflow which is essentially same for both customer and agent
|
|
126
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
127
|
-
const linkModePostChatWorkflow = (props, dispatch, setWebChatStyles) => {
|
|
128
|
-
var _props$webChatContain, _props$webChatContain2;
|
|
129
|
-
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
130
|
-
Event: TelemetryEvent.LinkModePostChatWorkflowStarted
|
|
131
|
-
});
|
|
132
|
-
dispatch({
|
|
133
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
134
|
-
payload: ConversationState.InActive
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Disable SendBox
|
|
138
|
-
if ((props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd) !== false) {
|
|
139
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
|
-
setWebChatStyles(styles => {
|
|
141
|
-
return {
|
|
142
|
-
...styles,
|
|
143
|
-
hideSendBox: true
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
// Function for embed mode postchat workflow which is essentially same for both customer and agent
|
|
150
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
151
|
-
const embedModePostChatWorkflow = async (dispatch, state) => {
|
|
152
|
-
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
153
|
-
Event: TelemetryEvent.EmbedModePostChatWorkflowStarted
|
|
154
|
-
});
|
|
155
|
-
if (state.domainStates.postChatContext) {
|
|
156
|
-
dispatch({
|
|
157
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
158
|
-
payload: ConversationState.PostchatLoading
|
|
159
|
-
});
|
|
160
|
-
await addDelayInMs(Constants.PostChatLoadingDurationInMs);
|
|
161
|
-
const loadPostChatEvent = {
|
|
162
|
-
eventName: BroadcastEvent.LoadPostChatSurvey
|
|
163
|
-
};
|
|
164
|
-
BroadcastService.postMessage(loadPostChatEvent);
|
|
165
|
-
} else {
|
|
166
|
-
const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${state.domainStates.postChatContext}`;
|
|
167
|
-
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
168
|
-
Event: TelemetryEvent.AppStatesException,
|
|
169
|
-
ExceptionDetails: {
|
|
170
|
-
exception: error
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
throw new Error(error);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
// Function will handle only postchat cases initiated by customer
|
|
178
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
179
|
-
const postChatInitiatedByCustomer = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, shouldUseBotSetting) => {
|
|
180
|
-
let postChatSurveyMode = "";
|
|
181
|
-
if (shouldUseBotSetting) {
|
|
182
|
-
var _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4;
|
|
183
|
-
postChatSurveyMode = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_postconversationsurveybotsurveymode) ?? ((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveybotsurveymode);
|
|
184
|
-
} else {
|
|
185
|
-
var _props$chatConfig3, _props$chatConfig3$Li, _state$domainStates$l5, _state$domainStates$l6;
|
|
186
|
-
postChatSurveyMode = ((_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : (_state$domainStates$l6 = _state$domainStates$l5.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.msdyn_postconversationsurveymode);
|
|
187
|
-
}
|
|
188
|
-
// Check if agent or bot has joined conversation
|
|
189
|
-
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === Constants.truePascal) {
|
|
190
|
-
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
191
|
-
Event: TelemetryEvent.PostChatWorkflowFromCustomer,
|
|
192
|
-
Description: shouldUseBotSetting ? "PostChat Workflow was started by customer using bot settings" : "PostChat Workflow was started by customer using agent settings"
|
|
193
|
-
});
|
|
194
|
-
const chatSession = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
195
|
-
// End chat call to end chatsdk but not close chat, only if chat ended by customer
|
|
196
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, true, false);
|
|
197
|
-
// Saving request Id below for chat transcript calls
|
|
198
|
-
if (chatSession) {
|
|
199
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
|
-
chatSDK.chatToken = chatSession.chatToken ?? {};
|
|
201
|
-
chatSDK.requestId = chatSession.requestId;
|
|
202
|
-
}
|
|
203
|
-
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
204
|
-
await embedModePostChatWorkflow(dispatch, state);
|
|
205
|
-
} else if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
206
|
-
linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
|
|
207
|
-
} else {
|
|
208
|
-
const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
|
|
209
|
-
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
210
|
-
Event: TelemetryEvent.AppStatesException,
|
|
211
|
-
ExceptionDetails: {
|
|
212
|
-
exception: error
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
throw new Error(error);
|
|
216
|
-
}
|
|
217
|
-
} else {
|
|
218
|
-
// Agent did not join chat so end chat normally
|
|
219
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
// Function will handle only postchat cases initiated by agent
|
|
224
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
|
-
const postChatInitiatedByAgent = async (props, setWebChatStyles, dispatch, state) => {
|
|
226
|
-
var _props$chatConfig4, _props$chatConfig4$Li, _state$domainStates$l7, _state$domainStates$l8;
|
|
227
|
-
const postChatSurveyMode = ((_props$chatConfig4 = props.chatConfig) === null || _props$chatConfig4 === void 0 ? void 0 : (_props$chatConfig4$Li = _props$chatConfig4.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig4$Li === void 0 ? void 0 : _props$chatConfig4$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : (_state$domainStates$l8 = _state$domainStates$l7.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l8 === void 0 ? void 0 : _state$domainStates$l8.msdyn_postconversationsurveymode);
|
|
228
|
-
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
229
|
-
Event: TelemetryEvent.PostChatWorkflowFromAgent,
|
|
230
|
-
Description: "PostChat Workflow was started by agent"
|
|
231
|
-
});
|
|
232
|
-
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
233
|
-
await embedModePostChatWorkflow(dispatch, state);
|
|
234
|
-
} else if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
235
|
-
linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
|
|
236
|
-
} else {
|
|
237
|
-
const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
|
|
238
|
-
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
239
|
-
Event: TelemetryEvent.AppStatesException,
|
|
240
|
-
ExceptionDetails: {
|
|
241
|
-
exception: error
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
throw new Error(error);
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
// Function will handle only postchat cases initiated by bot
|
|
249
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
250
|
-
const postChatInitiatedByBot = async (props, setWebChatStyles, dispatch, state) => {
|
|
251
|
-
var _props$chatConfig5, _props$chatConfig5$Li, _state$domainStates$l9, _state$domainStates$l10;
|
|
252
|
-
const postChatSurveyMode = ((_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.msdyn_postconversationsurveybotsurveymode) ?? ((_state$domainStates$l9 = state.domainStates.liveChatConfig) === null || _state$domainStates$l9 === void 0 ? void 0 : (_state$domainStates$l10 = _state$domainStates$l9.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l10 === void 0 ? void 0 : _state$domainStates$l10.msdyn_postconversationsurveybotsurveymode);
|
|
253
|
-
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
254
|
-
Event: TelemetryEvent.PostChatWorkflowFromBot,
|
|
255
|
-
Description: "PostChat Workflow was started by bot"
|
|
256
|
-
});
|
|
257
|
-
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
258
|
-
await embedModePostChatWorkflow(dispatch, state);
|
|
259
|
-
} else if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
260
|
-
linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
|
|
261
|
-
} else {
|
|
262
|
-
const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveybotsurveymode = ${postChatSurveyMode}`;
|
|
263
|
-
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
264
|
-
Event: TelemetryEvent.AppStatesException,
|
|
265
|
-
ExceptionDetails: {
|
|
266
|
-
exception: error
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
throw new Error(error);
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
274
|
-
const getConversationDetailsCall = async chatSDK => {
|
|
275
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
276
|
-
let conversationDetails = undefined;
|
|
277
|
-
try {
|
|
278
|
-
conversationDetails = await chatSDK.getConversationDetails();
|
|
279
|
-
} catch (error) {
|
|
280
|
-
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
281
|
-
Event: TelemetryEvent.GetConversationDetailsCallFailed,
|
|
282
|
-
ExceptionDetails: {
|
|
283
|
-
exception: `Get Conversation Details Call Failed : ${error}`
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
NotificationHandler.notifyError(NotificationScenarios.Connection, "Get Conversation Details Call Failed: " + error);
|
|
287
|
-
}
|
|
288
|
-
return conversationDetails;
|
|
289
|
-
};
|
|
290
|
-
export { setPostChatContextAndLoadSurvey, checkPostChatEnabled, initiatePostChat };
|
|
38
|
+
};
|