@microsoft/omnichannel-chat-widget 0.1.0-main.9e62ed8 → 0.1.0-main.a60f242

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 (47) hide show
  1. package/lib/cjs/common/Constants.js +2 -0
  2. package/lib/cjs/common/telemetry/TelemetryConstants.js +4 -0
  3. package/lib/cjs/common/utils.js +48 -2
  4. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
  5. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  6. package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -2
  7. package/lib/cjs/components/livechatwidget/common/endChat.js +49 -17
  8. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +9 -0
  9. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  10. package/lib/cjs/components/livechatwidget/common/startChat.js +115 -80
  11. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +89 -99
  12. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
  13. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
  14. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  15. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +0 -1
  16. package/lib/cjs/controller/componentController.js +2 -2
  17. package/lib/esm/common/Constants.js +2 -0
  18. package/lib/esm/common/telemetry/TelemetryConstants.js +4 -0
  19. package/lib/esm/common/utils.js +36 -0
  20. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -0
  21. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  22. package/lib/esm/components/headerstateful/HeaderStateful.js +2 -2
  23. package/lib/esm/components/livechatwidget/common/endChat.js +50 -18
  24. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +10 -2
  25. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  26. package/lib/esm/components/livechatwidget/common/startChat.js +114 -80
  27. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +89 -97
  28. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
  29. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -1
  30. package/lib/esm/contexts/common/ConversationState.js +3 -2
  31. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +0 -1
  32. package/lib/esm/controller/componentController.js +2 -2
  33. package/lib/types/common/Constants.d.ts +1 -0
  34. package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -1
  35. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -1
  36. package/lib/types/common/utils.d.ts +3 -0
  37. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
  38. package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
  39. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
  40. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
  41. package/lib/types/components/livechatwidget/common/startChat.d.ts +2 -1
  42. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
  43. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
  44. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
  45. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  46. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +0 -1
  47. package/package.json +1 -1
@@ -1,12 +1,12 @@
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); }
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
3
  import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
4
4
  import { BroadcastService, decodeComponentString } from "@microsoft/omnichannel-chat-components";
5
5
  import { Stack } from "@fluentui/react";
6
6
  import React, { useEffect, useRef, useState } from "react";
7
- import { createTimer, getLocaleDirection, getWidgetCacheId, getWidgetEndChatEventName } from "../../../common/utils";
7
+ import { createTimer, getLocaleDirection, getStateFromCache, getWidgetCacheId, getWidgetEndChatEventName, isUndefinedOrEmpty } from "../../../common/utils";
8
8
  import { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat } from "../common/reconnectChatHelper";
