@microsoft/omnichannel-chat-widget 0.1.0-main.3d1c026 → 0.1.0-main.63cfb47

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 (139) 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 +6 -2
  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 +37 -4
  8. package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
  9. package/lib/cjs/common/telemetry/TelemetryManager.js +11 -6
  10. package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  11. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -54
  12. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
  13. package/lib/cjs/components/footerstateful/FooterStateful.js +4 -5
  14. package/lib/cjs/components/headerstateful/HeaderStateful.js +11 -8
  15. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -4
  16. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +16 -9
  17. package/lib/cjs/components/livechatwidget/common/endChat.js +102 -54
  18. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +5 -0
  19. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +27 -12
  20. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +105 -20
  21. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +23 -5
  22. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +26 -24
  23. package/lib/cjs/components/livechatwidget/common/startChat.js +113 -54
  24. package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -3
  25. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +91 -30
  26. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
  27. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +8 -0
  28. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
  29. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +28 -11
  30. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +10 -4
  31. package/lib/cjs/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  32. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
  33. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +51 -73
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +9 -46
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +44 -0
  38. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  39. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +15 -14
  40. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -2
  41. package/lib/cjs/contexts/createReducer.js +13 -10
  42. package/lib/cjs/controller/componentController.js +2 -2
  43. package/lib/cjs/plugins/newMessageEventHandler.js +102 -0
  44. package/lib/esm/assets/Audios.js +1 -0
  45. package/lib/esm/assets/Icons.js +11 -0
  46. package/lib/esm/common/Constants.js +6 -2
  47. package/lib/esm/common/contextDataStore/DataStoreManager.js +5 -0
  48. package/lib/esm/common/interfaces/IContextDataStore.js +1 -0
  49. package/lib/esm/common/telemetry/TelemetryConstants.js +33 -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/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -50
  54. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
  55. package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
  56. package/lib/esm/components/headerstateful/HeaderStateful.js +12 -9
  57. package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -3
  58. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -10
  59. package/lib/esm/components/livechatwidget/common/endChat.js +100 -51
  60. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -0
  61. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +23 -12
  62. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +94 -20
  63. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +20 -4
  64. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +23 -22
  65. package/lib/esm/components/livechatwidget/common/startChat.js +108 -51
  66. package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
  67. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +85 -29
  68. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
  69. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +6 -0
  70. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
  71. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +26 -10
  72. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +9 -5
  73. package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  74. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
  75. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -12
  76. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -44
  77. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  78. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  79. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +31 -0
  80. package/lib/esm/contexts/common/ConversationState.js +3 -2
  81. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +15 -14
  82. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -2
  83. package/lib/esm/contexts/createReducer.js +13 -9
  84. package/lib/esm/controller/componentController.js +2 -2
  85. package/lib/esm/plugins/newMessageEventHandler.js +84 -0
  86. package/lib/types/assets/Audios.d.ts +1 -0
  87. package/lib/types/assets/Icons.d.ts +11 -0
  88. package/lib/types/common/Constants.d.ts +3 -1
  89. package/lib/types/common/contextDataStore/DataStoreManager.d.ts +4 -0
  90. package/lib/types/common/interfaces/IContextDataStore.d.ts +14 -0
  91. package/lib/types/common/telemetry/TelemetryConstants.d.ts +23 -1
  92. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
  93. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +5 -2
  94. package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
  95. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +4 -1
  96. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  97. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -2
  98. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
  99. package/lib/types/components/livechatwidget/common/startChat.d.ts +1 -1
  100. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
  101. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  102. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
  103. package/lib/types/components/prechatsurveypanestateful/interfaces/IPreChatSurveyPaneStatefulParams.d.ts +1 -1
  104. package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
  105. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -0
  106. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  107. package/lib/types/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.d.ts +1 -1
  108. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
  109. package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
  110. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  111. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  112. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +15 -14
  113. package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
  114. package/package.json +7 -6
  115. package/lib/cjs/assets/audios/newMessageNotification.mp3 +0 -0
  116. package/lib/cjs/assets/icons/archiveIcon.svg +0 -3
  117. package/lib/cjs/assets/icons/audioIcon.svg +0 -6
  118. package/lib/cjs/assets/icons/blankIcon.svg +0 -6
  119. package/lib/cjs/assets/icons/excelIcon.svg +0 -6
  120. package/lib/cjs/assets/icons/imageIcon.svg +0 -6
  121. package/lib/cjs/assets/icons/oneNoteIcon.svg +0 -6
  122. package/lib/cjs/assets/icons/pdfIcon.svg +0 -6
  123. package/lib/cjs/assets/icons/powerpointIcon.svg +0 -6
  124. package/lib/cjs/assets/icons/videoIcon.svg +0 -6
  125. package/lib/cjs/assets/icons/visioIcon.svg +0 -6
  126. package/lib/cjs/assets/icons/wordIcon.svg +0 -6
  127. package/lib/esm/assets/assets.d.js +0 -0
  128. package/lib/esm/assets/audios/newMessageNotification.mp3 +0 -0
  129. package/lib/esm/assets/icons/archiveIcon.svg +0 -3
  130. package/lib/esm/assets/icons/audioIcon.svg +0 -6
  131. package/lib/esm/assets/icons/blankIcon.svg +0 -6
  132. package/lib/esm/assets/icons/excelIcon.svg +0 -6
  133. package/lib/esm/assets/icons/imageIcon.svg +0 -6
  134. package/lib/esm/assets/icons/oneNoteIcon.svg +0 -6
  135. package/lib/esm/assets/icons/pdfIcon.svg +0 -6
  136. package/lib/esm/assets/icons/powerpointIcon.svg +0 -6
  137. package/lib/esm/assets/icons/videoIcon.svg +0 -6
  138. package/lib/esm/assets/icons/visioIcon.svg +0 -6
  139. package/lib/esm/assets/icons/wordIcon.svg +0 -6
