@microsoft/omnichannel-chat-widget 0.1.0-main.8b6c0d8 → 0.1.0-main.a60f242
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 +52 -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 +59 -4
- package/lib/cjs/common/telemetry/TelemetryHelper.js +22 -4
- package/lib/cjs/common/telemetry/TelemetryManager.js +28 -9
- package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +3 -3
- package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +48 -15
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +9 -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 +28 -5
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -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 +13 -10
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -4
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +49 -47
- package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +14 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +142 -43
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +5 -0
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +49 -11
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +105 -20
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +11 -7
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +22 -24
- package/lib/cjs/components/livechatwidget/common/startChat.js +174 -41
- package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -3
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +249 -67
- 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 +22 -10
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +27 -5
- 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 +4 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +13 -7
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +13 -5
- package/lib/cjs/contexts/createReducer.js +43 -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 -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 +55 -3
- package/lib/esm/common/telemetry/TelemetryHelper.js +22 -5
- package/lib/esm/common/telemetry/TelemetryManager.js +22 -9
- package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +3 -3
- package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +50 -15
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +9 -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 +31 -8
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -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 +14 -11
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +47 -48
- package/lib/esm/components/livechatwidget/common/disposeTelemetryLoggers.js +4 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +139 -42
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -0
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +43 -12
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +94 -20
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +10 -3
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +19 -22
- package/lib/esm/components/livechatwidget/common/startChat.js +167 -39
- package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +235 -71
- 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 +22 -10
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +26 -6
- 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 +4 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +13 -7
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +13 -5
- package/lib/esm/contexts/createReducer.js +43 -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 -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 +43 -2
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryManager.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +3 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +15 -9
- package/lib/types/common/telemetry/interfaces/IChatSDKLogger.d.ts +1 -0
- package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +2 -0
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +12 -0
- 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/disposeTelemetryLoggers.d.ts +1 -0
- 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 +3 -2
- 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 +3 -1
- 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 +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 +5 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +14 -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,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,10 +1,9 @@
|
|
|
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 packageInfo from "@microsoft/omnichannel-chat-sdk/package.json";
|
|
8
7
|
export const registerTelemetryLoggers = (props, dispatch) => {
|
|
9
8
|
var _props$liveChatContex, _props$liveChatContex2;
|
|
10
9
|
|
|
@@ -17,6 +16,8 @@ export const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
17
16
|
|
|
18
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;
|
|
19
18
|
} else {
|
|
19
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$chatSDK3, _props$chatSDK3$omnic;
|
|
20
|
+
|
|
20
21
|
let telemetryData = { ...defaultInternalTelemetryData,
|
|
21
22
|
telemetryConfig: Object.assign({}, defaultTelemetryConfiguration, telemetryConfig),
|
|
22
23
|
ariaConfig: Object.assign({}, defaultAriaConfig, telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.ariaConfigurations)
|
|
@@ -27,7 +28,13 @@ export const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
telemetryData = TelemetryHelper.addWidgetDataToTelemetry(telemetryConfig, telemetryData);
|
|
30
|
-
telemetryData.OCChatSDKVersion =
|
|
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;
|
|
31
38
|
dispatch({
|
|
32
39
|
type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
|
|
33
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,13 @@ 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 => {
|
|
35
32
|
dispatch({
|
|
36
33
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
37
34
|
payload: ConversationState.Postchat
|
|
38
35
|
});
|
|
39
|
-
}
|
|
36
|
+
});
|
|
40
37
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
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
4
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
5
5
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
@@ -7,16 +7,33 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
|
|
|
7
7
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
8
8
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
9
9
|
import { createAdapter } from "./createAdapter";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
|
|
11
|
+
import { createTimer, getStateFromCache, isUndefinedOrEmpty } from "../../../common/utils";
|
|
12
|
+
import { getReconnectIdForAuthenticatedChat, handleRedirectUnauthenticatedReconnectChat } from "./reconnectChatHelper";
|
|
13
|
+
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
12
14
|
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
13
|
-
import {
|
|
15
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
|
|
17
|
+
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
18
|
|
|
15
19
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
var _props$reconnectChatP;
|
|
21
|
+
|
|
22
|
+
optionalParams = {}; //Resetting to ensure no stale values
|
|
23
|
+
// Can connect to existing chat session
|
|
24
|
+
|
|
25
|
+
if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
|
|
26
|
+
return;
|
|
27
|
+
} // Redirecting if unauthenticated reconnect chat expired
|
|
28
|
+
|
|
29
|
+
|
|
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, 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
|
+
|
|
20
37
|
|
|
21
38
|
const reconnectId = await getReconnectIdForAuthenticatedChat(props, chatSDK);
|
|
22
39
|
|
|
@@ -29,7 +46,26 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
29
46
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
30
47
|
payload: ConversationState.ReconnectChat
|
|
31
48
|
});
|
|
32
|
-
|
|
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, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
|
|
59
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const setPreChatAndInitiateChat = async (chatSDK, 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) {
|
|
33
69
|
dispatch({
|
|
34
70
|
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
35
71
|
payload: preChatSurveyResponse
|
|
@@ -38,54 +74,100 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
38
74
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
39
75
|
payload: ConversationState.Prechat
|
|
40
76
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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, dispatch, setAdapter);
|
|
48
86
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
87
|
|
|
50
88
|
|
|
51
|
-
const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
|
|
89
|
+
const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
|
|
52
90
|
try {
|
|
53
|
-
var _TelemetryTimers$Widg;
|
|
91
|
+
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
54
92
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
+
}
|
|
58
104
|
});
|
|
59
|
-
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
//Start widget load timer
|
|
60
109
|
TelemetryTimers.WidgetLoadTimer = createTimer();
|
|
110
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
111
|
+
Event: TelemetryEvent.StartChatSDKCall
|
|
112
|
+
}); // Set optional params
|
|
113
|
+
|
|
114
|
+
optionalParams = Object.assign({}, params, optionalParams);
|
|
115
|
+
await chatSDK.startChat(optionalParams);
|
|
116
|
+
isStartChatSuccessful = true;
|
|
61
117
|
} catch (error) {
|
|
62
|
-
TelemetryHelper.
|
|
118
|
+
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
63
119
|
Event: TelemetryEvent.StartChatMethodException,
|
|
64
120
|
ExceptionDetails: {
|
|
65
121
|
exception: `Failed to setup startChat: ${error}`
|
|
66
122
|
}
|
|
67
123
|
});
|
|
68
|
-
|
|
124
|
+
isStartChatSuccessful = false; // Resetting the widget state to Closed, for recent introduction of OC rate limiting(429 Error)
|
|
125
|
+
// TODO : How to diplay a proper UI message to customer to try after sometime at this point - cool down scenario
|
|
126
|
+
|
|
127
|
+
dispatch({
|
|
128
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
129
|
+
payload: ConversationState.Closed
|
|
130
|
+
});
|
|
131
|
+
return;
|
|
132
|
+
} // New adapter creation
|
|
133
|
+
|
|
69
134
|
|
|
70
135
|
const newAdapter = await createAdapter(chatSDK);
|
|
71
|
-
setAdapter(newAdapter);
|
|
136
|
+
setAdapter(newAdapter);
|
|
137
|
+
const chatToken = await chatSDK.getChatToken();
|
|
138
|
+
dispatch({
|
|
139
|
+
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
140
|
+
payload: chatToken
|
|
141
|
+
});
|
|
142
|
+
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
143
|
|
|
73
|
-
if (
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
-
const chatToken = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatToken());
|
|
144
|
+
if (persistedState) {
|
|
76
145
|
dispatch({
|
|
77
|
-
type: LiveChatWidgetActionType.
|
|
78
|
-
payload:
|
|
146
|
+
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
147
|
+
payload: persistedState
|
|
79
148
|
});
|
|
80
|
-
|
|
149
|
+
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
150
|
+
return;
|
|
151
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
152
|
|
|
82
|
-
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, false);
|
|
83
|
-
await updateSessionDataForTelemetry(chatSDK, dispatch); // Set app state to Active
|
|
84
153
|
|
|
154
|
+
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
85
155
|
dispatch({
|
|
86
|
-
type: LiveChatWidgetActionType.
|
|
87
|
-
payload:
|
|
88
|
-
});
|
|
156
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
157
|
+
payload: liveChatContext
|
|
158
|
+
}); // Set post chat context in state, no survey load
|
|
159
|
+
|
|
160
|
+
await setPostChatContextAndLoadSurvey(chatSDK, dispatch); // Updating chat session detail for telemetry
|
|
161
|
+
|
|
162
|
+
await updateSessionDataForTelemetry(chatSDK, dispatch); // Set app state to Active
|
|
163
|
+
|
|
164
|
+
if (isStartChatSuccessful) {
|
|
165
|
+
dispatch({
|
|
166
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
167
|
+
payload: ConversationState.Active
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
89
171
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
90
172
|
Event: TelemetryEvent.WidgetLoadComplete,
|
|
91
173
|
Description: "Widget load complete",
|
|
@@ -93,9 +175,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
|
|
|
93
175
|
});
|
|
94
176
|
} catch (ex) {
|
|
95
177
|
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
96
|
-
Event: TelemetryEvent.
|
|
178
|
+
Event: TelemetryEvent.WidgetLoadFailed,
|
|
97
179
|
ExceptionDetails: {
|
|
98
|
-
Exception: `
|
|
180
|
+
Exception: `Widget load Failed: ${ex}`
|
|
99
181
|
}
|
|
100
182
|
});
|
|
101
183
|
NotificationHandler.notifyError(NotificationScenarios.Connection, "Start Chat Failed: " + ex); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -110,7 +192,53 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
|
|
|
110
192
|
payload: ConversationState.OutOfOffice
|
|
111
193
|
});
|
|
112
194
|
}
|
|
195
|
+
} finally {
|
|
196
|
+
optionalParams = {};
|
|
197
|
+
}
|
|
198
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
202
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _persistedState$domai6, _persistedState$appSt;
|
|
203
|
+
|
|
204
|
+
// By pass this function in case of popout chat
|
|
205
|
+
if (state.appStates.skipChatButtonRendering === true) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
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
|
|
210
|
+
|
|
211
|
+
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) {
|
|
212
|
+
var _persistedState$domai7;
|
|
213
|
+
|
|
214
|
+
dispatch({
|
|
215
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
216
|
+
payload: ConversationState.Loading
|
|
217
|
+
});
|
|
218
|
+
const optionalParams = {
|
|
219
|
+
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
220
|
+
};
|
|
221
|
+
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
222
|
+
return true;
|
|
223
|
+
} else {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
const setCustomContextParams = (props, chatSDK) => {
|
|
230
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4, _props$chatConfig, _persistedState$domai8;
|
|
231
|
+
|
|
232
|
+
// Add custom context only for unauthenticated chat
|
|
233
|
+
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);
|
|
234
|
+
|
|
235
|
+
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)) {
|
|
236
|
+
var _persistedState$domai9;
|
|
237
|
+
|
|
238
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
239
|
+
customContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.customContext
|
|
240
|
+
});
|
|
113
241
|
}
|
|
114
242
|
};
|
|
115
243
|
|
|
116
|
-
export { prepareStartChat, initStartChat };
|
|
244
|
+
export { prepareStartChat, initStartChat, setPreChatAndInitiateChat };
|
|
@@ -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
|
});
|