9
- import { initStartChat, prepareStartChat } from "../common/startChat";
9
+ import { initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
10
10
  import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
11
11
  import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
12
12
  import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
@@ -44,7 +44,7 @@ import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
44
44
  import useChatContextStore from "../../../hooks/useChatContextStore";
45
45
  import useChatSDKStore from "../../../hooks/useChatSDKStore";
46
46
  export const LiveChatWidgetStateful = props => {
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;
47
+ var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$controlProps6, _props$componentOverr, _props$controlProps7, _props$componentOverr2, _props$controlProps8, _props$componentOverr3, _props$controlProps9, _props$componentOverr4, _props$controlProps10, _props$componentOverr5, _props$controlProps11, _props$componentOverr6, _props$controlProps12, _props$componentOverr7, _props$controlProps13, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$controlProps16, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
48
48
 
49
49
  const [state, dispatch] = useChatContextStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
50
 
@@ -59,8 +59,7 @@ export const LiveChatWidgetStateful = props => {
59
59
  const {
60
60
  Composer
61
61
  } = Components;
62
- const canStartProactiveChat = useRef(true);
63
- const canEndChat = useRef(true); // Process general styles
62
+ const canStartProactiveChat = useRef(true); // Process general styles
64
63
 
65
64
  const generalStyles = {
66
65
  root: Object.assign({}, getGeneralStylesForButton(state), (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyles)
@@ -71,9 +70,13 @@ export const LiveChatWidgetStateful = props => {
71
70
  let widgetStateEventName = "";
72
71
 
73
72
  const initiateEndChatOnBrowserUnload = () => {
74
- var _DataStoreManager$cli;
73
+ var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli;
75
74
 
76
- const persistedState = getStateFromCache(); // End chat if the chat is still active and browser closed
75
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
76
+ Event: TelemetryEvent.BrowserUnloadEventStarted,
77
+ Description: "Browser unload event received."
78
+ });
79
+ const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId); // End chat if the chat is still active and browser closed
77
80
 
78
81
  if (persistedState.appStates.conversationState === ConversationState.Active) {
79
82
  //Browser close scenario/no room for PCS/so just end chat and notify agent immidiately
@@ -81,25 +84,20 @@ export const LiveChatWidgetStateful = props => {
81
84
  } // Clean local storage
82
85
 
83
86
 
84
- (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage");
85
- BroadcastService.postMessage({
86
- eventName: BroadcastEvent.ChatEnded
87
- });
88
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
+ (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage"); //Dispose calling instance
89
88
 
89
+ if (voiceVideoCallingSDK) {
90
+ voiceVideoCallingSDK === null || voiceVideoCallingSDK === void 0 ? void 0 : voiceVideoCallingSDK.close();
91
+ } //Message for clearing window[popouTab]
90
92
 
91
- const getStateFromCache = () => {
92
- var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli2;
93
93
 
94
- // Getting updated state from cache
95
- const widgetStateEventName = getWidgetCacheId((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId) ?? "");
96
- const widgetStateFromCache = (_DataStoreManager$cli2 = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli2 === void 0 ? void 0 : _DataStoreManager$cli2.getData(widgetStateEventName, "localStorage");
97
- const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
98
- return persistedState;
94
+ BroadcastService.postMessage({
95
+ eventName: BroadcastEvent.ClosePopoutWindow
96
+ });
99
97
  };
100
98
 
101
99
  useEffect(() => {
102
- var _props$controlProps2, _props$controlProps3, _props$reconnectChatP, _props$controlProps4, _props$chatConfig, _props$chatConfig$Cha, _state$domainStates;
100
+ var _props$controlProps2, _props$controlProps3, _props$chatConfig, _props$chatConfig$Cha, _props$controlProps4, _props$reconnectChatP, _props$chatConfig2, _props$chatConfig2$Li;
103
101
 
104
102
  registerTelemetryLoggers(props, dispatch);
105
103
  createInternetConnectionChangeHandler();
@@ -121,29 +119,44 @@ export const LiveChatWidgetStateful = props => {
121
119
  type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
122
120
  payload: true
123
121
  });
122
+ }); // Initialize global dir
123
+
124
+ const globalDir = ((_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.dir) ?? getLocaleDirection((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Cha = _props$chatConfig.ChatWidgetLanguage) === null || _props$chatConfig$Cha === void 0 ? void 0 : _props$chatConfig$Cha.msdyn_localeid);
125
+ dispatch({
126
+ type: LiveChatWidgetActionType.SET_GLOBAL_DIR,
127
+ payload: globalDir
124
128
  });
125
129
 
126
- 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) {
130
+ if (!((_props$controlProps4 = props.controlProps) !== null && _props$controlProps4 !== void 0 && _props$controlProps4.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
127
131
  var _props$reconnectChatP2;
128
132
 
129
133
  startUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
130
- } // Initialize global dir
134
+ return;
135
+ } // Check if auth settings enabled, do not connect to existing chat from cache during refresh/re-load
136
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
137
 
132
138
 
133
- const globalDir = ((_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.dir) ?? getLocaleDirection((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Cha = _props$chatConfig.ChatWidgetLanguage) === null || _props$chatConfig$Cha === void 0 ? void 0 : _props$chatConfig$Cha.msdyn_localeid);
134
- dispatch({
135
- type: LiveChatWidgetActionType.SET_GLOBAL_DIR,
136
- payload: globalDir
137
- });
139
+ const isAuthenticationSettingsEnabled = (_props$chatConfig2 = props.chatConfig) !== null && _props$chatConfig2 !== void 0 && (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) !== null && _props$chatConfig2$Li !== void 0 && _props$chatConfig2$Li.msdyn_javascriptclientfunction ? true : false;
138
140
 
139
- if ((_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.liveChatContext) {
140
- var _state$domainStates2;
141
+ if (!isAuthenticationSettingsEnabled) {
142
+ var _state$domainStates;
141
143
 
142
- const optionalParams = {
143
- liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
144
- };
145
- initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
146
- }
144
+ if (!isUndefinedOrEmpty((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && state.appStates.conversationState === ConversationState.Active) {
145
+ var _state$domainStates2;
146
+
147
+ const optionalParams = {
148
+ liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
149
+ };
150
+ initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
151
+ return;
152
+ }
153
+ } // All other case should show start chat button, skipChatButtonRendering will take care of it own
154
+
155
+
156
+ dispatch({
157
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
158
+ payload: ConversationState.Closed
159
+ });
147
160
  }, []); // useEffect for when skip chat button rendering
148
161
 
149
162
  useEffect(() => {
@@ -174,11 +187,7 @@ export const LiveChatWidgetStateful = props => {
174
187
  eventName: BroadcastEvent.StartChatSkippingChatButtonRendering
175
188
  };
176
189
  BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
177
- dispatch({
178
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
179
- payload: ConversationState.Loading
180
- });
181
- initStartChat(chatSDK, dispatch, setAdapter);
190
+ setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter);
182
191
  }
183
192
  });
184
193
  }
@@ -186,7 +195,7 @@ export const LiveChatWidgetStateful = props => {
186
195
  }, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
187
196
 
188
197
  useEffect(() => {
189
- var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
198
+ var _chatSDK$omnichannelC7, _chatSDK$omnichannelC8;
190
199
 
191
200
  // Add the custom context on receiving the SetCustomContext event
192
201
  BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
@@ -218,11 +227,13 @@ export const LiveChatWidgetStateful = props => {
218
227
  }); // Start chat from SDK Event
219
228
 
220
229
  BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(() => {
230
+ var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
231
+
221
232
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
222
233
  Event: TelemetryEvent.StartChatEventRecevied,
223
234
  Description: "Start chat event received."
224
235
  });
225
- const persistedState = getStateFromCache();
236
+ const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId);
226
237
 
227
238
  if (persistedState && (persistedState.appStates.conversationState === ConversationState.Closed || persistedState.appStates.conversationState === ConversationState.InActive || persistedState.appStates.conversationState === ConversationState.Postchat)) {
228
239
  // Embedded mode
@@ -230,12 +241,6 @@ export const LiveChatWidgetStateful = props => {
230
241
  eventName: BroadcastEvent.ChatInitiated
231
242
  });
232
243
  prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
233
- } else if (!persistedState) {
234
- // Popout chat
235
- BroadcastService.postMessage({
236
- eventName: BroadcastEvent.ChatInitiated
237
- });
238
- prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
239
244
  } else {
240
245
  var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
241
246
 
@@ -255,49 +260,38 @@ export const LiveChatWidgetStateful = props => {
255
260
  }); // End chat
256
261
 
257
262
  BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async () => {
258
- if (canEndChat.current) {
259
- prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
260
- } else {
261
- const skipEndChatSDK = true;
262
- const skipCloseChat = false;
263
- endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
263
+ if (state.appStates.skipChatButtonRendering !== true) {
264
+ var _chatSDK$omnichannelC5, _chatSDK$omnichannelC6;
265
+
266
+ // This is to ensure to get latest state from cache in multitab
267
+ const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.widgetId);
268
+
269
+ if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
270
+ prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
271
+ } else {
272
+ const skipEndChatSDK = true;
273
+ const skipCloseChat = false;
274
+ endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
275
+ }
264
276
  }
265
277
 
266
278
  BroadcastService.postMessage({
267
279
  eventName: BroadcastEvent.CloseChat
268
280
  });
269
- });
281
+ }); // End chat on browser unload
282
+
270
283
  BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
271
284
  initiateEndChatOnBrowserUnload();
272
- }); // reset proactive chat params
273
-
274
- BroadcastService.getMessageByEventName(BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
275
- dispatch({
276
- type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
277
- payload: {
278
- proactiveChatBodyTitle: "",
279
- proactiveChatEnablePrechat: false,
280
- proactiveChatInNewWindow: false
281
- }
282
- });
283
285
  }); // Listen to end chat event from other tabs
