@microsoft/omnichannel-chat-widget 1.8.4-main.424a580 → 1.8.4-main.4515f87

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 (79) hide show
  1. package/README.md +39 -3
  2. package/lib/cjs/common/Constants.js +4 -0
  3. package/lib/cjs/common/telemetry/AppInsightsEvents.js +11 -5
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +6 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
  6. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +7 -7
  7. package/lib/cjs/common/utils/xssUtils.js +23 -51
  8. package/lib/cjs/common/utils.js +15 -2
  9. package/lib/cjs/components/errorboundary/ErrorBoundary.js +2 -1
  10. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
  11. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +2 -1
  12. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +32 -20
  13. package/lib/cjs/components/livechatwidget/common/createAdapter.js +3 -2
  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/liveChatConfigUtils.js +36 -4
  17. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  18. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +113 -27
  19. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +8 -6
  20. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +0 -1
  21. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +48 -37
  22. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +121 -14
  23. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
  24. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
  25. package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  26. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +19 -9
  27. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +169 -156
  28. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +1 -1
  29. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -0
  30. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  31. package/lib/cjs/controller/componentController.js +13 -1
  32. package/lib/esm/common/Constants.js +4 -0
  33. package/lib/esm/common/telemetry/AppInsightsEvents.js +11 -5
  34. package/lib/esm/common/telemetry/TelemetryConstants.js +6 -0
  35. package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
  36. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +7 -7
  37. package/lib/esm/common/utils/xssUtils.js +23 -51
  38. package/lib/esm/common/utils.js +12 -1
  39. package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -2
  40. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
  41. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +2 -1
  42. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +32 -20
  43. package/lib/esm/components/livechatwidget/common/createAdapter.js +3 -2
  44. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
  45. package/lib/esm/components/livechatwidget/common/endChat.js +26 -9
  46. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
  47. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  48. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +113 -27
  49. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +8 -6
  50. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -2
  51. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +49 -41
  52. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +121 -14
  53. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
  54. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
  55. package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  56. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +19 -9
  57. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +169 -160
  58. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +1 -1
  59. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -0
  60. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -0
  61. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  62. package/lib/esm/controller/componentController.js +13 -1
  63. package/lib/types/common/Constants.d.ts +4 -0
  64. package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -0
  65. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
  66. package/lib/types/common/utils/xssUtils.d.ts +5 -21
  67. package/lib/types/common/utils.d.ts +9 -1
  68. package/lib/types/components/errorboundary/ErrorBoundary.d.ts +1 -1
  69. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +1 -0
  70. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +2 -1
  71. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
  72. package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +1 -0
  73. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +0 -1
  74. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +2 -0
  75. package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +7 -0
  76. package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
  77. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +1 -2
  78. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +15 -39
  79. package/package.json +15 -6
package/README.md CHANGED
@@ -177,7 +177,7 @@ Header's and Footer's child components consist of three parts:
177
177
  1. "middleGroup" - adding child components in the middle of the Header/Footer
178
178
  1. "rightGroup" - adding child components at the right of the Header/Footer
179
179
 
