@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 1.8.4-main.4478bbf
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 +7 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
- package/lib/cjs/common/telemetry/AppInsightsEvents.js +4 -5
- package/lib/cjs/common/telemetry/TelemetryConstants.js +46 -2
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +26 -10
- package/lib/cjs/common/utils/SecureEventBus.js +307 -0
- package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
- package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +199 -0
- package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
- package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
- package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +284 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +28 -3
- package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -6
- package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +10 -5
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
- package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
- package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +41 -8
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +29 -2
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +122 -11
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +36 -2
- package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
- package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +18 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +44 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +97 -30
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/cjs/index.js +9 -1
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
- package/lib/esm/common/Constants.js +7 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
- package/lib/esm/common/telemetry/AppInsightsEvents.js +4 -5
- package/lib/esm/common/telemetry/TelemetryConstants.js +44 -1
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +27 -11
- package/lib/esm/common/utils/SecureEventBus.js +328 -0
- package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
- package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +188 -0
- package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
- package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
- package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +277 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +29 -4
- package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -6
- package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +12 -7
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
- package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
- package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +42 -9
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -4
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +125 -12
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
- package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +32 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
- package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +42 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +98 -30
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/esm/index.js +1 -0
- package/lib/esm/plugins/newMessageEventHandler.js +4 -1
- package/lib/types/common/Constants.d.ts +6 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +41 -2
- package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
- package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
- package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
- package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
- package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
- package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
- package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
- package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -1
- package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
- package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +6 -1
- package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
- package/lib/types/index.d.ts +1 -0
- package/package.json +3 -3
- /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
- /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
- /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
1
|
+
import { ConversationStage, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import React, { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { ConfirmationState } from "../../common/Constants";
|
|
4
4
|
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
@@ -61,7 +61,10 @@ export const HeaderStateful = props => {
|
|
|
61
61
|
var _props$headerProps, _props$headerProps$co, _props$headerProps$co2;
|
|
62
62
|
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
63
63
|
Event: TelemetryEvent.HeaderCloseButtonClicked,
|
|
64
|
-
Description: "Header Close action started."
|
|
64
|
+
Description: "Header Close action started.",
|
|
65
|
+
CustomProperties: {
|
|
66
|
+
ConversationStage: ConversationStage.ConversationEnd
|
|
67
|
+
}
|
|
65
68
|
});
|
|
66
69
|
if (localConfirmationPaneState.current !== ConfirmationState.Ok) {
|
|
67
70
|
dispatch({
|
|
@@ -76,7 +79,10 @@ export const HeaderStateful = props => {
|
|
|
76
79
|
}
|
|
77
80
|
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
78
81
|
Event: TelemetryEvent.CloseChatActionCompleted,
|
|
79
|
-
Description: "Header Close action completed."
|
|
82
|
+
Description: "Header Close action completed.",
|
|
83
|
+
CustomProperties: {
|
|
84
|
+
ConversationStage: ConversationStage.ConversationEnd
|
|
85
|
+
}
|
|
80
86
|
});
|
|
81
87
|
const closeButtonId = ((_props$headerProps = props.headerProps) === null || _props$headerProps === void 0 ? void 0 : (_props$headerProps$co = _props$headerProps.controlProps) === null || _props$headerProps$co === void 0 ? void 0 : (_props$headerProps$co2 = _props$headerProps$co.closeButtonProps) === null || _props$headerProps$co2 === void 0 ? void 0 : _props$headerProps$co2.id) ?? `${controlProps.id}-close-button`;
|
|
82
88
|
if (closeButtonId) {
|
|
@@ -13,13 +13,13 @@ import { isPersistentChatEnabled } from "./common/liveChatConfigUtils";
|
|
|
13
13
|
import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
|
|
14
14
|
import { registerTelemetryLoggers } from "./common/registerTelemetryLoggers";
|
|
15
15
|
export const LiveChatWidget = props => {
|
|
16
|
-
var _props$
|
|
16
|
+
var _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig2, _props$chatConfig2$Li;
|
|
17
17
|
const reducer = createReducer();
|
|
18
18
|
const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
20
|
const [adapter, setAdapter] = useState(undefined);
|
|
21
21
|
const [facadeChatSDK, setFacadeChatSDK] = useState(undefined);
|
|
22
|
-
const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 :
|
|
22
|
+
const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 : props.mock);
|
|
23
23
|
const disableReauthentication = ((_props$featureConfigP = props.featureConfigProps) === null || _props$featureConfigP === void 0 ? void 0 : _props$featureConfigP.disableReauthentication) === true;
|
|
24
24
|
overridePropsOnMockIfApplicable(props);
|
|
25
25
|
if (!props.chatConfig) {
|
|
@@ -29,14 +29,14 @@ export const LiveChatWidget = props => {
|
|
|
29
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
30
|
const isAuthenticatedChat = !!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction) || isPersistentChatEnabled((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_conversationmode);
|
|
31
31
|
if (!facadeChatSDK) {
|
|
32
|
-
var _props$
|
|
32
|
+
var _props$mock;
|
|
33
33
|
setFacadeChatSDK(new FacadeChatSDK({
|
|
34
34
|
"chatSDK": chatSDK,
|
|
35
35
|
"chatConfig": props.chatConfig,
|
|
36
36
|
"isAuthenticated": isAuthenticatedChat,
|
|
37
37
|
"getAuthToken": props === null || props === void 0 ? void 0 : props.getAuthToken,
|
|
38
38
|
//when type is not undefined, it means the SDK is mocked
|
|
39
|
-
"isSDKMocked": !isNullOrUndefined(props === null || props === void 0 ? void 0 : (_props$
|
|
39
|
+
"isSDKMocked": !isNullOrUndefined(props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type)
|
|
40
40
|
}, disableReauthentication));
|
|
41
41
|
}
|
|
42
42
|
useEffect(() => {
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import { BroadcastEvent } from "../../../../common/telemetry/TelemetryConstants";
|
|
8
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
9
|
+
import ChatWidgetEvents from "../ChatWidgetEvents";
|
|
10
|
+
import SecureEventBus from "../../../../common/utils/SecureEventBus";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `AddActivitySubscriber` class is responsible for subscribing to the `ADD_ACTIVITY` event
|
|
14
|
+
* from the `ChatWidgetEvents` and notifying an observer when a new activity is added.
|
|
15
|
+
*
|
|
16
|
+
* This class implements the `IActivitySubscriber` interface and acts as a bridge between
|
|
17
|
+
* the event system and the observer pattern.
|
|
18
|
+
*/
|
|
19
|
+
export let AddActivitySubscriber = /*#__PURE__*/function () {
|
|
20
|
+
/**
|
|
21
|
+
* The observer that will be notified when a new activity is added.
|
|
22
|
+
* This is expected to be an object with a `next` method, such as an RxJS `Observer`.
|
|
23
|
+
*/
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Set to track processed activity IDs to prevent duplicate processing.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Unsubscribe function for the secure event listener
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Subscription for PersistentConversationReset event
|
|
36
|
+
*/
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Constructor initializes the `AddActivitySubscriber` and sets up a secure event listener
|
|
41
|
+
* for the `ChatWidgetEvents.ADD_ACTIVITY` event. When the event is triggered, it checks
|
|
42
|
+
* if the event payload contains an `activity` and notifies the observer.
|
|
43
|
+
*/
|
|
44
|
+
function AddActivitySubscriber() {
|
|
45
|
+
_classCallCheck(this, AddActivitySubscriber);
|
|
46
|
+
_defineProperty(this, "observer", void 0);
|
|
47
|
+
_defineProperty(this, "processedActivityIds", new Set());
|
|
48
|
+
_defineProperty(this, "unsubscribeFromSecureEvent", null);
|
|
49
|
+
_defineProperty(this, "resetEventListener", void 0);
|
|
50
|
+
const eventBus = SecureEventBus.getInstance();
|
|
51
|
+
|
|
52
|
+
// Subscribe to the secure event bus instead of global window events
|
|
53
|
+
this.unsubscribeFromSecureEvent = eventBus.subscribe(ChatWidgetEvents.ADD_ACTIVITY, payload => {
|
|
54
|
+
if (payload !== null && payload !== void 0 && payload.activity) {
|
|
55
|
+
var _this$observer;
|
|
56
|
+
const activity = payload.activity;
|
|
57
|
+
const activityId = activity.id;
|
|
58
|
+
if (activity.identifier) {
|
|
59
|
+
if (this.processedActivityIds.has(activity === null || activity === void 0 ? void 0 : activity.identifier)) {
|
|
60
|
+
return; // Skip processing if already handled
|
|
61
|
+
}
|
|
62
|
+
// Add the activity ID to the processed set
|
|
63
|
+
this.processedActivityIds.add(activity === null || activity === void 0 ? void 0 : activity.identifier);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Check if activity has an ID and if it has already been processed
|
|
67
|
+
if (activityId) {
|
|
68
|
+
if (this.processedActivityIds.has(activityId)) {
|
|
69
|
+
return; // Skip processing if already handled
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Add the activity ID to the processed set
|
|
73
|
+
this.processedActivityIds.add(activityId);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Notify the observer with the new activity
|
|
77
|
+
(_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.next(activity);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Subscribe to reset events for cleanup
|
|
82
|
+
this.resetEventListener = BroadcastService.getMessageByEventName(BroadcastEvent.PersistentConversationReset).subscribe(() => {
|
|
83
|
+
this.reset();
|
|
84
|
+
// Clean up the secure event listener when conversation resets
|
|
85
|
+
if (this.unsubscribeFromSecureEvent) {
|
|
86
|
+
this.unsubscribeFromSecureEvent();
|
|
87
|
+
this.unsubscribeFromSecureEvent = null;
|
|
88
|
+
}
|
|
89
|
+
// Unsubscribe from the reset event to prevent accumulation
|
|
90
|
+
if (this.resetEventListener) {
|
|
91
|
+
this.resetEventListener.unsubscribe();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The `next` method is a placeholder for processing the activity.
|
|
98
|
+
* This method can be overridden or extended as needed.
|
|
99
|
+
*
|
|
100
|
+
* @param activity - The activity object to process.
|
|
101
|
+
* @returns The activity object (asynchronously).
|
|
102
|
+
*/
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
+
_createClass(AddActivitySubscriber, [{
|
|
105
|
+
key: "next",
|
|
106
|
+
value: async function next(activity) {
|
|
107
|
+
return activity;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Reset the processed activity IDs when a conversation resets
|
|
112
|
+
*/
|
|
113
|
+
}, {
|
|
114
|
+
key: "reset",
|
|
115
|
+
value: function reset() {
|
|
116
|
+
this.processedActivityIds.clear();
|
|
117
|
+
}
|
|
118
|
+
}]);
|
|
119
|
+
return AddActivitySubscriber;
|
|
120
|
+
}();
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
CHANGED
|
@@ -13,7 +13,6 @@ import { TelemetryManager } from "../../../../common/telemetry/TelemetryManager"
|
|
|
13
13
|
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
14
14
|
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
15
15
|
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
16
|
-
let response;
|
|
17
16
|
const extractSignInId = signInUrl => {
|
|
18
17
|
const result = botOauthUrlRegex.exec(signInUrl);
|
|
19
18
|
if (result && result[1]) {
|
|
@@ -49,20 +48,20 @@ const fetchBotAuthConfig = async (retries, interval) => {
|
|
|
49
48
|
eventName: BroadcastEvent.BotAuthConfigRequest
|
|
50
49
|
};
|
|
51
50
|
BroadcastService.postMessage(botAuthConfigRequestEvent);
|
|
51
|
+
let response;
|
|
52
52
|
const listener = BroadcastService.getMessageByEventName(BroadcastEvent.BotAuthConfigResponse).subscribe(data => {
|
|
53
53
|
var _data$payload, _data$payload2;
|
|
54
54
|
response = ((_data$payload = data.payload) === null || _data$payload === void 0 ? void 0 : _data$payload.response) !== undefined ? (_data$payload2 = data.payload) === null || _data$payload2 === void 0 ? void 0 : _data$payload2.response : response;
|
|
55
55
|
listener.unsubscribe();
|
|
56
56
|
});
|
|
57
|
-
if (response !== undefined) {
|
|
58
|
-
//return response;
|
|
59
|
-
return response;
|
|
60
|
-
}
|
|
61
57
|
if (retries === 1) {
|
|
62
58
|
// Base Case
|
|
63
59
|
throw new Error();
|
|
64
60
|
}
|
|
65
61
|
await delay(interval);
|
|
62
|
+
if (response !== undefined) {
|
|
63
|
+
return response;
|
|
64
|
+
}
|
|
66
65
|
return await fetchBotAuthConfig(--retries, interval);
|
|
67
66
|
};
|
|
68
67
|
export let BotAuthActivitySubscriber = /*#__PURE__*/function () {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var ChatWidgetEvents;
|
|
2
|
+
(function (ChatWidgetEvents) {
|
|
3
|
+
ChatWidgetEvents["ADD_ACTIVITY"] = "CHAT_WIDGET/ADD_ACTIVITY";
|
|
4
|
+
ChatWidgetEvents["FETCH_PERSISTENT_CHAT_HISTORY"] = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY";
|
|
5
|
+
ChatWidgetEvents["NO_MORE_HISTORY_AVAILABLE"] = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE";
|
|
6
|
+
ChatWidgetEvents["HIDE_LOADING_BANNER"] = "CHAT_WIDGET/HIDE_LOADING_BANNER";
|
|
7
|
+
})(ChatWidgetEvents || (ChatWidgetEvents = {}));
|
|
8
|
+
export default ChatWidgetEvents;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
8
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
9
|
+
import ChatWidgetEvents from "./ChatWidgetEvents";
|
|
10
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
11
|
+
import conversationDividerActivity from "../../webchatcontainerstateful/common/activities/conversationDividerActivity";
|
|
12
|
+
import convertPersistentChatHistoryMessageToActivity from "../../webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity";
|
|
13
|
+
import { createTimer } from "../../../common/utils";
|
|
14
|
+
import { defaultPersistentChatHistoryProps } from "./defaultProps/defaultPersistentChatHistoryProps";
|
|
15
|
+
import dispatchCustomEvent from "../../../common/utils/dispatchCustomEvent";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Class responsible for handling persistent conversation history
|
|
19
|
+
*/
|
|
20
|
+
let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
|
|
23
|
+
function PersistentConversationHandler(facadeChatSDK, props) {
|
|
24
|
+
_classCallCheck(this, PersistentConversationHandler);
|
|
25
|
+
_defineProperty(this, "appliedProps", {
|
|
26
|
+
...defaultPersistentChatHistoryProps
|
|
27
|
+
});
|
|
28
|
+
_defineProperty(this, "isLastPull", false);
|
|
29
|
+
_defineProperty(this, "pageToken", null);
|
|
30
|
+
_defineProperty(this, "facadeChatSDK", void 0);
|
|
31
|
+
_defineProperty(this, "lastMessage", null);
|
|
32
|
+
_defineProperty(this, "count", 0);
|
|
33
|
+
_defineProperty(this, "pageSize", 4);
|
|
34
|
+
_defineProperty(this, "isCurrentlyPulling", false);
|
|
35
|
+
_defineProperty(this, "pageTokenInTransitSet", new Set());
|
|
36
|
+
_defineProperty(this, "resetEventListener", BroadcastService.getMessageByEventName(BroadcastEvent.PersistentConversationReset).subscribe(() => {
|
|
37
|
+
this.reset();
|
|
38
|
+
}));
|
|
39
|
+
this.facadeChatSDK = facadeChatSDK;
|
|
40
|
+
this.appliedPropsHandler(props);
|
|
41
|
+
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
42
|
+
Event: TelemetryEvent.LCWPersistentConversationHandlerInitialized,
|
|
43
|
+
Description: "PersistentConversationHandler initialized",
|
|
44
|
+
CustomProperties: {
|
|
45
|
+
pageSize: this.pageSize
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
_createClass(PersistentConversationHandler, [{
|
|
50
|
+
key: "appliedPropsHandler",
|
|
51
|
+
value: function appliedPropsHandler(props) {
|
|
52
|
+
this.appliedProps = {
|
|
53
|
+
...defaultPersistentChatHistoryProps,
|
|
54
|
+
...props
|
|
55
|
+
};
|
|
56
|
+
this.pageSize = this.appliedProps.pageSize || 4;
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "reset",
|
|
60
|
+
value: function reset() {
|
|
61
|
+
this.isLastPull = false;
|
|
62
|
+
this.pageToken = null;
|
|
63
|
+
this.lastMessage = null;
|
|
64
|
+
this.count = 0;
|
|
65
|
+
this.isCurrentlyPulling = false;
|
|
66
|
+
this.pageTokenInTransitSet.clear();
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "destroy",
|
|
70
|
+
value: function destroy() {
|
|
71
|
+
// Only unsubscribe when the handler is being destroyed completely
|
|
72
|
+
this.resetEventListener.unsubscribe();
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "pullHistory",
|
|
76
|
+
value: async function pullHistory() {
|
|
77
|
+
const pullTimer = createTimer();
|
|
78
|
+
|
|
79
|
+
// Prevent concurrent pulls regardless of pageToken
|
|
80
|
+
if (this.isCurrentlyPulling) {
|
|
81
|
+
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
82
|
+
Event: TelemetryEvent.LCWPersistentHistoryPullBlocked,
|
|
83
|
+
Description: "History pull blocked - already in progress"
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Additional check for specific pageToken duplicates
|
|
89
|
+
if (this.pageToken && this.pageTokenInTransitSet.has(this.pageToken)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Mark as currently pulling
|
|
94
|
+
this.isCurrentlyPulling = true;
|
|
95
|
+
if (this.pageToken) {
|
|
96
|
+
this.pageTokenInTransitSet.add(this.pageToken);
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
var _ref;
|
|
100
|
+
const messages = await this.fetchHistoryMessages();
|
|
101
|
+
if (messages === null || (messages === null || messages === void 0 ? void 0 : messages.length) === 0) {
|
|
102
|
+
this.isLastPull = true;
|
|
103
|
+
// Dispatch event to notify UI that no more history is available
|
|
104
|
+
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
105
|
+
// Also hide the loading banner
|
|
106
|
+
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
107
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
108
|
+
Event: TelemetryEvent.LCWPersistentHistoryPullCompleted,
|
|
109
|
+
Description: "History pull completed - no more messages",
|
|
110
|
+
ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed
|
|
111
|
+
});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
|
|
115
|
+
this.processHistoryMessages(messagesDescOrder);
|
|
116
|
+
|
|
117
|
+
// Dispatch event to hide the loading banner after messages are processed
|
|
118
|
+
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
119
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
120
|
+
Event: TelemetryEvent.LCWPersistentHistoryPullCompleted,
|
|
121
|
+
Description: "History pull completed successfully",
|
|
122
|
+
ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed,
|
|
123
|
+
CustomProperties: {
|
|
124
|
+
messageCount: messages.length,
|
|
125
|
+
totalProcessed: this.count
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
} finally {
|
|
129
|
+
// Always clear the pulling flag when done
|
|
130
|
+
this.isCurrentlyPulling = false;
|
|
131
|
+
|
|
132
|
+
// Remove pageToken from transit set if it was added
|
|
133
|
+
if (this.pageToken) {
|
|
134
|
+
this.pageTokenInTransitSet.delete(this.pageToken);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
|
+
}, {
|
|
141
|
+
key: "processHistoryMessages",
|
|
142
|
+
value: function processHistoryMessages(messagesDescOrder) {
|
|
143
|
+
for (const message of messagesDescOrder) {
|
|
144
|
+
try {
|
|
145
|
+
const activity = this.processMessageToActivity(message);
|
|
146
|
+
if (activity) {
|
|
147
|
+
dispatchCustomEvent(ChatWidgetEvents.ADD_ACTIVITY, {
|
|
148
|
+
activity
|
|
149
|
+
});
|
|
150
|
+
const dividerActivity = this.createDividerActivity(activity);
|
|
151
|
+
if (dividerActivity) {
|
|
152
|
+
dispatchCustomEvent(ChatWidgetEvents.ADD_ACTIVITY, {
|
|
153
|
+
activity: dividerActivity
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
this.lastMessage = activity;
|
|
157
|
+
}
|
|
158
|
+
} catch (error) {
|
|
159
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
160
|
+
Event: TelemetryEvent.ConvertPersistentChatHistoryMessageToActivityFailed,
|
|
161
|
+
ExceptionDetails: error
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
|
+
}, {
|
|
169
|
+
key: "fetchHistoryMessages",
|
|
170
|
+
value: async function fetchHistoryMessages() {
|
|
171
|
+
if (!this.shouldPull()) {
|
|
172
|
+
// Dispatch event to ensure banner is hidden when no more pulls are needed
|
|
173
|
+
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
174
|
+
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
const options = {
|
|
178
|
+
pageSize: this.pageSize,
|
|
179
|
+
pageToken: this.pageToken || undefined
|
|
180
|
+
};
|
|
181
|
+
try {
|
|
182
|
+
var _this$facadeChatSDK;
|
|
183
|
+
const response = await ((_this$facadeChatSDK = this.facadeChatSDK) === null || _this$facadeChatSDK === void 0 ? void 0 : _this$facadeChatSDK.fetchPersistentConversationHistory(options));
|
|
184
|
+
const {
|
|
185
|
+
chatMessages: messages,
|
|
186
|
+
nextPageToken: pageToken
|
|
187
|
+
} = response;
|
|
188
|
+
this.pageToken = pageToken || null;
|
|
189
|
+
if (pageToken === null) {
|
|
190
|
+
this.isLastPull = true;
|
|
191
|
+
// Dispatch event when we reach the end of available history
|
|
192
|
+
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// if chatMessages is null, return empty array
|
|
196
|
+
if (!messages) {
|
|
197
|
+
this.isLastPull = true;
|
|
198
|
+
// Dispatch event when we reach the end of available history
|
|
199
|
+
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
200
|
+
// Also hide the loading banner
|
|
201
|
+
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
202
|
+
return [];
|
|
203
|
+
}
|
|
204
|
+
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
205
|
+
return messages;
|
|
206
|
+
} catch (error) {
|
|
207
|
+
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
208
|
+
Event: TelemetryEvent.FetchPersistentChatHistoryFailed,
|
|
209
|
+
ExceptionDetails: error
|
|
210
|
+
});
|
|
211
|
+
this.isLastPull = true;
|
|
212
|
+
this.pageToken = null;
|
|
213
|
+
// Dispatch event when there's an error to stop loading banner
|
|
214
|
+
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
215
|
+
// Also hide the loading banner
|
|
216
|
+
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
217
|
+
return [];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}, {
|
|
221
|
+
key: "shouldPull",
|
|
222
|
+
value: function shouldPull() {
|
|
223
|
+
return !this.isLastPull;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
227
|
+
}, {
|
|
228
|
+
key: "processMessageToActivity",
|
|
229
|
+
value: function processMessageToActivity(message) {
|
|
230
|
+
try {
|
|
231
|
+
const activity = convertPersistentChatHistoryMessageToActivity(message);
|
|
232
|
+
activity.id = activity.id || `activity-${this.count}`;
|
|
233
|
+
activity.channelData = {
|
|
234
|
+
...activity.channelData,
|
|
235
|
+
metadata: {
|
|
236
|
+
count: this.count
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// Increment the count after assigning it to the activity
|
|
241
|
+
this.count += 1;
|
|
242
|
+
return activity;
|
|
243
|
+
} catch (error) {
|
|
244
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
245
|
+
Event: TelemetryEvent.ConvertPersistentChatHistoryMessageToActivityFailed,
|
|
246
|
+
ExceptionDetails: error
|
|
247
|
+
});
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
+
}, {
|
|
254
|
+
key: "createDividerActivity",
|
|
255
|
+
value: function createDividerActivity(activity) {
|
|
256
|
+
var _this$lastMessage, _this$lastMessage$cha;
|
|
257
|
+
if (((_this$lastMessage = this.lastMessage) === null || _this$lastMessage === void 0 ? void 0 : (_this$lastMessage$cha = _this$lastMessage.channelData) === null || _this$lastMessage$cha === void 0 ? void 0 : _this$lastMessage$cha.conversationId) !== activity.channelData.conversationId) {
|
|
258
|
+
const rawSequenceId = activity.channelData["webchat:sequence-id"];
|
|
259
|
+
const sequenceId = typeof rawSequenceId === "number" && !isNaN(rawSequenceId) ? rawSequenceId + 1 : 1;
|
|
260
|
+
const timestamp = new Date(activity.timestamp).getTime() + 1;
|
|
261
|
+
return {
|
|
262
|
+
...conversationDividerActivity,
|
|
263
|
+
channelData: {
|
|
264
|
+
...conversationDividerActivity.channelData,
|
|
265
|
+
conversationId: activity.channelData.conversationId,
|
|
266
|
+
"webchat:sequence-id": sequenceId
|
|
267
|
+
},
|
|
268
|
+
timestamp: new Date(timestamp).toISOString(),
|
|
269
|
+
identifier: `divider-${activity.channelData.conversationId}`
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
}]);
|
|
275
|
+
return PersistentConversationHandler;
|
|
276
|
+
}();
|
|
277
|
+
export default PersistentConversationHandler;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AddActivitySubscriber } from "./ActivitySubscriber/AddActivitySubscriber";
|
|
1
2
|
import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
|
|
2
3
|
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
3
4
|
import { HiddenAdaptiveCardActivitySubscriber } from "./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber";
|
|
@@ -44,6 +45,7 @@ export const createAdapter = async (facadeChatSDK, props) => {
|
|
|
44
45
|
fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval
|
|
45
46
|
};
|
|
46
47
|
adapter = new ChatAdapterShim(adapter);
|
|
48
|
+
adapter.addSubscriber(new AddActivitySubscriber());
|
|
47
49
|
adapter.addSubscriber(new PauseActivitySubscriber());
|
|
48
50
|
adapter.addSubscriber(new BotAuthActivitySubscriber(botAuthActivitySubscriberOptionalParams));
|
|
49
51
|
// Remove this code after ICM ID:544623085 is fixed
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import { ConfirmationState, Constants, ConversationEndEntity, ParticipantType, PrepareEndChatDescriptionConstants } from "../../../common/Constants";
|
|
2
|
+
import { ConfirmationState, Constants, ConversationEndEntity, LiveWorkItemState, ParticipantType, PrepareEndChatDescriptionConstants } from "../../../common/Constants";
|
|
3
3
|
import { getConversationDetailsCall, getWidgetEndChatEventName } from "../../../common/utils";
|
|
4
4
|
import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
|
|
5
5
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
6
6
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
7
|
+
import { LazyLoadHandler } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity";
|
|
7
8
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
8
9
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
9
10
|
import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
@@ -39,7 +40,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
// Use Case: If ended by Agent, stay chat in InActive state
|
|
42
|
-
|
|
43
|
+
const isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
|
|
43
44
|
if (isConversationalSurveyEnabled && ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.conversationEndedBy) === ConversationEndEntity.Bot)) {
|
|
44
45
|
dispatch({
|
|
45
46
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -147,8 +148,23 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
|
|
|
147
148
|
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
148
149
|
payload: null
|
|
149
150
|
});
|
|
151
|
+
let isSessionEnded = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.chatDisconnectEventReceived;
|
|
152
|
+
if (!isSessionEnded) {
|
|
153
|
+
// double check by fetching the latest conversation details
|
|
154
|
+
const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
|
|
155
|
+
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.WrapUp || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.Closed) {
|
|
156
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
157
|
+
Event: TelemetryEvent.ChatDisconnectThreadEventReceived,
|
|
158
|
+
Description: "Checking conversation details upon endChat. Chat disconnected.",
|
|
159
|
+
CustomProperties: {
|
|
160
|
+
conversationDetails
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
isSessionEnded = true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
150
166
|
const endChatOptionalParameters = {
|
|
151
|
-
isSessionEnded
|
|
167
|
+
isSessionEnded
|
|
152
168
|
};
|
|
153
169
|
try {
|
|
154
170
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
@@ -210,7 +226,12 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
|
|
|
210
226
|
type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
|
|
211
227
|
payload: undefined
|
|
212
228
|
});
|
|
213
|
-
|
|
229
|
+
|
|
230
|
+
// Call direct reset to ensure LazyLoadHandler gets reset regardless of broadcast timing
|
|
231
|
+
LazyLoadHandler.directReset();
|
|
232
|
+
BroadcastService.postMessage({
|
|
233
|
+
eventName: BroadcastEvent.PersistentConversationReset
|
|
234
|
+
});
|
|
214
235
|
closeChatWidget(dispatch, setWebChatStyles, props);
|
|
215
236
|
facadeChatSDK.destroy();
|
|
216
237
|
}
|
|
@@ -296,6 +317,10 @@ export const closeChatStateCleanUp = dispatch => {
|
|
|
296
317
|
proactiveChatInNewWindow: false
|
|
297
318
|
}
|
|
298
319
|
});
|
|
320
|
+
dispatch({
|
|
321
|
+
type: LiveChatWidgetActionType.SET_CITATIONS,
|
|
322
|
+
payload: {}
|
|
323
|
+
});
|
|
299
324
|
|
|
300
325
|
// Clear live chat context only if chat widget is fully closed to support transcript calls after sessionclose is called
|
|
301
326
|
dispatch({
|
|
@@ -3,14 +3,15 @@ import { DesignerChatSDK } from "../../webchatcontainerstateful/common/DesignerC
|
|
|
3
3
|
import { MockChatSDK } from "../../webchatcontainerstateful/common/mockchatsdk";
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
export const getMockChatSDKIfApplicable = (chatSDK,
|
|
7
|
-
if (type) {
|
|
8
|
-
switch (type.toLowerCase()) {
|
|
6
|
+
export const getMockChatSDKIfApplicable = (chatSDK, mockProps) => {
|
|
7
|
+
if (mockProps !== null && mockProps !== void 0 && mockProps.type) {
|
|
8
|
+
switch (mockProps.type.toLowerCase()) {
|
|
9
9
|
case "demo":
|
|
10
10
|
chatSDK = new DemoChatSDK();
|
|
11
11
|
break;
|
|
12
12
|
case "designer":
|
|
13
13
|
chatSDK = new DesignerChatSDK();
|
|
14
|
+
chatSDK.mockMessages = mockProps === null || mockProps === void 0 ? void 0 : mockProps.mockMessages;
|
|
14
15
|
break;
|
|
15
16
|
default:
|
|
16
17
|
chatSDK = new MockChatSDK();
|