@microsoft/omnichannel-chat-widget 0.1.0-main.8b6c0d8 → 0.1.0-main.8cded52

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 (205) hide show
  1. package/README.md +259 -0
  2. package/lib/cjs/assets/Audios.js +8 -0
  3. package/lib/cjs/assets/Icons.js +28 -0
  4. package/lib/cjs/common/Constants.js +54 -4
  5. package/lib/cjs/common/contextDataStore/DataStoreManager.js +14 -0
  6. package/lib/cjs/{assets/assets.d.js → common/interfaces/IContextDataStore.js} +0 -0
  7. package/lib/cjs/common/telemetry/TelemetryConstants.js +61 -4
  8. package/lib/cjs/common/telemetry/TelemetryHelper.js +22 -4
  9. package/lib/cjs/common/telemetry/TelemetryManager.js +28 -9
  10. package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +3 -3
  11. package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  12. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +48 -15
  13. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +9 -5
  14. package/lib/cjs/common/utils.js +89 -2
  15. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  16. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +28 -5
  17. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -54
  18. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
  19. package/lib/cjs/components/footerstateful/FooterStateful.js +4 -5
  20. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
  21. package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -10
  22. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
  23. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
  24. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  25. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
  26. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
  27. package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
  28. package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
  29. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +32 -32
  30. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +50 -48
  31. package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +14 -0
  32. package/lib/cjs/components/livechatwidget/common/endChat.js +142 -43
  33. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +5 -0
  34. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +51 -10
  35. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +115 -22
  36. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +11 -7
  37. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +22 -24
  38. package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
  39. package/lib/cjs/components/livechatwidget/common/startChat.js +225 -40
  40. package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -3
  41. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +296 -69
  42. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
  43. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +8 -0
  44. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
  45. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +22 -10
  46. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +27 -5
  47. package/lib/cjs/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  48. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
  49. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -0
  50. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +51 -73
  51. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  52. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
  53. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +25 -48
  54. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
  55. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
  56. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
  57. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
  58. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  59. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +45 -0
  60. package/lib/cjs/contexts/common/ConversationState.js +4 -2
  61. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +14 -7
  62. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +14 -5
  63. package/lib/cjs/contexts/createReducer.js +51 -10
  64. package/lib/cjs/controller/componentController.js +5 -5
  65. package/lib/cjs/plugins/newMessageEventHandler.js +99 -0
  66. package/lib/esm/assets/Audios.js +1 -0
  67. package/lib/esm/assets/Icons.js +11 -0
  68. package/lib/esm/common/Constants.js +50 -3
  69. package/lib/esm/common/contextDataStore/DataStoreManager.js +5 -0
  70. package/lib/esm/common/interfaces/IContextDataStore.js +1 -0
  71. package/lib/esm/common/telemetry/TelemetryConstants.js +57 -3
  72. package/lib/esm/common/telemetry/TelemetryHelper.js +22 -5
  73. package/lib/esm/common/telemetry/TelemetryManager.js +22 -9
  74. package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +3 -3
  75. package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  76. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +50 -15
  77. package/lib/esm/common/telemetry/loggers/consoleLogger.js +9 -5
  78. package/lib/esm/common/utils.js +64 -1
  79. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  80. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +31 -8
  81. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -50
  82. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
  83. package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
  84. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
  85. package/lib/esm/components/headerstateful/HeaderStateful.js +15 -11
  86. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
  87. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
  88. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  89. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
  90. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
  91. package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
  92. package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
  93. package/lib/esm/components/livechatwidget/common/createMarkdown.js +32 -31
  94. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +48 -49
  95. package/lib/esm/components/livechatwidget/common/disposeTelemetryLoggers.js +4 -0
  96. package/lib/esm/components/livechatwidget/common/endChat.js +139 -42
  97. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -0
  98. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +45 -11
  99. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +104 -22
  100. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +10 -3
  101. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +19 -22
  102. package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
  103. package/lib/esm/components/livechatwidget/common/startChat.js +212 -37
  104. package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
  105. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +280 -74
  106. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
  107. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +6 -0
  108. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
  109. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +22 -10
  110. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +26 -6
  111. package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  112. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
  113. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -0
  114. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -12
  115. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  116. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  117. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +23 -46
  118. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  119. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  120. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
  121. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
  122. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  123. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +32 -0
  124. package/lib/esm/contexts/common/ConversationState.js +4 -2
  125. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +14 -7
  126. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +14 -5
  127. package/lib/esm/contexts/createReducer.js +51 -9
  128. package/lib/esm/controller/componentController.js +5 -5
  129. package/lib/esm/plugins/newMessageEventHandler.js +82 -0
  130. package/lib/types/assets/Audios.d.ts +1 -0
  131. package/lib/types/assets/Icons.d.ts +11 -0
  132. package/lib/types/common/Constants.d.ts +27 -1
  133. package/lib/types/common/contextDataStore/DataStoreManager.d.ts +4 -0
  134. package/lib/types/common/interfaces/IContextDataStore.d.ts +14 -0
  135. package/lib/types/common/telemetry/TelemetryConstants.d.ts +45 -2
  136. package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -0
  137. package/lib/types/common/telemetry/TelemetryManager.d.ts +1 -0
  138. package/lib/types/common/telemetry/definitions/Contracts.d.ts +3 -0
  139. package/lib/types/common/telemetry/definitions/Payload.d.ts +15 -9
  140. package/lib/types/common/telemetry/interfaces/IChatSDKLogger.d.ts +1 -0
  141. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +2 -0
  142. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +12 -0
  143. package/lib/types/common/utils.d.ts +8 -1
  144. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +5 -2
  145. package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
  146. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +5 -1
  147. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  148. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  149. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  150. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  151. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  152. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  153. package/lib/types/components/livechatwidget/common/disposeTelemetryLoggers.d.ts +1 -0
  154. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  155. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -2
  156. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
  157. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  158. package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
  159. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
  160. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  161. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
  162. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +4 -1
  163. package/lib/types/components/prechatsurveypanestateful/interfaces/IPreChatSurveyPaneStatefulParams.d.ts +1 -1
  164. package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
  165. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -1
  166. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -0
  167. package/lib/types/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.d.ts +1 -1
  168. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  169. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  170. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  171. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
  172. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  173. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  174. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  175. package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
  176. package/lib/types/contexts/common/ConversationState.d.ts +4 -2
  177. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -1
  178. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +15 -8
  179. package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
  180. package/package.json +13 -12
  181. package/lib/cjs/assets/audios/newMessageNotification.mp3 +0 -0
  182. package/lib/cjs/assets/icons/archiveIcon.svg +0 -3
  183. package/lib/cjs/assets/icons/audioIcon.svg +0 -6
  184. package/lib/cjs/assets/icons/blankIcon.svg +0 -6
  185. package/lib/cjs/assets/icons/excelIcon.svg +0 -6
  186. package/lib/cjs/assets/icons/imageIcon.svg +0 -6
  187. package/lib/cjs/assets/icons/oneNoteIcon.svg +0 -6
  188. package/lib/cjs/assets/icons/pdfIcon.svg +0 -6
  189. package/lib/cjs/assets/icons/powerpointIcon.svg +0 -6
  190. package/lib/cjs/assets/icons/videoIcon.svg +0 -6
  191. package/lib/cjs/assets/icons/visioIcon.svg +0 -6
  192. package/lib/cjs/assets/icons/wordIcon.svg +0 -6
  193. package/lib/esm/assets/assets.d.js +0 -0
  194. package/lib/esm/assets/audios/newMessageNotification.mp3 +0 -0
  195. package/lib/esm/assets/icons/archiveIcon.svg +0 -3
  196. package/lib/esm/assets/icons/audioIcon.svg +0 -6
  197. package/lib/esm/assets/icons/blankIcon.svg +0 -6
  198. package/lib/esm/assets/icons/excelIcon.svg +0 -6
  199. package/lib/esm/assets/icons/imageIcon.svg +0 -6
  200. package/lib/esm/assets/icons/oneNoteIcon.svg +0 -6
  201. package/lib/esm/assets/icons/pdfIcon.svg +0 -6
  202. package/lib/esm/assets/icons/powerpointIcon.svg +0 -6
  203. package/lib/esm/assets/icons/videoIcon.svg +0 -6
  204. package/lib/esm/assets/icons/visioIcon.svg +0 -6
  205. package/lib/esm/assets/icons/wordIcon.svg +0 -6