@@ -1,65 +1,80 @@
1
+ import { ChatSDKError, Constants } from "../../../common/Constants";
1
2
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
- import { ChatSDKError } from "../../../common/Constants";
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 { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ import { getReconnectIdForAuthenticatedChat, handleRedirectUnauthenticatedReconnectChat } from "./reconnectChatHelper";
14
+ import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
15
+ import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
16
 
15
17
  const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
16
- // Getting PreChat Survey Context
17
- const parseToJson = false;
18
- const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
19
- const showPrechat = state.appStates.conversationState === ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
18
+ var _props$reconnectChatP;
20
19
 
21
- const reconnectId = await getReconnectIdForAuthenticatedChat(props, chatSDK);
20
+ if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
21
+ return;
22
+ } // Redirecting if unauthenticated reconnect chat expired
22
23
 
23
- if (reconnectId) {
24
- dispatch({
25
- type: LiveChatWidgetActionType.SET_RECONNECT_ID,
26
- payload: reconnectId
27
- });
28
- dispatch({
29
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
30
- payload: ConversationState.ReconnectChat
31
- });
32
- } else if (showPrechat) {
33
- dispatch({
34
- type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
35
- payload: preChatSurveyResponse
36
- });
37
- dispatch({
38
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
39
- payload: ConversationState.Prechat
40
- });
24
+
25
+ if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
26
+ var _props$reconnectChatP2, _props$reconnectChatP3;
27
+
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);
41
29
  } else {
42
- dispatch({
43
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
44
- payload: ConversationState.Loading
45
- });
46
- 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
+ }
47
62
  }
48
63
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
64
 
50
65
 