284
286
 
285
- const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId);
287
+ const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.widgetId);
286
288
  BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
287
289
  endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
288
- }); // Close popout window
289
-
290
- window.addEventListener("beforeunload", () => {
291
- TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
292
- Event: TelemetryEvent.WindowClosed,
293
- Description: "Closed window."
294
- });
295
- disposeTelemetryLoggers();
296
- });
290
+ }); // When conversation ended by agent
297
291
 
298
292
  if (state.appStates.conversationEndedByAgent) {
299
293
  endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
300
- } //Listen to WidgetSize
294
+ } //Listen to WidgetSize, used for minimize to maximize
301
295
 
302
296
 
303
297
  BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
@@ -306,25 +300,23 @@ export const LiveChatWidgetStateful = props => {
306
300
  payload: msg === null || msg === void 0 ? void 0 : msg.payload
307
301
  });
308
302
  });
303
+ return () => {
304
+ disposeTelemetryLoggers();
305
+ };
309
306
  }, []);
310
307
  useEffect(() => {
311
- canEndChat.current = state.appStates.conversationState === ConversationState.Active;
312
-
313
- if (state.appStates.conversationState === ConversationState.Active) {
314
- chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
315
- BroadcastService.postMessage({
316
- eventName: BroadcastEvent.NewMessageNotification
317
- });
318
- });
319
- } // Track the message count
320
-
321
-
308
+ // On new message
322
309
  if (state.appStates.conversationState === ConversationState.Active) {
323
310
  chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
311
+ // Track the message count
324
312
  currentMessageCountRef.current++;
325
313
  dispatch({
326
314
  type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
327
315
  payload: currentMessageCountRef.current + 1
316
+ }); // New message notification
317
+
318
+ BroadcastService.postMessage({
319
+ eventName: BroadcastEvent.NewMessageNotification
328
320
  });
329
321
  });
