@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
|
@@ -53,6 +53,7 @@ import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
|
53
53
|
import { defaultAdaptiveCardStyles } from "../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles";
|
|
54
54
|
import StartChatErrorPaneStateful from "../../startchaterrorpanestateful/StartChatErrorPaneStateful";
|
|
55
55
|
import { StartChatFailureType } from "../../../contexts/common/StartChatFailureType";
|
|
56
|
+
import { executeReducer } from "../../../contexts/createReducer";
|
|
56
57
|
export const LiveChatWidgetStateful = props => {
|
|
57
58
|
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
58
59
|
const [state, dispatch] = useChatContextStore();
|
|
@@ -117,8 +118,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
117
118
|
const isReconnectTriggered = async () => {
|
|
118
119
|
if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
|
|
119
120
|
const noValidReconnectId = await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
121
|
+
const inMemoryState = executeReducer(state, {
|
|
122
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
123
|
+
payload: null
|
|
124
|
+
});
|
|
120
125
|
// If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
|
|
121
|
-
if (!noValidReconnectId && (
|
|
126
|
+
if (!noValidReconnectId && (inMemoryState.appStates.conversationState === ConversationState.Active || inMemoryState.appStates.conversationState === ConversationState.ReconnectChat)) {
|
|
122
127
|
return true;
|
|
123
128
|
}
|
|
124
129
|
}
|
|
@@ -131,9 +136,6 @@ export const LiveChatWidgetStateful = props => {
|
|
|
131
136
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
132
137
|
payload: ConversationState.Loading
|
|
133
138
|
});
|
|
134
|
-
if (localState) {
|
|
135
|
-
localState.appStates.conversationState = ConversationState.Loading;
|
|
136
|
-
}
|
|
137
139
|
|
|
138
140
|
//Check if conversation state is not in wrapup or closed state
|
|
139
141
|
isChatValid = await checkIfConversationStillValid(chatSDK, dispatch, state);
|
|
@@ -150,7 +152,11 @@ export const LiveChatWidgetStateful = props => {
|
|
|
150
152
|
// adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
|
|
151
153
|
const reconnectTriggered = await isReconnectTriggered();
|
|
152
154
|
if (!reconnectTriggered) {
|
|
153
|
-
|
|
155
|
+
const inMemoryState = executeReducer(state, {
|
|
156
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
157
|
+
payload: null
|
|
158
|
+
});
|
|
159
|
+
await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, undefined, undefined, inMemoryState, props);
|
|
154
160
|
}
|
|
155
161
|
return;
|
|
156
162
|
} else {
|
|
@@ -330,76 +336,70 @@ export const LiveChatWidgetStateful = props => {
|
|
|
330
336
|
}
|
|
331
337
|
});
|
|
332
338
|
|
|
339
|
+
/**
|
|
340
|
+
* This will allow to sync multiple tabs to handle minimize and maximize state,
|
|
341
|
+
* the event is expected to be emitted from scripting layer.
|
|
342
|
+
*/
|
|
343
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.SyncMinimize).subscribe(msg => {
|
|
344
|
+
var _msg$payload4;
|
|
345
|
+
dispatch({
|
|
346
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
347
|
+
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.minimized
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
333
351
|
// Start chat from SDK Event
|
|
334
352
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
|
|
335
|
-
var _msg$
|
|
353
|
+
var _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
336
354
|
// If the startChat event is not initiated by the same tab. Ignore the call
|
|
337
|
-
if (!isNullOrUndefined(msg === null || msg === void 0 ? void 0 : (_msg$
|
|
355
|
+
if (!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.InternalTelemetryData.lcwRuntimeId) {
|
|
338
356
|
return;
|
|
339
357
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
var _msg$payload7, _msg$payload8;
|
|
358
|
+
if (msg !== null && msg !== void 0 && (_msg$payload7 = msg.payload) !== null && _msg$payload7 !== void 0 && _msg$payload7.customContext) {
|
|
359
|
+
var _msg$payload8;
|
|
343
360
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
344
361
|
Event: TelemetryEvent.CustomContextReceived,
|
|
345
362
|
Description: "CustomContext received through startChat event."
|
|
346
363
|
});
|
|
347
364
|
dispatch({
|
|
348
365
|
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
349
|
-
payload: msg === null || msg === void 0 ? void 0 : (_msg$
|
|
366
|
+
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
|
|
350
367
|
});
|
|
351
|
-
stateWithUpdatedContext = {
|
|
352
|
-
...state,
|
|
353
|
-
domainStates: {
|
|
354
|
-
...state.domainStates,
|
|
355
|
-
customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
368
|
}
|
|
359
369
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
360
370
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
361
371
|
Description: "Start chat event received."
|
|
362
372
|
});
|
|
373
|
+
const inMemoryState = executeReducer(state, {
|
|
374
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
375
|
+
payload: null
|
|
376
|
+
});
|
|
377
|
+
inMemoryState.domainStates.customContext = msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.customContext;
|
|
363
378
|
|
|
364
|
-
//
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
// Chat not found in cache - scenario: explicitly clearing cache and calling startChat SDK method
|
|
368
|
-
if (persistedState === undefined) {
|
|
379
|
+
// Only initiate new chat if widget runtime state is one of the followings
|
|
380
|
+
if (((_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) === ConversationState.Closed || ((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === ConversationState.InActive || ((_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.conversationState) === ConversationState.Postchat) {
|
|
369
381
|
BroadcastService.postMessage({
|
|
370
382
|
eventName: BroadcastEvent.ChatInitiated
|
|
371
383
|
});
|
|
372
|
-
prepareStartChat(props, chatSDK,
|
|
384
|
+
prepareStartChat(props, chatSDK, inMemoryState, dispatch, setAdapter);
|
|
373
385
|
return;
|
|
374
386
|
}
|
|
375
387
|
|
|
376
|
-
//
|
|
377
|
-
if (
|
|
378
|
-
var
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
dispatch({
|
|
392
|
-
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
393
|
-
payload: false
|
|
394
|
-
});
|
|
395
|
-
BroadcastService.postMessage({
|
|
396
|
-
eventName: BroadcastEvent.MaximizeChat,
|
|
397
|
-
payload: {
|
|
398
|
-
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,
|
|
399
|
-
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
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
}
|
|
388
|
+
// If minimized, maximize the chat
|
|
389
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.isMinimized) === true) {
|
|
390
|
+
var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
|
|
391
|
+
dispatch({
|
|
392
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
393
|
+
payload: false
|
|
394
|
+
});
|
|
395
|
+
BroadcastService.postMessage({
|
|
396
|
+
eventName: BroadcastEvent.MaximizeChat,
|
|
397
|
+
payload: {
|
|
398
|
+
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,
|
|
399
|
+
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
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
return;
|
|
403
403
|
}
|
|
404
404
|
});
|
|
405
405
|
|
|
@@ -448,8 +448,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
448
448
|
// Listen to end chat event from other tabs
|
|
449
449
|
const endChatEventName = 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) ?? "");
|
|
450
450
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
451
|
-
var _msg$
|
|
452
|
-
if ((msg === null || msg === void 0 ? void 0 : (_msg$
|
|
451
|
+
var _msg$payload10;
|
|
452
|
+
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload10 = msg.payload) === null || _msg$payload10 === void 0 ? void 0 : _msg$payload10.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
453
453
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
454
454
|
Event: TelemetryEvent.PrepareEndChat,
|
|
455
455
|
Description: "Received EndChat BroadcastEvent from other tabs. Closing this chat."
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNullOrUndefined, parseLowerCaseString } from "../../../../common/utils";
|
|
1
2
|
export const isMaskingforCustomer = maskingInfo => {
|
|
2
3
|
var _maskingInfo$setting;
|
|
3
4
|
// If the masking info (containing masking setting and masking rules) is missing or empty, return false.
|
|
@@ -8,8 +9,9 @@ export const isMaskingforCustomer = maskingInfo => {
|
|
|
8
9
|
|
|
9
10
|
// If the masking rules are provided and;
|
|
10
11
|
// If the masking setting is NOT null and masking for customer is NOT null, return the configuration
|
|
11
|
-
if ((_maskingInfo$setting = maskingInfo.setting)
|
|
12
|
-
|
|
12
|
+
if (!isNullOrUndefined((_maskingInfo$setting = maskingInfo.setting) === null || _maskingInfo$setting === void 0 ? void 0 : _maskingInfo$setting.msdyn_maskforcustomer)) {
|
|
13
|
+
var _maskingInfo$setting2;
|
|
14
|
+
return parseLowerCaseString(maskingInfo === null || maskingInfo === void 0 ? void 0 : (_maskingInfo$setting2 = maskingInfo.setting) === null || _maskingInfo$setting2 === void 0 ? void 0 : _maskingInfo$setting2.msdyn_maskforcustomer) === "true";
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
// 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)
|
|
@@ -45,4 +45,5 @@ export let LiveChatWidgetActionType;
|
|
|
45
45
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 42] = "SET_SURVEY_MODE";
|
|
46
46
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 43] = "SET_CONFIRMATION_STATE";
|
|
47
47
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 44] = "SET_POST_CHAT_PARTICIPANT_TYPE";
|
|
48
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 45] = "GET_IN_MEMORY_STATE";
|
|
48
49
|
})(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
|
|
@@ -12,6 +12,16 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
12
12
|
const initialState = defaultClientDataStoreProvider(cacheTtlInMins, storageType).getData(widgetCacheId);
|
|
13
13
|
if (!isNullOrUndefined(initialState)) {
|
|
14
14
|
const initialStateFromCache = JSON.parse(initialState);
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* 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
|
|
18
|
+
* and it will be blocking all elements behind it
|
|
19
|
+
* as part of the flow, the pre-chat will be detected and then it will be displayed properly
|
|
20
|
+
* this case is only and only for pre-chat pane.
|
|
21
|
+
* **/
|
|
22
|
+
if (initialStateFromCache.appStates.conversationState === ConversationState.Prechat) {
|
|
23
|
+
initialStateFromCache.appStates.conversationState = ConversationState.Closed;
|
|
24
|
+
}
|
|
15
25
|
return initialStateFromCache;
|
|
16
26
|
}
|
|
17
27
|
const LiveChatWidgetContextInitialState = {
|