51
- const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
66
+ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
52
67
  try {
53
- var _TelemetryTimers$Widg;
68
+ var _newAdapter$activity$, _TelemetryTimers$Widg;
54
69
 
55
70
  try {
56
- TelemetryHelper.logConfigDataEvent(LogLevel.INFO, {
71
+ TelemetryTimers.WidgetLoadTimer = createTimer();
72
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
57
73
  Event: TelemetryEvent.StartChatSDKCall
58
74
  });
59
75
  await chatSDK.startChat(params);
60
- TelemetryTimers.WidgetLoadTimer = createTimer();
61
76
  } catch (error) {
62
- TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
77
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
63
78
  Event: TelemetryEvent.StartChatMethodException,
64
79
  ExceptionDetails: {
65
80
  exception: `Failed to setup startChat: ${error}`
@@ -68,24 +83,42 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
68
83
  }
69
84
 
70
85
  const newAdapter = await createAdapter(chatSDK);
71
- setAdapter(newAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
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));
72
89
 
73
- if (chatSDK !== null && chatSDK !== void 0 && chatSDK.getVoiceVideoCalling) {
90
+ if (!persistedState) {
74
91
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
- const chatToken = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatToken());
92
+ if (chatSDK !== null && chatSDK !== void 0 && chatSDK.getVoiceVideoCalling) {
93
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
+ const chatToken = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatToken());
95
+ dispatch({
96
+ type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
97
+ payload: chatToken
98
+ });
99
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
+
101
+
102
+ const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
76
103
  dispatch({
77
- type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
78
- payload: chatToken
104
+ type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
105
+ payload: liveChatContext
79
106
  });
80
- }
107
+ await setPostChatContextAndLoadSurvey(chatSDK, dispatch);
108
+ await updateSessionDataForTelemetry(chatSDK, dispatch); // Set app state to Active
81
109
 
82
- await setPostChatContextAndLoadSurvey(chatSDK, dispatch, false);
83
- await updateSessionDataForTelemetry(chatSDK, dispatch); // Set app state to Active
110
+ dispatch({
111
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
112
+ payload: ConversationState.Active
113
+ });
114
+ } else {
115
+ dispatch({
116
+ type: LiveChatWidgetActionType.SET_WIDGET_STATE,
117
+ payload: persistedState
118
+ });
119
+ await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
120
+ }
84
121
 
85
- dispatch({
86
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
87
- payload: ConversationState.Active
88
- });
89
122
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
90
123
  Event: TelemetryEvent.WidgetLoadComplete,
91
124
  Description: "Widget load complete",
@@ -93,9 +126,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
93
126
  });
94
127
  } catch (ex) {
95
128
  TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
96
- Event: TelemetryEvent.StartChatFailed,
129
+ Event: TelemetryEvent.WidgetLoadFailed,
97
130
  ExceptionDetails: {
98
- Exception: `Start Chat Failed: ${ex}`
131
+ Exception: `Widget load Failed: ${ex}`
99
132
  }
100
133
  });
101
134
  NotificationHandler.notifyError(NotificationScenarios.Connection, "Start Chat Failed: " + ex); // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -111,6 +144,30 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
111
144
  });
112
145
  }
113
146
  }
147
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
+
149
+
150
+ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
151
+ var _DataStoreManager$cli, _persistedState$domai;
152
+
153
+ const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(Constants.widgetStateDataKey, "localStorage");
154
+ const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
155
+
156
+ if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext) {
157
+ var _persistedState$domai2;
158
+
159
+ dispatch({
160
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
161
+ payload: ConversationState.Loading
162
+ });
163
+ const optionalParams = {
164
+ liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai2 = persistedState.domainStates) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.liveChatContext
165
+ };
166
+ await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
167
+ return true;
168
+ } else {
169
+ return false;
170
+ }
114
171
  };
115
172
 
116
173
  export { prepareStartChat, initStartChat };
@@ -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
  });
@@ -1,10 +1,11 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
4
  import { BroadcastService, decodeComponentString } from "@microsoft/omnichannel-chat-components";
4
5
  import { Stack } from "@fluentui/react";
5
6
  import React, { useEffect, useRef, useState } from "react";
6
7
  import { createTimer, getLocaleDirection } from "../../../common/utils";
7
- import { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat } from "../common/reconnectChatHelper";
8
+ import { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat } from "../common/reconnectChatHelper";
8
9
  import { initStartChat, prepareStartChat } from "../common/startChat";
9
10
  import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
10
11
  import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
@@ -12,6 +13,7 @@ import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
12
13
  import { Components } from "botframework-webchat";
13
14
  import ConfirmationPaneStateful from "../../confirmationpanestateful/ConfirmationPaneStateful";
14
15
  import { ConversationState } from "../../../contexts/common/ConversationState";
16
+ import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
15
17
  import { ElementType } from "@microsoft/omnichannel-chat-components";
16
18
  import EmailTranscriptPaneStateful from "../../emailtranscriptpanestateful/EmailTranscriptPaneStateful";
17
19
  import HeaderStateful from "../../headerstateful/HeaderStateful";
