@microsoft/omnichannel-chat-widget 0.1.0-main.fb426ed → 1.0.0

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 (341) hide show
  1. package/README.md +7 -2
  2. package/lib/cjs/assets/Icons.js +4 -2
  3. package/lib/cjs/common/Constants.js +40 -164
  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 +84 -30
  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 +92 -85
  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 +139 -51
  44. package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +0 -3
  45. package/lib/cjs/components/livechatwidget/common/endChat.js +98 -57
  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 +79 -128
  51. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +4 -17
  52. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +254 -14
  53. package/lib/cjs/components/livechatwidget/common/shareObservable.js +41 -0
  54. package/lib/cjs/components/livechatwidget/common/startChat.js +257 -117
  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 +368 -197
  59. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +37 -25
  60. package/lib/cjs/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +57 -0
  61. package/lib/cjs/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
  62. package/lib/cjs/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
  63. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +4 -17
  64. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +4 -17
  65. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +35 -24
  66. package/lib/cjs/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
  67. package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +13 -0
  68. package/lib/cjs/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
  69. package/lib/cjs/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  70. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +11 -42
  71. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  72. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +19 -33
  73. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +8 -24
  74. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -19
  75. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -7
  76. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -6
  77. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
  78. package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +12 -27
  79. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -17
  80. package/lib/cjs/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -24
  81. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +5 -15
  82. package/lib/cjs/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -8
  83. package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  84. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  85. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +12 -0
  86. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -5
  87. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
  88. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
  89. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
  90. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
  91. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
  92. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
  93. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
  94. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
  95. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +0 -7
  96. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -5
  97. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -37
  98. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +10 -22
  99. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +25 -61
  100. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +7 -15
  101. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  102. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +82 -0
  103. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
  104. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +10 -0
  105. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -3
  106. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -3
  107. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +10 -0
  108. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -9
  109. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +89 -0
  110. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +7 -18
  111. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +8 -42
  112. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +4 -22
  113. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +20 -33
  114. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +3 -9
  115. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +81 -45
  116. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -10
  117. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +1 -12
  118. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +17 -19
  119. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +1 -9
  120. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -9
  121. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -34
  122. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +1 -10
  123. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +7 -11
  124. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +5 -14
  125. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -21
  126. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +0 -12
  127. package/lib/cjs/contexts/ChatAdapterStore.js +0 -2
  128. package/lib/cjs/contexts/ChatContextStore.js +0 -2
  129. package/lib/cjs/contexts/ChatSDKStore.js +0 -2
  130. package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
  131. package/lib/cjs/contexts/common/ConversationState.js +3 -3
  132. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +34 -26
  133. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +20 -14
  134. package/lib/cjs/contexts/createReducer.js +200 -104
  135. package/lib/cjs/controller/componentController.js +4 -33
  136. package/lib/cjs/hooks/useChatAdapterStore.js +0 -6
  137. package/lib/cjs/hooks/useChatContextStore.js +0 -6
  138. package/lib/cjs/hooks/useChatSDKStore.js +0 -6
  139. package/lib/cjs/hooks/useDebounce.js +28 -0
  140. package/lib/cjs/hooks/useWindowDimensions.js +30 -0
  141. package/lib/cjs/index.js +0 -5
  142. package/lib/cjs/plugins/newMessageEventHandler.js +29 -36
  143. package/lib/esm/assets/Icons.js +2 -1
  144. package/lib/esm/common/Constants.js +36 -151
  145. package/lib/esm/common/KeyCodes.js +3 -3
  146. package/lib/esm/common/contextDataStore/DataStoreManager.js +3 -3
  147. package/lib/esm/common/storage/default/defaultCacheManager.js +18 -0
  148. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +104 -0
  149. package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +70 -0
  150. package/lib/esm/common/telemetry/TelemetryConstants.js +88 -27
  151. package/lib/esm/common/telemetry/TelemetryHelper.js +21 -47
  152. package/lib/esm/common/telemetry/TelemetryManager.js +3 -19
  153. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +28 -24
  154. package/lib/esm/common/telemetry/loggers/consoleLogger.js +0 -5
  155. package/lib/esm/common/utils.js +84 -47
  156. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +8 -17
  157. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -12
  158. package/lib/esm/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
  159. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +20 -31
  160. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +9 -16
  161. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -6
  162. package/lib/esm/components/footerstateful/FooterStateful.js +13 -23
  163. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +14 -36
  164. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -6
  165. package/lib/esm/components/headerstateful/HeaderStateful.js +21 -17
  166. package/lib/esm/components/livechatwidget/LiveChatWidget.js +2 -2
  167. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +32 -0
  168. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
  169. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +13 -0
  170. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  171. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +27 -0
  172. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +57 -0
  173. package/lib/esm/components/livechatwidget/common/Deferred.js +30 -0
  174. package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
  175. package/lib/esm/components/livechatwidget/common/authHelper.js +42 -0
  176. package/lib/esm/components/livechatwidget/common/createAdapter.js +14 -4
  177. package/lib/esm/components/livechatwidget/common/createFooter.js +4 -16
  178. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -5
  179. package/lib/esm/components/livechatwidget/common/createMarkdown.js +38 -37
  180. package/lib/esm/components/livechatwidget/common/defaultProps/defaultScrollBarProps.js +7 -0
  181. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +140 -37
  182. package/lib/esm/components/livechatwidget/common/endChat.js +98 -43
  183. package/lib/esm/components/livechatwidget/common/getGeneralStylesForButton.js +0 -2
  184. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +9 -11
  185. package/lib/esm/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -5
  186. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +32 -57
  187. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +80 -110
  188. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +4 -9
  189. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +257 -8
  190. package/lib/esm/components/livechatwidget/common/shareObservable.js +35 -0
  191. package/lib/esm/components/livechatwidget/common/startChat.js +256 -96
  192. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +4 -2
  193. package/lib/esm/components/livechatwidget/interfaces/IScrollBarProps.js +1 -0
  194. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +372 -144
  195. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +38 -13
  196. package/lib/esm/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +50 -0
  197. package/lib/esm/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
  198. package/lib/esm/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
  199. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +4 -5
  200. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +4 -5
  201. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +35 -12
  202. package/lib/esm/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
  203. package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +6 -0
  204. package/lib/esm/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
  205. package/lib/esm/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  206. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +15 -27
  207. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  208. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +21 -9
  209. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +8 -6
  210. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -4
  211. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
  212. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  213. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
  214. package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +12 -19
  215. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -13
  216. package/lib/esm/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -16
  217. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +5 -5
  218. package/lib/esm/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -6
  219. package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  220. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  221. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  222. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -3
  223. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
  224. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
  225. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
  226. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
  227. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
  228. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
  229. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
  230. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
  231. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +2 -5
  232. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -4
  233. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -22
  234. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -14
  235. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +25 -39
  236. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +9 -8
  237. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +34 -0
  238. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +80 -0
  239. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
  240. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +3 -0
  241. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -1
  242. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -1
  243. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +3 -0
  244. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -7
  245. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +83 -0
  246. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +8 -9
  247. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +9 -28
  248. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +5 -14
  249. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +20 -22
  250. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +5 -8
  251. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +81 -40
  252. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +3 -7
  253. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +3 -8
  254. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +17 -14
  255. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +3 -7
  256. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -7
  257. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +15 -27
  258. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +3 -5
  259. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +9 -9
  260. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +7 -9
  261. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -13
  262. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +0 -5
  263. package/lib/esm/contexts/ChatAdapterStore.js +2 -1
  264. package/lib/esm/contexts/ChatContextStore.js +2 -1
  265. package/lib/esm/contexts/ChatSDKStore.js +2 -1
  266. package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
  267. package/lib/esm/contexts/common/ConversationState.js +3 -3
  268. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +34 -26
  269. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +20 -10
  270. package/lib/esm/contexts/createReducer.js +200 -101
  271. package/lib/esm/controller/componentController.js +5 -4
  272. package/lib/esm/hooks/useChatAdapterStore.js +0 -4
  273. package/lib/esm/hooks/useChatContextStore.js +0 -4
  274. package/lib/esm/hooks/useChatSDKStore.js +0 -4
  275. package/lib/esm/hooks/useDebounce.js +22 -0
  276. package/lib/esm/hooks/useWindowDimensions.js +23 -0
  277. package/lib/esm/plugins/newMessageEventHandler.js +29 -26
  278. package/lib/types/assets/Icons.d.ts +1 -0
  279. package/lib/types/common/Constants.d.ts +30 -1
  280. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  281. package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
  282. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
  283. package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
  284. package/lib/types/common/telemetry/TelemetryConstants.d.ts +65 -12
  285. package/lib/types/common/telemetry/definitions/Contracts.d.ts +4 -4
  286. package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
  287. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
  288. package/lib/types/common/utils.d.ts +8 -1
  289. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
  290. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
  291. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  292. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
  293. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  294. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  295. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  296. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  297. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  298. package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
  299. package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
  300. package/lib/types/components/livechatwidget/common/defaultProps/defaultScrollBarProps.d.ts +2 -0
  301. package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
  302. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
  303. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -7
  304. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
  305. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  306. package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -2
  307. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +4 -1
  308. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +7 -2
  309. package/lib/types/components/livechatwidget/interfaces/IScrollBarProps.d.ts +22 -0
  310. package/lib/types/components/loadingpanestateful/LoadingPaneStateful.d.ts +1 -2
  311. package/lib/types/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.d.ts +2 -0
  312. package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +4 -0
  313. package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +4 -0
  314. package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -2
  315. package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +5 -0
  316. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +4 -0
  317. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -2
  318. package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
  319. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  320. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
  321. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  322. package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +4 -1
  323. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
  324. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  325. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
  326. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  327. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  328. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
  329. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.d.ts +3 -0
  330. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.d.ts +3 -0
  331. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  332. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
  333. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +1 -1
  334. package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
  335. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  336. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +11 -4
  337. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +34 -25
  338. package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
  339. package/lib/types/hooks/useDebounce.d.ts +3 -0
  340. package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
  341. 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
