@microsoft/omnichannel-chat-widget 1.7.3-main.112d01b → 1.7.3-main.34ea4da
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/Constants.js +1 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +3 -0
- package/lib/cjs/components/footerstateful/FooterStateful.js +14 -3
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +6 -1
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +15 -6
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +77 -0
- package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +2 -2
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +15 -2
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +6 -2
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +2 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +20 -5
- package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +26 -0
- package/lib/cjs/components/livechatwidget/common/helpers/markdownHelper.js +23 -0
- package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +41 -0
- package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +2 -1
- package/lib/cjs/components/livechatwidget/common/startChat.js +37 -28
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +6 -6
- package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -3
- package/lib/cjs/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js +1 -0
- package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +7 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +30 -0
- package/lib/cjs/components/webchatcontainerstateful/common/DemoChatAdapter.js +87 -0
- package/lib/cjs/components/webchatcontainerstateful/common/DemoChatSDK.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +41 -0
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/common/MockBotCardCommandType.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/common/MockBotCommand.js +19 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +3 -0
- package/lib/cjs/components/webchatcontainerstateful/common/utils/attachmentActivityUtils.js +71 -0
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +90 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotAuthConfig.js +1 -0
- package/lib/cjs/plugins/createChatTranscript.js +84 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -2
- package/lib/esm/common/Constants.js +1 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +3 -0
- package/lib/esm/components/footerstateful/FooterStateful.js +12 -3
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +6 -1
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +15 -6
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +70 -0
- package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +3 -2
- package/lib/esm/components/livechatwidget/common/createAdapter.js +14 -2
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +6 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +2 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +20 -5
- package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +20 -0
- package/lib/esm/components/livechatwidget/common/helpers/markdownHelper.js +15 -0
- package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +34 -0
- package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +2 -1
- package/lib/esm/components/livechatwidget/common/startChat.js +37 -28
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
- package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +7 -2
- package/lib/esm/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js +1 -0
- package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +6 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -1
- package/lib/esm/components/webchatcontainerstateful/common/DemoChatAdapter.js +79 -0
- package/lib/esm/components/webchatcontainerstateful/common/DemoChatSDK.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +33 -0
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/common/MockBotCardCommandType.js +7 -0
- package/lib/esm/components/webchatcontainerstateful/common/MockBotCommand.js +12 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/attachmentActivityUtils.js +61 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +77 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotAuthConfig.js +1 -0
- package/lib/esm/plugins/createChatTranscript.js +84 -0
- package/lib/esm/plugins/newMessageEventHandler.js +4 -2
- package/lib/types/common/Constants.d.ts +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/helpers/markdownHelper.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/overridePropsOnMockIfApplicable.d.ts +3 -0
- package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +4 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/common/DemoChatAdapter.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/common/DemoChatSDK.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/common/MockBotCardCommandType.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/common/MockBotCommand.d.ts +11 -0
- package/lib/types/components/webchatcontainerstateful/common/mockadapter.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/attachmentActivityUtils.d.ts +9 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +9 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import React from "react";
|
|
2
|
+
import React, { useEffect } from "react";
|
|
3
3
|
import AudioNotificationStateful from "./audionotificationstateful/AudioNotificationStateful";
|
|
4
4
|
import { Constants } from "../../common/Constants";
|
|
5
5
|
import { Footer } from "@microsoft/omnichannel-chat-components";
|
|
@@ -14,7 +14,7 @@ import useChatSDKStore from "../../hooks/useChatSDKStore";
|
|
|
14
14
|
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
16
|
export const FooterStateful = props => {
|
|
17
|
-
var _footerProps$controlP3, _footerProps$
|
|
17
|
+
var _footerProps$controlP3, _footerProps$controlP6;
|
|
18
18
|
const [state, dispatch] = useChatContextStore();
|
|
19
19
|
// hideFooterDisplay - the purpose of this is to keep the footer always "active",
|
|
20
20
|
// but hide it visually in certain states (e.g., loading state) and show in some other states (e.g. active state).
|
|
@@ -81,13 +81,22 @@ export const FooterStateful = props => {
|
|
|
81
81
|
isAudioMuted: state.appStates.isAudioMuted
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (state.appStates.isAudioMuted === null) {
|
|
86
|
+
var _footerProps$controlP4, _footerProps$controlP5;
|
|
87
|
+
dispatch({
|
|
88
|
+
type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
|
|
89
|
+
payload: (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : (_footerProps$controlP5 = _footerProps$controlP4.audioNotificationButtonProps) === null || _footerProps$controlP5 === void 0 ? void 0 : _footerProps$controlP5.isAudioMuted) ?? false
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}, []);
|
|
84
93
|
return /*#__PURE__*/React.createElement(React.Fragment, null, !hideFooterDisplay && /*#__PURE__*/React.createElement(Footer, {
|
|
85
94
|
componentOverrides: footerProps === null || footerProps === void 0 ? void 0 : footerProps.componentOverrides,
|
|
86
95
|
controlProps: controlProps,
|
|
87
96
|
styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
|
|
88
97
|
}), /*#__PURE__*/React.createElement(AudioNotificationStateful, {
|
|
89
98
|
audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? NewMessageNotificationSoundBase64,
|
|
90
|
-
isAudioMuted: state.appStates.isAudioMuted === null ? (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$
|
|
99
|
+
isAudioMuted: state.appStates.isAudioMuted === null ? (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP6 = footerProps.controlProps) === null || _footerProps$controlP6 === void 0 ? void 0 : _footerProps$controlP6.hideAudioNotificationButton) ?? false : state.appStates.isAudioMuted ?? false
|
|
91
100
|
}));
|
|
92
101
|
};
|
|
93
102
|
export default FooterStateful;
|
|
@@ -5,13 +5,18 @@ import { ChatSDKStore } from "../../contexts/ChatSDKStore";
|
|
|
5
5
|
import LiveChatWidgetStateful from "./livechatwidgetstateful/LiveChatWidgetStateful";
|
|
6
6
|
import { createReducer } from "../../contexts/createReducer";
|
|
7
7
|
import { getLiveChatWidgetContextInitialState } from "../../contexts/common/LiveChatWidgetContextInitialState";
|
|
8
|
+
import { getMockChatSDKIfApplicable } from "./common/getMockChatSDKIfApplicable";
|
|
9
|
+
import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
|
|
8
10
|
export const LiveChatWidget = props => {
|
|
11
|
+
var _props$mock;
|
|
9
12
|
const reducer = createReducer();
|
|
10
13
|
const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
|
|
11
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
15
|
const [adapter, setAdapter] = useState(undefined);
|
|
16
|
+
const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type);
|
|
17
|
+
overridePropsOnMockIfApplicable(props);
|
|
13
18
|
return /*#__PURE__*/React.createElement(ChatSDKStore.Provider, {
|
|
14
|
-
value:
|
|
19
|
+
value: chatSDK
|
|
15
20
|
}, /*#__PURE__*/React.createElement(ChatAdapterStore.Provider, {
|
|
16
21
|
value: [adapter, setAdapter]
|
|
17
22
|
}, /*#__PURE__*/React.createElement(ChatContextStore.Provider, {
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
CHANGED
|
@@ -9,8 +9,6 @@ import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
|
9
9
|
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
10
10
|
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
11
11
|
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
12
|
-
const fetchBotAuthConfigRetries = 3;
|
|
13
|
-
const fetchBotAuthConfigRetryInterval = 1000;
|
|
14
12
|
let response;
|
|
15
13
|
const extractSignInId = signInUrl => {
|
|
16
14
|
const result = botOauthUrlRegex.exec(signInUrl);
|
|
@@ -39,7 +37,7 @@ const extractSasUrl = async attachment => {
|
|
|
39
37
|
}
|
|
40
38
|
return sasUrl;
|
|
41
39
|
};
|
|
42
|
-
const fetchBotAuthConfig = async retries => {
|
|
40
|
+
const fetchBotAuthConfig = async (retries, interval) => {
|
|
43
41
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
44
42
|
Event: TelemetryEvent.SetBotAuthProviderFetchConfig
|
|
45
43
|
});
|
|
@@ -60,14 +58,25 @@ const fetchBotAuthConfig = async retries => {
|
|
|
60
58
|
// Base Case
|
|
61
59
|
throw new Error();
|
|
62
60
|
}
|
|
63
|
-
await delay(
|
|
64
|
-
return await fetchBotAuthConfig(--retries);
|
|
61
|
+
await delay(interval);
|
|
62
|
+
return await fetchBotAuthConfig(--retries, interval);
|
|
65
63
|
};
|
|
66
64
|
export class BotAuthActivitySubscriber {
|
|
67
65
|
constructor() {
|
|
66
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
68
67
|
_defineProperty(this, "observer", void 0);
|
|
69
68
|
_defineProperty(this, "signInCardSeen", void 0);
|
|
69
|
+
_defineProperty(this, "fetchBotAuthConfigRetries", void 0);
|
|
70
|
+
_defineProperty(this, "fetchBotAuthConfigRetryInterval", void 0);
|
|
70
71
|
this.signInCardSeen = new Set();
|
|
72
|
+
this.fetchBotAuthConfigRetries = 3;
|
|
73
|
+
this.fetchBotAuthConfigRetryInterval = 1000;
|
|
74
|
+
if (optionalParams.fetchBotAuthConfigRetries) {
|
|
75
|
+
this.fetchBotAuthConfigRetries = optionalParams.fetchBotAuthConfigRetries;
|
|
76
|
+
}
|
|
77
|
+
if (optionalParams.fetchBotAuthConfigRetryInterval) {
|
|
78
|
+
this.fetchBotAuthConfigRetryInterval = optionalParams.fetchBotAuthConfigRetryInterval;
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
81
|
applicable(activity) {
|
|
73
82
|
var _activity$attachments;
|
|
@@ -106,7 +115,7 @@ export class BotAuthActivitySubscriber {
|
|
|
106
115
|
BroadcastService.postMessage(event);
|
|
107
116
|
}
|
|
108
117
|
try {
|
|
109
|
-
const response = await fetchBotAuthConfig(fetchBotAuthConfigRetries);
|
|
118
|
+
const response = await fetchBotAuthConfig(this.fetchBotAuthConfigRetries, this.fetchBotAuthConfigRetryInterval);
|
|
110
119
|
if (response === false) {
|
|
111
120
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
112
121
|
Event: TelemetryEvent.SetBotAuthProviderHideCard
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import { Constants } from "../../../../common/Constants";
|
|
5
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../../common/telemetry/TelemetryConstants";
|
|
6
|
+
import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
7
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
8
|
+
export class HiddenAdaptiveCardActivitySubscriber {
|
|
9
|
+
constructor() {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
_defineProperty(this, "observer", void 0);
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
async apply(activity) {
|
|
15
|
+
const {
|
|
16
|
+
attachments,
|
|
17
|
+
attachment
|
|
18
|
+
} = activity;
|
|
19
|
+
this.observer.next(false);
|
|
20
|
+
BroadcastService.postMessage({
|
|
21
|
+
eventName: BroadcastEvent.NewMessageReceived,
|
|
22
|
+
payload: {
|
|
23
|
+
attachments: attachments || [attachment],
|
|
24
|
+
text: "Custom Event"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
31
|
+
applicable(activity) {
|
|
32
|
+
const {
|
|
33
|
+
attachments,
|
|
34
|
+
attachment
|
|
35
|
+
} = activity;
|
|
36
|
+
|
|
37
|
+
// Use `attachments` or `attachment` (whichever exists)
|
|
38
|
+
const cards = attachments || [attachment];
|
|
39
|
+
|
|
40
|
+
// Check if contentType is "AdaptiveCard"
|
|
41
|
+
const adaptiveCard = cards === null || cards === void 0 ? void 0 : cards.find(
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
item => Constants.supportedAdaptiveCardContentTypes.indexOf(item === null || item === void 0 ? void 0 : item.contentType) >= 0);
|
|
44
|
+
if (adaptiveCard && adaptiveCard.content) {
|
|
45
|
+
const {
|
|
46
|
+
body
|
|
47
|
+
} = adaptiveCard.content;
|
|
48
|
+
if (Array.isArray(body)) {
|
|
49
|
+
// Check if all elements in `body` have `isVisible: false`
|
|
50
|
+
const allInvisible = body.every(item => item.isVisible === false);
|
|
51
|
+
if (allInvisible) {
|
|
52
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
53
|
+
Event: TelemetryEvent.HiddenAdaptiveCardMessageReceived,
|
|
54
|
+
Description: "All elements in AdaptiveCard are invisible"
|
|
55
|
+
});
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
async next(activity) {
|
|
65
|
+
if (this.applicable(activity)) {
|
|
66
|
+
return await this.apply(activity);
|
|
67
|
+
}
|
|
68
|
+
return activity;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
1
2
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
2
3
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
3
|
-
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
4
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
5
4
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
|
+
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
6
|
+
|
|
6
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
8
|
const handleChatDisconnect = (props, state, setWebChatStyles) => {
|
|
8
9
|
var _state$appStates, _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
|
|
@@ -5,9 +5,14 @@ import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/
|
|
|
5
5
|
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
6
6
|
import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber";
|
|
7
7
|
import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
|
|
8
|
+
import { HiddenAdaptiveCardActivitySubscriber } from "./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber";
|
|
9
|
+
const defaultBotAuthConfig = {
|
|
10
|
+
fetchBotAuthConfigRetries: 3,
|
|
11
|
+
fetchBotAuthConfigRetryInterval: 1000
|
|
12
|
+
};
|
|
8
13
|
|
|
9
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
export const createAdapter = async chatSDK => {
|
|
15
|
+
export const createAdapter = async (chatSDK, props) => {
|
|
11
16
|
const chatAdapterOptionalParams = {
|
|
12
17
|
IC3Adapter: {
|
|
13
18
|
options: {
|
|
@@ -33,9 +38,16 @@ export const createAdapter = async chatSDK => {
|
|
|
33
38
|
let adapter = await chatSDK.createChatAdapter(chatAdapterOptionalParams);
|
|
34
39
|
//so far, there is no need to convert to the shim adapter when using visual tests
|
|
35
40
|
if (chatSDK.isMockModeOn !== true) {
|
|
41
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4;
|
|
42
|
+
const botAuthActivitySubscriberOptionalParams = {
|
|
43
|
+
fetchBotAuthConfigRetries: (props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.botAuthConfig) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.fetchBotAuthConfigRetries) || defaultBotAuthConfig.fetchBotAuthConfigRetries,
|
|
44
|
+
fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval
|
|
45
|
+
};
|
|
36
46
|
adapter = new ChatAdapterShim(adapter);
|
|
37
47
|
adapter.addSubscriber(new PauseActivitySubscriber());
|
|
38
|
-
adapter.addSubscriber(new BotAuthActivitySubscriber());
|
|
48
|
+
adapter.addSubscriber(new BotAuthActivitySubscriber(botAuthActivitySubscriberOptionalParams));
|
|
49
|
+
// Remove this code after ICM ID:544623085 is fixed
|
|
50
|
+
adapter.addSubscriber(new HiddenAdaptiveCardActivitySubscriber());
|
|
39
51
|
return adapter.chatAdapter;
|
|
40
52
|
}
|
|
41
53
|
return adapter;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
1
3
|
import { Constants } from "../../../common/Constants";
|
|
2
4
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
3
5
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
4
|
-
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
5
6
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
|
-
import {
|
|
7
|
+
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
7
8
|
const isInternetConnected = async () => {
|
|
8
9
|
try {
|
|
9
10
|
const response = await fetch(Constants.internetConnectionTestUrl);
|
|
@@ -26,6 +27,9 @@ export const createInternetConnectionChangeHandler = async () => {
|
|
|
26
27
|
Event: TelemetryEvent.NetworkReconnected
|
|
27
28
|
});
|
|
28
29
|
NotificationHandler.notifySuccess(NotificationScenarios.InternetConnection, defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
|
|
30
|
+
BroadcastService.postMessage({
|
|
31
|
+
eventName: BroadcastEvent.NetworkReconnected
|
|
32
|
+
});
|
|
29
33
|
}
|
|
30
34
|
};
|
|
31
35
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Constants } from "../../../common/Constants";
|
|
2
2
|
import MarkdownIt from "markdown-it";
|
|
3
3
|
import MarkdownItForInline from "markdown-it-for-inline";
|
|
4
|
-
import MarkdownSlack from "slack-markdown-it";
|
|
5
4
|
import { defaultMarkdownLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMarkdownLocalizedTexts";
|
|
5
|
+
import { addSlackMarkdownIt } from "./helpers/markdownHelper";
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
8
|
export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdownSupport) => {
|
|
@@ -13,7 +13,7 @@ export const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineM
|
|
|
13
13
|
linkify: true,
|
|
14
14
|
breaks: !disableNewLineMarkdownSupport
|
|
15
15
|
});
|
|
16
|
-
markdown
|
|
16
|
+
markdown = addSlackMarkdownIt(markdown);
|
|
17
17
|
} else {
|
|
18
18
|
markdown = new MarkdownIt(Constants.Zero, {
|
|
19
19
|
html: true,
|
|
@@ -135,12 +135,27 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
135
135
|
await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
|
|
136
136
|
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
137
137
|
} catch (ex) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
138
|
+
var _inMemoryState$appSta;
|
|
139
|
+
const inMemoryState = executeReducer(state, {
|
|
140
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
141
|
+
payload: null
|
|
143
142
|
});
|
|
143
|
+
// if the chat was disconnected or ended by the agent, we don't want to log the error
|
|
144
|
+
if (!(inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$appSta = inMemoryState.appStates) !== null && _inMemoryState$appSta !== void 0 && _inMemoryState$appSta.chatDisconnectEventReceived)) {
|
|
145
|
+
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
146
|
+
Event: TelemetryEvent.EndChatSDKCallFailed,
|
|
147
|
+
ExceptionDetails: {
|
|
148
|
+
exception: ex
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
TelemetryHelper.logSDKEvent(LogLevel.WARN, {
|
|
153
|
+
Event: TelemetryEvent.DisconnectEndChatSDKCallFailed,
|
|
154
|
+
ExceptionDetails: {
|
|
155
|
+
exception: ex
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
144
159
|
postMessageToOtherTab = false;
|
|
145
160
|
} finally {
|
|
146
161
|
await endChatStateCleanUp(dispatch);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DemoChatSDK } from "../../webchatcontainerstateful/common/DemoChatSDK";
|
|
2
|
+
import { DesignerChatSDK } from "../../webchatcontainerstateful/common/DesignerChatSDK";
|
|
3
|
+
import { MockChatSDK } from "../../webchatcontainerstateful/common/mockchatsdk";
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
export const getMockChatSDKIfApplicable = (chatSDK, type) => {
|
|
7
|
+
if (type) {
|
|
8
|
+
switch (type.toLowerCase()) {
|
|
9
|
+
case "demo":
|
|
10
|
+
chatSDK = new DemoChatSDK();
|
|
11
|
+
break;
|
|
12
|
+
case "designer":
|
|
13
|
+
chatSDK = new DesignerChatSDK();
|
|
14
|
+
break;
|
|
15
|
+
default:
|
|
16
|
+
chatSDK = new MockChatSDK();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return chatSDK;
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import SlackMarkdown from "slack-markdown-it";
|
|
2
|
+
export const addSlackMarkdownIt = markdown => {
|
|
3
|
+
try {
|
|
4
|
+
markdown.use(SlackMarkdown);
|
|
5
|
+
} catch (e) {
|
|
6
|
+
// this is to support the case when slack-markdown-it
|
|
7
|
+
// transpiled code doesn't export default (webpack5)
|
|
8
|
+
if (SlackMarkdown.default.apply) {
|
|
9
|
+
markdown.use(SlackMarkdown.default);
|
|
10
|
+
} else {
|
|
11
|
+
console.error("Error while adding slackMarkdown plugin", e);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return markdown;
|
|
15
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const overridePropsOnMockIfApplicable = props => {
|
|
2
|
+
var _props$mock, _props$mock2;
|
|
3
|
+
if (props !== null && props !== void 0 && (_props$mock = props.mock) !== null && _props$mock !== void 0 && _props$mock.type && (props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type.toLowerCase()) === "designer") {
|
|
4
|
+
if (!props.webChatContainerProps) {
|
|
5
|
+
props.webChatContainerProps = {};
|
|
6
|
+
}
|
|
7
|
+
if (!props.webChatContainerProps.webChatProps) {
|
|
8
|
+
props.webChatContainerProps.webChatProps = {};
|
|
9
|
+
}
|
|
10
|
+
if (!props.webChatContainerProps.webChatStyles) {
|
|
11
|
+
props.webChatContainerProps.webChatStyles = {};
|
|
12
|
+
}
|
|
13
|
+
if (!props.webChatContainerProps.webChatProps.overrideLocalizedStrings) {
|
|
14
|
+
props.webChatContainerProps.webChatProps.overrideLocalizedStrings = {};
|
|
15
|
+
}
|
|
16
|
+
props.webChatContainerProps = {
|
|
17
|
+
...props.webChatContainerProps,
|
|
18
|
+
webChatProps: {
|
|
19
|
+
disabled: true,
|
|
20
|
+
...props.webChatContainerProps.webChatProps,
|
|
21
|
+
overrideLocalizedStrings: {
|
|
22
|
+
TEXT_INPUT_PLACEHOLDER: "Send a message . . .",
|
|
23
|
+
...props.webChatContainerProps.webChatProps.overrideLocalizedStrings
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
webChatStyles: {
|
|
27
|
+
hideUploadButton: false,
|
|
28
|
+
sendBoxBackground: "rgb(243, 242, 241)",
|
|
29
|
+
...props.webChatContainerProps.webChatStyles
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export default overridePropsOnMockIfApplicable;
|
|
@@ -6,7 +6,8 @@ export const shouldSetPreChatIfPersistentChat = async (chatSDK, conversationMode
|
|
|
6
6
|
let skipPreChat = false;
|
|
7
7
|
if (persistentEnabled) {
|
|
8
8
|
const reconnectableChatsParams = {
|
|
9
|
-
authenticatedUserToken: chatSDK.authenticatedUserToken
|
|
9
|
+
authenticatedUserToken: chatSDK.authenticatedUserToken,
|
|
10
|
+
requestId: chatSDK.requestId
|
|
10
11
|
};
|
|
11
12
|
try {
|
|
12
13
|
const reconnectableChatsResponse = await chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams);
|
|
@@ -2,21 +2,21 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/teleme
|
|
|
2
2
|
import { Constants, LiveWorkItemState, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
3
3
|
import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
4
4
|
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
5
|
+
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
|
|
6
|
+
import { handleStartChatError, logWidgetLoadComplete } from "./startChatErrorHandler";
|
|
5
7
|
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
6
8
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
9
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
8
10
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
9
11
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
10
12
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
13
|
+
import { chatSDKStateCleanUp } from "./endChat";
|
|
11
14
|
import { createAdapter } from "./createAdapter";
|
|
12
15
|
import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
|
|
13
|
-
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
|
|
14
|
-
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
15
|
-
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
16
|
-
import { logWidgetLoadComplete, handleStartChatError } from "./startChatErrorHandler";
|
|
17
|
-
import { chatSDKStateCleanUp } from "./endChat";
|
|
18
16
|
import { isPersistentChatEnabled } from "./liveChatConfigUtils";
|
|
17
|
+
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
19
18
|
import { shouldSetPreChatIfPersistentChat } from "./persistentChatHelper";
|
|
19
|
+
import { updateTelemetryData } from "./updateSessionDataForTelemetry";
|
|
20
20
|
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
let optionalParams = {};
|
|
@@ -43,6 +43,7 @@ const setAuthenticationIfApplicable = async (props, chatSDK) => {
|
|
|
43
43
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
44
44
|
optionalParams = {}; //Resetting to ensure no stale values
|
|
45
45
|
widgetInstanceId = getWidgetCacheIdfromProps(props);
|
|
46
|
+
|
|
46
47
|
// reconnect > chat from cache
|
|
47
48
|
if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
|
|
48
49
|
const shouldStartChatNormally = await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
@@ -64,7 +65,11 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
64
65
|
// Setting Proactive chat settings
|
|
65
66
|
const isProactiveChat = state.appStates.conversationState === ConversationState.ProactiveChat;
|
|
66
67
|
const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
|
|
67
|
-
|
|
68
|
+
|
|
69
|
+
// Setting auth settings to OC API to retrieve existing persistent chat session before start chat if any
|
|
70
|
+
if (isPersistentEnabled(props.chatConfig)) {
|
|
71
|
+
await setAuthenticationIfApplicable(props, chatSDK);
|
|
72
|
+
}
|
|
68
73
|
|
|
69
74
|
//Setting PreChat and intiate chat
|
|
70
75
|
await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
|
|
@@ -146,7 +151,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
146
151
|
chatSDKStateCleanUp(chatSDK);
|
|
147
152
|
}
|
|
148
153
|
try {
|
|
149
|
-
var _state$appStates2
|
|
154
|
+
var _state$appStates2;
|
|
150
155
|
// Clear disconnect state on start chat
|
|
151
156
|
(state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.chatDisconnectEventReceived) && dispatch({
|
|
152
157
|
type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
@@ -160,6 +165,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
160
165
|
Description: "Widget loading started"
|
|
161
166
|
});
|
|
162
167
|
|
|
168
|
+
// Auth token retrieval needs to happen during start chat to support pop-out chat
|
|
169
|
+
await setAuthenticationIfApplicable(props, chatSDK);
|
|
170
|
+
|
|
163
171
|
//Check if chat retrieved from cache
|
|
164
172
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
165
173
|
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|
|
@@ -194,16 +202,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
194
202
|
isStartChatSuccessful = false;
|
|
195
203
|
throw error;
|
|
196
204
|
}
|
|
197
|
-
|
|
198
|
-
// New adapter creation
|
|
199
|
-
const newAdapter = await createAdapter(chatSDK);
|
|
200
|
-
setAdapter(newAdapter);
|
|
201
|
-
const chatToken = await chatSDK.getChatToken();
|
|
202
|
-
dispatch({
|
|
203
|
-
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
204
|
-
payload: chatToken
|
|
205
|
-
});
|
|
206
|
-
newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe(createOnNewAdapterActivityHandler(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
|
|
205
|
+
await createAdapterAndSubscribe(chatSDK, dispatch, setAdapter, props);
|
|
207
206
|
|
|
208
207
|
// Set app state to Active
|
|
209
208
|
if (isStartChatSuccessful) {
|
|
@@ -224,27 +223,26 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
224
223
|
payload: persistedState
|
|
225
224
|
});
|
|
226
225
|
logWidgetLoadComplete(WidgetLoadTelemetryMessage.PersistedStateRetrievedMessage);
|
|
227
|
-
|
|
226
|
+
// Set post chat context in state, load in background to do not block the load
|
|
227
|
+
setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
|
-
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
233
|
-
|
|
234
231
|
// Persistent Chat relies on the `reconnectId` retrieved from reconnectablechats API to reconnect upon start chat and not `liveChatContext`
|
|
235
232
|
if (!persistentChatEnabled) {
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
|
+
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
236
236
|
dispatch({
|
|
237
237
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
238
238
|
payload: liveChatContext
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
logWidgetLoadComplete();
|
|
242
|
-
// Set post chat context in state
|
|
243
|
-
|
|
244
|
-
await setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
245
|
-
|
|
242
|
+
// Set post chat context in state, load in background to do not block the load
|
|
243
|
+
setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
246
244
|
// Updating chat session detail for telemetry
|
|
247
|
-
await
|
|
245
|
+
await updateTelemetryData(chatSDK, dispatch);
|
|
248
246
|
} catch (ex) {
|
|
249
247
|
handleStartChatError(dispatch, chatSDK, props, ex, isStartChatSuccessful);
|
|
250
248
|
} finally {
|
|
@@ -253,6 +251,19 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
253
251
|
}
|
|
254
252
|
};
|
|
255
253
|
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
255
|
+
const createAdapterAndSubscribe = async (chatSDK, dispatch, setAdapter, props) => {
|
|
256
|
+
var _newAdapter$activity$;
|
|
257
|
+
// New adapter creation
|
|
258
|
+
const newAdapter = await createAdapter(chatSDK, props);
|
|
259
|
+
setAdapter(newAdapter);
|
|
260
|
+
const chatToken = await chatSDK.getChatToken();
|
|
261
|
+
dispatch({
|
|
262
|
+
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
263
|
+
payload: chatToken
|
|
264
|
+
});
|
|
265
|
+
newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe(createOnNewAdapterActivityHandler(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
|
|
266
|
+
};
|
|
256
267
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
257
268
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
258
269
|
var _state$appStates3, _persistedState$domai6, _persistedState$appSt;
|
|
@@ -341,10 +352,8 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
341
352
|
var _state$domainStates8, _state$domainStates8$, _state$domainStates9;
|
|
342
353
|
const requestIdFromCache = (_state$domainStates8 = state.domainStates) === null || _state$domainStates8 === void 0 ? void 0 : (_state$domainStates8$ = _state$domainStates8.liveChatContext) === null || _state$domainStates8$ === void 0 ? void 0 : _state$domainStates8$.requestId;
|
|
343
354
|
const liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates9 = state.domainStates) === null || _state$domainStates9 === void 0 ? void 0 : _state$domainStates9.liveChatContext;
|
|
344
|
-
|
|
345
355
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
346
356
|
let conversationDetails = undefined;
|
|
347
|
-
|
|
348
357
|
// Preserve current requestId
|
|
349
358
|
const currentRequestId = chatSDK.requestId ?? "";
|
|
350
359
|
dispatch({
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChatSDKError, ChatSDKErrorName } from "@microsoft/omnichannel-chat-sdk";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { PrepareEndChatDescriptionConstants, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
4
|
+
import { callingStateCleanUp, chatSDKStateCleanUp, closeChatStateCleanUp, endChatStateCleanUp } from "./endChat";
|
|
5
5
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
6
|
-
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
7
|
-
import { callingStateCleanUp, endChatStateCleanUp, closeChatStateCleanUp, chatSDKStateCleanUp } from "./endChat";
|
|
8
6
|
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
9
|
-
import {
|
|
10
|
-
import { PrepareEndChatDescriptionConstants, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
7
|
+
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
11
8
|
import { StartChatFailureType } from "../../../contexts/common/StartChatFailureType";
|
|
9
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
10
|
+
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
11
|
+
import { getWidgetCacheIdfromProps } from "../../../common/utils";
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
14
|
export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSuccessful) => {
|
|
@@ -6,7 +6,13 @@ import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
|
6
6
|
import { getConversationDetailsCall } from "../../../common/utils";
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
export const
|
|
9
|
+
export const updateTelemetryData = async (chatSDK, dispatch) => {
|
|
10
|
+
// load it concurrently, this will reduce the load time
|
|
11
|
+
await Promise.all([updateSessionDataForTelemetry(chatSDK, dispatch), updateConversationDataForTelemetry(chatSDK, dispatch)]);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const updateSessionDataForTelemetry = async (chatSDK, dispatch) => {
|
|
10
16
|
if (chatSDK) {
|
|
11
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
18
|
const chatSession = await chatSDK.getCurrentLiveChatContext();
|
|
@@ -21,7 +27,6 @@ export const updateSessionDataForTelemetry = async (chatSDK, dispatch) => {
|
|
|
21
27
|
chatSession
|
|
22
28
|
}
|
|
23
29
|
});
|
|
24
|
-
await updateConversationDataForTelemetry(chatSDK, dispatch);
|
|
25
30
|
}
|
|
26
31
|
};
|
|
27
32
|
|
package/lib/esm/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|