@@ -23,12 +25,14 @@ import PostChatSurveyPaneStateful from "../../postchatsurveypanestateful/PostCha
23
25
  import PreChatSurveyPaneStateful from "../../prechatsurveypanestateful/PreChatSurveyPaneStateful";
24
26
  import ProactiveChatPaneStateful from "../../proactivechatpanestateful/ProactiveChatPaneStateful";
25
27
  import ReconnectChatPaneStateful from "../../reconnectchatpanestateful/ReconnectChatPaneStateful";
28
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
26
29
  import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
27
30
  import WebChatContainerStateful from "../../webchatcontainerstateful/WebChatContainerStateful";
28
31
  import { createFooter } from "../common/createFooter";
29
32
  import { createInternetConnectionChangeHandler } from "../common/createInternetConnectionChangeHandler";
30
33
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
31
- import { endChat } from "../common/endChat";
34
+ import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
35
+ import { endChat, prepareEndChat } from "../common/endChat";
32
36
  import { getGeneralStylesForButton } from "../common/getGeneralStylesForButton";
33
37
  import { initCallingSdk } from "../common/initCallingSdk";
34
38
  import { initConfirmationPropsComposer } from "../common/initConfirmationPropsComposer";
@@ -39,10 +43,8 @@ import { startProactiveChat } from "../common/startProactiveChat";
39
43
  import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
40
44
  import useChatContextStore from "../../../hooks/useChatContextStore";
41
45
  import useChatSDKStore from "../../../hooks/useChatSDKStore";
