@microsoft/omnichannel-chat-widget 1.3.1-main.da9dc59 → 1.4.1-main.22cb7d3
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 +1 -1
- package/lib/cjs/assets/Icons.js +8 -2
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +2 -22
- package/lib/cjs/common/utils.js +19 -2
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -1
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +5 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +77 -17
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +6 -0
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +1 -1
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +11 -9
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +52 -33
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +5 -2
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +32 -13
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +6 -3
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +3 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +40 -101
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +92 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentContent.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentIcon.js +21 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/DownloadBlockedAttachment.js +36 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/FileScanStatus.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/MaliciousAttachment.js +24 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/ScanInProgressAttachment.js +24 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Spinner.js +41 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/esm/assets/Icons.js +4 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +2 -22
- package/lib/esm/common/utils.js +16 -0
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -2
- package/lib/esm/components/livechatwidget/common/createAdapter.js +5 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +76 -20
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +6 -0
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +1 -1
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +11 -9
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +55 -36
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +6 -3
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +32 -13
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +6 -3
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +36 -96
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +84 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentContent.js +9 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentIcon.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/DownloadBlockedAttachment.js +28 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/FileScanStatus.js +7 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/MaliciousAttachment.js +16 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/ScanInProgressAttachment.js +16 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Spinner.js +33 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/types/assets/Icons.d.ts +3 -0
- package/lib/types/common/utils.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +6 -2
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentContent.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentIcon.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/DownloadBlockedAttachment.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/FileScanStatus.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/MaliciousAttachment.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/ScanInProgressAttachment.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Spinner.d.ts +2 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +16 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +5 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import React, { useEffect, useState } from "react";
|
|
3
|
-
import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
|
|
3
|
+
import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, formatTemplateString, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
|
|
4
4
|
import { DimLayer } from "../dimlayer/DimLayer";
|
|
5
5
|
import { InputValidationPane } from "@microsoft/omnichannel-chat-components";
|
|
6
6
|
import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
|
|
@@ -10,6 +10,7 @@ import { Regex } from "../../common/Constants";
|
|
|
10
10
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
11
11
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
12
12
|
import useChatSDKStore from "../../hooks/useChatSDKStore";
|
|
13
|
+
import { defaultMiddlewareLocalizedTexts } from "../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
13
14
|
export const EmailTranscriptPaneStateful = props => {
|
|
14
15
|
var _props$controlProps;
|
|
15
16
|
const initialTabIndexMap = new Map();
|
|
@@ -46,6 +47,7 @@ export const EmailTranscriptPaneStateful = props => {
|
|
|
46
47
|
};
|
|
47
48
|
try {
|
|
48
49
|
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.emailLiveChatTranscript(chatTranscriptBody));
|
|
50
|
+
NotificationHandler.notifySuccess(NotificationScenarios.EmailAddressSaved, defaultMiddlewareLocalizedTexts === null || defaultMiddlewareLocalizedTexts === void 0 ? void 0 : defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS);
|
|
49
51
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
50
52
|
Event: TelemetryEvent.EmailTranscriptSent,
|
|
51
53
|
Description: "Transcript sent to email successfully."
|
|
@@ -57,7 +59,8 @@ export const EmailTranscriptPaneStateful = props => {
|
|
|
57
59
|
exception: ex
|
|
58
60
|
}
|
|
59
61
|
});
|
|
60
|
-
|
|
62
|
+
const message = formatTemplateString(defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR, [email]);
|
|
63
|
+
NotificationHandler.notifyError(NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? message);
|
|
61
64
|
}
|
|
62
65
|
},
|
|
63
66
|
onCancel: () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ConfirmationState, Constants, ConversationEndEntity } from "../../../common/Constants";
|
|
1
|
+
import { ConfirmationState, Constants, ConversationEndEntity, ParticipantType } from "../../../common/Constants";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
4
|
-
import { getConversationDetailsCall, getWidgetEndChatEventName
|
|
4
|
+
import { getConversationDetailsCall, getWidgetEndChatEventName } from "../../../common/utils";
|
|
5
5
|
import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
|
|
6
6
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
7
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
@@ -9,34 +9,43 @@ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidge
|
|
|
9
9
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
10
10
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
11
11
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
12
|
+
import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
12
13
|
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter
|
|
15
|
+
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
15
16
|
try {
|
|
16
|
-
var _conversationDetails$, _state$domainStates
|
|
17
|
+
var _conversationDetails$, _state$domainStates;
|
|
18
|
+
// Use Case: If call is ongoing, end the call by simulating end call button click
|
|
19
|
+
endVoiceVideoCallIfOngoing(chatSDK, dispatch);
|
|
17
20
|
const conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
18
21
|
|
|
19
|
-
// Use Case
|
|
22
|
+
// Use Case: When post chat is not configured
|
|
20
23
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : (_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === Constants.false) {
|
|
21
24
|
var _state$appStates;
|
|
22
25
|
// If ended by customer, just close chat
|
|
23
26
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.conversationEndedBy) === ConversationEndEntity.Customer) {
|
|
24
|
-
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true
|
|
27
|
+
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
25
28
|
}
|
|
26
|
-
//Use Case: If ended by Agent, stay chat in InActive state
|
|
29
|
+
// Use Case: If ended by Agent, stay chat in InActive state
|
|
27
30
|
return;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
//
|
|
31
|
-
|
|
33
|
+
// Register post chat participant type
|
|
34
|
+
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.User) {
|
|
35
|
+
dispatch({
|
|
36
|
+
type: LiveChatWidgetActionType.SET_POST_CHAT_PARTICIPANT_TYPE,
|
|
37
|
+
payload: conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType
|
|
38
|
+
});
|
|
39
|
+
}
|
|
32
40
|
|
|
41
|
+
// Use Case: Can render post chat scenarios
|
|
33
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
const postchatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext;
|
|
43
|
+
const postchatContext = (await getPostChatContext(chatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
|
|
35
44
|
if (postchatContext === undefined) {
|
|
36
45
|
var _state$appStates2;
|
|
37
46
|
// For Customer intiated conversations, just close chat widget
|
|
38
47
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Customer) {
|
|
39
|
-
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true
|
|
48
|
+
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
40
49
|
return;
|
|
41
50
|
}
|
|
42
51
|
|
|
@@ -47,10 +56,10 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
47
56
|
});
|
|
48
57
|
return;
|
|
49
58
|
}
|
|
50
|
-
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, true, true
|
|
59
|
+
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, true, true);
|
|
51
60
|
|
|
52
61
|
// Initiate post chat render
|
|
53
|
-
if (
|
|
62
|
+
if (postchatContext) {
|
|
54
63
|
await initiatePostChat(props, conversationDetails, state, dispatch, postchatContext);
|
|
55
64
|
return;
|
|
56
65
|
}
|
|
@@ -65,7 +74,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
65
74
|
|
|
66
75
|
//Close chat widget for any failure in embedded to allow to show start chat button
|
|
67
76
|
if (((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.hideStartChatButton) === false) {
|
|
68
|
-
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true
|
|
77
|
+
await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
69
78
|
}
|
|
70
79
|
} finally {
|
|
71
80
|
//Chat token clean up
|
|
@@ -74,8 +83,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
74
83
|
};
|
|
75
84
|
|
|
76
85
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
-
const endChat = async
|
|
78
|
-
let uwid = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : "";
|
|
86
|
+
const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
|
|
79
87
|
if (!skipEndChatSDK && chatSDK.conversation) {
|
|
80
88
|
try {
|
|
81
89
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
@@ -127,15 +135,39 @@ const endChat = async function (props, chatSDK, state, dispatch, setAdapter, set
|
|
|
127
135
|
closeChatWidget(dispatch, props, state);
|
|
128
136
|
}
|
|
129
137
|
}
|
|
130
|
-
if (postMessageToOtherTab
|
|
138
|
+
if (postMessageToOtherTab) {
|
|
131
139
|
const endChatEventName = await getEndChatEventName(chatSDK, props);
|
|
132
140
|
BroadcastService.postMessage({
|
|
133
141
|
eventName: endChatEventName,
|
|
134
|
-
payload:
|
|
142
|
+
payload: {
|
|
143
|
+
runtimeId: TelemetryManager.InternalTelemetryData.lcwRuntimeId
|
|
144
|
+
}
|
|
135
145
|
});
|
|
136
146
|
}
|
|
137
147
|
};
|
|
138
|
-
const
|
|
148
|
+
export const callingStateCleanUp = async dispatch => {
|
|
149
|
+
dispatch({
|
|
150
|
+
type: LiveChatWidgetActionType.SHOW_CALLING_CONTAINER,
|
|
151
|
+
payload: false
|
|
152
|
+
});
|
|
153
|
+
dispatch({
|
|
154
|
+
type: LiveChatWidgetActionType.SET_INCOMING_CALL,
|
|
155
|
+
payload: true
|
|
156
|
+
});
|
|
157
|
+
dispatch({
|
|
158
|
+
type: LiveChatWidgetActionType.DISABLE_VIDEO_CALL,
|
|
159
|
+
payload: true
|
|
160
|
+
});
|
|
161
|
+
dispatch({
|
|
162
|
+
type: LiveChatWidgetActionType.DISABLE_LOCAL_VIDEO,
|
|
163
|
+
payload: true
|
|
164
|
+
});
|
|
165
|
+
dispatch({
|
|
166
|
+
type: LiveChatWidgetActionType.DISABLE_REMOTE_VIDEO,
|
|
167
|
+
payload: true
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
export const endChatStateCleanUp = async dispatch => {
|
|
139
171
|
// Need to clear these states immediately when chat ended from OC.
|
|
140
172
|
dispatch({
|
|
141
173
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
@@ -150,7 +182,7 @@ const endChatStateCleanUp = async dispatch => {
|
|
|
150
182
|
payload: false
|
|
151
183
|
});
|
|
152
184
|
};
|
|
153
|
-
const closeChatStateCleanUp = async dispatch => {
|
|
185
|
+
export const closeChatStateCleanUp = async dispatch => {
|
|
154
186
|
dispatch({
|
|
155
187
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
156
188
|
payload: undefined
|
|
@@ -185,6 +217,30 @@ const closeChatStateCleanUp = async dispatch => {
|
|
|
185
217
|
}
|
|
186
218
|
});
|
|
187
219
|
};
|
|
220
|
+
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
222
|
+
export const endVoiceVideoCallIfOngoing = async (chatSDK, dispatch) => {
|
|
223
|
+
let callId = "";
|
|
224
|
+
try {
|
|
225
|
+
const voiceVideoCallingSdk = await chatSDK.getVoiceVideoCalling();
|
|
226
|
+
if (voiceVideoCallingSdk && voiceVideoCallingSdk.isInACall()) {
|
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
228
|
+
callId = voiceVideoCallingSdk.callId;
|
|
229
|
+
voiceVideoCallingSdk.stopCall();
|
|
230
|
+
TelemetryHelper.logCallingEvent(LogLevel.INFO, {
|
|
231
|
+
Event: TelemetryEvent.EndCallButtonClick
|
|
232
|
+
}, callId);
|
|
233
|
+
callingStateCleanUp(dispatch);
|
|
234
|
+
}
|
|
235
|
+
} catch (error) {
|
|
236
|
+
TelemetryHelper.logCallingEvent(LogLevel.ERROR, {
|
|
237
|
+
Event: TelemetryEvent.EndCallButtonClickException,
|
|
238
|
+
ExceptionDetails: {
|
|
239
|
+
exception: `Failed to End Call: ${error}`
|
|
240
|
+
}
|
|
241
|
+
}, callId);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
188
244
|
const closeChatWidget = (dispatch, props, state) => {
|
|
189
245
|
var _state$appStates3;
|
|
190
246
|
if (state !== null && state !== void 0 && (_state$appStates3 = state.appStates) !== null && _state$appStates3 !== void 0 && _state$appStates3.hideStartChatButton) {
|
|
@@ -63,6 +63,12 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
|
|
|
63
63
|
payload: ConversationEndEntity.Agent
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
+
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.User) {
|
|
67
|
+
dispatch({
|
|
68
|
+
type: LiveChatWidgetActionType.SET_POST_CHAT_PARTICIPANT_TYPE,
|
|
69
|
+
payload: conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType
|
|
70
|
+
});
|
|
71
|
+
}
|
|
66
72
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
67
73
|
Event: TelemetryEvent.ConversationEndedThreadEventReceived,
|
|
68
74
|
Description: "Conversation end by agent side or by timeout event received."
|
|
@@ -20,7 +20,7 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
|
|
|
20
20
|
// Get chat reconnect context
|
|
21
21
|
const reconnectChatContext = await getChatReconnectContext(chatSDK, props.chatConfig, props, isAuthenticatedChat);
|
|
22
22
|
|
|
23
|
-
//Redirect if enabled
|
|
23
|
+
// Redirect if enabled
|
|
24
24
|
if (reconnectChatContext !== null && reconnectChatContext !== void 0 && reconnectChatContext.redirectURL) {
|
|
25
25
|
var _props$reconnectChatP;
|
|
26
26
|
redirectPage(reconnectChatContext.redirectURL, (_props$reconnectChatP = props.reconnectChatPaneProps) === null || _props$reconnectChatP === void 0 ? void 0 : _props$reconnectChatP.redirectInSameWindow);
|
|
@@ -42,24 +42,25 @@ const setSurveyMode = async (props, participantType, state, dispatch) => {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
const renderSurvey = async (postChatContext, dispatch) => {
|
|
46
48
|
if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
47
49
|
setWidgetStateToInactive(dispatch);
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
52
|
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
51
|
-
await embedModePostChatWorkflow(
|
|
53
|
+
await embedModePostChatWorkflow(postChatContext, dispatch);
|
|
52
54
|
}
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
// Function for embed mode postchat workflow which is essentially same for both customer and agent
|
|
56
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
-
const embedModePostChatWorkflow = async (
|
|
58
|
-
var _state$domainStates2;
|
|
59
|
+
const embedModePostChatWorkflow = async (postChatContext, dispatch) => {
|
|
59
60
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
60
61
|
Event: TelemetryEvent.EmbedModePostChatWorkflowStarted
|
|
61
62
|
});
|
|
62
|
-
if (
|
|
63
|
+
if (postChatContext) {
|
|
63
64
|
dispatch({
|
|
64
65
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
65
66
|
payload: ConversationState.PostchatLoading
|
|
@@ -70,7 +71,7 @@ const embedModePostChatWorkflow = async (state, dispatch) => {
|
|
|
70
71
|
payload: ConversationState.Postchat
|
|
71
72
|
});
|
|
72
73
|
} else {
|
|
73
|
-
const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${
|
|
74
|
+
const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${postChatContext}`;
|
|
74
75
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
75
76
|
Event: TelemetryEvent.AppStatesException,
|
|
76
77
|
ExceptionDetails: {
|
|
@@ -86,7 +87,7 @@ const initiatePostChat = async (props, conversationDetailsParam, state, dispatch
|
|
|
86
87
|
conversationDetails = conversationDetailsParam;
|
|
87
88
|
const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
|
|
88
89
|
await setSurveyMode(props, participantType, state, dispatch);
|
|
89
|
-
await renderSurvey(
|
|
90
|
+
await renderSurvey(postchatContext, dispatch);
|
|
90
91
|
};
|
|
91
92
|
|
|
92
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -99,8 +100,8 @@ const isPostChatEnabled = (props, state) => {
|
|
|
99
100
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
101
|
const getPostChatContext = async (chatSDK, state, dispatch) => {
|
|
101
102
|
try {
|
|
102
|
-
var _state$
|
|
103
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
103
|
+
var _state$domainStates2;
|
|
104
|
+
if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
|
|
104
105
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
106
|
const context = await chatSDK.getPostChatSurveyContext();
|
|
106
107
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
@@ -111,6 +112,7 @@ const getPostChatContext = async (chatSDK, state, dispatch) => {
|
|
|
111
112
|
type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
|
|
112
113
|
payload: context
|
|
113
114
|
});
|
|
115
|
+
return context;
|
|
114
116
|
}
|
|
115
117
|
} catch (error) {
|
|
116
118
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
@@ -6,9 +6,9 @@ import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveW
|
|
|
6
6
|
import { Stack } from "@fluentui/react";
|
|
7
7
|
import React, { useEffect, useRef, useState } from "react";
|
|
8
8
|
import { checkIfConversationStillValid, initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
|
|
9
|
-
import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString,
|
|
9
|
+
import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty } from "../../../common/utils";
|
|
10
10
|
import { defaultClientDataStoreProvider, isCookieAllowed } from "../../../common/storage/default/defaultClientDataStoreProvider";
|
|
11
|
-
import { endChat, prepareEndChat } from "../common/endChat";
|
|
11
|
+
import { endChat, endChatStateCleanUp, prepareEndChat } from "../common/endChat";
|
|
12
12
|
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "../common/reconnectChatHelper";
|
|
13
13
|
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
14
14
|
import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
|
|
@@ -30,7 +30,7 @@ import PreChatSurveyPaneStateful from "../../prechatsurveypanestateful/PreChatSu
|
|
|
30
30
|
import ProactiveChatPaneStateful from "../../proactivechatpanestateful/ProactiveChatPaneStateful";
|
|
31
31
|
import ReconnectChatPaneStateful from "../../reconnectchatpanestateful/ReconnectChatPaneStateful";
|
|
32
32
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
33
|
-
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
33
|
+
import { TelemetryManager, TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
34
34
|
import WebChatContainerStateful from "../../webchatcontainerstateful/WebChatContainerStateful";
|
|
35
35
|
import createDownloadTranscriptProps from "../common/createDownloadTranscriptProps";
|
|
36
36
|
import { createFooter } from "../common/createFooter";
|
|
@@ -50,8 +50,10 @@ import { startProactiveChat } from "../common/startProactiveChat";
|
|
|
50
50
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
51
51
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
52
52
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
53
|
+
import { defaultAdaptiveCardStyles } from "../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles";
|
|
54
|
+
import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
|
|
53
55
|
export const LiveChatWidgetStateful = props => {
|
|
54
|
-
var _props$webChatContain, _props$styleProps,
|
|
56
|
+
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$contro10, _livechatProps$compon8, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$compon11, _livechatProps$compon12;
|
|
55
57
|
const [state, dispatch] = useChatContextStore();
|
|
56
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
59
|
const [adapter, setAdapter] = useChatAdapterStore();
|
|
@@ -75,17 +77,20 @@ export const LiveChatWidgetStateful = props => {
|
|
|
75
77
|
|
|
76
78
|
//Scrollbar styles
|
|
77
79
|
const scrollbarProps = Object.assign({}, defaultScrollBarProps, props === null || props === void 0 ? void 0 : props.scrollBarProps);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
|
|
81
|
+
// In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
|
|
82
|
+
if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
|
|
83
|
+
var _chatSDK$omnichannelC, _props$controlProps2;
|
|
84
|
+
const broadcastServiceChannelName = getBroadcastChannelName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.widgetId, ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.widgetInstanceId) ?? "");
|
|
85
|
+
BroadcastServiceInitialize(broadcastServiceChannelName);
|
|
86
|
+
}
|
|
80
87
|
TelemetryTimers.LcwLoadToChatButtonTimer = createTimer();
|
|
81
|
-
const widgetElementId = ((_props$
|
|
88
|
+
const widgetElementId = ((_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.id) || "oc-lcw";
|
|
82
89
|
const currentMessageCountRef = useRef(0);
|
|
83
90
|
let widgetStateEventId = "";
|
|
84
91
|
const lastLWICheckTimeRef = useRef(0);
|
|
85
92
|
let optionalParams;
|
|
86
93
|
let activeCachedChatExist = false;
|
|
87
|
-
const uwid = useRef(""); // its an uniqueid per chatr instance
|
|
88
|
-
|
|
89
94
|
const setOptionalParams = () => {
|
|
90
95
|
var _state$appStates, _state$domainStates, _state$appStates3;
|
|
91
96
|
if (!isUndefinedOrEmpty((_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.reconnectId)) {
|
|
@@ -170,8 +175,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
170
175
|
// Add default localStorage support for widget
|
|
171
176
|
const widgetCacheId = getWidgetCacheIdfromProps(props);
|
|
172
177
|
if (props.contextDataStore === undefined) {
|
|
173
|
-
var _props$
|
|
174
|
-
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$
|
|
178
|
+
var _props$controlProps4;
|
|
179
|
+
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.cacheTtlInMins) ?? Constants.CacheTtlInMinutes;
|
|
175
180
|
const storageType = (props === null || props === void 0 ? void 0 : props.useSessionStorage) === true ? StorageType.sessionStorage : StorageType.localStorage;
|
|
176
181
|
DataStoreManager.clientDataStore = defaultClientDataStoreProvider(cacheTtlInMins, storageType);
|
|
177
182
|
registerBroadcastServiceForStorage(widgetCacheId, cacheTtlInMins, storageType);
|
|
@@ -180,30 +185,29 @@ export const LiveChatWidgetStateful = props => {
|
|
|
180
185
|
}
|
|
181
186
|
};
|
|
182
187
|
useEffect(() => {
|
|
183
|
-
var _props$
|
|
188
|
+
var _props$controlProps5, _props$controlProps6, _props$controlProps7, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps9, _props$chatConfig2, _props$chatConfig2$Ch, _state$appStates5;
|
|
184
189
|
state.domainStates.confirmationPaneConfirmedOptionClicked = false;
|
|
185
190
|
state.domainStates.confirmationState = ConfirmationState.NotSet;
|
|
186
191
|
setupClientDataStore();
|
|
187
192
|
registerTelemetryLoggers(props, dispatch);
|
|
188
193
|
createInternetConnectionChangeHandler();
|
|
189
|
-
uwid.current = newGuid();
|
|
190
194
|
dispatch({
|
|
191
195
|
type: LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
|
|
192
196
|
payload: widgetElementId
|
|
193
197
|
});
|
|
194
198
|
dispatch({
|
|
195
199
|
type: LiveChatWidgetActionType.SET_START_CHAT_BUTTON_DISPLAY,
|
|
196
|
-
payload: ((_props$
|
|
200
|
+
payload: ((_props$controlProps5 = props.controlProps) === null || _props$controlProps5 === void 0 ? void 0 : _props$controlProps5.hideStartChatButton) || false
|
|
197
201
|
});
|
|
198
202
|
dispatch({
|
|
199
203
|
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
200
204
|
payload: false
|
|
201
205
|
});
|
|
202
|
-
if ((_props$
|
|
203
|
-
var _props$
|
|
206
|
+
if ((_props$controlProps6 = props.controlProps) !== null && _props$controlProps6 !== void 0 && _props$controlProps6.widgetInstanceId && !isNullOrEmptyString((_props$controlProps7 = props.controlProps) === null || _props$controlProps7 === void 0 ? void 0 : _props$controlProps7.widgetInstanceId)) {
|
|
207
|
+
var _props$controlProps8;
|
|
204
208
|
dispatch({
|
|
205
209
|
type: LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID,
|
|
206
|
-
payload: (_props$
|
|
210
|
+
payload: (_props$controlProps8 = props.controlProps) === null || _props$controlProps8 === void 0 ? void 0 : _props$controlProps8.widgetInstanceId
|
|
207
211
|
});
|
|
208
212
|
}
|
|
209
213
|
if (((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_callingoptions) !== E2VVOptions.NoCalling) {
|
|
@@ -222,7 +226,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
222
226
|
}
|
|
223
227
|
|
|
224
228
|
// Initialize global dir
|
|
225
|
-
const globalDir = ((_props$
|
|
229
|
+
const globalDir = ((_props$controlProps9 = props.controlProps) === null || _props$controlProps9 === void 0 ? void 0 : _props$controlProps9.dir) ?? getLocaleDirection((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Ch = _props$chatConfig2.ChatWidgetLanguage) === null || _props$chatConfig2$Ch === void 0 ? void 0 : _props$chatConfig2$Ch.msdyn_localeid);
|
|
226
230
|
dispatch({
|
|
227
231
|
type: LiveChatWidgetActionType.SET_GLOBAL_DIR,
|
|
228
232
|
payload: globalDir
|
|
@@ -258,7 +262,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
258
262
|
|
|
259
263
|
// useEffect for custom context
|
|
260
264
|
useEffect(() => {
|
|
261
|
-
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$
|
|
265
|
+
var _chatSDK$omnichannelC2, _chatSDK$omnichannelC3, _props$controlProps11;
|
|
262
266
|
// Add the custom context on receiving the SetCustomContext event
|
|
263
267
|
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
264
268
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
@@ -291,8 +295,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
291
295
|
BroadcastService.getMessageByEventName(BroadcastEvent.HideChatVisibilityChangeEvent).subscribe(async event => {
|
|
292
296
|
var _event$payload;
|
|
293
297
|
if ((event === null || event === void 0 ? void 0 : (_event$payload = event.payload) === null || _event$payload === void 0 ? void 0 : _event$payload.isChatHidden) !== undefined) {
|
|
294
|
-
var _props$
|
|
295
|
-
if ((_props$
|
|
298
|
+
var _props$controlProps10;
|
|
299
|
+
if ((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideStartChatButton) {
|
|
296
300
|
var _event$payload2;
|
|
297
301
|
dispatch({
|
|
298
302
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -319,23 +323,27 @@ export const LiveChatWidgetStateful = props => {
|
|
|
319
323
|
|
|
320
324
|
// Start chat from SDK Event
|
|
321
325
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
|
|
322
|
-
var _msg$payload4;
|
|
326
|
+
var _msg$payload4, _msg$payload5, _msg$payload6;
|
|
327
|
+
// If the startChat event is not initiated by the same tab. Ignore the call
|
|
328
|
+
if (!isNullOrUndefined(msg === null || msg === void 0 ? void 0 : (_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
323
331
|
let stateWithUpdatedContext = state;
|
|
324
|
-
if (msg !== null && msg !== void 0 && (_msg$
|
|
325
|
-
var _msg$
|
|
332
|
+
if (msg !== null && msg !== void 0 && (_msg$payload6 = msg.payload) !== null && _msg$payload6 !== void 0 && _msg$payload6.customContext) {
|
|
333
|
+
var _msg$payload7, _msg$payload8;
|
|
326
334
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
327
335
|
Event: TelemetryEvent.CustomContextReceived,
|
|
328
336
|
Description: "CustomContext received through startChat event."
|
|
329
337
|
});
|
|
330
338
|
dispatch({
|
|
331
339
|
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
332
|
-
payload: msg === null || msg === void 0 ? void 0 : (_msg$
|
|
340
|
+
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload7 = msg.payload) === null || _msg$payload7 === void 0 ? void 0 : _msg$payload7.customContext
|
|
333
341
|
});
|
|
334
342
|
stateWithUpdatedContext = {
|
|
335
343
|
...state,
|
|
336
344
|
domainStates: {
|
|
337
345
|
...state.domainStates,
|
|
338
|
-
customContext: msg === null || msg === void 0 ? void 0 : (_msg$
|
|
346
|
+
customContext: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
|
|
339
347
|
}
|
|
340
348
|
};
|
|
341
349
|
}
|
|
@@ -411,11 +419,18 @@ export const LiveChatWidgetStateful = props => {
|
|
|
411
419
|
});
|
|
412
420
|
|
|
413
421
|
// Listen to end chat event from other tabs
|
|
414
|
-
const endChatEventName = getWidgetEndChatEventName(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$
|
|
422
|
+
const endChatEventName = getWidgetEndChatEventName(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$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
415
423
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
416
|
-
|
|
417
|
-
if (msg.payload !==
|
|
424
|
+
var _msg$payload9;
|
|
425
|
+
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
418
426
|
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
427
|
+
endChatStateCleanUp(dispatch);
|
|
428
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
429
|
+
chatSDK.requestId = uuidv4();
|
|
430
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
431
|
+
chatSDK.chatToken = {};
|
|
432
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
433
|
+
chatSDK.reconnectId = null;
|
|
419
434
|
return;
|
|
420
435
|
}
|
|
421
436
|
});
|
|
@@ -543,13 +558,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
543
558
|
|
|
544
559
|
// If start chat failed, and C2 is trying to close chat widget
|
|
545
560
|
if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed || (state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === ConversationState.Postchat) {
|
|
546
|
-
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true
|
|
561
|
+
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true);
|
|
547
562
|
return;
|
|
548
563
|
}
|
|
549
564
|
|
|
550
565
|
// Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
|
|
551
566
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === ConversationState.InActive) {
|
|
552
|
-
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true
|
|
567
|
+
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
553
568
|
return;
|
|
554
569
|
}
|
|
555
570
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === ConversationEndEntity.Bot) {
|
|
@@ -560,7 +575,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
560
575
|
}
|
|
561
576
|
|
|
562
577
|
// All other cases
|
|
563
|
-
prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter
|
|
578
|
+
prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
|
|
564
579
|
}, [state === null || state === void 0 ? void 0 : (_state$appStates14 = state.appStates) === null || _state$appStates14 === void 0 ? void 0 : _state$appStates14.conversationEndedBy]);
|
|
565
580
|
|
|
566
581
|
// Publish chat widget state
|
|
@@ -618,13 +633,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
618
633
|
};
|
|
619
634
|
const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
620
635
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
621
|
-
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab
|
|
636
|
+
const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab);
|
|
622
637
|
const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
|
|
623
638
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
624
639
|
const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
|
|
625
640
|
const confirmationPaneProps = initConfirmationPropsComposer(props);
|
|
626
641
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
627
|
-
const prepareEndChatRelay = () => prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter
|
|
642
|
+
const prepareEndChatRelay = () => prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter);
|
|
628
643
|
const webChatProps = initWebChatComposer(props, state, dispatch, chatSDK, endChatRelay);
|
|
629
644
|
const downloadTranscriptProps = createDownloadTranscriptProps(props.downloadTranscriptProps, {
|
|
630
645
|
...(defaultWebChatContainerStatefulProps === null || defaultWebChatContainerStatefulProps === void 0 ? void 0 : defaultWebChatContainerStatefulProps.webChatStyles),
|
|
@@ -636,7 +651,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
636
651
|
};
|
|
637
652
|
const chatWidgetDraggableConfig = {
|
|
638
653
|
elementId: widgetElementId,
|
|
639
|
-
channel: ((_props$
|
|
654
|
+
channel: ((_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "lcw",
|
|
640
655
|
disabled: ((_props$draggableChatW = props.draggableChatWidgetProps) === null || _props$draggableChatW === void 0 ? void 0 : _props$draggableChatW.disabled) === true ?? false // Draggable by default, unless explicitly disabled
|
|
641
656
|
};
|
|
642
657
|
|
|
@@ -668,7 +683,11 @@ export const LiveChatWidgetStateful = props => {
|
|
|
668
683
|
background: ${scrollbarProps.thumbHoverColor};
|
|
669
684
|
}
|
|
670
685
|
`), /*#__PURE__*/React.createElement(DraggableChatWidget, chatWidgetDraggableConfig, /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
|
|
671
|
-
styleOptions:
|
|
686
|
+
styleOptions: {
|
|
687
|
+
...webChatStyles,
|
|
688
|
+
bubbleBackground: ((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : (_props$webChatContain8 = _props$webChatContain7.adaptiveCardStyles) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.background) ?? defaultAdaptiveCardStyles.background,
|
|
689
|
+
bubbleTextColor: ((_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : (_props$webChatContain10 = _props$webChatContain9.adaptiveCardStyles) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.color) ?? defaultAdaptiveCardStyles.color
|
|
690
|
+
},
|
|
672
691
|
directLine: ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? defaultWebChatContainerStatefulProps.directLine
|
|
673
692
|
}), /*#__PURE__*/React.createElement(Stack, {
|
|
674
693
|
id: widgetElementId,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import React, { useEffect } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { ParticipantType } from "../../common/Constants";
|
|
4
4
|
import { CustomerVoiceEvents } from "./enums/CustomerVoiceEvents";
|
|
5
5
|
import { PostChatSurveyMode } from "./enums/PostChatSurveyMode";
|
|
6
6
|
import { PostChatSurveyPane } from "@microsoft/omnichannel-chat-components";
|
|
@@ -18,14 +18,17 @@ const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, co
|
|
|
18
18
|
return surveyLink;
|
|
19
19
|
};
|
|
20
20
|
export const PostChatSurveyPaneStateful = props => {
|
|
21
|
-
var _props$styleProps, _state$appStates,
|
|
21
|
+
var _props$styleProps, _state$appStates, _props$controlProps;
|
|
22
22
|
const [state] = useChatContextStore();
|
|
23
23
|
const generalStyleProps = Object.assign({}, defaultGeneralPostChatSurveyPaneStyleProps, (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyleProps, {
|
|
24
24
|
display: state.appStates.isMinimized ? "none" : "contents"
|
|
25
25
|
});
|
|
26
26
|
let surveyInviteLink = "";
|
|
27
27
|
const surveyMode = (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.selectedSurveyMode) === PostChatSurveyMode.Embed;
|
|
28
|
-
if (
|
|
28
|
+
if (state.domainStates.postChatContext.botSurveyInviteLink &&
|
|
29
|
+
// Bot survey enabled
|
|
30
|
+
state.appStates.postChatParticipantType === ParticipantType.Bot) {
|
|
31
|
+
// Only Bot has engaged
|
|
29
32
|
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|
|
30
33
|
} else {
|
|
31
34
|
surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
|