330
322
  }
@@ -348,7 +340,7 @@ export const LiveChatWidgetStateful = props => {
348
340
  }, [state.appStates.isMinimized]); // Broadcast the UnreadMessageCount state on any change.
349
341
 
350
342
  useEffect(() => {
351
- if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
343
+ if (state.appStates.isMinimized === true && state.appStates.unreadMessageCount > 0) {
352
344
  const customEvent = {
353
345
  elementType: ElementType.Custom,
354
346
  eventName: BroadcastEvent.UnreadMessageCount,
@@ -399,28 +391,28 @@ export const LiveChatWidgetStateful = props => {
399
391
  id: widgetElementId,
400
392
  styles: generalStyles,
401
393
  className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
402
- }, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
394
+ }, !((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.hideChatButton) && !((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.skipChatButtonRendering) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
403
395
  buttonProps: props.chatButtonProps,
404
396
  outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
405
397
  startChat: prepareStartChatRelay
406
- })), !((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.hideProactiveChatPane) && shouldShowProactiveChatPane(state) && (decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/React.createElement(ProactiveChatPaneStateful, {
398
+ })), !((_props$controlProps7 = props.controlProps) !== null && _props$controlProps7 !== void 0 && _props$controlProps7.hideProactiveChatPane) && shouldShowProactiveChatPane(state) && (decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/React.createElement(ProactiveChatPaneStateful, {
407
399
  proactiveChatProps: props.proactiveChatPaneProps,
408
400
  startChat: prepareStartChatRelay
409
- })), !((_props$controlProps7 = props.controlProps) !== null && _props$controlProps7 !== void 0 && _props$controlProps7.hideHeader) && shouldShowHeader(state) && (decodeComponentString((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/React.createElement(HeaderStateful, {
401
+ })), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.hideHeader) && shouldShowHeader(state) && (decodeComponentString((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/React.createElement(HeaderStateful, {
410
402
  headerProps: props.headerProps,
411
403
  outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
412
404
  endChat: endChatRelay
413
- })), !((_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, {
405
+ })), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.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$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.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$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
414
406
  reconnectChatProps: props.reconnectChatPaneProps,
415
407
  initStartChat: initStartChatRelay
416
- })), !((_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, {
408
+ })), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
417
409
  surveyProps: props.preChatSurveyPaneProps,
418
410
  initStartChat: initStartChatRelay
419
- })), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
411
+ })), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
420
412
  voiceVideoCallingSdk: voiceVideoCallingSDK
