@microsoft/omnichannel-chat-widget 1.8.4-main.424a580 → 1.8.4-main.6672d3a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +27 -0
  2. package/lib/cjs/common/Constants.js +2 -0
  3. package/lib/cjs/common/telemetry/AppInsightsEvents.js +11 -5
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
  6. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
  7. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +24 -21
  8. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
  9. package/lib/cjs/components/livechatwidget/common/endChat.js +21 -9
  10. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  11. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +102 -26
  12. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +2 -2
  13. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +3 -11
  14. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +8 -2
  15. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
  16. package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  17. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
  18. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
  19. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  20. package/lib/esm/common/Constants.js +2 -0
  21. package/lib/esm/common/telemetry/AppInsightsEvents.js +11 -5
  22. package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
  23. package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
  24. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
  25. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +24 -21
  26. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
  27. package/lib/esm/components/livechatwidget/common/endChat.js +21 -9
  28. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  29. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +102 -26
  30. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +2 -2
  31. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +3 -14
  32. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +8 -2
  33. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
  34. package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  35. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
  36. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
  37. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  38. package/lib/types/common/Constants.d.ts +2 -0
  39. package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -0
  40. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
  41. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +1 -1
  42. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +0 -1
  43. package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
  44. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +1 -2
  45. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +1 -1
  46. package/package.json +1 -1
@@ -62,7 +62,7 @@ const createMagicCodeSuccessResponse = signin => {
62
62
  };
63
63
  };
64
64
  const WebChatContainerStateful = props => {
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;
65
+ var _props$webChatContain, _defaultWebChatContai, _extendedChatConfig$L, _extendedChatConfig$L2, _extendedChatConfig$L3, _extendedChatConfig$L4, _webChatContainerProp, _webChatContainerProp2, _webChatContainerProp3, _webChatContainerProp4, _webChatContainerProp5, _webChatContainerProp6, _webChatContainerProp7, _webChatContainerProp8, _props$webChatContain6, _props$webChatContain7, _defaultWebChatContai2, _props$webChatContain8, _props$webChatContain9, _defaultWebChatContai3, _webChatContainerProp9, _webChatContainerProp10, _webChatContainerProp11, _webChatContainerProp12, _webChatContainerProp13, _webChatContainerProp14, _webChatContainerProp15, _webChatContainerProp16, _webChatContainerProp17, _webChatContainerProp18, _webChatContainerProp19, _webChatContainerProp20, _webChatContainerProp21, _webChatContainerProp22, _webChatContainerProp23, _props$webChatContain10, _props$webChatContain11, _webChatContainerProp24, _webChatContainerProp25, _webChatContainerProp26, _webChatContainerProp27, _props$citationPanePr, _props$citationPanePr2, _props$citationPanePr3, _props$citationPanePr4, _props$citationPanePr5;
66
66
  const [facadeChatSDK] = (0, _useFacadeChatSDKStore.default)();
67
67
 
68
68
  // Create a font family that includes emoji support, based on the primary font or default
@@ -96,18 +96,12 @@ const WebChatContainerStateful = props => {
96
96
 
97
97
  // Type the chatConfig properly to avoid 'any' usage
98
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
99
  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
100
  const isHistoryEnabledViaFCB = extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L2 = extendedChatConfig.LcwFcbConfiguration) === null || _extendedChatConfig$L2 === void 0 ? void 0 : _extendedChatConfig$L2.lcwPersistentChatHistoryEnabled;
102
101
  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
102
 
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
103
  // Check if both persistent chat and widget support are enabled
110
- const shouldLoadPersistentHistoryMessages = isPersistentHistoryEnabled && isHistoryEnabledViaFCB && isPersistentChatEnabledForWidget;
104
+ const shouldLoadPersistentHistoryMessages = isHistoryEnabledInConfig && isHistoryEnabledViaFCB && isPersistentChatEnabledForWidget;
111
105
  if (shouldLoadPersistentHistoryMessages) {
112
106
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
113
107
  Event: _TelemetryConstants.TelemetryEvent.PersistentChatHistoryEnabled
@@ -421,9 +415,7 @@ const WebChatContainerStateful = props => {
421
415
  height: "100%",
422
416
  width: "100%"
423
417
  }
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, {
418
+ }, shouldLoadPersistentHistoryMessages && /*#__PURE__*/_react2.default.createElement(_WebChatEventSubscribers.default, null), /*#__PURE__*/_react2.default.createElement(BasicWebChat, null))), citationPaneOpen && /*#__PURE__*/_react2.default.createElement(_CitationPaneStateful.default, {
427
419
  id: ((_props$citationPanePr = props.citationPaneProps) === null || _props$citationPanePr === void 0 ? void 0 : _props$citationPanePr.id) || _Constants.HtmlAttributeNames.ocwCitationPaneClassName,
428
420
  title: ((_props$citationPanePr2 = props.citationPaneProps) === null || _props$citationPanePr2 === void 0 ? void 0 : _props$citationPanePr2.title) || _Constants.HtmlAttributeNames.ocwCitationPaneTitle,
429
421
  contentHtml: citationPaneText,
@@ -62,11 +62,17 @@ const convertPersistentChatHistoryMessageToActivity = message => {
62
62
  }
63
63
  if (tags) {
64
64
  const formattedTags = additionalData.tags.split(",");
65
- activity.channelData.tags = [...activity.channelData.tags, ...formattedTags];
65
+ activity.channelData = {
66
+ ...activity.channelData,
67
+ tags: [...activity.channelData.tags, ...formattedTags]
68
+ };
66
69
  }
67
70
  }
68
71
  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;
72
+ activity.from = {
73
+ ...activity.from,
74
+ name: from.user.displayName
75
+ };
70
76
  }
