@microsoft/omnichannel-chat-widget 0.1.0-main.7338c17 → 0.1.0-main.745305b

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 (132) hide show
  1. package/README.md +3 -11
  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 +36 -4
  5. package/lib/cjs/common/telemetry/TelemetryConstants.js +39 -5
  6. package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
  7. package/lib/cjs/common/telemetry/TelemetryManager.js +17 -6
  8. package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  9. package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  10. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +33 -13
  11. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
  12. package/lib/cjs/common/utils.js +16 -2
  13. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  14. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +1 -1
  15. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -39
  16. package/lib/cjs/components/footerstateful/FooterStateful.js +4 -5
  17. package/lib/cjs/components/headerstateful/HeaderStateful.js +11 -8
  18. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -4
  19. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +16 -21
  20. package/lib/cjs/components/livechatwidget/common/endChat.js +102 -57
  21. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +1 -1
  22. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +32 -7
  23. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +105 -20
  24. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +6 -17
  25. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -5
  26. package/lib/cjs/components/livechatwidget/common/startChat.js +43 -30
  27. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +91 -30
  28. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
  29. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +2 -2
  30. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
  31. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +51 -73
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +9 -46
  33. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +45 -0
  36. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  37. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +7 -7
  38. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -2
  39. package/lib/cjs/contexts/createReducer.js +7 -10
  40. package/lib/cjs/controller/componentController.js +2 -2
  41. package/lib/cjs/plugins/newMessageEventHandler.js +102 -0
  42. package/lib/esm/assets/Audios.js +1 -0
  43. package/lib/esm/assets/Icons.js +11 -0
  44. package/lib/esm/common/Constants.js +32 -3
  45. package/lib/esm/common/telemetry/TelemetryConstants.js +35 -4
  46. package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
  47. package/lib/esm/common/telemetry/TelemetryManager.js +15 -6
  48. package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  49. package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  50. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +36 -14
  51. package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
  52. package/lib/esm/common/utils.js +12 -1
  53. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  54. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +1 -1
  55. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -35
  56. package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
  57. package/lib/esm/components/headerstateful/HeaderStateful.js +12 -9
  58. package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -3
  59. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -22
  60. package/lib/esm/components/livechatwidget/common/endChat.js +101 -55
  61. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +1 -1
  62. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +29 -8
  63. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +94 -20
  64. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +5 -14
  65. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -5
  66. package/lib/esm/components/livechatwidget/common/startChat.js +43 -31
  67. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +83 -28
  68. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
  69. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +3 -3
  70. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
  71. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -12
  72. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -44
  73. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  74. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  75. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +32 -0
  76. package/lib/esm/contexts/common/ConversationState.js +3 -2
  77. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +7 -7
  78. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -2
  79. package/lib/esm/contexts/createReducer.js +7 -9
  80. package/lib/esm/controller/componentController.js +2 -2
  81. package/lib/esm/plugins/newMessageEventHandler.js +84 -0
  82. package/lib/types/assets/Audios.d.ts +1 -0
  83. package/lib/types/assets/Icons.d.ts +11 -0
  84. package/lib/types/common/Constants.d.ts +18 -1
  85. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  86. package/lib/types/common/telemetry/TelemetryConstants.d.ts +24 -3
  87. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
  88. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
  89. package/lib/types/common/utils.d.ts +1 -0
  90. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +5 -2
  91. package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
  92. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +4 -1
  93. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  94. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -2
  95. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  96. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -1
  97. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -0
  98. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  99. package/lib/types/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.d.ts +1 -1
  100. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
  101. package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
  102. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  103. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  104. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +7 -7
  105. package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
  106. package/package.json +9 -11
  107. package/lib/cjs/assets/assets.d.js +0 -1
  108. package/lib/cjs/assets/audios/newMessageNotification.mp3 +0 -0
  109. package/lib/cjs/assets/icons/archiveIcon.svg +0 -3
  110. package/lib/cjs/assets/icons/audioIcon.svg +0 -6
  111. package/lib/cjs/assets/icons/blankIcon.svg +0 -6
  112. package/lib/cjs/assets/icons/excelIcon.svg +0 -6
  113. package/lib/cjs/assets/icons/imageIcon.svg +0 -6
  114. package/lib/cjs/assets/icons/oneNoteIcon.svg +0 -6
  115. package/lib/cjs/assets/icons/pdfIcon.svg +0 -6
  116. package/lib/cjs/assets/icons/powerpointIcon.svg +0 -6
  117. package/lib/cjs/assets/icons/videoIcon.svg +0 -6
  118. package/lib/cjs/assets/icons/visioIcon.svg +0 -6
  119. package/lib/cjs/assets/icons/wordIcon.svg +0 -6
  120. package/lib/esm/assets/assets.d.js +0 -0
  121. package/lib/esm/assets/audios/newMessageNotification.mp3 +0 -0
  122. package/lib/esm/assets/icons/archiveIcon.svg +0 -3
  123. package/lib/esm/assets/icons/audioIcon.svg +0 -6
  124. package/lib/esm/assets/icons/blankIcon.svg +0 -6
  125. package/lib/esm/assets/icons/excelIcon.svg +0 -6
  126. package/lib/esm/assets/icons/imageIcon.svg +0 -6
  127. package/lib/esm/assets/icons/oneNoteIcon.svg +0 -6
  128. package/lib/esm/assets/icons/pdfIcon.svg +0 -6
  129. package/lib/esm/assets/icons/powerpointIcon.svg +0 -6
  130. package/lib/esm/assets/icons/videoIcon.svg +0 -6
  131. package/lib/esm/assets/icons/visioIcon.svg +0 -6
  132. package/lib/esm/assets/icons/wordIcon.svg +0 -6
