@microsoft/omnichannel-chat-widget 0.1.0-main.cde77ea → 0.1.0-main.ce08f21
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 +2 -0
- package/lib/cjs/common/utils.js +12 -5
- package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -1
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +4 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +2 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +3 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +23 -15
- package/lib/cjs/components/livechatwidget/common/startChat.js +45 -14
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +84 -40
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/esm/common/utils.js +11 -5
- package/lib/esm/components/headerstateful/HeaderStateful.js +2 -1
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +4 -1
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +2 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +3 -3
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +24 -17
- package/lib/esm/components/livechatwidget/common/startChat.js +44 -16
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +83 -42
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/types/common/Constants.d.ts +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -0
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -1
- package/lib/types/common/utils.d.ts +4 -4
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -5
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -2
- 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/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +4 -3
- package/lib/cjs/components/livechatwidget/interfaces/IAuthProps.js +0 -1
- package/lib/esm/components/livechatwidget/interfaces/IAuthProps.js +0 -1
- package/lib/types/components/livechatwidget/interfaces/IAuthProps.d.ts +0 -4
|
@@ -89,6 +89,10 @@ var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useCha
|
|
|
89
89
|
|
|
90
90
|
var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
|
|
91
91
|
|
|
92
|
+
var _ActivityStreamHandler = require("../common/ActivityStreamHandler");
|
|
93
|
+
|
|
94
|
+
var _Constants = require("../../../common/Constants");
|
|
95
|
+
|
|
92
96
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
93
97
|
|
|
94
98
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -98,7 +102,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
98
102
|
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
103
|
|
|
100
104
|
const LiveChatWidgetStateful = props => {
|
|
101
|
-
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$
|
|
105
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps13, _props$controlProps14, _props$componentOverr, _props$controlProps15, _props$componentOverr2, _props$controlProps16, _props$componentOverr3, _props$controlProps17, _props$componentOverr4, _props$controlProps18, _props$componentOverr5, _props$controlProps19, _props$componentOverr6, _props$controlProps20, _props$componentOverr7, _props$controlProps21, _props$controlProps22, _props$componentOverr8, _props$controlProps23, _props$componentOverr9, _props$controlProps24, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
102
106
|
|
|
103
107
|
const [state, dispatch] = (0, _useChatContextStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
108
|
|
|
@@ -124,20 +128,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
124
128
|
let widgetStateEventName = "";
|
|
125
129
|
|
|
126
130
|
const initiateEndChatOnBrowserUnload = () => {
|
|
127
|
-
var
|
|
131
|
+
var _DataStoreManager$cli;
|
|
128
132
|
|
|
129
133
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
130
134
|
Event: _TelemetryConstants.TelemetryEvent.BrowserUnloadEventStarted,
|
|
131
135
|
Description: "Browser unload event received."
|
|
132
136
|
});
|
|
133
137
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
137
|
-
//Browser close scenario/no room for PCS/so just end chat and notify agent immidiately
|
|
138
|
-
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
139
|
-
} // Clean local storage
|
|
140
|
-
|
|
138
|
+
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false); // Clean local storage
|
|
141
139
|
|
|
142
140
|
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage"); //Dispose calling instance
|
|
143
141
|
|
|
@@ -152,8 +150,9 @@ const LiveChatWidgetStateful = props => {
|
|
|
152
150
|
};
|
|
153
151
|
|
|
154
152
|
(0, _react2.useEffect)(() => {
|
|
155
|
-
var _props$controlProps2, _props$controlProps3, _props$chatConfig, _props$chatConfig$Cha, _props$
|
|
153
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$controlProps2, _props$controlProps3, _props$controlProps4, _props$controlProps6, _props$chatConfig, _props$chatConfig$Cha, _props$controlProps7, _props$reconnectChatP, _props$chatConfig2, _props$chatConfig2$Li;
|
|
156
154
|
|
|
155
|
+
(0, _omnichannelChatComponents.BroadcastServiceInitialize)((_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.widgetId);
|
|
157
156
|
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
158
157
|
(0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
|
|
159
158
|
_DataStoreManager.DataStoreManager.clientDataStore = props.contextDataStore ?? undefined;
|
|
@@ -169,6 +168,16 @@ const LiveChatWidgetStateful = props => {
|
|
|
169
168
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
170
169
|
payload: false
|
|
171
170
|
});
|
|
171
|
+
|
|
172
|
+
if ((_props$controlProps3 = props.controlProps) !== null && _props$controlProps3 !== void 0 && _props$controlProps3.widgetInstanceId && !(0, _utils.isNullOrEmptyString)((_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.widgetInstanceId)) {
|
|
173
|
+
var _props$controlProps5;
|
|
174
|
+
|
|
175
|
+
dispatch({
|
|
176
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
|
|
177
|
+
payload: (_props$controlProps5 = props.controlProps) === null || _props$controlProps5 === void 0 ? void 0 : _props$controlProps5.widgetInstanceId
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
172
181
|
(0, _initCallingSdk.initCallingSdk)(chatSDK, setVoiceVideoCallingSDK).then(sdkCreated => {
|
|
173
182
|
sdkCreated && dispatch({
|
|
174
183
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
@@ -176,16 +185,16 @@ const LiveChatWidgetStateful = props => {
|
|
|
176
185
|
});
|
|
177
186
|
}); // Initialize global dir
|
|
178
187
|
|
|
179
|
-
const globalDir = ((_props$
|
|
188
|
+
const globalDir = ((_props$controlProps6 = props.controlProps) === null || _props$controlProps6 === void 0 ? void 0 : _props$controlProps6.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
189
|
dispatch({
|
|
181
190
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
182
191
|
payload: globalDir
|
|
183
192
|
});
|
|
184
193
|
|
|
185
|
-
if (!((_props$
|
|
194
|
+
if (!((_props$controlProps7 = props.controlProps) !== null && _props$controlProps7 !== void 0 && _props$controlProps7.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
186
195
|
var _props$reconnectChatP2;
|
|
187
196
|
|
|
188
|
-
(0, _reconnectChatHelper.startUnauthenticatedReconnectChat)(chatSDK, props.
|
|
197
|
+
(0, _reconnectChatHelper.startUnauthenticatedReconnectChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, _startChat.initStartChat);
|
|
189
198
|
return;
|
|
190
199
|
} // Check if auth settings enabled, do not connect to existing chat from cache during refresh/re-load
|
|
191
200
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -193,7 +202,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
193
202
|
|
|
194
203
|
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;
|
|
195
204
|
|
|
196
|
-
if (
|
|
205
|
+
if (isAuthenticationSettingsEnabled === false) {
|
|
197
206
|
var _state$domainStates;
|
|
198
207
|
|
|
199
208
|
if (!(0, _utils.isUndefinedOrEmpty)((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
@@ -202,7 +211,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
202
211
|
const optionalParams = {
|
|
203
212
|
liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
204
213
|
};
|
|
205
|
-
(0, _startChat.initStartChat)(chatSDK, props.
|
|
214
|
+
(0, _startChat.initStartChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
|
|
206
215
|
return;
|
|
207
216
|
}
|
|
208
217
|
} // All other case should show start chat button, skipChatButtonRendering will take care of it own
|
|
@@ -225,7 +234,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
225
234
|
if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
|
|
226
235
|
var _props$reconnectChatP4, _props$reconnectChatP5;
|
|
227
236
|
|
|
228
|
-
(0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(chatSDK, props.
|
|
237
|
+
(0, _reconnectChatHelper.handleUnauthenticatedReconnectChat)(chatSDK, props.chatConfig, props.getAuthToken, 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);
|
|
229
238
|
} else {
|
|
230
239
|
(0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK).then(authReconnectId => {
|
|
231
240
|
if (authReconnectId && !state.appStates.reconnectId) {
|
|
@@ -244,7 +253,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
244
253
|
|
|
245
254
|
_omnichannelChatComponents.BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
246
255
|
|
|
247
|
-
(0, _startChat.setPreChatAndInitiateChat)(chatSDK, props.
|
|
256
|
+
(0, _startChat.setPreChatAndInitiateChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter);
|
|
248
257
|
}
|
|
249
258
|
});
|
|
250
259
|
}
|
|
@@ -252,7 +261,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
252
261
|
}, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
|
|
253
262
|
|
|
254
263
|
(0, _react2.useEffect)(() => {
|
|
255
|
-
var _chatSDK$
|
|
264
|
+
var _chatSDK$omnichannelC5, _chatSDK$omnichannelC6, _props$controlProps10;
|
|
256
265
|
|
|
257
266
|
// Add the custom context on receiving the SetCustomContext event
|
|
258
267
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
@@ -287,26 +296,39 @@ const LiveChatWidgetStateful = props => {
|
|
|
287
296
|
|
|
288
297
|
|
|
289
298
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
290
|
-
var _chatSDK$
|
|
299
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps8;
|
|
291
300
|
|
|
292
301
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
293
302
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
294
303
|
Description: "Start chat event received."
|
|
295
304
|
});
|
|
296
305
|
|
|
297
|
-
const persistedState = (0, _utils.getStateFromCache)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
306
|
+
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, (props === null || props === void 0 ? void 0 : (_props$controlProps8 = props.controlProps) === null || _props$controlProps8 === void 0 ? void 0 : _props$controlProps8.widgetInstanceId) ?? ""); // Chat not found in cache
|
|
298
307
|
|
|
299
|
-
if (persistedState
|
|
300
|
-
// Embedded mode
|
|
308
|
+
if (persistedState === undefined) {
|
|
301
309
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
302
310
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
303
311
|
});
|
|
304
312
|
|
|
305
313
|
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
306
|
-
|
|
314
|
+
return;
|
|
315
|
+
} // Chat exist in cache
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
if (persistedState) {
|
|
307
319
|
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
308
320
|
|
|
309
|
-
//
|
|
321
|
+
// Only initiate new chat if widget state in cache in one of the followings
|
|
322
|
+
if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat) {
|
|
323
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
324
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
328
|
+
return;
|
|
329
|
+
} // If minimized, maximize the chat
|
|
330
|
+
|
|
331
|
+
|
|
310
332
|
dispatch({
|
|
311
333
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
312
334
|
payload: false
|
|
@@ -325,10 +347,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
325
347
|
|
|
326
348
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
327
349
|
if (state.appStates.skipChatButtonRendering !== true) {
|
|
328
|
-
var _chatSDK$
|
|
350
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4, _props$controlProps9;
|
|
329
351
|
|
|
330
352
|
// 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$
|
|
353
|
+
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, (props === null || props === void 0 ? void 0 : (_props$controlProps9 = props.controlProps) === null || _props$controlProps9 === void 0 ? void 0 : _props$controlProps9.widgetInstanceId) ?? "");
|
|
332
354
|
|
|
333
355
|
if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
334
356
|
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
@@ -350,10 +372,11 @@ const LiveChatWidgetStateful = props => {
|
|
|
350
372
|
}); // Listen to end chat event from other tabs
|
|
351
373
|
|
|
352
374
|
|
|
353
|
-
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
375
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(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, ((_props$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? "");
|
|
354
376
|
|
|
355
377
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
356
378
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
379
|
+
return;
|
|
357
380
|
}); // When conversation ended by agent
|
|
358
381
|
|
|
359
382
|
|
|
@@ -395,6 +418,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
395
418
|
}, [state.appStates.conversationState, state.appStates.proactiveChatStates.proactiveChatInNewWindow]); // Reset the UnreadMessageCount when minimized is toggled and broadcast it.
|
|
396
419
|
|
|
397
420
|
(0, _react2.useEffect)(() => {
|
|
421
|
+
if (state.appStates.isMinimized) {
|
|
422
|
+
_ActivityStreamHandler.ActivityStreamHandler.cork();
|
|
423
|
+
} else {
|
|
424
|
+
setTimeout(() => _ActivityStreamHandler.ActivityStreamHandler.uncork(), 500);
|
|
425
|
+
}
|
|
426
|
+
|
|
398
427
|
currentMessageCountRef.current = -1;
|
|
399
428
|
dispatch({
|
|
400
429
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
@@ -429,9 +458,24 @@ const LiveChatWidgetStateful = props => {
|
|
|
429
458
|
}, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]); // Publish chat widget state
|
|
430
459
|
|
|
431
460
|
(0, _react2.useEffect)(() => {
|
|
432
|
-
var _props$
|
|
461
|
+
var _props$controlProps11, _props$chatSDK2, _props$chatSDK2$omnic, _props$chatSDK3, _props$chatSDK3$omnic, _props$controlProps12;
|
|
433
462
|
|
|
434
|
-
|
|
463
|
+
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
464
|
+
// Ghost chat scenarios
|
|
465
|
+
if (state.appStates.conversationState === _ConversationState.ConversationState.Active && ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.skipChatButtonRendering) === true) {
|
|
466
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
467
|
+
window.onbeforeunload = function () {
|
|
468
|
+
const prompt = _Constants.Constants.BrowserUnloadConfirmationMessage;
|
|
469
|
+
return prompt;
|
|
470
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
window.onunload = function () {
|
|
474
|
+
initiateEndChatOnBrowserUnload();
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
widgetStateEventName = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK3 = props.chatSDK) === null || _props$chatSDK3 === void 0 ? void 0 : (_props$chatSDK3$omnic = _props$chatSDK3.omnichannelConfig) === null || _props$chatSDK3$omnic === void 0 ? void 0 : _props$chatSDK3$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "");
|
|
435
479
|
const chatWidgetStateChangeEvent = {
|
|
436
480
|
eventName: widgetStateEventName,
|
|
437
481
|
payload: { ...state
|
|
@@ -439,13 +483,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
439
483
|
};
|
|
440
484
|
|
|
441
485
|
_omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
442
|
-
}, [state]);
|
|
486
|
+
}, [state.appStates.conversationState]);
|
|
443
487
|
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, state, dispatch, setWebChatStyles);
|
|
444
488
|
|
|
445
489
|
const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
446
490
|
|
|
447
491
|
|
|
448
|
-
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat) => (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
492
|
+
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
449
493
|
|
|
450
494
|
|
|
451
495
|
const prepareEndChatRelay = (adapter, state) => (0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
@@ -453,7 +497,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
453
497
|
const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
454
498
|
|
|
455
499
|
|
|
456
|
-
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, props.
|
|
500
|
+
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams, persistedState);
|
|
457
501
|
|
|
458
502
|
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
459
503
|
return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
@@ -463,29 +507,29 @@ const LiveChatWidgetStateful = props => {
|
|
|
463
507
|
id: widgetElementId,
|
|
464
508
|
styles: generalStyles,
|
|
465
509
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
466
|
-
}, !((_props$
|
|
510
|
+
}, !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideChatButton) && !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.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, {
|
|
467
511
|
buttonProps: props.chatButtonProps,
|
|
468
512
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
469
513
|
startChat: prepareStartChatRelay
|
|
470
|
-
})), !((_props$
|
|
514
|
+
})), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.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, {
|
|
471
515
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
472
516
|
startChat: prepareStartChatRelay
|
|
473
|
-
})), !((_props$
|
|
517
|
+
})), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.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, {
|
|
474
518
|
headerProps: props.headerProps,
|
|
475
519
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
476
520
|
endChat: endChatRelay
|
|
477
|
-
})), !((_props$
|
|
521
|
+
})), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.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$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.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$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.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, {
|
|
478
522
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
479
523
|
initStartChat: initStartChatRelay
|
|
480
|
-
})), !((_props$
|
|
524
|
+
})), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.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, {
|
|
481
525
|
surveyProps: props.preChatSurveyPaneProps,
|
|
482
526
|
initStartChat: initStartChatRelay
|
|
483
|
-
})), !((_props$
|
|
527
|
+
})), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
484
528
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
485
|
-
}, props.callingContainerProps)), !((_props$
|
|
529
|
+
}, props.callingContainerProps)), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.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$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.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, {
|
|
486
530
|
setPostChatContext: setPostChatContextRelay,
|
|
487
531
|
prepareEndChat: prepareEndChatRelay
|
|
488
|
-
}))), !((_props$
|
|
532
|
+
}))), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.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))));
|
|
489
533
|
};
|
|
490
534
|
|
|
491
535
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
@@ -93,7 +93,7 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
93
93
|
try {
|
|
94
94
|
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _persistedState$domai, _persistedState$appSt;
|
|
95
95
|
|
|
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) ?? "");
|
|
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) ?? "", state.domainStates.widgetInstanceId ?? "");
|
|
97
97
|
let optionalParams = {}; //Connect to Active chats and chat is not popout
|
|
98
98
|
|
|
99
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) {
|
|
@@ -41,4 +41,5 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
41
41
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
|
|
42
42
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 31] = "SET_BOT_OAUTH_SIGNIN_ID";
|
|
43
43
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 32] = "SET_WIDGET_SIZE";
|
|
44
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 33] = "SET_WIDGET_INSTANCE_ID";
|
|
44
45
|
})(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
|
|
@@ -29,7 +29,8 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
29
29
|
globalDir: "ltr",
|
|
30
30
|
liveChatContext: undefined,
|
|
31
31
|
customContext: undefined,
|
|
32
|
-
widgetSize: undefined
|
|
32
|
+
widgetSize: undefined,
|
|
33
|
+
widgetInstanceId: ""
|
|
33
34
|
},
|
|
34
35
|
appStates: {
|
|
35
36
|
conversationState: _ConversationState.ConversationState.Closed,
|
|
@@ -243,6 +243,14 @@ const createReducer = () => {
|
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
|
|
246
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID:
|
|
247
|
+
return { ...state,
|
|
248
|
+
domainStates: { ...state.domainStates,
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
250
|
+
widgetInstanceId: action.payload
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
246
254
|
default:
|
|
247
255
|
return state;
|
|
248
256
|
}
|
|
@@ -160,6 +160,8 @@ _defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChang
|
|
|
160
160
|
|
|
161
161
|
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
162
162
|
|
|
163
|
+
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
164
|
+
|
|
163
165
|
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);
|
|
164
166
|
export class HtmlIdNames {}
|
|
165
167
|
|
|
@@ -131,6 +131,8 @@ export let TelemetryEvent;
|
|
|
131
131
|
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
132
132
|
TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
|
|
133
133
|
TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
|
|
134
|
+
TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
|
|
135
|
+
TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
|
|
134
136
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
135
137
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
136
138
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -2,6 +2,7 @@ import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants"
|
|
|
2
2
|
import { DataStoreManager } from "./contextDataStore/DataStoreManager";
|
|
3
3
|
import { KeyCodes } from "./KeyCodes";
|
|
4
4
|
import { BroadcastEvent } from "./telemetry/TelemetryConstants";
|
|
5
|
+
import { Md5 } from "md5-typescript";
|
|
5
6
|
|
|
6
7
|
const getElementBySelector = selector => {
|
|
7
8
|
let element;
|
|
@@ -290,20 +291,25 @@ export const getDomain = hostValue => {
|
|
|
290
291
|
|
|
291
292
|
return AriaTelemetryConstants.Public;
|
|
292
293
|
};
|
|
293
|
-
export const getWidgetCacheId = (orgId, widgetId) => {
|
|
294
|
-
|
|
294
|
+
export const getWidgetCacheId = (orgId, widgetId, widgetInstanceId) => {
|
|
295
|
+
const widgetCacheId = `${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
296
|
+
return Md5.init(widgetCacheId);
|
|
295
297
|
};
|
|
296
|
-
export const getWidgetEndChatEventName = (orgId, widgetId) => {
|
|
298
|
+
export const getWidgetEndChatEventName = (orgId, widgetId, widgetInstanceId) => {
|
|
299
|
+
if (!isNullOrEmptyString(widgetInstanceId)) {
|
|
300
|
+
return `${BroadcastEvent.ChatEnded}_${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
301
|
+
}
|
|
302
|
+
|
|
297
303
|
return `${BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
|
|
298
304
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
299
305
|
|
|
300
|
-
export const getStateFromCache = (orgId, widgetId) => {
|
|
306
|
+
export const getStateFromCache = (orgId, widgetId, widgetInstanceId) => {
|
|
301
307
|
// Getting updated state from cache
|
|
302
308
|
try {
|
|
303
309
|
if (DataStoreManager.clientDataStore) {
|
|
304
310
|
var _DataStoreManager$cli;
|
|
305
311
|
|
|
306
|
-
const widgetStateEventName = getWidgetCacheId(orgId, widgetId);
|
|
312
|
+
const widgetStateEventName = getWidgetCacheId(orgId, widgetId, widgetInstanceId);
|
|
307
313
|
const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
308
314
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
309
315
|
return persistedState;
|
|
@@ -49,7 +49,8 @@ export const HeaderStateful = props => {
|
|
|
49
49
|
} else {
|
|
50
50
|
const skipEndChatSDK = true;
|
|
51
51
|
const skipCloseChat = false;
|
|
52
|
-
|
|
52
|
+
const postMessageToOtherTabs = true;
|
|
53
|
+
await endChat(adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTabs);
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
dispatch({
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
import { Deferred } from "./Deferred";
|
|
4
|
+
export class ActivityStreamHandler {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Use of a deferred pattern, to hold the execution of the activity.
|
|
10
|
+
*
|
|
11
|
+
* */
|
|
12
|
+
static cork() {
|
|
13
|
+
ActivityStreamHandler.restoreDeferred = new Deferred();
|
|
14
|
+
ActivityStreamHandler.restorePromise = ActivityStreamHandler.restoreDeferred.promise;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the promise, releasing it to continue with the execution of the activity.
|
|
18
|
+
*
|
|
19
|
+
* */
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
static uncork() {
|
|
23
|
+
ActivityStreamHandler.restoreDeferred.resolve();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_defineProperty(ActivityStreamHandler, "restoreDeferred", {
|
|
29
|
+
resolve: () => {
|
|
30
|
+
return "initialState";
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
_defineProperty(ActivityStreamHandler, "restorePromise", void 0);
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
import { ActivityStreamHandler } from "../ActivityStreamHandler";
|
|
4
|
+
export class PauseActivitySubscriber {
|
|
5
|
+
constructor() {
|
|
6
|
+
_defineProperty(this, "observer", void 0);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
async apply(activity) {
|
|
11
|
+
await ActivityStreamHandler.restorePromise;
|
|
12
|
+
return activity;
|
|
13
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
applicable(activity) {
|
|
17
|
+
return true;
|
|
18
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
async next(activity) {
|
|
22
|
+
if (this.applicable(activity)) {
|
|
23
|
+
return await this.apply(activity);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return activity;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 Deferred {
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
constructor() {
|
|
6
|
+
_defineProperty(this, "_promise", void 0);
|
|
7
|
+
|
|
8
|
+
_defineProperty(this, "_resolve", void 0);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "_reject", () => {
|
|
11
|
+
return;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
_defineProperty(this, "resolve", value => {
|
|
15
|
+
this._resolve(value);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "reject", value => {
|
|
19
|
+
this._reject(value);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
this._promise = new Promise((resolve, reject) => {
|
|
23
|
+
this._resolve = resolve;
|
|
24
|
+
this._reject = reject;
|
|
25
|
+
});
|
|
26
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
get promise() {
|
|
30
|
+
return this._promise;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
@@ -2,7 +2,8 @@ import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontr
|
|
|
2
2
|
import { NotificationLevel } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationLevel";
|
|
3
3
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
4
4
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
5
|
-
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
5
|
+
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
6
|
+
import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
7
|
|
|
7
8
|
export const createAdapter = async chatSDK => {
|
|
8
9
|
const chatAdapterOptionalParams = {
|
|
@@ -28,6 +29,8 @@ export const createAdapter = async chatSDK => {
|
|
|
28
29
|
|
|
29
30
|
if (chatSDK.isMockModeOn !== true) {
|
|
30
31
|
adapter = new ChatAdapterShim(adapter);
|
|
32
|
+
adapter.addSubscriber(new PauseActivitySubscriber());
|
|
33
|
+
return adapter.chatAdapter;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
return adapter;
|
|
@@ -1683,9 +1683,6 @@ export const dummyDefaultProps = {
|
|
|
1683
1683
|
fwdUrl: ""
|
|
1684
1684
|
}
|
|
1685
1685
|
},
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
setAuthTokenProviderToChatSdk: undefined
|
|
1689
|
-
},
|
|
1690
|
-
telemetryConfig: undefined
|
|
1686
|
+
telemetryConfig: undefined,
|
|
1687
|
+
getAuthToken: undefined
|
|
1691
1688
|
};
|
|
@@ -31,7 +31,7 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
31
31
|
if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === Constants.truePascal) {
|
|
32
32
|
const skipEndChatSDK = false;
|
|
33
33
|
const skipCloseChat = true;
|
|
34
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat,
|
|
34
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, false);
|
|
35
35
|
|
|
36
36
|
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
37
37
|
dispatch({
|
|
@@ -129,9 +129,9 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
if (postMessageToOtherTab) {
|
|
132
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
|
|
132
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps;
|
|
133
133
|
|
|
134
|
-
const endChatEventName = getWidgetEndChatEventName(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);
|
|
134
|
+
const endChatEventName = getWidgetEndChatEventName(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, (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
135
135
|
BroadcastService.postMessage({
|
|
136
136
|
eventName: endChatEventName
|
|
137
137
|
});
|