@microsoft/omnichannel-chat-widget 1.8.3-main.ec1328d → 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 (204) hide show
  1. package/README.md +27 -0
  2. package/lib/cjs/common/Constants.js +9 -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 +49 -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/CitationDim.js +29 -0
  13. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +218 -0
  14. package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
  15. package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  16. package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
  17. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
  18. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
  19. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  20. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
  21. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +290 -0
  22. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  23. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +17 -0
  24. package/lib/cjs/components/livechatwidget/common/endChat.js +54 -12
  25. package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  26. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -7
  27. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
  28. package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  29. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  30. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  31. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  32. package/lib/cjs/components/livechatwidget/common/startChat.js +10 -5
  33. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
  34. package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
  35. package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  36. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +152 -33
  37. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +37 -8
  38. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
  39. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +135 -26
  40. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  41. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  42. package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
  43. package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
  44. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +103 -0
  45. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
  46. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
  47. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  48. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +36 -2
  49. package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
  50. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +57 -0
  51. package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  52. package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  53. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +121 -0
  54. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
  55. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +47 -0
  56. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1058 -0
  57. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
  58. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +50 -1
  59. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
  60. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  61. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
  62. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  63. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
  64. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
  65. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
  66. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
  67. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +102 -30
  68. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  69. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  70. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +47 -45
  71. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +9 -1
  72. package/lib/cjs/contexts/createReducer.js +30 -0
  73. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  74. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  75. package/lib/cjs/index.js +9 -1
  76. package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
  77. package/lib/esm/common/Constants.js +9 -0
  78. package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
  79. package/lib/esm/common/telemetry/AppInsightsEvents.js +14 -9
  80. package/lib/esm/common/telemetry/TelemetryConstants.js +47 -1
  81. package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
  82. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +30 -14
  83. package/lib/esm/common/utils/SecureEventBus.js +328 -0
  84. package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
  85. package/lib/esm/common/utils.js +11 -0
  86. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
  87. package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
  88. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +207 -0
  89. package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
  90. package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
  91. package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
  92. package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
  93. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
  94. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
  95. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
  96. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +283 -0
  97. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  98. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +10 -0
  99. package/lib/esm/components/livechatwidget/common/endChat.js +55 -13
  100. package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
  101. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +16 -7
  102. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
  103. package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
  104. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  105. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  106. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  107. package/lib/esm/components/livechatwidget/common/startChat.js +12 -7
  108. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
  109. package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
  110. package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  111. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +153 -34
  112. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +39 -10
  113. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
  114. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +135 -27
  115. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -14
  116. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
  117. package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
  118. package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
  119. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +96 -0
  120. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
  121. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  122. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
  123. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +32 -0
  124. package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
  125. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +49 -0
  126. package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
  127. package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  128. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +114 -0
  129. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
  130. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +39 -0
  131. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1080 -0
  132. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
  133. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +48 -1
  134. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
  135. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  136. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
  137. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
  138. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
  139. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
  140. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
  141. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
  142. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +103 -30
  143. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  144. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +2 -2
  145. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +47 -45
  146. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +9 -1
  147. package/lib/esm/contexts/createReducer.js +30 -0
  148. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  149. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  150. package/lib/esm/index.js +1 -0
  151. package/lib/esm/plugins/newMessageEventHandler.js +4 -1
  152. package/lib/types/common/Constants.d.ts +8 -0
  153. package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
  154. package/lib/types/common/telemetry/TelemetryConstants.d.ts +44 -2
  155. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
  156. package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
  157. package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
  158. package/lib/types/common/utils.d.ts +9 -1
  159. package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
  160. package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
  161. package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
  162. package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
  163. package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
  164. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
  165. package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
  166. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
  167. package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
  168. package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
  169. package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
  170. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
  171. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
  172. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -1
  173. package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
  174. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +11 -0
  175. package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
  176. package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
  177. package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
  178. package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
  179. package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
  180. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +6 -1
  181. package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
  182. package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
  183. package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
  184. package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
  185. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +6 -0
  186. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
  187. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
  188. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
  189. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
  190. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
  191. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
  192. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
  193. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
  194. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +3 -4
  195. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
  196. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
  197. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -0
  198. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +6 -0
  199. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +47 -45
  200. package/lib/types/index.d.ts +1 -0
  201. package/package.json +3 -3
  202. /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  203. /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
  204. /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