@@ -4,13 +4,13 @@ import AudioNotificationStateful from "./audionotificationstateful/AudioNotifica
4
4
  import { Constants } from "../../common/Constants";
5
5
  import { Footer } from "@microsoft/omnichannel-chat-components";
6
6
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
7
+ import { NewMessageNotificationSoundBase64 } from "../../assets/Audios";
7
8
  import { NotificationHandler } from "../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
8
9
  import { NotificationScenarios } from "../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
9
10
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
10
11
  import { downloadTranscript } from "./downloadtranscriptstateful/DownloadTranscriptStateful";
11
12
  import useChatContextStore from "../../hooks/useChatContextStore";
12
- import useChatSDKStore from "../../hooks/useChatSDKStore";
13
- import newMessageNotification from "../../assets/audios/newMessageNotification.mp3"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ import useChatSDKStore from "../../hooks/useChatSDKStore"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
14
 
15
15
  export const FooterStateful = props => {
16
16
  var _footerProps$controlP3, _footerProps$controlP4;
@@ -96,9 +96,8 @@ export const FooterStateful = props => {
96
96
  controlProps: controlProps,
97
97
  styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
98
98
  }), /*#__PURE__*/React.createElement(AudioNotificationStateful, {
99
- audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? newMessageNotification,
100
- hideAudioNotificationButton: (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : _footerProps$controlP4.hideAudioNotificationButton) ?? false,
101
- isAudioMuted: state.appStates.isAudioMuted ?? false
99
+ audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? NewMessageNotificationSoundBase64,
100
+ isAudioMuted: state.appStates.isAudioMuted === null ? (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : _footerProps$controlP4.hideAudioNotificationButton) ?? false : state.appStates.isAudioMuted ?? false
102
101
  }));
103
102
  };
104
103
  export default FooterStateful;
@@ -1,5 +1,5 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
- import React, { useEffect, useState } from "react";
2
+ import React, { useEffect, useRef, useState } from "react";
3
3
  import { ConversationState } from "../../contexts/common/ConversationState";
4
4
  import { Header } from "@microsoft/omnichannel-chat-components";
5
5
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
@@ -21,6 +21,7 @@ export const HeaderStateful = props => {
21
21
 
22
22
  const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_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.OutOfOperatingHours) === "True");
23
23
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
24
+ const conversationState = useRef(state.appStates.conversationState);
24
25
  const controlProps = {
25
26
  id: "oc-lcw-header",
26
27
  dir: state.domainStates.globalDir,
@@ -40,17 +41,15 @@ export const HeaderStateful = props => {
40
41
  Description: "Header Close button clicked."
41
42
  });