@@ -1,10 +1,13 @@
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
2
  import { createStore } from "botframework-webchat";
3
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
2
4
  import { ConversationState } from "../../../contexts/common/ConversationState";
3
5
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
4
6
  import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
7
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
5
8
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
6
9
  import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
7
- import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
10
+ import { addDelayInMs, changeLanguageCodeFormatForWebChat } from "../../../common/utils";
8
11
  import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
9
12
  import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
10
13
  import createAttachmentMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
@@ -14,6 +17,7 @@ import createConversationEndMiddleware from "../../webchatcontainerstateful/webc
14
17
  import createDataMaskingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware";
15
18
  import { createMarkdown } from "./createMarkdown";
16
19
  import createMaxMessageSizeValidator from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator";
20
+ import { createWebChatTelemetry } from "../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
17
21
  import { defaultAttachmentProps } from "../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps";
18
22
  import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
19
23
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
@@ -23,10 +27,12 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
23
27
  import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
24
28
  import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
25
29
  import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
26
- import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
31
+ import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
32
+ import { Constants } from "../../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
33
 
28
34
  export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
29
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21;
35
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
30
36
 
31
37
  const localizedTexts = { ...defaultMiddlewareLocalizedTexts,
32
38
  ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
@@ -45,6 +51,11 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
45
51
  const conversationEndCallback = async () => {
46
52
  var _props$webChatContain4, _props$webChatContain5;
47
53
 
54
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
55
+ Event: TelemetryEvent.ConversationEndedThreadEventReceived,
56
+ Description: "Conversation is ended by agent side or by timeout."
57
+ });
58
+
48
59
  if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
