@microsoft/omnichannel-chat-widget 0.1.0-main.488d6f1 → 0.1.0-main.4eb4d1f
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 +35 -11
- package/lib/cjs/common/Constants.js +52 -6
- package/lib/cjs/common/telemetry/TelemetryConstants.js +58 -6
- package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +17 -6
- package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
- package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +33 -13
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +76 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -4
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -42
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -2
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
- package/lib/cjs/components/headerstateful/HeaderStateful.js +3 -9
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +9 -1
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -17
- package/lib/cjs/components/livechatwidget/common/endChat.js +94 -11
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +1 -1
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +35 -6
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +115 -22
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +6 -17
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -9
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +169 -50
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +233 -78
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +19 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +25 -48
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +45 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +9 -7
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +8 -3
- package/lib/cjs/contexts/createReducer.js +16 -10
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/cjs/plugins/newMessageEventHandler.js +99 -0
- package/lib/esm/common/Constants.js +48 -5
- package/lib/esm/common/telemetry/TelemetryConstants.js +54 -5
- package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +15 -6
- package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
- package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +36 -14
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +55 -1
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -7
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -37
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -2
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
- package/lib/esm/components/headerstateful/HeaderStateful.js +3 -9
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -18
- package/lib/esm/components/livechatwidget/common/endChat.js +91 -13
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +1 -1
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +30 -7
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +104 -22
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +5 -14
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -9
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +166 -52
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +219 -78
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +20 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +23 -46
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +32 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +9 -7
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +8 -3
- package/lib/esm/contexts/createReducer.js +16 -9
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/esm/plugins/newMessageEventHandler.js +82 -0
- package/lib/types/common/Constants.d.ts +26 -2
- package/lib/types/common/interfaces/IContextDataStore.d.ts +2 -2
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +42 -4
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +3 -1
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
- package/lib/types/common/utils.d.ts +7 -1
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +4 -4
- package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -2
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -1
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- 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 +2 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +10 -8
- package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
- package/package.json +9 -11
|
@@ -9,7 +9,8 @@ import createAttachmentMiddleware from "../../../webchatcontainerstateful/webcha
|
|
|
9
9
|
import { createAvatarMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware";
|
|
10
10
|
import { createMarkdown } from "../createMarkdown";
|
|
11
11
|
import { groupActivitiesMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware";
|
|
12
|
-
import { typingIndicatorMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware";
|
|
12
|
+
import { typingIndicatorMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware";
|
|
13
|
+
import { createWebChatTelemetry } from "../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger"; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
14
|
|
|
14
15
|
export const dummyDefaultProps = {
|
|
15
16
|
audioNotificationProps: {
|
|
@@ -252,18 +253,6 @@ export const dummyDefaultProps = {
|
|
|
252
253
|
width: "50px",
|
|
253
254
|
fontSize: "18px"
|
|
254
255
|
},
|
|
255
|
-
currentCallTimerStyleProps: {
|
|
256
|
-
borderRadius: "2px",
|
|
257
|
-
margin: "1px",
|
|
258
|
-
color: "#FFFFFF",
|
|
259
|
-
paddingTop: "18px",
|
|
260
|
-
fontSize: 12,
|
|
261
|
-
fontFamily: "Segoe UI, Arial, sans-serif",
|
|
262
|
-
backgroundColor: "darkgrey",
|
|
263
|
-
height: "45px",
|
|
264
|
-
width: "50px",
|
|
265
|
-
textAlign: "center"
|
|
266
|
-
},
|
|
267
256
|
videoTileStyleProps: {
|
|
268
257
|
width: "100%",
|
|
269
258
|
marginLeft: "auto",
|
|
@@ -327,7 +316,9 @@ export const dummyDefaultProps = {
|
|
|
327
316
|
hideChatTextContainer: false,
|
|
328
317
|
hideChatSubtitle: false,
|
|
329
318
|
hideChatTitle: false,
|
|
330
|
-
hideNotificationBubble: true
|
|
319
|
+
hideNotificationBubble: true,
|
|
320
|
+
unreadMessageString: "new messages",
|
|
321
|
+
largeUnreadMessageString: "99+"
|
|
331
322
|
},
|
|
332
323
|
styleProps: {
|
|
333
324
|
generalStyleProps: {
|
|
@@ -1422,9 +1413,9 @@ export const dummyDefaultProps = {
|
|
|
1422
1413
|
startNewChatButtonClassName: undefined
|
|
1423
1414
|
}
|
|
1424
1415
|
},
|
|
1425
|
-
authClientFunction: undefined,
|
|
1426
1416
|
isReconnectEnabled: undefined,
|
|
1427
|
-
reconnectId: undefined
|
|
1417
|
+
reconnectId: undefined,
|
|
1418
|
+
redirectInSameWindow: undefined
|
|
1428
1419
|
},
|
|
1429
1420
|
styleProps: {
|
|
1430
1421
|
generalStyles: {
|
|
@@ -1496,7 +1487,7 @@ export const dummyDefaultProps = {
|
|
|
1496
1487
|
internalErrorBoxClass: undefined,
|
|
1497
1488
|
internalRenderErrorBox: undefined,
|
|
1498
1489
|
locale: "en-US",
|
|
1499
|
-
onTelemetry:
|
|
1490
|
+
onTelemetry: createWebChatTelemetry(),
|
|
1500
1491
|
overrideLocalizedStrings: undefined,
|
|
1501
1492
|
renderMarkdown: createMarkdown(false, false),
|
|
1502
1493
|
scrollToEndButtonMiddleware: undefined,
|
|
@@ -1686,7 +1677,12 @@ export const dummyDefaultProps = {
|
|
|
1686
1677
|
MIDDLEWARE_MESSAGE_RETRY: "Retry",
|
|
1687
1678
|
PRECHAT_REQUIRED_FIELD_MISSING_MESSAGE: "{0} field is required",
|
|
1688
1679
|
MARKDOWN_EXTERNAL_LINK_ALT: "Opens in a new window; external."
|
|
1680
|
+
},
|
|
1681
|
+
botMagicCode: {
|
|
1682
|
+
disabled: false,
|
|
1683
|
+
fwdUrl: ""
|
|
1689
1684
|
}
|
|
1690
1685
|
},
|
|
1691
|
-
telemetryConfig: undefined
|
|
1686
|
+
telemetryConfig: undefined,
|
|
1687
|
+
getAuthToken: undefined
|
|
1692
1688
|
};
|
|
@@ -1,15 +1,66 @@
|
|
|
1
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
3
3
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
4
4
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
5
5
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
6
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
7
|
-
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
7
|
+
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
8
|
+
import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
|
|
9
|
+
import { Constants } from "../../../common/Constants";
|
|
10
|
+
import { addDelayInMs, getWidgetEndChatEventName } from "../../../common/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
13
|
+
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
14
|
+
|
|
15
|
+
const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
|
|
16
|
+
const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
|
|
18
|
+
let conversationDetails = undefined;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
conversationDetails = await chatSDK.getConversationDetails();
|
|
22
|
+
} catch (erorr) {
|
|
23
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
24
|
+
Event: TelemetryEvent.GetConversationDetailsException,
|
|
25
|
+
ExceptionDetails: {
|
|
26
|
+
exception: `Failed to get conversation details: ${erorr}`
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === Constants.truePascal) {
|
|
32
|
+
const skipEndChatSDK = false;
|
|
33
|
+
const skipCloseChat = true;
|
|
34
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, true);
|
|
35
|
+
|
|
36
|
+
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
37
|
+
dispatch({
|
|
38
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
39
|
+
payload: ConversationState.PostchatLoading
|
|
40
|
+
});
|
|
41
|
+
await addDelayInMs(Constants.PostChatLoadingDurationInMs);
|
|
42
|
+
const loadPostChatEvent = {
|
|
43
|
+
eventName: BroadcastEvent.LoadPostChatSurvey
|
|
44
|
+
};
|
|
45
|
+
BroadcastService.postMessage(loadPostChatEvent);
|
|
46
|
+
} else if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
47
|
+
dispatch({
|
|
48
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
49
|
+
payload: ConversationState.InActive
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
|
|
57
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
|
|
10
61
|
if (!skipEndChatSDK) {
|
|
11
62
|
try {
|
|
12
|
-
TelemetryHelper.
|
|
63
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
13
64
|
Event: TelemetryEvent.EndChatSDKCall
|
|
14
65
|
});
|
|
15
66
|
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
@@ -20,8 +71,23 @@ export const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
20
71
|
exception: ex
|
|
21
72
|
}
|
|
22
73
|
});
|
|
74
|
+
postMessageToOtherTab = false;
|
|
23
75
|
}
|
|
24
|
-
}
|
|
76
|
+
} // Need to clear these states immediately when chat ended from OC.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
dispatch({
|
|
80
|
+
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
81
|
+
payload: undefined
|
|
82
|
+
});
|
|
83
|
+
dispatch({
|
|
84
|
+
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
85
|
+
payload: undefined
|
|
86
|
+
});
|
|
87
|
+
dispatch({
|
|
88
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
89
|
+
payload: undefined
|
|
90
|
+
});
|
|
25
91
|
|
|
26
92
|
if (!skipCloseChat) {
|
|
27
93
|
try {
|
|
@@ -50,16 +116,26 @@ export const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
50
116
|
payload: null
|
|
51
117
|
});
|
|
52
118
|
dispatch({
|
|
53
|
-
type: LiveChatWidgetActionType.
|
|
54
|
-
payload:
|
|
119
|
+
type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
120
|
+
payload: 0
|
|
55
121
|
});
|
|
56
122
|
dispatch({
|
|
57
|
-
type: LiveChatWidgetActionType.
|
|
58
|
-
payload:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
123
|
+
type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
124
|
+
payload: {
|
|
125
|
+
proactiveChatBodyTitle: "",
|
|
126
|
+
proactiveChatEnablePrechat: false,
|
|
127
|
+
proactiveChatInNewWindow: false
|
|
128
|
+
}
|
|
62
129
|
});
|
|
130
|
+
|
|
131
|
+
if (postMessageToOtherTab) {
|
|
132
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
|
|
133
|
+
|
|
134
|
+
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId);
|
|
135
|
+
BroadcastService.postMessage({
|
|
136
|
+
eventName: endChatEventName
|
|
137
|
+
});
|
|
138
|
+
}
|
|
63
139
|
} catch (error) {
|
|
64
140
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
65
141
|
Event: TelemetryEvent.CloseChatMethodException,
|
|
@@ -69,4 +145,6 @@ export const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
69
145
|
});
|
|
70
146
|
}
|
|
71
147
|
}
|
|
72
|
-
};
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export { prepareEndChat, endChat };
|
|
@@ -8,7 +8,7 @@ export const initCallingSdk = async (chatSDK, setVoiceVideoCallingSDK) => {
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
9
|
const callingSDK = await chatSDK.getVoiceVideoCalling();
|
|
10
10
|
setVoiceVideoCallingSDK(callingSDK);
|
|
11
|
-
TelemetryHelper.logCallingEvent(LogLevel.
|
|
11
|
+
TelemetryHelper.logCallingEvent(LogLevel.INFO, {
|
|
12
12
|
Event: TelemetryEvent.CallingSDKLoadSuccess
|
|
13
13
|
});
|
|
14
14
|
return true;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
1
2
|
import { createStore } from "botframework-webchat";
|
|
3
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
|
+
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
2
5
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
3
6
|
import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
|
|
7
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
8
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
5
9
|
import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
|
|
6
|
-
import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
|
|
10
|
+
import { addDelayInMs, changeLanguageCodeFormatForWebChat } from "../../../common/utils";
|
|
7
11
|
import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
|
|
8
12
|
import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
|
|
9
13
|
import createAttachmentMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
|
|
@@ -13,6 +17,7 @@ import createConversationEndMiddleware from "../../webchatcontainerstateful/webc
|
|
|
13
17
|
import createDataMaskingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware";
|
|
14
18
|
import { createMarkdown } from "./createMarkdown";
|
|
15
19
|
import createMaxMessageSizeValidator from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator";
|
|
20
|
+
import { createWebChatTelemetry } from "../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
|
|
16
21
|
import { defaultAttachmentProps } from "../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps";
|
|
17
22
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
18
23
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
@@ -22,11 +27,12 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
|
|
|
22
27
|
import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
|
|
23
28
|
import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
|
|
24
29
|
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
25
|
-
import {
|
|
26
|
-
import
|
|
30
|
+
import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
|
|
31
|
+
import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
|
|
32
|
+
import { Constants } from "../../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
33
|
|
|
28
34
|
export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
29
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21;
|
|
35
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
30
36
|
|
|
31
37
|
const localizedTexts = { ...defaultMiddlewareLocalizedTexts,
|
|
32
38
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -45,6 +51,11 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
45
51
|
const conversationEndCallback = async () => {
|
|
46
52
|
var _props$webChatContain4, _props$webChatContain5;
|
|
47
53
|
|
|
54
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
55
|
+
Event: TelemetryEvent.ConversationEndedThreadEventReceived,
|
|
56
|
+
Description: "Conversation is ended by agent side or by timeout."
|
|
57
|
+
});
|
|
58
|
+
|
|
48
59
|
if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
|
|
49
60
|
setWebChatStyles(styles => {
|
|
50
61
|
return { ...styles,
|
|
@@ -55,8 +66,14 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
55
66
|
|
|
56
67
|
if (isPostChatEnabled === "true") {
|
|
57
68
|
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
69
|
+
WebChatStoreLoader.store = null;
|
|
70
|
+
dispatch({
|
|
71
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
72
|
+
payload: ConversationState.PostchatLoading
|
|
73
|
+
});
|
|
74
|
+
await addDelayInMs(Constants.PostChatLoadingDurationInMs);
|
|
58
75
|
const loadPostChatEvent = {
|
|
59
|
-
eventName:
|
|
76
|
+
eventName: BroadcastEvent.LoadPostChatSurvey
|
|
60
77
|
};
|
|
61
78
|
BroadcastService.postMessage(loadPostChatEvent);
|
|
62
79
|
} else if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
@@ -76,10 +93,14 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
76
93
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
77
94
|
payload: undefined
|
|
78
95
|
});
|
|
96
|
+
dispatch({
|
|
97
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
98
|
+
payload: undefined
|
|
99
|
+
});
|
|
79
100
|
};
|
|
80
101
|
|
|
81
102
|
webChatStore = createStore({}, //initial state
|
|
82
|
-
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), createMessageTimeStampMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware, createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
104
|
...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
|
|
84
105
|
WebChatStoreLoader.store = webChatStore;
|
|
85
106
|
} // Initialize the remaining Web Chat props
|
|
@@ -96,7 +117,9 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
96
117
|
avatarMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableAvatarMiddleware ? undefined : createAvatarMiddleware((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
|
|
97
118
|
groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
98
119
|
typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
99
|
-
|
|
120
|
+
onTelemetry: createWebChatTelemetry(),
|
|
121
|
+
cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
122
|
+
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
100
123
|
};
|
|
101
124
|
return webChatProps;
|
|
102
125
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "regenerator-runtime/runtime";
|
|
2
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
-
import {
|
|
2
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
5
5
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
6
6
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -29,9 +29,17 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
32
|
-
var _props$
|
|
32
|
+
var _props$chatConfig, _props$reconnectChatP;
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
let authClientFunction = undefined;
|
|
35
|
+
|
|
36
|
+
if ((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) {
|
|
37
|
+
var _props$chatConfig2, _props$chatConfig2$Li;
|
|
38
|
+
|
|
39
|
+
authClientFunction = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_javascriptclientfunction) ?? undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && authClientFunction // TODO: Implement this after storage is in place
|
|
35
43
|
|
|
36
44
|
/* && !isLoadWithState() */
|
|
37
45
|
) {
|
|
@@ -46,33 +54,107 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
|
46
54
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
55
|
|
|
48
56
|
|
|
49
|
-
const handleUnauthenticatedReconnectChat = async (dispatch, reconnectId, initStartChat) => {
|
|
50
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(reconnectId);
|
|
57
|
+
const handleUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
58
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
51
59
|
|
|
52
|
-
if (reconnectAvailabilityResponse
|
|
53
|
-
|
|
60
|
+
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
61
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
54
62
|
} else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
|
|
64
|
+
}
|
|
65
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const startUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
69
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
70
|
+
|
|
71
|
+
if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
72
|
+
await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
|
|
73
|
+
}
|
|
74
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
const setReconnectIdAndStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
78
|
+
const startUnauthenticatedReconnectChat = {
|
|
79
|
+
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
80
|
+
};
|
|
81
|
+
BroadcastService.postMessage(startUnauthenticatedReconnectChat);
|
|
82
|
+
const optionalParams = {
|
|
83
|
+
reconnectId: reconnectId
|
|
84
|
+
};
|
|
85
|
+
dispatch({
|
|
86
|
+
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
87
|
+
payload: reconnectId
|
|
88
|
+
});
|
|
89
|
+
dispatch({
|
|
90
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
91
|
+
payload: ConversationState.Loading
|
|
92
|
+
});
|
|
93
|
+
await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, optionalParams);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
97
|
+
const redirectPageRequest = {
|
|
98
|
+
eventName: BroadcastEvent.RedirectPageRequest,
|
|
99
|
+
payload: {
|
|
100
|
+
redirectURL: redirectURL
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
BroadcastService.postMessage(redirectPageRequest);
|
|
104
|
+
|
|
105
|
+
if (redirectInSameWindow) {
|
|
106
|
+
window.location.href = redirectURL;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
|
|
111
|
+
return reconnectAvailabilityResponse && !reconnectAvailabilityResponse.reconnectId;
|
|
112
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
const startNewChatEmptyRedirectionUrl = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat) => {
|
|
116
|
+
const startUnauthenticatedReconnectChat = {
|
|
117
|
+
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
118
|
+
};
|
|
119
|
+
BroadcastService.postMessage(startUnauthenticatedReconnectChat); // Getting PreChat Survey Context
|
|
120
|
+
|
|
121
|
+
const parseToJson = false;
|
|
122
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
123
|
+
|
|
124
|
+
if (preChatSurveyResponse) {
|
|
58
125
|
dispatch({
|
|
59
|
-
type: LiveChatWidgetActionType.
|
|
60
|
-
payload:
|
|
126
|
+
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
127
|
+
payload: preChatSurveyResponse
|
|
61
128
|
});
|
|
129
|
+
dispatch({
|
|
130
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
131
|
+
payload: ConversationState.Prechat
|
|
132
|
+
});
|
|
133
|
+
} else {
|
|
62
134
|
dispatch({
|
|
63
135
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
64
136
|
payload: ConversationState.Loading
|
|
65
137
|
});
|
|
66
|
-
await initStartChat(
|
|
138
|
+
await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter);
|
|
67
139
|
}
|
|
68
|
-
};
|
|
140
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
141
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
142
|
+
|
|
143
|
+
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
144
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
145
|
+
|
|
146
|
+
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
147
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
148
|
+
}
|
|
149
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
153
|
+
if (reconnectAvailabilityResponse.redirectURL) {
|
|
154
|
+
redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
|
|
155
|
+
} else {
|
|
156
|
+
await startNewChatEmptyRedirectionUrl(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat);
|
|
157
|
+
}
|
|
76
158
|
};
|
|
77
159
|
|
|
78
|
-
export { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat };
|
|
160
|
+
export { getChatReconnectContext, getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat, handleRedirectUnauthenticatedReconnectChat };
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
2
1
|
import { RegisterLoggers, TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
2
|
+
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
3
3
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
4
|
import { defaultAriaConfig } from "../../../common/telemetry/defaultConfigs/defaultAriaConfig";
|
|
5
5
|
import { defaultInternalTelemetryData } from "../../../common/telemetry/defaultConfigs/defaultTelemetryInternalData";
|
|
6
6
|
import { defaultTelemetryConfiguration } from "../../../common/telemetry/defaultConfigs/defaultTelemetryConfiguration";
|
|
7
|
-
import { version as chatComponentVersion } from "@microsoft/omnichannel-chat-components/package.json";
|
|
8
|
-
import { version as chatSdkVersion } from "@microsoft/omnichannel-chat-sdk/package.json";
|
|
9
7
|
export const registerTelemetryLoggers = (props, dispatch) => {
|
|
10
8
|
var _props$liveChatContex, _props$liveChatContex2;
|
|
11
9
|
|
|
12
|
-
let widgetPackageInfo;
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
widgetPackageInfo = require("@microsoft/omnichannel-chat-widget/package.json");
|
|
16
|
-
} catch (error) {
|
|
17
|
-
widgetPackageInfo = "0.0.0-0";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
10
|
const telemetryConfig = { ...defaultTelemetryConfiguration,
|
|
21
11
|
...props.telemetryConfig
|
|
22
12
|
};
|
|
@@ -38,12 +28,13 @@ export const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
38
28
|
}
|
|
39
29
|
|
|
40
30
|
telemetryData = TelemetryHelper.addWidgetDataToTelemetry(telemetryConfig, telemetryData);
|
|
41
|
-
telemetryData.OCChatSDKVersion =
|
|
42
|
-
telemetryData.chatComponentVersion = chatComponentVersion;
|
|
43
|
-
telemetryData.chatWidgetVersion =
|
|
31
|
+
telemetryData.OCChatSDKVersion = telemetryConfig.OCChatSDKVersion ?? "0.0.0-0";
|
|
32
|
+
telemetryData.chatComponentVersion = telemetryConfig.chatComponentVersion ?? "0.0.0-0";
|
|
33
|
+
telemetryData.chatWidgetVersion = telemetryConfig.chatWidgetVersion ?? "0.0.0-0";
|
|
44
34
|
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;
|
|
45
35
|
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;
|
|
46
36
|
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;
|
|
37
|
+
TelemetryManager.InternalTelemetryData = telemetryData;
|
|
47
38
|
dispatch({
|
|
48
39
|
type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
|
|
49
40
|
payload: telemetryData
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
3
|
-
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
|
-
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
5
2
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
6
|
-
|
|
3
|
+
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
4
|
+
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
5
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
|
|
7
7
|
export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
|
|
8
8
|
try {
|
|
9
9
|
if (!persistedChat) {
|
|
@@ -25,13 +25,10 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persist
|
|
|
25
25
|
exception: ex
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
-
}
|
|
28
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
29
|
+
|
|
29
30
|
|
|
30
31
|
BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
|
|
31
|
-
dispatch({
|
|
32
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
33
|
-
payload: ConversationState.Loading
|
|
34
|
-
});
|
|
35
32
|
dispatch({
|
|
36
33
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
37
34
|
payload: ConversationState.Postchat
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
|
+
export function shareObservable(observable) {
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
+
let observers = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
|
|
6
|
+
let subscription; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
+
|
|
8
|
+
return new window.Observable(observer => {
|
|
9
|
+
if (!subscription) {
|
|
10
|
+
subscription = observable.subscribe({
|
|
11
|
+
complete() {
|
|
12
|
+
observers.forEach(observer => observer.complete());
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
error(err) {
|
|
17
|
+
observers.forEach(observer => observer.error(err));
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
next(value) {
|
|
22
|
+
observers.forEach(observer => observer.next(value));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
observers.push(observer);
|
|
29
|
+
return () => {
|
|
30
|
+
observers = observers.filter(o => o !== observer);
|
|
31
|
+
|
|
32
|
+
if (!observers.length) {
|
|
33
|
+
subscription.unsubscribe();
|
|
34
|
+
subscription = null;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|