@microsoft/omnichannel-chat-widget 0.1.0-main.99b5123 → 0.1.0-main.99bac9c
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.
- package/lib/cjs/common/storage/default/defaultCacheManager.js +34 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +13 -0
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +31 -18
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -4
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
- package/lib/cjs/components/footerstateful/FooterStateful.js +5 -13
- package/lib/cjs/components/headerstateful/HeaderStateful.js +10 -4
- package/lib/cjs/components/livechatwidget/common/authHelper.js +16 -3
- package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +15 -2
- package/lib/cjs/components/livechatwidget/common/startChat.js +12 -3
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +81 -44
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +10 -5
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -1
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +11 -4
- package/lib/cjs/contexts/createReducer.js +2 -2
- package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +13 -0
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +29 -13
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -4
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
- package/lib/esm/components/footerstateful/FooterStateful.js +5 -13
- package/lib/esm/components/headerstateful/HeaderStateful.js +10 -4
- package/lib/esm/components/livechatwidget/common/authHelper.js +14 -3
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +15 -2
- package/lib/esm/components/livechatwidget/common/startChat.js +13 -4
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +81 -44
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +6 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -1
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +9 -4
- package/lib/esm/contexts/createReducer.js +2 -2
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +5 -1
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +3 -2
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +1 -1
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/package.json +2 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getDomain, isNullOrEmptyString, isNullOrUndefined } from "../../utils";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { AWTPiiKind } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
|
|
2
|
+
import { AWTLogManager } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/webjs/AriaSDK";
|
|
3
|
+
import { AWTCustomerContentKind, AWTPiiKind, AWTPropertyType } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
|
|
5
4
|
import { Constants, AriaTelemetryConstants, EnvironmentVersion } from "../../Constants";
|
|
6
5
|
import { TelemetryManager } from "../TelemetryManager";
|
|
7
6
|
export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, collectiorUriForTelemetry, ariaTelemetryApplicationName) => {
|
|
@@ -49,18 +48,35 @@ export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, colle
|
|
|
49
48
|
const ariaLogger = {
|
|
50
49
|
log: (logLevel, telemetryInput) => {
|
|
51
50
|
try {
|
|
52
|
-
|
|
53
|
-
const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.telemetryInfo;
|
|
54
|
-
const eventProperties = new AWTEventProperties();
|
|
55
|
-
eventProperties.setName(telemetryInput.scenarioType);
|
|
51
|
+
var _telemetryInput$telem;
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
53
|
+
const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$telem = telemetryInput.telemetryInfo) === null || _telemetryInput$telem === void 0 ? void 0 : _telemetryInput$telem.telemetryInfo; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
|
|
55
|
+
const eventProperties = {
|
|
56
|
+
name: telemetryInput.scenarioType,
|
|
57
|
+
properties: {}
|
|
58
|
+
};
|
|
62
59
|
|
|
63
|
-
|
|
60
|
+
if (telemetryInfo) {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
+
Object.keys(telemetryInfo).forEach((key, index) => {
|
|
63
|
+
if (!isNullOrUndefined(telemetryInfo[key]) && !isNullOrEmptyString(telemetryInfo[key])) {
|
|
64
|
+
const property = {
|
|
65
|
+
value: typeof telemetryInfo[key] === "object" ? JSON.stringify(telemetryInfo[key]) : telemetryInfo[key],
|
|
66
|
+
type: typeof telemetryInfo[key] === "number" ? AWTPropertyType.Double : AWTPropertyType.String,
|
|
67
|
+
pii: AWTPiiKind.NotSet,
|
|
68
|
+
cc: AWTCustomerContentKind.NotSet
|
|
69
|
+
};
|
|
70
|
+
eventProperties.properties[key] = property;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const nameProperty = {
|
|
74
|
+
value: Constants.LiveChatWidget,
|
|
75
|
+
type: AWTPropertyType.String,
|
|
76
|
+
pii: AWTPiiKind.GenericData,
|
|
77
|
+
cc: AWTCustomerContentKind.NotSet
|
|
78
|
+
};
|
|
79
|
+
eventProperties.properties[ariaTelemetryApplicationName] = nameProperty;
|
|
64
80
|
}
|
|
65
81
|
|
|
66
82
|
logger() ? logger().logEvent(eventProperties) : console.log("Unable to initialize aria logger");
|
|
@@ -54,12 +54,12 @@ export const ConfirmationPaneStateful = props => {
|
|
|
54
54
|
type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
|
|
55
55
|
payload: false
|
|
56
56
|
});
|
|
57
|
-
const
|
|
57
|
+
const previousFocusedElementId = state.appStates.previousElementIdOnFocusBeforeModalOpen;
|
|
58
58
|
|
|
59
|
-
if (
|
|
60
|
-
setFocusOnElement(
|
|
59
|
+
if (previousFocusedElementId) {
|
|
60
|
+
setFocusOnElement("#" + previousFocusedElementId);
|
|
61
61
|
dispatch({
|
|
62
|
-
type: LiveChatWidgetActionType.
|
|
62
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
63
63
|
payload: null
|
|
64
64
|
});
|
|
65
65
|
} else {
|
|
@@ -25,16 +25,16 @@ export const EmailTranscriptPaneStateful = props => {
|
|
|
25
25
|
type: LiveChatWidgetActionType.SET_SHOW_EMAIL_TRANSCRIPT_PANE,
|
|
26
26
|
payload: false
|
|
27
27
|
});
|
|
28
|
-
const
|
|
28
|
+
const previousFocusedElementId = state.appStates.previousElementIdOnFocusBeforeModalOpen;
|
|
29
29
|
|
|
30
|
-
if (
|
|
31
|
-
setFocusOnElement(
|
|
30
|
+
if (previousFocusedElementId) {
|
|
31
|
+
setFocusOnElement("#" + previousFocusedElementId);
|
|
32
32
|
} else {
|
|
33
33
|
setFocusOnSendBox();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
dispatch({
|
|
37
|
-
type: LiveChatWidgetActionType.
|
|
37
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
38
38
|
payload: null
|
|
39
39
|
});
|
|
40
40
|
setTabIndices(elements, initialTabIndexMap, true);
|
|
@@ -54,13 +54,12 @@ export const FooterStateful = props => {
|
|
|
54
54
|
Event: TelemetryEvent.EmailTranscriptButtonClicked,
|
|
55
55
|
Description: "Email Transcript button clicked."
|
|
56
56
|
});
|
|
57
|
-
const emailTranscriptButtonId = (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP = footerProps.controlProps) === null || _footerProps$controlP === void 0 ? void 0 : (_footerProps$controlP2 = _footerProps$controlP.emailTranscriptButtonProps) === null || _footerProps$controlP2 === void 0 ? void 0 : _footerProps$controlP2.id) ??
|
|
58
|
-
const emailTranscriptButton = document.getElementById(emailTranscriptButtonId);
|
|
57
|
+
const emailTranscriptButtonId = (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP = footerProps.controlProps) === null || _footerProps$controlP === void 0 ? void 0 : (_footerProps$controlP2 = _footerProps$controlP.emailTranscriptButtonProps) === null || _footerProps$controlP2 === void 0 ? void 0 : _footerProps$controlP2.id) ?? `${controlProps.id}-emailtranscript-button`;
|
|
59
58
|
|
|
60
|
-
if (
|
|
59
|
+
if (emailTranscriptButtonId) {
|
|
61
60
|
dispatch({
|
|
62
|
-
type: LiveChatWidgetActionType.
|
|
63
|
-
payload:
|
|
61
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
62
|
+
payload: emailTranscriptButtonId
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
65
|
|
|
@@ -84,14 +83,7 @@ export const FooterStateful = props => {
|
|
|
84
83
|
isAudioMuted: state.appStates.isAudioMuted
|
|
85
84
|
}
|
|
86
85
|
};
|
|
87
|
-
|
|
88
|
-
const footer = document.getElementById(footerId);
|
|
89
|
-
|
|
90
|
-
if (footer) {
|
|
91
|
-
footer.style.display = hideFooterDisplay ? "none" : "";
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Footer, {
|
|
86
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !hideFooterDisplay && /*#__PURE__*/React.createElement(Footer, {
|
|
95
87
|
componentOverrides: footerProps === null || footerProps === void 0 ? void 0 : footerProps.componentOverrides,
|
|
96
88
|
controlProps: controlProps,
|
|
97
89
|
styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
|
|
@@ -36,6 +36,8 @@ export const HeaderStateful = props => {
|
|
|
36
36
|
});
|
|
37
37
|
},
|
|
38
38
|
onCloseClick: async () => {
|
|
39
|
+
var _props$headerProps, _props$headerProps$co, _props$headerProps$co2;
|
|
40
|
+
|
|
39
41
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
40
42
|
Event: TelemetryEvent.HeaderCloseButtonClicked,
|
|
41
43
|
Description: "Header Close button clicked."
|
|
@@ -53,10 +55,14 @@ export const HeaderStateful = props => {
|
|
|
53
55
|
await endChat(adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTabs);
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
const closeButtonId = ((_props$headerProps = props.headerProps) === null || _props$headerProps === void 0 ? void 0 : (_props$headerProps$co = _props$headerProps.controlProps) === null || _props$headerProps$co === void 0 ? void 0 : (_props$headerProps$co2 = _props$headerProps$co.closeButtonProps) === null || _props$headerProps$co2 === void 0 ? void 0 : _props$headerProps$co2.id) ?? `${controlProps.id}-close-button`;
|
|
59
|
+
|
|
60
|
+
if (closeButtonId) {
|
|
61
|
+
dispatch({
|
|
62
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
63
|
+
payload: closeButtonId
|
|
64
|
+
});
|
|
65
|
+
}
|
|
60
66
|
},
|
|
61
67
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
62
68
|
hideTitle: state.appStates.conversationState === ConversationState.Loading || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
3
|
-
import { isNullOrEmptyString } from "../../../common/utils";
|
|
3
|
+
import { isNullOrEmptyString } from "../../../common/utils";
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const getAuthClientFunction = chatConfig => {
|
|
6
6
|
let authClientFunction = undefined;
|
|
7
7
|
|
|
8
8
|
if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
|
|
@@ -11,6 +11,13 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
11
11
|
authClientFunction = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveChatC = chatConfig.LiveChatConfigAuthSettings) === null || _chatConfig$LiveChatC === void 0 ? void 0 : _chatConfig$LiveChatC.msdyn_javascriptclientfunction) ?? undefined;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
return authClientFunction;
|
|
15
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
19
|
+
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
20
|
+
|
|
14
21
|
if (getAuthToken && authClientFunction) {
|
|
15
22
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
16
23
|
Event: TelemetryEvent.GetAuthTokenCalled
|
|
@@ -22,12 +29,16 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
22
29
|
chatSDK.setAuthTokenProvider(async () => {
|
|
23
30
|
return token;
|
|
24
31
|
});
|
|
32
|
+
return true;
|
|
25
33
|
} else {
|
|
26
34
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
27
35
|
Event: TelemetryEvent.ReceivedNullOrEmptyToken
|
|
28
36
|
});
|
|
37
|
+
return false;
|
|
29
38
|
}
|
|
30
39
|
}
|
|
40
|
+
|
|
41
|
+
return false;
|
|
31
42
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
43
|
|
|
33
44
|
|
|
@@ -36,4 +47,4 @@ const removeAuthTokenProvider = chatSDK => {
|
|
|
36
47
|
chatSDK.authenticatedUserToken = null;
|
|
37
48
|
};
|
|
38
49
|
|
|
39
|
-
export { handleAuthentication, removeAuthTokenProvider };
|
|
50
|
+
export { getAuthClientFunction, handleAuthentication, removeAuthTokenProvider };
|
|
@@ -3,25 +3,14 @@ import React from "react";
|
|
|
3
3
|
import { decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { shouldShowFooter } from "../../../controller/componentController";
|
|
5
5
|
export const createFooter = (props, state) => {
|
|
6
|
-
var _props$
|
|
6
|
+
var _props$controlProps, _props$componentOverr;
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
hideDownloadTranscriptButton: true,
|
|
11
|
-
hideEmailTranscriptButton: true,
|
|
12
|
-
hideAudioNotificationButton: true
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const footer = !((_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideFooter) && shouldShowFooter(state) ? decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.footer) || /*#__PURE__*/React.createElement(FooterStateful, {
|
|
8
|
+
const hideFooterDisplay = !((_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideFooter) && shouldShowFooter(state) ? false : true;
|
|
9
|
+
const footer = decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.footer) || /*#__PURE__*/React.createElement(FooterStateful, {
|
|
16
10
|
footerProps: props.footerProps,
|
|
17
11
|
downloadTranscriptProps: props.downloadTranscriptProps,
|
|
18
12
|
audioNotificationProps: props.audioNotificationProps,
|
|
19
|
-
hideFooterDisplay:
|
|
20
|
-
}) : decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.footer) || /*#__PURE__*/React.createElement(FooterStateful, {
|
|
21
|
-
footerProps: footerPropsHidden,
|
|
22
|
-
downloadTranscriptProps: props.downloadTranscriptProps,
|
|
23
|
-
audioNotificationProps: props.audioNotificationProps,
|
|
24
|
-
hideFooterDisplay: true
|
|
13
|
+
hideFooterDisplay: hideFooterDisplay
|
|
25
14
|
});
|
|
26
15
|
return footer;
|
|
27
16
|
};
|
|
@@ -2,6 +2,8 @@ import { Constants } from "../../../common/Constants";
|
|
|
2
2
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
3
3
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
4
4
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
5
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
5
7
|
|
|
6
8
|
const isInternetConnected = async () => {
|
|
7
9
|
try {
|
|
@@ -18,8 +20,14 @@ export const createInternetConnectionChangeHandler = async () => {
|
|
|
18
20
|
const connected = await isInternetConnected();
|
|
19
21
|
|
|
20
22
|
if (!connected) {
|
|
23
|
+
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
24
|
+
Event: TelemetryEvent.NetworkDisconnected
|
|
25
|
+
});
|
|
21
26
|
NotificationHandler.notifyError(NotificationScenarios.InternetConnection, defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
|
|
22
27
|
} else {
|
|
28
|
+
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
29
|
+
Event: TelemetryEvent.NetworkReconnected
|
|
30
|
+
});
|
|
23
31
|
NotificationHandler.notifySuccess(NotificationScenarios.InternetConnection, defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
|
|
24
32
|
}
|
|
25
33
|
}; // Checking connection status on online & offline events due to possible false positives
|
|
@@ -870,7 +870,7 @@ export const dummyDefaultProps = {
|
|
|
870
870
|
className: undefined
|
|
871
871
|
},
|
|
872
872
|
closeButtonProps: {
|
|
873
|
-
id: "oc-lcw-header-
|
|
873
|
+
id: "oc-lcw-header-close-button",
|
|
874
874
|
type: "icon",
|
|
875
875
|
iconName: "ChromeClose",
|
|
876
876
|
ariaLabel: "Close",
|
|
@@ -1186,7 +1186,17 @@ export const dummyDefaultProps = {
|
|
|
1186
1186
|
hideSubtitle: false,
|
|
1187
1187
|
subtitleText: "Live chat support!",
|
|
1188
1188
|
hideCloseButton: false,
|
|
1189
|
-
|
|
1189
|
+
closeButtonProps: {
|
|
1190
|
+
id: "oc-lcw-proactivechat-closebutton",
|
|
1191
|
+
type: "icon",
|
|
1192
|
+
iconName: "ChromeClose",
|
|
1193
|
+
ariaLabel: "Close",
|
|
1194
|
+
imageIconProps: undefined,
|
|
1195
|
+
text: "Close",
|
|
1196
|
+
onClick: undefined,
|
|
1197
|
+
className: undefined,
|
|
1198
|
+
hideButtonTitle: true
|
|
1199
|
+
},
|
|
1190
1200
|
isBodyContainerHorizantal: false,
|
|
1191
1201
|
hideBodyTitle: false,
|
|
1192
1202
|
bodyTitleText: "Hi! Have any questions? I am here to help.",
|
|
@@ -1655,6 +1665,9 @@ export const dummyDefaultProps = {
|
|
|
1655
1665
|
},
|
|
1656
1666
|
attachmentSizeStyles: {
|
|
1657
1667
|
display: "none"
|
|
1668
|
+
},
|
|
1669
|
+
receivedMessageAnchorStyles: {
|
|
1670
|
+
color: "white"
|
|
1658
1671
|
}
|
|
1659
1672
|
},
|
|
1660
1673
|
localizedTexts: {
|
|
@@ -14,7 +14,7 @@ import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurv
|
|
|
14
14
|
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
15
15
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
16
16
|
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
17
|
-
import { handleAuthentication } from "./authHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
import { getAuthClientFunction, handleAuthentication } from "./authHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
18
|
|
|
19
19
|
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
20
|
|
|
@@ -93,6 +93,17 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
93
93
|
try {
|
|
94
94
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
95
95
|
|
|
96
|
+
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
97
|
+
|
|
98
|
+
if (getAuthToken && authClientFunction) {
|
|
99
|
+
// set auth token to chat sdk before start chat
|
|
100
|
+
const authSuccess = await handleAuthentication(chatSDK, chatConfig, getAuthToken);
|
|
101
|
+
|
|
102
|
+
if (!authSuccess) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
96
107
|
let isStartChatSuccessful = false; //Check if chat retrieved from cache
|
|
97
108
|
|
|
98
109
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
@@ -115,9 +126,7 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
115
126
|
}); // Set custom context params
|
|
116
127
|
|
|
117
128
|
setCustomContextParams(chatSDK);
|
|
118
|
-
optionalParams = Object.assign({}, params, optionalParams);
|
|
119
|
-
|
|
120
|
-
await handleAuthentication(chatSDK, chatConfig, getAuthToken);
|
|
129
|
+
optionalParams = Object.assign({}, params, optionalParams);
|
|
121
130
|
await chatSDK.startChat(optionalParams);
|
|
122
131
|
isStartChatSuccessful = true;
|
|
123
132
|
} catch (error) {
|
|
@@ -44,7 +44,8 @@ import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
|
44
44
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
45
45
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
46
46
|
import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
|
|
47
|
-
import {
|
|
47
|
+
import { registerBroadcastServiceForLocalStorage } from "../../../common/storage/default/defaultCacheManager";
|
|
48
|
+
import { defaultClientDataStoreProvider } from "../../../common/storage/default/defaultClientDataStoreProvider";
|
|
48
49
|
export const LiveChatWidgetStateful = props => {
|
|
49
50
|
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps14, _props$controlProps15, _props$componentOverr, _props$controlProps16, _props$componentOverr2, _props$controlProps17, _props$componentOverr3, _props$controlProps18, _props$componentOverr4, _props$controlProps19, _props$componentOverr5, _props$controlProps20, _props$componentOverr6, _props$controlProps21, _props$componentOverr7, _props$controlProps22, _props$controlProps23, _props$componentOverr8, _props$controlProps24, _props$componentOverr9, _props$controlProps25, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
50
51
|
|
|
@@ -95,30 +96,39 @@ export const LiveChatWidgetStateful = props => {
|
|
|
95
96
|
};
|
|
96
97
|
|
|
97
98
|
useEffect(() => {
|
|
98
|
-
var _props$
|
|
99
|
+
var _props$controlProps4, _props$controlProps5, _props$controlProps6, _props$controlProps8, _props$chatConfig, _props$chatConfig$Cha, _props$controlProps9, _props$reconnectChatP, _props$chatConfig2, _props$chatConfig2$Li, _props$reconnectChatP4, _state$domainStates;
|
|
100
|
+
|
|
101
|
+
// Add default localStorage support for widget
|
|
102
|
+
if (props.contextDataStore === undefined) {
|
|
103
|
+
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps3;
|
|
104
|
+
|
|
105
|
+
registerBroadcastServiceForLocalStorage(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.widgetInstanceId) ?? "");
|
|
106
|
+
DataStoreManager.clientDataStore = defaultClientDataStoreProvider();
|
|
107
|
+
} else {
|
|
108
|
+
DataStoreManager.clientDataStore = props.contextDataStore;
|
|
109
|
+
}
|
|
99
110
|
|
|
100
111
|
registerTelemetryLoggers(props, dispatch);
|
|
101
112
|
createInternetConnectionChangeHandler();
|
|
102
|
-
DataStoreManager.clientDataStore = props.contextDataStore ?? undefined;
|
|
103
113
|
dispatch({
|
|
104
114
|
type: LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
|
|
105
115
|
payload: widgetElementId
|
|
106
116
|
});
|
|
107
117
|
dispatch({
|
|
108
118
|
type: LiveChatWidgetActionType.SET_SKIP_CHAT_BUTTON_RENDERING,
|
|
109
|
-
payload: ((_props$
|
|
119
|
+
payload: ((_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.skipChatButtonRendering) || false
|
|
110
120
|
});
|
|
111
121
|
dispatch({
|
|
112
122
|
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
113
123
|
payload: false
|
|
114
124
|
});
|
|
115
125
|
|
|
116
|
-
if ((_props$
|
|
117
|
-
var _props$
|
|
126
|
+
if ((_props$controlProps5 = props.controlProps) !== null && _props$controlProps5 !== void 0 && _props$controlProps5.widgetInstanceId && !isNullOrEmptyString((_props$controlProps6 = props.controlProps) === null || _props$controlProps6 === void 0 ? void 0 : _props$controlProps6.widgetInstanceId)) {
|
|
127
|
+
var _props$controlProps7;
|
|
118
128
|
|
|
119
129
|
dispatch({
|
|
120
130
|
type: LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
|
|
121
|
-
payload: (_props$
|
|
131
|
+
payload: (_props$controlProps7 = props.controlProps) === null || _props$controlProps7 === void 0 ? void 0 : _props$controlProps7.widgetInstanceId
|
|
122
132
|
});
|
|
123
133
|
}
|
|
124
134
|
|
|
@@ -129,35 +139,48 @@ export const LiveChatWidgetStateful = props => {
|
|
|
129
139
|
});
|
|
130
140
|
}); // Initialize global dir
|
|
131
141
|
|
|
132
|
-
const globalDir = ((_props$
|
|
142
|
+
const globalDir = ((_props$controlProps8 = props.controlProps) === null || _props$controlProps8 === void 0 ? void 0 : _props$controlProps8.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);
|
|
133
143
|
dispatch({
|
|
134
144
|
type: LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
135
145
|
payload: globalDir
|
|
136
146
|
});
|
|
137
147
|
|
|
138
|
-
if (!((_props$
|
|
148
|
+
if (!((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
139
149
|
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
140
150
|
|
|
141
151
|
startUnauthenticatedReconnectChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.isReconnectEnabled, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId, initStartChat);
|
|
142
152
|
return;
|
|
143
|
-
} //
|
|
153
|
+
} // Checks if reconnectId is present for auth chat. If it is present, then it shows reconnect chat pane,
|
|
154
|
+
// where customer can choose to continue previous conversation or start new conversation
|
|
144
155
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
156
|
|
|
146
157
|
|
|
147
158
|
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;
|
|
148
159
|
|
|
149
|
-
if (isAuthenticationSettingsEnabled ===
|
|
150
|
-
|
|
160
|
+
if (!state.appStates.skipChatButtonRendering && state.appStates.conversationState === ConversationState.Active && isAuthenticationSettingsEnabled === true && (_props$reconnectChatP4 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP4 !== void 0 && _props$reconnectChatP4.isReconnectEnabled) {
|
|
161
|
+
getReconnectIdForAuthenticatedChat(props, chatSDK).then(authReconnectId => {
|
|
162
|
+
if (authReconnectId && !state.appStates.reconnectId) {
|
|
163
|
+
dispatch({
|
|
164
|
+
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
165
|
+
payload: authReconnectId
|
|
166
|
+
});
|
|
167
|
+
dispatch({
|
|
168
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
169
|
+
payload: ConversationState.ReconnectChat
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
151
175
|
|
|
152
|
-
|
|
153
|
-
|
|
176
|
+
if (!state.appStates.skipChatButtonRendering && !isUndefinedOrEmpty((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext) && state.appStates.conversationState === ConversationState.Active) {
|
|
177
|
+
var _state$domainStates2;
|
|
154
178
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
179
|
+
const optionalParams = {
|
|
180
|
+
liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
181
|
+
};
|
|
182
|
+
initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
|
|
183
|
+
return;
|
|
161
184
|
} // All other case should show start chat button, skipChatButtonRendering will take care of it own
|
|
162
185
|
|
|
163
186
|
|
|
@@ -169,16 +192,16 @@ export const LiveChatWidgetStateful = props => {
|
|
|
169
192
|
|
|
170
193
|
useEffect(() => {
|
|
171
194
|
if (state.appStates.skipChatButtonRendering) {
|
|
172
|
-
var _props$
|
|
195
|
+
var _props$reconnectChatP5;
|
|
173
196
|
|
|
174
197
|
BroadcastService.postMessage({
|
|
175
198
|
eventName: BroadcastEvent.ChatInitiated
|
|
176
199
|
});
|
|
177
200
|
|
|
178
|
-
if ((_props$
|
|
179
|
-
var _props$
|
|
201
|
+
if ((_props$reconnectChatP5 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP5 !== void 0 && _props$reconnectChatP5.reconnectId && !state.appStates.reconnectId) {
|
|
202
|
+
var _props$reconnectChatP6, _props$reconnectChatP7, _props$reconnectChatP8;
|
|
180
203
|
|
|
181
|
-
handleUnauthenticatedReconnectChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, (_props$
|
|
204
|
+
handleUnauthenticatedReconnectChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, (_props$reconnectChatP6 = props.reconnectChatPaneProps) === null || _props$reconnectChatP6 === void 0 ? void 0 : _props$reconnectChatP6.isReconnectEnabled, (_props$reconnectChatP7 = props.reconnectChatPaneProps) === null || _props$reconnectChatP7 === void 0 ? void 0 : _props$reconnectChatP7.reconnectId, initStartChat, (_props$reconnectChatP8 = props.reconnectChatPaneProps) === null || _props$reconnectChatP8 === void 0 ? void 0 : _props$reconnectChatP8.redirectInSameWindow);
|
|
182
205
|
} else {
|
|
183
206
|
getReconnectIdForAuthenticatedChat(props, chatSDK).then(authReconnectId => {
|
|
184
207
|
if (authReconnectId && !state.appStates.reconnectId) {
|
|
@@ -191,11 +214,23 @@ export const LiveChatWidgetStateful = props => {
|
|
|
191
214
|
payload: ConversationState.ReconnectChat
|
|
192
215
|
});
|
|
193
216
|
} else {
|
|
217
|
+
var _state$domainStates3;
|
|
218
|
+
|
|
194
219
|
const chatStartedSkippingChatButtonRendering = {
|
|
195
220
|
eventName: BroadcastEvent.StartChatSkippingChatButtonRendering
|
|
196
221
|
};
|
|
197
222
|
BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
198
|
-
|
|
223
|
+
|
|
224
|
+
if (!isUndefinedOrEmpty((_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.liveChatContext) && state.appStates.conversationState === ConversationState.Active) {
|
|
225
|
+
var _state$domainStates4;
|
|
226
|
+
|
|
227
|
+
const optionalParams = {
|
|
228
|
+
liveChatContext: (_state$domainStates4 = state.domainStates) === null || _state$domainStates4 === void 0 ? void 0 : _state$domainStates4.liveChatContext
|
|
229
|
+
};
|
|
230
|
+
initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
|
|
231
|
+
} else {
|
|
232
|
+
setPreChatAndInitiateChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter);
|
|
233
|
+
}
|
|
199
234
|
}
|
|
200
235
|
});
|
|
201
236
|
}
|
|
@@ -203,7 +238,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
203
238
|
}, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
|
|
204
239
|
|
|
205
240
|
useEffect(() => {
|
|
206
|
-
var _chatSDK$
|
|
241
|
+
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps12;
|
|
207
242
|
|
|
208
243
|
// Add the custom context on receiving the SetCustomContext event
|
|
209
244
|
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
@@ -235,13 +270,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
235
270
|
}); // Start chat from SDK Event
|
|
236
271
|
|
|
237
272
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(() => {
|
|
238
|
-
var _chatSDK$
|
|
273
|
+
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps10;
|
|
239
274
|
|
|
240
275
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
241
276
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
242
277
|
Description: "Start chat event received."
|
|
243
278
|
});
|
|
244
|
-
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
279
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps10 = props.controlProps) === null || _props$controlProps10 === void 0 ? void 0 : _props$controlProps10.widgetInstanceId) ?? ""); // Chat not found in cache
|
|
245
280
|
|
|
246
281
|
if (persistedState === undefined) {
|
|
247
282
|
BroadcastService.postMessage({
|
|
@@ -281,10 +316,10 @@ export const LiveChatWidgetStateful = props => {
|
|
|
281
316
|
|
|
282
317
|
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
283
318
|
if (state.appStates.skipChatButtonRendering !== true) {
|
|
284
|
-
var _chatSDK$
|
|
319
|
+
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps11;
|
|
285
320
|
|
|
286
321
|
// This is to ensure to get latest state from cache in multitab
|
|
287
|
-
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
322
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
288
323
|
|
|
289
324
|
if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
|
|
290
325
|
prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
@@ -304,7 +339,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
304
339
|
initiateEndChatOnBrowserUnload();
|
|
305
340
|
}); // Listen to end chat event from other tabs
|
|
306
341
|
|
|
307
|
-
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$
|
|
342
|
+
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "");
|
|
308
343
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
309
344
|
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
310
345
|
return;
|
|
@@ -385,23 +420,25 @@ export const LiveChatWidgetStateful = props => {
|
|
|
385
420
|
}, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]); // Publish chat widget state
|
|
386
421
|
|
|
387
422
|
useEffect(() => {
|
|
388
|
-
var _props$
|
|
423
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps13;
|
|
389
424
|
|
|
390
425
|
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
391
426
|
// Ghost chat scenarios
|
|
392
|
-
if (state.appStates.conversationState === ConversationState.Active && ((_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.skipChatButtonRendering) === true) {
|
|
393
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
394
|
-
window.onbeforeunload = function () {
|
|
395
|
-
const prompt = Constants.BrowserUnloadConfirmationMessage;
|
|
396
|
-
return prompt;
|
|
397
|
-
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
window.onunload = function () {
|
|
401
|
-
initiateEndChatOnBrowserUnload();
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
427
|
|
|
428
|
+
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
429
|
+
if (state.appStates.conversationState === ConversationState.Active &&
|
|
430
|
+
props.controlProps?.skipChatButtonRendering === true) {
|
|
431
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
432
|
+
|
|
433
|
+
window.onbeforeunload = function () {
|
|
434
|
+
const prompt = Constants.BrowserUnloadConfirmationMessage;
|
|
435
|
+
return prompt;
|
|
436
|
+
};
|
|
437
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
438
|
+
window.onunload = function () {
|
|
439
|
+
initiateEndChatOnBrowserUnload();
|
|
440
|
+
};
|
|
441
|
+
}*/
|
|
405
442
|
widgetStateEventName = getWidgetCacheId(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps13 = props.controlProps) === null || _props$controlProps13 === void 0 ? void 0 : _props$controlProps13.widgetInstanceId) ?? "");
|
|
406
443
|
const chatWidgetStateChangeEvent = {
|
|
407
444
|
eventName: widgetStateEventName,
|