49
60
  setWebChatStyles(styles => {
50
61
  return { ...styles,
@@ -53,26 +64,47 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
53
64
  });
54
65
  }
55
66
 
56
- if (isPostChatEnabled === "true" && postChatSurveyMode === PostChatSurveyMode.Embed) {
67
+ if (isPostChatEnabled === "true") {
68
+ if (postChatSurveyMode === PostChatSurveyMode.Embed) {
69
+ WebChatStoreLoader.store = null;
70
+ dispatch({
71
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
72
+ payload: ConversationState.PostchatLoading
73
+ });
74
+ await addDelayInMs(Constants.PostChatLoadingDurationInMs);
75
+ const loadPostChatEvent = {
76
+ eventName: BroadcastEvent.LoadPostChatSurvey
77
+ };
78
+ BroadcastService.postMessage(loadPostChatEvent);
79
+ } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
80
+ dispatch({
81
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
82
+ payload: ConversationState.InActive
83
+ });
84
+ }
85
+ } else {
57
86
  dispatch({
58
- type: LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT,
59
- payload: true
87
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
88
+ payload: ConversationState.InActive
60
89
  });
61
90
  dispatch({
62
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
63
- payload: ConversationState.Loading
91
+ type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
92
+ payload: true
64
93
  });
65
- await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
66
94
  }
67
95
 
68
96
  dispatch({
69
97
  type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
70
98
  payload: undefined
71
99
  });
100
+ dispatch({
101
+ type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
102
+ payload: undefined
103
+ });
72
104
  };
73
105
 
74
106
  webChatStore = createStore({}, //initial state
75
- preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, // eslint-disable-next-line @typescript-eslint/no-explicit-any
107
+ preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), createMessageTimeStampMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
108
  ...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
77
109
  WebChatStoreLoader.store = webChatStore;
78
110
  } // Initialize the remaining Web Chat props
