@microsoft/omnichannel-chat-widget 1.8.4-main.7bdb634 → 1.8.4-main.c687f88

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 (104) hide show
  1. package/README.md +27 -0
  2. package/lib/cjs/common/Constants.js +3 -0
  3. package/lib/cjs/common/telemetry/AppInsightsEvents.js +14 -9
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +15 -2
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
  6. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +29 -13
  7. package/lib/cjs/common/utils.js +14 -1
  8. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
  9. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +20 -1
  10. package/lib/cjs/components/errorboundary/ErrorBoundary.js +2 -1
  11. package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
  12. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
  13. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +26 -20
  14. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
  15. package/lib/cjs/components/livechatwidget/common/endChat.js +26 -9
  16. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +9 -2
  17. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
  18. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  19. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  20. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  21. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
  22. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
  23. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -28
  24. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +37 -8
  25. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
  26. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +28 -30
  27. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +12 -12
  28. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  29. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
  30. package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  31. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +30 -1
  33. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -2
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -0
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  38. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
  39. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
  40. package/lib/cjs/contexts/createReducer.js +15 -0
  41. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  42. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  43. package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
  44. package/lib/esm/common/Constants.js +3 -0
  45. package/lib/esm/common/telemetry/AppInsightsEvents.js +14 -9
  46. package/lib/esm/common/telemetry/TelemetryConstants.js +13 -1
  47. package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
  48. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +30 -14
  49. package/lib/esm/common/utils.js +11 -0
  50. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
  51. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +20 -1
  52. package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -2
  53. package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
  54. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
  55. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +26 -20
  56. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
  57. package/lib/esm/components/livechatwidget/common/endChat.js +26 -9
  58. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +9 -2
  59. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
  60. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  61. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  62. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  63. package/lib/esm/components/livechatwidget/common/startChat.js +7 -3
  64. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
  65. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +125 -29
  66. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +39 -10
  67. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
  68. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +29 -34
  69. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +12 -12
  70. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  71. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
  72. package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  73. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
  74. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +30 -1
  75. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
  76. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -2
  77. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -0
  78. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -0
  79. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  80. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  81. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
  82. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
  83. package/lib/esm/contexts/createReducer.js +15 -0
  84. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  85. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  86. package/lib/esm/plugins/newMessageEventHandler.js +4 -1
  87. package/lib/types/common/Constants.d.ts +3 -0
  88. package/lib/types/common/telemetry/TelemetryConstants.d.ts +12 -1
  89. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
  90. package/lib/types/common/utils.d.ts +9 -1
  91. package/lib/types/components/errorboundary/ErrorBoundary.d.ts +1 -1
  92. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +1 -1
  93. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
  94. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
  95. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +5 -1
  96. package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
  97. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +1 -2
  98. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +1 -1
  99. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
  100. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
  101. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  102. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +5 -0
  103. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
  104. package/package.json +3 -3
