@microsoft/omnichannel-chat-widget 0.1.0-main.cf54410 → 0.1.0-main.e170704

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 (141) hide show
  1. package/README.md +227 -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 +36 -4
  5. package/lib/cjs/common/telemetry/TelemetryConstants.js +42 -4
  6. package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
  7. package/lib/cjs/common/telemetry/TelemetryManager.js +11 -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 +31 -10
  11. package/lib/cjs/common/utils.js +15 -2
  12. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +1 -1
  13. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -41
  14. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
  15. package/lib/cjs/components/footerstateful/FooterStateful.js +4 -5
  16. package/lib/cjs/components/headerstateful/HeaderStateful.js +11 -8
  17. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -4
  18. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +16 -9
  19. package/lib/cjs/components/livechatwidget/common/endChat.js +102 -58
  20. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +5 -0
  21. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +28 -7
  22. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +105 -20
  23. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +6 -17
  24. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -5
  25. package/lib/cjs/components/livechatwidget/common/startChat.js +52 -39
  26. package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -3
  27. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +96 -28
  28. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
  29. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +8 -0
  30. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
  31. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -5
  32. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +10 -4
  33. package/lib/cjs/{assets/assets.d.js → components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js} +0 -0
  34. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
  35. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +51 -73
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +9 -46
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +44 -0
  40. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  41. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +7 -7
  42. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -2
  43. package/lib/cjs/contexts/createReducer.js +7 -10
  44. package/lib/cjs/controller/componentController.js +2 -2
  45. package/lib/cjs/plugins/newMessageEventHandler.js +102 -0
  46. package/lib/esm/assets/Audios.js +1 -0
  47. package/lib/esm/assets/Icons.js +11 -0
  48. package/lib/esm/common/Constants.js +32 -3
  49. package/lib/esm/common/telemetry/TelemetryConstants.js +38 -3
  50. package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
  51. package/lib/esm/common/telemetry/TelemetryManager.js +10 -6
  52. package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  53. package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  54. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +33 -13
  55. package/lib/esm/common/utils.js +11 -1
  56. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +1 -1
  57. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -37
  58. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
  59. package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
  60. package/lib/esm/components/headerstateful/HeaderStateful.js +12 -9
  61. package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -3
  62. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -10
  63. package/lib/esm/components/livechatwidget/common/endChat.js +100 -55
  64. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -0
  65. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +25 -8
  66. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +94 -20
  67. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +5 -14
  68. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -5
  69. package/lib/esm/components/livechatwidget/common/startChat.js +50 -38
  70. package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
  71. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +88 -27
  72. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
  73. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +6 -0
  74. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
  75. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -4
  76. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +9 -5
  77. package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  78. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
  79. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -12
  80. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -44
  81. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  82. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  83. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +31 -0
  84. package/lib/esm/contexts/common/ConversationState.js +3 -2
  85. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +7 -7
  86. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -2
  87. package/lib/esm/contexts/createReducer.js +7 -9
  88. package/lib/esm/controller/componentController.js +2 -2
  89. package/lib/esm/plugins/newMessageEventHandler.js +84 -0
  90. package/lib/types/assets/Audios.d.ts +1 -0
  91. package/lib/types/assets/Icons.d.ts +11 -0
  92. package/lib/types/common/Constants.d.ts +18 -1
  93. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  94. package/lib/types/common/telemetry/TelemetryConstants.d.ts +25 -1
  95. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
  96. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
  97. package/lib/types/common/utils.d.ts +1 -0
  98. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +5 -2
  99. package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
  100. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +4 -1
  101. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  102. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -2
  103. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
  104. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  105. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -1
  106. package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
  107. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -0
  108. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  109. package/lib/types/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.d.ts +1 -1
  110. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
  111. package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
  112. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  113. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  114. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +7 -7
  115. package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
  116. package/package.json +9 -11
  117. package/lib/cjs/assets/audios/newMessageNotification.mp3 +0 -0
  118. package/lib/cjs/assets/icons/archiveIcon.svg +0 -3
  119. package/lib/cjs/assets/icons/audioIcon.svg +0 -6
  120. package/lib/cjs/assets/icons/blankIcon.svg +0 -6
  121. package/lib/cjs/assets/icons/excelIcon.svg +0 -6
  122. package/lib/cjs/assets/icons/imageIcon.svg +0 -6
  123. package/lib/cjs/assets/icons/oneNoteIcon.svg +0 -6
  124. package/lib/cjs/assets/icons/pdfIcon.svg +0 -6
  125. package/lib/cjs/assets/icons/powerpointIcon.svg +0 -6
  126. package/lib/cjs/assets/icons/videoIcon.svg +0 -6
  127. package/lib/cjs/assets/icons/visioIcon.svg +0 -6
  128. package/lib/cjs/assets/icons/wordIcon.svg +0 -6
  129. package/lib/esm/assets/assets.d.js +0 -0
  130. package/lib/esm/assets/audios/newMessageNotification.mp3 +0 -0
  131. package/lib/esm/assets/icons/archiveIcon.svg +0 -3
  132. package/lib/esm/assets/icons/audioIcon.svg +0 -6
  133. package/lib/esm/assets/icons/blankIcon.svg +0 -6
  134. package/lib/esm/assets/icons/excelIcon.svg +0 -6
  135. package/lib/esm/assets/icons/imageIcon.svg +0 -6
  136. package/lib/esm/assets/icons/oneNoteIcon.svg +0 -6
  137. package/lib/esm/assets/icons/pdfIcon.svg +0 -6
  138. package/lib/esm/assets/icons/powerpointIcon.svg +0 -6
  139. package/lib/esm/assets/icons/videoIcon.svg +0 -6
  140. package/lib/esm/assets/icons/visioIcon.svg +0 -6
  141. package/lib/esm/assets/icons/wordIcon.svg +0 -6
