@microsoft/omnichannel-chat-widget 1.8.4-main.7bdb634 → 1.8.4-main.9ae37a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/lib/cjs/common/Constants.js +3 -0
- package/lib/cjs/common/telemetry/AppInsightsEvents.js +14 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +15 -2
- package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +26 -10
- 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/ChatWidgetEvents.js +1 -1
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +26 -20
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +21 -9
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +9 -2
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- package/lib/cjs/components/livechatwidget/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/livechatwidgetstateful/LiveChatWidgetStateful.js +123 -28
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -4
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +30 -29
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +8 -2
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +30 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/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 +3 -0
- package/lib/esm/common/telemetry/AppInsightsEvents.js +14 -9
- package/lib/esm/common/telemetry/TelemetryConstants.js +13 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +27 -11
- 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/ChatWidgetEvents.js +1 -1
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +26 -20
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +21 -9
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +9 -2
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- package/lib/esm/components/livechatwidget/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/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -29
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +33 -6
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +30 -32
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +8 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +30 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/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 +3 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +12 -1
- package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +5 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +1 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +5 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +2 -2
|
@@ -7,6 +7,7 @@ exports.FirstResponseLatencyTracker = void 0;
|
|
|
7
7
|
var _TelemetryConstants = require("../common/telemetry/TelemetryConstants");
|
|
8
8
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
9
|
var _TelemetryHelper = require("../common/telemetry/TelemetryHelper");
|
|
10
|
+
var _Constants = require("../common/Constants");
|
|
10
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
12
|
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); } }
|
|
12
13
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -133,7 +134,8 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
|
|
|
133
134
|
CustomProperties: {
|
|
134
135
|
elapsedTime,
|
|
135
136
|
userMessage: this.startTrackingMessage,
|
|
136
|
-
botMessage: this.stopTrackingMessage
|
|
137
|
+
botMessage: this.stopTrackingMessage,
|
|
138
|
+
type: payload === null || payload === void 0 ? void 0 : payload.type
|
|
137
139
|
}
|
|
138
140
|
});
|
|
139
141
|
}
|
|
@@ -174,7 +176,9 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
|
|
|
174
176
|
value: function stopClock(payload) {
|
|
175
177
|
try {
|
|
176
178
|
if (!payload || !payload.Id) {
|
|
177
|
-
|
|
179
|
+
if ((payload === null || payload === void 0 ? void 0 : payload.type) !== _Constants.Constants.typing) {
|
|
180
|
+
throw new Error("Invalid payload");
|
|
181
|
+
}
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
// Only allow stopTracking if sender is valid and tracking is active
|
|
@@ -84,6 +84,9 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
|
|
|
84
84
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
85
|
const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
|
|
86
86
|
if (messageHasNoTags && messageHasNoText && messageHasNoAttachments) {
|
|
87
|
+
if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants2.Constants.typing) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
87
90
|
return false;
|
|
88
91
|
}
|
|
89
92
|
return true;
|
|
@@ -112,7 +115,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
|
|
|
112
115
|
});
|
|
113
116
|
};
|
|
114
117
|
const raiseMessageEvent = activity => {
|
|
115
|
-
if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants2.Constants.message) {
|
|
118
|
+
if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants2.Constants.message || (activity === null || activity === void 0 ? void 0 : activity.type) === _Constants2.Constants.typing) {
|
|
116
119
|
const scenarioType = (0, _util.getScenarioType)(activity);
|
|
117
120
|
switch (scenarioType) {
|
|
118
121
|
case _Constants.ScenarioType.UserSendMessageStrategy:
|
|
@@ -61,6 +61,7 @@ _defineProperty(Constants, "queuePositionMessageTag", "queueposition");
|
|
|
61
61
|
_defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
|
|
62
62
|
_defineProperty(Constants, "message", "message");
|
|
63
63
|
_defineProperty(Constants, "hiddenTag", "Hidden");
|
|
64
|
+
_defineProperty(Constants, "typing", "typing");
|
|
64
65
|
// messageTimestampMiddleware
|
|
65
66
|
_defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
|
|
66
67
|
_defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
|
|
@@ -135,6 +136,7 @@ _defineProperty(Constants, "customEventName", "customEventName");
|
|
|
135
136
|
_defineProperty(Constants, "customEventValue", "customEventValue");
|
|
136
137
|
_defineProperty(Constants, "Hidden", "Hidden");
|
|
137
138
|
_defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
|
|
139
|
+
_defineProperty(Constants, "SkipSessionCloseForPersistentChatFlag", "skipSessionCloseForPersistentChat");
|
|
138
140
|
export const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
|
|
139
141
|
_classCallCheck(this, Regex);
|
|
140
142
|
}), _defineProperty(_class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\])$"), _class);
|
|
@@ -344,6 +346,7 @@ _defineProperty(PrepareEndChatDescriptionConstants, "ConversationEndedBy", "Conv
|
|
|
344
346
|
_defineProperty(PrepareEndChatDescriptionConstants, "PrepareEndChatError", "There's an error while preparing to end chat. Closing chat widget.");
|
|
345
347
|
_defineProperty(PrepareEndChatDescriptionConstants, "WidgetLoadFailedAfterSessionInit", "SessionInit was successful, but widget load failed. Ending chat to avoid ghost chats in OC.");
|
|
346
348
|
_defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceived", "Received InitiateEndChat BroadcastEvent while conversation state is not Active. Ending chat.");
|
|
349
|
+
_defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceivedActiveChat", "Received InitiateEndChat BroadcastEvent while conversation state is Active. Updating conversation states.");
|
|
347
350
|
_defineProperty(PrepareEndChatDescriptionConstants, "EndChatReceivedFromOtherTabs", "Received EndChat BroadcastEvent from other tabs. Closing this chat.");
|
|
348
351
|
_defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseChatOnFailureOrPostChat", "Customer is trying to close chat widget on start chat failure or post chat pane.");
|
|
349
352
|
_defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseInactiveChat", "Chat was Inactive and customer is trying to close chat widget or refreshing the page.");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export const AppInsightsEventMapping = {
|
|
2
2
|
"LCWChatButtonClicked": "LCWChatButtonActionStarted",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
3
|
+
"UXLCWChatButtonLoadingStart": "LiveChatWidgetChatButtonLoadingStarted",
|
|
4
|
+
"UXLCWChatButtonLoadingCompleted": "LiveChatWidgetChatButtonLoadingCompleted",
|
|
5
|
+
"UXPrechatPaneStart": "PrechatSurveyStarted",
|
|
6
|
+
"UXPrechatPaneCompleted": "PrechatSurveyCompleted",
|
|
7
|
+
"PrechatSubmitted": "PrechatSurveySubmitCompleted",
|
|
8
8
|
"EndChatEventReceived": "EndChatEventReceivedCompleted",
|
|
9
9
|
"EmailTranscriptSent": "EmailTranscriptActionCompleted",
|
|
10
10
|
"EmailTranscriptFailed": "EmailTranscriptActionFailed",
|
|
@@ -12,13 +12,18 @@ export const AppInsightsEventMapping = {
|
|
|
12
12
|
"HeaderMinimizeButtonClicked": "MinimizeChatActionStarted",
|
|
13
13
|
"DownloadTranscriptButtonClicked": "DownloadTranscriptActionStarted",
|
|
14
14
|
"EmailTranscriptButtonClicked": "EmailTranscriptButtonActionStarted",
|
|
15
|
-
"CustomerVoiceFormResponseSubmitted": "CustomerVoiceFormResponseSubmitCompleted",
|
|
16
|
-
"StartProactiveChatEventReceived": "StartProactiveChatEventReceivedCompleted",
|
|
17
15
|
"ProactiveChatRejected": "ProactiveChatTimeOutCompleted",
|
|
18
16
|
"MessageSent": "MessageSentCompleted",
|
|
19
17
|
"MessageReceived": "MessageReceivedCompleted",
|
|
20
18
|
"SystemMessageReceived": "SystemMessageReceivedCompleted",
|
|
21
|
-
"RehydrateMessageReceived": "
|
|
19
|
+
"RehydrateMessageReceived": "ChatHistoryMessageReceivedCompleted",
|
|
22
20
|
"CustomContextReceived": "CustomContextReceivedCompleted",
|
|
23
|
-
"
|
|
21
|
+
"NewTokenValidationStarted": "AuthTokenValidationStarted",
|
|
22
|
+
"NewTokenValidationCompleted": "AuthTokenValidationCompleted",
|
|
23
|
+
"NewTokenValidationFailed": "AuthTokenValidationFailed",
|
|
24
|
+
"UXPostChatPaneStarted": "PostChatSurveyStarted",
|
|
25
|
+
"UXPostChatPaneCompleted": "PostChatSurveyCompleted",
|
|
26
|
+
"WidgetLoadStarted": "ChatSessionInitializationStarted",
|
|
27
|
+
"WidgetLoadComplete": "ChatSessionInitializationCompleted",
|
|
28
|
+
"WidgetLoadFailed": "ChatSessionInitializationFailed"
|
|
24
29
|
};
|
|
@@ -118,6 +118,7 @@ export let TelemetryEvent;
|
|
|
118
118
|
TelemetryEvent["EndChatFailed"] = "EndChatFailed";
|
|
119
119
|
TelemetryEvent["SettingCustomContext"] = "SettingCustomContext";
|
|
120
120
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
121
|
+
TelemetryEvent["PersistentChatHistoryEnabled"] = "PersistentChatHistoryEnabled";
|
|
121
122
|
TelemetryEvent["LCWChatButtonActionCompleted"] = "LCWChatButtonActionCompleted";
|
|
122
123
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
123
124
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -282,6 +283,8 @@ export let TelemetryEvent;
|
|
|
282
283
|
TelemetryEvent["UXCitationPaneCompleted"] = "UXCitationPaneCompleted";
|
|
283
284
|
TelemetryEvent["UXLiveChatWidgetStart"] = "UXLiveChatWidgetStart";
|
|
284
285
|
TelemetryEvent["UXLiveChatWidgetCompleted"] = "UXLiveChatWidgetCompleted";
|
|
286
|
+
TelemetryEvent["UXPostChatPaneStarted"] = "UXPostChatPaneStarted";
|
|
287
|
+
TelemetryEvent["UXPostChatPaneCompleted"] = "UXPostChatPaneCompleted";
|
|
285
288
|
TelemetryEvent["AppInsightsInitialized"] = "AppInsightsInitialized";
|
|
286
289
|
TelemetryEvent["AppInsightsInitFailed"] = "AppInsightsInitFailed";
|
|
287
290
|
TelemetryEvent["ConvertPersistentChatHistoryMessageToActivityFailed"] = "ConvertPersistentChatHistoryMessageToActivityFailed";
|
|
@@ -297,6 +300,7 @@ export let TelemetryEvent;
|
|
|
297
300
|
TelemetryEvent["LCWPersistentConversationHandlerInitialized"] = "LCWPersistentConversationHandlerInitialized";
|
|
298
301
|
TelemetryEvent["LCWPersistentHistoryPullBlocked"] = "LCWPersistentHistoryPullBlocked";
|
|
299
302
|
TelemetryEvent["LCWPersistentHistoryPullCompleted"] = "LCWPersistentHistoryPullCompleted";
|
|
303
|
+
TelemetryEvent["LCWPersistentHistoryReturnedNull"] = "LCWPersistentHistoryReturnedNull";
|
|
300
304
|
TelemetryEvent["LCWLazyLoadInitializationStarted"] = "LCWLazyLoadInitializationStarted";
|
|
301
305
|
TelemetryEvent["LCWLazyLoadContainerNotFound"] = "LCWLazyLoadContainerNotFound";
|
|
302
306
|
TelemetryEvent["LCWLazyLoadInitializationCompleted"] = "LCWLazyLoadInitializationCompleted";
|
|
@@ -306,10 +310,12 @@ export let TelemetryEvent;
|
|
|
306
310
|
TelemetryEvent["LCWLazyLoadActivityMounted"] = "LCWLazyLoadActivityMounted";
|
|
307
311
|
TelemetryEvent["LCWLazyLoadReset"] = "LCWLazyLoadReset";
|
|
308
312
|
TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
|
|
313
|
+
TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
|
|
309
314
|
TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
|
|
310
315
|
TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
|
|
311
316
|
TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
|
|
312
317
|
TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
|
|
318
|
+
TelemetryEvent["StartChatComplete"] = "StartChatComplete";
|
|
313
319
|
})(TelemetryEvent || (TelemetryEvent = {}));
|
|
314
320
|
export let TelemetryConstants = /*#__PURE__*/function () {
|
|
315
321
|
function TelemetryConstants() {
|
|
@@ -439,4 +445,10 @@ export let TelemetryConstants = /*#__PURE__*/function () {
|
|
|
439
445
|
}
|
|
440
446
|
}]);
|
|
441
447
|
return TelemetryConstants;
|
|
442
|
-
}();
|
|
448
|
+
}();
|
|
449
|
+
export let ConversationStage;
|
|
450
|
+
(function (ConversationStage) {
|
|
451
|
+
ConversationStage["Initialization"] = "Initialization";
|
|
452
|
+
ConversationStage["CSREngagement"] = "CSR Engagement";
|
|
453
|
+
ConversationStage["ConversationEnd"] = "Conversation End";
|
|
454
|
+
})(ConversationStage || (ConversationStage = {}));
|
|
@@ -41,7 +41,7 @@ export const RegisterLoggers = () => {
|
|
|
41
41
|
loggers.push(consoleLogger());
|
|
42
42
|
}
|
|
43
43
|
if (((_TelemetryManager$Int9 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int9 === void 0 ? void 0 : (_TelemetryManager$Int10 = _TelemetryManager$Int9.telemetryConfig) === null || _TelemetryManager$Int10 === void 0 ? void 0 : _TelemetryManager$Int10.telemetryDisabled) === false) {
|
|
44
|
-
var _TelemetryManager$Int11, _TelemetryManager$Int20, _TelemetryManager$Int21, _TelemetryManager$Int22, _TelemetryManager$Int23;
|
|
44
|
+
var _TelemetryManager$Int11, _TelemetryManager$Int20, _TelemetryManager$Int21, _TelemetryManager$Int22, _TelemetryManager$Int23, _TelemetryManager$Int24, _TelemetryManager$Int25, _TelemetryManager$Int26;
|
|
45
45
|
if ((_TelemetryManager$Int11 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int11 !== void 0 && _TelemetryManager$Int11.ariaConfig) {
|
|
46
46
|
var _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14, _TelemetryManager$Int15, _TelemetryManager$Int16, _TelemetryManager$Int17, _TelemetryManager$Int18, _TelemetryManager$Int19;
|
|
47
47
|
loggers.push(ariaTelemetryLogger(((_TelemetryManager$Int12 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : (_TelemetryManager$Int13 = _TelemetryManager$Int12.ariaConfig) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.ariaTelemetryKey) ?? defaultAriaConfig.ariaTelemetryKey, ((_TelemetryManager$Int14 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : (_TelemetryManager$Int15 = _TelemetryManager$Int14.ariaConfig) === null || _TelemetryManager$Int15 === void 0 ? void 0 : _TelemetryManager$Int15.disableCookieUsage) ?? defaultAriaConfig.disableCookieUsage, ((_TelemetryManager$Int16 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int16 === void 0 ? void 0 : (_TelemetryManager$Int17 = _TelemetryManager$Int16.ariaConfig) === null || _TelemetryManager$Int17 === void 0 ? void 0 : _TelemetryManager$Int17.collectorUriForTelemetry) ?? defaultAriaConfig.collectorUriForTelemetry, ((_TelemetryManager$Int18 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int18 === void 0 ? void 0 : (_TelemetryManager$Int19 = _TelemetryManager$Int18.ariaConfig) === null || _TelemetryManager$Int19 === void 0 ? void 0 : _TelemetryManager$Int19.ariaTelemetryApplicationName) ?? defaultAriaConfig.ariaTelemetryApplicationName));
|
|
@@ -52,12 +52,15 @@ export const RegisterLoggers = () => {
|
|
|
52
52
|
loggers.push(logger);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
const chatConfigAppInsightsKey = (_TelemetryManager$Int22 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int22 === void 0 ? void 0 : _TelemetryManager$Int22.chatConfigAppInsightsKey;
|
|
56
|
+
const appInsightsKeyFromUser = (_TelemetryManager$Int23 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int23 === void 0 ? void 0 : (_TelemetryManager$Int24 = _TelemetryManager$Int23.appInsightsConfig) === null || _TelemetryManager$Int24 === void 0 ? void 0 : _TelemetryManager$Int24.appInsightsKey;
|
|
57
|
+
// when chatConfig has AppInsightsInstrumentationKey
|
|
58
|
+
if (chatConfigAppInsightsKey) {
|
|
59
|
+
loggers.push(appInsightsLogger(chatConfigAppInsightsKey));
|
|
60
|
+
}
|
|
61
|
+
// when key set through appInsightsConfig
|
|
62
|
+
else if (appInsightsKeyFromUser && ((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : (_TelemetryManager$Int26 = _TelemetryManager$Int25.appInsightsConfig) === null || _TelemetryManager$Int26 === void 0 ? void 0 : _TelemetryManager$Int26.appInsightsDisabled) === false) {
|
|
63
|
+
loggers.push(appInsightsLogger(appInsightsKeyFromUser));
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
};
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { LogLevel, TelemetryEvent } from "../TelemetryConstants";
|
|
1
|
+
import { ConversationStage, LogLevel, TelemetryEvent } from "../TelemetryConstants";
|
|
2
2
|
import ScenarioMarker from "../ScenarioMarker";
|
|
3
3
|
import { TelemetryHelper } from "../TelemetryHelper";
|
|
4
4
|
import { AppInsightsTelemetryMessage } from "../../Constants";
|
|
5
5
|
import { AppInsightsEventMapping } from "../AppInsightsEvents";
|
|
6
6
|
var AllowedKeys;
|
|
7
7
|
(function (AllowedKeys) {
|
|
8
|
-
AllowedKeys["
|
|
8
|
+
AllowedKeys["OrganizationId"] = "OrganizationId";
|
|
9
|
+
AllowedKeys["ConversationId"] = "LiveWorkItemId";
|
|
10
|
+
AllowedKeys["ElapsedTimeInMilliseconds"] = "Duration";
|
|
9
11
|
AllowedKeys["Description"] = "Description";
|
|
10
|
-
AllowedKeys["
|
|
11
|
-
AllowedKeys["ChannelId"] = "ChannelId";
|
|
12
|
+
AllowedKeys["ChannelId"] = "ChannelType";
|
|
12
13
|
AllowedKeys["LCWRuntimeId"] = "ClientSessionId";
|
|
13
|
-
AllowedKeys["ConversationId"] = "LiveWorkItemId";
|
|
14
|
-
AllowedKeys["ChatId"] = "ChatThreadId";
|
|
15
|
-
AllowedKeys["OrganizationId"] = "OrganizationId";
|
|
16
|
-
AllowedKeys["ElapsedTimeInMilliseconds"] = "DurationInMilliseconds";
|
|
17
14
|
})(AllowedKeys || (AllowedKeys = {}));
|
|
18
15
|
let initializationPromise = null;
|
|
19
16
|
export const appInsightsLogger = appInsightsKey => {
|
|
@@ -86,9 +83,9 @@ export const appInsightsLogger = appInsightsKey => {
|
|
|
86
83
|
if (!_logger) return;
|
|
87
84
|
const eventName = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$paylo = telemetryInput.payload) === null || _telemetryInput$paylo === void 0 ? void 0 : _telemetryInput$paylo.Event;
|
|
88
85
|
const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$telem = telemetryInput.telemetryInfo) === null || _telemetryInput$telem === void 0 ? void 0 : _telemetryInput$telem.telemetryInfo;
|
|
89
|
-
const eventProperties = setEventProperties(telemetryInfo);
|
|
90
86
|
if (eventName) {
|
|
91
87
|
const trackingEventName = getTrackingEventName(logLevel, eventName);
|
|
88
|
+
const eventProperties = setEventProperties(trackingEventName, telemetryInfo);
|
|
92
89
|
_logger.trackEvent({
|
|
93
90
|
name: trackingEventName,
|
|
94
91
|
properties: eventProperties
|
|
@@ -107,17 +104,36 @@ export const appInsightsLogger = appInsightsKey => {
|
|
|
107
104
|
};
|
|
108
105
|
|
|
109
106
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
|
-
function setEventProperties(telemetryInfo) {
|
|
107
|
+
function setEventProperties(eventName, telemetryInfo) {
|
|
111
108
|
const eventProperties = {};
|
|
112
109
|
if (telemetryInfo) {
|
|
113
110
|
for (const key in AllowedKeys) {
|
|
114
|
-
const finalKey = AllowedKeys[key]; // get renamed keys for LCWRuntimeId, ConversationId
|
|
111
|
+
const finalKey = AllowedKeys[key]; // get renamed keys for LCWRuntimeId, ConversationId
|
|
115
112
|
const value = telemetryInfo[key];
|
|
116
113
|
if (value !== undefined && value !== null && value !== "") {
|
|
117
114
|
eventProperties[finalKey] = value;
|
|
118
115
|
}
|
|
119
116
|
}
|
|
120
117
|
}
|
|
118
|
+
// Include exception details in description for error events
|
|
119
|
+
if (telemetryInfo !== null && telemetryInfo !== void 0 && telemetryInfo.ExceptionDetails) {
|
|
120
|
+
eventProperties[AllowedKeys.Description] = JSON.stringify(telemetryInfo.ExceptionDetails);
|
|
121
|
+
}
|
|
122
|
+
const customProperties = (() => {
|
|
123
|
+
if (!(telemetryInfo !== null && telemetryInfo !== void 0 && telemetryInfo.CustomProperties)) {
|
|
124
|
+
return {};
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
return typeof telemetryInfo.CustomProperties === "string" ? JSON.parse(telemetryInfo.CustomProperties) : telemetryInfo.CustomProperties;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.warn("Failed to parse CustomProperties:", error);
|
|
130
|
+
return {};
|
|
131
|
+
}
|
|
132
|
+
})();
|
|
133
|
+
// Additional properties
|
|
134
|
+
eventProperties["ConversationStage"] = customProperties.ConversationStage ?? ConversationStage.CSREngagement;
|
|
135
|
+
eventProperties["Scenario"] = "Conversation Diagnostics";
|
|
136
|
+
eventProperties["OperationName"] = eventName.includes(": ") ? eventName.split(": ")[1] : eventName;
|
|
121
137
|
return eventProperties;
|
|
122
138
|
}
|
|
123
139
|
function getTrackingEventName(logLevel, eventName) {
|
|
@@ -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 { createTimer, setFocusOnElement } from "../../common/utils";
|
|
4
4
|
import { ChatButton } from "@microsoft/omnichannel-chat-components";
|
|
@@ -17,7 +17,10 @@ export const ChatButtonStateful = props => {
|
|
|
17
17
|
uiTimer = createTimer();
|
|
18
18
|
TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
|
|
19
19
|
Event: TelemetryEvent.UXLCWChatButtonLoadingStart,
|
|
20
|
-
Description: "Chat button loading started"
|
|
20
|
+
Description: "Chat button loading started",
|
|
21
|
+
CustomProperties: {
|
|
22
|
+
ConversationStage: ConversationStage.Initialization
|
|
23
|
+
}
|
|
21
24
|
});
|
|
22
25
|
}, []);
|
|
23
26
|
|
|
@@ -40,7 +43,10 @@ export const ChatButtonStateful = props => {
|
|
|
40
43
|
ref.current = async () => {
|
|
41
44
|
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
42
45
|
Event: TelemetryEvent.LCWChatButtonClicked,
|
|
43
|
-
Description: "Chat button click action started"
|
|
46
|
+
Description: "Chat button click action started",
|
|
47
|
+
CustomProperties: {
|
|
48
|
+
ConversationStage: ConversationStage.Initialization
|
|
49
|
+
}
|
|
44
50
|
});
|
|
45
51
|
if (state.appStates.isMinimized) {
|
|
46
52
|
dispatch({
|
|
@@ -60,7 +66,10 @@ export const ChatButtonStateful = props => {
|
|
|
60
66
|
}
|
|
61
67
|
TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
|
|
62
68
|
Event: TelemetryEvent.LCWChatButtonActionCompleted,
|
|
63
|
-
Description: "Chat button action completed"
|
|
69
|
+
Description: "Chat button action completed",
|
|
70
|
+
CustomProperties: {
|
|
71
|
+
ConversationStage: ConversationStage.Initialization
|
|
72
|
+
}
|
|
64
73
|
});
|
|
65
74
|
};
|
|
66
75
|
const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
@@ -114,7 +123,10 @@ export const ChatButtonStateful = props => {
|
|
|
114
123
|
TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
|
|
115
124
|
Event: TelemetryEvent.UXLCWChatButtonLoadingCompleted,
|
|
116
125
|
Description: "Chat button loading completed",
|
|
117
|
-
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
126
|
+
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed,
|
|
127
|
+
CustomProperties: {
|
|
128
|
+
ConversationStage: ConversationStage.Initialization
|
|
129
|
+
}
|
|
118
130
|
});
|
|
119
131
|
}, []);
|
|
120
132
|
useEffect(() => {
|
|
@@ -33,7 +33,7 @@ export const CitationPaneStateful = props => {
|
|
|
33
33
|
const [paneStyle, setPaneStyle] = useState(null);
|
|
34
34
|
const [isReady, setIsReady] = useState(false);
|
|
35
35
|
|
|
36
|
-
//
|
|
36
|
+
// Initial focus pattern (mirrors ConfirmationPaneStateful): focus first focusable element (will re-attempt after visibility becomes true)
|
|
37
37
|
useEffect(() => {
|
|
38
38
|
preventFocusToMoveOutOfElement(controlId);
|
|
39
39
|
const focusableElements = findAllFocusableElement(`#${controlId}`);
|
|
@@ -55,6 +55,25 @@ export const CitationPaneStateful = props => {
|
|
|
55
55
|
});
|
|
56
56
|
}, []);
|
|
57
57
|
|
|
58
|
+
// Retry focus once pane is actually visible (isReady) in case initial attempt occurred while wrapper was visibility:hidden
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!isReady) return;
|
|
61
|
+
const focusableElements = findAllFocusableElement(`#${controlId}`);
|
|
62
|
+
if (focusableElements && focusableElements.length > 0) {
|
|
63
|
+
const first = focusableElements[0];
|
|
64
|
+
// If focused element is not already inside the pane, move focus
|
|
65
|
+
if (!first.contains(document.activeElement) && !(document.activeElement && document.activeElement.id.startsWith(controlId))) {
|
|
66
|
+
requestAnimationFrame(() => {
|
|
67
|
+
if (first.isConnected) {
|
|
68
|
+
first.focus({
|
|
69
|
+
preventScroll: true
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, [isReady, controlId]);
|
|
76
|
+
|
|
58
77
|
// Compute the widget bounds and set pane style accordingly (95% of widget size
|
|
59
78
|
// and centered inside the widget). If the widget container can't be found,
|
|
60
79
|
// fall back to the default pane styles from defaultCitationPaneProps.
|
|
@@ -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) {
|
|
@@ -3,6 +3,6 @@ var ChatWidgetEvents;
|
|
|
3
3
|
ChatWidgetEvents["ADD_ACTIVITY"] = "CHAT_WIDGET/ADD_ACTIVITY";
|
|
4
4
|
ChatWidgetEvents["FETCH_PERSISTENT_CHAT_HISTORY"] = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY";
|
|
5
5
|
ChatWidgetEvents["NO_MORE_HISTORY_AVAILABLE"] = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE";
|
|
6
|
-
ChatWidgetEvents["
|
|
6
|
+
ChatWidgetEvents["HISTORY_LOAD_ERROR"] = "CHAT_WIDGET/HISTORY_LOAD_ERROR";
|
|
7
7
|
})(ChatWidgetEvents || (ChatWidgetEvents = {}));
|
|
8
8
|
export default ChatWidgetEvents;
|
|
@@ -30,7 +30,7 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
|
30
30
|
_defineProperty(this, "facadeChatSDK", void 0);
|
|
31
31
|
_defineProperty(this, "lastMessage", null);
|
|
32
32
|
_defineProperty(this, "count", 0);
|
|
33
|
-
_defineProperty(this, "pageSize",
|
|
33
|
+
_defineProperty(this, "pageSize", defaultPersistentChatHistoryProps.pageSize);
|
|
34
34
|
_defineProperty(this, "isCurrentlyPulling", false);
|
|
35
35
|
_defineProperty(this, "pageTokenInTransitSet", new Set());
|
|
36
36
|
_defineProperty(this, "resetEventListener", BroadcastService.getMessageByEventName(BroadcastEvent.PersistentConversationReset).subscribe(() => {
|
|
@@ -42,18 +42,21 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
|
42
42
|
Event: TelemetryEvent.LCWPersistentConversationHandlerInitialized,
|
|
43
43
|
Description: "PersistentConversationHandler initialized",
|
|
44
44
|
CustomProperties: {
|
|
45
|
-
pageSize:
|
|
45
|
+
pageSize: defaultPersistentChatHistoryProps.pageSize
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
_createClass(PersistentConversationHandler, [{
|
|
50
50
|
key: "appliedPropsHandler",
|
|
51
51
|
value: function appliedPropsHandler(props) {
|
|
52
|
+
var _this$appliedProps;
|
|
52
53
|
this.appliedProps = {
|
|
53
54
|
...defaultPersistentChatHistoryProps,
|
|
54
55
|
...props
|
|
55
56
|
};
|
|
56
|
-
|
|
57
|
+
|
|
58
|
+
// if the props is not existent or is not a number then default to defaultPersistentChatHistoryProps.pageSize
|
|
59
|
+
this.pageSize = ((_this$appliedProps = this.appliedProps) === null || _this$appliedProps === void 0 ? void 0 : _this$appliedProps.pageSize) !== undefined && !isNaN(this.appliedProps.pageSize) ? this.appliedProps.pageSize : defaultPersistentChatHistoryProps.pageSize;
|
|
57
60
|
}
|
|
58
61
|
}, {
|
|
59
62
|
key: "reset",
|
|
@@ -98,12 +101,23 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
|
98
101
|
try {
|
|
99
102
|
var _ref;
|
|
100
103
|
const messages = await this.fetchHistoryMessages();
|
|
101
|
-
|
|
104
|
+
|
|
105
|
+
// Handle error case - null indicates an error occurred
|
|
106
|
+
// Don't mark as last pull to allow retry on next attempt
|
|
107
|
+
if (messages == null) {
|
|
108
|
+
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
109
|
+
Event: TelemetryEvent.LCWPersistentHistoryReturnedNull,
|
|
110
|
+
Description: "History pull returned null - Possible error occurred, will retry on next scroll",
|
|
111
|
+
ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed
|
|
112
|
+
});
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Handle legitimate end of history - empty array
|
|
117
|
+
if (messages.length === 0) {
|
|
102
118
|
this.isLastPull = true;
|
|
103
119
|
// Dispatch event to notify UI that no more history is available
|
|
104
120
|
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
105
|
-
// Also hide the loading banner
|
|
106
|
-
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
107
121
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
108
122
|
Event: TelemetryEvent.LCWPersistentHistoryPullCompleted,
|
|
109
123
|
Description: "History pull completed - no more messages",
|
|
@@ -113,9 +127,6 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
|
113
127
|
}
|
|
114
128
|
const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
|
|
115
129
|
this.processHistoryMessages(messagesDescOrder);
|
|
116
|
-
|
|
117
|
-
// Dispatch event to hide the loading banner after messages are processed
|
|
118
|
-
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
119
130
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
120
131
|
Event: TelemetryEvent.LCWPersistentHistoryPullCompleted,
|
|
121
132
|
Description: "History pull completed successfully",
|
|
@@ -171,7 +182,6 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
|
171
182
|
if (!this.shouldPull()) {
|
|
172
183
|
// Dispatch event to ensure banner is hidden when no more pulls are needed
|
|
173
184
|
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
174
|
-
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
175
185
|
return [];
|
|
176
186
|
}
|
|
177
187
|
const options = {
|
|
@@ -197,24 +207,20 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
|
197
207
|
this.isLastPull = true;
|
|
198
208
|
// Dispatch event when we reach the end of available history
|
|
199
209
|
dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
|
|
200
|
-
// Also hide the loading banner
|
|
201
|
-
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
202
210
|
return [];
|
|
203
211
|
}
|
|
204
|
-
dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
|
|
205
212
|
return messages;
|
|
206
213
|
} catch (error) {
|
|
207
214
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
208
215
|
Event: TelemetryEvent.FetchPersistentChatHistoryFailed,
|
|
209
216
|
ExceptionDetails: error
|
|
210
217
|
});
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
//
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
return [];
|
|
218
|
+
|
|
219
|
+
// On error, dispatch HISTORY_LOAD_ERROR to hide loading banner without marking conversation as ended
|
|
220
|
+
// This allows recovery on the next attempt (e.g., transient network errors)
|
|
221
|
+
// Return null to distinguish error from legitimate empty history
|
|
222
|
+
dispatchCustomEvent(ChatWidgetEvents.HISTORY_LOAD_ERROR);
|
|
223
|
+
return null;
|
|
218
224
|
}
|
|
219
225
|
}
|
|
220
226
|
}, {
|
|
@@ -195,6 +195,18 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
|
|
|
195
195
|
facadeChatSDK.destroy();
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
+
|
|
199
|
+
//moving logic below to before processing skipCloseChat logic to avoid race conditions of postMessage for endChatEvent for other tabs vs postMessage for CloseChat
|
|
200
|
+
//TODO: clarify if this postMessageToOtherTab actually works in production.
|
|
201
|
+
if (postMessageToOtherTab) {
|
|
202
|
+
const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
|
|
203
|
+
BroadcastService.postMessage({
|
|
204
|
+
eventName: endChatEventName,
|
|
205
|
+
payload: {
|
|
206
|
+
runtimeId: TelemetryManager.InternalTelemetryData.lcwRuntimeId
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
198
210
|
if (!skipCloseChat) {
|
|
199
211
|
try {
|
|
200
212
|
var _props$webChatContain;
|
|
@@ -234,17 +246,17 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
|
|
|
234
246
|
});
|
|
235
247
|
closeChatWidget(dispatch, setWebChatStyles, props);
|
|
236
248
|
facadeChatSDK.destroy();
|
|
249
|
+
|
|
250
|
+
//always post the close chat event after chat closed and cleanup completed
|
|
251
|
+
BroadcastService.postMessage({
|
|
252
|
+
eventName: BroadcastEvent.CloseChat
|
|
253
|
+
});
|
|
254
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
255
|
+
Event: TelemetryEvent.CloseChatCall,
|
|
256
|
+
Description: "Broadcasted close chat event"
|
|
257
|
+
});
|
|
237
258
|
}
|
|
238
259
|
}
|
|
239
|
-
if (postMessageToOtherTab) {
|
|
240
|
-
const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
|
|
241
|
-
BroadcastService.postMessage({
|
|
242
|
-
eventName: endChatEventName,
|
|
243
|
-
payload: {
|
|
244
|
-
runtimeId: TelemetryManager.InternalTelemetryData.lcwRuntimeId
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
260
|
};
|
|
249
261
|
export const callingStateCleanUp = dispatch => {
|
|
250
262
|
dispatch({
|
|
@@ -120,7 +120,14 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
|
|
|
120
120
|
};
|
|
121
121
|
webChatStore = createStore({},
|
|
122
122
|
//initial state
|
|
123
|
-
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), createCustomEventMiddleware(BroadcastService), createQueueOverflowMiddleware(state, dispatch), channelDataMiddleware(addConversationalSurveyTagsCallback), createConversationEndMiddleware(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, createMessageSequenceIdOverrideMiddleware, createCitationsMiddleware(state, dispatch), gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware(honorsTargetInHTMLLinks), createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, createCallActionMiddleware(),
|
|
123
|
+
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), createCustomEventMiddleware(BroadcastService), createQueueOverflowMiddleware(state, dispatch), channelDataMiddleware(addConversationalSurveyTagsCallback), createConversationEndMiddleware(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, createMessageSequenceIdOverrideMiddleware, createCitationsMiddleware(state, dispatch), gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware(honorsTargetInHTMLLinks), createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, createCallActionMiddleware(),
|
|
124
|
+
// Pass a callback so middleware can push initials into React context for reactivity
|
|
125
|
+
localizedStringsBotInitialsMiddleware(initials => {
|
|
126
|
+
dispatch({
|
|
127
|
+
type: LiveChatWidgetActionType.SET_BOT_AVATAR_INITIALS,
|
|
128
|
+
payload: initials
|
|
129
|
+
});
|
|
130
|
+
}),
|
|
124
131
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
132
|
...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
|
|
126
133
|
WebChatStoreLoader.store = webChatStore;
|
|
@@ -163,7 +170,7 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
|
|
|
163
170
|
dir: state.domainStates.globalDir,
|
|
164
171
|
locale: changeLanguageCodeFormatForWebChat(getLocaleStringFromId((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
|
|
165
172
|
store: webChatStore,
|
|
166
|
-
activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : createActivityMiddleware(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
|
|
173
|
+
activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : createActivityMiddleware(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps, localizedTexts),
|
|
167
174
|
attachmentMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableAttachmentMiddleware ? undefined : createAttachmentMiddleware(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? defaultAttachmentProps.enableInlinePlaying),
|
|
168
175
|
activityStatusMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableActivityStatusMiddleware ? undefined : createActivityStatusMiddleware(getLocaleStringFromId((_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : (_state$domainStates$l7 = _state$domainStates$l6.ChatWidgetLanguage) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.msdyn_localeid)),
|
|
169
176
|
toastMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableToastMiddleware ? undefined : createToastMiddleware(props.notificationPaneProps, endChat),
|
|
@@ -24,7 +24,10 @@ export const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
24
24
|
appInsightsConfig: Object.assign({}, defaultAppInsightsConfig, props.appInsightsConfig)
|
|
25
25
|
};
|
|
26
26
|
if (props.chatConfig) {
|
|
27
|
+
var _props$chatConfig$Liv;
|
|
27
28
|
telemetryData = TelemetryHelper.addChatConfigDataToTelemetry(props === null || props === void 0 ? void 0 : props.chatConfig, telemetryData);
|
|
29
|
+
//store AppInsights instrumentation key from chatConfig if present
|
|
30
|
+
telemetryData.chatConfigAppInsightsKey = (_props$chatConfig$Liv = props.chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.AppInsightsInstrumentationKey;
|
|
28
31
|
}
|
|
29
32
|
if (!((_props$chatSDK = props.chatSDK) !== null && _props$chatSDK !== void 0 && (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) !== null && _props$chatSDK$omnich !== void 0 && _props$chatSDK$omnich.orgId) || ((_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.orgId.trim().length) === 0) {
|
|
30
33
|
throw new Error("orgId is undefined in ChatSDK");
|