@microsoft/omnichannel-chat-widget 1.8.3 → 1.8.4-main.424a580
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 +5 -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 +44 -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/CitationPaneStateful.js +20 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +287 -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 +7 -1
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -7
- 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 +5 -1
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
- package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +22 -3
- 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 +36 -5
- 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 +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -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 +47 -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 +50 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
- 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/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/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
- package/lib/esm/common/Constants.js +5 -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 +42 -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/CitationPaneStateful.js +20 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +280 -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 +7 -1
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +16 -7
- 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 +7 -3
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
- package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +23 -4
- 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 +39 -5
- 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 +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -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 +39 -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 +48 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
- 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/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/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/esm/plugins/newMessageEventHandler.js +4 -1
- package/lib/types/common/Constants.d.ts +4 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +39 -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/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/startChatErrorHandler.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +12 -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/hooks/usePersistentChatHistory.d.ts +4 -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/activityMiddleware.d.ts +2 -1
- 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/localizedStringsBotInitialsMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +6 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +3 -3
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.logWidgetLoadWithUnexpectedError = exports.logWidgetLoadComplete = exports.handleStartChatError = void 0;
|
|
6
|
+
exports.logWidgetLoadWithUnexpectedError = exports.logWidgetLoadComplete = exports.logStartChatComplete = exports.handleStartChatError = void 0;
|
|
7
7
|
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _Constants = require("../../../common/Constants");
|
|
@@ -124,7 +124,10 @@ const logWidgetLoadFailed = ex => {
|
|
|
124
124
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
125
125
|
Description: "Widget load complete with error",
|
|
126
126
|
ExceptionDetails: exDetails,
|
|
127
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
127
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed,
|
|
128
|
+
CustomProperties: {
|
|
129
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
130
|
+
}
|
|
128
131
|
});
|
|
129
132
|
};
|
|
130
133
|
const logWidgetLoadComplete = additionalMessage => {
|
|
@@ -140,6 +143,17 @@ const logWidgetLoadComplete = additionalMessage => {
|
|
|
140
143
|
});
|
|
141
144
|
};
|
|
142
145
|
exports.logWidgetLoadComplete = logWidgetLoadComplete;
|
|
146
|
+
const logStartChatComplete = additionalMessage => {
|
|
147
|
+
let descriptionString = "Start chat complete";
|
|
148
|
+
if (additionalMessage) {
|
|
149
|
+
descriptionString += `. ${additionalMessage}`;
|
|
150
|
+
}
|
|
151
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
152
|
+
Event: _TelemetryConstants.TelemetryEvent.StartChatComplete,
|
|
153
|
+
Description: descriptionString
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
exports.logStartChatComplete = logStartChatComplete;
|
|
143
157
|
const logWidgetLoadCompleteWithError = ex => {
|
|
144
158
|
var _TelemetryTimers$Widg3;
|
|
145
159
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -156,7 +170,10 @@ const logWidgetLoadCompleteWithError = ex => {
|
|
|
156
170
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
157
171
|
Description: "Widget load complete with error",
|
|
158
172
|
ExceptionDetails: exDetails,
|
|
159
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
173
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed,
|
|
174
|
+
CustomProperties: {
|
|
175
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
176
|
+
}
|
|
160
177
|
});
|
|
161
178
|
};
|
|
162
179
|
const logWidgetLoadWithUnexpectedError = ex => {
|
|
@@ -184,7 +201,10 @@ const logWidgetLoadWithUnexpectedError = ex => {
|
|
|
184
201
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
185
202
|
Description: "Widget load with unexpected error",
|
|
186
203
|
ExceptionDetails: exDetails,
|
|
187
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
|
|
204
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed,
|
|
205
|
+
CustomProperties: {
|
|
206
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
207
|
+
}
|
|
188
208
|
});
|
|
189
209
|
};
|
|
190
210
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -69,7 +69,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
69
69
|
uiTimer = (0, _utils.createTimer)();
|
|
70
70
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
71
71
|
Event: _TelemetryConstants.TelemetryEvent.UXLiveChatWidgetStart,
|
|
72
|
-
Description: "Live chat widget loading started."
|
|
72
|
+
Description: "Live chat widget loading started.",
|
|
73
|
+
CustomProperties: {
|
|
74
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
75
|
+
}
|
|
73
76
|
});
|
|
74
77
|
}, []);
|
|
75
78
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
@@ -500,7 +503,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
500
503
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
501
504
|
_TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
502
505
|
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
503
|
-
Description: "Received InitiateEndChat BroadcastEvent."
|
|
506
|
+
Description: "Received InitiateEndChat BroadcastEvent.",
|
|
507
|
+
CustomProperties: {
|
|
508
|
+
ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd
|
|
509
|
+
}
|
|
504
510
|
});
|
|
505
511
|
|
|
506
512
|
// This is to ensure to get latest state from cache in multitab
|
|
@@ -805,7 +811,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
805
811
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
806
812
|
Event: _TelemetryConstants.TelemetryEvent.UXLiveChatWidgetCompleted,
|
|
807
813
|
Description: "Live chat widget loading completed.",
|
|
808
|
-
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
814
|
+
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed,
|
|
815
|
+
CustomProperties: {
|
|
816
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
817
|
+
}
|
|
809
818
|
});
|
|
810
819
|
}, []);
|
|
811
820
|
const initiateEndChatOnBrowserUnload = () => {
|
|
@@ -875,6 +884,16 @@ const LiveChatWidgetStateful = props => {
|
|
|
875
884
|
bubbleTextColor
|
|
876
885
|
}), [webChatStyles, bubbleBackground, bubbleTextColor]);
|
|
877
886
|
|
|
887
|
+
// React to dynamic bot avatar initials updates from context
|
|
888
|
+
(0, _react2.useEffect)(() => {
|
|
889
|
+
if (state.domainStates.botAvatarInitials && state.domainStates.botAvatarInitials !== webChatStyles.botAvatarInitials) {
|
|
890
|
+
setWebChatStyles(styles => ({
|
|
891
|
+
...styles,
|
|
892
|
+
botAvatarInitials: state.domainStates.botAvatarInitials
|
|
893
|
+
}));
|
|
894
|
+
}
|
|
895
|
+
}, [state.domainStates.botAvatarInitials]);
|
|
896
|
+
|
|
878
897
|
// WebChat's Composer can only be rendered if a directLine object is defined
|
|
879
898
|
return directLine && /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
880
899
|
#oc-lcw .webchat__basic-transcript__scrollable::-webkit-scrollbar {
|
|
@@ -18,6 +18,7 @@ var _isValidSurveyUrl = _interopRequireDefault(require("./common/isValidSurveyUr
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
let uiTimer;
|
|
21
22
|
const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact, customerVoiceSurveyCorrelationId) {
|
|
22
23
|
let showMultiLingual = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
23
24
|
const surveyLinkParams = new URLSearchParams({
|
|
@@ -31,6 +32,16 @@ const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, co
|
|
|
31
32
|
};
|
|
32
33
|
const PostChatSurveyPaneStateful = props => {
|
|
33
34
|
var _props$styleProps, _state$appStates, _props$controlProps;
|
|
35
|
+
(0, _react.useEffect)(() => {
|
|
36
|
+
uiTimer = (0, _utils.createTimer)();
|
|
37
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
38
|
+
Event: _TelemetryConstants.TelemetryEvent.UXPostChatPaneStarted,
|
|
39
|
+
Description: "Postchat survey pane loading started.",
|
|
40
|
+
CustomProperties: {
|
|
41
|
+
ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}, []);
|
|
34
45
|
const [state] = (0, _useChatContextStore.default)();
|
|
35
46
|
const generalStyleProps = Object.assign({}, _defaultgeneralPostChatSurveyPaneStyleProps.defaultGeneralPostChatSurveyPaneStyleProps, (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyleProps, {
|
|
36
47
|
display: state.appStates.isMinimized ? "none" : "contents"
|
|
@@ -81,7 +92,14 @@ const PostChatSurveyPaneStateful = props => {
|
|
|
81
92
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
82
93
|
Event: _TelemetryConstants.TelemetryEvent.PostChatSurveyLoaded
|
|
83
94
|
});
|
|
84
|
-
|
|
95
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
96
|
+
Event: _TelemetryConstants.TelemetryEvent.UXPostChatPaneCompleted,
|
|
97
|
+
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed,
|
|
98
|
+
Description: "Postchat survey pane loading completed.",
|
|
99
|
+
CustomProperties: {
|
|
100
|
+
ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd
|
|
101
|
+
}
|
|
102
|
+
});
|
|
85
103
|
//Customer Voice Telemetry Events
|
|
86
104
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
105
|
window.addEventListener("message", message => {
|
|
@@ -96,7 +114,10 @@ const PostChatSurveyPaneStateful = props => {
|
|
|
96
114
|
} else if (data === _CustomerVoiceEvents.CustomerVoiceEvents.FormResponseSubmitted) {
|
|
97
115
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
98
116
|
Event: _TelemetryConstants.TelemetryEvent.CustomerVoiceFormResponseSubmitted,
|
|
99
|
-
Description: "Customer Voice form response submitted."
|
|
117
|
+
Description: "Customer Voice form response submitted.",
|
|
118
|
+
CustomProperties: {
|
|
119
|
+
ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd
|
|
120
|
+
}
|
|
100
121
|
});
|
|
101
122
|
} else if (data === _CustomerVoiceEvents.CustomerVoiceEvents.FormResponseError) {
|
|
102
123
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -104,6 +125,9 @@ const PostChatSurveyPaneStateful = props => {
|
|
|
104
125
|
Description: "Customer Voice form response error.",
|
|
105
126
|
ExceptionDetails: {
|
|
106
127
|
message: "Customer Voice form response error."
|
|
128
|
+
},
|
|
129
|
+
CustomProperties: {
|
|
130
|
+
ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd
|
|
107
131
|
}
|
|
108
132
|
});
|
|
109
133
|
} else if (typeof data === "string" && data.startsWith(_CustomerVoiceEvents.CustomerVoiceEvents.FormsError)) {
|
|
@@ -112,6 +136,9 @@ const PostChatSurveyPaneStateful = props => {
|
|
|
112
136
|
Description: "Customer Voice failed to load with forms error.",
|
|
113
137
|
ExceptionDetails: {
|
|
114
138
|
message: `Customer Voice forms error details: ${data}`
|
|
139
|
+
},
|
|
140
|
+
CustomProperties: {
|
|
141
|
+
ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd
|
|
115
142
|
}
|
|
116
143
|
});
|
|
117
144
|
}
|
|
@@ -28,7 +28,10 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
28
28
|
uiTimer = (0, _utils.createTimer)();
|
|
29
29
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
30
30
|
Event: _TelemetryConstants.TelemetryEvent.UXPrechatPaneStart,
|
|
31
|
-
Description: "Prechat survey pane loading started."
|
|
31
|
+
Description: "Prechat survey pane loading started.",
|
|
32
|
+
CustomProperties: {
|
|
33
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
34
|
+
}
|
|
32
35
|
});
|
|
33
36
|
}, []);
|
|
34
37
|
|
|
@@ -79,7 +82,10 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
79
82
|
onSubmit: async values => {
|
|
80
83
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
81
84
|
Event: _TelemetryConstants.TelemetryEvent.PrechatSubmitted,
|
|
82
|
-
Description: "Prechat survey submitted."
|
|
85
|
+
Description: "Prechat survey submitted.",
|
|
86
|
+
CustomProperties: {
|
|
87
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
88
|
+
}
|
|
83
89
|
});
|
|
84
90
|
dispatch({
|
|
85
91
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -153,7 +159,10 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
153
159
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
154
160
|
Event: _TelemetryConstants.TelemetryEvent.UXPrechatPaneCompleted,
|
|
155
161
|
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed,
|
|
156
|
-
Description: "Prechat survey pane loading completed."
|
|
162
|
+
Description: "Prechat survey pane loading completed.",
|
|
163
|
+
CustomProperties: {
|
|
164
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
165
|
+
}
|
|
157
166
|
});
|
|
158
167
|
}, []);
|
|
159
168
|
|
|
@@ -17,6 +17,7 @@ var _NotificationHandler = require("./webchatcontroller/notification/Notificatio
|
|
|
17
17
|
var _NotificationScenarios = require("./webchatcontroller/enums/NotificationScenarios");
|
|
18
18
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
19
19
|
var _WebChatActionType = require("./webchatcontroller/enums/WebChatActionType");
|
|
20
|
+
var _WebChatEventSubscribers = _interopRequireDefault(require("./webchatcontroller/WebChatEventSubscribers"));
|
|
20
21
|
var _WebChatStoreLoader = require("./webchatcontroller/WebChatStoreLoader");
|
|
21
22
|
var _fontUtils = require("./common/utils/fontUtils");
|
|
22
23
|
var _defaultAdaptiveCardStyles = require("./common/defaultStyles/defaultAdaptiveCardStyles");
|
|
@@ -26,7 +27,10 @@ var _defaultSentMessageAnchorStyles = require("./webchatcontroller/middlewares/r
|
|
|
26
27
|
var _defaultSystemMessageBoxStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles");
|
|
27
28
|
var _defaultUserMessageBoxStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles");
|
|
28
29
|
var _defaultWebChatContainerStatefulProps = require("./common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
30
|
+
var _liveChatConfigUtils = require("../livechatwidget/common/liveChatConfigUtils");
|
|
29
31
|
var _ = require("../..");
|
|
32
|
+
var _useFacadeChatSDKStore = _interopRequireDefault(require("../../hooks/useFacadeChatSDKStore"));
|
|
33
|
+
var _usePersistentChatHistory = _interopRequireDefault(require("./hooks/usePersistentChatHistory"));
|
|
30
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
35
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
36
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -58,7 +62,9 @@ const createMagicCodeSuccessResponse = signin => {
|
|
|
58
62
|
};
|
|
59
63
|
};
|
|
60
64
|
const WebChatContainerStateful = props => {
|
|
61
|
-
var _props$webChatContain, _defaultWebChatContai, _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;
|
|
65
|
+
var _props$webChatContain, _defaultWebChatContai, _props$persistentChat, _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$persistentChat2, _props$citationPanePr, _props$citationPanePr2, _props$citationPanePr3, _props$citationPanePr4, _props$citationPanePr5;
|
|
66
|
+
const [facadeChatSDK] = (0, _useFacadeChatSDKStore.default)();
|
|
67
|
+
|
|
62
68
|
// Create a font family that includes emoji support, based on the primary font or default
|
|
63
69
|
const webChatStyles = ((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles;
|
|
64
70
|
const primaryFont = (webChatStyles === null || webChatStyles === void 0 ? void 0 : webChatStyles.primaryFont) ?? ((_defaultWebChatContai = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.primaryFont);
|
|
@@ -79,9 +85,6 @@ const WebChatContainerStateful = props => {
|
|
|
79
85
|
// Guard to prevent handling multiple rapid clicks which could cause
|
|
80
86
|
// the dim layer and pane to re-render out of sync and create a flicker.
|
|
81
87
|
const citationOpeningRef = (0, _react2.useRef)(false);
|
|
82
|
-
|
|
83
|
-
// ...existing code...
|
|
84
|
-
|
|
85
88
|
const {
|
|
86
89
|
BasicWebChat
|
|
87
90
|
} = _botframeworkWebchat.Components;
|
|
@@ -91,6 +94,26 @@ const WebChatContainerStateful = props => {
|
|
|
91
94
|
contextDataStore
|
|
92
95
|
} = props;
|
|
93
96
|
|
|
97
|
+
// Type the chatConfig properly to avoid 'any' usage
|
|
98
|
+
const extendedChatConfig = props.chatConfig;
|
|
99
|
+
const isHistoryEnabledViaProps = props === null || props === void 0 ? void 0 : (_props$persistentChat = props.persistentChatHistoryProps) === null || _props$persistentChat === void 0 ? void 0 : _props$persistentChat.persistentChatHistoryEnabled;
|
|
100
|
+
const isHistoryEnabledInConfig = extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L === void 0 ? void 0 : _extendedChatConfig$L.msdyn_enablepersistentchatpreviousconversations;
|
|
101
|
+
const isHistoryEnabledViaFCB = extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L2 = extendedChatConfig.LcwFcbConfiguration) === null || _extendedChatConfig$L2 === void 0 ? void 0 : _extendedChatConfig$L2.lcwPersistentChatHistoryEnabled;
|
|
102
|
+
const isPersistentChatEnabledForWidget = !!(extendedChatConfig !== null && extendedChatConfig !== void 0 && (_extendedChatConfig$L3 = extendedChatConfig.LiveChatConfigAuthSettings) !== null && _extendedChatConfig$L3 !== void 0 && _extendedChatConfig$L3.msdyn_javascriptclientfunction) || (0, _liveChatConfigUtils.isPersistentChatEnabled)(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L4 = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L4 === void 0 ? void 0 : _extendedChatConfig$L4.msdyn_conversationmode);
|
|
103
|
+
|
|
104
|
+
// isPersistentHistoryEnabled can only be true if isHistoryEnabledViaFCB is true, and next conditions are met:
|
|
105
|
+
// 1. isHistoryEnabledViaProps is true (takes precedence over config)
|
|
106
|
+
// 2. isHistoryEnabledInConfig is true and isHistoryEnabledViaProps is undefined
|
|
107
|
+
const isPersistentHistoryEnabled = isHistoryEnabledViaProps || isHistoryEnabledInConfig && !isHistoryEnabledViaProps;
|
|
108
|
+
|
|
109
|
+
// Check if both persistent chat and widget support are enabled
|
|
110
|
+
const shouldLoadPersistentHistoryMessages = isPersistentHistoryEnabled && isHistoryEnabledViaFCB && isPersistentChatEnabledForWidget;
|
|
111
|
+
if (shouldLoadPersistentHistoryMessages) {
|
|
112
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
113
|
+
Event: _TelemetryConstants.TelemetryEvent.PersistentChatHistoryEnabled
|
|
114
|
+
});
|
|
115
|
+
(0, _usePersistentChatHistory.default)(facadeChatSDK, (props === null || props === void 0 ? void 0 : props.persistentChatHistoryProps) ?? {});
|
|
116
|
+
}
|
|
94
117
|
// Delegated click handler for citation anchors. Placed after state is
|
|
95
118
|
// available so we can prefer reading citations from app state and fall
|
|
96
119
|
// back to the legacy window map for backward-compatibility in tests.
|
|
@@ -392,7 +415,15 @@ const WebChatContainerStateful = props => {
|
|
|
392
415
|
`), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
393
416
|
styles: containerStyles,
|
|
394
417
|
className: "webchat__stacked-layout_container"
|
|
395
|
-
}, /*#__PURE__*/_react2.default.createElement(
|
|
418
|
+
}, /*#__PURE__*/_react2.default.createElement("div", {
|
|
419
|
+
id: "ms_lcw_webchat_root",
|
|
420
|
+
style: {
|
|
421
|
+
height: "100%",
|
|
422
|
+
width: "100%"
|
|
423
|
+
}
|
|
424
|
+
}, shouldLoadPersistentHistoryMessages && /*#__PURE__*/_react2.default.createElement(_WebChatEventSubscribers.default, {
|
|
425
|
+
persistentChatHistoryEnabled: props === null || props === void 0 ? void 0 : (_props$persistentChat2 = props.persistentChatHistoryProps) === null || _props$persistentChat2 === void 0 ? void 0 : _props$persistentChat2.persistentChatHistoryEnabled
|
|
426
|
+
}), /*#__PURE__*/_react2.default.createElement(BasicWebChat, null))), citationPaneOpen && /*#__PURE__*/_react2.default.createElement(_CitationPaneStateful.default, {
|
|
396
427
|
id: ((_props$citationPanePr = props.citationPaneProps) === null || _props$citationPanePr === void 0 ? void 0 : _props$citationPanePr.id) || _Constants.HtmlAttributeNames.ocwCitationPaneClassName,
|
|
397
428
|
title: ((_props$citationPanePr2 = props.citationPaneProps) === null || _props$citationPanePr2 === void 0 ? void 0 : _props$citationPanePr2.title) || _Constants.HtmlAttributeNames.ocwCitationPaneTitle,
|
|
398
429
|
contentHtml: citationPaneText,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const botActivity = {
|
|
8
|
+
from: {
|
|
9
|
+
role: "bot"
|
|
10
|
+
},
|
|
11
|
+
type: "message"
|
|
12
|
+
};
|
|
13
|
+
var _default = botActivity;
|
|
14
|
+
exports.default = _default;
|
package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _Constants = require("../../../../common/Constants");
|
|
8
|
+
var _botActivity = _interopRequireDefault(require("./botActivity"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
const conversationDividerActivity = {
|
|
11
|
+
..._botActivity.default,
|
|
12
|
+
channelData: {
|
|
13
|
+
tags: [_Constants.Constants.conversationDividerTag]
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var _default = conversationDividerActivity;
|
|
17
|
+
exports.default = _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _Constants = require("../../../../common/Constants");
|
|
8
|
+
var _botActivity = _interopRequireDefault(require("../activities/botActivity"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
const convertStringValueToInt = value => {
|
|
12
|
+
if (typeof value !== "string" || value === "") {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
let result;
|
|
16
|
+
try {
|
|
17
|
+
result = parseInt(value);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return isNaN(result) ? undefined : result;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
const convertPersistentChatHistoryMessageToActivity = message => {
|
|
26
|
+
var _from$user, _from$application;
|
|
27
|
+
const {
|
|
28
|
+
additionalData,
|
|
29
|
+
attachments,
|
|
30
|
+
content,
|
|
31
|
+
created,
|
|
32
|
+
from,
|
|
33
|
+
transcriptOriginalMessageId
|
|
34
|
+
} = message;
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
const activity = {
|
|
37
|
+
..._botActivity.default,
|
|
38
|
+
channelData: {
|
|
39
|
+
tags: [_Constants.Constants.persistentChatHistoryMessageTag]
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
let webchatSequenceId;
|
|
43
|
+
let timestamp;
|
|
44
|
+
if (transcriptOriginalMessageId) {
|
|
45
|
+
const id = convertStringValueToInt(transcriptOriginalMessageId); // Id used to determine the sequence of messages which is the same as the 'live' messages
|
|
46
|
+
if (id) {
|
|
47
|
+
webchatSequenceId = id;
|
|
48
|
+
timestamp = new Date(id) || created;
|
|
49
|
+
activity.channelData = {
|
|
50
|
+
...activity.channelData,
|
|
51
|
+
"webchat:sequence-id": webchatSequenceId
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (additionalData !== null && additionalData !== void 0 && additionalData.tags) {
|
|
56
|
+
const {
|
|
57
|
+
tags,
|
|
58
|
+
ConversationId
|
|
59
|
+
} = additionalData;
|
|
60
|
+
if (ConversationId) {
|
|
61
|
+
activity.channelData.conversationId = ConversationId;
|
|
62
|
+
}
|
|
63
|
+
if (tags) {
|
|
64
|
+
const formattedTags = additionalData.tags.split(",");
|
|
65
|
+
activity.channelData.tags = [...activity.channelData.tags, ...formattedTags];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (from !== null && from !== void 0 && (_from$user = from.user) !== null && _from$user !== void 0 && _from$user.displayName) {
|
|
69
|
+
activity.from.name = from.user.displayName;
|
|
70
|
+
}
|
|
71
|
+
if ((from === null || from === void 0 ? void 0 : (_from$application = from.application) === null || _from$application === void 0 ? void 0 : _from$application.displayName) === "Customer") {
|
|
72
|
+
activity.from = {
|
|
73
|
+
role: "user",
|
|
74
|
+
name: from.application.displayName
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (content) {
|
|
78
|
+
return {
|
|
79
|
+
...activity,
|
|
80
|
+
text: content,
|
|
81
|
+
timestamp
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (attachments && attachments.length > 0) {
|
|
85
|
+
const fileName = attachments[0].name || "Unknown";
|
|
86
|
+
const text = `The following attachment was uploaded during the conversation: ${fileName}`;
|
|
87
|
+
return {
|
|
88
|
+
...activity,
|
|
89
|
+
text,
|
|
90
|
+
timestamp
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// If neither content nor attachments are present, return null to indicate no activity could be created.
|
|
94
|
+
return null;
|
|
95
|
+
};
|
|
96
|
+
var _default = convertPersistentChatHistoryMessageToActivity;
|
|
97
|
+
exports.default = _default;
|
|
@@ -34,6 +34,8 @@ const defaultMiddlewareLocalizedTexts = {
|
|
|
34
34
|
THIRD_PARTY_COOKIES_BLOCKED_ALERT_MESSAGE: "Allow sites to save/read cookies in browser settings. Reloading page starts a new chat.",
|
|
35
35
|
MIDDLEWARE_BANNER_FILE_IS_MALICIOUS: "{0} has been blocked because the file may contain a malware.",
|
|
36
36
|
MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS: "Email will be sent after chat ends!",
|
|
37
|
-
MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR: "Email {0} could not be saved, try again later."
|
|
37
|
+
MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR: "Email {0} could not be saved, try again later.",
|
|
38
|
+
PREVIOUS_MESSAGES_LOADING: "Loading previous messages...",
|
|
39
|
+
CONVERSATION_DIVIDER_ARIA_LABEL: "Conversation history divider"
|
|
38
40
|
};
|
|
39
41
|
exports.defaultMiddlewareLocalizedTexts = defaultMiddlewareLocalizedTexts;
|
|
@@ -9,7 +9,7 @@ var _groupActivitiesMiddleware = require("../../webchatcontroller/middlewares/re
|
|
|
9
9
|
var _typingIndicatorMiddleware = require("../../webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware");
|
|
10
10
|
const defaultWebChatStatefulProps = {
|
|
11
11
|
// activityMiddleware: activityMiddleware, - this is implemented elsewhere and can be customized
|
|
12
|
-
activityStatusMiddleware: _activityStatusMiddleware.
|
|
12
|
+
activityStatusMiddleware: (0, _activityStatusMiddleware.createActivityStatusMiddleware)(),
|
|
13
13
|
// avatarMiddleware: avatarMiddleware, - this is implemented elsewhere and can be customized
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
15
|
groupActivitiesMiddleware: _groupActivitiesMiddleware.groupActivitiesMiddleware,
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _ChatWidgetEvents = _interopRequireDefault(require("../../livechatwidget/common/ChatWidgetEvents"));
|
|
10
|
+
var _PersistentConversationHandler = _interopRequireDefault(require("../../livechatwidget/common/PersistentConversationHandler"));
|
|
11
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
12
|
+
var _dispatchCustomEvent = _interopRequireDefault(require("../../../common/utils/dispatchCustomEvent"));
|
|
13
|
+
var _SecureEventBus = _interopRequireDefault(require("../../../common/utils/SecureEventBus"));
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
const usePersistentChatHistory = (facadeChatSDK, props) => {
|
|
16
|
+
const handlerRef = (0, _react.useRef)(null);
|
|
17
|
+
(0, _react.useEffect)(() => {
|
|
18
|
+
if (!facadeChatSDK) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
22
|
+
Event: _TelemetryConstants.TelemetryEvent.UXLCWPersistentChatHistoryInitialized,
|
|
23
|
+
Description: "Persistent chat history hook initialized"
|
|
24
|
+
});
|
|
25
|
+
handlerRef.current = new _PersistentConversationHandler.default(facadeChatSDK, props);
|
|
26
|
+
const handler = async () => {
|
|
27
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
28
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWPersistentChatHistoryFetchStarted,
|
|
29
|
+
Description: "Persistent chat history fetch started"
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
var _handlerRef$current;
|
|
33
|
+
await ((_handlerRef$current = handlerRef.current) === null || _handlerRef$current === void 0 ? void 0 : _handlerRef$current.pullHistory());
|
|
34
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
|
|
35
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
36
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWPersistentChatHistoryFetchCompleted,
|
|
37
|
+
Description: "Persistent chat history fetch completed successfully"
|
|
38
|
+
});
|
|
39
|
+
} catch (error) {
|
|
40
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
41
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWPersistentChatHistoryFetchFailed,
|
|
42
|
+
Description: "Persistent chat history fetch failed",
|
|
43
|
+
ExceptionDetails: error
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Subscribe to the secure event bus instead of global window events
|
|
49
|
+
const eventBus = _SecureEventBus.default.getInstance();
|
|
50
|
+
const unsubscribe = eventBus.subscribe(_ChatWidgetEvents.default.FETCH_PERSISTENT_CHAT_HISTORY, handler);
|
|
51
|
+
return () => {
|
|
52
|
+
var _handlerRef$current2;
|
|
53
|
+
unsubscribe();
|
|
54
|
+
(_handlerRef$current2 = handlerRef.current) === null || _handlerRef$current2 === void 0 ? void 0 : _handlerRef$current2.destroy(); // Call destroy instead of reset to properly clean up
|
|
55
|
+
};
|
|
56
|
+
}, [facadeChatSDK]);
|
|
57
|
+
};
|
|
58
|
+
var _default = usePersistentChatHistory;
|
|
59
|
+
exports.default = _default;
|
package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _ChatWidgetEvents = _interopRequireDefault(require("../../livechatwidget/common/ChatWidgetEvents"));
|
|
10
|
+
var _Constants = require("../../../common/Constants");
|
|
11
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
12
|
+
var _WebChatStoreLoader = require("./WebChatStoreLoader");
|
|
13
|
+
var _utils = require("../../../common/utils");
|
|
14
|
+
var _dispatchCustomEvent = _interopRequireDefault(require("../../../common/utils/dispatchCustomEvent"));
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
/**
|
|
17
|
+
* Component to handle persistent chat history events.
|
|
18
|
+
* Uses WebChatStoreLoader instead of hooks to avoid context issues.
|
|
19
|
+
*/
|
|
20
|
+
const WebChatEventSubscribers = props => {
|
|
21
|
+
const [isConnected, setIsConnected] = (0, _react.useState)(false);
|
|
22
|
+
const [storeReady, setStoreReady] = (0, _react.useState)(false);
|
|
23
|
+
const storeWaitTimer = (0, _utils.createTimer)();
|
|
24
|
+
(0, _react.useEffect)(() => {
|
|
25
|
+
if (!props.persistentChatHistoryEnabled) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
29
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWWebChatStorePollingStarted,
|
|
30
|
+
Description: "WebChat store polling started"
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Wait for WebChat store to be available
|
|
34
|
+
const waitForStore = () => {
|
|
35
|
+
if (_WebChatStoreLoader.WebChatStoreLoader.store) {
|
|
36
|
+
setStoreReady(true);
|
|
37
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
38
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWWebChatStoreReady,
|
|
39
|
+
Description: "WebChat store ready",
|
|
40
|
+
ElapsedTimeInMilliseconds: storeWaitTimer.milliSecondsElapsed
|
|
41
|
+
});
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Check if store is already available
|
|
48
|
+
if (!waitForStore()) {
|
|
49
|
+
// Poll for store availability
|
|
50
|
+
const storeCheckInterval = setInterval(() => {
|
|
51
|
+
if (waitForStore()) {
|
|
52
|
+
clearInterval(storeCheckInterval);
|
|
53
|
+
}
|
|
54
|
+
}, 100);
|
|
55
|
+
return () => {
|
|
56
|
+
clearInterval(storeCheckInterval);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}, [props.persistentChatHistoryEnabled]);
|
|
60
|
+
(0, _react.useEffect)(() => {
|
|
61
|
+
if (!props.persistentChatHistoryEnabled || !storeReady) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const checkConnectionStatus = () => {
|
|
65
|
+
try {
|
|
66
|
+
if (_WebChatStoreLoader.WebChatStoreLoader.store) {
|
|
67
|
+
const state = _WebChatStoreLoader.WebChatStoreLoader.store.getState();
|
|
68
|
+
const connectivityStatus = state === null || state === void 0 ? void 0 : state.connectivityStatus;
|
|
69
|
+
const newIsConnected = connectivityStatus === "connected";
|
|
70
|
+
if (newIsConnected && !isConnected) {
|
|
71
|
+
setIsConnected(true);
|
|
72
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
73
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWWebChatConnected,
|
|
74
|
+
Description: "WebChat connection established, dispatching events"
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Dispatch events when connection is established
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.FETCH_PERSISTENT_CHAT_HISTORY);
|
|
80
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.ADD_ACTIVITY, {
|
|
81
|
+
activity: {
|
|
82
|
+
from: {
|
|
83
|
+
role: "bot"
|
|
84
|
+
},
|
|
85
|
+
timestamp: 0,
|
|
86
|
+
type: "message",
|
|
87
|
+
channelData: {
|
|
88
|
+
tags: [_Constants.Constants.persistentChatHistoryMessagePullTriggerTag]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}, 2000);
|
|
93
|
+
} else if (!newIsConnected && isConnected) {
|
|
94
|
+
setIsConnected(false);
|
|
95
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.WARN, {
|
|
96
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWWebChatDisconnected,
|
|
97
|
+
Description: "WebChat connection lost"
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} catch (error) {
|
|
102
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
103
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWWebChatConnectionCheckFailed,
|
|
104
|
+
Description: "WebChat connection status check failed",
|
|
105
|
+
ExceptionDetails: error
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Check immediately
|
|
111
|
+
checkConnectionStatus();
|
|
112
|
+
|
|
113
|
+
// Set up interval to check connection status
|
|
114
|
+
const interval = setInterval(checkConnectionStatus, 1000);
|
|
115
|
+
return () => {
|
|
116
|
+
clearInterval(interval);
|
|
117
|
+
};
|
|
118
|
+
}, [isConnected, props.persistentChatHistoryEnabled, storeReady]);
|
|
119
|
+
return null;
|
|
120
|
+
};
|
|
121
|
+
var _default = WebChatEventSubscribers;
|
|
122
|
+
exports.default = _default;
|