@microsoft/omnichannel-chat-widget 1.6.2-main.c7d45e8 → 1.6.3-main.0e66ed8
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/telemetry/TelemetryConstants.js +1 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +9 -10
- package/lib/cjs/common/utils.js +15 -6
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +29 -24
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +12 -6
- package/lib/cjs/components/livechatwidget/common/authHelper.js +4 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +9 -30
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +16 -6
- package/lib/cjs/components/livechatwidget/common/startChat.js +35 -19
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +5 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +53 -53
- package/lib/cjs/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +4 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +10 -0
- package/lib/cjs/contexts/createReducer.js +653 -345
- package/lib/esm/common/telemetry/TelemetryConstants.js +1 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +9 -10
- package/lib/esm/common/utils.js +12 -4
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +30 -25
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +12 -6
- package/lib/esm/components/livechatwidget/common/authHelper.js +4 -1
- package/lib/esm/components/livechatwidget/common/endChat.js +10 -31
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +17 -7
- package/lib/esm/components/livechatwidget/common/startChat.js +35 -19
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +5 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +53 -53
- package/lib/esm/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +4 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +10 -0
- package/lib/esm/contexts/createReducer.js +650 -343
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -1
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +3 -0
- package/lib/types/common/utils.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +3 -2
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/lib/types/contexts/createReducer.d.ts +1 -0
- package/package.json +6 -4
|
@@ -57,6 +57,7 @@ var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDK
|
|
|
57
57
|
var _defaultAdaptiveCardStyles = require("../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles");
|
|
58
58
|
var _StartChatErrorPaneStateful = _interopRequireDefault(require("../../startchaterrorpanestateful/StartChatErrorPaneStateful"));
|
|
59
59
|
var _StartChatFailureType = require("../../../contexts/common/StartChatFailureType");
|
|
60
|
+
var _createReducer = require("../../../contexts/createReducer");
|
|
60
61
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
61
62
|
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); }
|
|
62
63
|
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; }
|
|
@@ -125,8 +126,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
125
126
|
const isReconnectTriggered = async () => {
|
|
126
127
|
if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true && !(0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
|
|
127
128
|
const noValidReconnectId = await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, _startChat.initStartChat, state);
|
|
129
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
130
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
131
|
+
payload: null
|
|
132
|
+
});
|
|
128
133
|
// If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
|
|
129
|
-
if (!noValidReconnectId && (
|
|
134
|
+
if (!noValidReconnectId && (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Active || inMemoryState.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat)) {
|
|
130
135
|
return true;
|
|
131
136
|
}
|
|
132
137
|
}
|
|
@@ -139,9 +144,6 @@ const LiveChatWidgetStateful = props => {
|
|
|
139
144
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
140
145
|
payload: _ConversationState.ConversationState.Loading
|
|
141
146
|
});
|
|
142
|
-
if (localState) {
|
|
143
|
-
localState.appStates.conversationState = _ConversationState.ConversationState.Loading;
|
|
144
|
-
}
|
|
145
147
|
|
|
146
148
|
//Check if conversation state is not in wrapup or closed state
|
|
147
149
|
isChatValid = await (0, _startChat.checkIfConversationStillValid)(chatSDK, dispatch, state);
|
|
@@ -158,7 +160,11 @@ const LiveChatWidgetStateful = props => {
|
|
|
158
160
|
// adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
|
|
159
161
|
const reconnectTriggered = await isReconnectTriggered();
|
|
160
162
|
if (!reconnectTriggered) {
|
|
161
|
-
|
|
163
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
164
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
165
|
+
payload: null
|
|
166
|
+
});
|
|
167
|
+
await (0, _startChat.setPreChatAndInitiateChat)(chatSDK, dispatch, setAdapter, undefined, undefined, inMemoryState, props);
|
|
162
168
|
}
|
|
163
169
|
return;
|
|
164
170
|
} else {
|
|
@@ -338,76 +344,70 @@ const LiveChatWidgetStateful = props => {
|
|
|
338
344
|
}
|
|
339
345
|
});
|
|
340
346
|
|
|
347
|
+
/**
|
|
348
|
+
* This will allow to sync multiple tabs to handle minimize and maximize state,
|
|
349
|
+
* the event is expected to be emitted from scripting layer.
|
|
350
|
+
*/
|
|
351
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SyncMinimize).subscribe(msg => {
|
|
352
|
+
var _msg$payload4;
|
|
353
|
+
dispatch({
|
|
354
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
355
|
+
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.minimized
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
|
|
341
359
|
// Start chat from SDK Event
|
|
342
360
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
|
|
343
|
-
var _msg$
|
|
361
|
+
var _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
344
362
|
// If the startChat event is not initiated by the same tab. Ignore the call
|
|
345
|
-
if (!(0, _utils.isNullOrUndefined)(msg === null || msg === void 0 ? void 0 : (_msg$
|
|
363
|
+
if (!(0, _utils.isNullOrUndefined)(msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload6 = msg.payload) === null || _msg$payload6 === void 0 ? void 0 : _msg$payload6.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
346
364
|
return;
|
|
347
365
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
var _msg$payload7, _msg$payload8;
|
|
366
|
+
if (msg !== null && msg !== void 0 && (_msg$payload7 = msg.payload) !== null && _msg$payload7 !== void 0 && _msg$payload7.customContext) {
|
|
367
|
+
var _msg$payload8;
|
|
351
368
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
352
369
|
Event: _TelemetryConstants.TelemetryEvent.CustomContextReceived,
|
|
353
370
|
Description: "CustomContext received through startChat event."
|
|
354
371
|
});
|
|
355
372
|
dispatch({
|
|
356
373
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
357
|
-
payload: msg === null || msg === void 0 ? void 0 : (_msg$
|
|
374
|
+
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
|
|
358
375
|
});
|
|
359
|
-
stateWithUpdatedContext = {
|
|
360
|
-
...state,
|
|
361
|
-
domainStates: {
|
|
362
|
-
...state.domainStates,
|
|
363
|
-
customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
376
|
}
|
|
367
377
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
368
378
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
369
379
|
Description: "Start chat event received."
|
|
370
380
|
});
|
|
381
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
382
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
383
|
+
payload: null
|
|
384
|
+
});
|
|
385
|
+
inMemoryState.domainStates.customContext = msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.customContext;
|
|
371
386
|
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
// Chat not found in cache - scenario: explicitly clearing cache and calling startChat SDK method
|
|
376
|
-
if (persistedState === undefined) {
|
|
387
|
+
// Only initiate new chat if widget runtime state is one of the followings
|
|
388
|
+
if (((_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) === _ConversationState.ConversationState.Closed || ((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === _ConversationState.ConversationState.InActive || ((_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.conversationState) === _ConversationState.ConversationState.Postchat) {
|
|
377
389
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
378
390
|
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
379
391
|
});
|
|
380
|
-
(0, _startChat.prepareStartChat)(props, chatSDK,
|
|
392
|
+
(0, _startChat.prepareStartChat)(props, chatSDK, inMemoryState, dispatch, setAdapter);
|
|
381
393
|
return;
|
|
382
394
|
}
|
|
383
395
|
|
|
384
|
-
//
|
|
385
|
-
if (
|
|
386
|
-
var
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
dispatch({
|
|
400
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
401
|
-
payload: false
|
|
402
|
-
});
|
|
403
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
404
|
-
eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
|
|
405
|
-
payload: {
|
|
406
|
-
height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
|
|
407
|
-
width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
}
|
|
396
|
+
// If minimized, maximize the chat
|
|
397
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.isMinimized) === true) {
|
|
398
|
+
var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
|
|
399
|
+
dispatch({
|
|
400
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
401
|
+
payload: false
|
|
402
|
+
});
|
|
403
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
404
|
+
eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
|
|
405
|
+
payload: {
|
|
406
|
+
height: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.widgetSize) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.height,
|
|
407
|
+
width: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.widgetSize) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.width
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
return;
|
|
411
411
|
}
|
|
412
412
|
});
|
|
413
413
|
|
|
@@ -456,8 +456,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
456
456
|
// Listen to end chat event from other tabs
|
|
457
457
|
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
458
458
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
459
|
-
var _msg$
|
|
460
|
-
if ((msg === null || msg === void 0 ? void 0 : (_msg$
|
|
459
|
+
var _msg$payload10;
|
|
460
|
+
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload10 = msg.payload) === null || _msg$payload10 === void 0 ? void 0 : _msg$payload10.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
461
461
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
462
462
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
463
463
|
Description: "Received EndChat BroadcastEvent from other tabs. Closing this chat."
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isMaskingforCustomer = void 0;
|
|
7
|
+
var _utils = require("../../../../common/utils");
|
|
7
8
|
const isMaskingforCustomer = maskingInfo => {
|
|
8
9
|
var _maskingInfo$setting;
|
|
9
10
|
// If the masking info (containing masking setting and masking rules) is missing or empty, return false.
|
|
@@ -14,8 +15,9 @@ const isMaskingforCustomer = maskingInfo => {
|
|
|
14
15
|
|
|
15
16
|
// If the masking rules are provided and;
|
|
16
17
|
// If the masking setting is NOT null and masking for customer is NOT null, return the configuration
|
|
17
|
-
if ((_maskingInfo$setting = maskingInfo.setting)
|
|
18
|
-
|
|
18
|
+
if (!(0, _utils.isNullOrUndefined)((_maskingInfo$setting = maskingInfo.setting) === null || _maskingInfo$setting === void 0 ? void 0 : _maskingInfo$setting.msdyn_maskforcustomer)) {
|
|
19
|
+
var _maskingInfo$setting2;
|
|
20
|
+
return (0, _utils.parseLowerCaseString)(maskingInfo === null || maskingInfo === void 0 ? void 0 : (_maskingInfo$setting2 = maskingInfo.setting) === null || _maskingInfo$setting2 === void 0 ? void 0 : _maskingInfo$setting2.msdyn_maskforcustomer) === "true";
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
// In all other cases, even if masking setting is missing, return true to apply the masking for backward compatibility (i.e. in old versions, OC does not have masking info settings)
|
|
@@ -52,4 +52,5 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
52
52
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 42] = "SET_SURVEY_MODE";
|
|
53
53
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 43] = "SET_CONFIRMATION_STATE";
|
|
54
54
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 44] = "SET_POST_CHAT_PARTICIPANT_TYPE";
|
|
55
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 45] = "GET_IN_MEMORY_STATE";
|
|
55
56
|
})(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
|
|
@@ -18,6 +18,16 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
18
18
|
const initialState = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)(cacheTtlInMins, storageType).getData(widgetCacheId);
|
|
19
19
|
if (!(0, _utils.isNullOrUndefined)(initialState)) {
|
|
20
20
|
const initialStateFromCache = JSON.parse(initialState);
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* this step is needed to avoid the pre-chat pane to be injected in the DOM when the widget is reloaded, because wont be visible
|
|
24
|
+
* and it will be blocking all elements behind it
|
|
25
|
+
* as part of the flow, the pre-chat will be detected and then it will be displayed properly
|
|
26
|
+
* this case is only and only for pre-chat pane.
|
|
27
|
+
* **/
|
|
28
|
+
if (initialStateFromCache.appStates.conversationState === _ConversationState.ConversationState.Prechat) {
|
|
29
|
+
initialStateFromCache.appStates.conversationState = _ConversationState.ConversationState.Closed;
|
|
30
|
+
}
|
|
21
31
|
return initialStateFromCache;
|
|
22
32
|
}
|
|
23
33
|
const LiveChatWidgetContextInitialState = {
|