421
- }, 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, {
413
+ }, props.callingContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.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$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
422
414
  setPostChatContext: setPostChatContextRelay,
423
415
  prepareEndChat: prepareEndChatRelay
424
- }))), !((_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))));
416
+ }))), !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.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))));
425
417
  };
426
418
  export default LiveChatWidgetStateful;
@@ -1,9 +1,8 @@
1
1
  import { HtmlAttributeNames, Regex } from "../../common/Constants";
2
2
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
3
3
  import React, { useEffect } from "react";
4
- import { extractPreChatSurveyResponseValues, findAllFocusableElement, getWidgetCacheId, parseAdaptiveCardPayload } from "../../common/utils";
4
+ import { extractPreChatSurveyResponseValues, findAllFocusableElement, getStateFromCache, isUndefinedOrEmpty, parseAdaptiveCardPayload } from "../../common/utils";
5
5
  import { ConversationState } from "../../contexts/common/ConversationState";
6
- import { DataStoreManager } from "../../common/contextDataStore/DataStoreManager";
7
6
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
8
7
  import { PreChatSurveyPane } from "@microsoft/omnichannel-chat-components";
9
8
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
@@ -67,14 +66,12 @@ export const PreChatSurveyPaneStateful = props => {
67
66
  });
68
67
 
69
68
  try {
70
- var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _DataStoreManager$cli, _persistedState$domai;
69
+ var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _persistedState$domai, _persistedState$appSt;
71
70
 
72
- const widgetStateCacheId = getWidgetCacheId(((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$t = _state$domainStates.telemetryInternalData) === null || _state$domainStates$t === void 0 ? void 0 : _state$domainStates$t.orgId) ?? "", ((_state$domainStates$t2 = state.domainStates.telemetryInternalData) === null || _state$domainStates$t2 === void 0 ? void 0 : _state$domainStates$t2.widgetId) ?? "");
73
- const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateCacheId, "localStorage");
74
- const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
75
- let optionalParams = {};
71
+ const persistedState = getStateFromCache(((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$t = _state$domainStates.telemetryInternalData) === null || _state$domainStates$t === void 0 ? void 0 : _state$domainStates$t.orgId) ?? "", ((_state$domainStates$t2 = state.domainStates.telemetryInternalData) === null || _state$domainStates$t2 === void 0 ? void 0 : _state$domainStates$t2.widgetId) ?? "");
72
+ let optionalParams = {}; //Connect to Active chats and chat is not popout
76
73
 
