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