@microsoft/omnichannel-chat-widget 1.8.3 → 1.8.4-main.1bfa518

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 (149) hide show
  1. package/README.md +27 -0
  2. package/lib/cjs/common/Constants.js +7 -0
  3. package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
  4. package/lib/cjs/common/telemetry/AppInsightsEvents.js +14 -9
  5. package/lib/cjs/common/telemetry/TelemetryConstants.js +46 -2
  6. package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
  7. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +29 -13
  8. package/lib/cjs/common/utils/SecureEventBus.js +307 -0
  9. package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
  10. package/lib/cjs/common/utils.js +14 -1
  11. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
  12. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +20 -1
  13. package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
  14. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
  15. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
  16. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +290 -0
  17. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  18. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +17 -0
  19. package/lib/cjs/components/livechatwidget/common/endChat.js +33 -10
  20. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -7
  21. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
  22. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  23. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  24. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  25. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
  26. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
  27. package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  28. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +123 -28
  29. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +37 -8
  30. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
  31. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +46 -22
  32. package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
  33. package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
  34. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +103 -0
  35. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
  36. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
  37. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +57 -0
  38. package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +121 -0
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +47 -0
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1058 -0
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +50 -1
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
  50. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
  51. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  52. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  53. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
  54. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
  55. package/lib/cjs/contexts/createReducer.js +15 -0
  56. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  57. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  58. package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
  59. package/lib/esm/common/Constants.js +7 -0
  60. package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
  61. package/lib/esm/common/telemetry/AppInsightsEvents.js +14 -9
  62. package/lib/esm/common/telemetry/TelemetryConstants.js +44 -1
  63. package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
  64. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +30 -14
  65. package/lib/esm/common/utils/SecureEventBus.js +328 -0
  66. package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
  67. package/lib/esm/common/utils.js +11 -0
  68. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
  69. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +20 -1
  70. package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
  71. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
  72. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
  73. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +283 -0
  74. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  75. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +10 -0
  76. package/lib/esm/components/livechatwidget/common/endChat.js +33 -10
  77. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +16 -7
  78. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
  79. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  80. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  81. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  82. package/lib/esm/components/livechatwidget/common/startChat.js +7 -3
  83. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
  84. package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  85. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -29
  86. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +39 -10
  87. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
  88. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +46 -22
  89. package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
  90. package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
  91. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +96 -0
  92. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
  93. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  94. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +49 -0
  95. package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  96. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +114 -0
  97. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
  98. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +39 -0
  99. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1080 -0
  100. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
  101. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +48 -1
  102. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
  103. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
  104. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
  105. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
  106. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
  107. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
  108. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  109. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  110. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
  111. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
  112. package/lib/esm/contexts/createReducer.js +15 -0
  113. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  114. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  115. package/lib/esm/plugins/newMessageEventHandler.js +4 -1
  116. package/lib/types/common/Constants.d.ts +6 -0
  117. package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
  118. package/lib/types/common/telemetry/TelemetryConstants.d.ts +41 -2
  119. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
  120. package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
  121. package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
  122. package/lib/types/common/utils.d.ts +9 -1
  123. package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
  124. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
  125. package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
  126. package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
  127. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
  128. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
  129. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
  130. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +11 -0
  131. package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
  132. package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
  133. package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
  134. package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
  135. package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
  136. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +6 -0
  137. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
  138. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
  139. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
  140. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
  141. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
  142. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
  143. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
  144. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
  145. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
  146. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  147. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +6 -0
  148. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
  149. package/package.json +3 -3
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _SecureEventBus = _interopRequireDefault(require("./SecureEventBus"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ const dispatchCustomEvent = (name, payload) => {
11
+ try {
12
+ const eventBus = _SecureEventBus.default.getInstance();
13
+ const authToken = eventBus.getAuthToken();
14
+
15
+ // Dispatch through the secure event bus instead of global window
16
+ const success = eventBus.dispatch(name, payload, authToken);
17
+ if (!success) {
18
+ console.error("Failed to dispatch secure event:", name);
19
+ }
20
+ } catch (error) {
21
+ console.error("Error dispatching secure custom event:", name, payload, error);
22
+ }
23
+ };
24
+ var _default = dispatchCustomEvent;
25
+ exports.default = _default;
@@ -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.
@@ -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) {
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AddActivitySubscriber = void 0;
7
+ var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstants");
8
+ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
9
+ var _ChatWidgetEvents = _interopRequireDefault(require("../ChatWidgetEvents"));
10
+ var _SecureEventBus = _interopRequireDefault(require("../../../../common/utils/SecureEventBus"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
+ 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); } }
14
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
17
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
18
+ /**
19
+ * The `AddActivitySubscriber` class is responsible for subscribing to the `ADD_ACTIVITY` event
20
+ * from the `ChatWidgetEvents` and notifying an observer when a new activity is added.
21
+ *
22
+ * This class implements the `IActivitySubscriber` interface and acts as a bridge between
23
+ * the event system and the observer pattern.
24
+ */
25
+ let AddActivitySubscriber = /*#__PURE__*/function () {
26
+ /**
27
+ * The observer that will be notified when a new activity is added.
28
+ * This is expected to be an object with a `next` method, such as an RxJS `Observer`.
29
+ */
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+
32
+ /**
33
+ * Set to track processed activity IDs to prevent duplicate processing.
34
+ */
35
+
36
+ /**
37
+ * Unsubscribe function for the secure event listener
38
+ */
39
+
40
+ /**
41
+ * Subscription for PersistentConversationReset event
42
+ */
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+
45
+ /**
46
+ * Constructor initializes the `AddActivitySubscriber` and sets up a secure event listener
47
+ * for the `ChatWidgetEvents.ADD_ACTIVITY` event. When the event is triggered, it checks
48
+ * if the event payload contains an `activity` and notifies the observer.
49
+ */
50
+ function AddActivitySubscriber() {
51
+ _classCallCheck(this, AddActivitySubscriber);
52
+ _defineProperty(this, "observer", void 0);
53
+ _defineProperty(this, "processedActivityIds", new Set());
54
+ _defineProperty(this, "unsubscribeFromSecureEvent", null);
55
+ _defineProperty(this, "resetEventListener", void 0);
56
+ const eventBus = _SecureEventBus.default.getInstance();
57
+
58
+ // Subscribe to the secure event bus instead of global window events
59
+ this.unsubscribeFromSecureEvent = eventBus.subscribe(_ChatWidgetEvents.default.ADD_ACTIVITY, payload => {
60
+ if (payload !== null && payload !== void 0 && payload.activity) {
61
+ var _this$observer;
62
+ const activity = payload.activity;
63
+ const activityId = activity.id;
64
+ if (activity.identifier) {
65
+ if (this.processedActivityIds.has(activity === null || activity === void 0 ? void 0 : activity.identifier)) {
66
+ return; // Skip processing if already handled
67
+ }
68
+ // Add the activity ID to the processed set
69
+ this.processedActivityIds.add(activity === null || activity === void 0 ? void 0 : activity.identifier);
70
+ }
71
+
72
+ // Check if activity has an ID and if it has already been processed
73
+ if (activityId) {
74
+ if (this.processedActivityIds.has(activityId)) {
75
+ return; // Skip processing if already handled
76
+ }
77
+
78
+ // Add the activity ID to the processed set
79
+ this.processedActivityIds.add(activityId);
80
+ }
81
+
82
+ // Notify the observer with the new activity
83
+ (_this$observer = this.observer) === null || _this$observer === void 0 ? void 0 : _this$observer.next(activity);
84
+ }
85
+ });
86
+
87
+ // Subscribe to reset events for cleanup
88
+ this.resetEventListener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.PersistentConversationReset).subscribe(() => {
89
+ this.reset();
90
+ // Clean up the secure event listener when conversation resets
91
+ if (this.unsubscribeFromSecureEvent) {
92
+ this.unsubscribeFromSecureEvent();
93
+ this.unsubscribeFromSecureEvent = null;
94
+ }
95
+ // Unsubscribe from the reset event to prevent accumulation
96
+ if (this.resetEventListener) {
97
+ this.resetEventListener.unsubscribe();
98
+ }
99
+ });
100
+ }
101
+
102
+ /**
103
+ * The `next` method is a placeholder for processing the activity.
104
+ * This method can be overridden or extended as needed.
105
+ *
106
+ * @param activity - The activity object to process.
107
+ * @returns The activity object (asynchronously).
108
+ */
109
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
+ _createClass(AddActivitySubscriber, [{
111
+ key: "next",
112
+ value: async function next(activity) {
113
+ return activity;
114
+ }
115
+
116
+ /**
117
+ * Reset the processed activity IDs when a conversation resets
118
+ */
119
+ }, {
120
+ key: "reset",
121
+ value: function reset() {
122
+ this.processedActivityIds.clear();
123
+ }
124
+ }]);
125
+ return AddActivitySubscriber;
126
+ }();
127
+ exports.AddActivitySubscriber = AddActivitySubscriber;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var ChatWidgetEvents;
8
+ (function (ChatWidgetEvents) {
9
+ ChatWidgetEvents["ADD_ACTIVITY"] = "CHAT_WIDGET/ADD_ACTIVITY";
10
+ ChatWidgetEvents["FETCH_PERSISTENT_CHAT_HISTORY"] = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY";
11
+ ChatWidgetEvents["NO_MORE_HISTORY_AVAILABLE"] = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE";
12
+ ChatWidgetEvents["HISTORY_LOAD_ERROR"] = "CHAT_WIDGET/HISTORY_LOAD_ERROR";
13
+ })(ChatWidgetEvents || (ChatWidgetEvents = {}));
14
+ var _default = ChatWidgetEvents;
15
+ exports.default = _default;
@@ -0,0 +1,290 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
8
+ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
9
+ var _ChatWidgetEvents = _interopRequireDefault(require("./ChatWidgetEvents"));
10
+ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
11
+ var _conversationDividerActivity = _interopRequireDefault(require("../../webchatcontainerstateful/common/activities/conversationDividerActivity"));
12
+ var _convertPersistentChatHistoryMessageToActivity = _interopRequireDefault(require("../../webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity"));
13
+ var _utils = require("../../../common/utils");
14
+ var _defaultPersistentChatHistoryProps = require("./defaultProps/defaultPersistentChatHistoryProps");
15
+ var _dispatchCustomEvent = _interopRequireDefault(require("../../../common/utils/dispatchCustomEvent"));
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
+ 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); } }
19
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
20
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
22
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
23
+ /**
24
+ * Class responsible for handling persistent conversation history
25
+ */
26
+ let PersistentConversationHandler = /*#__PURE__*/function () {
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+
29
+ function PersistentConversationHandler(facadeChatSDK, props) {
30
+ _classCallCheck(this, PersistentConversationHandler);
31
+ _defineProperty(this, "appliedProps", {
32
+ ..._defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps
33
+ });
34
+ _defineProperty(this, "isLastPull", false);
35
+ _defineProperty(this, "pageToken", null);
36
+ _defineProperty(this, "facadeChatSDK", void 0);
37
+ _defineProperty(this, "lastMessage", null);
38
+ _defineProperty(this, "count", 0);
39
+ _defineProperty(this, "pageSize", _defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps.pageSize);
40
+ _defineProperty(this, "isCurrentlyPulling", false);
41
+ _defineProperty(this, "pageTokenInTransitSet", new Set());
42
+ _defineProperty(this, "resetEventListener", _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.PersistentConversationReset).subscribe(() => {
43
+ this.reset();
44
+ }));
45
+ this.facadeChatSDK = facadeChatSDK;
46
+ this.appliedPropsHandler(props);
47
+ _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
48
+ Event: _TelemetryConstants.TelemetryEvent.LCWPersistentConversationHandlerInitialized,
49
+ Description: "PersistentConversationHandler initialized",
50
+ CustomProperties: {
51
+ pageSize: _defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps.pageSize
52
+ }
53
+ });
54
+ }
55
+ _createClass(PersistentConversationHandler, [{
56
+ key: "appliedPropsHandler",
57
+ value: function appliedPropsHandler(props) {
58
+ var _this$appliedProps;
59
+ this.appliedProps = {
60
+ ..._defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps,
61
+ ...props
62
+ };
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;
66
+ }
67
+ }, {
68
+ key: "reset",
69
+ value: function reset() {
70
+ this.isLastPull = false;
71
+ this.pageToken = null;
72
+ this.lastMessage = null;
73
+ this.count = 0;
74
+ this.isCurrentlyPulling = false;
75
+ this.pageTokenInTransitSet.clear();
76
+ }
77
+ }, {
78
+ key: "destroy",
79
+ value: function destroy() {
80
+ // Only unsubscribe when the handler is being destroyed completely
81
+ this.resetEventListener.unsubscribe();
82
+ }
83
+ }, {
84
+ key: "pullHistory",
85
+ value: async function pullHistory() {
86
+ const pullTimer = (0, _utils.createTimer)();
87
+
88
+ // Prevent concurrent pulls regardless of pageToken
89
+ if (this.isCurrentlyPulling) {
90
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
91
+ Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullBlocked,
92
+ Description: "History pull blocked - already in progress"
93
+ });
94
+ return;
95
+ }
96
+
97
+ // Additional check for specific pageToken duplicates
98
+ if (this.pageToken && this.pageTokenInTransitSet.has(this.pageToken)) {
99
+ return;
100
+ }
101
+
102
+ // Mark as currently pulling
103
+ this.isCurrentlyPulling = true;
104
+ if (this.pageToken) {
105
+ this.pageTokenInTransitSet.add(this.pageToken);
106
+ }
107
+ try {
108
+ var _ref;
109
+ const messages = await this.fetchHistoryMessages();
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) {
124
+ this.isLastPull = true;
125
+ // Dispatch event to notify UI that no more history is available
126
+ (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
127
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
128
+ Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
129
+ Description: "History pull completed - no more messages",
130
+ ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed
131
+ });
132
+ return;
133
+ }
134
+ const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
135
+ this.processHistoryMessages(messagesDescOrder);
136
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
137
+ Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
138
+ Description: "History pull completed successfully",
139
+ ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed,
140
+ CustomProperties: {
141
+ messageCount: messages.length,
142
+ totalProcessed: this.count
143
+ }
144
+ });
145
+ } finally {
146
+ // Always clear the pulling flag when done
147
+ this.isCurrentlyPulling = false;
148
+
149
+ // Remove pageToken from transit set if it was added
150
+ if (this.pageToken) {
151
+ this.pageTokenInTransitSet.delete(this.pageToken);
152
+ }
153
+ }
154
+ }
155
+
156
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
157
+ }, {
158
+ key: "processHistoryMessages",
159
+ value: function processHistoryMessages(messagesDescOrder) {
160
+ for (const message of messagesDescOrder) {
161
+ try {
162
+ const activity = this.processMessageToActivity(message);
163
+ if (activity) {
164
+ (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.ADD_ACTIVITY, {
165
+ activity
166
+ });
167
+ const dividerActivity = this.createDividerActivity(activity);
168
+ if (dividerActivity) {
169
+ (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.ADD_ACTIVITY, {
170
+ activity: dividerActivity
171
+ });
172
+ }
173
+ this.lastMessage = activity;
174
+ }
175
+ } catch (error) {
176
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
177
+ Event: _TelemetryConstants.TelemetryEvent.ConvertPersistentChatHistoryMessageToActivityFailed,
178
+ ExceptionDetails: error
179
+ });
180
+ }
181
+ }
182
+ }
183
+
184
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
+ }, {
186
+ key: "fetchHistoryMessages",
187
+ value: async function fetchHistoryMessages() {
188
+ if (!this.shouldPull()) {
189
+ // Dispatch event to ensure banner is hidden when no more pulls are needed
190
+ (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
191
+ return [];
192
+ }
193
+ const options = {
194
+ pageSize: this.pageSize,
195
+ pageToken: this.pageToken || undefined
196
+ };
197
+ try {
198
+ var _this$facadeChatSDK;
199
+ const response = await ((_this$facadeChatSDK = this.facadeChatSDK) === null || _this$facadeChatSDK === void 0 ? void 0 : _this$facadeChatSDK.fetchPersistentConversationHistory(options));
200
+ const {
201
+ chatMessages: messages,
202
+ nextPageToken: pageToken
203
+ } = response;
204
+ this.pageToken = pageToken || null;
205
+ if (pageToken === null) {
206
+ this.isLastPull = true;
207
+ // Dispatch event when we reach the end of available history
208
+ (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
209
+ }
210
+
211
+ // if chatMessages is null, return empty array
212
+ if (!messages) {
213
+ this.isLastPull = true;
214
+ // Dispatch event when we reach the end of available history
215
+ (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
216
+ return [];
217
+ }
218
+ return messages;
219
+ } catch (error) {
220
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
221
+ Event: _TelemetryConstants.TelemetryEvent.FetchPersistentChatHistoryFailed,
222
+ ExceptionDetails: error
223
+ });
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;
230
+ }
231
+ }
232
+ }, {
233
+ key: "shouldPull",
234
+ value: function shouldPull() {
235
+ return !this.isLastPull;
236
+ }
237
+
238
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
239
+ }, {
240
+ key: "processMessageToActivity",
241
+ value: function processMessageToActivity(message) {
242
+ try {
243
+ const activity = (0, _convertPersistentChatHistoryMessageToActivity.default)(message);
244
+ activity.id = activity.id || `activity-${this.count}`;
245
+ activity.channelData = {
246
+ ...activity.channelData,
247
+ metadata: {
248
+ count: this.count
249
+ }
250
+ };
251
+
252
+ // Increment the count after assigning it to the activity
253
+ this.count += 1;
254
+ return activity;
255
+ } catch (error) {
256
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
257
+ Event: _TelemetryConstants.TelemetryEvent.ConvertPersistentChatHistoryMessageToActivityFailed,
258
+ ExceptionDetails: error
259
+ });
260
+ throw error;
261
+ }
262
+ }
263
+
264
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
265
+ }, {
266
+ key: "createDividerActivity",
267
+ value: function createDividerActivity(activity) {
268
+ var _this$lastMessage, _this$lastMessage$cha;
269
+ if (((_this$lastMessage = this.lastMessage) === null || _this$lastMessage === void 0 ? void 0 : (_this$lastMessage$cha = _this$lastMessage.channelData) === null || _this$lastMessage$cha === void 0 ? void 0 : _this$lastMessage$cha.conversationId) !== activity.channelData.conversationId) {
270
+ const rawSequenceId = activity.channelData["webchat:sequence-id"];
271
+ const sequenceId = typeof rawSequenceId === "number" && !isNaN(rawSequenceId) ? rawSequenceId + 1 : 1;
272
+ const timestamp = new Date(activity.timestamp).getTime() + 1;
273
+ return {
274
+ ..._conversationDividerActivity.default,
275
+ channelData: {
276
+ ..._conversationDividerActivity.default.channelData,
277
+ conversationId: activity.channelData.conversationId,
278
+ "webchat:sequence-id": sequenceId
279
+ },
280
+ timestamp: new Date(timestamp).toISOString(),
281
+ identifier: `divider-${activity.channelData.conversationId}`
282
+ };
283
+ }
284
+ return null;
285
+ }
286
+ }]);
287
+ return PersistentConversationHandler;
288
+ }();
289
+ var _default = PersistentConversationHandler;
290
+ exports.default = _default;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createAdapter = void 0;
7
+ var _AddActivitySubscriber = require("./ActivitySubscriber/AddActivitySubscriber");
7
8
  var _BotAuthActivitySubscriber = require("./ActivitySubscriber/BotAuthActivitySubscriber");
8
9
  var _ChatAdapterShim = require("./ChatAdapterShim");
9
10
  var _HiddenAdaptiveCardActivitySubscriber = require("./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber");
@@ -50,6 +51,7 @@ const createAdapter = async (facadeChatSDK, props) => {
50
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
52
  };
52
53
  adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
54
+ adapter.addSubscriber(new _AddActivitySubscriber.AddActivitySubscriber());
53
55
  adapter.addSubscriber(new _PauseActivitySubscriber.PauseActivitySubscriber());
54
56
  adapter.addSubscriber(new _BotAuthActivitySubscriber.BotAuthActivitySubscriber(botAuthActivitySubscriberOptionalParams));
55
57
  // Remove this code after ICM ID:544623085 is fixed
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.defaultPersistentChatHistoryProps = void 0;
7
+ const defaultPersistentChatHistoryProps = {
8
+ pageSize: 10,
9
+ dividerActivityStyle: {
10
+ border: "1px solid rgb(96, 94, 92, 0.5)",
11
+ margin: "10px 20%"
12
+ },
13
+ bannerStyle: {
14
+ margin: "10px auto"
15
+ }
16
+ };
17
+ exports.defaultPersistentChatHistoryProps = defaultPersistentChatHistoryProps;