@microsoft/omnichannel-chat-widget 0.1.0-main.8b6c0d8 → 0.1.0-main.ae27766
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/README.md +227 -0
- package/lib/cjs/assets/Audios.js +8 -0
- package/lib/cjs/assets/Icons.js +28 -0
- package/lib/cjs/common/Constants.js +38 -4
- package/lib/cjs/common/contextDataStore/DataStoreManager.js +14 -0
- package/lib/cjs/{assets/assets.d.js → common/interfaces/IContextDataStore.js} +0 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +37 -3
- package/lib/cjs/common/telemetry/TelemetryHelper.js +22 -4
- package/lib/cjs/common/telemetry/TelemetryManager.js +22 -9
- package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +3 -3
- package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +35 -3
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +3 -0
- package/lib/cjs/common/utils.js +15 -2
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +8 -1
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -54
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
- package/lib/cjs/components/footerstateful/FooterStateful.js +4 -5
- package/lib/cjs/components/headerstateful/HeaderStateful.js +11 -8
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -4
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +43 -35
- package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +14 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +102 -50
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +5 -0
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +29 -9
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +105 -20
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +11 -7
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +26 -24
- package/lib/cjs/components/livechatwidget/common/startChat.js +113 -54
- package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -3
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +101 -32
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +8 -0
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +28 -11
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +10 -4
- package/lib/cjs/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
- package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +51 -73
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +9 -46
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +44 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +15 -12
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +11 -4
- package/lib/cjs/contexts/createReducer.js +27 -10
- package/lib/cjs/controller/componentController.js +2 -2
- package/lib/cjs/plugins/newMessageEventHandler.js +102 -0
- package/lib/esm/assets/Audios.js +1 -0
- package/lib/esm/assets/Icons.js +11 -0
- package/lib/esm/common/Constants.js +34 -3
- package/lib/esm/common/contextDataStore/DataStoreManager.js +5 -0
- package/lib/esm/common/interfaces/IContextDataStore.js +1 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +33 -2
- package/lib/esm/common/telemetry/TelemetryHelper.js +22 -5
- package/lib/esm/common/telemetry/TelemetryManager.js +17 -9
- package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +3 -3
- package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +32 -2
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +3 -0
- package/lib/esm/common/utils.js +11 -1
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +9 -1
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -50
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
- package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
- package/lib/esm/components/headerstateful/HeaderStateful.js +12 -9
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +41 -36
- package/lib/esm/components/livechatwidget/common/disposeTelemetryLoggers.js +4 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +100 -47
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -0
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +25 -9
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +94 -20
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +10 -3
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +23 -22
- package/lib/esm/components/livechatwidget/common/startChat.js +108 -51
- package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +94 -33
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +6 -0
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +26 -10
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +9 -5
- package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -12
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -44
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +31 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +15 -12
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +11 -4
- package/lib/esm/contexts/createReducer.js +27 -9
- package/lib/esm/controller/componentController.js +2 -2
- package/lib/esm/plugins/newMessageEventHandler.js +84 -0
- package/lib/types/assets/Audios.d.ts +1 -0
- package/lib/types/assets/Icons.d.ts +11 -0
- package/lib/types/common/Constants.d.ts +19 -1
- package/lib/types/common/contextDataStore/DataStoreManager.d.ts +4 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +14 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +24 -1
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/lib/types/common/telemetry/TelemetryManager.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +3 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +3 -0
- package/lib/types/common/telemetry/interfaces/IChatSDKLogger.d.ts +1 -0
- package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +2 -0
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +12 -0
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +5 -2
- package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/disposeTelemetryLoggers.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -2
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
- package/lib/types/components/prechatsurveypanestateful/interfaces/IPreChatSurveyPaneStatefulParams.d.ts +1 -1
- package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +3 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +15 -12
- package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
- package/package.json +11 -11
- package/lib/cjs/assets/audios/newMessageNotification.mp3 +0 -0
- package/lib/cjs/assets/icons/archiveIcon.svg +0 -3
- package/lib/cjs/assets/icons/audioIcon.svg +0 -6
- package/lib/cjs/assets/icons/blankIcon.svg +0 -6
- package/lib/cjs/assets/icons/excelIcon.svg +0 -6
- package/lib/cjs/assets/icons/imageIcon.svg +0 -6
- package/lib/cjs/assets/icons/oneNoteIcon.svg +0 -6
- package/lib/cjs/assets/icons/pdfIcon.svg +0 -6
- package/lib/cjs/assets/icons/powerpointIcon.svg +0 -6
- package/lib/cjs/assets/icons/videoIcon.svg +0 -6
- package/lib/cjs/assets/icons/visioIcon.svg +0 -6
- package/lib/cjs/assets/icons/wordIcon.svg +0 -6
- package/lib/esm/assets/assets.d.js +0 -0
- package/lib/esm/assets/audios/newMessageNotification.mp3 +0 -0
- package/lib/esm/assets/icons/archiveIcon.svg +0 -3
- package/lib/esm/assets/icons/audioIcon.svg +0 -6
- package/lib/esm/assets/icons/blankIcon.svg +0 -6
- package/lib/esm/assets/icons/excelIcon.svg +0 -6
- package/lib/esm/assets/icons/imageIcon.svg +0 -6
- package/lib/esm/assets/icons/oneNoteIcon.svg +0 -6
- package/lib/esm/assets/icons/pdfIcon.svg +0 -6
- package/lib/esm/assets/icons/powerpointIcon.svg +0 -6
- package/lib/esm/assets/icons/videoIcon.svg +0 -6
- package/lib/esm/assets/icons/visioIcon.svg +0 -6
- package/lib/esm/assets/icons/wordIcon.svg +0 -6
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.handleUnauthenticatedReconnectChat = exports.getReconnectIdForAuthenticatedChat = void 0;
|
|
6
|
+
exports.startUnauthenticatedReconnectChat = exports.handleUnauthenticatedReconnectChat = exports.handleRedirectUnauthenticatedReconnectChat = exports.getReconnectIdForAuthenticatedChat = exports.getChatReconnectContext = void 0;
|
|
7
7
|
|
|
8
8
|
require("regenerator-runtime/runtime");
|
|
9
9
|
|
|
10
10
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
13
13
|
|
|
14
14
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
15
15
|
|
|
@@ -41,6 +41,8 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
|
41
41
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
exports.getChatReconnectContext = getChatReconnectContext;
|
|
45
|
+
|
|
44
46
|
const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
45
47
|
var _props$reconnectChatP, _props$reconnectChatP2;
|
|
46
48
|
|
|
@@ -61,33 +63,116 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
|
61
63
|
|
|
62
64
|
exports.getReconnectIdForAuthenticatedChat = getReconnectIdForAuthenticatedChat;
|
|
63
65
|
|
|
64
|
-
const handleUnauthenticatedReconnectChat = async (dispatch, reconnectId, initStartChat) => {
|
|
65
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(reconnectId);
|
|
66
|
+
const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
67
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
66
68
|
|
|
67
|
-
if (reconnectAvailabilityResponse
|
|
68
|
-
|
|
69
|
+
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
70
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
69
71
|
} else {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
73
|
+
}
|
|
74
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
exports.handleUnauthenticatedReconnectChat = handleUnauthenticatedReconnectChat;
|
|
78
|
+
|
|
79
|
+
const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
80
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
81
|
+
|
|
82
|
+
if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
83
|
+
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
84
|
+
}
|
|
85
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
exports.startUnauthenticatedReconnectChat = startUnauthenticatedReconnectChat;
|
|
89
|
+
|
|
90
|
+
const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
91
|
+
const startUnauthenticatedReconnectChat = {
|
|
92
|
+
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
_omnichannelChatComponents.BroadcastService.postMessage(startUnauthenticatedReconnectChat);
|
|
96
|
+
|
|
97
|
+
const optionalParams = {
|
|
98
|
+
reconnectId: reconnectId
|
|
99
|
+
};
|
|
100
|
+
dispatch({
|
|
101
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
102
|
+
payload: reconnectId
|
|
103
|
+
});
|
|
104
|
+
dispatch({
|
|
105
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
106
|
+
payload: _ConversationState.ConversationState.Loading
|
|
107
|
+
});
|
|
108
|
+
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
112
|
+
const redirectPageRequest = {
|
|
113
|
+
eventName: _TelemetryConstants.BroadcastEvent.RedirectPageRequest,
|
|
114
|
+
payload: {
|
|
115
|
+
redirectURL: redirectURL
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
_omnichannelChatComponents.BroadcastService.postMessage(redirectPageRequest);
|
|
120
|
+
|
|
121
|
+
if (redirectInSameWindow) {
|
|
122
|
+
window.location.href = redirectURL;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
|
|
127
|
+
return reconnectAvailabilityResponse && !reconnectAvailabilityResponse.reconnectId;
|
|
128
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
|
|
132
|
+
const startUnauthenticatedReconnectChat = {
|
|
133
|
+
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
_omnichannelChatComponents.BroadcastService.postMessage(startUnauthenticatedReconnectChat); // Getting PreChat Survey Context
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
const parseToJson = false;
|
|
140
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
141
|
+
|
|
142
|
+
if (preChatSurveyResponse) {
|
|
143
|
+
dispatch({
|
|
144
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
145
|
+
payload: preChatSurveyResponse
|
|
146
|
+
});
|
|
73
147
|
dispatch({
|
|
74
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
75
|
-
payload:
|
|
148
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
149
|
+
payload: _ConversationState.ConversationState.Prechat
|
|
76
150
|
});
|
|
151
|
+
} else {
|
|
77
152
|
dispatch({
|
|
78
153
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
79
154
|
payload: _ConversationState.ConversationState.Loading
|
|
80
155
|
});
|
|
81
|
-
await initStartChat(
|
|
156
|
+
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
82
157
|
}
|
|
83
|
-
};
|
|
158
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
159
|
|
|
85
|
-
exports.handleUnauthenticatedReconnectChat = handleUnauthenticatedReconnectChat;
|
|
86
160
|
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
161
|
+
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
162
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
163
|
+
|
|
164
|
+
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
165
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
166
|
+
}
|
|
167
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
exports.handleRedirectUnauthenticatedReconnectChat = handleRedirectUnauthenticatedReconnectChat;
|
|
171
|
+
|
|
172
|
+
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
173
|
+
if (reconnectAvailabilityResponse.redirectURL) {
|
|
174
|
+
redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
|
|
175
|
+
} else {
|
|
176
|
+
await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
|
|
177
|
+
}
|
|
93
178
|
};
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.registerTelemetryLoggers = void 0;
|
|
7
7
|
|
|
8
|
-
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
9
|
-
|
|
10
8
|
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
11
9
|
|
|
10
|
+
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
11
|
+
|
|
12
12
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
13
13
|
|
|
14
14
|
var _defaultAriaConfig = require("../../../common/telemetry/defaultConfigs/defaultAriaConfig");
|
|
@@ -17,10 +17,6 @@ var _defaultTelemetryInternalData = require("../../../common/telemetry/defaultCo
|
|
|
17
17
|
|
|
18
18
|
var _defaultTelemetryConfiguration = require("../../../common/telemetry/defaultConfigs/defaultTelemetryConfiguration");
|
|
19
19
|
|
|
20
|
-
var _package = _interopRequireDefault(require("@microsoft/omnichannel-chat-sdk/package.json"));
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
20
|
const registerTelemetryLoggers = (props, dispatch) => {
|
|
25
21
|
var _props$liveChatContex, _props$liveChatContex2;
|
|
26
22
|
|
|
@@ -33,6 +29,8 @@ const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
33
29
|
|
|
34
30
|
_TelemetryManager.TelemetryManager.InternalTelemetryData = (_props$liveChatContex3 = props.liveChatContextFromCache) === null || _props$liveChatContex3 === void 0 ? void 0 : (_props$liveChatContex4 = _props$liveChatContex3.domainStates) === null || _props$liveChatContex4 === void 0 ? void 0 : _props$liveChatContex4.telemetryInternalData;
|
|
35
31
|
} else {
|
|
32
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$chatSDK3, _props$chatSDK3$omnic;
|
|
33
|
+
|
|
36
34
|
let telemetryData = { ..._defaultTelemetryInternalData.defaultInternalTelemetryData,
|
|
37
35
|
telemetryConfig: Object.assign({}, _defaultTelemetryConfiguration.defaultTelemetryConfiguration, telemetryConfig),
|
|
38
36
|
ariaConfig: Object.assign({}, _defaultAriaConfig.defaultAriaConfig, telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.ariaConfigurations)
|
|
@@ -43,7 +41,13 @@ const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
telemetryData = _TelemetryHelper.TelemetryHelper.addWidgetDataToTelemetry(telemetryConfig, telemetryData);
|
|
46
|
-
telemetryData.OCChatSDKVersion =
|
|
44
|
+
telemetryData.OCChatSDKVersion = telemetryConfig.OCChatSDKVersion ?? "0.0.0-0";
|
|
45
|
+
telemetryData.chatComponentVersion = telemetryConfig.chatComponentVersion ?? "0.0.0-0";
|
|
46
|
+
telemetryData.chatWidgetVersion = telemetryConfig.chatWidgetVersion ?? "0.0.0-0";
|
|
47
|
+
telemetryData.orgId = (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId;
|
|
48
|
+
telemetryData.widgetId = (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId;
|
|
49
|
+
telemetryData.orgUrl = (_props$chatSDK3 = props.chatSDK) === null || _props$chatSDK3 === void 0 ? void 0 : (_props$chatSDK3$omnic = _props$chatSDK3.omnichannelConfig) === null || _props$chatSDK3$omnic === void 0 ? void 0 : _props$chatSDK3$omnic.orgUrl;
|
|
50
|
+
_TelemetryManager.TelemetryManager.InternalTelemetryData = telemetryData;
|
|
47
51
|
dispatch({
|
|
48
52
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_TELEMETRY_DATA,
|
|
49
53
|
payload: telemetryData
|
|
@@ -7,27 +7,31 @@ exports.setPostChatContextAndLoadSurvey = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
9
|
|
|
10
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
11
|
+
|
|
12
|
+
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
13
|
+
|
|
10
14
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
11
15
|
|
|
12
16
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
13
17
|
|
|
14
|
-
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
15
|
-
|
|
16
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
-
const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch,
|
|
19
|
+
const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
|
|
18
20
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
if (!persistedChat) {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
const context = await chatSDK.getPostChatSurveyContext();
|
|
24
|
+
|
|
25
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
26
|
+
Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
|
|
27
|
+
Description: "Postchat context call succeed."
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
dispatch({
|
|
31
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
|
|
32
|
+
payload: context
|
|
33
|
+
});
|
|
34
|
+
}
|
|
31
35
|
} catch (ex) {
|
|
32
36
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
33
37
|
Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallFailed,
|
|
@@ -35,21 +39,19 @@ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, loadSurvey) =>
|
|
|
35
39
|
exception: ex
|
|
36
40
|
}
|
|
37
41
|
});
|
|
38
|
-
}
|
|
39
|
-
/* -true: setPostChatContextAndLoadSurvey is called after passing all checks from ConfirmationPane and endChatMiddleware in usual scenario.
|
|
40
|
-
-false: Below if condition is needed for multi-tab scenarios. So when agent ends a chat and customer has opened chat in multiple tabs,
|
|
41
|
-
all tabs should show post chat survey as per existing functionality. But when an agent end a conversation, Omnichannel SDK
|
|
42
|
-
getPostChatSurveyContext returns as invalid conversation. To avoid that, caching the survey url is needed after chat starts and
|
|
43
|
-
in this case loadSurvey is false
|
|
44
|
-
*/
|
|
42
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
43
|
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
|
|
46
|
+
dispatch({
|
|
47
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
48
|
+
payload: _ConversationState.ConversationState.Loading
|
|
49
|
+
});
|
|
48
50
|
dispatch({
|
|
49
51
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
50
52
|
payload: _ConversationState.ConversationState.Postchat
|
|
51
53
|
});
|
|
52
|
-
}
|
|
54
|
+
});
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
exports.setPostChatContextAndLoadSurvey = setPostChatContextAndLoadSurvey;
|
|
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.prepareStartChat = exports.initStartChat = void 0;
|
|
7
7
|
|
|
8
|
-
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
-
|
|
10
8
|
var _Constants = require("../../../common/Constants");
|
|
11
9
|
|
|
10
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
11
|
+
|
|
12
12
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
13
13
|
|
|
14
|
+
var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
|
|
15
|
+
|
|
14
16
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
15
17
|
|
|
16
18
|
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
@@ -23,66 +25,82 @@ var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
|
23
25
|
|
|
24
26
|
var _createAdapter = require("./createAdapter");
|
|
25
27
|
|
|
28
|
+
var _newMessageEventHandler = require("../../../plugins/newMessageEventHandler");
|
|
29
|
+
|
|
26
30
|
var _utils = require("../../../common/utils");
|
|
27
31
|
|
|
28
32
|
var _reconnectChatHelper = require("./reconnectChatHelper");
|
|
29
33
|
|
|
30
|
-
var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
|
|
31
|
-
|
|
32
34
|
var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
|
|
33
35
|
|
|
36
|
+
var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
|
|
37
|
+
|
|
34
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
39
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
36
|
-
|
|
37
|
-
const parseToJson = false;
|
|
38
|
-
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
39
|
-
const showPrechat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
40
|
+
var _props$reconnectChatP;
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
|
|
43
|
+
return;
|
|
44
|
+
} // Redirecting if unauthenticated reconnect chat expired
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
dispatch({
|
|
49
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
50
|
-
payload: _ConversationState.ConversationState.ReconnectChat
|
|
51
|
-
});
|
|
52
|
-
} else if (showPrechat) {
|
|
53
|
-
dispatch({
|
|
54
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
55
|
-
payload: preChatSurveyResponse
|
|
56
|
-
});
|
|
57
|
-
dispatch({
|
|
58
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
59
|
-
payload: _ConversationState.ConversationState.Prechat
|
|
60
|
-
});
|
|
46
|
+
|
|
47
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
48
|
+
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
49
|
+
|
|
50
|
+
await (0, _reconnectChatHelper.handleRedirectUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
61
51
|
} else {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
// Getting PreChat Survey Context
|
|
53
|
+
const parseToJson = false;
|
|
54
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
55
|
+
const showPrechat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
56
|
+
|
|
57
|
+
const reconnectId = await (0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK);
|
|
58
|
+
|
|
59
|
+
if (reconnectId) {
|
|
60
|
+
dispatch({
|
|
61
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
62
|
+
payload: reconnectId
|
|
63
|
+
});
|
|
64
|
+
dispatch({
|
|
65
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
66
|
+
payload: _ConversationState.ConversationState.ReconnectChat
|
|
67
|
+
});
|
|
68
|
+
} else if (showPrechat) {
|
|
69
|
+
dispatch({
|
|
70
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
71
|
+
payload: preChatSurveyResponse
|
|
72
|
+
});
|
|
73
|
+
dispatch({
|
|
74
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
75
|
+
payload: _ConversationState.ConversationState.Prechat
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
dispatch({
|
|
79
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
80
|
+
payload: _ConversationState.ConversationState.Loading
|
|
81
|
+
});
|
|
82
|
+
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
83
|
+
}
|
|
67
84
|
}
|
|
68
85
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
86
|
|
|
70
87
|
|
|
71
88
|
exports.prepareStartChat = prepareStartChat;
|
|
72
89
|
|
|
73
|
-
const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
|
|
90
|
+
const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
|
|
74
91
|
try {
|
|
75
|
-
var _TelemetryTimers$Widg;
|
|
92
|
+
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
76
93
|
|
|
77
94
|
try {
|
|
78
|
-
|
|
95
|
+
_TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
|
|
96
|
+
|
|
97
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
79
98
|
Event: _TelemetryConstants.TelemetryEvent.StartChatSDKCall
|
|
80
99
|
});
|
|
81
100
|
|
|
82
101
|
await chatSDK.startChat(params);
|
|
83
|
-
_TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
|
|
84
102
|
} catch (error) {
|
|
85
|
-
_TelemetryHelper.TelemetryHelper.
|
|
103
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
86
104
|
Event: _TelemetryConstants.TelemetryEvent.StartChatMethodException,
|
|
87
105
|
ExceptionDetails: {
|
|
88
106
|
exception: `Failed to setup startChat: ${error}`
|
|
@@ -91,24 +109,41 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
|
|
|
91
109
|
}
|
|
92
110
|
|
|
93
111
|
const newAdapter = await (0, _createAdapter.createAdapter)(chatSDK);
|
|
94
|
-
setAdapter(newAdapter);
|
|
112
|
+
setAdapter(newAdapter);
|
|
113
|
+
const chatToken = await chatSDK.getChatToken();
|
|
114
|
+
newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe((0, _newMessageEventHandler.createOnNewAdapterActivityHandler)(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
|
|
95
115
|
|
|
96
|
-
if (
|
|
116
|
+
if (!persistedState) {
|
|
97
117
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
-
|
|
118
|
+
if (chatSDK !== null && chatSDK !== void 0 && chatSDK.getVoiceVideoCalling) {
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
+
const chatToken = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatToken());
|
|
121
|
+
dispatch({
|
|
122
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
123
|
+
payload: chatToken
|
|
124
|
+
});
|
|
125
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
99
129
|
dispatch({
|
|
100
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
101
|
-
payload:
|
|
130
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
131
|
+
payload: liveChatContext
|
|
102
132
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, false);
|
|
106
|
-
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch); // Set app state to Active
|
|
133
|
+
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
134
|
+
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch); // Set app state to Active
|
|
107
135
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
136
|
+
dispatch({
|
|
137
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
138
|
+
payload: _ConversationState.ConversationState.Active
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
dispatch({
|
|
142
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
143
|
+
payload: persistedState
|
|
144
|
+
});
|
|
145
|
+
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
|
|
146
|
+
}
|
|
112
147
|
|
|
113
148
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
114
149
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
@@ -117,9 +152,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
|
|
|
117
152
|
});
|
|
118
153
|
} catch (ex) {
|
|
119
154
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
120
|
-
Event: _TelemetryConstants.TelemetryEvent.
|
|
155
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
121
156
|
ExceptionDetails: {
|
|
122
|
-
Exception: `
|
|
157
|
+
Exception: `Widget load Failed: ${ex}`
|
|
123
158
|
}
|
|
124
159
|
});
|
|
125
160
|
|
|
@@ -137,6 +172,30 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
|
|
|
137
172
|
});
|
|
138
173
|
}
|
|
139
174
|
}
|
|
140
|
-
};
|
|
175
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
exports.initStartChat = initStartChat;
|
|
179
|
+
|
|
180
|
+
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
181
|
+
var _DataStoreManager$cli, _persistedState$domai;
|
|
141
182
|
|
|
142
|
-
|
|
183
|
+
const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(_Constants.Constants.widgetStateDataKey, "localStorage");
|
|
184
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
185
|
+
|
|
186
|
+
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext) {
|
|
187
|
+
var _persistedState$domai2;
|
|
188
|
+
|
|
189
|
+
dispatch({
|
|
190
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
191
|
+
payload: _ConversationState.ConversationState.Loading
|
|
192
|
+
});
|
|
193
|
+
const optionalParams = {
|
|
194
|
+
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai2 = persistedState.domainStates) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.liveChatContext
|
|
195
|
+
};
|
|
196
|
+
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
197
|
+
return true;
|
|
198
|
+
} else {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
@@ -16,12 +16,12 @@ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
|
16
16
|
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
17
17
|
|
|
18
18
|
// Defines startProactiveChat callback
|
|
19
|
-
const startProactiveChat = (dispatch,
|
|
19
|
+
const startProactiveChat = (dispatch, notificationConfig, enablePreChat, inNewWindow) => {
|
|
20
20
|
dispatch({
|
|
21
21
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
22
22
|
payload: {
|
|
23
|
-
proactiveChatBodyTitle:
|
|
24
|
-
proactiveChatEnablePrechat:
|
|
23
|
+
proactiveChatBodyTitle: notificationConfig && notificationConfig.message ? notificationConfig.message : "",
|
|
24
|
+
proactiveChatEnablePrechat: enablePreChat ?? false,
|
|
25
25
|
proactiveChatInNewWindow: inNewWindow ?? false
|
|
26
26
|
}
|
|
27
27
|
});
|