package/README.md CHANGED
@@ -268,6 +268,33 @@ const customizedFooterProp: IFooterProps = {
268
268
  setOnCustomEvent((event) => console.log(event));
269
269
  ```
270
270
 
271
+ #### Trigger initiateEndChat event
272
+ Customer can trigger the initiateEndChat event via BroadcastService to end a chat session.
273
+ When needed, the payload below could be triggered:
274
+ ```js
275
+ const endChatEvent = {
276
+ eventName: "InitiateEndChat",
277
+ payload: {
278
+ skipSessionCloseForPersistentChat: true
279
+ } //optional payload
280
+ };
281
+ BroadcastService.postMessage(endChatEvent);
282
+ ```
283
+
284
+ The payload of the event is optional, only needed when force closing of a persistent chat session is not required.
285
+ When chat widget receives the event without any payload, it will:
286
+ 1. set the widget to closed state, the widget panel will be minimized. Post chat survey will not be displayed.
287
+ 2. trigger a sessionclose service network request to OmniChannel services.
288
+
289
+ If skipSessionCloseForPersistentChat is set to true. The session close network request will not be triggered, instead, if postChat survey is available, post chat survey will be displayed.
290
+
291
+ After successfully processed initiateEndChat event. The CloseChat event is broadcasted.
292
+ ```js
293
+ BroadcastService.getMessageByEventName("CloseChat").subscribe(async (msg) => {
294
+ console.log("close chat received: ", msg);
295
+ //more actions to unmount component and resources
296
+ })
297
+ ```
271
298
  ## See Also
272
299
 
273
300
  [Customizations Dev Guide](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/customizations/getstarted.md)\
@@ -68,6 +68,7 @@ _defineProperty(Constants, "queuePositionMessageTag", "queueposition");
68
68
  _defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
69
69
  _defineProperty(Constants, "message", "message");
70
70
  _defineProperty(Constants, "hiddenTag", "Hidden");
71
+ _defineProperty(Constants, "typing", "typing");
71
72
  // messageTimestampMiddleware
72
73
  _defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
73
74
  _defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
@@ -142,6 +143,7 @@ _defineProperty(Constants, "customEventName", "customEventName");
142
143
  _defineProperty(Constants, "customEventValue", "customEventValue");
143
144
  _defineProperty(Constants, "Hidden", "Hidden");
144
145
  _defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
146
+ _defineProperty(Constants, "SkipSessionCloseForPersistentChatFlag", "skipSessionCloseForPersistentChat");
145
147
  const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
146
148
  _classCallCheck(this, Regex);
147
149
  }), _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);
@@ -377,6 +379,7 @@ _defineProperty(PrepareEndChatDescriptionConstants, "ConversationEndedBy", "Conv
377
379
  _defineProperty(PrepareEndChatDescriptionConstants, "PrepareEndChatError", "There's an error while preparing to end chat. Closing chat widget.");
378
380
  _defineProperty(PrepareEndChatDescriptionConstants, "WidgetLoadFailedAfterSessionInit", "SessionInit was successful, but widget load failed. Ending chat to avoid ghost chats in OC.");
379
381
  _defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceived", "Received InitiateEndChat BroadcastEvent while conversation state is not Active. Ending chat.");
382
+ _defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceivedActiveChat", "Received InitiateEndChat BroadcastEvent while conversation state is Active. Updating conversation states.");
380
383
  _defineProperty(PrepareEndChatDescriptionConstants, "EndChatReceivedFromOtherTabs", "Received EndChat BroadcastEvent from other tabs. Closing this chat.");
381
384
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseChatOnFailureOrPostChat", "Customer is trying to close chat widget on start chat failure or post chat pane.");
382
385
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseInactiveChat", "Chat was Inactive and customer is trying to close chat widget or refreshing the page.");
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.AppInsightsEventMapping = void 0;
7
7
  const AppInsightsEventMapping = {
8
8
  "LCWChatButtonClicked": "LCWChatButtonActionStarted",
9
- "WidgetLoadStarted": "WidgetStartChatStarted",
10
- "WidgetLoadComplete": "WidgetStartChatCompleted",
11
- "WidgetLoadFailed": "WidgetStartChatFailed",
12
- "PrechatSubmitted": "PrechatSubmitCompleted",
13
- "StartChatEventRecevied": "StartChatEventReceivedCompleted",
9
+ "UXLCWChatButtonLoadingStart": "LiveChatWidgetChatButtonLoadingStarted",
10
+ "UXLCWChatButtonLoadingCompleted": "LiveChatWidgetChatButtonLoadingCompleted",
11
+ "UXPrechatPaneStart": "PrechatSurveyStarted",
12
+ "UXPrechatPaneCompleted": "PrechatSurveyCompleted",
13
+ "PrechatSubmitted": "PrechatSurveySubmitCompleted",
14
14
  "EndChatEventReceived": "EndChatEventReceivedCompleted",
15
15
  "EmailTranscriptSent": "EmailTranscriptActionCompleted",
16
16
  "EmailTranscriptFailed": "EmailTranscriptActionFailed",
@@ -18,14 +18,19 @@ const AppInsightsEventMapping = {
18
18
  "HeaderMinimizeButtonClicked": "MinimizeChatActionStarted",
19
19
  "DownloadTranscriptButtonClicked": "DownloadTranscriptActionStarted",
20
20
  "EmailTranscriptButtonClicked": "EmailTranscriptButtonActionStarted",
21
- "CustomerVoiceFormResponseSubmitted": "CustomerVoiceFormResponseSubmitCompleted",
22
- "StartProactiveChatEventReceived": "StartProactiveChatEventReceivedCompleted",
23
21
  "ProactiveChatRejected": "ProactiveChatTimeOutCompleted",
24
22
  "MessageSent": "MessageSentCompleted",
25
23
  "MessageReceived": "MessageReceivedCompleted",
26
24
  "SystemMessageReceived": "SystemMessageReceivedCompleted",
27
- "RehydrateMessageReceived": "RehydrateMessageReceivedCompleted",
25
+ "RehydrateMessageReceived": "ChatHistoryMessageReceivedCompleted",
28
26
  "CustomContextReceived": "CustomContextReceivedCompleted",
29
- "PostChatContextCallSucceed": "PostChatContextCallCompleted"
27
+ "NewTokenValidationStarted": "AuthTokenValidationStarted",
28
+ "NewTokenValidationCompleted": "AuthTokenValidationCompleted",
29
+ "NewTokenValidationFailed": "AuthTokenValidationFailed",
30
+ "UXPostChatPaneStarted": "PostChatSurveyStarted",
31
+ "UXPostChatPaneCompleted": "PostChatSurveyCompleted",
32
+ "WidgetLoadStarted": "ChatSessionInitializationStarted",
33
+ "WidgetLoadComplete": "ChatSessionInitializationCompleted",
34
+ "WidgetLoadFailed": "ChatSessionInitializationFailed"
30
35
  };
31
36
  exports.AppInsightsEventMapping = AppInsightsEventMapping;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TelemetryEvent = exports.TelemetryConstants = exports.ScenarioType = exports.LogLevel = exports.BroadcastEvent = void 0;
6
+ exports.TelemetryEvent = exports.TelemetryConstants = exports.ScenarioType = exports.LogLevel = exports.ConversationStage = exports.BroadcastEvent = void 0;
7
7
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
8
  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); } }
9
9
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -124,6 +124,7 @@ exports.TelemetryEvent = TelemetryEvent;
124
124
  TelemetryEvent["EndChatFailed"] = "EndChatFailed";
125
125
  TelemetryEvent["SettingCustomContext"] = "SettingCustomContext";
126
126
  TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
127
+ TelemetryEvent["PersistentChatHistoryEnabled"] = "PersistentChatHistoryEnabled";
127
128
  TelemetryEvent["LCWChatButtonActionCompleted"] = "LCWChatButtonActionCompleted";
128
129
  TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
129
130
  TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
@@ -288,6 +289,8 @@ exports.TelemetryEvent = TelemetryEvent;
288
289
  TelemetryEvent["UXCitationPaneCompleted"] = "UXCitationPaneCompleted";
289
290
  TelemetryEvent["UXLiveChatWidgetStart"] = "UXLiveChatWidgetStart";
290
291
  TelemetryEvent["UXLiveChatWidgetCompleted"] = "UXLiveChatWidgetCompleted";
292
+ TelemetryEvent["UXPostChatPaneStarted"] = "UXPostChatPaneStarted";
293
+ TelemetryEvent["UXPostChatPaneCompleted"] = "UXPostChatPaneCompleted";
291
294
  TelemetryEvent["AppInsightsInitialized"] = "AppInsightsInitialized";
292
295
  TelemetryEvent["AppInsightsInitFailed"] = "AppInsightsInitFailed";
293
296
  TelemetryEvent["ConvertPersistentChatHistoryMessageToActivityFailed"] = "ConvertPersistentChatHistoryMessageToActivityFailed";
@@ -303,6 +306,7 @@ exports.TelemetryEvent = TelemetryEvent;
303
306
  TelemetryEvent["LCWPersistentConversationHandlerInitialized"] = "LCWPersistentConversationHandlerInitialized";
304
307
  TelemetryEvent["LCWPersistentHistoryPullBlocked"] = "LCWPersistentHistoryPullBlocked";
305
308
  TelemetryEvent["LCWPersistentHistoryPullCompleted"] = "LCWPersistentHistoryPullCompleted";
309
+ TelemetryEvent["LCWPersistentHistoryReturnedNull"] = "LCWPersistentHistoryReturnedNull";
306
310
  TelemetryEvent["LCWLazyLoadInitializationStarted"] = "LCWLazyLoadInitializationStarted";
307
311
  TelemetryEvent["LCWLazyLoadContainerNotFound"] = "LCWLazyLoadContainerNotFound";
308
312
  TelemetryEvent["LCWLazyLoadInitializationCompleted"] = "LCWLazyLoadInitializationCompleted";
@@ -312,10 +316,12 @@ exports.TelemetryEvent = TelemetryEvent;
312
316
  TelemetryEvent["LCWLazyLoadActivityMounted"] = "LCWLazyLoadActivityMounted";
313
317
  TelemetryEvent["LCWLazyLoadReset"] = "LCWLazyLoadReset";
314
318
  TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
319
+ TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
315
320
  TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
316
321
  TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
317
322
  TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
318
323
  TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
324
+ TelemetryEvent["StartChatComplete"] = "StartChatComplete";
319
325
  })(TelemetryEvent || (exports.TelemetryEvent = TelemetryEvent = {}));
320
326
  let TelemetryConstants = /*#__PURE__*/function () {
321
327
  function TelemetryConstants() {
@@ -446,4 +452,11 @@ let TelemetryConstants = /*#__PURE__*/function () {
446
452
  }]);
447
453
  return TelemetryConstants;
448
454
  }();
449
- exports.TelemetryConstants = TelemetryConstants;
455
+ exports.TelemetryConstants = TelemetryConstants;
456
+ let ConversationStage;
457
+ exports.ConversationStage = ConversationStage;
458
+ (function (ConversationStage) {
459
+ ConversationStage["Initialization"] = "Initialization";
460
+ ConversationStage["CSREngagement"] = "CSR Engagement";
461
+ ConversationStage["ConversationEnd"] = "Conversation End";
462
+ })(ConversationStage || (exports.ConversationStage = ConversationStage = {}));
@@ -50,7 +50,7 @@ const RegisterLoggers = () => {
50
50
  loggers.push((0, _consoleLogger.consoleLogger)());
51
51
  }
52
52
  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) {
53
- var _TelemetryManager$Int11, _TelemetryManager$Int20, _TelemetryManager$Int21, _TelemetryManager$Int22, _TelemetryManager$Int23;
53
+ var _TelemetryManager$Int11, _TelemetryManager$Int20, _TelemetryManager$Int21, _TelemetryManager$Int22, _TelemetryManager$Int23, _TelemetryManager$Int24, _TelemetryManager$Int25, _TelemetryManager$Int26;
54
54
  if ((_TelemetryManager$Int11 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int11 !== void 0 && _TelemetryManager$Int11.ariaConfig) {
55
55
  var _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14, _TelemetryManager$Int15, _TelemetryManager$Int16, _TelemetryManager$Int17, _TelemetryManager$Int18, _TelemetryManager$Int19;
56
56
  loggers.push((0, _ariaTelemetryLogger.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.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.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.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.defaultAriaConfig.ariaTelemetryApplicationName));
@@ -61,12 +61,15 @@ const RegisterLoggers = () => {
61
61
  loggers.push(logger);
62
62
  });
63
63
  }
64
- 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) {
65
- var _TelemetryManager$Int24;
66
- if ((_TelemetryManager$Int24 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int24 !== void 0 && _TelemetryManager$Int24.appInsightsConfig.appInsightsKey) {
67
- var _TelemetryManager$Int25;
68
- loggers.push((0, _appInsightsLogger.appInsightsLogger)((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : _TelemetryManager$Int25.appInsightsConfig.appInsightsKey));
69
- }
64
+ const chatConfigAppInsightsKey = (_TelemetryManager$Int22 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int22 === void 0 ? void 0 : _TelemetryManager$Int22.chatConfigAppInsightsKey;
65
+ 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;
66
+ // when chatConfig has AppInsightsInstrumentationKey
67
+ if (chatConfigAppInsightsKey) {
68
+ loggers.push((0, _appInsightsLogger.appInsightsLogger)(chatConfigAppInsightsKey));
69
+ }
70
+ // when key set through appInsightsConfig
71
+ 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) {
72
+ loggers.push((0, _appInsightsLogger.appInsightsLogger)(appInsightsKeyFromUser));
70
73
  }
71
74
  }
72
75
  };
@@ -14,15 +14,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
14
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
15
  var AllowedKeys;
16
16
  (function (AllowedKeys) {
17
- AllowedKeys["LogLevel"] = "LogLevel";
18
- AllowedKeys["Description"] = "Description";
19
- AllowedKeys["ExceptionDetails"] = "ExceptionDetails";
20
- AllowedKeys["ChannelId"] = "ChannelId";
17
+ AllowedKeys["OrganizationId"] = "powerplatform.analytics.resource.organization.id";
18
+ AllowedKeys["ConversationId"] = "powerplatform.analytics.resource.id";
19
+ AllowedKeys["ElapsedTimeInMilliseconds"] = "Duration";
20
+ AllowedKeys["Description"] = "omnichannel.description";
21
+ AllowedKeys["ChannelId"] = "omnichannel.channel.type";
21
22
  AllowedKeys["LCWRuntimeId"] = "ClientSessionId";
22
- AllowedKeys["ConversationId"] = "LiveWorkItemId";
23
- AllowedKeys["ChatId"] = "ChatThreadId";
24
- AllowedKeys["OrganizationId"] = "OrganizationId";
25
- AllowedKeys["ElapsedTimeInMilliseconds"] = "DurationInMilliseconds";
26
23
  })(AllowedKeys || (AllowedKeys = {}));
27
24
  let initializationPromise = null;
28
25
  const appInsightsLogger = appInsightsKey => {
@@ -95,11 +92,11 @@ const appInsightsLogger = appInsightsKey => {
95
92
  if (!_logger) return;
96
93
  const eventName = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$paylo = telemetryInput.payload) === null || _telemetryInput$paylo === void 0 ? void 0 : _telemetryInput$paylo.Event;
97
94
  const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$telem = telemetryInput.telemetryInfo) === null || _telemetryInput$telem === void 0 ? void 0 : _telemetryInput$telem.telemetryInfo;
98
- const eventProperties = setEventProperties(telemetryInfo);
99
95
  if (eventName) {
100
96
  const trackingEventName = getTrackingEventName(logLevel, eventName);
101
- _logger.trackEvent({
102
- name: trackingEventName,
97
+ const eventProperties = setEventProperties(trackingEventName, telemetryInfo);
98
+ _logger.trackTrace({
99
+ message: trackingEventName,
103
100
  properties: eventProperties
104
101
  });
105
102
  }
@@ -116,17 +113,36 @@ const appInsightsLogger = appInsightsKey => {
116
113
  };
117
114
 
118
115
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
119
- function setEventProperties(telemetryInfo) {
116
+ function setEventProperties(eventName, telemetryInfo) {
120
117
  const eventProperties = {};
121
118
  if (telemetryInfo) {
122
119
  for (const key in AllowedKeys) {
123
- const finalKey = AllowedKeys[key]; // get renamed keys for LCWRuntimeId, ConversationId, ChatId
120
+ const finalKey = AllowedKeys[key]; // get renamed keys for LCWRuntimeId, ConversationId
124
121
  const value = telemetryInfo[key];
125
122
  if (value !== undefined && value !== null && value !== "") {
126
123
  eventProperties[finalKey] = value;
127
124
  }
128
125
  }
129
126
  }
127
+ // Include exception details in description for error events
128
+ if (telemetryInfo !== null && telemetryInfo !== void 0 && telemetryInfo.ExceptionDetails) {
129
+ eventProperties[AllowedKeys.Description] = JSON.stringify(telemetryInfo.ExceptionDetails);
130
+ }
131
+ const customProperties = (() => {
132
+ if (!(telemetryInfo !== null && telemetryInfo !== void 0 && telemetryInfo.CustomProperties)) {
133
+ return {};
134
+ }
135
+ try {
136
+ return typeof telemetryInfo.CustomProperties === "string" ? JSON.parse(telemetryInfo.CustomProperties) : telemetryInfo.CustomProperties;
137
+ } catch (error) {
138
+ console.warn("Failed to parse CustomProperties:", error);
139
+ return {};
140
+ }
141
+ })();
142
+ // Additional properties
143
+ eventProperties["ConversationStage"] = customProperties.ConversationStage ?? _TelemetryConstants.ConversationStage.CSREngagement;
144
+ eventProperties["Scenario"] = "Conversation Diagnostics";
145
+ eventProperties["powerplatform.analytics.subscenario"] = eventName.includes(": ") ? eventName.split(": ")[1] : eventName;
130
146
  return eventProperties;
131
147
  }
132
148
  function getTrackingEventName(logLevel, eventName) {
@@ -7,7 +7,9 @@ exports.getCustomEventValue = exports.getConversationDetailsCall = exports.getBr
7
7
  exports.getDeviceType = getDeviceType;
8
8
  exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = void 0;
9
9
  exports.isEndConversationDueToOverflowActivity = isEndConversationDueToOverflowActivity;
10
- exports.setTabIndices = exports.setOcUserAgent = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isValidCustomEvent = exports.isUndefinedOrEmpty = exports.isThisSessionPopout = exports.isNullOrUndefined = exports.isNullOrEmptyString = void 0;
10
+ exports.parseAdaptiveCardPayload = exports.newGuid = exports.isValidCustomEvent = exports.isUndefinedOrEmpty = exports.isThisSessionPopout = exports.isNullOrUndefined = exports.isNullOrEmptyString = void 0;
11
+ exports.parseBooleanFromConfig = parseBooleanFromConfig;
12
+ exports.setTabIndices = exports.setOcUserAgent = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = void 0;
11
13
  var _Constants = require("./Constants");
12
14
  var _TelemetryConstants = require("./telemetry/TelemetryConstants");
13
15
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
@@ -519,4 +521,15 @@ exports.getCustomEventValue = getCustomEventValue;
519
521
  function isEndConversationDueToOverflowActivity(activity) {
520
522
  var _activity$channelData, _activity$channelData2;
521
523
  return (activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.tags) && Array.isArray(activity === null || activity === void 0 ? void 0 : (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.tags) && activity.channelData.tags.includes(_Constants.Constants.EndConversationDueToOverflow);
524
+ }
525
+
526
+ /**
527
+ * Parses a value that can be boolean or string ("true"/"false") into a boolean.
528
+ * Handles null/undefined by returning false.
529
+ *
530
+ * @param value - The value to parse (can be boolean, string, null, or undefined)
531
+ * @returns true if value is true or "true" (case-insensitive), false otherwise
532
+ */
533
+ function parseBooleanFromConfig(value) {
534
+ return value === true || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "true";
522
535
  }
@@ -26,7 +26,10 @@ const ChatButtonStateful = props => {
26
26
  uiTimer = (0, _utils.createTimer)();
27
27
  _TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
28
28
  Event: _TelemetryConstants.TelemetryEvent.UXLCWChatButtonLoadingStart,
29
- Description: "Chat button loading started"
29
+ Description: "Chat button loading started",
30
+ CustomProperties: {
31
+ ConversationStage: _TelemetryConstants.ConversationStage.Initialization
32
+ }
30
33
  });
31
34
  }, []);
32
35
 
@@ -49,7 +52,10 @@ const ChatButtonStateful = props => {
49
52
  ref.current = async () => {
50
53
  _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
51
54
  Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked,
52
- Description: "Chat button click action started"
55
+ Description: "Chat button click action started",
56
+ CustomProperties: {
57
+ ConversationStage: _TelemetryConstants.ConversationStage.Initialization
58
+ }
53
59
  });
54
60
  if (state.appStates.isMinimized) {
55
61
  dispatch({
@@ -69,7 +75,10 @@ const ChatButtonStateful = props => {
69
75
  }
70
76
  _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
71
77
  Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonActionCompleted,
72
- Description: "Chat button action completed"
78
+ Description: "Chat button action completed",
79
+ CustomProperties: {
80
+ ConversationStage: _TelemetryConstants.ConversationStage.Initialization
81
+ }
73
82
  });
74
83
  };
75
84
  const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeChatButtonStyleProps.defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
@@ -123,7 +132,10 @@ const ChatButtonStateful = props => {
123
132
  _TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
124
133
  Event: _TelemetryConstants.TelemetryEvent.UXLCWChatButtonLoadingCompleted,
125
134
  Description: "Chat button loading completed",
126
- ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
135
+ ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed,
136
+ CustomProperties: {
137
+ ConversationStage: _TelemetryConstants.ConversationStage.Initialization
138
+ }
127
139
  });
128
140
  }, []);
129
141
  (0, _react.useEffect)(() => {
@@ -42,7 +42,7 @@ const CitationPaneStateful = props => {
42
42
  const [paneStyle, setPaneStyle] = (0, _react.useState)(null);
43
43
  const [isReady, setIsReady] = (0, _react.useState)(false);
44
44
 
45
- // Move focus to the container
45
+ // Initial focus pattern (mirrors ConfirmationPaneStateful): focus first focusable element (will re-attempt after visibility becomes true)
46
46
  (0, _react.useEffect)(() => {
47
47
  (0, _utils.preventFocusToMoveOutOfElement)(controlId);
48
48
  const focusableElements = (0, _utils.findAllFocusableElement)(`#${controlId}`);
@@ -64,6 +64,25 @@ const CitationPaneStateful = props => {
64
64
  });