@@ -1,61 +1,106 @@
1
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
2
3
  import { ConversationState } from "../../../contexts/common/ConversationState";
3
4
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
4
- import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
5
- import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
6
5
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
7
6
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
8
7
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
9
- import { BroadcastService } from "@microsoft/omnichannel-chat-components"; // 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.logConfigDataEvent(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);
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);
60
37
  }
61
- };
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());
48
+ } catch (ex) {
49
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
50
+ Event: TelemetryEvent.EndChatSDKCallFailed,
51
+ ExceptionDetails: {
52
+ exception: ex
53
+ }
54
+ });
55
+ }
56
+ }
57
+
58
+ if (!skipCloseChat) {
59
+ try {
60
+ var _props$webChatContain;
61
+
62
+ adapter === null || adapter === void 0 ? void 0 : adapter.end();
63
+ setAdapter(undefined);
64
+ setWebChatStyles({ ...defaultWebChatContainerStatefulProps.webChatStyles,
65
+ ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
66
+ });
67
+ WebChatStoreLoader.store = null;
68
+ dispatch({
69
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
70
+ payload: ConversationState.Closed
71
+ });
72
+ dispatch({
73
+ type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
74
+ payload: false
75
+ });
76
+ dispatch({
77
+ type: LiveChatWidgetActionType.SET_RECONNECT_ID,
78
+ payload: undefined
79
+ });
80
+ dispatch({
81
+ type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
82
+ payload: null
83
+ });
84
+ dispatch({
85
+ type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
86
+ payload: undefined
87
+ });
88
+ dispatch({
89
+ type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
90
+ payload: undefined
91
+ });
92
+ BroadcastService.postMessage({
93
+ eventName: BroadcastEvent.EndChat
94
+ });
95
+ } catch (error) {
96
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
97
+ Event: TelemetryEvent.CloseChatMethodException,
98
+ ExceptionDetails: {
99
+ exception: `Failed to endChat: ${error}`
100
+ }
101
+ });
102
+ }
103
+ }
104
+ };
105
+
106
+ export { prepareEndChat, endChat };
@@ -8,6 +8,9 @@ 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.INFO, {
12
+ Event: TelemetryEvent.CallingSDKLoadSuccess
13
+ });
11
14
  return true;
