@microsoft/omnichannel-chat-widget 0.1.0-main.8e79cb8 → 0.1.0-main.94f4f7a

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 (332) hide show
  1. package/README.md +7 -2
  2. package/lib/cjs/assets/Icons.js +4 -2
  3. package/lib/cjs/common/Constants.js +34 -163
  4. package/lib/cjs/common/KeyCodes.js +3 -4
  5. package/lib/cjs/common/contextDataStore/DataStoreManager.js +3 -5
  6. package/lib/cjs/common/storage/default/defaultCacheManager.js +26 -0
  7. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +111 -0
  8. package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +78 -0
  9. package/lib/cjs/common/telemetry/TelemetryConstants.js +82 -29
  10. package/lib/cjs/common/telemetry/TelemetryHelper.js +21 -59
  11. package/lib/cjs/common/telemetry/TelemetryManager.js +3 -32
  12. package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +0 -2
  13. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +30 -36
  14. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +0 -9
  15. package/lib/cjs/common/utils.js +85 -92
  16. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +8 -46
  17. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -25
  18. package/lib/cjs/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
  19. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +18 -50
  20. package/lib/cjs/components/dimlayer/DimLayer.js +0 -4
  21. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +9 -37
  22. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -8
  23. package/lib/cjs/components/footerstateful/FooterStateful.js +11 -42
  24. package/lib/cjs/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +0 -6
  25. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +14 -43
  26. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -8
  27. package/lib/cjs/components/headerstateful/HeaderStateful.js +21 -32
  28. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +2 -14
  29. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +39 -0
  30. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
  31. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +20 -0
  32. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  33. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +34 -0
  34. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +64 -0
  35. package/lib/cjs/components/livechatwidget/common/Deferred.js +37 -0
  36. package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
  37. package/lib/cjs/components/livechatwidget/common/authHelper.js +50 -0
  38. package/lib/cjs/components/livechatwidget/common/createAdapter.js +12 -9
  39. package/lib/cjs/components/livechatwidget/common/createFooter.js +4 -23
  40. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -10
  41. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +36 -43
  42. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultScrollBarProps.js +14 -0
  43. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +133 -51
  44. package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +0 -3
  45. package/lib/cjs/components/livechatwidget/common/endChat.js +86 -63
  46. package/lib/cjs/components/livechatwidget/common/getGeneralStylesForButton.js +0 -6
  47. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +7 -16
  48. package/lib/cjs/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -8
  49. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +29 -88
  50. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +76 -129
  51. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +4 -17
  52. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +247 -14
  53. package/lib/cjs/components/livechatwidget/common/shareObservable.js +41 -0
  54. package/lib/cjs/components/livechatwidget/common/startChat.js +235 -127
  55. package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +0 -8
  56. package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +2 -11
  57. package/lib/cjs/components/livechatwidget/interfaces/IScrollBarProps.js +1 -0
  58. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +355 -207
  59. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +26 -19
  60. package/lib/cjs/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +57 -0
  61. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +4 -17
  62. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +4 -17
  63. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +32 -23
  64. package/lib/cjs/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
  65. package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +13 -0
  66. package/lib/cjs/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
  67. package/lib/cjs/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  68. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +11 -43
  69. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  70. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +19 -33
  71. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +6 -24
  72. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -19
  73. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -7
  74. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -6
  75. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
  76. package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +12 -27
  77. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -17
  78. package/lib/cjs/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -24
  79. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +5 -15
  80. package/lib/cjs/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -8
  81. package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  82. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  83. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +12 -0
  84. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -5
  85. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
  86. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
  87. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
  88. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
  89. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
  90. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
  91. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
  92. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
  93. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +0 -7
  94. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -5
  95. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -37
  96. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +10 -22
  97. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +25 -61
  98. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +7 -15
  99. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  100. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +82 -0
  101. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
  102. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +10 -0
  103. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -3
  104. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -3
  105. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +10 -0
  106. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -9
  107. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +89 -0
  108. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +7 -18
  109. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +8 -42
  110. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +4 -22
  111. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +20 -33
  112. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +3 -9
  113. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +6 -34
  114. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -10
  115. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +1 -12
  116. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +17 -19
  117. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +1 -9
  118. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -9
  119. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -34
  120. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +1 -10
  121. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +7 -11
  122. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +5 -14
  123. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -21
  124. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +0 -12
  125. package/lib/cjs/contexts/ChatAdapterStore.js +0 -2
  126. package/lib/cjs/contexts/ChatContextStore.js +0 -2
  127. package/lib/cjs/contexts/ChatSDKStore.js +0 -2
  128. package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
  129. package/lib/cjs/contexts/common/ConversationState.js +3 -3
  130. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +32 -26
  131. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +18 -14
  132. package/lib/cjs/contexts/createReducer.js +183 -104
  133. package/lib/cjs/controller/componentController.js +4 -33
  134. package/lib/cjs/hooks/useChatAdapterStore.js +0 -6
  135. package/lib/cjs/hooks/useChatContextStore.js +0 -6
  136. package/lib/cjs/hooks/useChatSDKStore.js +0 -6
  137. package/lib/cjs/hooks/useDebounce.js +28 -0
  138. package/lib/cjs/hooks/useWindowDimensions.js +30 -0
  139. package/lib/cjs/index.js +0 -5
  140. package/lib/cjs/plugins/newMessageEventHandler.js +29 -36
  141. package/lib/esm/assets/Icons.js +2 -1
  142. package/lib/esm/common/Constants.js +31 -150
  143. package/lib/esm/common/KeyCodes.js +3 -3
  144. package/lib/esm/common/contextDataStore/DataStoreManager.js +3 -3
  145. package/lib/esm/common/storage/default/defaultCacheManager.js +18 -0
  146. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +104 -0
  147. package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +70 -0
  148. package/lib/esm/common/telemetry/TelemetryConstants.js +86 -26
  149. package/lib/esm/common/telemetry/TelemetryHelper.js +21 -47
  150. package/lib/esm/common/telemetry/TelemetryManager.js +3 -19
  151. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +28 -24
  152. package/lib/esm/common/telemetry/loggers/consoleLogger.js +0 -5
  153. package/lib/esm/common/utils.js +81 -51
  154. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +8 -17
  155. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -12
  156. package/lib/esm/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
  157. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +20 -31
  158. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +9 -16
  159. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -6
  160. package/lib/esm/components/footerstateful/FooterStateful.js +13 -23
  161. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +14 -36
  162. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -6
  163. package/lib/esm/components/headerstateful/HeaderStateful.js +21 -17
  164. package/lib/esm/components/livechatwidget/LiveChatWidget.js +2 -2
  165. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +32 -0
  166. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
  167. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +13 -0
  168. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  169. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +27 -0
  170. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +57 -0
  171. package/lib/esm/components/livechatwidget/common/Deferred.js +30 -0
  172. package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
  173. package/lib/esm/components/livechatwidget/common/authHelper.js +42 -0
  174. package/lib/esm/components/livechatwidget/common/createAdapter.js +14 -4
  175. package/lib/esm/components/livechatwidget/common/createFooter.js +4 -16
  176. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -5
  177. package/lib/esm/components/livechatwidget/common/createMarkdown.js +38 -37
  178. package/lib/esm/components/livechatwidget/common/defaultProps/defaultScrollBarProps.js +7 -0
  179. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +134 -37
  180. package/lib/esm/components/livechatwidget/common/endChat.js +89 -48
  181. package/lib/esm/components/livechatwidget/common/getGeneralStylesForButton.js +0 -2
  182. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +9 -11
  183. package/lib/esm/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -5
  184. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +32 -57
  185. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +77 -111
  186. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +4 -9
  187. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +250 -8
  188. package/lib/esm/components/livechatwidget/common/shareObservable.js +35 -0
  189. package/lib/esm/components/livechatwidget/common/startChat.js +233 -103
  190. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +4 -2
  191. package/lib/esm/components/livechatwidget/interfaces/IScrollBarProps.js +1 -0
  192. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +358 -151
  193. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +26 -7
  194. package/lib/esm/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +50 -0
  195. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +4 -5
  196. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +4 -5
  197. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +32 -11
  198. package/lib/esm/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
  199. package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +6 -0
  200. package/lib/esm/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
  201. package/lib/esm/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  202. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +14 -27
  203. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  204. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +21 -9
  205. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +6 -6
  206. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -4
  207. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
  208. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  209. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
  210. package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +12 -19
  211. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -13
  212. package/lib/esm/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -16
  213. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +5 -5
  214. package/lib/esm/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -6
  215. package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  216. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  217. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  218. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -3
  219. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
  220. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
  221. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
  222. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
  223. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
  224. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
  225. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
  226. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
  227. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +2 -5
  228. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -4
  229. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -22
  230. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -14
  231. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +25 -39
  232. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +9 -8
  233. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +34 -0
  234. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +80 -0
  235. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
  236. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +3 -0
  237. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -1
  238. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -1
  239. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +3 -0
  240. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -7
  241. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +83 -0
  242. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +8 -9
  243. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +9 -28
  244. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +5 -14
  245. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +20 -22
  246. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +5 -8
  247. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +6 -29
  248. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +3 -7
  249. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +3 -8
  250. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +17 -14
  251. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +3 -7
  252. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -7
  253. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +15 -27
  254. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +3 -5
  255. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +9 -9
  256. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +7 -9
  257. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -13
  258. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +0 -5
  259. package/lib/esm/contexts/ChatAdapterStore.js +2 -1
  260. package/lib/esm/contexts/ChatContextStore.js +2 -1
  261. package/lib/esm/contexts/ChatSDKStore.js +2 -1
  262. package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
  263. package/lib/esm/contexts/common/ConversationState.js +3 -3
  264. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +32 -26
  265. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -10
  266. package/lib/esm/contexts/createReducer.js +183 -101
  267. package/lib/esm/controller/componentController.js +5 -4
  268. package/lib/esm/hooks/useChatAdapterStore.js +0 -4
  269. package/lib/esm/hooks/useChatContextStore.js +0 -4
  270. package/lib/esm/hooks/useChatSDKStore.js +0 -4
  271. package/lib/esm/hooks/useDebounce.js +22 -0
  272. package/lib/esm/hooks/useWindowDimensions.js +23 -0
  273. package/lib/esm/plugins/newMessageEventHandler.js +29 -26
  274. package/lib/types/assets/Icons.d.ts +1 -0
  275. package/lib/types/common/Constants.d.ts +24 -0
  276. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  277. package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
  278. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
  279. package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
  280. package/lib/types/common/telemetry/TelemetryConstants.d.ts +63 -11
  281. package/lib/types/common/telemetry/definitions/Contracts.d.ts +4 -4
  282. package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
  283. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
  284. package/lib/types/common/utils.d.ts +8 -3
  285. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
  286. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
  287. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  288. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
  289. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  290. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  291. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  292. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  293. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  294. package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
  295. package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
  296. package/lib/types/components/livechatwidget/common/defaultProps/defaultScrollBarProps.d.ts +2 -0
  297. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
  298. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -7
  299. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
  300. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  301. package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -2
  302. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +4 -1
  303. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -2
  304. package/lib/types/components/livechatwidget/interfaces/IScrollBarProps.d.ts +22 -0
  305. package/lib/types/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.d.ts +2 -0
  306. package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -2
  307. package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +5 -0
  308. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +4 -0
  309. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -2
  310. package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
  311. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  312. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
  313. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  314. package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +4 -1
  315. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
  316. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  317. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
  318. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  319. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  320. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
  321. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.d.ts +3 -0
  322. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.d.ts +3 -0
  323. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  324. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
  325. package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
  326. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  327. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +9 -4
  328. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +32 -25
  329. package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
  330. package/lib/types/hooks/useDebounce.d.ts +3 -0
  331. package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
  332. package/package.json +5 -4