65
65
  }, []);
66
66
 
67
+ // Retry focus once pane is actually visible (isReady) in case initial attempt occurred while wrapper was visibility:hidden
68
+ (0, _react.useEffect)(() => {
69
+ if (!isReady) return;
70
+ const focusableElements = (0, _utils.findAllFocusableElement)(`#${controlId}`);
71
+ if (focusableElements && focusableElements.length > 0) {
72
+ const first = focusableElements[0];
73
+ // If focused element is not already inside the pane, move focus
74
+ if (!first.contains(document.activeElement) && !(document.activeElement && document.activeElement.id.startsWith(controlId))) {
75
+ requestAnimationFrame(() => {
76
+ if (first.isConnected) {
77
+ first.focus({
78
+ preventScroll: true
79
+ });
80
+ }
81
+ });
82
+ }
83
+ }
84
+ }, [isReady, controlId]);
85
+
67
86
  // Compute the widget bounds and set pane style accordingly (95% of widget size
68
87
  // and centered inside the widget). If the widget container can't be found,
69
88
  // fall back to the default pane styles from defaultCitationPaneProps.
@@ -19,11 +19,12 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
19
19
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
20
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
21
21
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
+ // eslint-disable-next-line @typescript-eslint/ban-types
22
23
  const RenderChildrenFunction = _ref => {
23
24
  let {
24
25
  children
25
26
  } = _ref;
26
- return typeof children === 'function' ? children() : children;
27
+ return typeof children === "function" ? children() : children;
27
28
  };
