@microsoft/omnichannel-chat-widget 0.1.0-main.bcfe8a3 → 0.1.0-main.cde77ea
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 +92 -98
- 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 +2 -2
- 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 +92 -97
- 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 +2 -2
- 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
|
@@ -95,10 +95,10 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
95
95
|
|
|
96
96
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
97
97
|
|
|
98
|
-
function _extends() { _extends = Object.assign
|
|
98
|
+
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); }
|
|
99
99
|
|
|
100
100
|
const LiveChatWidgetStateful = props => {
|
|
101
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$
|
|
101
|
+
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;
|
|
102
102
|
|
|
103
103
|
const [state, dispatch] = (0, _useChatContextStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
104
|
|
|
@@ -113,8 +113,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
113
113
|
const {
|
|
114
114
|
Composer
|
|
115
115
|
} = _botframeworkWebchat.Components;
|
|
116
|
-
const canStartProactiveChat = (0, _react2.useRef)(true);
|
|
117
|
-
const canEndChat = (0, _react2.useRef)(true); // Process general styles
|
|
116
|
+
const canStartProactiveChat = (0, _react2.useRef)(true); // Process general styles
|
|
118
117
|
|
|
119
118
|
const generalStyles = {
|
|
120
119
|
root: Object.assign({}, (0, _getGeneralStylesForButton.getGeneralStylesForButton)(state), (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyles)
|
|
@@ -125,9 +124,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
125
124
|
let widgetStateEventName = "";
|
|
126
125
|
|
|
127
126
|
const initiateEndChatOnBrowserUnload = () => {
|
|
128
|
-
var _DataStoreManager$cli;
|
|
127
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli;
|
|
129
128
|
|
|
130
|
-
|
|
129
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
130
|
+
Event: _TelemetryConstants.TelemetryEvent.BrowserUnloadEventStarted,
|
|
131
|
+
Description: "Browser unload event received."
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const persistedState = (0, _utils.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
|
|
131
135
|
|
|
132
136
|
if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
133
137
|
//Browser close scenario/no room for PCS/so just end chat and notify agent immidiately
|
|
@@ -135,22 +139,20 @@ const LiveChatWidgetStateful = props => {
|
|
|
135
139
|
} // Clean local storage
|
|
136
140
|
|
|
137
141
|
|
|
138
|
-
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage");
|
|
139
|
-
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
+
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage"); //Dispose calling instance
|
|
140
143
|
|
|
144
|
+
if (voiceVideoCallingSDK) {
|
|
145
|
+
voiceVideoCallingSDK === null || voiceVideoCallingSDK === void 0 ? void 0 : voiceVideoCallingSDK.close();
|
|
146
|
+
} //Message for clearing window[popouTab]
|
|
141
147
|
|
|
142
|
-
const getStateFromCache = () => {
|
|
143
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli2;
|
|
144
148
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
149
|
-
return persistedState;
|
|
149
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
150
|
+
eventName: _TelemetryConstants.BroadcastEvent.ClosePopoutWindow
|
|
151
|
+
});
|
|
150
152
|
};
|
|
151
153
|
|
|
152
154
|
(0, _react2.useEffect)(() => {
|
|
153
|
-
var _props$controlProps2, _props$controlProps3, _props$
|
|
155
|
+
var _props$controlProps2, _props$controlProps3, _props$chatConfig, _props$chatConfig$Cha, _props$controlProps4, _props$reconnectChatP, _props$chatConfig2, _props$chatConfig2$Li;
|
|
154
156
|
|
|
155
157
|
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
156
158
|
(0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
|
|
@@ -172,29 +174,44 @@ const LiveChatWidgetStateful = props => {
|
|
|
172
174
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
173
175
|
payload: true
|
|
174
176
|
});
|
|
177
|
+
}); // Initialize global dir
|
|
178
|
+
|
|
179
|
+
const globalDir = ((_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.dir) ?? (0, _utils.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);
|
|
180
|
+
dispatch({
|
|
181
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
182
|
+
payload: globalDir
|
|
175
183
|
});
|
|
176
184
|
|
|
177
|
-
if (!((_props$
|
|
185
|
+
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) {
|
|
178
186
|
var _props$reconnectChatP2;
|
|
179
187
|
|
|
180
|
-
(0, _reconnectChatHelper.startUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, _startChat.initStartChat);
|
|
181
|
-
|
|
188
|
+
(0, _reconnectChatHelper.startUnauthenticatedReconnectChat)(chatSDK, props.authProps, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, _startChat.initStartChat);
|
|
189
|
+
return;
|
|
190
|
+
} // Check if auth settings enabled, do not connect to existing chat from cache during refresh/re-load
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
192
|
|
|
183
193
|
|
|
184
|
-
const
|
|
185
|
-
dispatch({
|
|
186
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
187
|
-
payload: globalDir
|
|
188
|
-
});
|
|
194
|
+
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;
|
|
189
195
|
|
|
190
|
-
if (
|
|
191
|
-
var _state$
|
|
196
|
+
if (!isAuthenticationSettingsEnabled) {
|
|
197
|
+
var _state$domainStates;
|
|
192
198
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
199
|
+
if (!(0, _utils.isUndefinedOrEmpty)((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
200
|
+
var _state$domainStates2;
|
|
201
|
+
|
|
202
|
+
const optionalParams = {
|
|
203
|
+
liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
204
|
+
};
|
|
205
|
+
(0, _startChat.initStartChat)(chatSDK, props.authProps, dispatch, setAdapter, optionalParams);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
} // All other case should show start chat button, skipChatButtonRendering will take care of it own
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
dispatch({
|
|
212
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
213
|
+
payload: _ConversationState.ConversationState.Closed
|
|
214
|
+
});
|
|
198
215
|
}, []); // useEffect for when skip chat button rendering
|
|
199
216
|
|
|
200
217
|
(0, _react2.useEffect)(() => {
|
|
@@ -208,7 +225,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
208
225
|
if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
|
|
209
226
|
var _props$reconnectChatP4, _props$reconnectChatP5;
|
|
210
227
|
|
|
211
|
-
(0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, _startChat.initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
|
|
228
|
+
(0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(chatSDK, props.authProps, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, _startChat.initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
|
|
212
229
|
} else {
|
|
213
230
|
(0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK).then(authReconnectId => {
|
|
214
231
|
if (authReconnectId && !state.appStates.reconnectId) {
|
|
@@ -227,11 +244,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
227
244
|
|
|
228
245
|
_omnichannelChatComponents.BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
229
246
|
|
|
230
|
-
dispatch
|
|
231
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
232
|
-
payload: _ConversationState.ConversationState.Loading
|
|
233
|
-
});
|
|
234
|
-
(0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter);
|
|
247
|
+
(0, _startChat.setPreChatAndInitiateChat)(chatSDK, props.authProps, dispatch, setAdapter);
|
|
235
248
|
}
|
|
236
249
|
});
|
|
237
250
|
}
|
|
@@ -239,7 +252,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
239
252
|
}, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
|
|
240
253
|
|
|
241
254
|
(0, _react2.useEffect)(() => {
|
|
242
|
-
var _chatSDK$
|
|
255
|
+
var _chatSDK$omnichannelC7, _chatSDK$omnichannelC8;
|
|
243
256
|
|
|
244
257
|
// Add the custom context on receiving the SetCustomContext event
|
|
245
258
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
@@ -274,12 +287,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
274
287
|
|
|
275
288
|
|
|
276
289
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
290
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
|
|
291
|
+
|
|
277
292
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
278
293
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
279
294
|
Description: "Start chat event received."
|
|
280
295
|
});
|
|
281
296
|
|
|
282
|
-
const persistedState = getStateFromCache();
|
|
297
|
+
const persistedState = (0, _utils.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);
|
|
283
298
|
|
|
284
299
|
if (persistedState && (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat)) {
|
|
285
300
|
// Embedded mode
|
|
@@ -287,13 +302,6 @@ const LiveChatWidgetStateful = props => {
|
|
|
287
302
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
288
303
|
});
|
|
289
304
|
|
|
290
|
-
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
291
|
-
} else if (!persistedState) {
|
|
292
|
-
// Popout chat
|
|
293
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
294
|
-
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
295
|
-
});
|
|
296
|
-
|
|
297
305
|
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
298
306
|
} else {
|
|
299
307
|
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
@@ -316,55 +324,42 @@ const LiveChatWidgetStateful = props => {
|
|
|
316
324
|
|
|
317
325
|
|
|
318
326
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
319
|
-
if (
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
|
|
327
|
+
if (state.appStates.skipChatButtonRendering !== true) {
|
|
328
|
+
var _chatSDK$omnichannelC5, _chatSDK$omnichannelC6;
|
|
329
|
+
|
|
330
|
+
// This is to ensure to get latest state from cache in multitab
|
|
331
|
+
const persistedState = (0, _utils.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);
|
|
332
|
+
|
|
333
|
+
if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
334
|
+
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
335
|
+
} else {
|
|
336
|
+
const skipEndChatSDK = true;
|
|
337
|
+
const skipCloseChat = false;
|
|
338
|
+
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
339
|
+
}
|
|
325
340
|
}
|
|
326
341
|
|
|
327
342
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
328
343
|
eventName: _TelemetryConstants.BroadcastEvent.CloseChat
|
|
329
344
|
});
|
|
330
|
-
});
|
|
345
|
+
}); // End chat on browser unload
|
|
346
|
+
|
|
331
347
|
|
|
332
348
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
|
|
333
349
|
initiateEndChatOnBrowserUnload();
|
|
334
|
-
}); // reset proactive chat params
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
|
|
338
|
-
dispatch({
|
|
339
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
340
|
-
payload: {
|
|
341
|
-
proactiveChatBodyTitle: "",
|
|
342
|
-
proactiveChatEnablePrechat: false,
|
|
343
|
-
proactiveChatInNewWindow: false
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
350
|
}); // Listen to end chat event from other tabs
|
|
347
351
|
|
|
348
352
|
|
|
349
|
-
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
353
|
+
const endChatEventName = (0, _utils.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);
|
|
350
354
|
|
|
351
355
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
352
356
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
353
|
-
}); //
|
|
354
|
-
|
|
357
|
+
}); // When conversation ended by agent
|
|
355
358
|
|
|
356
|
-
window.addEventListener("beforeunload", () => {
|
|
357
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
358
|
-
Event: _TelemetryConstants.TelemetryEvent.WindowClosed,
|
|
359
|
-
Description: "Closed window."
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
(0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
|
|
363
|
-
});
|
|
364
359
|
|
|
365
360
|
if (state.appStates.conversationEndedByAgent) {
|
|
366
361
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
367
|
-
} //Listen to WidgetSize
|
|
362
|
+
} //Listen to WidgetSize, used for minimize to maximize
|
|
368
363
|
|
|
369
364
|
|
|
370
365
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
|
|
@@ -373,25 +368,24 @@ const LiveChatWidgetStateful = props => {
|
|
|
373
368
|
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
374
369
|
});
|
|
375
370
|
});
|
|
371
|
+
|
|
372
|
+
return () => {
|
|
373
|
+
(0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
|
|
374
|
+
};
|
|
376
375
|
}, []);
|
|
377
376
|
(0, _react2.useEffect)(() => {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
381
|
-
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
382
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
383
|
-
eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
} // Track the message count
|
|
387
|
-
|
|
388
|
-
|
|
377
|
+
// On new message
|
|
389
378
|
if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
390
379
|
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
380
|
+
// Track the message count
|
|
391
381
|
currentMessageCountRef.current++;
|
|
392
382
|
dispatch({
|
|
393
383
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
394
384
|
payload: currentMessageCountRef.current + 1
|
|
385
|
+
}); // New message notification
|
|
386
|
+
|
|
387
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
388
|
+
eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
|
|
395
389
|
});
|
|
396
390
|
});
|
|
397
391
|
}
|
|
@@ -416,7 +410,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
416
410
|
}, [state.appStates.isMinimized]); // Broadcast the UnreadMessageCount state on any change.
|
|
417
411
|
|
|
418
412
|
(0, _react2.useEffect)(() => {
|
|
419
|
-
if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
|
|
413
|
+
if (state.appStates.isMinimized === true && state.appStates.unreadMessageCount > 0) {
|
|
420
414
|
const customEvent = {
|
|
421
415
|
elementType: _omnichannelChatComponents.ElementType.Custom,
|
|
422
416
|
eventName: _TelemetryConstants.BroadcastEvent.UnreadMessageCount,
|
|
@@ -459,7 +453,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
459
453
|
const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
460
454
|
|
|
461
455
|
|
|
462
|
-
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
456
|
+
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
|
|
463
457
|
|
|
464
458
|
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
465
459
|
return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
@@ -469,29 +463,29 @@ const LiveChatWidgetStateful = props => {
|
|
|
469
463
|
id: widgetElementId,
|
|
470
464
|
styles: generalStyles,
|
|
471
465
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
472
|
-
}, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
|
|
466
|
+
}, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && !((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.skipChatButtonRendering) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
|
|
473
467
|
buttonProps: props.chatButtonProps,
|
|
474
468
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
475
469
|
startChat: prepareStartChatRelay
|
|
476
|
-
})), !((_props$
|
|
470
|
+
})), !((_props$controlProps7 = props.controlProps) !== null && _props$controlProps7 !== void 0 && _props$controlProps7.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
|
|
477
471
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
478
472
|
startChat: prepareStartChatRelay
|
|
479
|
-
})), !((_props$
|
|
473
|
+
})), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
|
|
480
474
|
headerProps: props.headerProps,
|
|
481
475
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
482
476
|
endChat: endChatRelay
|
|
483
|
-
})), !((_props$
|
|
477
|
+
})), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, props.loadingPaneProps)), !((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, props.outOfOfficeHoursPaneProps)), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
|
|
484
478
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
485
479
|
initStartChat: initStartChatRelay
|
|
486
|
-
})), !((_props$
|
|
480
|
+
})), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
|
|
487
481
|
surveyProps: props.preChatSurveyPaneProps,
|
|
488
482
|
initStartChat: initStartChatRelay
|
|
489
|
-
})), !((_props$
|
|
483
|
+
})), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
490
484
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
491
|
-
}, props.callingContainerProps)), !((_props$
|
|
485
|
+
}, props.callingContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, props.webChatContainerProps)), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
|
|
492
486
|
setPostChatContext: setPostChatContextRelay,
|
|
493
487
|
prepareEndChat: prepareEndChatRelay
|
|
494
|
-
}))), !((_props$
|
|
488
|
+
}))), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane))));
|
|
495
489
|
};
|
|
496
490
|
|
|
497
491
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
@@ -15,8 +15,6 @@ var _utils = require("../../common/utils");
|
|
|
15
15
|
|
|
16
16
|
var _ConversationState = require("../../contexts/common/ConversationState");
|
|
17
17
|
|
|
18
|
-
var _DataStoreManager = require("../../common/contextDataStore/DataStoreManager");
|
|
19
|
-
|
|
20
18
|
var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
|
|
21
19
|
|
|
22
20
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
@@ -93,14 +91,12 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
93
91
|
});
|
|
94
92
|
|
|
95
93
|
try {
|
|
96
|
-
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2,
|
|
94
|
+
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _persistedState$domai, _persistedState$appSt;
|
|
97
95
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
101
|
-
let optionalParams = {};
|
|
96
|
+
const persistedState = (0, _utils.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) ?? "");
|
|
97
|
+
let optionalParams = {}; //Connect to Active chats and chat is not popout
|
|
102
98
|
|
|
103
|
-
if (persistedState
|
|
99
|
+
if (persistedState && !(0, _utils.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.ConversationState.Active && !state.appStates.skipChatButtonRendering) {
|
|
104
100
|
var _persistedState$domai2;
|
|
105
101
|
|
|
106
102
|
optionalParams = {
|
|
@@ -133,7 +133,7 @@ const ProactiveChatPaneStateful = props => {
|
|
|
133
133
|
});
|
|
134
134
|
},
|
|
135
135
|
...(proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : proactiveChatProps.controlProps),
|
|
136
|
-
bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle
|
|
136
|
+
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
|
|
137
137
|
};
|
|
138
138
|
(0, _react.useEffect)(() => {
|
|
139
139
|
(0, _utils.setFocusOnElement)(document.getElementById(controlProps.id + "-startbutton"));
|
|
@@ -14,6 +14,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
14
14
|
class MockChatSDK {
|
|
15
15
|
constructor() {
|
|
16
16
|
_defineProperty(this, "sleep", ms => new Promise(r => setTimeout(r, ms)));
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "isMockModeOn", true);
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
async startChat() {
|
|
@@ -15,6 +15,7 @@ exports.ConversationState = ConversationState;
|
|
|
15
15
|
ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
|
|
16
16
|
ConversationState[ConversationState["Active"] = 5] = "Active";
|
|
17
17
|
ConversationState[ConversationState["InActive"] = 6] = "InActive";
|
|
18
|
-
ConversationState[ConversationState["
|
|
19
|
-
ConversationState[ConversationState["
|
|
18
|
+
ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
|
|
19
|
+
ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
|
|
20
|
+
ConversationState[ConversationState["Closed"] = 9] = "Closed";
|
|
20
21
|
})(ConversationState || (exports.ConversationState = ConversationState = {}));
|
|
@@ -36,7 +36,6 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
36
36
|
isMinimized: false,
|
|
37
37
|
previousElementOnFocusBeforeModalOpen: null,
|
|
38
38
|
outsideOperatingHours: false,
|
|
39
|
-
shouldShowPostChat: false,
|
|
40
39
|
preChatResponseEmail: "",
|
|
41
40
|
isAudioMuted: null,
|
|
42
41
|
newMessage: false,
|
|
@@ -44,7 +44,7 @@ const shouldShowWebChatContainer = state => {
|
|
|
44
44
|
exports.shouldShowWebChatContainer = shouldShowWebChatContainer;
|
|
45
45
|
|
|
46
46
|
const shouldShowLoadingPane = state => {
|
|
47
|
-
return !state.appStates.isMinimized &&
|
|
47
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
exports.shouldShowLoadingPane = shouldShowLoadingPane;
|
|
@@ -56,7 +56,7 @@ const shouldShowReconnectChatPane = state => {
|
|
|
56
56
|
exports.shouldShowReconnectChatPane = shouldShowReconnectChatPane;
|
|
57
57
|
|
|
58
58
|
const shouldShowPostChatLoadingPane = state => {
|
|
59
|
-
return !state.appStates.isMinimized && state.appStates.
|
|
59
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
exports.shouldShowPostChatLoadingPane = shouldShowPostChatLoadingPane;
|
|
@@ -158,6 +158,8 @@ _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect
|
|
|
158
158
|
|
|
159
159
|
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
160
160
|
|
|
161
|
+
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
162
|
+
|
|
161
163
|
export const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
162
164
|
export class HtmlIdNames {}
|
|
163
165
|
|
|
@@ -48,6 +48,7 @@ export let BroadcastEvent; // Events being logged
|
|
|
48
48
|
BroadcastEvent["ChatInitiated"] = "ChatInitiated";
|
|
49
49
|
BroadcastEvent["CloseChat"] = "CloseChat";
|
|
50
50
|
BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
|
|
51
|
+
BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
|
|
51
52
|
})(BroadcastEvent || (BroadcastEvent = {}));
|
|
52
53
|
|
|
53
54
|
export let TelemetryEvent;
|
|
@@ -128,6 +129,8 @@ export let TelemetryEvent;
|
|
|
128
129
|
TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
|
|
129
130
|
TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
|
|
130
131
|
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
132
|
+
TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
|
|
133
|
+
TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
|
|
131
134
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
132
135
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
133
136
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
@@ -199,6 +202,7 @@ export class TelemetryConstants {
|
|
|
199
202
|
case TelemetryEvent.MessageSent:
|
|
200
203
|
case TelemetryEvent.MessageReceived:
|
|
201
204
|
case TelemetryEvent.CustomContextReceived:
|
|
205
|
+
case TelemetryEvent.BrowserUnloadEventStarted:
|
|
202
206
|
return ScenarioType.ACTIONS;
|
|
203
207
|
|
|
204
208
|
case TelemetryEvent.StartChatSDKCall:
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
|
|
2
|
+
import { DataStoreManager } from "./contextDataStore/DataStoreManager";
|
|
2
3
|
import { KeyCodes } from "./KeyCodes";
|
|
3
4
|
import { BroadcastEvent } from "./telemetry/TelemetryConstants";
|
|
4
5
|
|
|
@@ -294,4 +295,39 @@ export const getWidgetCacheId = (orgId, widgetId) => {
|
|
|
294
295
|
};
|
|
295
296
|
export const getWidgetEndChatEventName = (orgId, widgetId) => {
|
|
296
297
|
return `${BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
|
|
298
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
299
|
+
|
|
300
|
+
export const getStateFromCache = (orgId, widgetId) => {
|
|
301
|
+
// Getting updated state from cache
|
|
302
|
+
try {
|
|
303
|
+
if (DataStoreManager.clientDataStore) {
|
|
304
|
+
var _DataStoreManager$cli;
|
|
305
|
+
|
|
306
|
+
const widgetStateEventName = getWidgetCacheId(orgId, widgetId);
|
|
307
|
+
const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
308
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
309
|
+
return persistedState;
|
|
310
|
+
} else {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
} catch (error) {
|
|
314
|
+
console.log(error);
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
318
|
+
|
|
319
|
+
export const isUndefinedOrEmpty = object => {
|
|
320
|
+
if (object) {
|
|
321
|
+
if (Object.keys(object).length === 0) {
|
|
322
|
+
return true;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return false;
|
|
326
|
+
} else {
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
330
|
+
|
|
331
|
+
export const addDelayInMs = ms => {
|
|
332
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
297
333
|
};
|
|
@@ -57,6 +57,10 @@ export const ChatButtonStateful = props => {
|
|
|
57
57
|
titleText: "We're Offline",
|
|
58
58
|
subtitleText: "No agents available",
|
|
59
59
|
onClick: async () => {
|
|
60
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
61
|
+
Event: TelemetryEvent.LCWChatButtonClicked
|
|
62
|
+
});
|
|
63
|
+
|
|
60
64
|
if (state.appStates.isMinimized) {
|
|
61
65
|
dispatch({
|
|
62
66
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -17,7 +17,6 @@ export const ConfirmationPaneStateful = props => {
|
|
|
17
17
|
const {
|
|
18
18
|
prepareEndChat
|
|
19
19
|
} = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
20
|
|
|
22
21
|
const [adapter] = useChatAdapterStore();
|
|
23
22
|
const controlProps = {
|
|
@@ -58,8 +58,8 @@ export const HeaderStateful = props => {
|
|
|
58
58
|
});
|
|
59
59
|
},
|
|
60
60
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
61
|
-
hideTitle: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
62
|
-
hideIcon: state.appStates.conversationState === ConversationState.Loading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
61
|
+
hideTitle: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
62
|
+
hideIcon: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
63
63
|
hideCloseButton: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
64
64
|
};
|
|
65
65
|
const outOfOfficeControlProps = {
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
export class DefaultActivitySubscriber {
|
|
4
|
+
constructor() {
|
|
5
|
+
_defineProperty(this, "observer", void 0);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
async next(activity) {
|
|
10
|
+
this.observer.next(activity);
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|