@@ -3,97 +3,93 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.startUnauthenticatedReconnectChat = exports.handleUnauthenticatedReconnectChat = exports.handleRedirectUnauthenticatedReconnectChat = exports.getReconnectIdForAuthenticatedChat = exports.getChatReconnectContext = void 0;
7
-
6
+ exports.isReconnectEnabled = exports.handleChatReconnect = exports.getChatReconnectContext = void 0;
8
7
  require("regenerator-runtime/runtime");
9
-
10
8
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
11
-
9
+ var _authHelper = require("./authHelper");
10
+ var _utils = require("../../../common/utils");
12
11
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
13
-
14
12
  var _ConversationState = require("../../../contexts/common/ConversationState");
15
-
16
13
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
17
-
18
14
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
17
+ var _props$chatConfig, _props$chatConfig$Liv;
18
+ if (!isReconnectEnabled(props.chatConfig)) return;
19
+
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ const isAuthenticatedChat = (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
22
+
23
+ // Get chat reconnect context
24
+ const reconnectChatContext = await getChatReconnectContext(chatSDK, props.chatConfig, props, isAuthenticatedChat);
25
+ if (hasReconnectId(reconnectChatContext)) {
26
+ var _props$reconnectChatP2, _props$reconnectChatP3;
27
+ //Redirect if enabled
28
+ if (reconnectChatContext.redirectURL && !(0, _utils.isNullOrEmptyString)(reconnectChatContext.redirectURL)) {
29
+ var _props$reconnectChatP;
30
+ redirectPage(reconnectChatContext.redirectURL, (_props$reconnectChatP = props.reconnectChatPaneProps) === null || _props$reconnectChatP === void 0 ? void 0 : _props$reconnectChatP.redirectInSameWindow);
31
+ return;
32
+ }
33
+
34
+ //if reconnect id is provided in props, don't show reconnect pane
35
+ if ((_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.reconnectId && !(0, _utils.isNullOrEmptyString)((_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId)) {
36
+ const reconnectChatContext = await getChatReconnectContext(chatSDK, props.chatConfig, props, isAuthenticatedChat);
37
+ await setReconnectIdAndStartChat(isAuthenticatedChat, chatSDK, props, dispatch, setAdapter, reconnectChatContext.reconnectId ?? "", initStartChat);
38
+ return;
39
+ }
40
+
41
+ //show reconnect pane
42
+ state.appStates.conversationState = _ConversationState.ConversationState.ReconnectChat;
43
+ dispatch({
44
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RECONNECT_ID,
45
+ payload: reconnectChatContext.reconnectId ?? ""
46
+ });
47
+ dispatch({
48
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
49
+ payload: _ConversationState.ConversationState.ReconnectChat
50
+ });
51
+ return;
52
+ }
53
+ };
19
54
 
20
55
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- const getChatReconnectContext = async (chatSDK, reconnectId) => {
56
+ exports.handleChatReconnect = handleChatReconnect;
57
+ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticatedChat) => {
22
58
  try {
23
- if (reconnectId) {
24
- const chatReconnectOptionalParams = {
25
- reconnectId: reconnectId
26
- };
27
- return await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
28
- } else {
29
- return await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext());
59
+ var _props$reconnectChatP4;
60
+ const chatReconnectOptionalParams = {
61
+ reconnectId: (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId
62
+ };
63
+ // Get auth token for getting chat reconnect context
64
+ if (isAuthenticatedChat) {
65
+ await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, props.getAuthToken);
66
+ }
67
+ const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
68
+ if (isAuthenticatedChat) {
69
+ // remove auth token after reconnectId is fetched
70
+ // AuthToken will be reset later at start chat
71
+ (0, _authHelper.removeAuthTokenProvider)(chatSDK);
30
72
  }
31
- } catch (ex) {
73
+ return reconnectChatContext;
74
+ } catch (error) {
32
75
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
33
76
  Event: _TelemetryConstants.TelemetryEvent.GetChatReconnectContextSDKCallFailed,
34
77
  ExceptionDetails: {
35
- exception: ex
78
+ exception: error
36
79
  }
37
80
  });
38
81
  }
82
+ };
39
83
 