28
29
  let ErrorBoundary = /*#__PURE__*/function (_Component) {
29
30
  _inherits(ErrorBoundary, _Component);
@@ -70,7 +70,10 @@ const HeaderStateful = props => {
70
70
  var _props$headerProps, _props$headerProps$co, _props$headerProps$co2;
71
71
  _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
72
72
  Event: _TelemetryConstants.TelemetryEvent.HeaderCloseButtonClicked,
73
- Description: "Header Close action started."
73
+ Description: "Header Close action started.",
74
+ CustomProperties: {
75
+ ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd
76
+ }
74
77
  });
75
78
  if (localConfirmationPaneState.current !== _Constants.ConfirmationState.Ok) {
76
79
  dispatch({
@@ -85,7 +88,10 @@ const HeaderStateful = props => {
85
88
  }
86
89
  _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
87
90
  Event: _TelemetryConstants.TelemetryEvent.CloseChatActionCompleted,
88
- Description: "Header Close action completed."
91
+ Description: "Header Close action completed.",
92
+ CustomProperties: {
93
+ ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd
94
+ }
89
95
  });
90
96
  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`;
91
97
  if (closeButtonId) {
@@ -9,7 +9,7 @@ var ChatWidgetEvents;
9
9
  ChatWidgetEvents["ADD_ACTIVITY"] = "CHAT_WIDGET/ADD_ACTIVITY";
10
10
  ChatWidgetEvents["FETCH_PERSISTENT_CHAT_HISTORY"] = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY";
11
11
  ChatWidgetEvents["NO_MORE_HISTORY_AVAILABLE"] = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE";
12
- ChatWidgetEvents["HIDE_LOADING_BANNER"] = "CHAT_WIDGET/HIDE_LOADING_BANNER";
12
+ ChatWidgetEvents["HISTORY_LOAD_ERROR"] = "CHAT_WIDGET/HISTORY_LOAD_ERROR";
13
13
  })(ChatWidgetEvents || (ChatWidgetEvents = {}));
14
14
  var _default = ChatWidgetEvents;
15
15
  exports.default = _default;
@@ -36,7 +36,7 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
36
36
  _defineProperty(this, "facadeChatSDK", void 0);
37
37
  _defineProperty(this, "lastMessage", null);
38
38
  _defineProperty(this, "count", 0);
39
- _defineProperty(this, "pageSize", 4);
39
+ _defineProperty(this, "pageSize", _defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps.pageSize);
40
40
  _defineProperty(this, "isCurrentlyPulling", false);
41
41
  _defineProperty(this, "pageTokenInTransitSet", new Set());
42
42
  _defineProperty(this, "resetEventListener", _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.PersistentConversationReset).subscribe(() => {
@@ -48,18 +48,21 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
48
48
  Event: _TelemetryConstants.TelemetryEvent.LCWPersistentConversationHandlerInitialized,
49
49
  Description: "PersistentConversationHandler initialized",
50
50
  CustomProperties: {
51
- pageSize: this.pageSize
51
+ pageSize: _defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps.pageSize
52
52
  }
53
53
  });
54
54
  }
55
55
  _createClass(PersistentConversationHandler, [{
56
56
  key: "appliedPropsHandler",
57
57
  value: function appliedPropsHandler(props) {
58
+ var _this$appliedProps;
58
59
  this.appliedProps = {
59
60
  ..._defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps,
60
61
  ...props
61
62
  };
62
- this.pageSize = this.appliedProps.pageSize || 4;
63
+
64
+ // if the props is not existent or is not a number then default to defaultPersistentChatHistoryProps.pageSize
65
+ 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.defaultPersistentChatHistoryProps.pageSize;
63
66
  }
64
67
  }, {
65
68
  key: "reset",
@@ -104,12 +107,23 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
104
107
  try {
105
108
  var _ref;
106
109
  const messages = await this.fetchHistoryMessages();
107
- if (messages === null || (messages === null || messages === void 0 ? void 0 : messages.length) === 0) {
110
+
111
+ // Handle error case - null indicates an error occurred
112
+ // Don't mark as last pull to allow retry on next attempt
113
+ if (messages == null) {
114
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
115
+ Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryReturnedNull,
116
+ Description: "History pull returned null - Possible error occurred, will retry on next scroll",
117
+ ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed
118
+ });
119
+ return;
120
+ }
121
+
122
+ // Handle legitimate end of history - empty array
123
+ if (messages.length === 0) {
108
124
  this.isLastPull = true;
109
125
  // Dispatch event to notify UI that no more history is available
110
126
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
111
- // Also hide the loading banner
112
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
113
127
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
114
128
  Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
115
129
  Description: "History pull completed - no more messages",
@@ -119,9 +133,6 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
119
133
  }
120
134
  const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
121
135
  this.processHistoryMessages(messagesDescOrder);
122
-
123
- // Dispatch event to hide the loading banner after messages are processed
124
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
125
136
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
126
137
  Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
127
138
  Description: "History pull completed successfully",
@@ -177,7 +188,6 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
177
188
  if (!this.shouldPull()) {
178
189
  // Dispatch event to ensure banner is hidden when no more pulls are needed
179
190
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
180
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
181
191
  return [];
182
192
  }
183
193
  const options = {
@@ -203,24 +213,20 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
203
213
  this.isLastPull = true;
204
214
  // Dispatch event when we reach the end of available history
205
215
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
206
- // Also hide the loading banner
207
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
208
216
  return [];
209
217
  }
210
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
211
218
  return messages;
212
219
  } catch (error) {
213
220
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
214
221
  Event: _TelemetryConstants.TelemetryEvent.FetchPersistentChatHistoryFailed,
215
222
  ExceptionDetails: error
216
223
  });
217
- this.isLastPull = true;
218
- this.pageToken = null;
219
- // Dispatch event when there's an error to stop loading banner
220
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
221
- // Also hide the loading banner
222
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
223
- return [];
224
+
225
+ // On error, dispatch HISTORY_LOAD_ERROR to hide loading banner without marking conversation as ended
226
+ // This allows recovery on the next attempt (e.g., transient network errors)
227
+ // Return null to distinguish error from legitimate empty history
228
+ (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HISTORY_LOAD_ERROR);
229
+ return null;
224
230
  }
225
231
  }
226
232
  }, {
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.defaultPersistentChatHistoryProps = void 0;
7
7
  const defaultPersistentChatHistoryProps = {
8
- persistentChatHistoryEnabled: true,
9
- pageSize: 4,
8
+ pageSize: 10,
10
9
  dividerActivityStyle: {
11
10
  border: "1px solid rgb(96, 94, 92, 0.5)",
12
11
  margin: "10px 20%"
@@ -12,6 +12,8 @@ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components
12
12
  var _ConversationState = require("../../../contexts/common/ConversationState");
13
13
  var _LazyLoadActivity = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity");
14
14
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
15
+ var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
16
+ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
15
17
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
16
18
  var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
17
19
  var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
@@ -201,6 +203,18 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
201
203
  facadeChatSDK.destroy();
202
204
  }
203
205
  }
206
+
207
+ //moving logic below to before processing skipCloseChat logic to avoid race conditions of postMessage for endChatEvent for other tabs vs postMessage for CloseChat
208
+ //TODO: clarify if this postMessageToOtherTab actually works in production.
209
+ if (postMessageToOtherTab) {
210
+ const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
211
+ _omnichannelChatComponents.BroadcastService.postMessage({
212
+ eventName: endChatEventName,
213
+ payload: {
214
+ runtimeId: _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId
215
+ }
216
+ });
217
+ }
204
218
  if (!skipCloseChat) {
205
219
  try {
206
220
  var _props$webChatContain;
@@ -240,17 +254,17 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
240
254
  });
241
255
  closeChatWidget(dispatch, setWebChatStyles, props);
242
256
  facadeChatSDK.destroy();
257
+
258
+ //always post the close chat event after chat closed and cleanup completed
259
+ _omnichannelChatComponents.BroadcastService.postMessage({
260
+ eventName: _TelemetryConstants.BroadcastEvent.CloseChat
261
+ });
262
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
263
+ Event: _TelemetryConstants.TelemetryEvent.CloseChatCall,
264
+ Description: "Broadcasted close chat event"
265
+ });
243
266
  }
244
267
  }
245
- if (postMessageToOtherTab) {
246
- const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
247
- _omnichannelChatComponents.BroadcastService.postMessage({
248
- eventName: endChatEventName,
249
- payload: {
250
- runtimeId: _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId
251
- }
252
- });
253
- }
254
268
  };
255
269
  exports.endChat = endChat;
256
270
  const callingStateCleanUp = dispatch => {
@@ -331,6 +345,9 @@ const closeChatStateCleanUp = dispatch => {
331
345
  payload: {}
332
346
  });
333
347
 
348
+ // Dismiss the chat disconnect notification banner if it was shown
349
+ _NotificationHandler.NotificationHandler.dismissNotification(_NotificationScenarios.NotificationScenarios.ChatDisconnect);
350
+
334
351
  // Clear live chat context only if chat widget is fully closed to support transcript calls after sessionclose is called
335
352
  dispatch({
336
353
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,