42
- import { TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
43
- import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
44
46
  export const LiveChatWidgetStateful = props => {
45
- var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$controlProps6, _props$componentOverr2, _props$controlProps7, _props$componentOverr3, _props$controlProps8, _props$componentOverr4, _props$controlProps9, _props$componentOverr5, _props$controlProps10, _props$componentOverr6, _props$controlProps11, _props$controlProps12, _props$controlProps13, _props$componentOverr7, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$componentOverr10, _props$componentOverr11;
47
+ var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$controlProps6, _props$componentOverr2, _props$controlProps7, _props$componentOverr3, _props$controlProps8, _props$componentOverr4, _props$controlProps9, _props$componentOverr5, _props$controlProps10, _props$componentOverr6, _props$controlProps11, _props$componentOverr7, _props$controlProps12, _props$controlProps13, _props$componentOverr8, _props$controlProps14, _props$componentOverr9, _props$controlProps15, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
46
48
 
47
49
  const [state, dispatch] = useChatContextStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
50
 
@@ -56,7 +58,8 @@ export const LiveChatWidgetStateful = props => {
56
58
  const {
57
59
  Composer
58
60
  } = Components;
59
- const canStartProactiveChat = useRef(true); // Process general styles
61
+ const canStartProactiveChat = useRef(true);
62
+ const canEndChat = useRef(true); // Process general styles
60
63
 
61
64
  const generalStyles = {
62
65
  root: Object.assign({}, getGeneralStylesForButton(state), (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyles)
@@ -69,6 +72,7 @@ export const LiveChatWidgetStateful = props => {
69
72
 
70
73
  registerTelemetryLoggers(props, dispatch);
71
74
  createInternetConnectionChangeHandler();
75
+ DataStoreManager.clientDataStore = props.contextDataStore ?? undefined;
72
76
  dispatch({
73
77
  type: LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
74
78
  payload: widgetElementId
@@ -87,7 +91,7 @@ export const LiveChatWidgetStateful = props => {
87
91
  if (!((_props$controlProps3 = props.controlProps) !== null && _props$controlProps3 !== void 0 && _props$controlProps3.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
88
92
  var _props$reconnectChatP2;
89
93
 
90
- handleUnauthenticatedReconnectChat(dispatch, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
94
+ startUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
91
95
  } // Initialize global dir
92
96
 
93
97
 
@@ -113,9 +117,9 @@ export const LiveChatWidgetStateful = props => {
113
117
  var _props$reconnectChatP3;
114
118
 
115
119
  if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
116
- var _props$reconnectChatP4;
120
+ var _props$reconnectChatP4, _props$reconnectChatP5;
117
121
 
118
- handleUnauthenticatedReconnectChat(dispatch, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, initStartChat);
122
+ handleUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
119
123
  } else {
120
124
  getReconnectIdForAuthenticatedChat(props, chatSDK).then(authReconnectId => {
121
125
  if (authReconnectId && !state.appStates.reconnectId) {
@@ -128,6 +132,10 @@ export const LiveChatWidgetStateful = props => {
128
132
  payload: ConversationState.ReconnectChat
129
133
  });
130
134
  } else {
135
+ const chatStartedSkippingChatButtonRendering = {
136
+ eventName: BroadcastEvent.StartChatSkippingChatButtonRendering
137
+ };
138
+ BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
131
139
  dispatch({
132
140
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
133
141
  payload: ConversationState.Loading
@@ -140,13 +148,54 @@ export const LiveChatWidgetStateful = props => {
140
148
  }, [state.appStates.skipChatButtonRendering]);
141
149
  useEffect(() => {
142
150
  BroadcastService.getMessageByEventName("StartProactiveChat").subscribe(msg => {
151
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
152
+ Event: TelemetryEvent.StartProactiveChatEventReceived,
153
+ Description: "Start proactive chat event received."
154
+ });
155
+
143
156
  if (canStartProactiveChat.current) {
144
157
  var _msg$payload, _msg$payload2, _msg$payload3;
145
158
 
146
- startProactiveChat(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.bodyTitle, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.showPrechat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
159
+ startProactiveChat(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.notificationConfig, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.enablePreChat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
160
+ } else {
161
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
162
+ Event: TelemetryEvent.ChatAlreadyTriggered,
163
+ Description: "Start proactive chat method called, when chat was already triggered."
164
+ });
165
+ }
166
+ }); // start chat from SDK Event
167
+
168
+ BroadcastService.getMessageByEventName("StartChat").subscribe(() => {
169
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
170
+ Event: TelemetryEvent.StartChatEventRecevied,
171
+ Description: "Start chat event received."
172
+ });
173
+
174
+ if (state.appStates.isMinimized) {
175
+ dispatch({
176
+ type: LiveChatWidgetActionType.SET_MINIMIZED,
177
+ payload: false
178
+ });
179
+ } else {
180
+ prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
181
+ }
182
+ }); // end chat from SDK Event
183
+
184
+ BroadcastService.getMessageByEventName("EndChat").subscribe(async () => {
185
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
186
+ Event: TelemetryEvent.EndChatEventReceived,
187
+ Description: "End chat event received."
188
+ });
189
+
190
+ if (canEndChat.current) {
191
+ prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
192
+ } else {
193
+ const skipEndChatSDK = true;
194
+ const skipCloseChat = false;
195
+ endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
147
196
  }
148
197
  });
149
- window.addEventListener("beforeunload", event => {
198
+ window.addEventListener("beforeunload", () => {
150
199
  disposeTelemetryLoggers();
151
200
  });
152
201
 
@@ -156,17 +205,18 @@ export const LiveChatWidgetStateful = props => {
156
205
  }, []);
157
206
  useEffect(() => {
158
207
  canStartProactiveChat.current = state.appStates.conversationState === ConversationState.Closed;
208
+ canEndChat.current = state.appStates.conversationState === ConversationState.Active;
159
209
 
160
210
  if (state.appStates.conversationState === ConversationState.Active) {
161
211
  chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
162
212
  BroadcastService.postMessage({
163
- eventName: "NewMessageNotification"
213
+ eventName: BroadcastEvent.NewMessageNotification
164
214
  });
165
215
  });
166
216
  } // Track the message count
167
217
 
168
218
 
169
- if (state.appStates.conversationState == ConversationState.Active) {
219
+ if (state.appStates.conversationState === ConversationState.Active) {
170
220
  chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
171
221
  currentMessageCountRef.current++;
172
222
  dispatch({
@@ -185,7 +235,7 @@ export const LiveChatWidgetStateful = props => {
185
235
  });
186
236
  const customEvent = {
187
237
  elementType: ElementType.Custom,
188
- eventName: "UnreadMessageCount",
238
+ eventName: BroadcastEvent.UnreadMessageCount,
189
239
  payload: 0
190
240
  };
191
241
  BroadcastService.postMessage(customEvent);
@@ -195,7 +245,7 @@ export const LiveChatWidgetStateful = props => {
195
245
  if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
196
246
  const customEvent = {
197
247
  elementType: ElementType.Custom,
198
- eventName: "UnreadMessageCount",
248
+ eventName: BroadcastEvent.UnreadMessageCount,
199
249
  payload: `${state.appStates.unreadMessageCount}`
200
250
  };
201
251
  BroadcastService.postMessage(customEvent);
@@ -210,23 +260,29 @@ export const LiveChatWidgetStateful = props => {
210
260
  }, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]);
211
261
  const webChatProps = initWebChatComposer(props, chatSDK, state, dispatch, setWebChatStyles);
212
262
 
213
- const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
263
+ const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
264
+
265
+
266
+ const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat) => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat); // eslint-disable-next-line @typescript-eslint/no-explicit-any
214
267
 
215
- const endChatRelay = () => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
268
+
269
+ const prepareEndChatRelay = (adapter, state) => prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
216
270
 
217
271
  const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
218
272
 
219
273
 
220
- const initStartChatRelay = optionalParams => initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
274
+ const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
221
275
 
222
276
  const confirmationPaneProps = initConfirmationPropsComposer(props); // publish chat widget state
223
277
 
224
- const chatWidgetStateChangeEvent = {
225
- eventName: TelemetryEvent.ChatWidgetStateChanged,
226
- payload: { ...state
227
- }
228
- };
229
- BroadcastService.postMessage(chatWidgetStateChangeEvent);
278
+ useEffect(() => {
279
+ const chatWidgetStateChangeEvent = {
280
+ eventName: BroadcastEvent.ChatWidgetStateChanged,
281
+ payload: { ...state
282
+ }
283
+ };
284
+ BroadcastService.postMessage(chatWidgetStateChangeEvent);
285
+ }, [state]);
230
286
  return /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
231
287
  styleOptions: webChatStyles,
232
288
  directLine: ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.directLine) ?? adapter ?? defaultWebChatContainerStatefulProps.directLine
@@ -248,14 +304,14 @@ export const LiveChatWidgetStateful = props => {
248
304
  })), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, props.loadingPaneProps)), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, props.outOfOfficeHoursPaneProps)), !((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
249
305
  reconnectChatProps: props.reconnectChatPaneProps,
250
306
  initStartChat: initStartChatRelay
251
- })), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
307
+ })), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
252
308
  surveyProps: props.preChatSurveyPaneProps,
253
309
  initStartChat: initStartChatRelay
254
- }), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
310
+ })), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
255
311
  voiceVideoCallingSdk: voiceVideoCallingSDK