40
- return null;
41
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
-
43
-
84
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
85
  exports.getChatReconnectContext = getChatReconnectContext;
45
-
46
- const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
47
- var _props$reconnectChatP, _props$reconnectChatP2;
48
-
49
- if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.authClientFunction // TODO: Implement this after storage is in place
50
-
51
- /* && !isLoadWithState() */
52
- ) {
53
- const previousActiveSessionResponse = await getChatReconnectContext(chatSDK);
54
-
55
- if (previousActiveSessionResponse && previousActiveSessionResponse.reconnectId) {
56
- return previousActiveSessionResponse.reconnectId;
57
- }
58
- }
59
-
60
- return undefined;
61
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
-
63
-
64
- exports.getReconnectIdForAuthenticatedChat = getReconnectIdForAuthenticatedChat;
65
-
66
- const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
67
- const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
68
-
69
- if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
70
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
71
- } else {
72
- await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
73
- }
74
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
-
76
-
77
- exports.handleUnauthenticatedReconnectChat = handleUnauthenticatedReconnectChat;
78
-
79
- const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
80
- const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
81
-
82
- if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
83
- await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
86
+ const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, props, dispatch, setAdapter, reconnectId, initStartChat) => {
87
+ if (!isAuthenticatedChat) {
88
+ const startUnauthenticatedReconnectChat = {
89
+ eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
90
+ };
91
+ _omnichannelChatComponents.BroadcastService.postMessage(startUnauthenticatedReconnectChat);
84
92
  }
85
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
-
87
-
88
- exports.startUnauthenticatedReconnectChat = startUnauthenticatedReconnectChat;
89
-
90
- const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
91
- const startUnauthenticatedReconnectChat = {
92
- eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
93
- };
94
-
95
- _omnichannelChatComponents.BroadcastService.postMessage(startUnauthenticatedReconnectChat);
96
-
97
93
  const optionalParams = {
98
94
  reconnectId: reconnectId
99
95
  };
@@ -105,9 +101,8 @@ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconne
105
101
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
106
102
  payload: _ConversationState.ConversationState.Loading
107
103
  });
