@microsoft/omnichannel-chat-widget 0.1.0-main.438e1d0 → 0.1.0-main.4629f07
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 +7 -34
- package/lib/cjs/common/telemetry/TelemetryConstants.js +10 -0
- package/lib/cjs/common/utils.js +23 -2
- package/lib/cjs/components/headerstateful/HeaderStateful.js +1 -1
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +17 -12
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +26 -13
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +36 -17
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +7 -4
- package/lib/esm/common/telemetry/TelemetryConstants.js +10 -0
- package/lib/esm/common/utils.js +20 -0
- package/lib/esm/components/headerstateful/HeaderStateful.js +1 -1
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +17 -12
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +26 -13
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +36 -17
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +5 -5
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +11 -1
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
- package/package.json +2 -2
|
@@ -4,22 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.typingIndicatorMiddleware = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _DirectLineSenderRole = require("../../enums/DirectLineSenderRole");
|
|
9
9
|
var _defaultMiddlewareLocalizedTexts = require("../../../common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
10
10
|
var _defaultTypingIndicatorBubbleStyles = require("./defaultStyles/defaultTypingIndicatorBubbleStyles");
|
|
11
11
|
var _defaultTypingIndicatorContainerStyles = require("./defaultStyles/defaultTypingIndicatorContainerStyles");
|
|
12
12
|
var _defaultTypingIndicatorMessageStyles = require("./defaultStyles/defaultTypingIndicatorMessageStyles");
|
|
13
13
|
var _ = require("../../../../..");
|
|
14
|
+
var _utils = require("../../../../../common/utils");
|
|
14
15
|
var _useChatSDKStore = _interopRequireDefault(require("../../../../../hooks/useChatSDKStore"));
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
19
|
/******
|
|
17
20
|
* TypingIndicatorMiddleware
|
|
18
|
-
*
|
|
21
|
+
*
|
|
19
22
|
* This middleware changes the component that shows who's actively typing. It uses the default Microsoft LiveChatWidget styles.
|
|
20
23
|
******/
|
|
21
24
|
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
25
|
const TypingIndicator = _ref => {
|
|
24
26
|
var _state$domainStates$l, _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3;
|
|
25
27
|
let {
|
|
@@ -29,6 +31,7 @@ const TypingIndicator = _ref => {
|
|
|
29
31
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
32
|
const chatSDK = (0, _useChatSDKStore.default)();
|
|
31
33
|
const [state] = (0, _.useChatContextStore)();
|
|
34
|
+
const debounceTyping = (0, _react.useCallback)((0, _utils.debounceLeading)(() => chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.sendTypingEvent()), []);
|
|
32
35
|
if (!activeTyping || Object.keys(activeTyping).length === 0 || ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.LiveChatVersion) === 1 && !visible) {
|
|
33
36
|
return null;
|
|
34
37
|
}
|
|
@@ -38,7 +41,7 @@ const TypingIndicator = _ref => {
|
|
|
38
41
|
var _state$domainStates$l2;
|
|
39
42
|
//visible is set to false if the current user is typing, in which case, we just send typing indicator to OC
|
|
40
43
|
if (((_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.LiveChatVersion) === 2 && !visible) {
|
|
41
|
-
|
|
44
|
+
debounceTyping();
|
|
42
45
|
return null;
|
|
43
46
|
}
|
|
44
47
|
activeTyping.splice(i, 1);
|
|
@@ -51,6 +51,10 @@ export let BroadcastEvent;
|
|
|
51
51
|
BroadcastEvent["RaiseErrorEvent"] = "RaiseErrorEvent";
|
|
52
52
|
BroadcastEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
53
53
|
BroadcastEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
54
|
+
BroadcastEvent["SigninCardReceived"] = "SignInCardReceived";
|
|
55
|
+
BroadcastEvent["BotAuthConfigRequest"] = "BotAuthConfigRequest";
|
|
56
|
+
BroadcastEvent["BotAuthConfigResponse"] = "BotAuthConfigResponse";
|
|
57
|
+
BroadcastEvent["HideChatVisibilityChangeEvent"] = "hideChatVisibilityChangeEvent";
|
|
54
58
|
})(BroadcastEvent || (BroadcastEvent = {}));
|
|
55
59
|
export let TelemetryEvent;
|
|
56
60
|
(function (TelemetryEvent) {
|
|
@@ -91,6 +95,7 @@ export let TelemetryEvent;
|
|
|
91
95
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
92
96
|
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
93
97
|
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
98
|
+
TelemetryEvent["ChatVisibilityChanged"] = "ChatVisibilityChanged";
|
|
94
99
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
95
100
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
96
101
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -141,6 +146,11 @@ export let TelemetryEvent;
|
|
|
141
146
|
TelemetryEvent["CustomerVoiceResponsePageLoaded"] = "CustomerVoiceResponsePageLoaded";
|
|
142
147
|
TelemetryEvent["CustomerVoiceFormResponseSubmitted"] = "CustomerVoiceFormResponseSubmitted";
|
|
143
148
|
TelemetryEvent["CustomerVoiceFormResponseError"] = "CustomerVoiceFormResponseError";
|
|
149
|
+
TelemetryEvent["BotAuthActivityEmptySasUrl"] = "BotAuthActivityEmptySasUrl";
|
|
150
|
+
TelemetryEvent["SetBotAuthProviderFetchConfig"] = "SetBotAuthProviderFetchConfig";
|
|
151
|
+
TelemetryEvent["SetBotAuthProviderHideCard"] = "SetBotAuthProviderHideCard";
|
|
152
|
+
TelemetryEvent["SetBotAuthProviderDisplayCard"] = "SetBotAuthProviderDisplayCard";
|
|
153
|
+
TelemetryEvent["SetBotAuthProviderNotFound"] = "SetBotAuthProviderNotFound";
|
|
144
154
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
145
155
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
146
156
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _this = this;
|
|
1
2
|
import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
|
|
2
3
|
import { DataStoreManager } from "./contextDataStore/DataStoreManager";
|
|
3
4
|
import { KeyCodes } from "./KeyCodes";
|
|
@@ -304,4 +305,23 @@ export const addDelayInMs = ms => {
|
|
|
304
305
|
};
|
|
305
306
|
export const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
|
|
306
307
|
return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
311
|
+
export const debounceLeading = function (fn) {
|
|
312
|
+
let ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3000;
|
|
313
|
+
let timeoutId;
|
|
314
|
+
return function () {
|
|
315
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
316
|
+
|
|
317
|
+
if (!timeoutId) {
|
|
318
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
319
|
+
args[_key] = arguments[_key];
|
|
320
|
+
}
|
|
321
|
+
fn.apply(_this, args);
|
|
322
|
+
}
|
|
323
|
+
timeoutId = setTimeout(() => {
|
|
324
|
+
timeoutId = null;
|
|
325
|
+
}, ms);
|
|
326
|
+
};
|
|
307
327
|
};
|
|
@@ -63,7 +63,7 @@ export const HeaderStateful = props => {
|
|
|
63
63
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
64
64
|
hideTitle: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
65
65
|
hideIcon: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
66
|
-
hideCloseButton: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
66
|
+
hideCloseButton: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
67
67
|
};
|
|
68
68
|
const outOfOfficeControlProps = {
|
|
69
69
|
id: "oc-lcw-header",
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
6
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../../common/telemetry/TelemetryConstants";
|
|
8
|
+
import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
9
|
+
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
10
|
+
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
11
|
+
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
12
|
+
const fetchBotAuthConfigRetries = 3;
|
|
13
|
+
const fetchBotAuthConfigRetryInterval = 1000;
|
|
14
|
+
let response;
|
|
15
|
+
const extractSignInId = signInUrl => {
|
|
16
|
+
const result = botOauthUrlRegex.exec(signInUrl);
|
|
17
|
+
if (result && result[1]) {
|
|
18
|
+
return result[1];
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
};
|
|
22
|
+
const extractSasUrl = async attachment => {
|
|
23
|
+
let sasUrl = undefined;
|
|
24
|
+
if (attachment && attachment.content && attachment.content.tokenPostResource && attachment.content.tokenPostResource.sasUrl) {
|
|
25
|
+
sasUrl = attachment.content.tokenPostResource.sasUrl;
|
|
26
|
+
}
|
|
27
|
+
if (!sasUrl) {
|
|
28
|
+
const signInId = extractSignInId(attachment.content.buttons[0].value);
|
|
29
|
+
const getTestUrlEndpoint = `https://token.botframework.com/api/sas/gettesturl?signInId=${signInId}`;
|
|
30
|
+
try {
|
|
31
|
+
const response = await window.fetch(getTestUrlEndpoint);
|
|
32
|
+
if (response.status === 200) {
|
|
33
|
+
const responseJson = await response.json();
|
|
34
|
+
sasUrl = responseJson.sasUrl;
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
sasUrl = undefined;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return sasUrl;
|
|
41
|
+
};
|
|
42
|
+
const fetchBotAuthConfig = async retries => {
|
|
43
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
44
|
+
Event: TelemetryEvent.SetBotAuthProviderFetchConfig
|
|
45
|
+
});
|
|
46
|
+
const botAuthConfigRequestEvent = {
|
|
47
|
+
eventName: BroadcastEvent.BotAuthConfigRequest
|
|
48
|
+
};
|
|
49
|
+
BroadcastService.postMessage(botAuthConfigRequestEvent);
|
|
50
|
+
const listener = BroadcastService.getMessageByEventName(BroadcastEvent.BotAuthConfigResponse).subscribe(data => {
|
|
51
|
+
var _data$payload, _data$payload2;
|
|
52
|
+
response = ((_data$payload = data.payload) === null || _data$payload === void 0 ? void 0 : _data$payload.response) !== undefined ? (_data$payload2 = data.payload) === null || _data$payload2 === void 0 ? void 0 : _data$payload2.response : response;
|
|
53
|
+
listener.unsubscribe();
|
|
54
|
+
});
|
|
55
|
+
if (response !== undefined) {
|
|
56
|
+
//return response;
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
if (retries === 1) {
|
|
60
|
+
// Base Case
|
|
61
|
+
throw new Error();
|
|
62
|
+
}
|
|
63
|
+
await delay(fetchBotAuthConfigRetryInterval);
|
|
64
|
+
return await fetchBotAuthConfig(--retries);
|
|
65
|
+
};
|
|
66
|
+
export class BotAuthActivitySubscriber {
|
|
67
|
+
constructor() {
|
|
68
|
+
_defineProperty(this, "observer", void 0);
|
|
69
|
+
_defineProperty(this, "signInCardSeen", void 0);
|
|
70
|
+
this.signInCardSeen = new Set();
|
|
71
|
+
}
|
|
72
|
+
applicable(activity) {
|
|
73
|
+
var _activity$attachments;
|
|
74
|
+
return (activity === null || activity === void 0 ? void 0 : (_activity$attachments = activity.attachments) === null || _activity$attachments === void 0 ? void 0 : _activity$attachments.length) > 0 && activity.attachments[0] && supportedSignInCardContentTypes.indexOf(activity.attachments[0].contentType) >= 0;
|
|
75
|
+
}
|
|
76
|
+
async apply(activity) {
|
|
77
|
+
this.observer.next(false); // Hides card
|
|
78
|
+
const attachment = activity.attachments[0];
|
|
79
|
+
const signInUrl = attachment.content.buttons[0].value;
|
|
80
|
+
const signInId = extractSignInId(signInUrl);
|
|
81
|
+
if (!signInId) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (this.signInCardSeen.has(signInId)) {
|
|
85
|
+
// Prevents duplicate auth
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.signInCardSeen.add(signInId);
|
|
89
|
+
const sasUrl = await extractSasUrl(attachment);
|
|
90
|
+
const event = {
|
|
91
|
+
eventName: BroadcastEvent.SigninCardReceived,
|
|
92
|
+
payload: {
|
|
93
|
+
sasUrl
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
if (!sasUrl) {
|
|
97
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
98
|
+
Event: TelemetryEvent.BotAuthActivityEmptySasUrl,
|
|
99
|
+
Description: "SaS Url is empty"
|
|
100
|
+
});
|
|
101
|
+
return activity;
|
|
102
|
+
} else {
|
|
103
|
+
BroadcastService.postMessage(event);
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const response = await fetchBotAuthConfig(fetchBotAuthConfigRetries);
|
|
107
|
+
if (response === false) {
|
|
108
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
109
|
+
Event: TelemetryEvent.SetBotAuthProviderHideCard
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
113
|
+
Event: TelemetryEvent.SetBotAuthProviderDisplayCard
|
|
114
|
+
});
|
|
115
|
+
return activity;
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
119
|
+
Event: TelemetryEvent.SetBotAuthProviderNotFound
|
|
120
|
+
});
|
|
121
|
+
//this is to ensure listener continues waiting for response
|
|
122
|
+
if (this.signInCardSeen.has(signInId)) {
|
|
123
|
+
this.signInCardSeen.delete(signInId);
|
|
124
|
+
}
|
|
125
|
+
return activity;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async next(activity) {
|
|
129
|
+
if (this.applicable(activity)) {
|
|
130
|
+
return await this.apply(activity);
|
|
131
|
+
}
|
|
132
|
+
return activity;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -4,6 +4,7 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
|
|
|
4
4
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
5
5
|
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
6
6
|
import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber";
|
|
7
|
+
import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
|
|
7
8
|
|
|
8
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
10
|
export const createAdapter = async chatSDK => {
|
|
@@ -29,6 +30,7 @@ export const createAdapter = async chatSDK => {
|
|
|
29
30
|
if (chatSDK.isMockModeOn !== true) {
|
|
30
31
|
adapter = new ChatAdapterShim(adapter);
|
|
31
32
|
adapter.addSubscriber(new PauseActivitySubscriber());
|
|
33
|
+
adapter.addSubscriber(new BotAuthActivitySubscriber());
|
|
32
34
|
return adapter.chatAdapter;
|
|
33
35
|
}
|
|
34
36
|
return adapter;
|
|
@@ -12,9 +12,9 @@ import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
14
|
const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
15
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
16
|
-
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;
|
|
17
|
-
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;
|
|
15
|
+
var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2, _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
16
|
+
const isPostChatEnabled = ((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_postconversationsurveyenable) ?? ((_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);
|
|
17
|
+
const postChatSurveyMode = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_postconversationsurveymode) ?? ((_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);
|
|
18
18
|
|
|
19
19
|
//Unable to end chat if token has expired
|
|
20
20
|
if (props.getAuthToken) {
|
|
@@ -56,15 +56,20 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
56
56
|
chatSDK.requestId = chatSession.requestId;
|
|
57
57
|
}
|
|
58
58
|
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
// Only start embedded Postchat workflow if postchat context is set successfully else close chat
|
|
60
|
+
if (state.domainStates.postChatContext) {
|
|
61
|
+
dispatch({
|
|
62
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
63
|
+
payload: ConversationState.PostchatLoading
|
|
64
|
+
});
|
|
65
|
+
await addDelayInMs(Constants.PostChatLoadingDurationInMs);
|
|
66
|
+
const loadPostChatEvent = {
|
|
67
|
+
eventName: BroadcastEvent.LoadPostChatSurvey
|
|
68
|
+
};
|
|
69
|
+
BroadcastService.postMessage(loadPostChatEvent);
|
|
70
|
+
} else {
|
|
71
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, true, false, true);
|
|
72
|
+
}
|
|
68
73
|
} else if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
69
74
|
var _props$webChatContain, _props$webChatContain2;
|
|
70
75
|
dispatch({
|
|
@@ -33,7 +33,7 @@ import { Constants } from "../../../common/Constants";
|
|
|
33
33
|
|
|
34
34
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
35
|
export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
36
|
-
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;
|
|
36
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2, _props$chatConfig2, _props$chatConfig2$Li, _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;
|
|
37
37
|
const localizedTexts = {
|
|
38
38
|
...defaultMiddlewareLocalizedTexts,
|
|
39
39
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -41,8 +41,8 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
41
41
|
const disableNewLineMarkdownSupport = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.disableNewLineMarkdownSupport) ?? defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
|
|
42
42
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
43
43
|
const markdown = createMarkdown(((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableMarkdownMessageFormatting) ?? defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
|
|
44
|
-
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;
|
|
45
|
-
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;
|
|
44
|
+
const isPostChatEnabled = ((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_postconversationsurveyenable) ?? ((_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);
|
|
45
|
+
const postChatSurveyMode = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_postconversationsurveymode) ?? ((_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);
|
|
46
46
|
|
|
47
47
|
// Initialize Web Chat's redux store
|
|
48
48
|
let webChatStore = WebChatStoreLoader.store;
|
|
@@ -64,16 +64,28 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
64
64
|
}
|
|
65
65
|
if (isPostChatEnabled === "true") {
|
|
66
66
|
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
// Only start embedded Postchat workflow if postchat context is set successfully else close chat
|
|
68
|
+
if (state.domainStates.postChatContext) {
|
|
69
|
+
WebChatStoreLoader.store = null;
|
|
70
|
+
dispatch({
|
|
71
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
72
|
+
payload: ConversationState.PostchatLoading
|
|
73
|
+
});
|
|
74
|
+
await addDelayInMs(Constants.PostChatLoadingDurationInMs);
|
|
75
|
+
const loadPostChatEvent = {
|
|
76
|
+
eventName: BroadcastEvent.LoadPostChatSurvey
|
|
77
|
+
};
|
|
78
|
+
BroadcastService.postMessage(loadPostChatEvent);
|
|
79
|
+
} else {
|
|
80
|
+
dispatch({
|
|
81
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
82
|
+
payload: ConversationState.InActive
|
|
83
|
+
});
|
|
84
|
+
dispatch({
|
|
85
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
|
|
86
|
+
payload: true
|
|
87
|
+
});
|
|
88
|
+
}
|
|
77
89
|
} else if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
78
90
|
dispatch({
|
|
79
91
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -122,6 +134,7 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
122
134
|
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,
|
|
123
135
|
onTelemetry: createWebChatTelemetry(),
|
|
124
136
|
cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
137
|
+
sendTypingIndicator: true,
|
|
125
138
|
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
126
139
|
};
|
|
127
140
|
return webChatProps;
|
|
@@ -47,7 +47,7 @@ import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
|
47
47
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
48
48
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
49
49
|
export const LiveChatWidgetStateful = props => {
|
|
50
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$
|
|
50
|
+
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps15, _props$controlProps16, _props$componentOverr, _props$controlProps17, _props$componentOverr2, _props$controlProps18, _props$componentOverr3, _props$controlProps19, _props$componentOverr4, _props$controlProps20, _props$componentOverr5, _props$controlProps21, _props$componentOverr6, _props$controlProps22, _props$componentOverr7, _props$controlProps23, _props$controlProps24, _props$componentOverr8, _props$controlProps25, _props$componentOverr9, _props$controlProps26, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
|
|
51
51
|
const [state, dispatch] = useChatContextStore();
|
|
52
52
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
53
|
const [adapter, setAdapter] = useChatAdapterStore();
|
|
@@ -206,7 +206,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
206
206
|
|
|
207
207
|
// useEffect for custom context
|
|
208
208
|
useEffect(() => {
|
|
209
|
-
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$
|
|
209
|
+
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps13;
|
|
210
210
|
// Add the custom context on receiving the SetCustomContext event
|
|
211
211
|
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
212
212
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
@@ -234,14 +234,33 @@ export const LiveChatWidgetStateful = props => {
|
|
|
234
234
|
}
|
|
235
235
|
});
|
|
236
236
|
|
|
237
|
+
// Toggle chat visibility
|
|
238
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.HideChatVisibilityChangeEvent).subscribe(event => {
|
|
239
|
+
var _event$payload;
|
|
240
|
+
if ((event === null || event === void 0 ? void 0 : (_event$payload = event.payload) === null || _event$payload === void 0 ? void 0 : _event$payload.isChatHidden) !== undefined) {
|
|
241
|
+
var _event$payload2, _props$controlProps10;
|
|
242
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
243
|
+
Event: TelemetryEvent.ChatVisibilityChanged,
|
|
244
|
+
Description: "Chat visibility changed to " + (event === null || event === void 0 ? void 0 : (_event$payload2 = event.payload) === null || _event$payload2 === void 0 ? void 0 : _event$payload2.isChatHidden)
|
|
245
|
+
});
|
|
246
|
+
if ((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideStartChatButton) {
|
|
247
|
+
var _event$payload3;
|
|
248
|
+
dispatch({
|
|
249
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
250
|
+
payload: event === null || event === void 0 ? void 0 : (_event$payload3 = event.payload) === null || _event$payload3 === void 0 ? void 0 : _event$payload3.isChatHidden
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
237
256
|
// Start chat from SDK Event
|
|
238
257
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(() => {
|
|
239
|
-
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$
|
|
258
|
+
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps11;
|
|
240
259
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
241
260
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
242
261
|
Description: "Start chat event received."
|
|
243
262
|
});
|
|
244
|
-
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
263
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC5 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC5 === void 0 ? void 0 : _chatSDK$omnichannelC5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
245
264
|
|
|
246
265
|
// Chat not found in cache
|
|
247
266
|
if (persistedState === undefined) {
|
|
@@ -282,9 +301,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
282
301
|
// End chat
|
|
283
302
|
BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
284
303
|
if (state.appStates.hideStartChatButton === false) {
|
|
285
|
-
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$
|
|
304
|
+
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps12;
|
|
286
305
|
// This is to ensure to get latest state from cache in multitab
|
|
287
|
-
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
306
|
+
const persistedState = getStateFromCache(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC6 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC6 === void 0 ? void 0 : _chatSDK$omnichannelC6.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC7 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC7 === void 0 ? void 0 : _chatSDK$omnichannelC7.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps12 = props.controlProps) === null || _props$controlProps12 === void 0 ? void 0 : _props$controlProps12.widgetInstanceId) ?? "");
|
|
288
307
|
if (persistedState && persistedState.appStates.conversationState === ConversationState.Active) {
|
|
289
308
|
prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
290
309
|
} else {
|
|
@@ -304,7 +323,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
304
323
|
});
|
|
305
324
|
|
|
306
325
|
// Listen to end chat event from other tabs
|
|
307
|
-
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$
|
|
326
|
+
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC8 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC8 === void 0 ? void 0 : _chatSDK$omnichannelC8.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC9 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC9 === void 0 ? void 0 : _chatSDK$omnichannelC9.widgetId, ((_props$controlProps13 = props.controlProps) === null || _props$controlProps13 === void 0 ? void 0 : _props$controlProps13.widgetInstanceId) ?? "");
|
|
308
327
|
BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
309
328
|
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
310
329
|
return;
|
|
@@ -409,7 +428,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
409
428
|
|
|
410
429
|
// Publish chat widget state
|
|
411
430
|
useEffect(() => {
|
|
412
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$
|
|
431
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps14;
|
|
413
432
|
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
414
433
|
// Ghost chat scenarios
|
|
415
434
|
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
@@ -427,7 +446,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
427
446
|
};
|
|
428
447
|
}*/
|
|
429
448
|
|
|
430
|
-
widgetStateEventName = getWidgetCacheId(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
449
|
+
widgetStateEventName = getWidgetCacheId(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps14 = props.controlProps) === null || _props$controlProps14 === void 0 ? void 0 : _props$controlProps14.widgetInstanceId) ?? "");
|
|
431
450
|
const chatWidgetStateChangeEvent = {
|
|
432
451
|
eventName: widgetStateEventName,
|
|
433
452
|
payload: {
|
|
@@ -489,28 +508,28 @@ export const LiveChatWidgetStateful = props => {
|
|
|
489
508
|
id: widgetElementId,
|
|
490
509
|
styles: generalStyles,
|
|
491
510
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
492
|
-
}, !((_props$
|
|
511
|
+
}, !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideChatButton) && !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideStartChatButton) && shouldShowChatButton(state) && (decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/React.createElement(ChatButtonStateful, {
|
|
493
512
|
buttonProps: props.chatButtonProps,
|
|
494
513
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
495
514
|
startChat: prepareStartChatRelay
|
|
496
|
-
})), !((_props$
|
|
515
|
+
})), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideProactiveChatPane) && shouldShowProactiveChatPane(state) && (decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/React.createElement(ProactiveChatPaneStateful, {
|
|
497
516
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
498
517
|
startChat: prepareStartChatRelay
|
|
499
|
-
})), !((_props$
|
|
518
|
+
})), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hideHeader) && shouldShowHeader(state) && (decodeComponentString((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/React.createElement(HeaderStateful, {
|
|
500
519
|
headerProps: props.headerProps,
|
|
501
520
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
502
521
|
endChat: endChatRelay
|
|
503
|
-
})), !((_props$
|
|
522
|
+
})), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, props.loadingPaneProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, props.outOfOfficeHoursPaneProps)), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
|
|
504
523
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
505
524
|
initStartChat: initStartChatRelay
|
|
506
|
-
})), !((_props$
|
|
525
|
+
})), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
|
|
507
526
|
surveyProps: props.preChatSurveyPaneProps,
|
|
508
527
|
initStartChat: initStartChatRelay
|
|
509
|
-
})), !((_props$
|
|
528
|
+
})), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
|
|
510
529
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
511
|
-
}, props.callingContainerProps)), !((_props$
|
|
530
|
+
}, props.callingContainerProps)), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
|
|
512
531
|
setPostChatContext: setPostChatContextRelay,
|
|
513
532
|
prepareEndChat: prepareEndChatRelay
|
|
514
|
-
}))), !((_props$
|
|
533
|
+
}))), !((_props$controlProps26 = props.controlProps) !== null && _props$controlProps26 !== void 0 && _props$controlProps26.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane)))));
|
|
515
534
|
};
|
|
516
535
|
export default LiveChatWidgetStateful;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
/******
|
|
2
2
|
* TypingIndicatorMiddleware
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This middleware changes the component that shows who's actively typing. It uses the default Microsoft LiveChatWidget styles.
|
|
5
5
|
******/
|
|
6
6
|
|
|
7
|
-
import React from "react";
|
|
7
|
+
import React, { useCallback } from "react";
|
|
8
8
|
import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
|
|
9
9
|
import { defaultMiddlewareLocalizedTexts } from "../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
10
10
|
import { defaultTypingIndicatorBubbleStyles } from "./defaultStyles/defaultTypingIndicatorBubbleStyles";
|
|
11
11
|
import { defaultTypingIndicatorContainerStyles } from "./defaultStyles/defaultTypingIndicatorContainerStyles";
|
|
12
12
|
import { defaultTypingIndicatorMessageStyles } from "./defaultStyles/defaultTypingIndicatorMessageStyles";
|
|
13
13
|
import { useChatContextStore } from "../../../../..";
|
|
14
|
+
import { debounceLeading } from "../../../../../common/utils";
|
|
14
15
|
import useChatSDKStore from "../../../../../hooks/useChatSDKStore";
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
16
|
const TypingIndicator = _ref => {
|
|
18
17
|
var _state$domainStates$l, _state$domainStates$r, _state$domainStates$r2, _state$domainStates$r3;
|
|
19
18
|
let {
|
|
@@ -23,6 +22,7 @@ const TypingIndicator = _ref => {
|
|
|
23
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
23
|
const chatSDK = useChatSDKStore();
|
|
25
24
|
const [state] = useChatContextStore();
|
|
25
|
+
const debounceTyping = useCallback(debounceLeading(() => chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.sendTypingEvent()), []);
|
|
26
26
|
if (!activeTyping || Object.keys(activeTyping).length === 0 || ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.LiveChatVersion) === 1 && !visible) {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
@@ -32,7 +32,7 @@ const TypingIndicator = _ref => {
|
|
|
32
32
|
var _state$domainStates$l2;
|
|
33
33
|
//visible is set to false if the current user is typing, in which case, we just send typing indicator to OC
|
|
34
34
|
if (((_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.LiveChatVersion) === 2 && !visible) {
|
|
35
|
-
|
|
35
|
+
debounceTyping();
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
activeTyping.splice(i, 1);
|
|
@@ -44,7 +44,11 @@ export declare enum BroadcastEvent {
|
|
|
44
44
|
ClosePopoutWindow = "ClosePopoutWindow",
|
|
45
45
|
RaiseErrorEvent = "RaiseErrorEvent",
|
|
46
46
|
NetworkDisconnected = "NetworkDisconnected",
|
|
47
|
-
NetworkReconnected = "NetworkReconnected"
|
|
47
|
+
NetworkReconnected = "NetworkReconnected",
|
|
48
|
+
SigninCardReceived = "SignInCardReceived",
|
|
49
|
+
BotAuthConfigRequest = "BotAuthConfigRequest",
|
|
50
|
+
BotAuthConfigResponse = "BotAuthConfigResponse",
|
|
51
|
+
HideChatVisibilityChangeEvent = "hideChatVisibilityChangeEvent"
|
|
48
52
|
}
|
|
49
53
|
export declare enum TelemetryEvent {
|
|
50
54
|
CallAdded = "CallAdded",
|
|
@@ -84,6 +88,7 @@ export declare enum TelemetryEvent {
|
|
|
84
88
|
ParseAdaptiveCardFailed = "ParseAdaptiveCardFailed",
|
|
85
89
|
ClientDataStoreProviderFailed = "ClientDataStoreProviderFailed",
|
|
86
90
|
InMemoryDataStoreFailed = "InMemoryDataStoreFailed",
|
|
91
|
+
ChatVisibilityChanged = "ChatVisibilityChanged",
|
|
87
92
|
WebChatLoaded = "WebChatLoaded",
|
|
88
93
|
LCWChatButtonClicked = "LCWChatButtonClicked",
|
|
89
94
|
LCWChatButtonShow = "LCWChatButtonShow",
|
|
@@ -134,6 +139,11 @@ export declare enum TelemetryEvent {
|
|
|
134
139
|
CustomerVoiceResponsePageLoaded = "CustomerVoiceResponsePageLoaded",
|
|
135
140
|
CustomerVoiceFormResponseSubmitted = "CustomerVoiceFormResponseSubmitted",
|
|
136
141
|
CustomerVoiceFormResponseError = "CustomerVoiceFormResponseError",
|
|
142
|
+
BotAuthActivityEmptySasUrl = "BotAuthActivityEmptySasUrl",
|
|
143
|
+
SetBotAuthProviderFetchConfig = "SetBotAuthProviderFetchConfig",
|
|
144
|
+
SetBotAuthProviderHideCard = "SetBotAuthProviderHideCard",
|
|
145
|
+
SetBotAuthProviderDisplayCard = "SetBotAuthProviderDisplayCard",
|
|
146
|
+
SetBotAuthProviderNotFound = "SetBotAuthProviderNotFound",
|
|
137
147
|
ProcessingHTMLTextMiddlewareFailed = "ProcessingHTMLTextMiddlewareFailed",
|
|
138
148
|
ProcessingSanitizationMiddlewareFailed = "ProcessingSanitizationMiddlewareFailed",
|
|
139
149
|
FormatTagsMiddlewareJSONStringifyFailed = "FormatTagsMiddlewareJSONStringifyFailed",
|