@microsoft/omnichannel-chat-widget 0.1.0-main.9e62ed8 → 0.1.0-main.a60f242
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/endChat.js +49 -17
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +9 -0
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +115 -80
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +89 -99
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- 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/endChat.js +50 -18
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +10 -2
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +114 -80
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +89 -97
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
- 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/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
- 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,26 +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
|
-
|
|
140
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
141
|
-
eventName: _TelemetryConstants.BroadcastEvent.ChatEnded
|
|
142
|
-
});
|
|
143
|
-
}; // 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
|
|
144
143
|
|
|
144
|
+
if (voiceVideoCallingSDK) {
|
|
145
|
+
voiceVideoCallingSDK === null || voiceVideoCallingSDK === void 0 ? void 0 : voiceVideoCallingSDK.close();
|
|
146
|
+
} //Message for clearing window[popouTab]
|
|
145
147
|
|
|
146
|
-
const getStateFromCache = () => {
|
|
147
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli2;
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
153
|
-
return persistedState;
|
|
149
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
150
|
+
eventName: _TelemetryConstants.BroadcastEvent.ClosePopoutWindow
|
|
151
|
+
});
|
|
154
152
|
};
|
|
155
153
|
|
|
156
154
|
(0, _react2.useEffect)(() => {
|
|
157
|
-
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;
|
|
158
156
|
|
|
159
157
|
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
160
158
|
(0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
|
|
@@ -176,29 +174,44 @@ const LiveChatWidgetStateful = props => {
|
|
|
176
174
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
177
175
|
payload: true
|
|
178
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
|
|
179
183
|
});
|
|
180
184
|
|
|
181
|
-
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) {
|
|
182
186
|
var _props$reconnectChatP2;
|
|
183
187
|
|
|
184
188
|
(0, _reconnectChatHelper.startUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, _startChat.initStartChat);
|
|
185
|
-
|
|
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
|
|
186
192
|
|
|
187
193
|
|
|
188
|
-
const
|
|
189
|
-
dispatch({
|
|
190
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
191
|
-
payload: globalDir
|
|
192
|
-
});
|
|
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;
|
|
193
195
|
|
|
194
|
-
if (
|
|
195
|
-
var _state$
|
|
196
|
+
if (!isAuthenticationSettingsEnabled) {
|
|
197
|
+
var _state$domainStates;
|
|
196
198
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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, 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
|
+
});
|
|
202
215
|
}, []); // useEffect for when skip chat button rendering
|
|
203
216
|
|
|
204
217
|
(0, _react2.useEffect)(() => {
|
|
@@ -231,11 +244,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
231
244
|
|
|
232
245
|
_omnichannelChatComponents.BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
233
246
|
|
|
234
|
-
dispatch
|
|
235
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
236
|
-
payload: _ConversationState.ConversationState.Loading
|
|
237
|
-
});
|
|
238
|
-
(0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter);
|
|
247
|
+
(0, _startChat.setPreChatAndInitiateChat)(chatSDK, dispatch, setAdapter);
|
|
239
248
|
}
|
|
240
249
|
});
|
|
241
250
|
}
|
|
@@ -243,7 +252,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
243
252
|
}, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
|
|
244
253
|
|
|
245
254
|
(0, _react2.useEffect)(() => {
|
|
246
|
-
var _chatSDK$
|
|
255
|
+
var _chatSDK$omnichannelC7, _chatSDK$omnichannelC8;
|
|
247
256
|
|
|
248
257
|
// Add the custom context on receiving the SetCustomContext event
|
|
249
258
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
@@ -278,12 +287,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
278
287
|
|
|
279
288
|
|
|
280
289
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
290
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
|
|
291
|
+
|
|
281
292
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
282
293
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
283
294
|
Description: "Start chat event received."
|
|
284
295
|
});
|
|
285
296
|
|
|
286
|
-
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);
|
|
287
298
|
|
|
288
299
|
if (persistedState && (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat)) {
|
|
289
300
|
// Embedded mode
|
|
@@ -291,13 +302,6 @@ const LiveChatWidgetStateful = props => {
|
|
|
291
302
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
292
303
|
});
|
|
293
304
|
|
|
294
|
-
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
295
|
-
} else if (!persistedState) {
|
|
296
|
-
// Popout chat
|
|
297
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
298
|
-
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
299
|
-
});
|
|
300
|
-
|
|
301
305
|
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
302
306
|
} else {
|
|
303
307
|
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
@@ -320,55 +324,42 @@ const LiveChatWidgetStateful = props => {
|
|
|
320
324
|
|
|
321
325
|
|
|
322
326
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const
|
|
328
|
-
|
|
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
|
+
}
|
|
329
340
|
}
|
|
330
341
|
|
|
331
342
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
332
343
|
eventName: _TelemetryConstants.BroadcastEvent.CloseChat
|
|
333
344
|
});
|
|
334
|
-
});
|
|
345
|
+
}); // End chat on browser unload
|
|
346
|
+
|
|
335
347
|
|
|
336
348
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
|
|
337
349
|
initiateEndChatOnBrowserUnload();
|
|
338
|
-
}); // reset proactive chat params
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
|
|
342
|
-
dispatch({
|
|
343
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
344
|
-
payload: {
|
|
345
|
-
proactiveChatBodyTitle: "",
|
|
346
|
-
proactiveChatEnablePrechat: false,
|
|
347
|
-
proactiveChatInNewWindow: false
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
350
|
}); // Listen to end chat event from other tabs
|
|
351
351
|
|
|
352
352
|
|
|
353
|
-
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);
|
|
354
354
|
|
|
355
355
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
356
356
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
357
|
-
}); //
|
|
357
|
+
}); // When conversation ended by agent
|
|
358
358
|
|
|
359
359
|
|
|
360
|
-
window.addEventListener("beforeunload", () => {
|
|
361
|
-
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
362
|
-
Event: _TelemetryConstants.TelemetryEvent.WindowClosed,
|
|
363
|
-
Description: "Closed window."
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
(0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
|
|
367
|
-
});
|
|
368
|
-
|
|
369
360
|
if (state.appStates.conversationEndedByAgent) {
|
|
370
361
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
371
|
-
} //Listen to WidgetSize
|
|
362
|
+
} //Listen to WidgetSize, used for minimize to maximize
|
|
372
363
|
|
|
373
364
|
|
|
374
365
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
|
|
@@ -377,25 +368,24 @@ const LiveChatWidgetStateful = props => {
|
|
|
377
368
|
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
378
369
|
});
|
|
379
370
|
});
|
|
371
|
+
|
|
372
|
+
return () => {
|
|
373
|
+
(0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
|
|
374
|
+
};
|
|
380
375
|
}, []);
|
|
381
376
|
(0, _react2.useEffect)(() => {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
385
|
-
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
386
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
387
|
-
eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
} // Track the message count
|
|
391
|
-
|
|
392
|
-
|
|
377
|
+
// On new message
|
|
393
378
|
if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
394
379
|
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
|
|
380
|
+
// Track the message count
|
|
395
381
|
currentMessageCountRef.current++;
|
|
396
382
|
dispatch({
|
|
397
383
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
398
384
|
payload: currentMessageCountRef.current + 1
|
|
385
|
+
}); // New message notification
|
|
386
|
+
|
|
387
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
388
|
+
eventName: _TelemetryConstants.BroadcastEvent.NewMessageNotification
|
|
399
389
|
});
|
|
400
390
|
});
|
|
401
391
|
}
|
|
@@ -420,7 +410,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
420
410
|
}, [state.appStates.isMinimized]); // Broadcast the UnreadMessageCount state on any change.
|
|
421
411
|
|
|
422
412
|
(0, _react2.useEffect)(() => {
|
|
423
|
-
if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
|
|
413
|
+
if (state.appStates.isMinimized === true && state.appStates.unreadMessageCount > 0) {
|
|
424
414
|
const customEvent = {
|
|
425
415
|
elementType: _omnichannelChatComponents.ElementType.Custom,
|
|
426
416
|
eventName: _TelemetryConstants.BroadcastEvent.UnreadMessageCount,
|
|
@@ -473,29 +463,29 @@ const LiveChatWidgetStateful = props => {
|
|
|
473
463
|
id: widgetElementId,
|
|
474
464
|
styles: generalStyles,
|
|
475
465
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
476
|
-
}, !((_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, {
|
|
477
467
|
buttonProps: props.chatButtonProps,
|
|
478
468
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
479
469
|
startChat: prepareStartChatRelay
|
|
480
|
-
})), !((_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, {
|
|
481
471
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
482
472
|
startChat: prepareStartChatRelay
|
|
483
|
-
})), !((_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, {
|
|
484
474
|
headerProps: props.headerProps,
|
|
485
475
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
486
476
|
endChat: endChatRelay
|
|
487
|
-
})), !((_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, {
|
|
488
478
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
489
479
|
initStartChat: initStartChatRelay
|
|
490
|
-
})), !((_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, {
|
|
491
481
|
surveyProps: props.preChatSurveyPaneProps,
|
|
492
482
|
initStartChat: initStartChatRelay
|
|
493
|
-
})), !((_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({
|
|
494
484
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
495
|
-
}, 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, {
|
|
496
486
|
setPostChatContext: setPostChatContextRelay,
|
|
497
487
|
prepareEndChat: prepareEndChatRelay
|
|
498
|
-
}))), !((_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))));
|
|
499
489
|
};
|
|
500
490
|
|
|
501
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"));
|
|
@@ -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 = {
|