108
- await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
104
+ await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
109
105
  };
110
-
111
106
  const redirectPage = (redirectURL, redirectInSameWindow) => {
112
107
  const redirectPageRequest = {
113
108
  eventName: _TelemetryConstants.BroadcastEvent.RedirectPageRequest,
@@ -115,64 +110,16 @@ const redirectPage = (redirectURL, redirectInSameWindow) => {
115
110
  redirectURL: redirectURL
116
111
  }
117
112
  };
118
-
119
113
  _omnichannelChatComponents.BroadcastService.postMessage(redirectPageRequest);
120
-
121
114
  if (redirectInSameWindow) {
122
115
  window.location.href = redirectURL;
123
116
  }
124
117
  };
125
-
126
- const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
127
- return reconnectAvailabilityResponse && !reconnectAvailabilityResponse.reconnectId;
128
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
-
130
-
131
- const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
132
- const startUnauthenticatedReconnectChat = {
133
- eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
134
- };
135
-
136
- _omnichannelChatComponents.BroadcastService.postMessage(startUnauthenticatedReconnectChat); // Getting PreChat Survey Context
137
-
138
-
139
- const parseToJson = false;
140
- const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
141
-
142
- if (preChatSurveyResponse) {
143
- dispatch({
144
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
145
- payload: preChatSurveyResponse
146
- });
147
- dispatch({
148
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
149
- payload: _ConversationState.ConversationState.Prechat
150
- });
151
- } else {
152
- dispatch({
153
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
154
- payload: _ConversationState.ConversationState.Loading
155
- });
156
- await initStartChat(chatSDK, dispatch, setAdapter);
157
- }
158
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
-
160
-
161
- const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
162
- const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
163
-
164
- if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
165
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
166
- }
167
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
-
169
-
170
- exports.handleRedirectUnauthenticatedReconnectChat = handleRedirectUnauthenticatedReconnectChat;
171
-
172
- const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
173
- if (reconnectAvailabilityResponse.redirectURL) {
174
- redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
175
- } else {
176
- await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
177
- }
118
+ const isReconnectEnabled = chatConfig => {
119
+ var _chatConfig$LiveWSAnd;
120
+ return chatConfig && ((_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_enablechatreconnect) && (chatConfig.LiveWSAndLiveChatEngJoin.msdyn_enablechatreconnect === "true" || chatConfig.LiveWSAndLiveChatEngJoin.msdyn_enablechatreconnect === true);
121
+ };
122
+ exports.isReconnectEnabled = isReconnectEnabled;
123
+ const hasReconnectId = reconnectAvailabilityResponse => {
124
+ return reconnectAvailabilityResponse && !(0, _utils.isNullOrUndefined)(reconnectAvailabilityResponse.reconnectId);
178
125
  };
@@ -4,42 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.registerTelemetryLoggers = void 0;
7
-
8
7
  var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
9
-
10
8
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
11
-
12
9
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
13
-
14
10
  var _defaultAriaConfig = require("../../../common/telemetry/defaultConfigs/defaultAriaConfig");
15
-
16
11
  var _defaultTelemetryInternalData = require("../../../common/telemetry/defaultConfigs/defaultTelemetryInternalData");
17
-
18
12
  var _defaultTelemetryConfiguration = require("../../../common/telemetry/defaultConfigs/defaultTelemetryConfiguration");
19
-
20
13
  const registerTelemetryLoggers = (props, dispatch) => {
21
14
  var _props$liveChatContex, _props$liveChatContex2;
22
-
23
- const telemetryConfig = { ..._defaultTelemetryConfiguration.defaultTelemetryConfiguration,
15
+ const telemetryConfig = {
16
+ ..._defaultTelemetryConfiguration.defaultTelemetryConfiguration,
24
17
  ...props.telemetryConfig
25
18
  };
26
-
27
19
  if ((_props$liveChatContex = props.liveChatContextFromCache) !== null && _props$liveChatContex !== void 0 && (_props$liveChatContex2 = _props$liveChatContex.domainStates) !== null && _props$liveChatContex2 !== void 0 && _props$liveChatContex2.telemetryInternalData) {
28
20
  var _props$liveChatContex3, _props$liveChatContex4;
29
-
30
21
  _TelemetryManager.TelemetryManager.InternalTelemetryData = (_props$liveChatContex3 = props.liveChatContextFromCache) === null || _props$liveChatContex3 === void 0 ? void 0 : (_props$liveChatContex4 = _props$liveChatContex3.domainStates) === null || _props$liveChatContex4 === void 0 ? void 0 : _props$liveChatContex4.telemetryInternalData;
31
22
  } else {
32
23
  var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$chatSDK3, _props$chatSDK3$omnic;
33
-
34
- let telemetryData = { ..._defaultTelemetryInternalData.defaultInternalTelemetryData,
24
+ let telemetryData = {
25
+ ..._defaultTelemetryInternalData.defaultInternalTelemetryData,
35
26
  telemetryConfig: Object.assign({}, _defaultTelemetryConfiguration.defaultTelemetryConfiguration, telemetryConfig),
36
27
  ariaConfig: Object.assign({}, _defaultAriaConfig.defaultAriaConfig, telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.ariaConfigurations)
37
28
  };
38
-
39
29
  if (props.chatConfig) {
40
30
  telemetryData = _TelemetryHelper.TelemetryHelper.addChatConfigDataToTelemetry(props === null || props === void 0 ? void 0 : props.chatConfig, telemetryData);
41
31
  }
42
-
43
32
  telemetryData = _TelemetryHelper.TelemetryHelper.addWidgetDataToTelemetry(telemetryConfig, telemetryData);
44
33
  telemetryData.OCChatSDKVersion = telemetryConfig.OCChatSDKVersion ?? "0.0.0-0";
45
34
  telemetryData.chatComponentVersion = telemetryConfig.chatComponentVersion ?? "0.0.0-0";
@@ -53,8 +42,6 @@ const registerTelemetryLoggers = (props, dispatch) => {
53
42
  payload: telemetryData
54
43
  });
55
44
  }
56
-
57
45
  (0, _TelemetryManager.RegisterLoggers)();
58
46
  };
59
-
60
47
  exports.registerTelemetryLoggers = registerTelemetryLoggers;
@@ -3,30 +3,29 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setPostChatContextAndLoadSurvey = void 0;
7
-
6
+ exports.setPostChatContextAndLoadSurvey = exports.initiatePostChat = exports.checkPostChatEnabled = void 0;
8
7
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
-
10
8
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
11
-
12
9
  var _ConversationState = require("../../../contexts/common/ConversationState");
13
-
14
10
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
15
-
16
11
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
17
-
12
+ var _Constants = require("../../../common/Constants");
13
+ var _endChat = require("./endChat");
14
+ var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostChatSurveyMode");
15
+ var _utils = require("../../../common/utils");
16
+ var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
17
+ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
18
+ var _ConversationEndEntity = require("../../../contexts/common/ConversationEndEntity");
18
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
20
  const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
20
21
  try {
21
22
  if (!persistedChat) {
22
23
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
24
  const context = await chatSDK.getPostChatSurveyContext();
24
-
25
25
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
26
26
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
27
27
  Description: "Postchat context call succeed."
28
28
  });
29
-
30
29
  dispatch({
31
30
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
32
31
  payload: context
@@ -39,19 +38,253 @@ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat)
39
38
  exception: ex
40
39
  }
41
40
  });