256
- }, props.callingContainerProps)), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
312
+ }, props.callingContainerProps)), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
257
313
  setPostChatContext: setPostChatContextRelay,
258
- endChat: endChatRelay
259
- }))), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane))));
314
+ prepareEndChat: prepareEndChatRelay
315
+ }))), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane))));
260
316
  };
261
317
  export default LiveChatWidgetStateful;
@@ -26,7 +26,7 @@ export const LoadingPaneStateful = props => {
26
26
  firstElement[0].focus();
27
27
  }
28
28
 
29
- TelemetryHelper.logActionEvent(LogLevel.INFO, {
29
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
30
30
  Event: TelemetryEvent.LoadingPaneLoaded,
31
31
  Description: "Loading pane loaded."
32
32
  });
@@ -1,5 +1,7 @@
1
+ import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
1
2
  import React, { useEffect } from "react";
2
3
  import { OutOfOfficeHoursPane } from "@microsoft/omnichannel-chat-components";
4
+ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
3
5
  import { defaultGeneralStyleProps } from "./common/defaultStyleProps/defaultgeneralOOOHPaneStyleProps";
4
6
  import { findAllFocusableElement } from "../../common/utils";
5
7
  import useChatContextStore from "../../hooks/useChatContextStore";
@@ -23,6 +25,10 @@ export const OutOfOfficeHoursPaneStateful = props => {
23
25
  if (firstElement && firstElement[0]) {
24
26
  firstElement[0].focus();
25
27
  }
28
+
29
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
30
+ Event: TelemetryEvent.OutOfOfficePaneLoaded
31
+ });
26
32
  }, []);