180
- By default Header has the header icon and title on the left and minimize and close buttons on the right, and Footer has Download Transcript and Email Transcript buttons on the left and audio notification button on the right. These components can be overriden with [ComponentOverrides](#ComponentOverrides). In addition, other custom child components can be added to both Header and Footer by creating custom react nodes and adding them to attributes "leftGroup", "middleGroup" or "rightGroup" of "controlProps".
180
+ By default Header has the header icon and title on the left and minimize and close buttons on the right, and Footer has Download Transcript and Email Transcript buttons on the left and audio notification button on the right. These components can be overriden with [ComponentOverrides](#componentoverrides). In addition, other custom child components can be added to both Header and Footer by creating custom react nodes and adding them to attributes "leftGroup", "middleGroup" or "rightGroup" of "controlProps".
181
181
 
182
182
  ```js
183
183
  const buttonStyleProps: IButtonStyles = {
@@ -224,8 +224,10 @@ const customizedFooterProp: IFooterProps = {
224
224
  > :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
225
225
 
226
226
  #### Bidirectional Custom Events
227
+
227
228
  - Sending events from a hosting web page to bots/agents
228
- - Register a function to post event
229
+ - Register a function to post event
230
+
229
231
  ```js
230
232
  //define sendCustomEvent function
231
233
  const sendCustomEvent = (payload) => {
@@ -253,7 +255,9 @@ const customizedFooterProp: IFooterProps = {
253
255
  }
254
256
  })
255
257
  ```
256
- - Receiving events from bots/agents
258
+
259
+ - Receiving events from bots/agents
260
+
257
261
  ```js
258
262
  //define setOnCustomEvent function
259
263
  const setOnCustomEvent = (callback) => {
@@ -268,6 +272,38 @@ const customizedFooterProp: IFooterProps = {
268
272
  setOnCustomEvent((event) => console.log(event));
269
273
  ```
270
274
 
275
+ #### Trigger initiateEndChat event
276
+
277
+ Customer can trigger the initiateEndChat event via BroadcastService to end a chat session.
278
+ When needed, the payload below could be triggered:
279
+
280
+ ```js
281
+ const endChatEvent = {
282
+ eventName: "InitiateEndChat",
283
+ payload: {
284
+ skipSessionCloseForPersistentChat: true
285
+ } //optional payload
286
+ };
287
+ BroadcastService.postMessage(endChatEvent);
288
+ ```
289
+
290
+ The payload of the event is optional, only needed when force closing of a persistent chat session is not required.
291
+ When chat widget receives the event without any payload, it will:
292
+
293
+ 1. set the widget to closed state, the widget panel will be minimized. Post chat survey will not be displayed.
294
+ 2. trigger a sessionclose service network request to OmniChannel services.
295
+
296
+ 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.
297
+
298
+ After successfully processed initiateEndChat event. The CloseChat event is broadcasted.
299
+
300
+ ```js
301
+ BroadcastService.getMessageByEventName("CloseChat").subscribe(async (msg) => {
302
+ console.log("close chat received: ", msg);
303
+ //more actions to unmount component and resources
304
+ })
305
+ ```
306
+
271
307
  ## See Also
272
308
 
273
309
  [Customizations Dev Guide](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/customizations/getstarted.md)\
@@ -82,6 +82,8 @@ _defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|amr|flac|mp2|m
82
82
  _defineProperty(Constants, "videoMediaRegex", /(\.)(avchd|avi|flv|mpe|mpeg|mpg|mpv|mp4|m4p|m4v|mov|qt|swf|webm|wmv)$/i);
83
83
  _defineProperty(Constants, "chromeSupportedInlineMediaRegex", /(\.)(aac|mp3|wav|mp4)$/i);
84
84
  _defineProperty(Constants, "firefoxSupportedInlineMediaRegex", /(\.)(aac|flac|mp3|wav|mp4|mov)$/i);
85
+ _defineProperty(Constants, "AdaptiveCardType", "adaptivecard");
86
+ _defineProperty(Constants, "SuggestedActionsType", "suggestedactions");
85
87
  // calling container event names
86
88
  _defineProperty(Constants, "CallAdded", "callAdded");
87
89
  _defineProperty(Constants, "LocalVideoStreamAdded", "localVideoStreamAdded");
@@ -143,6 +145,7 @@ _defineProperty(Constants, "customEventName", "customEventName");
143
145
  _defineProperty(Constants, "customEventValue", "customEventValue");
144
146
  _defineProperty(Constants, "Hidden", "Hidden");
145
147
  _defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
148
+ _defineProperty(Constants, "SkipSessionCloseForPersistentChatFlag", "skipSessionCloseForPersistentChat");
146
149
  const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
147
150
  _classCallCheck(this, Regex);
148
151
  }), _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);
@@ -378,6 +381,7 @@ _defineProperty(PrepareEndChatDescriptionConstants, "ConversationEndedBy", "Conv
378
381
  _defineProperty(PrepareEndChatDescriptionConstants, "PrepareEndChatError", "There's an error while preparing to end chat. Closing chat widget.");
379
382
  _defineProperty(PrepareEndChatDescriptionConstants, "WidgetLoadFailedAfterSessionInit", "SessionInit was successful, but widget load failed. Ending chat to avoid ghost chats in OC.");
380
383
  _defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceived", "Received InitiateEndChat BroadcastEvent while conversation state is not Active. Ending chat.");
384
+ _defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceivedActiveChat", "Received InitiateEndChat BroadcastEvent while conversation state is Active. Updating conversation states.");
381
385
  _defineProperty(PrepareEndChatDescriptionConstants, "EndChatReceivedFromOtherTabs", "Received EndChat BroadcastEvent from other tabs. Closing this chat.");
382
386
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseChatOnFailureOrPostChat", "Customer is trying to close chat widget on start chat failure or post chat pane.");
383
387
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseInactiveChat", "Chat was Inactive and customer is trying to close chat widget or refreshing the page.");
@@ -6,8 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.AppInsightsEventMapping = void 0;
7
7
  const AppInsightsEventMapping = {
8
8
  "LCWChatButtonClicked": "LCWChatButtonActionStarted",
9
- "PrechatSubmitted": "PrechatSubmitCompleted",
10
- "StartChatEventRecevied": "StartChatEventReceivedCompleted",
9
+ "UXLCWChatButtonLoadingStart": "LiveChatWidgetChatButtonLoadingStarted",
10
+ "UXLCWChatButtonLoadingCompleted": "LiveChatWidgetChatButtonLoadingCompleted",
11
+ "UXPrechatPaneStart": "PrechatSurveyStarted",
12
+ "UXPrechatPaneCompleted": "PrechatSurveyCompleted",
13
+ "PrechatSubmitted": "PrechatSurveySubmitCompleted",
11
14
  "EndChatEventReceived": "EndChatEventReceivedCompleted",
12
15
  "EmailTranscriptSent": "EmailTranscriptActionCompleted",
13
16
  "EmailTranscriptFailed": "EmailTranscriptActionFailed",
@@ -15,8 +18,6 @@ const AppInsightsEventMapping = {
15
18
  "HeaderMinimizeButtonClicked": "MinimizeChatActionStarted",
16
19
  "DownloadTranscriptButtonClicked": "DownloadTranscriptActionStarted",
17
20
  "EmailTranscriptButtonClicked": "EmailTranscriptButtonActionStarted",
18
- "CustomerVoiceFormResponseSubmitted": "CustomerVoiceFormResponseSubmitCompleted",
19
- "StartProactiveChatEventReceived": "StartProactiveChatEventReceivedCompleted",
20
21
  "ProactiveChatRejected": "ProactiveChatTimeOutCompleted",
21
22
  "MessageSent": "MessageSentCompleted",
22
23
  "MessageReceived": "MessageReceivedCompleted",
@@ -25,6 +26,11 @@ const AppInsightsEventMapping = {
25
26
  "CustomContextReceived": "CustomContextReceivedCompleted",
26
27
  "NewTokenValidationStarted": "AuthTokenValidationStarted",
27
28
  "NewTokenValidationCompleted": "AuthTokenValidationCompleted",
28
- "NewTokenValidationFailed": "AuthTokenValidationFailed"
29
+ "NewTokenValidationFailed": "AuthTokenValidationFailed",
30
+ "UXPostChatPaneStarted": "PostChatSurveyStarted",
31
+ "UXPostChatPaneCompleted": "PostChatSurveyCompleted",
32
+ "WidgetLoadStarted": "ChatSessionInitializationStarted",
33
+ "WidgetLoadComplete": "ChatSessionInitializationCompleted",
34
+ "WidgetLoadFailed": "ChatSessionInitializationFailed"
29
35
  };
30
36
  exports.AppInsightsEventMapping = AppInsightsEventMapping;
@@ -306,6 +306,7 @@ exports.TelemetryEvent = TelemetryEvent;
306
306
  TelemetryEvent["LCWPersistentConversationHandlerInitialized"] = "LCWPersistentConversationHandlerInitialized";
307
307
  TelemetryEvent["LCWPersistentHistoryPullBlocked"] = "LCWPersistentHistoryPullBlocked";
308
308
  TelemetryEvent["LCWPersistentHistoryPullCompleted"] = "LCWPersistentHistoryPullCompleted";
309
+ TelemetryEvent["LCWPersistentHistoryReturnedNull"] = "LCWPersistentHistoryReturnedNull";
309
310
  TelemetryEvent["LCWLazyLoadInitializationStarted"] = "LCWLazyLoadInitializationStarted";
310
311
  TelemetryEvent["LCWLazyLoadContainerNotFound"] = "LCWLazyLoadContainerNotFound";
311
312
  TelemetryEvent["LCWLazyLoadInitializationCompleted"] = "LCWLazyLoadInitializationCompleted";
@@ -315,7 +316,12 @@ exports.TelemetryEvent = TelemetryEvent;
315
316
  TelemetryEvent["LCWLazyLoadActivityMounted"] = "LCWLazyLoadActivityMounted";
316
317
  TelemetryEvent["LCWLazyLoadReset"] = "LCWLazyLoadReset";
317
318
  TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
319
+ TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
318
320
  TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
321
+ TelemetryEvent["LCWLazyLoadTriggerFired"] = "LCWLazyLoadTriggerFired";
322
+ TelemetryEvent["LCWLazyLoadBatchReceived"] = "LCWLazyLoadBatchReceived";
323
+ TelemetryEvent["LCWLazyLoadInitialLoadComplete"] = "LCWLazyLoadInitialLoadComplete";
324
+ TelemetryEvent["LCWLazyLoadScrollAnchorApplied"] = "LCWLazyLoadScrollAnchorApplied";
319
325
  TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
320
326
  TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
321
327
  TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
@@ -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,11 +14,11 @@ 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["OrganizationId"] = "OrganizationId";
18
- AllowedKeys["ConversationId"] = "LiveWorkItemId";
17
+ AllowedKeys["OrganizationId"] = "powerplatform.analytics.resource.organization.id";
18
+ AllowedKeys["ConversationId"] = "powerplatform.analytics.resource.id";
19
19
  AllowedKeys["ElapsedTimeInMilliseconds"] = "Duration";
20
- AllowedKeys["Description"] = "Description";
21
- AllowedKeys["ChannelId"] = "ChannelType";
20
+ AllowedKeys["Description"] = "omnichannel.description";
21
+ AllowedKeys["ChannelId"] = "omnichannel.channel.type";
22
22
  AllowedKeys["LCWRuntimeId"] = "ClientSessionId";
23
23
  })(AllowedKeys || (AllowedKeys = {}));
24
24
  let initializationPromise = null;
@@ -95,8 +95,8 @@ const appInsightsLogger = appInsightsKey => {
95
95
  if (eventName) {
96
96
  const trackingEventName = getTrackingEventName(logLevel, eventName);
97
97
  const eventProperties = setEventProperties(trackingEventName, telemetryInfo);
98
- _logger.trackEvent({
99
- name: trackingEventName,
98
+ _logger.trackTrace({
99
+ message: trackingEventName,
100
100
  properties: eventProperties
101
101
  });
102
102
  }
@@ -142,7 +142,7 @@ const appInsightsLogger = appInsightsKey => {
142
142
  // Additional properties
143
143
  eventProperties["ConversationStage"] = customProperties.ConversationStage ?? _TelemetryConstants.ConversationStage.CSREngagement;
144
144
  eventProperties["Scenario"] = "Conversation Diagnostics";
145
- eventProperties["OperationName"] = eventName.includes(": ") ? eventName.split(": ")[1] : eventName;
145
+ eventProperties["powerplatform.analytics.subscenario"] = eventName.includes(": ") ? eventName.split(": ")[1] : eventName;
146
146
  return eventProperties;
147
147
  }
148
148
  function getTrackingEventName(logLevel, eventName) {
@@ -7,70 +7,42 @@ exports.detectAndCleanXSS = void 0;
7
7
  var _dompurify = _interopRequireDefault(require("dompurify"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  /**
10
- * Detects potential Cross-Site Scripting (XSS) attacks in text input and sanitizes the content.
10
+ * Sanitizes text input and detects XSS attack patterns.
11
11
  *
12
- * This function performs comprehensive XSS detection using pattern matching for common attack vectors
13
- * and then sanitizes the input using DOMPurify with strict configuration. It's designed to protect
14
- * against various XSS techniques including script injection, event handler injection, style-based
15
- * attacks, and encoded payloads.
12
+ * Sanitizes first with DOMPurify, then checks for malicious patterns in both
13
+ * the original and sanitized text to catch mutation XSS attacks.
16
14
  *
17
- * Security patterns detected:
18
- * - JavaScript protocol URLs (javascript:)
19
- * - HTML event handlers (onmouseover, onclick, etc.)
20
- * - Script tags (<script>)
21
- * - CSS expression() functions
22
- * - CSS url() functions
23
- * - Position-based CSS attacks (position: fixed/absolute)
24
- * - VBScript protocol URLs
25
- * - Data URLs with HTML content
26
- * - Fragment identifiers with escaped quotes
27
- * - HTML entity-encoded angle brackets
28
- *
29
- * @param text - The input text to be analyzed and sanitized
30
- * @returns An object containing:
31
- * - cleanText: The sanitized version of the input text with all HTML tags and attributes removed
32
- * - isXSSDetected: Boolean flag indicating whether potential XSS patterns were found in the original text
15
+ * @param text - Input text to sanitize
16
+ * @returns Object with cleanText (sanitized) and isXSSDetected flag
33
17
  */
34
18
  const detectAndCleanXSS = text => {
35
- // Comprehensive array of regular expressions to detect common XSS attack patterns
36
- const xssPatterns = [/javascript\s*:/gi,
37
- // JavaScript protocol URLs (with optional spaces)
38
- /vbscript\s*:/gi,
39
- // VBScript protocol URLs (with optional spaces)
40
- /on\w+\s*=/gi,
41
- // HTML event handlers (onmouseover, onclick, onload, etc.)
42
- /<\s*script/gi,
43
- // Script tag opening (with optional spaces)
44
- /expression\s*\(/gi,
45
- // CSS expression() function (IE-specific)
46
- /url\s*\(/gi,
47
- // CSS url() function
48
- /style\s*=.*position\s*:\s*fixed/gi,
49
- // CSS position fixed attacks
50
- /style\s*=.*position\s*:\s*absolute/gi,
51
- // CSS position absolute attacks
52
- /data\s*:\s*text\s*\/\s*html/gi,
53
- // Data URLs containing HTML
54
- /#.*\\"/gi,
55
- // Fragment identifiers with escaped quotes
56
- /&gt;.*&lt;/gi // HTML entity-encoded angle brackets indicating tag structure
57
- ];
58
-
59
- // Check if any XSS patterns are detected in the input text
60
- const isXSSDetected = xssPatterns.some(pattern => pattern.test(text));
61
-
62
- // Clean the text using DOMPurify with strict config
19
+ // Sanitize first to prevent mutation XSS (e.g., "s<iframe></iframe>tyle" "style")
63
20
  const cleanText = _dompurify.default.sanitize(text, {
64
21
  ALLOWED_TAGS: [],
65
- // No HTML tags allowed in title
66
22
  ALLOWED_ATTR: [],
67
23
  KEEP_CONTENT: true,
68
- // Keep text content
69
24
  ALLOW_DATA_ATTR: false,
70
25
  ALLOW_UNKNOWN_PROTOCOLS: false,
71
26
  SANITIZE_DOM: true,
72
27
  FORCE_BODY: false
73
28
  });
29
+ const contentChanged = text !== cleanText;
30
+
31
+ // Non-global regex patterns to avoid stateful .test() issues
32
+ const xssPatterns = [/javascript\s*:/i, /vbscript\s*:/i, /on\w+\s*=/i,
33
+ // Event handlers
34
+ /<\s*script/i, /<\s*iframe/i, /<\s*object/i, /<\s*embed/i, /<\s*svg/i, /expression\s*\(/i,
35
+ // IE CSS expressions
36
+ /style\s*=.*position\s*:\s*(fixed|absolute)/i, /data\s*:\s*text\s*\/\s*html/i, /#.*\\"/i, /&(lt|gt|#x3c|#60|#x3e|#62);/i,
37
+ // HTML entities
38
+ /&#x?[0-9a-f]+;.*</i, /\u003c.*\u003e/i,
39
+ // Unicode escapes
40
+ /src\s*=\s*["']?\s*javascript:/i, /href\s*=\s*["']?\s*javascript:/i];
41
+ const hasXSSPattern = xssPatterns.some(pattern => {
42
+ return pattern.test(text) || pattern.test(cleanText);
43
+ });
44
+ const hasHTMLStructure = /<[^>]+>/.test(text) && !/<[^>]+>/.test(cleanText);
45
+ const isXSSDetected = contentChanged || hasXSSPattern || hasHTMLStructure;
74
46
  return {
75
47
  cleanText,
76
48
  isXSSDetected
@@ -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");
@@ -478,7 +480,7 @@ const setOcUserAgent = chatSDK => {
478
480
  // eslint-disable-line @typescript-eslint/no-explicit-any
479
481
  if ((_chatSDK$OCClient = chatSDK.OCClient) !== null && _chatSDK$OCClient !== void 0 && _chatSDK$OCClient.ocUserAgent && !((_chatSDK$OCClient2 = chatSDK.OCClient) !== null && _chatSDK$OCClient2 !== void 0 && _chatSDK$OCClient2.ocUserAgent.join(" ").includes("omnichannel-chat-widget/"))) {
480
482
  try {
481
- const version = require("../../../package.json").version; // eslint-disable-line @typescript-eslint/no-var-requires
483
+ const version = require("../../package.json").version; // eslint-disable-line @typescript-eslint/no-var-requires
482
484
  const userAgent = `omnichannel-chat-widget/${version}`;
483
485
  chatSDK.OCClient.ocUserAgent = [userAgent, ...chatSDK.OCClient.ocUserAgent];
484
486
  } catch (error) {
@@ -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
  }
@@ -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);
@@ -44,7 +44,7 @@ const extractSasUrl = async attachment => {
44
44
  }
45
45
  return sasUrl;
46
46
  };
47
- const fetchBotAuthConfig = async (retries, interval) => {
47
+ const fetchBotAuthConfig = async (retries, interval, fallback) => {
48
48
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
49
49
  Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderFetchConfig
50
50
  });
@@ -60,13 +60,23 @@ const fetchBotAuthConfig = async (retries, interval) => {
60
60
  });
61
61
  if (retries === 1) {
62
62
  // Base Case
63
- throw new Error();
63
+ if (response !== undefined) {
64
+ return response;
65
+ }
66
+ if (fallback !== undefined) {
67
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.WARN, {
68
+ Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderNotFound,
69
+ Description: `Failed to fetch bot auth config after maximum retries. Using fallback value: ${fallback}`
70
+ });
71
+ return fallback;
72
+ }
73
+ throw new Error("Failed to fetch bot auth config after maximum retries");
64
74
  }
65
75
  await delay(interval);
66
76
  if (response !== undefined) {
67
77
  return response;
68
78
  }
69
- return await fetchBotAuthConfig(--retries, interval);
79
+ return await fetchBotAuthConfig(--retries, interval, fallback);
70
80
  };
71
81
  let BotAuthActivitySubscriber = /*#__PURE__*/function () {
72
82
  function BotAuthActivitySubscriber() {
@@ -76,6 +86,7 @@ let BotAuthActivitySubscriber = /*#__PURE__*/function () {
76
86
  _defineProperty(this, "signInCardSeen", void 0);
77
87
  _defineProperty(this, "fetchBotAuthConfigRetries", void 0);
78
88
  _defineProperty(this, "fetchBotAuthConfigRetryInterval", void 0);
89
+ _defineProperty(this, "fallbackShowSignInCard", void 0);
79
90
  this.signInCardSeen = new Set();
80
91
  this.fetchBotAuthConfigRetries = 3;
81
92
  this.fetchBotAuthConfigRetryInterval = 1000;
@@ -85,6 +96,11 @@ let BotAuthActivitySubscriber = /*#__PURE__*/function () {
85
96
  if (optionalParams.fetchBotAuthConfigRetryInterval) {
86
97
  this.fetchBotAuthConfigRetryInterval = optionalParams.fetchBotAuthConfigRetryInterval;
87
98
  }
99
+ this.fallbackShowSignInCard = optionalParams.fallbackShowSignInCard;
100
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
101
+ Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderFetchConfig,
102
+ Description: `BotAuthActivitySubscriber initialized with fallbackShowSignInCard: ${optionalParams.fallbackShowSignInCard}`
103
+ });
88
104
  }
89
105
  _createClass(BotAuthActivitySubscriber, [{
90
106
  key: "applicable",
@@ -129,7 +145,7 @@ let BotAuthActivitySubscriber = /*#__PURE__*/function () {
129
145
  _omnichannelChatComponents.BroadcastService.postMessage(event);
130
146
  }
131
147
  try {
132
- const response = await fetchBotAuthConfig(this.fetchBotAuthConfigRetries, this.fetchBotAuthConfigRetryInterval);
148
+ const response = await fetchBotAuthConfig(this.fetchBotAuthConfigRetries, this.fetchBotAuthConfigRetryInterval, this.fallbackShowSignInCard);
133
149
  if (response === false) {
134
150
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
135
151
  Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderHideCard
@@ -140,9 +156,10 @@ let BotAuthActivitySubscriber = /*#__PURE__*/function () {
140
156
  });
141
157
  return activity;
142
158
  }
143
- } catch {
159
+ } catch (e) {
144
160
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
145
- Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderNotFound
161
+ Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderNotFound,
162
+ ExceptionDetails: e instanceof Error ? e.message : JSON.stringify(e)
146
163
  });
147
164
  //this is to ensure listener continues waiting for response
148
165
  if (this.signInCardSeen.has(signInId)) {
@@ -9,7 +9,8 @@ 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
+ ChatWidgetEvents["HISTORY_BATCH_LOADED"] = "CHAT_WIDGET/HISTORY_BATCH_LOADED";
13
14
  })(ChatWidgetEvents || (ChatWidgetEvents = {}));
14
15
  var _default = ChatWidgetEvents;
15
16
  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,7 +48,7 @@ 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
  }
@@ -61,8 +61,8 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
61
61
  ...props
62
62
  };
63
63
 
64
- // if the props is not existent or is not anumber then default to 4
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 : 4;
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;
66
66
  }
67
67
  }, {
68
68
  key: "reset",
@@ -107,12 +107,23 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
107
107
  try {
108
108
  var _ref;
109
109
  const messages = await this.fetchHistoryMessages();
110
- 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) {
111
124
  this.isLastPull = true;
112
125
  // Dispatch event to notify UI that no more history is available
113
126
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
114
- // Also hide the loading banner
115
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
116
127
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
117
128
  Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
118
129
  Description: "History pull completed - no more messages",
@@ -123,8 +134,11 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
123
134
  const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
124
135
  this.processHistoryMessages(messagesDescOrder);
125
136
 
126
- // Dispatch event to hide the loading banner after messages are processed
127
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
137
+ // Signal that a batch of history messages has been added to the store.
138
+ // LazyLoadActivity subscribes to this to apply scroll anchoring after render.
139
+ (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HISTORY_BATCH_LOADED, {
140
+ messageCount: messages.length
141
+ });
128
142
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
129
143
  Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
130
144
  Description: "History pull completed successfully",
@@ -180,7 +194,6 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
180
194
  if (!this.shouldPull()) {
181
195
  // Dispatch event to ensure banner is hidden when no more pulls are needed
182
196
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
183
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
184
197
  return [];
185
198
  }
186
199
  const options = {
@@ -206,24 +219,20 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
206
219
  this.isLastPull = true;
207
220
  // Dispatch event when we reach the end of available history
208
221
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
209
- // Also hide the loading banner
210
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
211
222
  return [];
212
223
  }
213
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
214
224
  return messages;
215
225
  } catch (error) {
216
226
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
217
227
  Event: _TelemetryConstants.TelemetryEvent.FetchPersistentChatHistoryFailed,
218
228
  ExceptionDetails: error
219
229
  });
220
- this.isLastPull = true;
221
- this.pageToken = null;
222
- // Dispatch event when there's an error to stop loading banner
223
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
224
- // Also hide the loading banner
225
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
226
- return [];
230
+
231
+ // On error, dispatch HISTORY_LOAD_ERROR to hide loading banner without marking conversation as ended
232
+ // This allows recovery on the next attempt (e.g., transient network errors)
233
+ // Return null to distinguish error from legitimate empty history
234
+ (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HISTORY_LOAD_ERROR);
235
+ return null;
227
236
  }
228
237
  }
229
238
  }, {
@@ -238,6 +247,9 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
238
247
  value: function processMessageToActivity(message) {
239
248
  try {
240
249
  const activity = (0, _convertPersistentChatHistoryMessageToActivity.default)(message);
250
+ if (!activity) {
251
+ return null;
252
+ }
241
253
  activity.id = activity.id || `activity-${this.count}`;
242
254
  activity.channelData = {
243
255
  ...activity.channelData,
@@ -45,10 +45,11 @@ const createAdapter = async (facadeChatSDK, props) => {
45
45
  //so far, there is no need to convert to the shim adapter when using visual tests
46
46
  const isMocked = facadeChatSDK.getChatSDK() instanceof _mockchatsdk.MockChatSDK;
47
47
  if (isMocked !== true) {
48
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4;
48
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6;
49
49
  const botAuthActivitySubscriberOptionalParams = {
50
50
  fetchBotAuthConfigRetries: (props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.botAuthConfig) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.fetchBotAuthConfigRetries) || defaultBotAuthConfig.fetchBotAuthConfigRetries,
51
- fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval
51
+ fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval,
52
+ fallbackShowSignInCard: props === null || props === void 0 ? void 0 : (_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : (_props$webChatContain6 = _props$webChatContain5.botAuthConfig) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.fallbackShowSignInCard
52
53
  };
53
54
  adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
54
55
  adapter.addSubscriber(new _AddActivitySubscriber.AddActivitySubscriber());
@@ -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%"