@@ -89,7 +121,9 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
89
121
  avatarMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableAvatarMiddleware ? undefined : createAvatarMiddleware((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
90
122
  groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
91
123
  typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
92
- ...((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.webChatProps)
124
+ onTelemetry: createWebChatTelemetry(),
125
+ cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
126
+ ...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
93
127
  };
94
128
  return webChatProps;
95
129
  };
@@ -1,6 +1,6 @@
1
1
  import "regenerator-runtime/runtime";
2
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
- import { Constants } from "../../../common/Constants";
2
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
4
  import { ConversationState } from "../../../contexts/common/ConversationState";
5
5
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
6
6
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -29,9 +29,17 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
29
29
 
30
30
 
31
31
  const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
32
- var _props$reconnectChatP, _props$reconnectChatP2;
32
+ var _props$chatConfig, _props$reconnectChatP;
33
33
 
34
- 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
34
+ let authClientFunction = undefined;
35
+
36
+ if ((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) {
37
+ var _props$chatConfig2, _props$chatConfig2$Li;
38
+
39
+ authClientFunction = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_javascriptclientfunction) ?? undefined;
40
+ }
41
+
42
+ if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && authClientFunction // TODO: Implement this after storage is in place
35
43
 
36
44
  /* && !isLoadWithState() */
37
45
  ) {
@@ -46,33 +54,107 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
46
54
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
55
 
48
56
 
49
- const handleUnauthenticatedReconnectChat = async (dispatch, reconnectId, initStartChat) => {
50
- const reconnectAvailabilityResponse = await getChatReconnectContext(reconnectId);
57
+ const handleUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
58
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
51
59
 
52
- if (reconnectAvailabilityResponse && reconnectAvailabilityResponse.redirectURL) {
53
- redirectPage(reconnectAvailabilityResponse.redirectURL);
60
+ if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
61
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
54
62
  } else {
55
- const optionalParams = {
56
- reconnectId: reconnectId
57
- };
63
+ await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
64
+ }
65
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
+
67
+
68
+ const startUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
69
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
70
+
71
+ if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
72
+ await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
73
+ }
74
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
+
76
+
77
+ const setReconnectIdAndStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
78
+ const startUnauthenticatedReconnectChat = {
79
+ eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
80
+ };
81
+ BroadcastService.postMessage(startUnauthenticatedReconnectChat);
82
+ const optionalParams = {
83
+ reconnectId: reconnectId
84
+ };
85
+ dispatch({
86
+ type: LiveChatWidgetActionType.SET_RECONNECT_ID,
87
+ payload: reconnectId
88
+ });
89
+ dispatch({
90
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
91
+ payload: ConversationState.Loading
92
+ });
93
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, optionalParams);
94
+ };
95
+
96
+ const redirectPage = (redirectURL, redirectInSameWindow) => {
97
+ const redirectPageRequest = {
98
+ eventName: BroadcastEvent.RedirectPageRequest,
99
+ payload: {
100
+ redirectURL: redirectURL
101
+ }
102
+ };
103
+ BroadcastService.postMessage(redirectPageRequest);
104
+
105
+ if (redirectInSameWindow) {
106
+ window.location.href = redirectURL;
107
+ }
108
+ };
109
+
110
+ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
111
+ return reconnectAvailabilityResponse && !reconnectAvailabilityResponse.reconnectId;
112
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
+
114
+
115
+ const startNewChatEmptyRedirectionUrl = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat) => {
116
+ const startUnauthenticatedReconnectChat = {
117
+ eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
118
+ };
119
+ BroadcastService.postMessage(startUnauthenticatedReconnectChat); // Getting PreChat Survey Context
120
+
121
+ const parseToJson = false;
122
+ const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
123
+
124
+ if (preChatSurveyResponse) {
58
125
  dispatch({
59
- type: LiveChatWidgetActionType.SET_RECONNECT_ID,
60
- payload: reconnectId
126
+ type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
127
+ payload: preChatSurveyResponse
61
128
  });
129
+ dispatch({
130
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
131
+ payload: ConversationState.Prechat
132
+ });
133
+ } else {
62
134
  dispatch({
63
135
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
64
136
  payload: ConversationState.Loading
65
137
  });
66
- await initStartChat(optionalParams);
138
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter);
67
139
  }
68
- };
140
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
141
 
70
- const redirectPage = newUrl => {
71
- const data = {
72
- messageName: Constants.redirectPageRequest,
73
- newUrl: newUrl
74
- };
75
- window.parent.postMessage(data, "*");
142
+
143
+ const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
144
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
145
+
146
+ if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
147
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
148
+ }
149
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
150
+
151
+
152
+ const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
153
+ if (reconnectAvailabilityResponse.redirectURL) {
154
+ redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
155
+ } else {
156
+ await startNewChatEmptyRedirectionUrl(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat);
157
+ }
76
158
  };
77
159
 
78
- export { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat };
160
+ export { getChatReconnectContext, getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat, handleRedirectUnauthenticatedReconnectChat };
@@ -1,10 +1,9 @@
1
- import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
2
1
  import { RegisterLoggers, TelemetryManager } from "../../../common/telemetry/TelemetryManager";
2
+ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
3
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
4
  import { defaultAriaConfig } from "../../../common/telemetry/defaultConfigs/defaultAriaConfig";
5
5
  import { defaultInternalTelemetryData } from "../../../common/telemetry/defaultConfigs/defaultTelemetryInternalData";
6
6
  import { defaultTelemetryConfiguration } from "../../../common/telemetry/defaultConfigs/defaultTelemetryConfiguration";
