@microsoft/omnichannel-chat-widget 0.1.0-main.1f10a2e → 0.1.0-main.2d7913d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/Constants.js +2 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +4 -0
- package/lib/cjs/common/utils.js +48 -2
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -2
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +9 -1
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +49 -17
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -0
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +15 -15
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +124 -84
- package/lib/cjs/components/livechatwidget/interfaces/IAuthProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +95 -92
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +0 -1
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +4 -0
- package/lib/esm/common/utils.js +36 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +2 -2
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -1
- package/lib/esm/components/livechatwidget/common/endChat.js +50 -18
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +9 -2
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +17 -16
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +125 -86
- package/lib/esm/components/livechatwidget/interfaces/IAuthProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +95 -92
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +0 -1
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/types/common/Constants.d.ts +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -1
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -1
- package/lib/types/common/utils.d.ts +3 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- 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/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
4
4
|
import { BroadcastService, decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
5
5
|
import { Stack } from "@fluentui/react";
|
|
6
6
|
import React, { useEffect, useRef, useState } from "react";
|
|
7
|
-
import { createTimer, getLocaleDirection, getWidgetCacheId, getWidgetEndChatEventName } from "../../../common/utils";
|
|
7
|
+
import { createTimer, getLocaleDirection, getStateFromCache, getWidgetCacheId, getWidgetEndChatEventName, isUndefinedOrEmpty } from "../../../common/utils";
|
|
8
8
|
import { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat } from "../common/reconnectChatHelper";
|
|
9
|
-
import { initStartChat, prepareStartChat } from "../common/startChat";
|
|
9
|
+
import { initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
|
|
10
10
|
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
11
11
|
import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
|
|
12
12
|
import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
|
|
@@ -44,7 +44,7 @@ import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
|
44
44
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
45
45
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
46
46
|
export const LiveChatWidgetStateful = props => {
|
|
47
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$
|
|
47
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$controlProps6, _props$componentOverr, _props$controlProps7, _props$componentOverr2, _props$controlProps8, _props$componentOverr3, _props$controlProps9, _props$componentOverr4, _props$controlProps10, _props$componentOverr5, _props$controlProps11, _props$componentOverr6, _props$controlProps12, _props$componentOverr7, _props$controlProps13, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$controlProps16, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
48
48
|
|
|
49
49
|
const [state, dispatch] = useChatContextStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
50
|
|
|
@@ -59,8 +59,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
59
59
|
const {
|
|
60
60
|
Composer
|
|
61
61
|
} = Components;
|
|
62
|
-
const canStartProactiveChat = useRef(true);
|
|
63
|
-
const canEndChat = useRef(true); // Process general styles
|
|
62
|
+
const canStartProactiveChat = useRef(true); // Process general styles
|
|
64
63
|
|
|
65
64
|
const generalStyles = {
|
|
66
65
|
root: Object.assign({}, getGeneralStylesForButton(state), (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyles)
|
|
@@ -71,9 +70,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
71
70
|
let widgetStateEventName = "";
|
|
72
71
|
|
|
73
72
|
const initiateEndChatOnBrowserUnload = () => {
|
|
74
|
-
var _DataStoreManager$cli;
|
|
73
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli;
|
|
75
74
|
|
|
76
|
-
|
|
75
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
76
|
+
Event: TelemetryEvent.BrowserUnloadEventStarted,
|
|
77
|
+
Description: "Browser unload event received."
|
|
78
|
+
});
|
|
79
|
+
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); // End chat if the chat is still active and browser closed
|
|
77
80
|
|
|
78
81
|
if (persistedState.appStates.conversationState === ConversationState.Active) {
|
|
79
82
|
//Browser close scenario/no room for PCS/so just end chat and notify agent immidiately
|
|
@@ -81,22 +84,20 @@ export const LiveChatWidgetStateful = props => {
|
|
|
81
84
|
} // Clean local storage
|
|
82
85
|
|
|
83
86
|
|
|
84
|
-
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage");
|
|
85
|
-
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
+
(_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage"); //Dispose calling instance
|
|
86
88
|
|
|
89
|
+
if (voiceVideoCallingSDK) {
|
|
90
|
+
voiceVideoCallingSDK === null || voiceVideoCallingSDK === void 0 ? void 0 : voiceVideoCallingSDK.close();
|
|
91
|
+
} //Message for clearing window[popouTab]
|
|
87
92
|
|
|
88
|
-
const getStateFromCache = () => {
|
|
89
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli2;
|
|
90
93
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
95
|
-
return persistedState;
|
|
94
|
+
BroadcastService.postMessage({
|
|
95
|
+
eventName: BroadcastEvent.ClosePopoutWindow
|
|
96
|
+
});
|
|
96
97
|
};
|
|
97
98
|
|
|
98
99
|
useEffect(() => {
|
|
99
|
-
var _props$controlProps2, _props$controlProps3, _props$
|
|
100
|
+
var _props$controlProps2, _props$controlProps3, _props$chatConfig, _props$chatConfig$Cha, _props$controlProps4, _props$reconnectChatP, _props$chatConfig2, _props$chatConfig2$Li;
|
|
100
101
|
|
|
101
102
|
registerTelemetryLoggers(props, dispatch);
|
|
102
103
|
createInternetConnectionChangeHandler();
|
|
@@ -118,29 +119,44 @@ export const LiveChatWidgetStateful = props => {
|
|
|
118
119
|
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
119
120
|
payload: true
|
|
120
121
|
});
|
|
122
|
+
}); // Initialize global dir
|
|
123
|
+
|
|
124
|
+
const globalDir = ((_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.dir) ?? getLocaleDirection((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Cha = _props$chatConfig.ChatWidgetLanguage) === null || _props$chatConfig$Cha === void 0 ? void 0 : _props$chatConfig$Cha.msdyn_localeid);
|
|
125
|
+
dispatch({
|
|
126
|
+
type: LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
127
|
+
payload: globalDir
|
|
121
128
|
});
|
|
122
129
|
|
|
123
|
-
if (!((_props$
|
|
130
|
+
if (!((_props$controlProps4 = props.controlProps) !== null && _props$controlProps4 !== void 0 && _props$controlProps4.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
124
131
|
var _props$reconnectChatP2;
|
|
125
132
|
|
|
126
|
-
startUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
|
|
127
|
-
|
|
133
|
+
startUnauthenticatedReconnectChat(chatSDK, props.authProps, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
|
|
134
|
+
return;
|
|
135
|
+
} // Check if auth settings enabled, do not connect to existing chat from cache during refresh/re-load
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
137
|
|
|
129
138
|
|
|
130
|
-
const
|
|
131
|
-
dispatch({
|
|
132
|
-
type: LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
133
|
-
payload: globalDir
|
|
134
|
-
});
|
|
139
|
+
const isAuthenticationSettingsEnabled = (_props$chatConfig2 = props.chatConfig) !== null && _props$chatConfig2 !== void 0 && (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) !== null && _props$chatConfig2$Li !== void 0 && _props$chatConfig2$Li.msdyn_javascriptclientfunction ? true : false;
|
|
135
140
|
|
|
136
|
-
if (
|
|
137
|
-
var _state$
|
|
141
|
+
if (!isAuthenticationSettingsEnabled) {
|
|
142
|
+
var _state$domainStates;
|
|
138
143
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
if (!isUndefinedOrEmpty((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && state.appStates.conversationState === ConversationState.Active) {
|
|
145
|
+
var _state$domainStates2;
|
|
146
|
+
|
|
147
|
+
const optionalParams = {
|
|
148
|
+
liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
149
|
+
};
|
|
150
|
+
initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
} // All other case should show start chat button, skipChatButtonRendering will take care of it own
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
dispatch({
|
|
157
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
158
|
+
payload: ConversationState.Closed
|
|
159
|
+
});
|
|
144
160
|
}, []); // useEffect for when skip chat button rendering
|
|
145
161
|
|
|
146
162
|
useEffect(() => {
|
|
@@ -154,7 +170,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
154
170
|
if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
|
|
155
171
|
var _props$reconnectChatP4, _props$reconnectChatP5;
|
|
156
172
|
|
|
157
|
-
handleUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
|
|
173
|
+
handleUnauthenticatedReconnectChat(chatSDK, props.authProps, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
|
|
158
174
|
} else {
|
|
159
175
|
getReconnectIdForAuthenticatedChat(props, chatSDK).then(authReconnectId => {
|
|
160
176
|
if (authReconnectId && !state.appStates.reconnectId) {
|
|
@@ -171,11 +187,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
171
187
|
eventName: BroadcastEvent.StartChatSkippingChatButtonRendering
|
|
172
188
|
};
|
|
173
189
|
BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
174
|
-
dispatch
|
|
175
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
176
|
-
payload: ConversationState.Loading
|
|
177
|
-
});
|
|
178
|
-
initStartChat(chatSDK, dispatch, setAdapter);
|
|
190
|
+
setPreChatAndInitiateChat(chatSDK, props.authProps, dispatch, setAdapter);
|
|
179
191
|
}
|
|
180
192
|
});
|
|
181
193
|
}
|
|
@@ -183,7 +195,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
183
195
|
}, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
|
|
184
196
|
|
|
185
197
|
useEffect(() => {
|
|
186
|
-
var _chatSDK$
|
|
198
|
+
var _chatSDK$omnichannelC7, _chatSDK$omnichannelC8;
|
|
187
199
|
|
|
188
200
|
// Add the custom context on receiving the SetCustomContext event
|
|
189
201
|
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
@@ -215,13 +227,16 @@ export const LiveChatWidgetStateful = props => {
|
|
|
215
227
|
}); // Start chat from SDK Event
|
|
216
228
|
|
|
217
229
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(() => {
|
|
230
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
|
|
231
|
+
|
|
218
232
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
219
233
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
220
234
|
Description: "Start chat event received."
|
|
221
235
|
});
|
|
222
|
-
const persistedState = getStateFromCache();
|
|
236
|
+
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);
|
|
223
237
|
|
|
224
|
-
if (persistedState.appStates.conversationState === ConversationState.Closed || persistedState.appStates.conversationState === ConversationState.InActive || persistedState.appStates.conversationState === ConversationState.Postchat) {
|
|
238
|
+
if (persistedState && (persistedState.appStates.conversationState === ConversationState.Closed || persistedState.appStates.conversationState === ConversationState.InActive || persistedState.appStates.conversationState === ConversationState.Postchat)) {
|
|
239
|
+
// Embedded mode
|
|
225
240
|
BroadcastService.postMessage({
|
|
226
241
|
eventName: BroadcastEvent.ChatInitiated
|
|
227
242
|
});
|
|
@@ -229,6 +244,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
229
244
|
} else {
|
|
230
245
|
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
231
246
|
|
|
247
|
+
// Minimize to Maximize
|
|
232
248
|
dispatch({
|
|
233
249
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
234
250
|
payload: false
|
|
@@ -244,49 +260,38 @@ export const LiveChatWidgetStateful = props => {
|
|
|
244
260
|
}); // End chat
|
|
245
261
|
|
|
246
262
|
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
247
|
-
if (
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
|
|
263
|
+
if (state.appStates.skipChatButtonRendering !== true) {
|
|
264
|
+
var _chatSDK$omnichannelC5, _chatSDK$omnichannelC6;
|
|
265
|
+
|
|
266
|
+
// This is to ensure to get latest state from cache in multitab
|
|
267
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.widgetId);
|
|
268
|
+
|
|
269
|
+
if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
|
|
270
|
+
prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
271
|
+
} else {
|
|
272
|
+
const skipEndChatSDK = true;
|
|
273
|
+
const skipCloseChat = false;
|
|
274
|
+
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
275
|
+
}
|
|
253
276
|
}
|
|
254
277
|
|
|
255
278
|
BroadcastService.postMessage({
|
|
256
279
|
eventName: BroadcastEvent.CloseChat
|
|
257
280
|
});
|
|
258
|
-
});
|
|
281
|
+
}); // End chat on browser unload
|
|
282
|
+
|
|
259
283
|
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
|
|
260
284
|
initiateEndChatOnBrowserUnload();
|
|
261
|
-
}); // reset proactive chat params
|
|
262
|
-
|
|
263
|
-
BroadcastService.getMessageByEventName(BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
|
|
264
|
-
dispatch({
|
|
265
|
-
type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
266
|
-
payload: {
|
|
267
|
-
proactiveChatBodyTitle: "",
|
|
268
|
-
proactiveChatEnablePrechat: false,
|
|
269
|
-
proactiveChatInNewWindow: false
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
285
|
}); // Listen to end chat event from other tabs
|
|
273
286
|
|
|
274
|
-
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
287
|
+
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.widgetId);
|
|
275
288
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
276
289
|
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
277
|
-
}); //
|
|
278
|
-
|
|
279
|
-
window.addEventListener("beforeunload", () => {
|
|
280
|
-
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
281
|
-
Event: TelemetryEvent.WindowClosed,
|
|
282
|
-
Description: "Closed window."
|
|
283
|
-
});
|
|
284
|
-
disposeTelemetryLoggers();
|
|
285
|
-
});
|
|
290
|
+
}); // When conversation ended by agent
|
|
286
291
|
|
|
287
292
|
if (state.appStates.conversationEndedByAgent) {
|
|
288
293
|
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
289
|
-
} //Listen to WidgetSize
|
|
294
|
+
} //Listen to WidgetSize, used for minimize to maximize
|
|
290
295
|
|
|
291
296
|
|
|
292
297
|
BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
|
|
@@ -295,25 +300,23 @@ export const LiveChatWidgetStateful = props => {
|
|
|
295
300
|
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
296
301
|
});
|
|
297
302
|
});
|
|
303
|
+
return () => {
|
|
304
|
+
disposeTelemetryLoggers();
|
|
305
|
+
};
|
|
298
306
|
}, []);
|
|
299
307
|
useEffect(() => {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (state.appStates.conversationState === ConversationState.Active) {
|
|
303
|
-
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
304
|
-
BroadcastService.postMessage({
|
|
305
|
-
eventName: BroadcastEvent.NewMessageNotification
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
} // Track the message count
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
// On new message
|
|
311
309
|
if (state.appStates.conversationState === ConversationState.Active) {
|
|
312
310
|
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
311
|
+
// Track the message count
|
|
313
312
|
currentMessageCountRef.current++;
|
|
314
313
|
dispatch({
|
|
315
314
|
type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
316
315
|
payload: currentMessageCountRef.current + 1
|
|
316
|
+
}); // New message notification
|
|
317
|
+
|
|
318
|
+
BroadcastService.postMessage({
|
|
319
|
+
eventName: BroadcastEvent.NewMessageNotification
|
|
317
320
|
});
|
|
318
321
|
});
|
|
319
322
|
}
|
|
@@ -337,7 +340,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
337
340
|
}, [state.appStates.isMinimized]); // Broadcast the UnreadMessageCount state on any change.
|
|
338
341
|
|
|
339
342
|
useEffect(() => {
|
|
340
|
-
if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
|
|
343
|
+
if (state.appStates.isMinimized === true && state.appStates.unreadMessageCount > 0) {
|
|
341
344
|
const customEvent = {
|
|
342
345
|
elementType: ElementType.Custom,
|
|
343
346
|
eventName: BroadcastEvent.UnreadMessageCount,
|
|
@@ -378,7 +381,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
378
381
|
const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
379
382
|
|
|
380
383
|
|
|
381
|
-
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
384
|
+
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
|
|
382
385
|
|
|
383
386
|
const confirmationPaneProps = initConfirmationPropsComposer(props);
|
|
384
387
|
return /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
|
|
@@ -388,28 +391,28 @@ export const LiveChatWidgetStateful = props => {
|
|
|
388
391
|
id: widgetElementId,
|
|
389
392
|
styles: generalStyles,
|
|
390
393
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
391
|
-
}, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
|
|
394
|
+
}, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && !((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.skipChatButtonRendering) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
|
|
392
395
|
buttonProps: props.chatButtonProps,
|
|
393
396
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
394
397
|
startChat: prepareStartChatRelay
|
|
395
|
-
})), !((_props$
|
|
398
|
+
})), !((_props$controlProps7 = props.controlProps) !== null && _props$controlProps7 !== void 0 && _props$controlProps7.hideProactiveChatPane) && shouldShowProactiveChatPane(state) && (decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/React.createElement(ProactiveChatPaneStateful, {
|
|
396
399
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
397
400
|
startChat: prepareStartChatRelay
|
|
398
|
-
})), !((_props$
|
|
401
|
+
})), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.hideHeader) && shouldShowHeader(state) && (decodeComponentString((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/React.createElement(HeaderStateful, {
|
|
399
402
|
headerProps: props.headerProps,
|
|
400
403
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
401
404
|
endChat: endChatRelay
|
|
402
|
-
})), !((_props$
|
|
405
|
+
})), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, props.loadingPaneProps)), !((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, props.outOfOfficeHoursPaneProps)), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
|
|
403
406
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
404
407
|
initStartChat: initStartChatRelay
|
|
405
|
-
})), !((_props$
|
|
408
|
+
})), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
|
|
406
409
|
surveyProps: props.preChatSurveyPaneProps,
|
|
407
410
|
initStartChat: initStartChatRelay
|
|
408
|
-
})), !((_props$
|
|
411
|
+
})), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
|
|
409
412
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
410
|
-
}, props.callingContainerProps)), !((_props$
|
|
413
|
+
}, props.callingContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
|
|
411
414
|
setPostChatContext: setPostChatContextRelay,
|
|
412
415
|
prepareEndChat: prepareEndChatRelay
|
|
413
|
-
}))), !((_props$
|
|
416
|
+
}))), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane))));
|
|
414
417
|
};
|
|
415
418
|
export default LiveChatWidgetStateful;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { HtmlAttributeNames, Regex } from "../../common/Constants";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import React, { useEffect } from "react";
|
|
4
|
-
import { extractPreChatSurveyResponseValues, findAllFocusableElement,
|
|
4
|
+
import { extractPreChatSurveyResponseValues, findAllFocusableElement, getStateFromCache, isUndefinedOrEmpty, parseAdaptiveCardPayload } from "../../common/utils";
|
|
5
5
|
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
6
|
-
import { DataStoreManager } from "../../common/contextDataStore/DataStoreManager";
|
|
7
6
|
import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
|
|
8
7
|
import { PreChatSurveyPane } from "@microsoft/omnichannel-chat-components";
|
|
9
8
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
@@ -67,14 +66,12 @@ export const PreChatSurveyPaneStateful = props => {
|
|
|
67
66
|
});
|
|
68
67
|
|
|
69
68
|
try {
|
|
70
|
-
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2,
|
|
69
|
+
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _persistedState$domai, _persistedState$appSt;
|
|
71
70
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
75
|
-
let optionalParams = {};
|
|
71
|
+
const persistedState = getStateFromCache(((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$t = _state$domainStates.telemetryInternalData) === null || _state$domainStates$t === void 0 ? void 0 : _state$domainStates$t.orgId) ?? "", ((_state$domainStates$t2 = state.domainStates.telemetryInternalData) === null || _state$domainStates$t2 === void 0 ? void 0 : _state$domainStates$t2.widgetId) ?? "");
|
|
72
|
+
let optionalParams = {}; //Connect to Active chats and chat is not popout
|
|
76
73
|
|
|
77
|
-
if (persistedState
|
|
74
|
+
if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : _persistedState$domai.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === ConversationState.Active && !state.appStates.skipChatButtonRendering) {
|
|
78
75
|
var _persistedState$domai2;
|
|
79
76
|
|
|
80
77
|
optionalParams = {
|
|
@@ -103,7 +103,7 @@ export const ProactiveChatPaneStateful = props => {
|
|
|
103
103
|
});
|
|
104
104
|
},
|
|
105
105
|
...(proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : proactiveChatProps.controlProps),
|
|
106
|
-
bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle
|
|
106
|
+
bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle ? state.appStates.proactiveChatStates.proactiveChatBodyTitle : proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : (_proactiveChatProps$c = proactiveChatProps.controlProps) === null || _proactiveChatProps$c === void 0 ? void 0 : _proactiveChatProps$c.bodyTitleText
|
|
107
107
|
};
|
|
108
108
|
useEffect(() => {
|
|
109
109
|
setFocusOnElement(document.getElementById(controlProps.id + "-startbutton"));
|
|
@@ -8,6 +8,7 @@ export let ConversationState;
|
|
|
8
8
|
ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
|
|
9
9
|
ConversationState[ConversationState["Active"] = 5] = "Active";
|
|
10
10
|
ConversationState[ConversationState["InActive"] = 6] = "InActive";
|
|
11
|
-
ConversationState[ConversationState["
|
|
12
|
-
ConversationState[ConversationState["
|
|
11
|
+
ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
|
|
12
|
+
ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
|
|
13
|
+
ConversationState[ConversationState["Closed"] = 9] = "Closed";
|
|
13
14
|
})(ConversationState || (ConversationState = {}));
|
|
@@ -27,7 +27,6 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
27
27
|
isMinimized: false,
|
|
28
28
|
previousElementOnFocusBeforeModalOpen: null,
|
|
29
29
|
outsideOperatingHours: false,
|
|
30
|
-
shouldShowPostChat: false,
|
|
31
30
|
preChatResponseEmail: "",
|
|
32
31
|
isAudioMuted: null,
|
|
33
32
|
newMessage: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConversationState } from "../contexts/common/ConversationState";
|
|
2
2
|
export const shouldShowChatButton = state => {
|
|
3
|
-
return state.appStates.isMinimized || state.appStates.conversationState === ConversationState.Closed;
|
|
3
|
+
return (state.appStates.isMinimized || state.appStates.conversationState === ConversationState.Closed) && state.appStates.skipChatButtonRendering == false; // Do not show chat button in case of popout
|
|
4
4
|
};
|
|
5
5
|
export const shouldShowProactiveChatPane = state => {
|
|
6
6
|
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.ProactiveChat;
|
|
@@ -18,13 +18,13 @@ export const shouldShowWebChatContainer = state => {
|
|
|
18
18
|
return state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.InActive;
|
|
19
19
|
};
|
|
20
20
|
export const shouldShowLoadingPane = state => {
|
|
21
|
-
return !state.appStates.isMinimized &&
|
|
21
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Loading;
|
|
22
22
|
};
|
|
23
23
|
export const shouldShowReconnectChatPane = state => {
|
|
24
24
|
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.ReconnectChat;
|
|
25
25
|
};
|
|
26
26
|
export const shouldShowPostChatLoadingPane = state => {
|
|
27
|
-
return !state.appStates.isMinimized && state.appStates.
|
|
27
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.PostchatLoading;
|
|
28
28
|
};
|
|
29
29
|
export const shouldShowOutOfOfficeHoursPane = state => {
|
|
30
30
|
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.OutOfOffice;
|
|
@@ -76,6 +76,7 @@ export declare class Constants {
|
|
|
76
76
|
static readonly internetConnectionTestUrl = "https://ocsdk-prod.azureedge.net/public/connecttest.txt";
|
|
77
77
|
static readonly internetConnectionTestUrlText = "Omnichannel Connect Test";
|
|
78
78
|
static readonly ChatWidgetStateChangedPrefix = "ChatWidgetStateChanged";
|
|
79
|
+
static readonly PostChatLoadingDurationInMs = 2000;
|
|
79
80
|
}
|
|
80
81
|
export declare const Regex: {
|
|
81
82
|
new (): {};
|
|
@@ -40,7 +40,8 @@ export declare enum BroadcastEvent {
|
|
|
40
40
|
MaximizeChat = "MaximizeChat",
|
|
41
41
|
ChatInitiated = "ChatInitiated",
|
|
42
42
|
CloseChat = "CloseChat",
|
|
43
|
-
InitiateEndChatOnBrowserUnload = "InitiateEndChatOnBrowserUnload"
|
|
43
|
+
InitiateEndChatOnBrowserUnload = "InitiateEndChatOnBrowserUnload",
|
|
44
|
+
ClosePopoutWindow = "ClosePopoutWindow"
|
|
44
45
|
}
|
|
45
46
|
export declare enum TelemetryEvent {
|
|
46
47
|
CallAdded = "CallAdded",
|
|
@@ -118,6 +119,8 @@ export declare enum TelemetryEvent {
|
|
|
118
119
|
AudioToggleButtonClicked = "AudioToggleButtonClicked",
|
|
119
120
|
SuppressBotMagicCodeSucceeded = "SuppressBotMagicCodeSucceeded",
|
|
120
121
|
SuppressBotMagicCodeFailed = "SuppressBotMagicCodeFailed",
|
|
122
|
+
GetConversationDetailsException = "GetConversationDetailsException",
|
|
123
|
+
BrowserUnloadEventStarted = "BrowserUnloadEventStarted",
|
|
121
124
|
ProcessingHTMLTextMiddlewareFailed = "ProcessingHTMLTextMiddlewareFailed",
|
|
122
125
|
ProcessingSanitizationMiddlewareFailed = "ProcessingSanitizationMiddlewareFailed",
|
|
123
126
|
FormatTagsMiddlewareJSONStringifyFailed = "FormatTagsMiddlewareJSONStringifyFailed",
|
|
@@ -31,7 +31,7 @@ export declare class TelemetryHelper {
|
|
|
31
31
|
static addWidgetDataToTelemetry(telemetryConfig: ITelemetryConfig, telemetryInternalData: IInternalTelemetryData): IInternalTelemetryData;
|
|
32
32
|
static addSessionDataToTelemetry(chatSession: LiveChatContext, telemetryInternalData: IInternalTelemetryData): IInternalTelemetryData;
|
|
33
33
|
static addConversationDataToTelemetry(liveWorkItem: LiveWorkItemDetails, telemetryInternalData: IInternalTelemetryData): IInternalTelemetryData;
|
|
34
|
-
static logCallingEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper, callId?: string
|
|
34
|
+
static logCallingEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper, callId?: string) => void;
|
|
35
35
|
static logLoadingEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
|
|
36
36
|
static logActionEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
|
|
37
37
|
static logSDKEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
|
|
@@ -24,3 +24,6 @@ export declare const createTimer: () => ITimer;
|
|
|
24
24
|
export declare const getDomain: (hostValue: any) => string;
|
|
25
25
|
export declare const getWidgetCacheId: (orgId: string, widgetId: string) => string;
|
|
26
26
|
export declare const getWidgetEndChatEventName: (orgId: string, widgetId: string) => string;
|
|
27
|
+
export declare const getStateFromCache: (orgId: string, widgetId: string) => any;
|
|
28
|
+
export declare const isUndefinedOrEmpty: (object: any) => boolean;
|
|
29
|
+
export declare const addDelayInMs: (ms: number) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const downloadTranscript: (chatSDK: any, renderMarkDown?: ((transcriptContent: string) => string) | undefined, bannerMessageOnError?: string
|
|
1
|
+
export declare const downloadTranscript: (chatSDK: any, renderMarkDown?: ((transcriptContent: string) => string) | undefined, bannerMessageOnError?: string, attachmentMessage?: string) => Promise<void>;
|
|
@@ -3,5 +3,5 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
|
|
|
3
3
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
4
4
|
import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
|
|
5
5
|
declare const prepareEndChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, state: ILiveChatWidgetContext) => Promise<void>;
|
|
6
|
-
declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, skipEndChatSDK?: boolean
|
|
6
|
+
declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, skipEndChatSDK?: boolean, skipCloseChat?: boolean, postMessageToOtherTab?: boolean) => Promise<void>;
|
|
7
7
|
export { prepareEndChat, endChat };
|
|
@@ -2,9 +2,10 @@ import "regenerator-runtime/runtime";
|
|
|
2
2
|
import { Dispatch } from "react";
|
|
3
3
|
import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
|
|
4
4
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
5
|
-
|
|
5
|
+
import { IAuthProps } from "../interfaces/IAuthProps";
|
|
6
|
+
declare const getChatReconnectContext: (chatSDK: any, reconnectId?: string) => Promise<any>;
|
|
6
7
|
declare const getReconnectIdForAuthenticatedChat: (props: ILiveChatWidgetProps, chatSDK: any) => Promise<string | undefined>;
|
|
7
|
-
declare const handleUnauthenticatedReconnectChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any, redirectInSameWindow: boolean | undefined) => Promise<void>;
|
|
8
|
-
declare const startUnauthenticatedReconnectChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any) => Promise<void>;
|
|
9
|
-
declare const handleRedirectUnauthenticatedReconnectChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, reconnectId: string, redirectInSameWindow: boolean | undefined) => Promise<void>;
|
|
8
|
+
declare const handleUnauthenticatedReconnectChat: (chatSDK: any, authProps: IAuthProps | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any, redirectInSameWindow: boolean | undefined) => Promise<void>;
|
|
9
|
+
declare const startUnauthenticatedReconnectChat: (chatSDK: any, authProps: IAuthProps | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any) => Promise<void>;
|
|
10
|
+
declare const handleRedirectUnauthenticatedReconnectChat: (chatSDK: any, authProps: IAuthProps | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, reconnectId: string, redirectInSameWindow: boolean | undefined) => Promise<void>;
|
|
10
11
|
export { getChatReconnectContext, getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat, handleRedirectUnauthenticatedReconnectChat };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Dispatch } from "react";
|
|
2
2
|
import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
|
|
3
|
-
export declare const setPostChatContextAndLoadSurvey: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, persistedChat?: boolean
|
|
3
|
+
export declare const setPostChatContextAndLoadSurvey: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, persistedChat?: boolean) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function shareObservable(observable: any): any;
|
|
@@ -2,6 +2,8 @@ import { Dispatch } from "react";
|
|
|
2
2
|
import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
|
|
3
3
|
import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
|
|
4
4
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
5
|
+
import { IAuthProps } from "../interfaces/IAuthProps";
|
|
5
6
|
declare const prepareStartChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any) => Promise<void>;
|
|
6
|
-
declare const
|
|
7
|
-
|
|
7
|
+
declare const setPreChatAndInitiateChat: (chatSDK: any, authProps: IAuthProps | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, isProactiveChat?: boolean | false, proactiveChatEnablePrechatState?: boolean | false) => Promise<void>;
|
|
8
|
+
declare const initStartChat: (chatSDK: any, authProps: IAuthProps | undefined, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, params?: any, persistedState?: any) => Promise<void>;
|
|
9
|
+
export { prepareStartChat, initStartChat, setPreChatAndInitiateChat };
|