27
33
  return /*#__PURE__*/React.createElement(OutOfOfficeHoursPane, {
28
34
  componentOverrides: props.componentOverrides,
@@ -3,6 +3,8 @@ import { LoadingPane } from "@microsoft/omnichannel-chat-components";
3
3
  import { defaultGeneralPostChatLoadingPaneStyleProps } from "./common/defaultgeneralPostChatLoadingPaneStyleProps";
4
4
  import { findAllFocusableElement } from "../../common/utils";
5
5
  import useChatContextStore from "../../hooks/useChatContextStore";
6
+ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
7
+ import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
6
8
  export const PostChatLoadingPaneStateful = props => {
7
9
  var _props$styleProps;
8
10
 
@@ -28,6 +30,10 @@ export const PostChatLoadingPaneStateful = props => {
28
30
  if (firstElement && firstElement[0]) {
29
31
  firstElement[0].focus();
30
32
  }
33
+
34
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
35
+ Event: TelemetryEvent.PostChatSurveyLoadingPaneLoaded
36
+ });
31
37
  }, []);
32
38
  return /*#__PURE__*/React.createElement(LoadingPane, {
33
39
  componentOverrides: props.componentOverrides,
@@ -1,10 +1,11 @@
1
+ import { Constants, HtmlAttributeNames, Regex } from "../../common/Constants";
1
2
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
3
  import React, { useEffect } from "react";
3
4
  import { extractPreChatSurveyResponseValues, findAllFocusableElement, parseAdaptiveCardPayload } from "../../common/utils";
4
5
  import { ConversationState } from "../../contexts/common/ConversationState";
6
+ import { DataStoreManager } from "../../common/contextDataStore/DataStoreManager";
5
7
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
6
8
  import { PreChatSurveyPane } from "@microsoft/omnichannel-chat-components";
7
- import { HtmlAttributeNames, Regex } from "../../common/Constants";
8
9
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
9
10
  import { defaultGeneralPreChatSurveyPaneStyleProps } from "./common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps";
10
11
  import { defaultPreChatSurveyLocalizedTexts } from "./common/defaultProps/defaultPreChatSurveyLocalizedTexts";
@@ -39,7 +40,7 @@ export const PreChatSurveyPaneStateful = props => {
39
40
  try {
40
41
  return parseAdaptiveCardPayload(payload, requiredFieldMissingMessage);
41
42
  } catch (ex) {
42
- TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
43
+ TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
43
44
  Event: TelemetryEvent.ParseAdaptiveCardFailed,
44
45
  Description: "Adaptive Card JSON Parse Failed.",
45
46
  ExceptionDetails: {
@@ -66,14 +67,29 @@ export const PreChatSurveyPaneStateful = props => {
66
67
  });
67
68
 
68
69
  try {
69
- const prechatResponseValues = extractPreChatSurveyResponseValues(state.domainStates.preChatSurveyResponse, values);
70
- const optionalParams = {
71
- initContext: {
72
- preChatResponse: prechatResponseValues
73
- }
74
- };
75
- setPreChatResponseEmail(values);
76
- await initStartChat(optionalParams);
70
+ var _DataStoreManager$cli, _persistedState$domai;
71
+
72
+ const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(Constants.widgetStateDataKey, "localStorage");
73
+ const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
74
+ let optionalParams = {};
75
+
76
+ if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext) {
77
+ var _persistedState$domai2;
78
+
79
+ optionalParams = {
80
+ liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai2 = persistedState.domainStates) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.liveChatContext
81
+ };
82
+ await initStartChat(optionalParams, persistedState);
83
+ } else {
84
+ const prechatResponseValues = extractPreChatSurveyResponseValues(state.domainStates.preChatSurveyResponse, values);
85
+ optionalParams = {
86
+ initContext: {
87
+ preChatResponse: prechatResponseValues
88
+ }
89
+ };
90
+ setPreChatResponseEmail(values);
91
+ await initStartChat(optionalParams);
92
+ }
77
93
  } catch (ex) {
78
94
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
79
95
  Event: TelemetryEvent.PreChatSurveyStartChatMethodFailed,