7
- import packageInfo from "@microsoft/omnichannel-chat-sdk/package.json";
8
7
  export const registerTelemetryLoggers = (props, dispatch) => {
9
8
  var _props$liveChatContex, _props$liveChatContex2;
10
9
 
@@ -17,6 +16,8 @@ export const registerTelemetryLoggers = (props, dispatch) => {
17
16
 
18
17
  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;
19
18
  } else {
19
+ var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$chatSDK3, _props$chatSDK3$omnic;
20
+
20
21
  let telemetryData = { ...defaultInternalTelemetryData,
21
22
  telemetryConfig: Object.assign({}, defaultTelemetryConfiguration, telemetryConfig),
22
23
  ariaConfig: Object.assign({}, defaultAriaConfig, telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.ariaConfigurations)
@@ -27,7 +28,13 @@ export const registerTelemetryLoggers = (props, dispatch) => {
27
28
  }
28
29
 
29
30
  telemetryData = TelemetryHelper.addWidgetDataToTelemetry(telemetryConfig, telemetryData);
30
- telemetryData.OCChatSDKVersion = packageInfo.version;
31
+ telemetryData.OCChatSDKVersion = telemetryConfig.OCChatSDKVersion ?? "0.0.0-0";
32
+ telemetryData.chatComponentVersion = telemetryConfig.chatComponentVersion ?? "0.0.0-0";
33
+ telemetryData.chatWidgetVersion = telemetryConfig.chatWidgetVersion ?? "0.0.0-0";
34
+ telemetryData.orgId = (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId;
35
+ telemetryData.widgetId = (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId;
36
+ telemetryData.orgUrl = (_props$chatSDK3 = props.chatSDK) === null || _props$chatSDK3 === void 0 ? void 0 : (_props$chatSDK3$omnic = _props$chatSDK3.omnichannelConfig) === null || _props$chatSDK3$omnic === void 0 ? void 0 : _props$chatSDK3$omnic.orgUrl;
37
+ TelemetryManager.InternalTelemetryData = telemetryData;
31
38
  dispatch({
32
39
  type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
33
40
  payload: telemetryData
@@ -1,20 +1,23 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
3
+ import { ConversationState } from "../../../contexts/common/ConversationState";
2
4
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
- import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
- import { ConversationState } from "../../../contexts/common/ConversationState"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
6
 
6
- export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, loadSurvey) => {
7
+ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
7
8
  try {
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- const context = await chatSDK.getPostChatSurveyContext();
10
- TelemetryHelper.logSDKEvent(LogLevel.INFO, {
11
- Event: TelemetryEvent.PostChatContextCallSucceed,
12
- Description: "Postchat context call succeed."
13
- });
14
- dispatch({
15
- type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
16
- payload: context
17
- });
9
+ if (!persistedChat) {
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ const context = await chatSDK.getPostChatSurveyContext();
12
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
13
+ Event: TelemetryEvent.PostChatContextCallSucceed,
14
+ Description: "Postchat context call succeed."
15
+ });
16
+ dispatch({
17
+ type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
18
+ payload: context
19
+ });
20
+ }
18
21
  } catch (ex) {
19
22
  TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
20
23
  Event: TelemetryEvent.PostChatContextCallFailed,
@@ -22,19 +25,13 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, loadSur
22
25
  exception: ex
23
26
  }
24
27
  });
25
- }
26
- /* -true: setPostChatContextAndLoadSurvey is called after passing all checks from ConfirmationPane and endChatMiddleware in usual scenario.
27
- -false: Below if condition is needed for multi-tab scenarios. So when agent ends a chat and customer has opened chat in multiple tabs,
28
- all tabs should show post chat survey as per existing functionality. But when an agent end a conversation, Omnichannel SDK
29
- getPostChatSurveyContext returns as invalid conversation. To avoid that, caching the survey url is needed after chat starts and
30
- in this case loadSurvey is false
31
- */
28
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
29
 
33
30
 
34
- if (loadSurvey) {
31
+ BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
35
32
  dispatch({
36
33
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
37
34
  payload: ConversationState.Postchat
38
35
  });
39
- }
36
+ });
40
37
  };
@@ -0,0 +1,38 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ export function shareObservable(observable) {
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ let observers = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+
6
+ let subscription; // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+
8
+ return new window.Observable(observer => {
9
+ if (!subscription) {
10
+ subscription = observable.subscribe({
11
+ complete() {
12
+ observers.forEach(observer => observer.complete());
13
+ },
14
+
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ error(err) {
17
+ observers.forEach(observer => observer.error(err));
18
+ },
19
+
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ next(value) {
22
+ observers.forEach(observer => observer.next(value));
23
+ }
24
+
25
+ });
26
+ }
27
+
28
+ observers.push(observer);
29
+ return () => {
30
+ observers = observers.filter(o => o !== observer);
31
+
32
+ if (!observers.length) {
33
+ subscription.unsubscribe();
34
+ subscription = null;
35
+ }
36
+ };
37
+ });
38
+ }