@microsoft/omnichannel-chat-widget 0.1.0-main.7338c17 → 0.1.0-main.7375e33
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 +35 -11
- package/lib/cjs/assets/Audios.js +8 -0
- package/lib/cjs/assets/Icons.js +28 -0
- package/lib/cjs/common/Constants.js +52 -6
- package/lib/cjs/common/telemetry/TelemetryConstants.js +56 -6
- 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 +76 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -4
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -40
- 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 +13 -10
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -4
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +27 -23
- package/lib/cjs/components/livechatwidget/common/endChat.js +141 -50
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +1 -1
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +47 -9
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +107 -22
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +6 -17
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -9
- package/lib/cjs/components/livechatwidget/common/startChat.js +143 -51
- package/lib/cjs/{assets/assets.d.js → components/livechatwidget/interfaces/IAuthProps.js} +0 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +235 -79
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +19 -3
- 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 +4 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +9 -7
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +8 -3
- package/lib/cjs/contexts/createReducer.js +16 -10
- package/lib/cjs/controller/componentController.js +5 -5
- 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 +48 -5
- package/lib/esm/common/telemetry/TelemetryConstants.js +52 -5
- 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 +55 -1
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -7
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -36
- 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 +14 -11
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +25 -24
- package/lib/esm/components/livechatwidget/common/endChat.js +139 -50
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +1 -1
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +42 -11
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +98 -23
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +5 -14
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -9
- package/lib/esm/components/livechatwidget/common/startChat.js +142 -54
- package/lib/esm/components/livechatwidget/interfaces/IAuthProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +221 -79
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +20 -4
- 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 +4 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +9 -7
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +8 -3
- package/lib/esm/contexts/createReducer.js +16 -9
- package/lib/esm/controller/componentController.js +5 -5
- 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 +26 -2
- package/lib/types/common/interfaces/IContextDataStore.d.ts +2 -2
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +40 -4
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +3 -1
- 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 +6 -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/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -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 +6 -2
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/IAuthProps.d.ts +4 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -1
- 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 +1 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -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 +4 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +10 -8
- package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
- package/package.json +9 -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,9 +1,13 @@
|
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
1
2
|
import { createStore } from "botframework-webchat";
|
|
3
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
|
+
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
2
5
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
3
6
|
import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
|
|
7
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
8
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
5
9
|
import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
|
|
6
|
-
import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
|
|
10
|
+
import { addDelayInMs, changeLanguageCodeFormatForWebChat } from "../../../common/utils";
|
|
7
11
|
import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
|
|
8
12
|
import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
|
|
9
13
|
import createAttachmentMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
|
|
@@ -13,6 +17,7 @@ import createConversationEndMiddleware from "../../webchatcontainerstateful/webc
|
|
|
13
17
|
import createDataMaskingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware";
|
|
14
18
|
import { createMarkdown } from "./createMarkdown";
|
|
15
19
|
import createMaxMessageSizeValidator from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator";
|
|
20
|
+
import { createWebChatTelemetry } from "../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
|
|
16
21
|
import { defaultAttachmentProps } from "../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps";
|
|
17
22
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
18
23
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
@@ -22,10 +27,12 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
|
|
|
22
27
|
import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
|
|
23
28
|
import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
|
|
24
29
|
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
25
|
-
import {
|
|
26
|
-
|
|
30
|
+
import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
|
|
31
|
+
import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
|
|
32
|
+
import { Constants } from "../../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
|
|
27
34
|
export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
28
|
-
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;
|
|
35
|
+
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;
|
|
29
36
|
|
|
30
37
|
const localizedTexts = { ...defaultMiddlewareLocalizedTexts,
|
|
31
38
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -44,6 +51,11 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
44
51
|
const conversationEndCallback = async () => {
|
|
45
52
|
var _props$webChatContain4, _props$webChatContain5;
|
|
46
53
|
|
|
54
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
55
|
+
Event: TelemetryEvent.ConversationEndedThreadEventReceived,
|
|
56
|
+
Description: "Conversation is ended by agent side or by timeout."
|
|
57
|
+
});
|
|
58
|
+
|
|
47
59
|
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) {
|
|
48
60
|
setWebChatStyles(styles => {
|
|
49
61
|
return { ...styles,
|
|
@@ -52,11 +64,24 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
52
64
|
});
|
|
53
65
|
}
|
|
54
66
|
|
|
55
|
-
if (isPostChatEnabled === "true"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
if (isPostChatEnabled === "true") {
|
|
68
|
+
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
69
|
+
WebChatStoreLoader.store = null;
|
|
70
|
+
dispatch({
|
|
71
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
72
|
+
payload: ConversationState.PostchatLoading
|
|
73
|
+
});
|
|
74
|
+
await addDelayInMs(Constants.PostChatLoadingDurationInMs);
|
|
75
|
+
const loadPostChatEvent = {
|
|
76
|
+
eventName: BroadcastEvent.LoadPostChatSurvey
|
|
77
|
+
};
|
|
78
|
+
BroadcastService.postMessage(loadPostChatEvent);
|
|
79
|
+
} else if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
80
|
+
dispatch({
|
|
81
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
82
|
+
payload: ConversationState.InActive
|
|
83
|
+
});
|
|
84
|
+
}
|
|
60
85
|
} else {
|
|
61
86
|
dispatch({
|
|
62
87
|
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
|
|
@@ -68,10 +93,14 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
68
93
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
69
94
|
payload: undefined
|
|
70
95
|
});
|
|
96
|
+
dispatch({
|
|
97
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
98
|
+
payload: undefined
|
|
99
|
+
});
|
|
71
100
|
};
|
|
72
101
|
|
|
73
102
|
webChatStore = createStore({}, //initial state
|
|
74
|
-
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
|
|
103
|
+
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
|
|
75
104
|
...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
|
|
76
105
|
WebChatStoreLoader.store = webChatStore;
|
|
77
106
|
} // Initialize the remaining Web Chat props
|
|
@@ -88,7 +117,9 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
88
117
|
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),
|
|
89
118
|
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,
|
|
90
119
|
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,
|
|
91
|
-
|
|
120
|
+
onTelemetry: createWebChatTelemetry(),
|
|
121
|
+
cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
122
|
+
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
92
123
|
};
|
|
93
124
|
return webChatProps;
|
|
94
125
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
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
|
-
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
9
|
const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
9
10
|
try {
|
|
10
11
|
if (reconnectId) {
|
|
@@ -29,9 +30,9 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
32
|
-
var _props$reconnectChatP, _props$
|
|
33
|
+
var _props$reconnectChatP, _props$authProps;
|
|
33
34
|
|
|
34
|
-
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$
|
|
35
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$authProps = props.authProps) !== null && _props$authProps !== void 0 && _props$authProps.authClientFunction // TODO: Implement this after storage is in place
|
|
35
36
|
|
|
36
37
|
/* && !isLoadWithState() */
|
|
37
38
|
) {
|
|
@@ -46,33 +47,107 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
|
46
47
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
48
|
|
|
48
49
|
|
|
49
|
-
const handleUnauthenticatedReconnectChat = async (dispatch, reconnectId, initStartChat) => {
|
|
50
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(reconnectId);
|
|
50
|
+
const handleUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
51
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
51
52
|
|
|
52
|
-
if (reconnectAvailabilityResponse
|
|
53
|
-
|
|
53
|
+
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
54
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
54
55
|
} else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
|
|
57
|
+
}
|
|
58
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const startUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
62
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
63
|
+
|
|
64
|
+
if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
65
|
+
await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
|
|
66
|
+
}
|
|
67
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const setReconnectIdAndStartChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
71
|
+
const startUnauthenticatedReconnectChat = {
|
|
72
|
+
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
73
|
+
};
|
|
74
|
+
BroadcastService.postMessage(startUnauthenticatedReconnectChat);
|
|
75
|
+
const optionalParams = {
|
|
76
|
+
reconnectId: reconnectId
|
|
77
|
+
};
|
|
78
|
+
dispatch({
|
|
79
|
+
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
80
|
+
payload: reconnectId
|
|
81
|
+
});
|
|
82
|
+
dispatch({
|
|
83
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
84
|
+
payload: ConversationState.Loading
|
|
85
|
+
});
|
|
86
|
+
await initStartChat(chatSDK, authProps, dispatch, setAdapter, optionalParams);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
90
|
+
const redirectPageRequest = {
|
|
91
|
+
eventName: BroadcastEvent.RedirectPageRequest,
|
|
92
|
+
payload: {
|
|
93
|
+
redirectURL: redirectURL
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
BroadcastService.postMessage(redirectPageRequest);
|
|
97
|
+
|
|
98
|
+
if (redirectInSameWindow) {
|
|
99
|
+
window.location.href = redirectURL;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
|
|
104
|
+
return reconnectAvailabilityResponse && !reconnectAvailabilityResponse.reconnectId;
|
|
105
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
const startNewChatEmptyRedirectionUrl = async (chatSDK, authProps, dispatch, setAdapter, initStartChat) => {
|
|
109
|
+
const startUnauthenticatedReconnectChat = {
|
|
110
|
+
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
111
|
+
};
|
|
112
|
+
BroadcastService.postMessage(startUnauthenticatedReconnectChat); // Getting PreChat Survey Context
|
|
113
|
+
|
|
114
|
+
const parseToJson = false;
|
|
115
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
116
|
+
|
|
117
|
+
if (preChatSurveyResponse) {
|
|
58
118
|
dispatch({
|
|
59
|
-
type: LiveChatWidgetActionType.
|
|
60
|
-
payload:
|
|
119
|
+
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
120
|
+
payload: preChatSurveyResponse
|
|
61
121
|
});
|
|
122
|
+
dispatch({
|
|
123
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
124
|
+
payload: ConversationState.Prechat
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
62
127
|
dispatch({
|
|
63
128
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
64
129
|
payload: ConversationState.Loading
|
|
65
130
|
});
|
|
66
|
-
await initStartChat(
|
|
131
|
+
await initStartChat(chatSDK, authProps, dispatch, setAdapter);
|
|
67
132
|
}
|
|
68
|
-
};
|
|
133
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
134
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
135
|
+
|
|
136
|
+
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
137
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
138
|
+
|
|
139
|
+
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
140
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
141
|
+
}
|
|
142
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
146
|
+
if (reconnectAvailabilityResponse.redirectURL) {
|
|
147
|
+
redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
|
|
148
|
+
} else {
|
|
149
|
+
await startNewChatEmptyRedirectionUrl(chatSDK, authProps, dispatch, setAdapter, initStartChat);
|
|
150
|
+
}
|
|
76
151
|
};
|
|
77
152
|
|
|
78
|
-
export { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat };
|
|
153
|
+
export { getChatReconnectContext, getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat, handleRedirectUnauthenticatedReconnectChat };
|
|
@@ -1,22 +1,12 @@
|
|
|
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";
|
|
6
6
|
import { defaultTelemetryConfiguration } from "../../../common/telemetry/defaultConfigs/defaultTelemetryConfiguration";
|
|
7
|
-
import { version as chatComponentVersion } from "@microsoft/omnichannel-chat-components/package.json";
|
|
8
|
-
import { version as chatSdkVersion } from "@microsoft/omnichannel-chat-sdk/package.json";
|
|
9
7
|
export const registerTelemetryLoggers = (props, dispatch) => {
|
|
10
8
|
var _props$liveChatContex, _props$liveChatContex2;
|
|
11
9
|
|
|
12
|
-
let widgetPackageInfo;
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
widgetPackageInfo = require("@microsoft/omnichannel-chat-widget/package.json");
|
|
16
|
-
} catch (error) {
|
|
17
|
-
widgetPackageInfo = "0.0.0-0";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
10
|
const telemetryConfig = { ...defaultTelemetryConfiguration,
|
|
21
11
|
...props.telemetryConfig
|
|
22
12
|
};
|
|
@@ -38,12 +28,13 @@ export const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
38
28
|
}
|
|
39
29
|
|
|
40
30
|
telemetryData = TelemetryHelper.addWidgetDataToTelemetry(telemetryConfig, telemetryData);
|
|
41
|
-
telemetryData.OCChatSDKVersion =
|
|
42
|
-
telemetryData.chatComponentVersion = chatComponentVersion;
|
|
43
|
-
telemetryData.chatWidgetVersion =
|
|
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";
|
|
44
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;
|
|
45
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;
|
|
46
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;
|
|
47
38
|
dispatch({
|
|
48
39
|
type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
|
|
49
40
|
payload: telemetryData
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
3
|
-
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
|
-
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
5
2
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
6
|
-
|
|
3
|
+
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
4
|
+
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
5
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
|
|
7
7
|
export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
|
|
8
8
|
try {
|
|
9
9
|
if (!persistedChat) {
|
|
@@ -25,13 +25,10 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persist
|
|
|
25
25
|
exception: ex
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
}
|
|
28
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
29
|
+
|
|
29
30
|
|
|
30
31
|
BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
|
|
31
|
-
dispatch({
|
|
32
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
33
|
-
payload: ConversationState.Loading
|
|
34
|
-
});
|
|
35
32
|
dispatch({
|
|
36
33
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
37
34
|
payload: ConversationState.Postchat
|
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
import { ChatSDKError
|
|
2
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
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";
|
|
5
4
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
6
5
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
7
6
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
8
7
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
9
8
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
10
9
|
import { createAdapter } from "./createAdapter";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
|
|
11
|
+
import { createTimer, getStateFromCache, isUndefinedOrEmpty } from "../../../common/utils";
|
|
12
|
+
import { getReconnectIdForAuthenticatedChat, handleRedirectUnauthenticatedReconnectChat } from "./reconnectChatHelper";
|
|
13
13
|
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
14
|
-
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
14
|
+
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
15
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
18
|
|
|
16
19
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
20
|
+
var _props$reconnectChatP;
|
|
21
|
+
|
|
22
|
+
optionalParams = {}; //Resetting to ensure no stale values
|
|
23
|
+
// Can connect to existing chat session
|
|
24
|
+
|
|
17
25
|
if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
|
|
18
26
|
return;
|
|
19
|
-
} //
|
|
27
|
+
} // Redirecting if unauthenticated reconnect chat expired
|
|
20
28
|
|
|
21
29
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
31
|
+
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
32
|
+
|
|
33
|
+
await handleRedirectUnauthenticatedReconnectChat(chatSDK, props.authProps, 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);
|
|
34
|
+
return;
|
|
35
|
+
} // Getting reconnectId for authenticated chat
|
|
36
|
+
|
|
25
37
|
|
|
26
38
|
const reconnectId = await getReconnectIdForAuthenticatedChat(props, chatSDK);
|
|
27
39
|
|
|
@@ -34,7 +46,26 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
34
46
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
35
47
|
payload: ConversationState.ReconnectChat
|
|
36
48
|
});
|
|
37
|
-
|
|
49
|
+
return;
|
|
50
|
+
} // Set custom context params
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
setCustomContextParams(props, chatSDK); // Setting Proactive chat settings
|
|
54
|
+
|
|
55
|
+
const isProactiveChat = state.appStates.conversationState === ConversationState.ProactiveChat;
|
|
56
|
+
const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat; //Setting PreChat and intiate chat
|
|
57
|
+
|
|
58
|
+
setPreChatAndInitiateChat(chatSDK, props.authProps, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
|
|
59
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const setPreChatAndInitiateChat = async (chatSDK, authProps, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
|
|
63
|
+
// Getting prechat Survey Context
|
|
64
|
+
const parseToJson = false;
|
|
65
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
66
|
+
const showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse;
|
|
67
|
+
|
|
68
|
+
if (showPrechat) {
|
|
38
69
|
dispatch({
|
|
39
70
|
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
40
71
|
payload: preChatSurveyResponse
|
|
@@ -43,26 +74,51 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
43
74
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
44
75
|
payload: ConversationState.Prechat
|
|
45
76
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
77
|
+
return;
|
|
78
|
+
} //Initiate start chat
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
dispatch({
|
|
82
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
83
|
+
payload: ConversationState.Loading
|
|
84
|
+
});
|
|
85
|
+
await initStartChat(chatSDK, authProps, dispatch, setAdapter);
|
|
53
86
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
87
|
|
|
55
88
|
|
|
56
|
-
const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
|
|
89
|
+
const initStartChat = async (chatSDK, authProps, dispatch, setAdapter, params, persistedState) => {
|
|
57
90
|
try {
|
|
58
|
-
var _TelemetryTimers$Widg;
|
|
91
|
+
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
92
|
+
|
|
93
|
+
let isStartChatSuccessful = false; //Check if chat retrieved from cache
|
|
94
|
+
|
|
95
|
+
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
96
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|
|
97
|
+
|
|
98
|
+
BroadcastService.postMessage({
|
|
99
|
+
eventName: BroadcastEvent.ChatRetrievedFromCache,
|
|
100
|
+
payload: {
|
|
101
|
+
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,
|
|
102
|
+
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
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
59
106
|
|
|
60
107
|
try {
|
|
108
|
+
//Start widget load timer
|
|
61
109
|
TelemetryTimers.WidgetLoadTimer = createTimer();
|
|
62
110
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
63
111
|
Event: TelemetryEvent.StartChatSDKCall
|
|
64
|
-
});
|
|
65
|
-
|
|
112
|
+
}); // Set optional params
|
|
113
|
+
|
|
114
|
+
optionalParams = Object.assign({}, params, optionalParams); // set auth token to chat sdk before start chat
|
|
115
|
+
|
|
116
|
+
if (authProps && authProps.setAuthTokenProviderToChatSdk) {
|
|
117
|
+
await authProps.setAuthTokenProviderToChatSdk(chatSDK, authProps.authClientFunction);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
await chatSDK.startChat(optionalParams);
|
|
121
|
+
isStartChatSuccessful = true;
|
|
66
122
|
} catch (error) {
|
|
67
123
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
68
124
|
Event: TelemetryEvent.StartChatMethodException,
|
|
@@ -70,41 +126,51 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
70
126
|
exception: `Failed to setup startChat: ${error}`
|
|
71
127
|
}
|
|
72
128
|
});
|
|
73
|
-
|
|
129
|
+
isStartChatSuccessful = false; // Resetting the widget state to Closed, for recent introduction of OC rate limiting(429 Error)
|
|
130
|
+
// TODO : How to diplay a proper UI message to customer to try after sometime at this point - cool down scenario
|
|
74
131
|
|
|
75
|
-
|
|
76
|
-
|
|
132
|
+
dispatch({
|
|
133
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
134
|
+
payload: ConversationState.Closed
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
} // New adapter creation
|
|
77
138
|
|
|
78
|
-
if (!persistedState) {
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
-
if (chatSDK !== null && chatSDK !== void 0 && chatSDK.getVoiceVideoCalling) {
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
-
const chatToken = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatToken());
|
|
83
|
-
dispatch({
|
|
84
|
-
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
85
|
-
payload: chatToken
|
|
86
|
-
});
|
|
87
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
139
|
|
|
140
|
+
const newAdapter = await createAdapter(chatSDK);
|
|
141
|
+
setAdapter(newAdapter);
|
|
142
|
+
const chatToken = await chatSDK.getChatToken();
|
|
143
|
+
dispatch({
|
|
144
|
+
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
145
|
+
payload: chatToken
|
|
146
|
+
});
|
|
147
|
+
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));
|
|
89
148
|
|
|
90
|
-
|
|
149
|
+
if (persistedState) {
|
|
91
150
|
dispatch({
|
|
92
|
-
type: LiveChatWidgetActionType.
|
|
93
|
-
payload:
|
|
151
|
+
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
152
|
+
payload: persistedState
|
|
94
153
|
});
|
|
95
|
-
await setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
96
|
-
|
|
154
|
+
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
155
|
+
return;
|
|
156
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
160
|
+
dispatch({
|
|
161
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
162
|
+
payload: liveChatContext
|
|
163
|
+
}); // Set post chat context in state, no survey load
|
|
97
164
|
|
|
165
|
+
await setPostChatContextAndLoadSurvey(chatSDK, dispatch); // Updating chat session detail for telemetry
|
|
166
|
+
|
|
167
|
+
await updateSessionDataForTelemetry(chatSDK, dispatch); // Set app state to Active
|
|
168
|
+
|
|
169
|
+
if (isStartChatSuccessful) {
|
|
98
170
|
dispatch({
|
|
99
171
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
100
172
|
payload: ConversationState.Active
|
|
101
173
|
});
|
|
102
|
-
} else {
|
|
103
|
-
dispatch({
|
|
104
|
-
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
105
|
-
payload: persistedState
|
|
106
|
-
});
|
|
107
|
-
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
108
174
|
}
|
|
109
175
|
|
|
110
176
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
@@ -131,31 +197,53 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
131
197
|
payload: ConversationState.OutOfOffice
|
|
132
198
|
});
|
|
133
199
|
}
|
|
200
|
+
} finally {
|
|
201
|
+
optionalParams = {};
|
|
134
202
|
}
|
|
135
203
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
136
204
|
|
|
137
205
|
|
|
138
206
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
139
|
-
var
|
|
207
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _persistedState$domai6, _persistedState$appSt;
|
|
208
|
+
|
|
209
|
+
// By pass this function in case of popout chat
|
|
210
|
+
if (state.appStates.skipChatButtonRendering === true) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
140
213
|
|
|
141
|
-
const
|
|
142
|
-
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
214
|
+
const persistedState = getStateFromCache(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); //Connect to only active chat session
|
|
143
215
|
|
|
144
|
-
if (persistedState
|
|
145
|
-
var _persistedState$
|
|
216
|
+
if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === ConversationState.Active) {
|
|
217
|
+
var _persistedState$domai7;
|
|
146
218
|
|
|
147
219
|
dispatch({
|
|
148
220
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
149
221
|
payload: ConversationState.Loading
|
|
150
222
|
});
|
|
151
223
|
const optionalParams = {
|
|
152
|
-
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$
|
|
224
|
+
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
153
225
|
};
|
|
154
|
-
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
226
|
+
await initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
|
|
155
227
|
return true;
|
|
156
228
|
} else {
|
|
157
229
|
return false;
|
|
158
230
|
}
|
|
231
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
const setCustomContextParams = (props, chatSDK) => {
|
|
235
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4, _props$chatConfig, _persistedState$domai8;
|
|
236
|
+
|
|
237
|
+
// Add custom context only for unauthenticated chat
|
|
238
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId);
|
|
239
|
+
|
|
240
|
+
if (!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai8 = persistedState.domainStates) === null || _persistedState$domai8 === void 0 ? void 0 : _persistedState$domai8.customContext)) {
|
|
241
|
+
var _persistedState$domai9;
|
|
242
|
+
|
|
243
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
244
|
+
customContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.customContext
|
|
245
|
+
});
|
|
246
|
+
}
|
|
159
247
|
};
|
|
160
248
|
|
|
161
|
-
export { prepareStartChat, initStartChat };
|
|
249
|
+
export { prepareStartChat, initStartChat, setPreChatAndInitiateChat };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|