77
- if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext) {
74
+ if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : _persistedState$domai.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === ConversationState.Active && !state.appStates.skipChatButtonRendering) {
78
75
  var _persistedState$domai2;
79
76
 
80
77
  optionalParams = {
@@ -103,7 +103,7 @@ export const ProactiveChatPaneStateful = props => {
103
103
  });
104
104
  },
105
105
  ...(proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : proactiveChatProps.controlProps),
106
- bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle ?? (proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : (_proactiveChatProps$c = proactiveChatProps.controlProps) === null || _proactiveChatProps$c === void 0 ? void 0 : _proactiveChatProps$c.bodyTitleText)
106
+ bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle ? state.appStates.proactiveChatStates.proactiveChatBodyTitle : proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : (_proactiveChatProps$c = proactiveChatProps.controlProps) === null || _proactiveChatProps$c === void 0 ? void 0 : _proactiveChatProps$c.bodyTitleText
107
107
  };
108
108
  useEffect(() => {
109
109
  setFocusOnElement(document.getElementById(controlProps.id + "-startbutton"));
@@ -8,6 +8,7 @@ export let ConversationState;
8
8
  ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
9
9
  ConversationState[ConversationState["Active"] = 5] = "Active";
10
10
  ConversationState[ConversationState["InActive"] = 6] = "InActive";
11
- ConversationState[ConversationState["Postchat"] = 7] = "Postchat";
12
- ConversationState[ConversationState["Closed"] = 8] = "Closed";
11
+ ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
12
+ ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
13
+ ConversationState[ConversationState["Closed"] = 9] = "Closed";
13
14
  })(ConversationState || (ConversationState = {}));