42
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
43
-
41
+ }
44
42
 
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
45
44
  _omnichannelChatComponents.BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
46
45
  dispatch({
47
46
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
48
- payload: _ConversationState.ConversationState.Loading
47
+ payload: _ConversationState.ConversationState.Postchat
48
+ });
49
+ });
50
+ };
51
+
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ exports.setPostChatContextAndLoadSurvey = setPostChatContextAndLoadSurvey;
54
+ const checkPostChatEnabled = (props, state) => {
55
+ var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2;
56
+ const isPostChatEnabled = ((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_postconversationsurveyenable) ?? ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable);
57
+ return isPostChatEnabled === _Constants.Constants.true;
58
+ };
59
+
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ exports.checkPostChatEnabled = checkPostChatEnabled;
62
+ const initiatePostChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
63
+ // Check if Postchat already in progress and handle case where chat is ended by customer
64
+ if (state.appStates.postChatWorkflowInProgress && state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
65
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
66
+ }
67
+
68
+ // Conversation Details call required by customer as well as agent
69
+ const conversationDetails = await getConversationDetailsCall(chatSDK);
70
+ // Start Postchat workflow
71
+ dispatch({
72
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS,
73
+ payload: true
74
+ });
75
+
76
+ // Below logic checks if agent or bot or noone joins conversation and handles them separately
77
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.Constants.userParticipantTypeTag) {
78
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
79
+ // Set use bot settings to false
80
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
81
+ } else if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
82
+ await postChatInitiatedByAgent(props, setWebChatStyles, dispatch, state);
83
+ } else {
84
+ const error = `Conversation was Ended after agent joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
85
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
86
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
87
+ ExceptionDetails: {
88
+ exception: error
89
+ }
90
+ });
91
+ throw new Error(error);
92
+ }
93
+ } else if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.Constants.botParticipantTypeTag) {
94
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
95
+ // Set use bot settings to true
96
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, true);
97
+ } else if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
98
+ await postChatInitiatedByBot(props, setWebChatStyles, dispatch, state);
99
+ } else {
100
+ const error = `Conversation was Ended after bot joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
101
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
102
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
103
+ ExceptionDetails: {
104
+ exception: error
105
+ }
106
+ });
107
+ throw new Error(error);
108
+ }
109
+ } else {
110
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
111
+ // No one has joined chat will be handled by postChat customer
112
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
113
+ } else {
114
+ const error = `ConversationDetails and App state was not set correctly: conversationDetails = ${JSON.stringify(conversationDetails)} , conversationEndedBy = ${state.appStates.conversationEndedBy}`;
115
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
116
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
117
+ ExceptionDetails: {
118
+ exception: error
119
+ }
120
+ });
121
+ throw new Error(error);
122
+ }
123
+ }
124
+ };
125
+
126
+ // Function for link mode postchat workflow which is essentially same for both customer and agent
127
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
+ exports.initiatePostChat = initiatePostChat;
129
+ const linkModePostChatWorkflow = (props, dispatch, setWebChatStyles) => {
130
+ var _props$webChatContain, _props$webChatContain2;
131
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
132
+ Event: _TelemetryConstants.TelemetryEvent.LinkModePostChatWorkflowStarted
133
+ });
134
+ dispatch({
135
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
136
+ payload: _ConversationState.ConversationState.InActive
137
+ });
138
+
139
+ // Disable SendBox
140
+ if ((props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd) !== false) {
141
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
+ setWebChatStyles(styles => {
143
+ return {
144
+ ...styles,
145
+ hideSendBox: true
146
+ };
49
147
  });
148
+ }
149
+ };
150
+
151
+ // Function for embed mode postchat workflow which is essentially same for both customer and agent
152
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
153
+ const embedModePostChatWorkflow = async (dispatch, state) => {
154
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
155
+ Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
156
+ });
157
+ if (state.domainStates.postChatContext) {
50
158
  dispatch({
51
159
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
52
- payload: _ConversationState.ConversationState.Postchat
160
+ payload: _ConversationState.ConversationState.PostchatLoading
161
+ });
162
+ await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
163
+ const loadPostChatEvent = {
164
+ eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
165
+ };
166
+ _omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
167
+ } else {
168
+ const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${state.domainStates.postChatContext}`;
169
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
170
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
171
+ ExceptionDetails: {
172
+ exception: error
173
+ }
174
+ });
175
+ throw new Error(error);
176
+ }
177
+ };
178
+
179
+ // Function will handle only postchat cases initiated by customer
180
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
181
+ const postChatInitiatedByCustomer = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, shouldUseBotSetting) => {
182
+ let postChatSurveyMode = "";
183
+ if (shouldUseBotSetting) {
184
+ var _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4;
185
+ postChatSurveyMode = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_postconversationsurveybotsurveymode) ?? ((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveybotsurveymode);
186
+ } else {
187
+ var _props$chatConfig3, _props$chatConfig3$Li, _state$domainStates$l5, _state$domainStates$l6;
188
+ postChatSurveyMode = ((_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : (_state$domainStates$l6 = _state$domainStates$l5.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.msdyn_postconversationsurveymode);
189
+ }
190
+ // Check if agent or bot has joined conversation
191
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
192
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
193
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromCustomer,
194
+ Description: shouldUseBotSetting ? "PostChat Workflow was started by customer using bot settings" : "PostChat Workflow was started by customer using agent settings"
195
+ });
196
+ const chatSession = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
197
+ if (chatSession) {
198
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
199
+ chatSDK.chatToken = chatSession.chatToken ?? {};
200
+ chatSDK.requestId = chatSession.requestId;
201
+ }
202
+ // End chat call to end chatsdk but not close chat, only if chat ended by customer
203
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, true, false);
204
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
205
+ await embedModePostChatWorkflow(dispatch, state);
206
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
207
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
208
+ } else {
209
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
210
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
211
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
212
+ ExceptionDetails: {
213
+ exception: error
214
+ }
215
+ });
216
+ throw new Error(error);
217
+ }
218
+ } else {
219
+ // Agent did not join chat so end chat normally
220
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
221
+ }
222
+ };
223
+
224
+ // Function will handle only postchat cases initiated by agent
225
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
226
+ const postChatInitiatedByAgent = async (props, setWebChatStyles, dispatch, state) => {
227
+ var _props$chatConfig4, _props$chatConfig4$Li, _state$domainStates$l7, _state$domainStates$l8;
228
+ const postChatSurveyMode = ((_props$chatConfig4 = props.chatConfig) === null || _props$chatConfig4 === void 0 ? void 0 : (_props$chatConfig4$Li = _props$chatConfig4.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig4$Li === void 0 ? void 0 : _props$chatConfig4$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : (_state$domainStates$l8 = _state$domainStates$l7.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l8 === void 0 ? void 0 : _state$domainStates$l8.msdyn_postconversationsurveymode);
229
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
230
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromAgent,
231
+ Description: "PostChat Workflow was started by agent"
232
+ });
233
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
234
+ await embedModePostChatWorkflow(dispatch, state);
235
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
236
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
237
+ } else {
238
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
239
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
240
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
241
+ ExceptionDetails: {
242
+ exception: error
243
+ }
53
244
  });
245
+ throw new Error(error);
246
+ }
247
+ };
248
+
249
+ // Function will handle only postchat cases initiated by bot
250
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
251
+ const postChatInitiatedByBot = async (props, setWebChatStyles, dispatch, state) => {
252
+ var _props$chatConfig5, _props$chatConfig5$Li, _state$domainStates$l9, _state$domainStates$l10;
253
+ const postChatSurveyMode = ((_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.msdyn_postconversationsurveybotsurveymode) ?? ((_state$domainStates$l9 = state.domainStates.liveChatConfig) === null || _state$domainStates$l9 === void 0 ? void 0 : (_state$domainStates$l10 = _state$domainStates$l9.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l10 === void 0 ? void 0 : _state$domainStates$l10.msdyn_postconversationsurveybotsurveymode);
254
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
255
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromBot,
256
+ Description: "PostChat Workflow was started by bot"
54
257
  });
258
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
259
+ await embedModePostChatWorkflow(dispatch, state);
260
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
261
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
262
+ } else {
263
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveybotsurveymode = ${postChatSurveyMode}`;
264
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
265
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
266
+ ExceptionDetails: {
267
+ exception: error
268
+ }
269
+ });
270
+ throw new Error(error);
271
+ }
55
272
  };