42
43
 
43
- if (state.appStates.conversationState === ConversationState.Active) {
44
+ if (conversationState.current === ConversationState.Active) {
44
45
  dispatch({
45
46
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
46
47
  payload: true
47
48
  });
48
- } else if (state.appStates.conversationState === ConversationState.Postchat) {
49
- dispatch({
50
- type: LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT,
51
- payload: false
52
- });
53
- await endChat(adapter);
49
+ } else {
50
+ const skipEndChatSDK = true;
51
+ const skipCloseChat = false;
52
+ await endChat(adapter, skipEndChatSDK, skipCloseChat);
54
53
  }
55
54
 
56
55
  dispatch({
@@ -82,7 +81,11 @@ export const HeaderStateful = props => {
82
81
  if (state.appStates.outsideOperatingHours) {
83
82
  setOutOfOperatingHours(true);
84
83
  }
85
- }, []);
84
+
85
+ if (state.appStates.conversationState) {
86
+ conversationState.current = state.appStates.conversationState;
87
+ }
88
+ }, [state.appStates]);
86
89
  return /*#__PURE__*/React.createElement(Header, {
87
90
  componentOverrides: headerProps === null || headerProps === void 0 ? void 0 : headerProps.componentOverrides,
88
91
  controlProps: outOfOperatingHours || state.appStates.conversationState === ConversationState.OutOfOffice ? outOfOfficeControlProps : controlProps,
@@ -1,5 +1,4 @@
1
1
  import MarkdownIt from "markdown-it";
2
- import MarkdownSlack from "slack-markdown-it";
3
2
  import MarkdownItForInline from "markdown-it-for-inline";
4
3
  import { defaultMarkdownLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMarkdownLocalizedTexts";
5
4
  import { Constants } from "../../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -12,8 +11,9 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
12
11
  html: true,
13
12
  linkify: true,
14
13
  breaks: !disableNewLineMarkdownSupport
15
- });
16
- markdown.use(MarkdownSlack); // Markdown override for open link in new tab
14
+ }); // ToDo: Commenting below usage of plugin until deferred bug is resolved: https://github.com/mayashavin/markdown-it-slack/issues/1
15
+ // markdown.use(MarkdownSlack);
16
+ // Markdown override for open link in new tab
17
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, quotes
18
18
 
