@microsoft/omnichannel-chat-widget 0.1.0-main.89c6531 → 0.1.0-main.9e62ed8
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/README.md +259 -0
- package/lib/cjs/assets/Audios.js +8 -0
- package/lib/cjs/assets/Icons.js +28 -0
- package/lib/cjs/common/Constants.js +50 -4
- package/lib/cjs/common/contextDataStore/DataStoreManager.js +14 -0
- package/lib/cjs/{assets/assets.d.js → common/interfaces/IContextDataStore.js} +0 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +55 -5
- package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +17 -6
- package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
- package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +33 -13
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +30 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -54
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
- package/lib/cjs/components/footerstateful/FooterStateful.js +4 -5
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
- package/lib/cjs/components/headerstateful/HeaderStateful.js +11 -8
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -4
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +23 -22
- package/lib/cjs/components/livechatwidget/common/endChat.js +116 -49
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +5 -0
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +40 -11
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +105 -20
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +11 -5
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +26 -24
- package/lib/cjs/components/livechatwidget/common/startChat.js +151 -53
- package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -3
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +228 -44
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +8 -0
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +26 -10
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +26 -4
- package/lib/cjs/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
- package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +51 -73
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +25 -48
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +45 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +12 -7
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +11 -3
- package/lib/cjs/contexts/createReducer.js +36 -10
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/cjs/plugins/newMessageEventHandler.js +99 -0
- package/lib/esm/assets/Audios.js +1 -0
- package/lib/esm/assets/Icons.js +11 -0
- package/lib/esm/common/Constants.js +46 -3
- package/lib/esm/common/contextDataStore/DataStoreManager.js +5 -0
- package/lib/esm/common/interfaces/IContextDataStore.js +1 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +51 -4
- package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +15 -6
- package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
- package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +36 -14
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +19 -1
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +18 -7
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -50
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
- package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
- package/lib/esm/components/headerstateful/HeaderStateful.js +12 -9
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +21 -23
- package/lib/esm/components/livechatwidget/common/endChat.js +111 -46
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -0
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +34 -11
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +94 -20
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +10 -4
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +23 -22
- package/lib/esm/components/livechatwidget/common/startChat.js +146 -52
- package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +212 -45
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +6 -0
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +25 -10
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +25 -5
- package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -12
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +23 -46
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +32 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +12 -7
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +11 -3
- package/lib/esm/contexts/createReducer.js +36 -9
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/esm/plugins/newMessageEventHandler.js +82 -0
- package/lib/types/assets/Audios.d.ts +1 -0
- package/lib/types/assets/Icons.d.ts +11 -0
- package/lib/types/common/Constants.d.ts +25 -1
- package/lib/types/common/contextDataStore/DataStoreManager.d.ts +4 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +14 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +39 -2
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
- package/lib/types/common/utils.d.ts +3 -0
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +5 -2
- package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -2
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/prechatsurveypanestateful/interfaces/IPreChatSurveyPaneStatefulParams.d.ts +1 -1
- package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +4 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +13 -8
- package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
- package/package.json +11 -11
- package/lib/cjs/assets/audios/newMessageNotification.mp3 +0 -0
- package/lib/cjs/assets/icons/archiveIcon.svg +0 -3
- package/lib/cjs/assets/icons/audioIcon.svg +0 -6
- package/lib/cjs/assets/icons/blankIcon.svg +0 -6
- package/lib/cjs/assets/icons/excelIcon.svg +0 -6
- package/lib/cjs/assets/icons/imageIcon.svg +0 -6
- package/lib/cjs/assets/icons/oneNoteIcon.svg +0 -6
- package/lib/cjs/assets/icons/pdfIcon.svg +0 -6
- package/lib/cjs/assets/icons/powerpointIcon.svg +0 -6
- package/lib/cjs/assets/icons/videoIcon.svg +0 -6
- package/lib/cjs/assets/icons/visioIcon.svg +0 -6
- package/lib/cjs/assets/icons/wordIcon.svg +0 -6
- package/lib/esm/assets/assets.d.js +0 -0
- package/lib/esm/assets/audios/newMessageNotification.mp3 +0 -0
- package/lib/esm/assets/icons/archiveIcon.svg +0 -3
- package/lib/esm/assets/icons/audioIcon.svg +0 -6
- package/lib/esm/assets/icons/blankIcon.svg +0 -6
- package/lib/esm/assets/icons/excelIcon.svg +0 -6
- package/lib/esm/assets/icons/imageIcon.svg +0 -6
- package/lib/esm/assets/icons/oneNoteIcon.svg +0 -6
- package/lib/esm/assets/icons/pdfIcon.svg +0 -6
- package/lib/esm/assets/icons/powerpointIcon.svg +0 -6
- package/lib/esm/assets/icons/videoIcon.svg +0 -6
- package/lib/esm/assets/icons/visioIcon.svg +0 -6
- package/lib/esm/assets/icons/wordIcon.svg +0 -6
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
1
2
|
import { createStore } from "botframework-webchat";
|
|
3
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
2
4
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
3
5
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
4
6
|
import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
|
|
7
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
8
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
6
9
|
import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
|
|
7
10
|
import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
|
|
@@ -14,6 +17,7 @@ import createConversationEndMiddleware from "../../webchatcontainerstateful/webc
|
|
|
14
17
|
import createDataMaskingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware";
|
|
15
18
|
import { createMarkdown } from "./createMarkdown";
|
|
16
19
|
import createMaxMessageSizeValidator from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator";
|
|
20
|
+
import { createWebChatTelemetry } from "../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
|
|
17
21
|
import { defaultAttachmentProps } from "../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps";
|
|
18
22
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
19
23
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
@@ -23,10 +27,11 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
|
|
|
23
27
|
import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
|
|
24
28
|
import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
|
|
25
29
|
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
26
|
-
import {
|
|
30
|
+
import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
|
|
31
|
+
import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
32
|
|
|
28
33
|
export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
29
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21;
|
|
34
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
30
35
|
|
|
31
36
|
const localizedTexts = { ...defaultMiddlewareLocalizedTexts,
|
|
32
37
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -45,6 +50,11 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
45
50
|
const conversationEndCallback = async () => {
|
|
46
51
|
var _props$webChatContain4, _props$webChatContain5;
|
|
47
52
|
|
|
53
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
54
|
+
Event: TelemetryEvent.ConversationEndedThreadEventReceived,
|
|
55
|
+
Description: "Conversation is ended by agent side or by timeout."
|
|
56
|
+
});
|
|
57
|
+
|
|
48
58
|
if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
|
|
49
59
|
setWebChatStyles(styles => {
|
|
50
60
|
return { ...styles,
|
|
@@ -53,26 +63,37 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
53
63
|
});
|
|
54
64
|
}
|
|
55
65
|
|
|
56
|
-
if (isPostChatEnabled === "true"
|
|
66
|
+
if (isPostChatEnabled === "true") {
|
|
67
|
+
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
68
|
+
const loadPostChatEvent = {
|
|
69
|
+
eventName: BroadcastEvent.LoadPostChatSurvey
|
|
70
|
+
};
|
|
71
|
+
BroadcastService.postMessage(loadPostChatEvent);
|
|
72
|
+
} else if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
73
|
+
dispatch({
|
|
74
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
75
|
+
payload: ConversationState.InActive
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
57
79
|
dispatch({
|
|
58
|
-
type: LiveChatWidgetActionType.
|
|
80
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
|
|
59
81
|
payload: true
|
|
60
82
|
});
|
|
61
|
-
dispatch({
|
|
62
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
63
|
-
payload: ConversationState.Loading
|
|
64
|
-
});
|
|
65
|
-
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
66
83
|
}
|
|
67
84
|
|
|
68
85
|
dispatch({
|
|
69
86
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
70
87
|
payload: undefined
|
|
71
88
|
});
|
|
89
|
+
dispatch({
|
|
90
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
91
|
+
payload: undefined
|
|
92
|
+
});
|
|
72
93
|
};
|
|
73
94
|
|
|
74
95
|
webChatStore = createStore({}, //initial state
|
|
75
|
-
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
+
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), createMessageTimeStampMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
97
|
...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
|
|
77
98
|
WebChatStoreLoader.store = webChatStore;
|
|
78
99
|
} // Initialize the remaining Web Chat props
|
|
@@ -89,7 +110,9 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
89
110
|
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),
|
|
90
111
|
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,
|
|
91
112
|
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,
|
|
92
|
-
|
|
113
|
+
onTelemetry: createWebChatTelemetry(),
|
|
114
|
+
cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
115
|
+
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
93
116
|
};
|
|
94
117
|
return webChatProps;
|
|
95
118
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "regenerator-runtime/runtime";
|
|
2
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
-
import {
|
|
2
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
5
5
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
6
6
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -46,33 +46,107 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
|
46
46
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
const handleUnauthenticatedReconnectChat = async (dispatch, reconnectId, initStartChat) => {
|
|
50
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(reconnectId);
|
|
49
|
+
const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
50
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
51
51
|
|
|
52
|
-
if (reconnectAvailabilityResponse
|
|
53
|
-
|
|
52
|
+
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
53
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
54
54
|
} else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
56
|
+
}
|
|
57
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
61
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
62
|
+
|
|
63
|
+
if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
64
|
+
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
65
|
+
}
|
|
66
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
70
|
+
const startUnauthenticatedReconnectChat = {
|
|
71
|
+
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
72
|
+
};
|
|
73
|
+
BroadcastService.postMessage(startUnauthenticatedReconnectChat);
|
|
74
|
+
const optionalParams = {
|
|
75
|
+
reconnectId: reconnectId
|
|
76
|
+
};
|
|
77
|
+
dispatch({
|
|
78
|
+
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
79
|
+
payload: reconnectId
|
|
80
|
+
});
|
|
81
|
+
dispatch({
|
|
82
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
83
|
+
payload: ConversationState.Loading
|
|
84
|
+
});
|
|
85
|
+
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
89
|
+
const redirectPageRequest = {
|
|
90
|
+
eventName: BroadcastEvent.RedirectPageRequest,
|
|
91
|
+
payload: {
|
|
92
|
+
redirectURL: redirectURL
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
BroadcastService.postMessage(redirectPageRequest);
|
|
96
|
+
|
|
97
|
+
if (redirectInSameWindow) {
|
|
98
|
+
window.location.href = redirectURL;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
|
|
103
|
+
return reconnectAvailabilityResponse && !reconnectAvailabilityResponse.reconnectId;
|
|
104
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
|
|
108
|
+
const startUnauthenticatedReconnectChat = {
|
|
109
|
+
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
110
|
+
};
|
|
111
|
+
BroadcastService.postMessage(startUnauthenticatedReconnectChat); // Getting PreChat Survey Context
|
|
112
|
+
|
|
113
|
+
const parseToJson = false;
|
|
114
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
115
|
+
|
|
116
|
+
if (preChatSurveyResponse) {
|
|
58
117
|
dispatch({
|
|
59
|
-
type: LiveChatWidgetActionType.
|
|
60
|
-
payload:
|
|
118
|
+
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
119
|
+
payload: preChatSurveyResponse
|
|
61
120
|
});
|
|
121
|
+
dispatch({
|
|
122
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
123
|
+
payload: ConversationState.Prechat
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
62
126
|
dispatch({
|
|
63
127
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
64
128
|
payload: ConversationState.Loading
|
|
65
129
|
});
|
|
66
|
-
await initStartChat(
|
|
130
|
+
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
67
131
|
}
|
|
68
|
-
};
|
|
132
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
133
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
134
|
+
|
|
135
|
+
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
136
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
137
|
+
|
|
138
|
+
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
139
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
140
|
+
}
|
|
141
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
145
|
+
if (reconnectAvailabilityResponse.redirectURL) {
|
|
146
|
+
redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
|
|
147
|
+
} else {
|
|
148
|
+
await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
|
|
149
|
+
}
|
|
76
150
|
};
|
|
77
151
|
|
|
78
|
-
export { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat };
|
|
152
|
+
export { getChatReconnectContext, getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat, handleRedirectUnauthenticatedReconnectChat };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
2
1
|
import { RegisterLoggers, TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
2
|
+
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
3
3
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
4
|
import { defaultAriaConfig } from "../../../common/telemetry/defaultConfigs/defaultAriaConfig";
|
|
5
5
|
import { defaultInternalTelemetryData } from "../../../common/telemetry/defaultConfigs/defaultTelemetryInternalData";
|
|
@@ -16,6 +16,8 @@ export const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
16
16
|
|
|
17
17
|
TelemetryManager.InternalTelemetryData = (_props$liveChatContex3 = props.liveChatContextFromCache) === null || _props$liveChatContex3 === void 0 ? void 0 : (_props$liveChatContex4 = _props$liveChatContex3.domainStates) === null || _props$liveChatContex4 === void 0 ? void 0 : _props$liveChatContex4.telemetryInternalData;
|
|
18
18
|
} else {
|
|
19
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$chatSDK3, _props$chatSDK3$omnic;
|
|
20
|
+
|
|
19
21
|
let telemetryData = { ...defaultInternalTelemetryData,
|
|
20
22
|
telemetryConfig: Object.assign({}, defaultTelemetryConfiguration, telemetryConfig),
|
|
21
23
|
ariaConfig: Object.assign({}, defaultAriaConfig, telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.ariaConfigurations)
|
|
@@ -26,9 +28,13 @@ export const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
telemetryData = TelemetryHelper.addWidgetDataToTelemetry(telemetryConfig, telemetryData);
|
|
29
|
-
telemetryData.OCChatSDKVersion = telemetryConfig
|
|
30
|
-
telemetryData.chatComponentVersion = telemetryConfig
|
|
31
|
-
telemetryData.chatWidgetVersion = telemetryConfig
|
|
31
|
+
telemetryData.OCChatSDKVersion = telemetryConfig.OCChatSDKVersion ?? "0.0.0-0";
|
|
32
|
+
telemetryData.chatComponentVersion = telemetryConfig.chatComponentVersion ?? "0.0.0-0";
|
|
33
|
+
telemetryData.chatWidgetVersion = telemetryConfig.chatWidgetVersion ?? "0.0.0-0";
|
|
34
|
+
telemetryData.orgId = (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId;
|
|
35
|
+
telemetryData.widgetId = (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId;
|
|
36
|
+
telemetryData.orgUrl = (_props$chatSDK3 = props.chatSDK) === null || _props$chatSDK3 === void 0 ? void 0 : (_props$chatSDK3$omnic = _props$chatSDK3.omnichannelConfig) === null || _props$chatSDK3$omnic === void 0 ? void 0 : _props$chatSDK3$omnic.orgUrl;
|
|
37
|
+
TelemetryManager.InternalTelemetryData = telemetryData;
|
|
32
38
|
dispatch({
|
|
33
39
|
type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
|
|
34
40
|
payload: telemetryData
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
3
|
+
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
2
4
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
3
|
-
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
|
-
import { ConversationState } from "../../../contexts/common/ConversationState"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
6
|
|
|
6
|
-
export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch,
|
|
7
|
+
export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
|
|
7
8
|
try {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
if (!persistedChat) {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
const context = await chatSDK.getPostChatSurveyContext();
|
|
12
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
13
|
+
Event: TelemetryEvent.PostChatContextCallSucceed,
|
|
14
|
+
Description: "Postchat context call succeed."
|
|
15
|
+
});
|
|
16
|
+
dispatch({
|
|
17
|
+
type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
|
|
18
|
+
payload: context
|
|
19
|
+
});
|
|
20
|
+
}
|
|
18
21
|
} catch (ex) {
|
|
19
22
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
20
23
|
Event: TelemetryEvent.PostChatContextCallFailed,
|
|
@@ -22,19 +25,17 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, loadSur
|
|
|
22
25
|
exception: ex
|
|
23
26
|
}
|
|
24
27
|
});
|
|
25
|
-
}
|
|
26
|
-
/* -true: setPostChatContextAndLoadSurvey is called after passing all checks from ConfirmationPane and endChatMiddleware in usual scenario.
|
|
27
|
-
-false: Below if condition is needed for multi-tab scenarios. So when agent ends a chat and customer has opened chat in multiple tabs,
|
|
28
|
-
all tabs should show post chat survey as per existing functionality. But when an agent end a conversation, Omnichannel SDK
|
|
29
|
-
getPostChatSurveyContext returns as invalid conversation. To avoid that, caching the survey url is needed after chat starts and
|
|
30
|
-
in this case loadSurvey is false
|
|
31
|
-
*/
|
|
28
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
29
|
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
|
|
32
|
+
dispatch({
|
|
33
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
34
|
+
payload: ConversationState.Loading
|
|
35
|
+
});
|
|
35
36
|
dispatch({
|
|
36
37
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
37
38
|
payload: ConversationState.Postchat
|
|
38
39
|
});
|
|
39
|
-
}
|
|
40
|
+
});
|
|
40
41
|
};
|
|
@@ -1,91 +1,149 @@
|
|
|
1
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
1
|
import { ChatSDKError } from "../../../common/Constants";
|
|
2
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
4
|
+
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
4
5
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
5
6
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
6
7
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
7
8
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
8
9
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
9
10
|
import { createAdapter } from "./createAdapter";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
11
|
+
import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
|
|
12
|
+
import { createTimer, getWidgetCacheId } from "../../../common/utils";
|
|
13
|
+
import { getReconnectIdForAuthenticatedChat, handleRedirectUnauthenticatedReconnectChat } from "./reconnectChatHelper";
|
|
14
|
+
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
12
15
|
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
13
|
-
import {
|
|
16
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
|
|
18
|
+
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
19
|
|
|
15
20
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
16
|
-
|
|
17
|
-
const parseToJson = false;
|
|
18
|
-
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
19
|
-
const showPrechat = state.appStates.conversationState === ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
21
|
+
var _props$reconnectChatP;
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
|
|
24
|
+
return;
|
|
25
|
+
} // Redirecting if unauthenticated reconnect chat expired
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
dispatch({
|
|
29
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
30
|
-
payload: ConversationState.ReconnectChat
|
|
31
|
-
});
|
|
32
|
-
} else if (showPrechat) {
|
|
33
|
-
dispatch({
|
|
34
|
-
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
35
|
-
payload: preChatSurveyResponse
|
|
36
|
-
});
|
|
37
|
-
dispatch({
|
|
38
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
39
|
-
payload: ConversationState.Prechat
|
|
40
|
-
});
|
|
27
|
+
|
|
28
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
29
|
+
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
30
|
+
|
|
31
|
+
await handleRedirectUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
41
32
|
} else {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
// Getting PreChat Survey Context
|
|
34
|
+
const parseToJson = false;
|
|
35
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
36
|
+
const showPrechat = state.appStates.conversationState === ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
37
|
+
|
|
38
|
+
const reconnectId = await getReconnectIdForAuthenticatedChat(props, chatSDK);
|
|
39
|
+
|
|
40
|
+
if (reconnectId) {
|
|
41
|
+
dispatch({
|
|
42
|
+
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
43
|
+
payload: reconnectId
|
|
44
|
+
});
|
|
45
|
+
dispatch({
|
|
46
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
47
|
+
payload: ConversationState.ReconnectChat
|
|
48
|
+
});
|
|
49
|
+
} else if (showPrechat) {
|
|
50
|
+
dispatch({
|
|
51
|
+
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
52
|
+
payload: preChatSurveyResponse
|
|
53
|
+
});
|
|
54
|
+
dispatch({
|
|
55
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
56
|
+
payload: ConversationState.Prechat
|
|
57
|
+
});
|
|
58
|
+
setCustomContextParams(props, state);
|
|
59
|
+
} else {
|
|
60
|
+
dispatch({
|
|
61
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
62
|
+
payload: ConversationState.Loading
|
|
63
|
+
});
|
|
64
|
+
setCustomContextParams(props, state);
|
|
65
|
+
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
66
|
+
}
|
|
47
67
|
}
|
|
48
68
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
69
|
|
|
50
70
|
|
|
51
|
-
const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
|
|
71
|
+
const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
|
|
52
72
|
try {
|
|
53
|
-
var _TelemetryTimers$Widg;
|
|
73
|
+
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
74
|
+
|
|
75
|
+
let isStartChatSuccessful = false;
|
|
76
|
+
|
|
77
|
+
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
78
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|
|
79
|
+
|
|
80
|
+
// Broadcasting limited cached chat details
|
|
81
|
+
BroadcastService.postMessage({
|
|
82
|
+
eventName: BroadcastEvent.ChatRetrievedFromCache,
|
|
83
|
+
payload: {
|
|
84
|
+
chatId: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.liveChatContext) === null || _persistedState$domai2 === void 0 ? void 0 : (_persistedState$domai3 = _persistedState$domai2.chatToken) === null || _persistedState$domai3 === void 0 ? void 0 : _persistedState$domai3.chatId,
|
|
85
|
+
requestId: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai4 = persistedState.domainStates) === null || _persistedState$domai4 === void 0 ? void 0 : (_persistedState$domai5 = _persistedState$domai4.liveChatContext) === null || _persistedState$domai5 === void 0 ? void 0 : _persistedState$domai5.requestId
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
54
89
|
|
|
55
90
|
try {
|
|
56
|
-
|
|
91
|
+
TelemetryTimers.WidgetLoadTimer = createTimer();
|
|
92
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
57
93
|
Event: TelemetryEvent.StartChatSDKCall
|
|
58
94
|
});
|
|
59
|
-
|
|
60
|
-
|
|
95
|
+
optionalParams = Object.assign({}, params, optionalParams);
|
|
96
|
+
await chatSDK.startChat(optionalParams);
|
|
97
|
+
isStartChatSuccessful = true;
|
|
61
98
|
} catch (error) {
|
|
62
|
-
TelemetryHelper.
|
|
99
|
+
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
63
100
|
Event: TelemetryEvent.StartChatMethodException,
|
|
64
101
|
ExceptionDetails: {
|
|
65
102
|
exception: `Failed to setup startChat: ${error}`
|
|
66
103
|
}
|
|
67
104
|
});
|
|
105
|
+
isStartChatSuccessful = false;
|
|
68
106
|
}
|
|
69
107
|
|
|
70
108
|
const newAdapter = await createAdapter(chatSDK);
|
|
71
|
-
setAdapter(newAdapter);
|
|
109
|
+
setAdapter(newAdapter);
|
|
110
|
+
const chatToken = await chatSDK.getChatToken();
|
|
111
|
+
newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe(createOnNewAdapterActivityHandler(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
|
|
72
112
|
|
|
73
|
-
if (
|
|
113
|
+
if (!persistedState) {
|
|
74
114
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
-
|
|
115
|
+
if (chatSDK !== null && chatSDK !== void 0 && chatSDK.getVoiceVideoCalling) {
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
|
+
const chatToken = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatToken());
|
|
118
|
+
dispatch({
|
|
119
|
+
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
120
|
+
payload: chatToken
|
|
121
|
+
});
|
|
122
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
76
126
|
dispatch({
|
|
77
|
-
type: LiveChatWidgetActionType.
|
|
78
|
-
payload:
|
|
127
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
128
|
+
payload: liveChatContext
|
|
79
129
|
});
|
|
80
|
-
|
|
130
|
+
await setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
131
|
+
await updateSessionDataForTelemetry(chatSDK, dispatch); // Set app state to Active
|
|
81
132
|
|
|
82
|
-
|
|
83
|
-
|
|
133
|
+
if (isStartChatSuccessful) {
|
|
134
|
+
dispatch({
|
|
135
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
136
|
+
payload: ConversationState.Active
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
dispatch({
|
|
141
|
+
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
142
|
+
payload: persistedState
|
|
143
|
+
});
|
|
144
|
+
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
145
|
+
}
|
|
84
146
|
|
|
85
|
-
dispatch({
|
|
86
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
87
|
-
payload: ConversationState.Active
|
|
88
|
-
});
|
|
89
147
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
90
148
|
Event: TelemetryEvent.WidgetLoadComplete,
|
|
91
149
|
Description: "Widget load complete",
|
|
@@ -93,9 +151,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
|
|
|
93
151
|
});
|
|
94
152
|
} catch (ex) {
|
|
95
153
|
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
96
|
-
Event: TelemetryEvent.
|
|
154
|
+
Event: TelemetryEvent.WidgetLoadFailed,
|
|
97
155
|
ExceptionDetails: {
|
|
98
|
-
Exception: `
|
|
156
|
+
Exception: `Widget load Failed: ${ex}`
|
|
99
157
|
}
|
|
100
158
|
});
|
|
101
159
|
NotificationHandler.notifyError(NotificationScenarios.Connection, "Start Chat Failed: " + ex); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -111,6 +169,42 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
|
|
|
111
169
|
});
|
|
112
170
|
}
|
|
113
171
|
}
|
|
172
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
176
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli, _persistedState$domai6;
|
|
177
|
+
|
|
178
|
+
const widgetStateEventName = getWidgetCacheId((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) ?? "");
|
|
179
|
+
const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
180
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
181
|
+
|
|
182
|
+
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai6 = persistedState.domainStates) !== null && _persistedState$domai6 !== void 0 && _persistedState$domai6.liveChatContext) {
|
|
183
|
+
var _persistedState$domai7;
|
|
184
|
+
|
|
185
|
+
dispatch({
|
|
186
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
187
|
+
payload: ConversationState.Loading
|
|
188
|
+
});
|
|
189
|
+
const optionalParams = {
|
|
190
|
+
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
191
|
+
};
|
|
192
|
+
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
193
|
+
return true;
|
|
194
|
+
} else {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const setCustomContextParams = (props, state) => {
|
|
200
|
+
var _props$chatConfig, _state$domainStates;
|
|
201
|
+
|
|
202
|
+
// Add custom context if any only for unauthenticated chat
|
|
203
|
+
if (!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) && (_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.customContext) {
|
|
204
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
205
|
+
customContext: state.domainStates.customContext
|
|
206
|
+
});
|
|
207
|
+
}
|
|
114
208
|
};
|
|
115
209
|
|
|
116
210
|
export { prepareStartChat, initStartChat };
|
|
@@ -2,14 +2,14 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
|
|
|
2
2
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
3
3
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
4
4
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
|
-
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
6
|
-
|
|
7
|
-
export const startProactiveChat = (dispatch,
|
|
5
|
+
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
6
|
+
// Defines startProactiveChat callback
|
|
7
|
+
export const startProactiveChat = (dispatch, notificationConfig, enablePreChat, inNewWindow) => {
|
|
8
8
|
dispatch({
|
|
9
9
|
type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
10
10
|
payload: {
|
|
11
|
-
proactiveChatBodyTitle:
|
|
12
|
-
proactiveChatEnablePrechat:
|
|
11
|
+
proactiveChatBodyTitle: notificationConfig && notificationConfig.message ? notificationConfig.message : "",
|
|
12
|
+
proactiveChatEnablePrechat: enablePreChat ?? false,
|
|
13
13
|
proactiveChatInNewWindow: inNewWindow ?? false
|
|
14
14
|
}
|
|
15
15
|
});
|