@@ -27,7 +27,6 @@ export const getLiveChatWidgetContextInitialState = props => {
27
27
  isMinimized: false,
28
28
  previousElementOnFocusBeforeModalOpen: null,
29
29
  outsideOperatingHours: false,
30
- shouldShowPostChat: false,
31
30
  preChatResponseEmail: "",
32
31
  isAudioMuted: null,
33
32
  newMessage: false,
@@ -18,13 +18,13 @@ export const shouldShowWebChatContainer = state => {
18
18
  return state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.InActive;
19
19
  };
20
20
  export const shouldShowLoadingPane = state => {
21
- return !state.appStates.isMinimized && !state.appStates.shouldShowPostChat && state.appStates.conversationState === ConversationState.Loading;
21
+ return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Loading;
22
22
  };
23
23
  export const shouldShowReconnectChatPane = state => {
24
24
  return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.ReconnectChat;
25
25
  };
26
26
  export const shouldShowPostChatLoadingPane = state => {
27
- return !state.appStates.isMinimized && state.appStates.shouldShowPostChat && state.appStates.conversationState === ConversationState.Loading;
27
+ return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.PostchatLoading;
28
28
  };
29
29
  export const shouldShowOutOfOfficeHoursPane = state => {
30
30
  return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.OutOfOffice;
@@ -76,6 +76,7 @@ export declare class Constants {
76
76
  static readonly internetConnectionTestUrl = "https://ocsdk-prod.azureedge.net/public/connecttest.txt";
77
77
  static readonly internetConnectionTestUrlText = "Omnichannel Connect Test";
78
78
  static readonly ChatWidgetStateChangedPrefix = "ChatWidgetStateChanged";
79
+ static readonly PostChatLoadingDurationInMs = 2000;
79
80
  }
80
81
  export declare const Regex: {
81
82
  new (): {};
@@ -40,7 +40,8 @@ export declare enum BroadcastEvent {
40
40
  MaximizeChat = "MaximizeChat",
41
41
  ChatInitiated = "ChatInitiated",
42
42
  CloseChat = "CloseChat",
43
- InitiateEndChatOnBrowserUnload = "InitiateEndChatOnBrowserUnload"
43
+ InitiateEndChatOnBrowserUnload = "InitiateEndChatOnBrowserUnload",
44
+ ClosePopoutWindow = "ClosePopoutWindow"
44
45
  }
45
46
  export declare enum TelemetryEvent {
46
47
  CallAdded = "CallAdded",
@@ -118,6 +119,8 @@ export declare enum TelemetryEvent {
118
119
  AudioToggleButtonClicked = "AudioToggleButtonClicked",
119
120
  SuppressBotMagicCodeSucceeded = "SuppressBotMagicCodeSucceeded",
120
121
  SuppressBotMagicCodeFailed = "SuppressBotMagicCodeFailed",
122
+ GetConversationDetailsException = "GetConversationDetailsException",
123
+ BrowserUnloadEventStarted = "BrowserUnloadEventStarted",
121
124
  ProcessingHTMLTextMiddlewareFailed = "ProcessingHTMLTextMiddlewareFailed",
122
125
  ProcessingSanitizationMiddlewareFailed = "ProcessingSanitizationMiddlewareFailed",
123
126
  FormatTagsMiddlewareJSONStringifyFailed = "FormatTagsMiddlewareJSONStringifyFailed",
@@ -31,7 +31,7 @@ export declare class TelemetryHelper {
31
31
  static addWidgetDataToTelemetry(telemetryConfig: ITelemetryConfig, telemetryInternalData: IInternalTelemetryData): IInternalTelemetryData;
32
32
  static addSessionDataToTelemetry(chatSession: LiveChatContext, telemetryInternalData: IInternalTelemetryData): IInternalTelemetryData;
33
33
  static addConversationDataToTelemetry(liveWorkItem: LiveWorkItemDetails, telemetryInternalData: IInternalTelemetryData): IInternalTelemetryData;
34
- static logCallingEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper, callId?: string | undefined) => void;
34
+ static logCallingEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper, callId?: string) => void;
35
35
  static logLoadingEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
36
36
  static logActionEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
37
37
  static logSDKEvent: (logLevel: LogLevel, payload: TelemetryEventWrapper) => void;
@@ -24,3 +24,6 @@ export declare const createTimer: () => ITimer;
24
24
  export declare const getDomain: (hostValue: any) => string;
25
25
  export declare const getWidgetCacheId: (orgId: string, widgetId: string) => string;
26
26
  export declare const getWidgetEndChatEventName: (orgId: string, widgetId: string) => string;
27
+ export declare const getStateFromCache: (orgId: string, widgetId: string) => any;
28
+ export declare const isUndefinedOrEmpty: (object: any) => boolean;
29
+ export declare const addDelayInMs: (ms: number) => Promise<void>;
@@ -1 +1 @@
1
- export declare const downloadTranscript: (chatSDK: any, renderMarkDown?: ((transcriptContent: string) => string) | undefined, bannerMessageOnError?: string | undefined, attachmentMessage?: string | undefined) => Promise<void>;
1
+ export declare const downloadTranscript: (chatSDK: any, renderMarkDown?: ((transcriptContent: string) => string) | undefined, bannerMessageOnError?: string, attachmentMessage?: string) => Promise<void>;
@@ -3,5 +3,5 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
3
3
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
4
4
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
5
5
  declare const prepareEndChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, state: ILiveChatWidgetContext) => Promise<void>;
6
- declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, skipEndChatSDK?: boolean | undefined, skipCloseChat?: boolean | undefined, postMessageToOtherTab?: boolean | undefined) => Promise<void>;
6
+ declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, skipEndChatSDK?: boolean, skipCloseChat?: boolean, postMessageToOtherTab?: boolean) => Promise<void>;
7
7
  export { prepareEndChat, endChat };
@@ -2,7 +2,7 @@ import "regenerator-runtime/runtime";
2
2
  import { Dispatch } from "react";
3
3
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
4
4
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
- declare const getChatReconnectContext: (chatSDK: any, reconnectId?: string | undefined) => Promise<any>;
5
+ declare const getChatReconnectContext: (chatSDK: any, reconnectId?: string) => Promise<any>;
6
6
  declare const getReconnectIdForAuthenticatedChat: (props: ILiveChatWidgetProps, chatSDK: any) => Promise<string | undefined>;
7
7
  declare const handleUnauthenticatedReconnectChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any, redirectInSameWindow: boolean | undefined) => Promise<void>;
