@microsoft/omnichannel-chat-widget 1.8.4-main.4478bbf → 1.8.4-main.6672d3a
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/README.md +27 -0
- package/lib/cjs/common/Constants.js +2 -0
- package/lib/cjs/common/telemetry/AppInsightsEvents.js +11 -5
- package/lib/cjs/common/telemetry/TelemetryConstants.js +3 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +20 -1
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +26 -20
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +21 -9
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +9 -2
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +112 -26
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +9 -12
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +8 -2
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +30 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/common/telemetry/AppInsightsEvents.js +11 -5
- package/lib/esm/common/telemetry/TelemetryConstants.js +3 -0
- package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +20 -1
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +26 -20
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +21 -9
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +9 -2
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +112 -26
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +9 -15
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +8 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +30 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/types/common/Constants.d.ts +2 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +3 -0
- package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +5 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +1 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +5 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +1 -1
|
@@ -54,9 +54,10 @@ import { startProactiveChat } from "../common/startProactiveChat";
|
|
|
54
54
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
55
55
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
56
56
|
import useFacadeSDKStore from "../../../hooks/useFacadeChatSDKStore";
|
|
57
|
+
import { getPostChatContext, initiatePostChat } from "../common/renderSurveyHelpers";
|
|
57
58
|
let uiTimer;
|
|
58
59
|
export const LiveChatWidgetStateful = props => {
|
|
59
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$styleProps, _props$webChatContain10, _props$webChatContain11, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain15, _state$
|
|
60
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$styleProps, _props$webChatContain10, _props$webChatContain11, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain15, _state$appStates8, _props$webChatContain17, _props$webChatContain18, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _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;
|
|
60
61
|
useEffect(() => {
|
|
61
62
|
uiTimer = createTimer();
|
|
62
63
|
TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
|
|
@@ -317,7 +318,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
317
318
|
});
|
|
318
319
|
});
|
|
319
320
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartProactiveChat).subscribe(msg => {
|
|
320
|
-
TelemetryHelper.
|
|
321
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
321
322
|
Event: TelemetryEvent.StartProactiveChatEventReceived,
|
|
322
323
|
Description: "Start proactive chat event received."
|
|
323
324
|
});
|
|
@@ -443,7 +444,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
443
444
|
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
|
|
444
445
|
});
|
|
445
446
|
}
|
|
446
|
-
TelemetryHelper.
|
|
447
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
447
448
|
Event: TelemetryEvent.StartChatEventReceived,
|
|
448
449
|
Description: "Start chat event received."
|
|
449
450
|
});
|
|
@@ -490,21 +491,91 @@ export const LiveChatWidgetStateful = props => {
|
|
|
490
491
|
return;
|
|
491
492
|
}
|
|
492
493
|
});
|
|
494
|
+
const handleInitiateEndChatForPersistentChat = async (msg, conversationDetails) => {
|
|
495
|
+
var _msg$payload10, _msg$payload11, _msg$payload12;
|
|
496
|
+
//If the payload does NOT include the skipSessionCloseForPersistentChat flag, default is false. Upon receiving the customer event, always ending session from C2.
|
|
497
|
+
const skipSessionCloseForPersistentChat = typeof (msg === null || msg === void 0 ? void 0 : (_msg$payload10 = msg.payload) === null || _msg$payload10 === void 0 ? void 0 : _msg$payload10[Constants.SkipSessionCloseForPersistentChatFlag]) === Constants.String && (msg === null || msg === void 0 ? void 0 : (_msg$payload11 = msg.payload) === null || _msg$payload11 === void 0 ? void 0 : _msg$payload11[Constants.SkipSessionCloseForPersistentChatFlag]).toLowerCase() === Constants.true || (msg === null || msg === void 0 ? void 0 : (_msg$payload12 = msg.payload) === null || _msg$payload12 === void 0 ? void 0 : _msg$payload12[Constants.SkipSessionCloseForPersistentChatFlag]) === true;
|
|
498
|
+
TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
499
|
+
Event: TelemetryEvent.EndChatEventReceived,
|
|
500
|
+
Description: "Processing initiateEndChat for persistent chat",
|
|
501
|
+
CustomProperties: {
|
|
502
|
+
conversationDetails
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
const conversationState = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state;
|
|
506
|
+
if (conversationState !== LiveWorkItemState.Closed && conversationState !== LiveWorkItemState.WrapUp) {
|
|
507
|
+
if (skipSessionCloseForPersistentChat) {
|
|
508
|
+
var _conversationDetails$;
|
|
509
|
+
if (((_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === "true") {
|
|
510
|
+
var _state$domainStates3;
|
|
511
|
+
TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
512
|
+
Event: TelemetryEvent.EndChatEventReceived,
|
|
513
|
+
Description: "Processing initiateEndChat, fetching postChatContext"
|
|
514
|
+
});
|
|
515
|
+
const postchatContext = (await getPostChatContext(facadeChatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.postChatContext);
|
|
516
|
+
if (postchatContext) {
|
|
517
|
+
TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
518
|
+
Event: TelemetryEvent.EndChatEventReceived,
|
|
519
|
+
Description: "Processing initiateEndChat, initiatePostChat",
|
|
520
|
+
CustomProperties: {
|
|
521
|
+
postchatContext
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
await initiatePostChat(props, conversationDetails, state, dispatch, postchatContext);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
} else {
|
|
528
|
+
const skipEndChatSDK = false;
|
|
529
|
+
const skipCloseChat = false;
|
|
530
|
+
TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
531
|
+
Event: TelemetryEvent.EndChatEventReceived,
|
|
532
|
+
Description: "Processing initiateEndChat, trigger endChat"
|
|
533
|
+
});
|
|
534
|
+
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
//if conversation already closed, it is safe to unmount it upon receiving the closeChat event
|
|
538
|
+
else {
|
|
539
|
+
BroadcastService.postMessage({
|
|
540
|
+
eventName: BroadcastEvent.CloseChat
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
};
|
|
493
544
|
|
|
494
545
|
// End chat
|
|
495
|
-
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async
|
|
546
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async msg => {
|
|
496
547
|
TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
497
548
|
Event: TelemetryEvent.EndChatEventReceived,
|
|
498
549
|
Description: "Received InitiateEndChat BroadcastEvent.",
|
|
499
550
|
CustomProperties: {
|
|
500
|
-
ConversationStage: ConversationStage.ConversationEnd
|
|
551
|
+
ConversationStage: ConversationStage.ConversationEnd,
|
|
552
|
+
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
501
553
|
}
|
|
502
554
|
});
|
|
503
|
-
|
|
504
|
-
|
|
555
|
+
const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
|
|
556
|
+
const {
|
|
557
|
+
chatConfig
|
|
558
|
+
} = props;
|
|
559
|
+
const isPersistent = isPersistentEnabled(chatConfig);
|
|
560
|
+
TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
561
|
+
Event: TelemetryEvent.EndChatEventReceived,
|
|
562
|
+
Description: "Processing initiateEndChat, fetched conversation details",
|
|
563
|
+
CustomProperties: {
|
|
564
|
+
conversationDetails,
|
|
565
|
+
isPersistent
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
if (isPersistent && conversationDetails) {
|
|
569
|
+
await handleInitiateEndChatForPersistentChat(msg, conversationDetails);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
505
572
|
const persistedState = getStateFromCache(getWidgetCacheIdfromProps(props));
|
|
506
573
|
if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
|
|
507
|
-
|
|
574
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
575
|
+
Event: TelemetryEvent.PrepareEndChat,
|
|
576
|
+
Description: PrepareEndChatDescriptionConstants.InitiateEndChatReceivedActiveChat
|
|
577
|
+
});
|
|
578
|
+
//We need to simulate states for closing chat, in order to messup with close confirmation pane.
|
|
508
579
|
dispatch({
|
|
509
580
|
type: LiveChatWidgetActionType.SET_CONFIRMATION_STATE,
|
|
510
581
|
payload: ConfirmationState.Ok
|
|
@@ -524,11 +595,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
524
595
|
Event: TelemetryEvent.PrepareEndChat,
|
|
525
596
|
Description: PrepareEndChatDescriptionConstants.InitiateEndChatReceived
|
|
526
597
|
});
|
|
527
|
-
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
598
|
+
await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
528
599
|
}
|
|
529
|
-
BroadcastService.postMessage({
|
|
530
|
-
eventName: BroadcastEvent.CloseChat
|
|
531
|
-
});
|
|
532
600
|
});
|
|
533
601
|
|
|
534
602
|
// End chat on browser unload
|
|
@@ -539,8 +607,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
539
607
|
// Listen to end chat event from other tabs
|
|
540
608
|
const endChatEventName = getWidgetEndChatEventName((_facadeChatSDK$getCha3 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha3 === void 0 ? void 0 : (_facadeChatSDK$getCha4 = _facadeChatSDK$getCha3.omnichannelConfig) === null || _facadeChatSDK$getCha4 === void 0 ? void 0 : _facadeChatSDK$getCha4.orgId, (_facadeChatSDK$getCha5 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha5 === void 0 ? void 0 : (_facadeChatSDK$getCha6 = _facadeChatSDK$getCha5.omnichannelConfig) === null || _facadeChatSDK$getCha6 === void 0 ? void 0 : _facadeChatSDK$getCha6.widgetId, ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
541
609
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
542
|
-
var _msg$
|
|
543
|
-
if ((msg === null || msg === void 0 ? void 0 : (_msg$
|
|
610
|
+
var _msg$payload13;
|
|
611
|
+
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload13 = msg.payload) === null || _msg$payload13 === void 0 ? void 0 : _msg$payload13.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
544
612
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
545
613
|
Event: TelemetryEvent.PrepareEndChat,
|
|
546
614
|
Description: "Received EndChat BroadcastEvent from other tabs. Closing this chat."
|
|
@@ -582,8 +650,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
582
650
|
|
|
583
651
|
// Retrieve convId
|
|
584
652
|
BroadcastService.getMessageByEventName(BroadcastEvent.UpdateConversationDataForTelemetry).subscribe(msg => {
|
|
585
|
-
var _msg$
|
|
586
|
-
if ((_msg$
|
|
653
|
+
var _msg$payload14, _msg$payload14$liveWo;
|
|
654
|
+
if ((_msg$payload14 = msg.payload) !== null && _msg$payload14 !== void 0 && (_msg$payload14$liveWo = _msg$payload14.liveWorkItem) !== null && _msg$payload14$liveWo !== void 0 && _msg$payload14$liveWo.conversationId) {
|
|
587
655
|
setConversationId(msg.payload.liveWorkItem.conversationId);
|
|
588
656
|
}
|
|
589
657
|
});
|
|
@@ -701,14 +769,22 @@ export const LiveChatWidgetStateful = props => {
|
|
|
701
769
|
}
|
|
702
770
|
}, [state.domainStates.confirmationState]);
|
|
703
771
|
useEffect(() => {
|
|
704
|
-
var
|
|
772
|
+
var _inMemoryState$appSta7, _inMemoryState$appSta8, _inMemoryState$appSta9, _inMemoryState$appSta10, _inMemoryState$appSta11, _inMemoryState$appSta12, _inMemoryState$appSta13;
|
|
773
|
+
const inMemoryState = executeReducer(state, {
|
|
774
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
775
|
+
payload: null
|
|
776
|
+
});
|
|
705
777
|
// Do not process anything during initialization
|
|
706
|
-
if ((
|
|
778
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta7 = inMemoryState.appStates) === null || _inMemoryState$appSta7 === void 0 ? void 0 : _inMemoryState$appSta7.conversationEndedBy) === ConversationEndEntity.NotSet) {
|
|
779
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
780
|
+
Event: TelemetryEvent.PrepareEndChat,
|
|
781
|
+
Description: "conversationEndedBy is not set"
|
|
782
|
+
});
|
|
707
783
|
return;
|
|
708
784
|
}
|
|
709
785
|
|
|
710
786
|
// If start chat failed, and C2 is trying to close chat widget
|
|
711
|
-
if (
|
|
787
|
+
if (inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$appSta8 = inMemoryState.appStates) !== null && _inMemoryState$appSta8 !== void 0 && _inMemoryState$appSta8.startChatFailed || (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta9 = inMemoryState.appStates) === null || _inMemoryState$appSta9 === void 0 ? void 0 : _inMemoryState$appSta9.conversationState) === ConversationState.Postchat) {
|
|
712
788
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
713
789
|
Event: TelemetryEvent.PrepareEndChat,
|
|
714
790
|
Description: PrepareEndChatDescriptionConstants.CustomerCloseChatOnFailureOrPostChat
|
|
@@ -718,7 +794,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
718
794
|
}
|
|
719
795
|
|
|
720
796
|
// Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
|
|
721
|
-
if ((
|
|
797
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta10 = inMemoryState.appStates) === null || _inMemoryState$appSta10 === void 0 ? void 0 : _inMemoryState$appSta10.conversationState) === ConversationState.InActive) {
|
|
722
798
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
723
799
|
Event: TelemetryEvent.PrepareEndChat,
|
|
724
800
|
Description: PrepareEndChatDescriptionConstants.CustomerCloseInactiveChat
|
|
@@ -726,11 +802,11 @@ export const LiveChatWidgetStateful = props => {
|
|
|
726
802
|
endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
727
803
|
return;
|
|
728
804
|
}
|
|
729
|
-
const isConversationalSurveyEnabled =
|
|
805
|
+
const isConversationalSurveyEnabled = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta11 = inMemoryState.appStates) === null || _inMemoryState$appSta11 === void 0 ? void 0 : _inMemoryState$appSta11.isConversationalSurveyEnabled;
|
|
730
806
|
|
|
731
807
|
// In conversational survey, we need to check post chat survey logics before we set ConversationState to InActive
|
|
732
808
|
// Hence setting ConversationState to InActive will be done later in the post chat flows
|
|
733
|
-
if (!isConversationalSurveyEnabled && (
|
|
809
|
+
if (!isConversationalSurveyEnabled && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta12 = inMemoryState.appStates) === null || _inMemoryState$appSta12 === void 0 ? void 0 : _inMemoryState$appSta12.conversationEndedBy) === ConversationEndEntity.Agent || (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta13 = inMemoryState.appStates) === null || _inMemoryState$appSta13 === void 0 ? void 0 : _inMemoryState$appSta13.conversationEndedBy) === ConversationEndEntity.Bot) {
|
|
734
810
|
dispatch({
|
|
735
811
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
736
812
|
payload: ConversationState.InActive
|
|
@@ -738,8 +814,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
738
814
|
}
|
|
739
815
|
|
|
740
816
|
// All other cases
|
|
741
|
-
prepareEndChat(props, facadeChatSDK,
|
|
742
|
-
}, [state === null || state === void 0 ? void 0 : (_state$
|
|
817
|
+
prepareEndChat(props, facadeChatSDK, inMemoryState, dispatch, setAdapter, setWebChatStyles, adapter);
|
|
818
|
+
}, [state === null || state === void 0 ? void 0 : (_state$appStates8 = state.appStates) === null || _state$appStates8 === void 0 ? void 0 : _state$appStates8.conversationEndedBy]);
|
|
743
819
|
|
|
744
820
|
// Publish chat widget state
|
|
745
821
|
useEffect(() => {
|
|
@@ -771,13 +847,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
771
847
|
|
|
772
848
|
// Handle Chat disconnect cases
|
|
773
849
|
useEffect(() => {
|
|
774
|
-
var _inMemoryState$
|
|
850
|
+
var _inMemoryState$appSta14;
|
|
775
851
|
const inMemoryState = executeReducer(state, {
|
|
776
852
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
777
853
|
payload: null
|
|
778
854
|
});
|
|
779
855
|
handleChatDisconnect(props, inMemoryState, setWebChatStyles);
|
|
780
|
-
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
856
|
+
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta14 = inMemoryState.appStates) === null || _inMemoryState$appSta14 === void 0 ? void 0 : _inMemoryState$appSta14.chatDisconnectEventReceived;
|
|
781
857
|
if (chatDisconnectState && adapter) {
|
|
782
858
|
try {
|
|
783
859
|
adapter.end();
|
|
@@ -876,6 +952,16 @@ export const LiveChatWidgetStateful = props => {
|
|
|
876
952
|
bubbleTextColor
|
|
877
953
|
}), [webChatStyles, bubbleBackground, bubbleTextColor]);
|
|
878
954
|
|
|
955
|
+
// React to dynamic bot avatar initials updates from context
|
|
956
|
+
useEffect(() => {
|
|
957
|
+
if (state.domainStates.botAvatarInitials && state.domainStates.botAvatarInitials !== webChatStyles.botAvatarInitials) {
|
|
958
|
+
setWebChatStyles(styles => ({
|
|
959
|
+
...styles,
|
|
960
|
+
botAvatarInitials: state.domainStates.botAvatarInitials
|
|
961
|
+
}));
|
|
962
|
+
}
|
|
963
|
+
}, [state.domainStates.botAvatarInitials]);
|
|
964
|
+
|
|
879
965
|
// WebChat's Composer can only be rendered if a directLine object is defined
|
|
880
966
|
return directLine && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, `
|
|
881
967
|
#oc-lcw .webchat__basic-transcript__scrollable::-webkit-scrollbar {
|
|
@@ -103,7 +103,7 @@ export const PostChatSurveyPaneStateful = props => {
|
|
|
103
103
|
Event: TelemetryEvent.CustomerVoiceResponsePageLoaded
|
|
104
104
|
});
|
|
105
105
|
} else if (data === CustomerVoiceEvents.FormResponseSubmitted) {
|
|
106
|
-
TelemetryHelper.
|
|
106
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
107
107
|
Event: TelemetryEvent.CustomerVoiceFormResponseSubmitted,
|
|
108
108
|
Description: "Customer Voice form response submitted.",
|
|
109
109
|
CustomProperties: {
|
|
@@ -111,7 +111,7 @@ export const PostChatSurveyPaneStateful = props => {
|
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
} else if (data === CustomerVoiceEvents.FormResponseError) {
|
|
114
|
-
TelemetryHelper.
|
|
114
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
115
115
|
Event: TelemetryEvent.CustomerVoiceFormResponseError,
|
|
116
116
|
Description: "Customer Voice form response error.",
|
|
117
117
|
ExceptionDetails: {
|
|
@@ -25,9 +25,6 @@ import { isPersistentChatEnabled } from "../livechatwidget/common/liveChatConfig
|
|
|
25
25
|
import { useChatContextStore } from "../..";
|
|
26
26
|
import useFacadeSDKStore from "../../hooks/useFacadeChatSDKStore";
|
|
27
27
|
import usePersistentChatHistory from "./hooks/usePersistentChatHistory";
|
|
28
|
-
|
|
29
|
-
// Types for better type safety
|
|
30
|
-
|
|
31
28
|
let uiTimer;
|
|
32
29
|
const broadcastChannelMessageEvent = "message";
|
|
33
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -56,7 +53,7 @@ const createMagicCodeSuccessResponse = signin => {
|
|
|
56
53
|
};
|
|
57
54
|
};
|
|
58
55
|
export const WebChatContainerStateful = props => {
|
|
59
|
-
var _props$webChatContain, _defaultWebChatContai, _extendedChatConfig$L,
|
|
56
|
+
var _props$webChatContain, _defaultWebChatContai, _extendedChatConfig$L, _extendedChatConfig$L2, _extendedChatConfig$L3, _extendedChatConfig$L4, _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _webChatContainerProp8, _props$webChatContain6, _props$webChatContain7, _defaultWebChatContai2, _props$webChatContain8, _props$webChatContain9, _defaultWebChatContai3, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _webChatContainerProp16, _webChatContainerProp17, _webChatContainerProp18, _webChatContainerProp19, _webChatContainerProp20, _webChatContainerProp21, _webChatContainerProp22, _webChatContainerProp23, _props$webChatContain10, _props$webChatContain11, _webChatContainerProp24, _webChatContainerProp25, _webChatContainerProp26, _webChatContainerProp27, _props$citationPanePr, _props$citationPanePr2, _props$citationPanePr3, _props$citationPanePr4, _props$citationPanePr5;
|
|
60
57
|
const [facadeChatSDK] = useFacadeSDKStore();
|
|
61
58
|
|
|
62
59
|
// Create a font family that includes emoji support, based on the primary font or default
|
|
@@ -90,17 +87,16 @@ export const WebChatContainerStateful = props => {
|
|
|
90
87
|
|
|
91
88
|
// Type the chatConfig properly to avoid 'any' usage
|
|
92
89
|
const extendedChatConfig = props.chatConfig;
|
|
93
|
-
const isHistoryEnabledInConfig = extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L = extendedChatConfig.
|
|
94
|
-
const
|
|
95
|
-
const isPersistentChatEnabledForWidget = !!(extendedChatConfig !== null && extendedChatConfig !== void 0 && (_extendedChatConfig$
|
|
96
|
-
|
|
97
|
-
// Persistent chat history is enabled if explicitly set via props, or if enabled in config
|
|
98
|
-
// Props take precedence over config settings
|
|
99
|
-
const isPersistentHistoryEnabled = isHistoryEnabledViaProps || isHistoryEnabledInConfig;
|
|
90
|
+
const isHistoryEnabledInConfig = extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L === void 0 ? void 0 : _extendedChatConfig$L.msdyn_enablepersistentchatpreviousconversations;
|
|
91
|
+
const isHistoryEnabledViaFCB = extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L2 = extendedChatConfig.LcwFcbConfiguration) === null || _extendedChatConfig$L2 === void 0 ? void 0 : _extendedChatConfig$L2.lcwPersistentChatHistoryEnabled;
|
|
92
|
+
const isPersistentChatEnabledForWidget = !!(extendedChatConfig !== null && extendedChatConfig !== void 0 && (_extendedChatConfig$L3 = extendedChatConfig.LiveChatConfigAuthSettings) !== null && _extendedChatConfig$L3 !== void 0 && _extendedChatConfig$L3.msdyn_javascriptclientfunction) || isPersistentChatEnabled(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L4 = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L4 === void 0 ? void 0 : _extendedChatConfig$L4.msdyn_conversationmode);
|
|
100
93
|
|
|
101
94
|
// Check if both persistent chat and widget support are enabled
|
|
102
|
-
const shouldLoadPersistentHistoryMessages =
|
|
95
|
+
const shouldLoadPersistentHistoryMessages = isHistoryEnabledInConfig && isHistoryEnabledViaFCB && isPersistentChatEnabledForWidget;
|
|
103
96
|
if (shouldLoadPersistentHistoryMessages) {
|
|
97
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
98
|
+
Event: TelemetryEvent.PersistentChatHistoryEnabled
|
|
99
|
+
});
|
|
104
100
|
usePersistentChatHistory(facadeChatSDK, (props === null || props === void 0 ? void 0 : props.persistentChatHistoryProps) ?? {});
|
|
105
101
|
}
|
|
106
102
|
// Delegated click handler for citation anchors. Placed after state is
|
|
@@ -410,9 +406,7 @@ export const WebChatContainerStateful = props => {
|
|
|
410
406
|
height: "100%",
|
|
411
407
|
width: "100%"
|
|
412
408
|
}
|
|
413
|
-
}, shouldLoadPersistentHistoryMessages && /*#__PURE__*/React.createElement(WebChatEventSubscribers, {
|
|
414
|
-
persistentChatHistoryEnabled: props === null || props === void 0 ? void 0 : (_props$persistentChat2 = props.persistentChatHistoryProps) === null || _props$persistentChat2 === void 0 ? void 0 : _props$persistentChat2.persistentChatHistoryEnabled
|
|
415
|
-
}), /*#__PURE__*/React.createElement(BasicWebChat, null))), citationPaneOpen && /*#__PURE__*/React.createElement(CitationPaneStateful, {
|
|
409
|
+
}, shouldLoadPersistentHistoryMessages && /*#__PURE__*/React.createElement(WebChatEventSubscribers, null), /*#__PURE__*/React.createElement(BasicWebChat, null))), citationPaneOpen && /*#__PURE__*/React.createElement(CitationPaneStateful, {
|
|
416
410
|
id: ((_props$citationPanePr = props.citationPaneProps) === null || _props$citationPanePr === void 0 ? void 0 : _props$citationPanePr.id) || HtmlAttributeNames.ocwCitationPaneClassName,
|
|
417
411
|
title: ((_props$citationPanePr2 = props.citationPaneProps) === null || _props$citationPanePr2 === void 0 ? void 0 : _props$citationPanePr2.title) || HtmlAttributeNames.ocwCitationPaneTitle,
|
|
418
412
|
contentHtml: citationPaneText,
|
|
@@ -56,11 +56,17 @@ const convertPersistentChatHistoryMessageToActivity = message => {
|
|
|
56
56
|
}
|
|
57
57
|
if (tags) {
|
|
58
58
|
const formattedTags = additionalData.tags.split(",");
|
|
59
|
-
activity.channelData
|
|
59
|
+
activity.channelData = {
|
|
60
|
+
...activity.channelData,
|
|
61
|
+
tags: [...activity.channelData.tags, ...formattedTags]
|
|
62
|
+
};
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
if (from !== null && from !== void 0 && (_from$user = from.user) !== null && _from$user !== void 0 && _from$user.displayName) {
|
|
63
|
-
activity.from
|
|
66
|
+
activity.from = {
|
|
67
|
+
...activity.from,
|
|
68
|
+
name: from.user.displayName
|
|
69
|
+
};
|
|
64
70
|
}
|
|
65
71
|
if ((from === null || from === void 0 ? void 0 : (_from$application = from.application) === null || _from$application === void 0 ? void 0 : _from$application.displayName) === "Customer") {
|
|
66
72
|
activity.from = {
|
|
@@ -29,5 +29,6 @@ export const defaultMiddlewareLocalizedTexts = {
|
|
|
29
29
|
MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware.",
|
|
30
30
|
MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS: "Email will be sent after chat ends!",
|
|
31
31
|
MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR: "Email {0} could not be saved, try again later.",
|
|
32
|
-
PREVIOUS_MESSAGES_LOADING: "Loading previous messages..."
|
|
32
|
+
PREVIOUS_MESSAGES_LOADING: "Loading previous messages...",
|
|
33
|
+
CONVERSATION_DIVIDER_ARIA_LABEL: "Conversation history divider"
|
|
33
34
|
};
|
|
@@ -2,9 +2,8 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
|
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
3
|
import ChatWidgetEvents from "../../livechatwidget/common/ChatWidgetEvents";
|
|
4
4
|
import PersistentConversationHandler from "../../livechatwidget/common/PersistentConversationHandler";
|
|
5
|
-
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
|
-
import dispatchCustomEvent from "../../../common/utils/dispatchCustomEvent";
|
|
7
5
|
import SecureEventBus from "../../../common/utils/SecureEventBus";
|
|
6
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
8
7
|
const usePersistentChatHistory = (facadeChatSDK, props) => {
|
|
9
8
|
const handlerRef = useRef(null);
|
|
10
9
|
useEffect(() => {
|
|
@@ -24,7 +23,6 @@ const usePersistentChatHistory = (facadeChatSDK, props) => {
|
|
|
24
23
|
try {
|
|
25
24
|
var _handlerRef$current;
|
|
26
25
|
await ((_handlerRef$current = handlerRef.current) === null || _handlerRef$current === void 0 ? void 0 : _handlerRef$current.pullHistory());
|
|
27
|
-
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
28
26
|
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
29
27
|
Event: TelemetryEvent.LCWPersistentChatHistoryFetchCompleted,
|
|
30
28
|
Description: "Persistent chat history fetch completed successfully"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js
CHANGED
|
@@ -11,14 +11,13 @@ import dispatchCustomEvent from "../../../common/utils/dispatchCustomEvent";
|
|
|
11
11
|
* Component to handle persistent chat history events.
|
|
12
12
|
* Uses WebChatStoreLoader instead of hooks to avoid context issues.
|
|
13
13
|
*/
|
|
14
|
-
const WebChatEventSubscribers =
|
|
14
|
+
const WebChatEventSubscribers = () => {
|
|
15
15
|
const [isConnected, setIsConnected] = useState(false);
|
|
16
16
|
const [storeReady, setStoreReady] = useState(false);
|
|
17
17
|
const storeWaitTimer = createTimer();
|
|
18
|
+
// Type the chatConfig properly to avoid 'any' usage
|
|
19
|
+
|
|
18
20
|
useEffect(() => {
|
|
19
|
-
if (!props.persistentChatHistoryEnabled) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
21
|
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
23
22
|
Event: TelemetryEvent.LCWWebChatStorePollingStarted,
|
|
24
23
|
Description: "WebChat store polling started"
|
|
@@ -50,9 +49,9 @@ const WebChatEventSubscribers = props => {
|
|
|
50
49
|
clearInterval(storeCheckInterval);
|
|
51
50
|
};
|
|
52
51
|
}
|
|
53
|
-
}, [
|
|
52
|
+
}, []);
|
|
54
53
|
useEffect(() => {
|
|
55
|
-
if (!
|
|
54
|
+
if (!storeReady) {
|
|
56
55
|
return;
|
|
57
56
|
}
|
|
58
57
|
const checkConnectionStatus = () => {
|
|
@@ -109,7 +108,7 @@ const WebChatEventSubscribers = props => {
|
|
|
109
108
|
return () => {
|
|
110
109
|
clearInterval(interval);
|
|
111
110
|
};
|
|
112
|
-
}, [isConnected,
|
|
111
|
+
}, [isConnected, storeReady]);
|
|
113
112
|
return null;
|
|
114
113
|
};
|
|
115
114
|
export default WebChatEventSubscribers;
|
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { defaultMiddlewareLocalizedTexts } from "../../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
2
3
|
import { defaultPersistentChatHistoryProps } from "../../../../../livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps";
|
|
3
4
|
import { mergeStyles } from "@fluentui/react";
|
|
4
5
|
const ConversationDividerActivity = props => {
|
|
5
6
|
const styleApplied = mergeStyles(defaultPersistentChatHistoryProps.dividerActivityStyle, props.dividerActivityStyle);
|
|
7
|
+
const ariaLabel = props.dividerActivityAriaLabel || defaultMiddlewareLocalizedTexts.CONVERSATION_DIVIDER_ARIA_LABEL;
|
|
8
|
+
|
|
9
|
+
// Create a simple separator that screen readers can detect without being interactive
|
|
10
|
+
// Preserve the visual divider styling while making it accessible
|
|
11
|
+
// Use a ref to programmatically remove only the "EL said:" prefix from the label
|
|
12
|
+
const dividerRef = React.useRef(null);
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (dividerRef.current) {
|
|
15
|
+
// Find and hardcode the text in the label div to just show the divider label
|
|
16
|
+
const article = dividerRef.current.closest(".webchat__basic-transcript__activity");
|
|
17
|
+
if (article) {
|
|
18
|
+
const labelDiv = article.querySelector("div[id*=\"webchat__basic-transcript__active-descendant-label--\"]");
|
|
19
|
+
if (labelDiv) {
|
|
20
|
+
// Hardcode the text to just the aria label
|
|
21
|
+
labelDiv.textContent = ariaLabel || "";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}, [ariaLabel]);
|
|
6
26
|
return /*#__PURE__*/React.createElement("div", {
|
|
7
|
-
|
|
27
|
+
ref: dividerRef,
|
|
28
|
+
role: "separator",
|
|
29
|
+
"aria-label": ariaLabel,
|
|
30
|
+
"aria-hidden": false,
|
|
31
|
+
className: styleApplied,
|
|
32
|
+
"data-accessibility-divider": "true",
|
|
33
|
+
style: {
|
|
34
|
+
// Add accessibility enhancements
|
|
35
|
+
position: "relative"
|
|
36
|
+
}
|
|
8
37
|
});
|
|
9
38
|
};
|
|
10
39
|
export default ConversationDividerActivity;
|
|
@@ -85,7 +85,7 @@ let LazyLoadHandler = /*#__PURE__*/function () {
|
|
|
85
85
|
|
|
86
86
|
// Scroll operation state
|
|
87
87
|
// Current scroll operation tracking
|
|
88
|
-
// Prevents concurrent scroll operations
|
|
88
|
+
// Prevents concurrent scroll operations (public for event handlers)
|
|
89
89
|
|
|
90
90
|
// Timeout and queue management
|
|
91
91
|
// Tracks all setTimeout IDs for cleanup
|
|
@@ -956,6 +956,21 @@ const LazyLoadActivity = props => {
|
|
|
956
956
|
setHasMoreHistory(false);
|
|
957
957
|
};
|
|
958
958
|
|
|
959
|
+
// Event listener for HISTORY_LOAD_ERROR - hides banner temporarily without disabling future loads
|
|
960
|
+
const handleHistoryLoadError = () => {
|
|
961
|
+
// Temporarily hide the banner by pausing, but keep hasMoreHistory true to allow retry
|
|
962
|
+
LazyLoadHandler.paused = true;
|
|
963
|
+
LazyLoadHandler.pendingScrollAction = false;
|
|
964
|
+
|
|
965
|
+
// Re-enable after a delay to allow retry on next scroll
|
|
966
|
+
// Note: This timeout is intentionally not tracked as it's scoped to the component lifecycle
|
|
967
|
+
window.setTimeout(() => {
|
|
968
|
+
LazyLoadHandler.paused = false;
|
|
969
|
+
}, 2000); // 2 second delay before allowing retry
|
|
970
|
+
|
|
971
|
+
LazyLoadHandler.logLifecycleEvent(TelemetryEvent.LCWLazyLoadHistoryError, "History load error - will retry on next scroll");
|
|
972
|
+
};
|
|
973
|
+
|
|
959
974
|
// Event listener for PersistentConversationReset to sync React state
|
|
960
975
|
// This fixes the issue where banner doesn't appear in start chat + close chat + start chat sequence
|
|
961
976
|
// by ensuring React state (hasMoreHistory) is synchronized with handler state when reset occurs
|
|
@@ -968,6 +983,9 @@ const LazyLoadActivity = props => {
|
|
|
968
983
|
const eventBus = SecureEventBus.getInstance();
|
|
969
984
|
const unsubscribeNoMoreHistory = eventBus.subscribe(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE, handleNoMoreHistory);
|
|
970
985
|
|
|
986
|
+
// Add event listener for history load errors
|
|
987
|
+
const unsubscribeHistoryError = eventBus.subscribe(ChatWidgetEvents.HISTORY_LOAD_ERROR, handleHistoryLoadError);
|
|
988
|
+
|
|
971
989
|
// Add event listener for persistent conversation reset
|
|
972
990
|
const resetSubscription = BroadcastService.getMessageByEventName(BroadcastEvent.PersistentConversationReset).subscribe(handlePersistentConversationReset);
|
|
973
991
|
|
|
@@ -984,6 +1002,7 @@ const LazyLoadActivity = props => {
|
|
|
984
1002
|
// Still need to return cleanup function even after reset
|
|
985
1003
|
return () => {
|
|
986
1004
|
unsubscribeNoMoreHistory();
|
|
1005
|
+
unsubscribeHistoryError();
|
|
987
1006
|
resetSubscription.unsubscribe();
|
|
988
1007
|
};
|
|
989
1008
|
}
|
|
@@ -1036,6 +1055,7 @@ const LazyLoadActivity = props => {
|
|
|
1036
1055
|
|
|
1037
1056
|
// Remove event listeners
|
|
1038
1057
|
unsubscribeNoMoreHistory();
|
|
1058
|
+
unsubscribeHistoryError();
|
|
1039
1059
|
resetSubscription.unsubscribe();
|
|
1040
1060
|
if (container) {
|
|
1041
1061
|
container.removeEventListener("scroll", handleScroll);
|
|
@@ -17,6 +17,7 @@ import { DirectLineActivityType } from "../../enums/DirectLineActivityType";
|
|
|
17
17
|
import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
|
|
18
18
|
import React from "react";
|
|
19
19
|
import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
|
|
20
|
+
import { defaultMiddlewareLocalizedTexts } from "../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
20
21
|
import { defaultSystemMessageStyles } from "./defaultStyles/defaultSystemMessageStyles";
|
|
21
22
|
import { defaultUserMessageStyles } from "./defaultStyles/defaultUserMessageStyles";
|
|
22
23
|
import { escapeHtml } from "../../../../../common/utils";
|
|
@@ -70,7 +71,7 @@ const isDataTagsPresent = card => {
|
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
-
export const createActivityMiddleware = (renderMarkdown, systemMessageStyleProps, userMessageStyleProps) => () => next => function () {
|
|
74
|
+
export const createActivityMiddleware = (renderMarkdown, systemMessageStyleProps, userMessageStyleProps, localizedTexts) => () => next => function () {
|
|
74
75
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
75
76
|
args[_key] = arguments[_key];
|
|
76
77
|
}
|
|
@@ -121,7 +122,11 @@ export const createActivityMiddleware = (renderMarkdown, systemMessageStyleProps
|
|
|
121
122
|
};
|
|
122
123
|
}
|
|
123
124
|
if (isTagIncluded(card, Constants.conversationDividerTag)) {
|
|
124
|
-
|
|
125
|
+
const conversationDividerLabel = (localizedTexts === null || localizedTexts === void 0 ? void 0 : localizedTexts.CONVERSATION_DIVIDER_ARIA_LABEL) || defaultMiddlewareLocalizedTexts.CONVERSATION_DIVIDER_ARIA_LABEL;
|
|
126
|
+
// Pass the computed localized text to the divider component
|
|
127
|
+
return /*#__PURE__*/React.createElement(ConversationDividerActivity, {
|
|
128
|
+
dividerActivityAriaLabel: conversationDividerLabel
|
|
129
|
+
});
|
|
125
130
|
}
|
|
126
131
|
if (card.activity.text && card.activity.type === DirectLineActivityType.Message) {
|
|
127
132
|
if (!card.activity.channelData.isHtmlEncoded && card.activity.channelId === Constants.webchatChannelId) {
|
|
@@ -27,7 +27,12 @@ export const createCitationsMiddleware = (state, dispatch) => () => next => acti
|
|
|
27
27
|
const citations = (_gptFeedback$summariz = gptFeedback.summarizationOpenAIResponse) === null || _gptFeedback$summariz === void 0 ? void 0 : (_gptFeedback$summariz2 = _gptFeedback$summariz.result) === null || _gptFeedback$summariz2 === void 0 ? void 0 : _gptFeedback$summariz2.textCitations;
|
|
28
28
|
// Rewrite inline citation labels in activity.text to match the global map keys
|
|
29
29
|
const updatedText = replaceCitations(action.payload.activity.text, citations, messagePrefix);
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
// Create new activity object to avoid mutation
|
|
32
|
+
action.payload.activity = {
|
|
33
|
+
...action.payload.activity,
|
|
34
|
+
text: updatedText
|
|
35
|
+
};
|
|
31
36
|
// Build a global citation map keyed by the prefixed citation id and
|
|
32
37
|
// dispatch it to app state so the UI container can render citations.
|
|
33
38
|
try {
|