71
77
  if ((from === null || from === void 0 ? void 0 : (_from$application = from.application) === null || _from$application === void 0 ? void 0 : _from$application.displayName) === "Customer") {
72
78
  activity.from = {
@@ -8,9 +8,8 @@ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants"
8
8
  var _react = require("react");
9
9
  var _ChatWidgetEvents = _interopRequireDefault(require("../../livechatwidget/common/ChatWidgetEvents"));
10
10
  var _PersistentConversationHandler = _interopRequireDefault(require("../../livechatwidget/common/PersistentConversationHandler"));
11
- var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
12
- var _dispatchCustomEvent = _interopRequireDefault(require("../../../common/utils/dispatchCustomEvent"));
13
11
  var _SecureEventBus = _interopRequireDefault(require("../../../common/utils/SecureEventBus"));
12
+ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
14
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
14
  const usePersistentChatHistory = (facadeChatSDK, props) => {
16
15
  const handlerRef = (0, _react.useRef)(null);
@@ -31,7 +30,6 @@ const usePersistentChatHistory = (facadeChatSDK, props) => {
31
30
  try {
32
31
  var _handlerRef$current;
33
32
  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
33
  _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
36
34
  Event: _TelemetryConstants.TelemetryEvent.LCWPersistentChatHistoryFetchCompleted,
37
35
  Description: "Persistent chat history fetch completed successfully"
@@ -17,14 +17,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
17
  * Component to handle persistent chat history events.
18
18
  * Uses WebChatStoreLoader instead of hooks to avoid context issues.
19
19
  */
20
- const WebChatEventSubscribers = props => {
20
+ const WebChatEventSubscribers = () => {
21
21
  const [isConnected, setIsConnected] = (0, _react.useState)(false);
22
22
  const [storeReady, setStoreReady] = (0, _react.useState)(false);
23
23
  const storeWaitTimer = (0, _utils.createTimer)();
24
+ // Type the chatConfig properly to avoid 'any' usage
25
+
24
26
  (0, _react.useEffect)(() => {
25
- if (!props.persistentChatHistoryEnabled) {
26
- return;
27
- }
28
27
  _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
29
28
  Event: _TelemetryConstants.TelemetryEvent.LCWWebChatStorePollingStarted,
30
29
  Description: "WebChat store polling started"
@@ -56,9 +55,9 @@ const WebChatEventSubscribers = props => {
56
55
  clearInterval(storeCheckInterval);
57
56
  };
58
57
  }
59
- }, [props.persistentChatHistoryEnabled]);
58
+ }, []);
60
59
  (0, _react.useEffect)(() => {
61
- if (!props.persistentChatHistoryEnabled || !storeReady) {
60
+ if (!storeReady) {
62
61
  return;
63
62
  }
64
63
  const checkConnectionStatus = () => {
@@ -115,7 +114,7 @@ const WebChatEventSubscribers = props => {
115
114
  return () => {
116
115
  clearInterval(interval);
117
116
  };
118
- }, [isConnected, props.persistentChatHistoryEnabled, storeReady]);
117
+ }, [isConnected, storeReady]);
119
118
  return null;
120
119
  };
121
120
  var _default = WebChatEventSubscribers;
@@ -62,7 +62,7 @@ let LazyLoadHandler = /*#__PURE__*/function () {
62
62
 
63
63
  // Scroll operation state
64
64
  // Current scroll operation tracking
65
- // Prevents concurrent scroll operations
65
+ // Prevents concurrent scroll operations (public for event handlers)
66
66
 
67
67
  // Timeout and queue management
68
68
  // Tracks all setTimeout IDs for cleanup
@@ -934,6 +934,21 @@ const LazyLoadActivity = props => {
934
934
  setHasMoreHistory(false);
935
935
  };
936
936
 
937
+ // Event listener for HISTORY_LOAD_ERROR - hides banner temporarily without disabling future loads
938
+ const handleHistoryLoadError = () => {
939
+ // Temporarily hide the banner by pausing, but keep hasMoreHistory true to allow retry
940
+ LazyLoadHandler.paused = true;
941
+ LazyLoadHandler.pendingScrollAction = false;
942
+
943
+ // Re-enable after a delay to allow retry on next scroll
944
+ // Note: This timeout is intentionally not tracked as it's scoped to the component lifecycle
945
+ window.setTimeout(() => {
946
+ LazyLoadHandler.paused = false;
947
+ }, 2000); // 2 second delay before allowing retry
948
+
949
+ LazyLoadHandler.logLifecycleEvent(_TelemetryConstants.TelemetryEvent.LCWLazyLoadHistoryError, "History load error - will retry on next scroll");
950
+ };
951
+
937
952
  // Event listener for PersistentConversationReset to sync React state
938
953
  // This fixes the issue where banner doesn't appear in start chat + close chat + start chat sequence
939
954
  // by ensuring React state (hasMoreHistory) is synchronized with handler state when reset occurs
@@ -946,6 +961,9 @@ const LazyLoadActivity = props => {
946
961
  const eventBus = _SecureEventBus.default.getInstance();
947
962
  const unsubscribeNoMoreHistory = eventBus.subscribe(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE, handleNoMoreHistory);
948
963
 
964
+ // Add event listener for history load errors
965
+ const unsubscribeHistoryError = eventBus.subscribe(_ChatWidgetEvents.default.HISTORY_LOAD_ERROR, handleHistoryLoadError);
966
+
949
967
  // Add event listener for persistent conversation reset
950
968
  const resetSubscription = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.PersistentConversationReset).subscribe(handlePersistentConversationReset);
951
969
 
@@ -962,6 +980,7 @@ const LazyLoadActivity = props => {
962
980
  // Still need to return cleanup function even after reset
963
981
  return () => {
964
982
  unsubscribeNoMoreHistory();
983
+ unsubscribeHistoryError();
965
984
  resetSubscription.unsubscribe();
966
985
  };
967
986
  }
@@ -1014,6 +1033,7 @@ const LazyLoadActivity = props => {
1014
1033
 
1015
1034
  // Remove event listeners
1016
1035
  unsubscribeNoMoreHistory();
1036
+ unsubscribeHistoryError();
1017
1037
  resetSubscription.unsubscribe();
1018
1038
  if (container) {
1019
1039
  container.removeEventListener("scroll", handleScroll);
@@ -32,7 +32,12 @@ const createCitationsMiddleware = (state, dispatch) => () => next => action => {
32
32
  const citations = (_gptFeedback$summariz = gptFeedback.summarizationOpenAIResponse) === null || _gptFeedback$summariz === void 0 ? void 0 : (_gptFeedback$summariz2 = _gptFeedback$summariz.result) === null || _gptFeedback$summariz2 === void 0 ? void 0 : _gptFeedback$summariz2.textCitations;
33
33
  // Rewrite inline citation labels in activity.text to match the global map keys
34
34
  const updatedText = replaceCitations(action.payload.activity.text, citations, messagePrefix);
35
- action.payload.activity.text = updatedText;
35
+
36
+ // Create new activity object to avoid mutation
37
+ action.payload.activity = {
38
+ ...action.payload.activity,
39
+ text: updatedText
40
+ };
36
41
  // Build a global citation map keyed by the prefixed citation id and
37
42
  // dispatch it to app state so the UI container can render citations.
38
43
  try {
@@ -136,6 +136,7 @@ _defineProperty(Constants, "customEventName", "customEventName");
136
136
  _defineProperty(Constants, "customEventValue", "customEventValue");
137
137
  _defineProperty(Constants, "Hidden", "Hidden");
138
138
  _defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
139
+ _defineProperty(Constants, "SkipSessionCloseForPersistentChatFlag", "skipSessionCloseForPersistentChat");
139
140
  export const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
140
141
  _classCallCheck(this, Regex);
141
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);
@@ -345,6 +346,7 @@ _defineProperty(PrepareEndChatDescriptionConstants, "ConversationEndedBy", "Conv
345
346
  _defineProperty(PrepareEndChatDescriptionConstants, "PrepareEndChatError", "There's an error while preparing to end chat. Closing chat widget.");
346
347
  _defineProperty(PrepareEndChatDescriptionConstants, "WidgetLoadFailedAfterSessionInit", "SessionInit was successful, but widget load failed. Ending chat to avoid ghost chats in OC.");
347
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.");
348
350
  _defineProperty(PrepareEndChatDescriptionConstants, "EndChatReceivedFromOtherTabs", "Received EndChat BroadcastEvent from other tabs. Closing this chat.");
349
351
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseChatOnFailureOrPostChat", "Customer is trying to close chat widget on start chat failure or post chat pane.");
350
352
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseInactiveChat", "Chat was Inactive and customer is trying to close chat widget or refreshing the page.");
@@ -1,7 +1,10 @@
1
1
  export const AppInsightsEventMapping = {
2
2
  "LCWChatButtonClicked": "LCWChatButtonActionStarted",
3
- "PrechatSubmitted": "PrechatSubmitCompleted",
4
- "StartChatEventRecevied": "StartChatEventReceivedCompleted",
3
+ "UXLCWChatButtonLoadingStart": "LiveChatWidgetChatButtonLoadingStarted",
4
+ "UXLCWChatButtonLoadingCompleted": "LiveChatWidgetChatButtonLoadingCompleted",
5
+ "UXPrechatPaneStart": "PrechatSurveyStarted",
6
+ "UXPrechatPaneCompleted": "PrechatSurveyCompleted",
7
+ "PrechatSubmitted": "PrechatSurveySubmitCompleted",
5
8
  "EndChatEventReceived": "EndChatEventReceivedCompleted",
6
9
  "EmailTranscriptSent": "EmailTranscriptActionCompleted",
7
10
  "EmailTranscriptFailed": "EmailTranscriptActionFailed",
@@ -9,8 +12,6 @@ export const AppInsightsEventMapping = {
9
12
  "HeaderMinimizeButtonClicked": "MinimizeChatActionStarted",
10
13
  "DownloadTranscriptButtonClicked": "DownloadTranscriptActionStarted",
11
14
  "EmailTranscriptButtonClicked": "EmailTranscriptButtonActionStarted",
12
- "CustomerVoiceFormResponseSubmitted": "CustomerVoiceFormResponseSubmitCompleted",
13
- "StartProactiveChatEventReceived": "StartProactiveChatEventReceivedCompleted",
14
15
  "ProactiveChatRejected": "ProactiveChatTimeOutCompleted",
15
16
  "MessageSent": "MessageSentCompleted",
16
17
  "MessageReceived": "MessageReceivedCompleted",
@@ -19,5 +20,10 @@ export const AppInsightsEventMapping = {
19
20
  "CustomContextReceived": "CustomContextReceivedCompleted",
20
21
  "NewTokenValidationStarted": "AuthTokenValidationStarted",
21
22
  "NewTokenValidationCompleted": "AuthTokenValidationCompleted",
22
- "NewTokenValidationFailed": "AuthTokenValidationFailed"
23
+ "NewTokenValidationFailed": "AuthTokenValidationFailed",
24
+ "UXPostChatPaneStarted": "PostChatSurveyStarted",
25
+ "UXPostChatPaneCompleted": "PostChatSurveyCompleted",
26
+ "WidgetLoadStarted": "ChatSessionInitializationStarted",
27
+ "WidgetLoadComplete": "ChatSessionInitializationCompleted",
28
+ "WidgetLoadFailed": "ChatSessionInitializationFailed"
23
29
  };
@@ -300,6 +300,7 @@ export let TelemetryEvent;
300
300
  TelemetryEvent["LCWPersistentConversationHandlerInitialized"] = "LCWPersistentConversationHandlerInitialized";
301
301
  TelemetryEvent["LCWPersistentHistoryPullBlocked"] = "LCWPersistentHistoryPullBlocked";
302
302
  TelemetryEvent["LCWPersistentHistoryPullCompleted"] = "LCWPersistentHistoryPullCompleted";
303
+ TelemetryEvent["LCWPersistentHistoryReturnedNull"] = "LCWPersistentHistoryReturnedNull";
303
304
  TelemetryEvent["LCWLazyLoadInitializationStarted"] = "LCWLazyLoadInitializationStarted";
304
305
  TelemetryEvent["LCWLazyLoadContainerNotFound"] = "LCWLazyLoadContainerNotFound";
305
306
  TelemetryEvent["LCWLazyLoadInitializationCompleted"] = "LCWLazyLoadInitializationCompleted";
@@ -309,6 +310,7 @@ export let TelemetryEvent;
309
310
  TelemetryEvent["LCWLazyLoadActivityMounted"] = "LCWLazyLoadActivityMounted";
310
311
  TelemetryEvent["LCWLazyLoadReset"] = "LCWLazyLoadReset";
311
312
  TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
313
+ TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
312
314
  TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
313
315
  TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
314
316
  TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
@@ -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
- if (((_TelemetryManager$Int22 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int22 === void 0 ? void 0 : (_TelemetryManager$Int23 = _TelemetryManager$Int22.appInsightsConfig) === null || _TelemetryManager$Int23 === void 0 ? void 0 : _TelemetryManager$Int23.appInsightsDisabled) === false) {
56
- var _TelemetryManager$Int24;
57
- if ((_TelemetryManager$Int24 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int24 !== void 0 && _TelemetryManager$Int24.appInsightsConfig.appInsightsKey) {
58
- var _TelemetryManager$Int25;
59
- loggers.push(appInsightsLogger((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : _TelemetryManager$Int25.appInsightsConfig.appInsightsKey));
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
  };
@@ -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["HIDE_LOADING_BANNER"] = "CHAT_WIDGET/HIDE_LOADING_BANNER";
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", 4);
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,7 +42,7 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
42
42
  Event: TelemetryEvent.LCWPersistentConversationHandlerInitialized,
43
43
  Description: "PersistentConversationHandler initialized",
44
44
  CustomProperties: {
45
- pageSize: this.pageSize
45
+ pageSize: defaultPersistentChatHistoryProps.pageSize
46
46
  }
47
47
  });
48
48
  }
@@ -55,8 +55,8 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
55
55
  ...props
56
56
  };
57
57
 
58
- // if the props is not existent or is not anumber then default to 4
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 : 4;
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;
60
60
  }
61
61
  }, {
62
62
  key: "reset",
@@ -101,12 +101,23 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
101
101
  try {
102
102
  var _ref;
103
103
  const messages = await this.fetchHistoryMessages();
104
- if (messages === null || (messages === null || messages === void 0 ? void 0 : messages.length) === 0) {
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) {
105
118
  this.isLastPull = true;
106
119
  // Dispatch event to notify UI that no more history is available
107
120
  dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
108
- // Also hide the loading banner
109
- dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
110
121
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
111
122
  Event: TelemetryEvent.LCWPersistentHistoryPullCompleted,
112
123
  Description: "History pull completed - no more messages",
@@ -116,9 +127,6 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
116
127
  }
117
128
  const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
118
129
  this.processHistoryMessages(messagesDescOrder);
119
-
120
- // Dispatch event to hide the loading banner after messages are processed
121
- dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
122
130
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
123
131
  Event: TelemetryEvent.LCWPersistentHistoryPullCompleted,
124
132
  Description: "History pull completed successfully",
@@ -174,7 +182,6 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
174
182
  if (!this.shouldPull()) {
175
183
  // Dispatch event to ensure banner is hidden when no more pulls are needed
176
184
  dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
177
- dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
178
185
  return [];
179
186
  }
180
187
  const options = {
@@ -200,24 +207,20 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
200
207
  this.isLastPull = true;
201
208
  // Dispatch event when we reach the end of available history
202
209
  dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
203
- // Also hide the loading banner
204
- dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
205
210
  return [];
206
211
  }
207
- dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
208
212
  return messages;
209
213
  } catch (error) {
210
214
  TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
211
215
  Event: TelemetryEvent.FetchPersistentChatHistoryFailed,
212
216
  ExceptionDetails: error
213
217
  });
214
- this.isLastPull = true;
215
- this.pageToken = null;
216
- // Dispatch event when there's an error to stop loading banner
217
- dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
218
- // Also hide the loading banner
219
- dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
220
- 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;
221
224
  }
222
225
  }
223
226
  }, {
@@ -1,6 +1,5 @@
1
1
  export const defaultPersistentChatHistoryProps = {
2
- persistentChatHistoryEnabled: true,
3
- pageSize: 4,
2
+ pageSize: 10,
4
3
  dividerActivityStyle: {
5
4
  border: "1px solid rgb(96, 94, 92, 0.5)",
6
5
  margin: "10px 20%"
@@ -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({
@@ -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");