@@ -1,10 +1,13 @@
1
1
  import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
- import { ConfirmationState, Constants, ConversationEndEntity, ParticipantType, PrepareEndChatDescriptionConstants } from "../../../common/Constants";
2
+ import { ConfirmationState, Constants, ConversationEndEntity, LiveWorkItemState, ParticipantType, PrepareEndChatDescriptionConstants } from "../../../common/Constants";
3
3
  import { getConversationDetailsCall, getWidgetEndChatEventName } from "../../../common/utils";
4
4
  import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
5
5
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
6
6
  import { ConversationState } from "../../../contexts/common/ConversationState";
7
+ import { LazyLoadHandler } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity";
7
8
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
9
+ import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
10
+ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
8
11
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
9
12
  import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
10
13
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
@@ -39,7 +42,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
39
42
  }
40
43
 
41
44
  // Use Case: If ended by Agent, stay chat in InActive state
42
- let isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
45
+ const isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
43
46
  if (isConversationalSurveyEnabled && ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.conversationEndedBy) === ConversationEndEntity.Bot)) {
44
47
  dispatch({
45
48
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
@@ -147,8 +150,23 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
147
150
  type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
148
151
  payload: null
149
152
  });
153
+ let isSessionEnded = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.chatDisconnectEventReceived;
154
+ if (!isSessionEnded) {
155
+ // double check by fetching the latest conversation details
156
+ const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
157
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.WrapUp || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state) === LiveWorkItemState.Closed) {
158
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
159
+ Event: TelemetryEvent.ChatDisconnectThreadEventReceived,
160
+ Description: "Checking conversation details upon endChat. Chat disconnected.",
161
+ CustomProperties: {
162
+ conversationDetails
163
+ }
164
+ });
165
+ isSessionEnded = true;
166
+ }
167
+ }
150
168
  const endChatOptionalParameters = {
151
- isSessionEnded: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.chatDisconnectEventReceived
169
+ isSessionEnded
152
170
  };
153
171
  try {
154
172
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
@@ -179,6 +197,18 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
179
197
  facadeChatSDK.destroy();
180
198
  }
181
199
  }
200
+
201
+ //moving logic below to before processing skipCloseChat logic to avoid race conditions of postMessage for endChatEvent for other tabs vs postMessage for CloseChat
202
+ //TODO: clarify if this postMessageToOtherTab actually works in production.
203
+ if (postMessageToOtherTab) {
204
+ const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
205
+ BroadcastService.postMessage({
206
+ eventName: endChatEventName,
207
+ payload: {
208
+ runtimeId: TelemetryManager.InternalTelemetryData.lcwRuntimeId
209
+ }
210
+ });
211
+ }
182
212
  if (!skipCloseChat) {
183
213
  try {
184
214
  var _props$webChatContain;
@@ -210,20 +240,25 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
210
240
  type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
211
241
  payload: undefined
212
242
  });
213
- // Always allow to close the chat for embedded mode irrespective of end chat errors
243
+
244
+ // Call direct reset to ensure LazyLoadHandler gets reset regardless of broadcast timing
245
+ LazyLoadHandler.directReset();
246
+ BroadcastService.postMessage({
247
+ eventName: BroadcastEvent.PersistentConversationReset
248
+ });
214
249
  closeChatWidget(dispatch, setWebChatStyles, props);
215
250
  facadeChatSDK.destroy();
251
+
252
+ //always post the close chat event after chat closed and cleanup completed
253
+ BroadcastService.postMessage({
254
+ eventName: BroadcastEvent.CloseChat
255
+ });
256
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
257
+ Event: TelemetryEvent.CloseChatCall,
258
+ Description: "Broadcasted close chat event"
259
+ });
216
260
  }
217
261
  }