12
15
  }
13
16
 
@@ -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,
@@ -88,6 +104,7 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
88
104
  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
105
  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
106
  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,
107
+ onTelemetry: createWebChatTelemetry(),
91
108
  ...((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.webChatProps)
92
109
  };
93
110
  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 };
@@ -1,22 +1,12 @@
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 { version as chatComponentVersion } from "@microsoft/omnichannel-chat-components/package.json";
8
- import { version as chatSdkVersion } from "@microsoft/omnichannel-chat-sdk/package.json";
9
7
  export const registerTelemetryLoggers = (props, dispatch) => {
10
8
  var _props$liveChatContex, _props$liveChatContex2;
11
9
 
12
- let widgetPackageInfo;
13
-
14
- try {
15
- widgetPackageInfo = require("@microsoft/omnichannel-chat-widget/package.json");
16
- } catch (error) {
17
- widgetPackageInfo = "0.0.0-0";
18
- }
19
-
20
10
  const telemetryConfig = { ...defaultTelemetryConfiguration,
21
11
  ...props.telemetryConfig
22
12
  };
@@ -38,12 +28,13 @@ export const registerTelemetryLoggers = (props, dispatch) => {
38
28
  }
39
29
 
40
30
  telemetryData = TelemetryHelper.addWidgetDataToTelemetry(telemetryConfig, telemetryData);
41
- telemetryData.OCChatSDKVersion = chatSdkVersion;
42
- telemetryData.chatComponentVersion = chatComponentVersion;
43
- telemetryData.chatWidgetVersion = widgetPackageInfo;
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";
44
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;
45
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;
46
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;
47
38
  dispatch({
48
39
  type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
49
40
  payload: telemetryData
@@ -1,9 +1,9 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
- import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
- import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
- import { ConversationState } from "../../../contexts/common/ConversationState";
5
2
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
+ import { ConversationState } from "../../../contexts/common/ConversationState";
4
+ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+
7
7
  export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
8
8
  try {
9
9
  if (!persistedChat) {
@@ -25,7 +25,8 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persist
25
25
  exception: ex
26
26
  }
27
27
  });
28
- }
28
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
+
29
30
 
30
31
  BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
31
32
  dispatch({
@@ -1,70 +1,80 @@
1
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
1
  import { ChatSDKError, Constants } from "../../../common/Constants";
2
+ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { ConversationState } from "../../../contexts/common/ConversationState";
4
+ import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
4
5
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
6
  import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
6
7
  import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
7
8
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
8
9
  import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
9
10
  import { createAdapter } from "./createAdapter";
11
+ import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
10
12
  import { createTimer } from "../../../common/utils";
11
- import { getReconnectIdForAuthenticatedChat } from "./reconnectChatHelper";
12
- import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
13
+ import { getReconnectIdForAuthenticatedChat, handleRedirectUnauthenticatedReconnectChat } from "./reconnectChatHelper";
13
14
  import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
14
- import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
16
 
16
17
  const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
18
+ var _props$reconnectChatP;
19
+
17
20
  if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
18
21
  return;
19
- } // Getting PreChat Survey Context
22
+ } // Redirecting if unauthenticated reconnect chat expired
20
23
 
21
24
 
22
- const parseToJson = false;
23
- const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
24
- const showPrechat = state.appStates.conversationState === ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
25
+ if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
26
+ var _props$reconnectChatP2, _props$reconnectChatP3;
25
27
 
26
- const reconnectId = await getReconnectIdForAuthenticatedChat(props, chatSDK);
27
-
28
- if (reconnectId) {
29
- dispatch({
30
- type: LiveChatWidgetActionType.SET_RECONNECT_ID,
31
- payload: reconnectId
32
- });
33
- dispatch({
34
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
35
- payload: ConversationState.ReconnectChat
36
- });
37
- } else if (showPrechat) {
38
- dispatch({
39
- type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
40
- payload: preChatSurveyResponse
41
- });
42
- dispatch({
43
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
44
- payload: ConversationState.Prechat
45
- });
28
+ await handleRedirectUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
46
29
  } else {
47
- dispatch({
48
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
49
- payload: ConversationState.Loading
50
- });
51
- await initStartChat(chatSDK, dispatch, setAdapter);
30
+ // Getting PreChat Survey Context
31
+ const parseToJson = false;
32
+ const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
33
+ const showPrechat = state.appStates.conversationState === ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
34
+
35
+ const reconnectId = await getReconnectIdForAuthenticatedChat(props, chatSDK);
36
+
37
+ if (reconnectId) {
38
+ dispatch({
39
+ type: LiveChatWidgetActionType.SET_RECONNECT_ID,
40
+ payload: reconnectId
41
+ });
42
+ dispatch({
43
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
44
+ payload: ConversationState.ReconnectChat
45
+ });
46
+ } else if (showPrechat) {
47
+ dispatch({
48
+ type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
49
+ payload: preChatSurveyResponse
50
+ });
51
+ dispatch({
52
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
53
+ payload: ConversationState.Prechat
54
+ });
55
+ } else {
56
+ dispatch({
57
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
58
+ payload: ConversationState.Loading
59
+ });
60
+ await initStartChat(chatSDK, dispatch, setAdapter);
61
+ }
52
62
  }
53
63
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
64
 
55
65
 
56
66
  const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
57
67
  try {
58
- var _TelemetryTimers$Widg;
68
+ var _newAdapter$activity$, _TelemetryTimers$Widg;
59
69
 
60
70
  try {
61
71
  TelemetryTimers.WidgetLoadTimer = createTimer();
62
- TelemetryHelper.logConfigDataEvent(LogLevel.INFO, {
72
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
63
73
  Event: TelemetryEvent.StartChatSDKCall
64
74
  });
65
75
  await chatSDK.startChat(params);
66
76
  } catch (error) {
67
- TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
77
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
68
78
  Event: TelemetryEvent.StartChatMethodException,
69
79
  ExceptionDetails: {
70
80
  exception: `Failed to setup startChat: ${error}`
@@ -74,6 +84,8 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
74
84
 
75
85
  const newAdapter = await createAdapter(chatSDK);
76
86
  setAdapter(newAdapter);
87
+ const chatToken = await chatSDK.getChatToken();
88
+ newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe(createOnNewAdapterActivityHandler(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
77
89
 
78
90
  if (!persistedState) {
79
91
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -114,9 +126,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
114
126
  });
115
127
  } catch (ex) {
116
128
  TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
117
- Event: TelemetryEvent.StartChatFailed,
129
+ Event: TelemetryEvent.WidgetLoadFailed,
118
130
  ExceptionDetails: {
119
- Exception: `Start Chat Failed: ${ex}`
131
+ Exception: `Widget load Failed: ${ex}`
120
132
  }
121
133
  });
122
134
  NotificationHandler.notifyError(NotificationScenarios.Connection, "Start Chat Failed: " + ex); // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -2,14 +2,14 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
2
2
  import { ConversationState } from "../../../contexts/common/ConversationState";
3
3
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
4
4
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
5
- import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager"; // Defines startProactiveChat callback
6
-
7
- export const startProactiveChat = (dispatch, bodyTitle, showPrechat, inNewWindow) => {
5
+ import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
6
+ // Defines startProactiveChat callback
7
+ export const startProactiveChat = (dispatch, notificationConfig, enablePreChat, inNewWindow) => {
8
8
  dispatch({
9
9
  type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
10
10
  payload: {
11
- proactiveChatBodyTitle: bodyTitle ?? "",
12
- proactiveChatEnablePrechat: showPrechat ?? false,
11
+ proactiveChatBodyTitle: notificationConfig && notificationConfig.message ? notificationConfig.message : "",
12
+ proactiveChatEnablePrechat: enablePreChat ?? false,
13
13
  proactiveChatInNewWindow: inNewWindow ?? false
14
14
  }
15
15
  });