- }
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);
58
92
  }
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);
84
- }
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,20 @@ 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);
118
+ const isReconnectEnabled = chatConfig => {
119
+ if (chatConfig) {
120
+ var _chatConfig$LiveWSAnd, _chatConfig$LiveWSAnd2;
121
+ const reconnectEnabled = ((_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : (_chatConfig$LiveWSAnd2 = _chatConfig$LiveWSAnd.msdyn_enablechatreconnect) === null || _chatConfig$LiveWSAnd2 === void 0 ? void 0 : _chatConfig$LiveWSAnd2.toLowerCase()) === "true";
122
+ return reconnectEnabled;
177
123
  }
124
+ return false;
125
+ };
126
+ exports.isReconnectEnabled = isReconnectEnabled;
127
+ const hasReconnectId = reconnectAvailabilityResponse => {
128
+ return reconnectAvailabilityResponse && !(0, _utils.isNullOrUndefined)(reconnectAvailabilityResponse.reconnectId);
178
129
  };
@@ -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,260 @@ 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
+ return;
67
+ }
68
+
69
+ // Conversation Details call required by customer as well as agent
70
+ const conversationDetails = await getConversationDetailsCall(chatSDK);
71
+ // Start Postchat workflow
72
+ dispatch({
73
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS,
74
+ payload: true
75
+ });
76
+
77
+ // Below logic checks if agent or bot or noone joins conversation and handles them separately
78
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.Constants.userParticipantTypeTag) {
79
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
80
+ // Set use bot settings to false
81
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
82
+ } else if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
83
+ await postChatInitiatedByAgent(props, setWebChatStyles, dispatch, state);
84
+ } else {
85
+ const error = `Conversation was Ended after agent joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
86
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
87
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
88
+ ExceptionDetails: {
89
+ exception: error
90
+ }
91
+ });
92
+ throw new Error(error);
93
+ }
94
+ } else if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.Constants.botParticipantTypeTag) {
95
+ // Set Use bot survey to true
96
+ dispatch({
97
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_USE_BOT_SURVEY,
98
+ payload: true
99
+ });
100
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
101
+ // Set use bot settings to true
102
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, true);
103
+ } else if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
104
+ await postChatInitiatedByBot(props, setWebChatStyles, dispatch, state);
105
+ } else {
106
+ const error = `Conversation was Ended after bot joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
107
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
108
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
109
+ ExceptionDetails: {
110
+ exception: error
111
+ }
112
+ });
113
+ throw new Error(error);
114
+ }
115
+ } else {
116
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
117
+ // No one has joined chat will be handled by postChat customer
118
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
119
+ } else {
120
+ const error = `ConversationDetails and App state was not set correctly: conversationDetails = ${JSON.stringify(conversationDetails)} , conversationEndedBy = ${state.appStates.conversationEndedBy}`;
121
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
122
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
123
+ ExceptionDetails: {
124
+ exception: error
125
+ }
126
+ });
127
+ throw new Error(error);
128
+ }
129
+ }
130
+ };
131
+
132
+ // Function for link mode postchat workflow which is essentially same for both customer and agent
133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
+ exports.initiatePostChat = initiatePostChat;
135
+ const linkModePostChatWorkflow = (props, dispatch, setWebChatStyles) => {
136
+ var _props$webChatContain, _props$webChatContain2;
137
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
138
+ Event: _TelemetryConstants.TelemetryEvent.LinkModePostChatWorkflowStarted
139
+ });
140
+ dispatch({
141
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
142
+ payload: _ConversationState.ConversationState.InActive
143
+ });
144
+
145
+ // Disable SendBox
146
+ 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) {
147
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
+ setWebChatStyles(styles => {
149
+ return {
150
+ ...styles,
151
+ hideSendBox: true
152
+ };
49
153
  });
154
+ }
155
+ };
156
+
157
+ // Function for embed mode postchat workflow which is essentially same for both customer and agent
158
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
+ const embedModePostChatWorkflow = async (dispatch, state) => {
160
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
161
+ Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
162
+ });
163
+ if (state.domainStates.postChatContext) {
50
164
  dispatch({
51
165
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
52
- payload: _ConversationState.ConversationState.Postchat
166
+ payload: _ConversationState.ConversationState.PostchatLoading
167
+ });
168
+ await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
169
+ const loadPostChatEvent = {
170
+ eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
171
+ };
172
+ _omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
173
+ } else {
174
+ const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${state.domainStates.postChatContext}`;
175
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
176
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
177
+ ExceptionDetails: {
178
+ exception: error
179
+ }
180
+ });
181
+ throw new Error(error);
182
+ }
183
+ };
184
+
185
+ // Function will handle only postchat cases initiated by customer
186
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
187
+ const postChatInitiatedByCustomer = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, shouldUseBotSetting) => {
188
+ let postChatSurveyMode = "";
189
+ if (shouldUseBotSetting) {
190
+ var _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4;
191
+ 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);
192
+ } else {
193
+ var _props$chatConfig3, _props$chatConfig3$Li, _state$domainStates$l5, _state$domainStates$l6;
194
+ 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);
195
+ }
196
+ // Check if agent or bot has joined conversation
197
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
198
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
199
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromCustomer,
200
+ Description: shouldUseBotSetting ? "PostChat Workflow was started by customer using bot settings" : "PostChat Workflow was started by customer using agent settings"
53
201
  });
202
+ const chatSession = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
203
+ // End chat call to end chatsdk but not close chat, only if chat ended by customer
204
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, true, false);
205
+ // Saving request Id below for chat transcript calls
206
+ if (chatSession) {
207
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
208
+ chatSDK.chatToken = chatSession.chatToken ?? {};
209
+ chatSDK.requestId = chatSession.requestId;
210
+ }
211
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
212
+ await embedModePostChatWorkflow(dispatch, state);
213
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
214
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
215
+ } else {
216
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
217
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
218
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
219
+ ExceptionDetails: {
220
+ exception: error
221
+ }
222
+ });
223
+ throw new Error(error);
224
+ }
225
+ } else {
226
+ // Agent did not join chat so end chat normally
227
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
228
+ }
229
+ };
230
+
231
+ // Function will handle only postchat cases initiated by agent
232
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
233
+ const postChatInitiatedByAgent = async (props, setWebChatStyles, dispatch, state) => {
234
+ var _props$chatConfig4, _props$chatConfig4$Li, _state$domainStates$l7, _state$domainStates$l8;
235
+ 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);
236
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
237
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromAgent,
238
+ Description: "PostChat Workflow was started by agent"
54
239
  });
240
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
241
+ await embedModePostChatWorkflow(dispatch, state);
242
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
243
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
244
+ } else {
245
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
246
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
247
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
248
+ ExceptionDetails: {
249
+ exception: error
250
+ }
251
+ });
252
+ throw new Error(error);
253
+ }
55
254
  };
56
255
 
57
- exports.setPostChatContextAndLoadSurvey = setPostChatContextAndLoadSurvey;
256
+ // Function will handle only postchat cases initiated by bot
257
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
258
+ const postChatInitiatedByBot = async (props, setWebChatStyles, dispatch, state) => {
259
+ var _props$chatConfig5, _props$chatConfig5$Li, _state$domainStates$l9, _state$domainStates$l10;
260
+ 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);
261
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
262
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromBot,
263
+ Description: "PostChat Workflow was started by bot"
264
+ });
265
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
266
+ await embedModePostChatWorkflow(dispatch, state);
267
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
268
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
269
+ } else {
270
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveybotsurveymode = ${postChatSurveyMode}`;
271
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
272
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
273
+ ExceptionDetails: {
274
+ exception: error
275
+ }
276
+ });
277
+ throw new Error(error);
278
+ }
279
+ };
280
+
281
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
282
+ const getConversationDetailsCall = async chatSDK => {
283
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
284
+ let conversationDetails = undefined;
285
+ try {
286
+ conversationDetails = await chatSDK.getConversationDetails();
287
+ } catch (error) {
288
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
289
+ Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallFailed,
290
+ ExceptionDetails: {
291
+ exception: `Get Conversation Details Call Failed : ${error}`
292
+ }
293
+ });
294
+ _NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.Connection, "Get Conversation Details Call Failed: " + error);
295
+ }
296
+ return conversationDetails;
297
+ };
@@ -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
+ }