218
- if (postMessageToOtherTab) {
219
- const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
220
- BroadcastService.postMessage({
221
- eventName: endChatEventName,
222
- payload: {
223
- runtimeId: TelemetryManager.InternalTelemetryData.lcwRuntimeId
224
- }
225
- });
226
- }
227
262
  };
228
263
  export const callingStateCleanUp = dispatch => {
229
264
  dispatch({
@@ -296,6 +331,13 @@ export const closeChatStateCleanUp = dispatch => {
296
331
  proactiveChatInNewWindow: false
297
332
  }
298
333
  });
334
+ dispatch({
335
+ type: LiveChatWidgetActionType.SET_CITATIONS,
336
+ payload: {}
337
+ });
338
+
339
+ // Dismiss the chat disconnect notification banner if it was shown
340
+ NotificationHandler.dismissNotification(NotificationScenarios.ChatDisconnect);
299
341
 
300
342
  // Clear live chat context only if chat widget is fully closed to support transcript calls after sessionclose is called
301
343
  dispatch({
@@ -3,14 +3,15 @@ import { DesignerChatSDK } from "../../webchatcontainerstateful/common/DesignerC
3
3
  import { MockChatSDK } from "../../webchatcontainerstateful/common/mockchatsdk";
4
4
 
5
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- export const getMockChatSDKIfApplicable = (chatSDK, type) => {
7
- if (type) {
8
- switch (type.toLowerCase()) {
6
+ export const getMockChatSDKIfApplicable = (chatSDK, mockProps) => {
7
+ if (mockProps !== null && mockProps !== void 0 && mockProps.type) {
8
+ switch (mockProps.type.toLowerCase()) {
9
9
  case "demo":
10
10
  chatSDK = new DemoChatSDK();
11
11
  break;
12
12
  case "designer":
13
13
  chatSDK = new DesignerChatSDK();
14
+ chatSDK.mockMessages = mockProps === null || mockProps === void 0 ? void 0 : mockProps.mockMessages;
14
15
  break;
15
16
  default:
16
17
  chatSDK = new MockChatSDK();
@@ -1,6 +1,7 @@
1
1
  import { ConversationEndEntity, ParticipantType } from "../../../common/Constants";
2
2
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { changeLanguageCodeFormatForWebChat, getConversationDetailsCall } from "../../../common/utils";
4
+ import { getOverriddenLocalizedStrings, localizedStringsBotInitialsMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware";
4
5
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
5
6
  import { Constants } from "../../../common/Constants";
6
7
  import { ConversationState } from "../../../contexts/common/ConversationState";
@@ -12,6 +13,7 @@ import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontro
12
13
  import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
13
14
  import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
14
15
  import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
16
+ import { createActivityStatusMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware";
15
17
  import { createAttachmentMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
16
18
  import createAttachmentUploadValidatorMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware";
17
19
  import { createAvatarMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware";
@@ -39,11 +41,10 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
39
41
  import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
40
42
  import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
41
43
  import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
42
- import { localizedStringsBotInitialsMiddleware, getOverriddenLocalizedStrings } from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware";
43
44
 
44
45
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
46
  export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
46
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain13, _props$webChatContain14, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain15, _props$webChatContain16, _defaultWebChatContai, _props$webChatContain17, _props$webChatContain18, _props$webChatContain19, _props$webChatContain20, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai2, _props$webChatContain23, _props$webChatContain24, _defaultWebChatContai3, _props$webChatContain25, _props$webChatContain26, _props$webChatContain27, _props$webChatContain28;
47
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain13, _props$webChatContain14, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain15, _props$webChatContain16, _state$domainStates$l6, _state$domainStates$l7, _props$webChatContain17, _props$webChatContain18, _props$webChatContain19, _props$webChatContain20, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai, _props$webChatContain23, _props$webChatContain24, _defaultWebChatContai2, _props$webChatContain25, _props$webChatContain26, _props$webChatContain27, _props$webChatContain28;
47
48
  // Add a hook to make all links open a new window
48
49
  postDomPurifyActivities();
49
50
  const localizedTexts = {
@@ -61,6 +62,7 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
61
62
  let webChatStore = WebChatStoreLoader.store;
62
63
  if (!webChatStore) {
63
64
  var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain7;
65
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
66
  const addConversationalSurveyTagsCallback = action => {
65
67
  var _inMemoryState$appSta;
66
68
  const inMemoryState = executeReducer(state, {
@@ -118,7 +120,14 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
118
120
  };
119
121
  webChatStore = createStore({},
120
122
  //initial state
121
- preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), createCustomEventMiddleware(BroadcastService), createQueueOverflowMiddleware(state, dispatch), channelDataMiddleware(addConversationalSurveyTagsCallback), createConversationEndMiddleware(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, createMessageSequenceIdOverrideMiddleware, createCitationsMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware(honorsTargetInHTMLLinks), createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, createCallActionMiddleware(), localizedStringsBotInitialsMiddleware(),
123
+ preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), createCustomEventMiddleware(BroadcastService), createQueueOverflowMiddleware(state, dispatch), channelDataMiddleware(addConversationalSurveyTagsCallback), createConversationEndMiddleware(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, createMessageSequenceIdOverrideMiddleware, createCitationsMiddleware(state, dispatch), gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware(honorsTargetInHTMLLinks), createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, createCallActionMiddleware(),
124
+ // Pass a callback so middleware can push initials into React context for reactivity
125
+ localizedStringsBotInitialsMiddleware(initials => {
126
+ dispatch({
127
+ type: LiveChatWidgetActionType.SET_BOT_AVATAR_INITIALS,
128
+ payload: initials
129
+ });
130
+ }),
122
131
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
132
  ...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
124
133
  WebChatStoreLoader.store = webChatStore;
@@ -161,14 +170,14 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
161
170
  dir: state.domainStates.globalDir,
162
171
  locale: changeLanguageCodeFormatForWebChat(getLocaleStringFromId((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
163
172
  store: webChatStore,
164
- activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : createActivityMiddleware(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
173
+ activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : createActivityMiddleware(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps, localizedTexts),
165
174
  attachmentMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableAttachmentMiddleware ? undefined : createAttachmentMiddleware(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? defaultAttachmentProps.enableInlinePlaying),
166
- activityStatusMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableActivityStatusMiddleware ? undefined : (_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.activityStatusMiddleware,
175
+ activityStatusMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableActivityStatusMiddleware ? undefined : createActivityStatusMiddleware(getLocaleStringFromId((_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : (_state$domainStates$l7 = _state$domainStates$l6.ChatWidgetLanguage) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.msdyn_localeid)),
167
176
  toastMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableToastMiddleware ? undefined : createToastMiddleware(props.notificationPaneProps, endChat),
168
177
  renderMarkdown,
169
178
  avatarMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableAvatarMiddleware ? undefined : createAvatarMiddleware((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
170
- groupActivitiesMiddleware: (_props$webChatContain21 = props.webChatContainerProps) !== null && _props$webChatContain21 !== void 0 && (_props$webChatContain22 = _props$webChatContain21.renderingMiddlewareProps) !== null && _props$webChatContain22 !== void 0 && _props$webChatContain22.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
171
- typingIndicatorMiddleware: (_props$webChatContain23 = props.webChatContainerProps) !== null && _props$webChatContain23 !== void 0 && (_props$webChatContain24 = _props$webChatContain23.renderingMiddlewareProps) !== null && _props$webChatContain24 !== void 0 && _props$webChatContain24.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
179
+ groupActivitiesMiddleware: (_props$webChatContain21 = props.webChatContainerProps) !== null && _props$webChatContain21 !== void 0 && (_props$webChatContain22 = _props$webChatContain21.renderingMiddlewareProps) !== null && _props$webChatContain22 !== void 0 && _props$webChatContain22.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.groupActivitiesMiddleware,
180
+ typingIndicatorMiddleware: (_props$webChatContain23 = props.webChatContainerProps) !== null && _props$webChatContain23 !== void 0 && (_props$webChatContain24 = _props$webChatContain23.renderingMiddlewareProps) !== null && _props$webChatContain24 !== void 0 && _props$webChatContain24.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.typingIndicatorMiddleware,
172
181
  onTelemetry: createWebChatTelemetry(),
173
182
  cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain25 = props.webChatContainerProps) === null || _props$webChatContain25 === void 0 ? void 0 : _props$webChatContain25.botMagicCode) || undefined),
174
183
  sendTypingIndicator: true,
@@ -1,11 +1,13 @@
1
+ import { isNullOrUndefined, parseBooleanFromConfig } from "../../../common/utils";
1
2
  import { ConversationMode } from "../../../common/Constants";
2
- import { isNullOrUndefined } from "../../../common/utils";
3
3
  export const isPostChatSurveyEnabled = async facadeChatSDK => {
4
4
  var _chatConfig$LiveWSAnd;
5
5
  const chatConfig = await facadeChatSDK.getLiveChatConfig();
6
6
  const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
7
7
  return postChatEnabled === "true";
8
8
  };
9
+
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
11
  export const getPostChatSurveyConfig = async facadeChatSDK => {
10
12
  var _chatConfig$LiveWSAnd2, _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4, _chatConfig$LiveWSAnd5, _chatConfig$LiveWSAnd6, _chatConfig$LiveWSAnd7, _chatConfig$LiveWSAnd8, _chatConfig$LiveWSAnd9, _chatConfig$LiveWSAnd10;
11
13
  const chatConfig = await facadeChatSDK.getLiveChatConfig();
@@ -26,5 +28,34 @@ export const isPersistentChatEnabled = conversationMode => {
26
28
  if (isNullOrUndefined(conversationMode)) {
27
29
  return false;
28
30
  }
29
- return (conversationMode === null || conversationMode === void 0 ? void 0 : conversationMode.toString().toLowerCase()) === ConversationMode.Persistent;
31
+ return (conversationMode === null || conversationMode === void 0 ? void 0 : conversationMode.toString()) === ConversationMode.Persistent;
32
+ };
33
+
34
+ /**
35
+ * Determines if persistent chat history should be loaded based on all required conditions.
36
+ *
37
+ * @param extendedChatConfig - The extended chat configuration object
38
+ * @returns true if ALL conditions are met:
39
+ * 1. Conversation mode must be Persistent ("192350001")
40
+ * 2. History is enabled in admin config (msdyn_enablepersistentchatpreviousconversations)
41
+ * 3. History is enabled via feature flag (lcwPersistentChatHistoryEnabled)
42
+ */
43
+ export const shouldLoadPersistentChatHistory = extendedChatConfig => {
44
+ var _extendedChatConfig$L, _extendedChatConfig$L2, _extendedChatConfig$L3;
45
+ // CRITICAL: First check if conversation mode is persistent
46
+ // Only persistent mode ("192350001") should allow history loading
47
+ const isPersistentChatEnabledForWidget = isPersistentChatEnabled(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L === void 0 ? void 0 : _extendedChatConfig$L.msdyn_conversationmode);
48
+ if (!isPersistentChatEnabledForWidget) {
49
+ return false;
50
+ }
51
+
52
+ // Check if history is enabled in admin config (handles both boolean and string "true"/"false")
53
+ const isHistoryEnabledInConfig = parseBooleanFromConfig(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L2 = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L2 === void 0 ? void 0 : _extendedChatConfig$L2.msdyn_enablepersistentchatpreviousconversations);
54
+ if (!isHistoryEnabledInConfig) {
55
+ return false;
56
+ }
57
+
58
+ // Check if history is enabled via feature flag (handles both boolean and string "true"/"false")
59
+ const isHistoryEnabledViaFCB = parseBooleanFromConfig(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L3 = extendedChatConfig.LcwFcbConfiguration) === null || _extendedChatConfig$L3 === void 0 ? void 0 : _extendedChatConfig$L3.lcwPersistentChatHistoryEnabled);
60
+ return isHistoryEnabledViaFCB;
30
61
  };
@@ -1,6 +1,7 @@
1
1
  const overridePropsOnMockIfApplicable = props => {
2
2
  var _props$mock, _props$mock2;
3
3
  if (props !== null && props !== void 0 && (_props$mock = props.mock) !== null && _props$mock !== void 0 && _props$mock.type && (props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type.toLowerCase()) === "designer") {
4
+ var _props$mock3, _props$mock3$mockMess;
4
5
  if (!props.webChatContainerProps) {
5
6
  props.webChatContainerProps = {};
6
7
  }
@@ -16,7 +17,7 @@ const overridePropsOnMockIfApplicable = props => {
16
17
  props.webChatContainerProps = {
17
18
  ...props.webChatContainerProps,
18
19
  webChatProps: {
19
- disabled: true,
20
+ disabled: !(props !== null && props !== void 0 && (_props$mock3 = props.mock) !== null && _props$mock3 !== void 0 && (_props$mock3$mockMess = _props$mock3.mockMessages) !== null && _props$mock3$mockMess !== void 0 && _props$mock3$mockMess.length),
20
21
  ...props.webChatContainerProps.webChatProps,
21
22
  overrideLocalizedStrings: {
22
23
  TEXT_INPUT_PLACEHOLDER: "Send a message . . .",
@@ -24,7 +24,10 @@ export const registerTelemetryLoggers = (props, dispatch) => {
24
24
  appInsightsConfig: Object.assign({}, defaultAppInsightsConfig, props.appInsightsConfig)
25
25
  };
26
26
  if (props.chatConfig) {
27
+ var _props$chatConfig$Liv;
27
28
  telemetryData = TelemetryHelper.addChatConfigDataToTelemetry(props === null || props === void 0 ? void 0 : props.chatConfig, telemetryData);
29
+ //store AppInsights instrumentation key from chatConfig if present
30
+ telemetryData.chatConfigAppInsightsKey = (_props$chatConfig$Liv = props.chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.AppInsightsInstrumentationKey;
28
31
  }
29
32
  if (!((_props$chatSDK = props.chatSDK) !== null && _props$chatSDK !== void 0 && (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) !== null && _props$chatSDK$omnich !== void 0 && _props$chatSDK$omnich.orgId) || ((_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.orgId.trim().length) === 0) {
30
33
  throw new Error("orgId is undefined in ChatSDK");
@@ -149,7 +149,7 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
149
149
  if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
150
150
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
151
151
  const context = await facadeChatSDK.getPostChatSurveyContext();
152
- TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
152
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
153
153
  Event: TelemetryEvent.PostChatContextCallSucceed,
154
154
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
155
155
  });
@@ -167,7 +167,7 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
167
167
  }
168
168
  }
169
169
  } catch (error) {
170
- TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.ERROR, {
170
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
171
171
  Event: TelemetryEvent.PostChatContextCallFailed,
172
172
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallFailed,
173
173
  ExceptionDetails: {
@@ -19,13 +19,13 @@ export const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, p
19
19
  const postChatEnabled = postChatConfig.postChatEnabled;
20
20
  if (postChatEnabled) {
21
21
  if (!persistedChat) {
22
- TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
22
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
23
23
  Event: TelemetryEvent.PostChatContextCallStarted,
24
24
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallStarted
25
25
  });
26
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
27
  const context = await facadeChatSDK.getPostChatSurveyContext();
28
- TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
28
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
29
29
  Event: TelemetryEvent.PostChatContextCallSucceed,
30
30
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
31
31
  });
@@ -42,7 +42,7 @@ export const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, p
42
42
  }
43
43
  }
44
44
  } catch (ex) {
45
- TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.ERROR, {
45
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
46
46
  Event: TelemetryEvent.PostChatContextCallFailed,
47
47
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallFailed,
48
48
  ExceptionDetails: {
@@ -1,9 +1,9 @@
1
- import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
+ import { BroadcastEvent, ConversationStage, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
2
  import { Constants, LiveWorkItemState, WidgetLoadTelemetryMessage } from "../../../common/Constants";
3
3
  import { TelemetryManager, TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
4
4
  import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty } from "../../../common/utils";
5
5
  import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
6
- import { handleStartChatError, logWidgetLoadComplete } from "./startChatErrorHandler";
6
+ import { handleStartChatError, logStartChatComplete, logWidgetLoadComplete } from "./startChatErrorHandler";
7
7
  import { ActivityStreamHandler } from "./ActivityStreamHandler";
8
8
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
9
9
  import { ConversationState } from "../../../contexts/common/ConversationState";
@@ -99,7 +99,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
99
99
 
100
100
  // If minimized, maximize the chat, if the state is missing, consider it as minimized
101
101
  if ((state === null || state === void 0 ? void 0 : state.appStates.isMinimized) === undefined || (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.isMinimized) === true) {
102
- var _state$domainStates3, _state$domainStates3$, _state$domainStates4, _state$domainStates4$;
102
+ var _state$domainStates3, _state$domainStates3$, _state$domainStates4, _state$domainStates4$, _TelemetryManager$Int;
103
103
  dispatch({
104
104
  type: LiveChatWidgetActionType.SET_MINIMIZED,
105
105
  payload: false
@@ -110,7 +110,8 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
110
110
  eventName: BroadcastEvent.MaximizeChat,
111
111
  payload: {
112
112
  height: state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : (_state$domainStates3$ = _state$domainStates3.widgetSize) === null || _state$domainStates3$ === void 0 ? void 0 : _state$domainStates3$.height,
113
- width: state === null || state === void 0 ? void 0 : (_state$domainStates4 = state.domainStates) === null || _state$domainStates4 === void 0 ? void 0 : (_state$domainStates4$ = _state$domainStates4.widgetSize) === null || _state$domainStates4$ === void 0 ? void 0 : _state$domainStates4$.width
113
+ width: state === null || state === void 0 ? void 0 : (_state$domainStates4 = state.domainStates) === null || _state$domainStates4 === void 0 ? void 0 : (_state$domainStates4$ = _state$domainStates4.widgetSize) === null || _state$domainStates4$ === void 0 ? void 0 : _state$domainStates4$.width,
114
+ runtimeId: TelemetryManager === null || TelemetryManager === void 0 ? void 0 : (_TelemetryManager$Int = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.lcwRuntimeId
114
115
  }
115
116
  });
116
117
  }
@@ -131,7 +132,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
131
132
  * This is because a new change to control OOH as closed event when a widget is coming from chat.
132
133
  */
133
134
  if ((state === null || state === void 0 ? void 0 : state.appStates.isMinimized) === undefined || (state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.isMinimized) === true) {
134
- var _state$domainStates5, _state$domainStates5$, _state$domainStates6, _state$domainStates6$, _TelemetryManager$Int;
135
+ var _state$domainStates5, _state$domainStates5$, _state$domainStates6, _state$domainStates6$, _TelemetryManager$Int2;
135
136
  dispatch({
136
137
  type: LiveChatWidgetActionType.SET_MINIMIZED,
137
138
  payload: false
@@ -142,7 +143,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
142
143
  payload: {
143
144
  height: state === null || state === void 0 ? void 0 : (_state$domainStates5 = state.domainStates) === null || _state$domainStates5 === void 0 ? void 0 : (_state$domainStates5$ = _state$domainStates5.widgetSize) === null || _state$domainStates5$ === void 0 ? void 0 : _state$domainStates5$.height,
144
145
  width: state === null || state === void 0 ? void 0 : (_state$domainStates6 = state.domainStates) === null || _state$domainStates6 === void 0 ? void 0 : (_state$domainStates6$ = _state$domainStates6.widgetSize) === null || _state$domainStates6$ === void 0 ? void 0 : _state$domainStates6$.width,
145
- runtimeId: TelemetryManager === null || TelemetryManager === void 0 ? void 0 : (_TelemetryManager$Int = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.lcwRuntimeId
146
+ runtimeId: TelemetryManager === null || TelemetryManager === void 0 ? void 0 : (_TelemetryManager$Int2 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int2 === void 0 ? void 0 : _TelemetryManager$Int2.lcwRuntimeId
146
147
  }
147
148
  });
148
149
  }
@@ -173,7 +174,10 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
173
174
  TelemetryTimers.WidgetLoadTimer = createTimer();
174
175
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
175
176
  Event: TelemetryEvent.WidgetLoadStarted,
176
- Description: "Widget start chat started."
177
+ Description: "Widget start chat started.",
178
+ CustomProperties: {
179
+ ConversationStage: ConversationStage.Initialization
180
+ }
177
181
  });
178
182
 
179
183
  //Check if chat retrieved from cache
@@ -201,6 +205,7 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
201
205
  const startTime = new Date().getTime();
202
206
  createTrackingForFirstMessage();
203
207
  await facadeChatSDK.startChat(startChatOptionalParams);
208
+ logStartChatComplete();
204
209
  isStartChatSuccessful = true;
205
210
  await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, startTime, props);
206
211
  } catch (error) {
@@ -1,5 +1,5 @@
1
1
  import { ChatSDKError, ChatSDKErrorName } from "@microsoft/omnichannel-chat-sdk";
2
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
+ import { ConversationStage, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { PrepareEndChatDescriptionConstants, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
4
4
  import { callingStateCleanUp, chatSDKStateCleanUp, closeChatStateCleanUp, endChatStateCleanUp } from "./endChat";
5
5
  import { ConversationState } from "../../../contexts/common/ConversationState";
@@ -118,7 +118,10 @@ const logWidgetLoadFailed = ex => {
118
118
  Event: TelemetryEvent.WidgetLoadFailed,
119
119
  Description: "Widget load complete with error",
120
120
  ExceptionDetails: exDetails,
121
- ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
121
+ ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed,
122
+ CustomProperties: {
123
+ ConversationStage: ConversationStage.Initialization
124
+ }
122
125
  });
123
126
  };
124
127
  export const logWidgetLoadComplete = additionalMessage => {
@@ -133,6 +136,16 @@ export const logWidgetLoadComplete = additionalMessage => {
133
136
  ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
134
137
  });
135
138
  };
139
+ export const logStartChatComplete = additionalMessage => {
140
+ let descriptionString = "Start chat complete";
141
+ if (additionalMessage) {
142
+ descriptionString += `. ${additionalMessage}`;
143
+ }
144
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
145
+ Event: TelemetryEvent.StartChatComplete,
146
+ Description: descriptionString
147
+ });
148
+ };
136
149
  const logWidgetLoadCompleteWithError = ex => {
137
150
  var _TelemetryTimers$Widg3;
138
151
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -149,7 +162,10 @@ const logWidgetLoadCompleteWithError = ex => {
149
162
  Event: TelemetryEvent.WidgetLoadFailed,
150
163
  Description: "Widget load complete with error",
151
164
  ExceptionDetails: exDetails,
152
- ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
165
+ ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed,
166
+ CustomProperties: {
167
+ ConversationStage: ConversationStage.Initialization
168
+ }
153
169
  });
154
170
  };
155
171
  export const logWidgetLoadWithUnexpectedError = ex => {
@@ -177,7 +193,10 @@ export const logWidgetLoadWithUnexpectedError = ex => {
177
193
  Event: TelemetryEvent.WidgetLoadFailed,
178
194
  Description: "Widget load with unexpected error",
179
195
  ExceptionDetails: exDetails,
180
- ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
196
+ ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed,
197
+ CustomProperties: {
198
+ ConversationStage: ConversationStage.Initialization
199
+ }
181
200
  });
182
201
  };
183
202
 
@@ -1,6 +1,6 @@
1
- var LiveChatWidgetMockType;
1
+ export let LiveChatWidgetMockType;
2
2
  (function (LiveChatWidgetMockType) {
3
3
  LiveChatWidgetMockType["Test"] = "Test";
4
4
  LiveChatWidgetMockType["Demo"] = "Demo";
5
- })(LiveChatWidgetMockType || (LiveChatWidgetMockType = {}));
6
- export {};
5
+ LiveChatWidgetMockType["Designer"] = "Designer";
6
+ })(LiveChatWidgetMockType || (LiveChatWidgetMockType = {}));