8
8
  declare const startUnauthenticatedReconnectChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, reconnectId: string, initStartChat: any) => Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import { Dispatch } from "react";
2
2
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
- export declare const setPostChatContextAndLoadSurvey: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, persistedChat?: boolean | undefined) => Promise<void>;
3
+ export declare const setPostChatContextAndLoadSurvey: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, persistedChat?: boolean) => Promise<void>;
@@ -3,5 +3,6 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
3
3
  import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
4
4
  import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
5
  declare const prepareStartChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any) => Promise<void>;
6
+ declare const setPreChatAndInitiateChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, isProactiveChat?: boolean | false, proactiveChatEnablePrechatState?: boolean | false) => Promise<void>;
6
7
  declare const initStartChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, params?: any, persistedState?: any) => Promise<void>;
7
- export { prepareStartChat, initStartChat };
8
+ export { prepareStartChat, initStartChat, setPreChatAndInitiateChat };
@@ -1,4 +1,4 @@
1
1
  import { Dispatch } from "react";
2
2
  import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
3
3
  import { IProactiveChatNotificationConfig } from "../../proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig";
4
- export declare const startProactiveChat: (dispatch: Dispatch<ILiveChatWidgetAction>, notificationConfig?: IProactiveChatNotificationConfig | undefined, enablePreChat?: boolean | undefined, inNewWindow?: boolean | undefined) => void;
4
+ export declare const startProactiveChat: (dispatch: Dispatch<ILiveChatWidgetAction>, notificationConfig?: IProactiveChatNotificationConfig, enablePreChat?: boolean, inNewWindow?: boolean) => void;
@@ -7,4 +7,4 @@
7
7
  * 3. Decodes certain html characters that came through from chat services
8
8
  ******/
9
9
  import React from "react";
10
- export declare const createActivityMiddleware: (systemMessageStyleProps?: React.CSSProperties | undefined, userMessageStyleProps?: React.CSSProperties | undefined) => () => (next: any) => (...args: any) => any;
10
+ export declare const createActivityMiddleware: (systemMessageStyleProps?: React.CSSProperties, userMessageStyleProps?: React.CSSProperties) => () => (next: any) => (...args: any) => any;
@@ -5,4 +5,4 @@
5
5
  * 1. Renders the first two letters of the sender as the profile pic
6
6
  ******/
7
7
  import React from "react";
8
- export declare const createAvatarMiddleware: (avatarStyleProps?: React.CSSProperties | undefined, avatarTextStyleProps?: React.CSSProperties | undefined) => () => (next: any) => (args_0: any) => false | (() => JSX.Element);
8
+ export declare const createAvatarMiddleware: (avatarStyleProps?: React.CSSProperties, avatarTextStyleProps?: React.CSSProperties) => () => (next: any) => (args_0: any) => false | (() => JSX.Element);
@@ -6,6 +6,7 @@ export declare enum ConversationState {
6
6
  ProactiveChat = 4,
7
7
  Active = 5,
8
8
  InActive = 6,
9
- Postchat = 7,
10
- Closed = 8
9
+ PostchatLoading = 7,
10
+ Postchat = 8,
11
+ Closed = 9
11
12
  }
@@ -23,7 +23,6 @@ export interface ILiveChatWidgetContext {
23
23
  isMinimized: boolean;
24
24
  previousElementOnFocusBeforeModalOpen: HTMLElement | null;
25
25
  outsideOperatingHours: boolean;
26
- shouldShowPostChat: boolean;
27
26
  preChatResponseEmail: string;
28
27
  isAudioMuted: boolean | null;
29
28
  newMessage: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "0.1.0-main.9e62ed8",
3
+ "version": "0.1.0-main.a60f242",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",