19
19
  markdown.use(MarkdownItForInline, "url_new_win", "link_open", function (tokens, idx, env) {
@@ -1,5 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any */
2
+ import { ChatReconnectIconBase64, CloseChatButtonIconBase64, ModernChatIconBase64, ProactiveChatBannerBase64 } from "@microsoft/omnichannel-chat-components";
2
3
  import MockAdapter from "../../../webchatcontainerstateful/common/mockadapter";
4
+ import { NewMessageNotificationSoundBase64 } from "../../../../assets/Audios";
3
5
  import { WebChatStoreLoader } from "../../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
4
6
  import { activityStatusMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware";
5
7
  import { createActivityMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
@@ -8,10 +10,11 @@ import { createAvatarMiddleware } from "../../../webchatcontainerstateful/webcha
8
10
  import { createMarkdown } from "../createMarkdown";
9
11
  import { groupActivitiesMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware";
10
12
  import { typingIndicatorMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware";
11
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
+ import { createWebChatTelemetry } from "../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger"; // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
+
12
15
  export const dummyDefaultProps = {
13
16
  audioNotificationProps: {
14
- audioSrc: "assets/audios/newMessageNotification.mp3"
17
+ audioSrc: NewMessageNotificationSoundBase64
15
18
  },
16
19
  callingContainerProps: {
17
20
  controlProps: {
@@ -250,18 +253,6 @@ export const dummyDefaultProps = {
250
253
  width: "50px",
251
254
  fontSize: "18px"
252
255
  },
253
- currentCallTimerStyleProps: {
254
- borderRadius: "2px",
255
- margin: "1px",
256
- color: "#FFFFFF",
257
- paddingTop: "18px",
258
- fontSize: 12,
259
- fontFamily: "Segoe UI, Arial, sans-serif",
260
- backgroundColor: "darkgrey",
261
- height: "45px",
262
- width: "50px",
263
- textAlign: "center"
264
- },
265
256
  videoTileStyleProps: {
266
257
  width: "100%",
267
258
  marginLeft: "auto",
@@ -366,7 +357,7 @@ export const dummyDefaultProps = {
366
357
  margin: "-2px -2px -2px -3px",
367
358
  justifyContent: "center",
368
359
  backgroundSize: "65% 65%",
369
- backgroundImage: "assets/imgs/chat.svg",
360
+ backgroundImage: `url(${ModernChatIconBase64})`,
370
361
  display: "flex",
371
362
  backgroundRepeat: "no-repeat",
372
363
  backgroundPosition: "center"
@@ -887,7 +878,7 @@ export const dummyDefaultProps = {
887
878
  },
888
879
  headerIconProps: {
889
880
  id: "oc-lcw-header-icon",
890
- src: "assets/imgs/chatIcon.svg",
881
+ src: ModernChatIconBase64,
891
882
  alt: "Chat Icon",
892
883
  className: undefined
893
884
  },
@@ -1012,7 +1003,7 @@ export const dummyDefaultProps = {
1012
1003
  alignSelf: "auto"
1013
1004
  },
1014
1005
  iconImageProps: {
1015
- src: "assets/imgs/chat.svg",
1006
+ src: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIwX2lpKSI+DQo8cGF0aCBkPSJNMTUuMTk3MSAxNi4yNzI1VjI1Ljg1MjRDMTUuMTk3MSAyNy4zODExIDE1Ljg0MDEgMjcuNTIwMSAxNi45ODMyIDI3LjUyMDFMMjYuNzA4NCAyNy41NjQ5TDMxLjAwMzkgMzIuMzEyM1YyNy41NjQ5SDMxLjg5N0MzMi4xNzQzIDI3LjU2MzcgMzIuNDQ4NyAyNy41MDc3IDMyLjcwNDUgMjcuNDAwMUMzMi45NjAzIDI3LjI5MjQgMzMuMTkyNSAyNy4xMzUzIDMzLjM4NzggMjYuOTM3NUMzMy41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GIi8+DQo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IndoaXRlIi8+DQo8L2xpbmVhckdyYWRpZW50Pg0KPC9kZWZzPg0KPC9zdmc+DQo=",
1016
1007
  imageFit: 0,
1017
1008
  width: "86px",
1018
1009
  height: "86px",
@@ -1220,7 +1211,7 @@ export const dummyDefaultProps = {
1220
1211
  },
1221
1212
  headerContainerStyleProps: {
1222
1213
  backgroundColor: "rgb(49, 95, 162)",
1223
- backgroundImage: "assets/imgs/Proactive_banner.png",
1214
+ backgroundImage: `url(${ProactiveChatBannerBase64})`,
1224
1215
  backgroundPosition: "initial",
1225
1216
  backgroundRepeat: "no-repeat",
1226
1217
  borderTopLeftRadius: "inherit",
@@ -1248,7 +1239,7 @@ export const dummyDefaultProps = {
1248
1239
  fontWeight: "600"
1249
1240
  },
1250
1241
  closeButtonStyleProps: {
1251
- backgroundImage: "assets/imgs/closeChatButton.svg",
1242
+ backgroundImage: `url(${CloseChatButtonIconBase64})`,
1252
1243
  backgroundPosition: "center",
1253
1244
  backgroundRepeat: "no-repeat",
1254
1245
  color: "#605e5c",
@@ -1371,7 +1362,7 @@ export const dummyDefaultProps = {
1371
1362
  lineHeight: "19px"
1372
1363
  },
1373
1364
  iconStyleProps: {
1374
- backgroundImage: "assets/imgs//ChatReconnectPopupIcon.png",
1365
+ backgroundImage: `url(${ChatReconnectIconBase64})`,
1375
1366
  backgroundPosition: "center",
1376
1367
  backgroundRepeat: "no-repeat",
1377
1368
  backgroundSize: "200px",
@@ -1422,7 +1413,8 @@ export const dummyDefaultProps = {
1422
1413
  },
1423
1414
  authClientFunction: undefined,
1424
1415
  isReconnectEnabled: undefined,
1425
- reconnectId: undefined
1416
+ reconnectId: undefined,
1417
+ redirectInSameWindow: undefined
1426
1418
  },
1427
1419
  styleProps: {
1428
1420
  generalStyles: {
@@ -1494,7 +1486,7 @@ export const dummyDefaultProps = {
1494
1486
  internalErrorBoxClass: undefined,
1495
1487
  internalRenderErrorBox: undefined,
1496
1488
  locale: "en-US",
1497
- onTelemetry: undefined,
1489
+ onTelemetry: createWebChatTelemetry(),
1498
1490
  overrideLocalizedStrings: undefined,
1499
1491
  renderMarkdown: createMarkdown(false, false),
1500
1492
  scrollToEndButtonMiddleware: undefined,
@@ -1,61 +1,107 @@
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 { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
6
- import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
7
5
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
8
6
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
9
- import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
-
11
- export const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter) => {
12
- try {
13
- var _props$webChatContain;
14
-
15
- TelemetryHelper.logSDKEvent(LogLevel.INFO, {
16
- Event: TelemetryEvent.EndChatSDKCall
17
- });
18
- await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
19
- adapter === null || adapter === void 0 ? void 0 : adapter.end();
20
- setAdapter(undefined);
21
- setWebChatStyles({ ...defaultWebChatContainerStatefulProps.webChatStyles,
22
- ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
23
- });
24
- WebChatStoreLoader.store = null;
25
- dispatch({
26
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
27
- payload: ConversationState.Closed
28
- });
29
- dispatch({
30
- type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
31
- payload: false
32
- });
33
- dispatch({
34
- type: LiveChatWidgetActionType.SET_RECONNECT_ID,
35
- payload: undefined
36
- });
37
- dispatch({
38
- type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
39
- payload: null
40
- });
41
- dispatch({
42
- type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
43
- payload: undefined
44
- });
45
- dispatch({
46
- type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
47
- payload: undefined
48
- });
49
- BroadcastService.postMessage({
50
- eventName: "EndChat"
51
- });
52
- } catch (ex) {
53
- TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
54
- Event: TelemetryEvent.EndChatSDKCallFailed,
55
- ExceptionDetails: {
56
- exception: ex
57
- }
58
- });
59
- NotificationHandler.notifyError(NotificationScenarios.Connection, "End Chat Call Failed: " + ex);
7
+ import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
8
+ import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
9
+ import { Constants } from "../../../common/Constants";
10
+
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
13
+ var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
14
+
15
+ const isPostChatEnabled = (_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;
16
+ const postChatSurveyMode = (_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_postconversationsurveymode;
17
+ const conversationDetails = await chatSDK.getConversationDetails();
18
+
19
+ if (isPostChatEnabled === "true" && (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === Constants.truePascal) {
20
+ const skipEndChatSDK = false;
21
+ const skipCloseChat = true;
22
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
23
+
24
+ if (postChatSurveyMode === PostChatSurveyMode.Embed) {
25
+ const loadPostChatEvent = {
26
+ eventName: BroadcastEvent.LoadPostChatSurvey
27
+ };
28
+ BroadcastService.postMessage(loadPostChatEvent);
29
+ } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
30
+ dispatch({
31
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
32
+ payload: ConversationState.InActive
33
+ });
34
+ }
35
+ } else {
36
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
37
+ }
38
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+
40
+
41
+ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat) => {
42
+ if (!skipEndChatSDK) {
43
+ try {
44
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
45
+ Event: TelemetryEvent.EndChatSDKCall
46
+ });
47
+ await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat()); // Need to clear these states immediately when chat ended from OC.
48
+
49
+ dispatch({
50
+ type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
51
+ payload: undefined
52
+ });
53
+ dispatch({
54
+ type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
55
+ payload: undefined
56
+ });
57
+ } catch (ex) {
58
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
59
+ Event: TelemetryEvent.EndChatSDKCallFailed,
60
+ ExceptionDetails: {
61
+ exception: ex
62
+ }
63
+ });
64
+ }
65
+ }
66
+
67
+ if (!skipCloseChat) {
68
+ try {
69
+ var _props$webChatContain;
70
+
71
+ adapter === null || adapter === void 0 ? void 0 : adapter.end();
72
+ setAdapter(undefined);
73
+ setWebChatStyles({ ...defaultWebChatContainerStatefulProps.webChatStyles,
74
+ ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
75
+ });
76
+ WebChatStoreLoader.store = null;
77
+ dispatch({
78
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
79
+ payload: ConversationState.Closed
80
+ });
81
+ dispatch({
82
+ type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
83
+ payload: false
84
+ });
85
+ dispatch({
86
+ type: LiveChatWidgetActionType.SET_RECONNECT_ID,
87
+ payload: undefined
88
+ });
89
+ dispatch({
90
+ type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
91
+ payload: null
92
+ });
93
+ BroadcastService.postMessage({
94
+ eventName: BroadcastEvent.EndChat
95
+ });
96
+ } catch (error) {
97
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
98
+ Event: TelemetryEvent.CloseChatMethodException,
99
+ ExceptionDetails: {
100
+ exception: `Failed to endChat: ${error}`
101
+ }
102
+ });
103
+ }
60
104
  }
61
- };
105
+ };
106
+
107
+ export { prepareEndChat, endChat };
@@ -8,7 +8,7 @@ export const initCallingSdk = async (chatSDK, setVoiceVideoCallingSDK) => {
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
9
  const callingSDK = await chatSDK.getVoiceVideoCalling();
10
10
  setVoiceVideoCallingSDK(callingSDK);
11
- TelemetryHelper.logCallingEvent(LogLevel.ERROR, {
11
+ TelemetryHelper.logCallingEvent(LogLevel.INFO, {
12
12
  Event: TelemetryEvent.CallingSDKLoadSuccess
13
13
  });
14
14
  return true;
@@ -1,6 +1,10 @@
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
2
  import { createStore } from "botframework-webchat";
3
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
+ import { ConversationState } from "../../../contexts/common/ConversationState";
2
5
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
6
  import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
7
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
8
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
5
9
  import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
6
10
  import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
@@ -13,6 +17,7 @@ import createConversationEndMiddleware from "../../webchatcontainerstateful/webc
13
17
  import createDataMaskingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware";
14
18
  import { createMarkdown } from "./createMarkdown";
15
19
  import createMaxMessageSizeValidator from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator";
20
+ import { createWebChatTelemetry } from "../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
16
21
  import { defaultAttachmentProps } from "../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps";
17
22
  import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
18
23
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
@@ -21,9 +26,8 @@ import gifUploadMiddleware from "../../webchatcontainerstateful/webchatcontrolle
21
26
  import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware";
22
27
  import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
23
28
  import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
24
- import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
25
- import { BroadcastService } from "@microsoft/omnichannel-chat-components";
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+
27
31
  export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
28
32
  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;
29
33
 
@@ -44,6 +48,11 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
44
48
  const conversationEndCallback = async () => {
45
49
  var _props$webChatContain4, _props$webChatContain5;
46
50
 
51
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
52
+ Event: TelemetryEvent.ConversationEndedThreadEventReceived,
53
+ Description: "Conversation is ended by agent side or by timeout."
54
+ });
55
+
47
56
  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) {
48
57
  setWebChatStyles(styles => {
49
58
  return { ...styles,
@@ -52,11 +61,18 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
52
61
  });
53
62
  }
54
63
 
55
- if (isPostChatEnabled === "true" && postChatSurveyMode === PostChatSurveyMode.Embed) {
56
- const loadPostChatEvent = {
57
- eventName: "LoadPostChatSurvey"
58
- };
59
- BroadcastService.postMessage(loadPostChatEvent);
64
+ if (isPostChatEnabled === "true") {
65
+ if (postChatSurveyMode === PostChatSurveyMode.Embed) {
66
+ const loadPostChatEvent = {
67
+ eventName: BroadcastEvent.LoadPostChatSurvey
68
+ };
69
+ BroadcastService.postMessage(loadPostChatEvent);
70
+ } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
71
+ dispatch({
72
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
73
+ payload: ConversationState.InActive
74
+ });
75
+ }
60
76
  } else {
61
77
  dispatch({
62
78
  type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
@@ -68,6 +84,10 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
68
84
  type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
69
85
  payload: undefined
70
86
  });
87
+ dispatch({
88
+ type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
89
+ payload: undefined
90
+ });
71
91
  };
72
92
 
73
93
  webChatStore = createStore({}, //initial state
@@ -88,6 +108,7 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
88
108
  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),
89
109
  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,
90
110
  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,
111
+ onTelemetry: createWebChatTelemetry(),
91
112
  ...((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.webChatProps)
92
113
  };
93
114
  return webChatProps;
@@ -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
@@ -46,33 +46,107 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
46
46
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
47
 
48
48
 
49
- const handleUnauthenticatedReconnectChat = async (dispatch, reconnectId, initStartChat) => {
50
- const reconnectAvailabilityResponse = await getChatReconnectContext(reconnectId);
49
+ const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
50
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
51
51
 
52
- if (reconnectAvailabilityResponse && reconnectAvailabilityResponse.redirectURL) {
53
- redirectPage(reconnectAvailabilityResponse.redirectURL);
52
+ if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
53
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
54
54
  } else {
55
- const optionalParams = {
56
- reconnectId: reconnectId
57
- };
55
+ await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
56
+ }
57
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+
59
+
60
+ const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
61
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
62
+
63
+ if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
64
+ await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
65
+ }
66
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
+
68
+
69
+ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
70
+ const startUnauthenticatedReconnectChat = {
71
+ eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
72
+ };
73
+ BroadcastService.postMessage(startUnauthenticatedReconnectChat);
74
+ const optionalParams = {
75
+ reconnectId: reconnectId
76
+ };
77
+ dispatch({
78
+ type: LiveChatWidgetActionType.SET_RECONNECT_ID,
79
+ payload: reconnectId
80
+ });
81
+ dispatch({
82
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
83
+ payload: ConversationState.Loading
84
+ });
85
+ await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
86
+ };
87
+
88
+ const redirectPage = (redirectURL, redirectInSameWindow) => {
89
+ const redirectPageRequest = {
90
+ eventName: BroadcastEvent.RedirectPageRequest,
91
+ payload: {
92
+ redirectURL: redirectURL
93
+ }
94
+ };
95
+ BroadcastService.postMessage(redirectPageRequest);
96
+
97
+ if (redirectInSameWindow) {
98
+ window.location.href = redirectURL;
99
+ }
100
+ };
101
+
102
+ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
103
+ return reconnectAvailabilityResponse && !reconnectAvailabilityResponse.reconnectId;
104
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
+
106
+
107
+ const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
108
+ const startUnauthenticatedReconnectChat = {
109
+ eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
110
+ };
111
+ BroadcastService.postMessage(startUnauthenticatedReconnectChat); // Getting PreChat Survey Context
112
+
113
+ const parseToJson = false;
114
+ const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
115
+
116
+ if (preChatSurveyResponse) {
58
117
  dispatch({
59
- type: LiveChatWidgetActionType.SET_RECONNECT_ID,
60
- payload: reconnectId
118
+ type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
119
+ payload: preChatSurveyResponse
61
120
  });
121
+ dispatch({
122
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
123
+ payload: ConversationState.Prechat
124
+ });
125
+ } else {
62
126
  dispatch({
63
127
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
64
128
  payload: ConversationState.Loading
65
129
  });
66
- await initStartChat(optionalParams);
130
+ await initStartChat(chatSDK, dispatch, setAdapter);
67
131
  }
68
- };
132
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
133
 
70
- const redirectPage = newUrl => {
71
- const data = {
72
- messageName: Constants.redirectPageRequest,
73
- newUrl: newUrl
74
- };
75
- window.parent.postMessage(data, "*");
134
+
135
+ const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
136
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
137
+
138
+ if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
139
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
140
+ }
141
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
+
143
+
144
+ const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
145
+ if (reconnectAvailabilityResponse.redirectURL) {
146
+ redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
147
+ } else {
148
+ await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
149
+ }
76
150
  };
77
151
 
78
- export { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat };
152
+ export { getChatReconnectContext, getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat, handleRedirectUnauthenticatedReconnectChat };