56
273
 
57
- exports.setPostChatContextAndLoadSurvey = setPostChatContextAndLoadSurvey;
274
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
275
+ const getConversationDetailsCall = async chatSDK => {
276
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
277
+ let conversationDetails = undefined;
278
+ try {
279
+ conversationDetails = await chatSDK.getConversationDetails();
280
+ } catch (error) {
281
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
282
+ Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallFailed,
283
+ ExceptionDetails: {
284
+ exception: `Get Conversation Details Call Failed : ${error}`
285
+ }
286
+ });
287
+ _NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.Connection, "Get Conversation Details Call Failed: " + error);
288
+ }
289
+ return conversationDetails;
290
+ };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.shareObservable = shareObservable;
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ function shareObservable(observable) {
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ let observers = [];
11
+
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ let subscription;
14
+
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ return new window.Observable(observer => {
17
+ if (!subscription) {
18
+ subscription = observable.subscribe({
19
+ complete() {
20
+ observers.forEach(observer => observer.complete());
21
+ },
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ error(err) {
24
+ observers.forEach(observer => observer.error(err));
25
+ },
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ next(value) {
28
+ observers.forEach(observer => observer.next(value));
29
+ }
30
+ });
31
+ }
32
+ observers.push(observer);
33
+ return () => {
34
+ observers = observers.filter(o => o !== observer);
35
+ if (!observers.length) {
36
+ subscription.unsubscribe();
37
+ subscription = null;
38
+ }
39
+ };
40
+ });
41
+ }