@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
package/README.md
CHANGED
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
1. [Installation](#installation)
|
|
12
12
|
1. [Example Usage](#example-usage)
|
|
13
13
|
1. [Components](#components)
|
|
14
|
-
1. [Common Scenarios](#common-scenarios)
|
|
15
|
-
- [Disable Bot Magic Code](#disable-bot-magic-code)
|
|
16
14
|
1. [See Also](#see-also)
|
|
17
15
|
|
|
18
16
|
## Introduction
|
|
@@ -97,7 +95,9 @@ const render = async () => {
|
|
|
97
95
|
render();
|
|
98
96
|
```
|
|
99
97
|
|
|
100
|
-
A sample widget can be found in this repo [here](https://github.com/microsoft/omnichannel-chat-widget/tree/main/chat-widget/sample). To build it, do ```yarn build-sample``` or ```yarn build-sample:dev``` from project root.
|
|
98
|
+
A javascript sample widget can be found in this repo [here](https://github.com/microsoft/omnichannel-chat-widget/tree/main/chat-widget/samples/javascript-sample). To build it, do ```yarn build-sample``` or ```yarn build-sample:dev``` from project root.
|
|
99
|
+
|
|
100
|
+
A typescript sample widget can be found [here](https://github.com/microsoft/omnichannel-chat-widget/tree/main/chat-widget/samples/typescript-sample)
|
|
101
101
|
|
|
102
102
|
## Components
|
|
103
103
|
|
|
@@ -129,6 +129,7 @@ These are components that are included in the ```@microsoft/omnichannel-chat-com
|
|
|
129
129
|
| ----- | -------- | ----- |
|
|
130
130
|
| WebChatContainer | The default wrapper around BotFramework's [WebChat](https://github.com/microsoft/BotFramework-WebChat), which is the message container we are using | [IWebChatContainerStatefulProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-widget/src/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.ts) |
|
|
131
131
|
| LiveChatWidget | The default widget that stitches the UI components with Chat SDK | [ILiveChatWidgetProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-widget/src/components/livechatwidget/interfaces/ILiveChatWidgetProps.ts) |
|
|
132
|
+
| PostChatLoadingPane | The default loading pane used after the chat is ended and before the post chat pane loads completely | [ILoadingPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/loadingpane/interfaces/ILoadingPaneProps.ts) |
|
|
132
133
|
|
|
133
134
|
Some of the interfaces listed in the Stateless table have Stateful counterparts defined in the ```@microsoft/omnichannel-chat-widget``` package. For example, [IConfirmationPaneStatefulProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-widget/src/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.ts) extends [IConfirmationPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/confirmationpane/interfaces/IConfirmationPaneProps.ts) with additional attributes that only makes sense in the stateful context.
|
|
134
135
|
|
|
@@ -220,40 +221,12 @@ const customizedFooterProp: IFooterProps = {
|
|
|
220
221
|
|
|
221
222
|
> :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
|
|
222
223
|
|
|
223
|
-
## Common Scenarios
|
|
224
|
-
|
|
225
|
-
### Disable Bot Magic Code
|
|
226
|
-
|
|
227
|
-
Configuration to disable the default behaviour of having to type the magic code in the conversation to complete the sign-in proccess with a bot. Instead, the magic code will be sent to the bot behind the scenes.
|
|
228
|
-
|
|
229
|
-
1. Add [MagicCodeForwarder.html](sample/MagicCodeForwarder.html) in the same location as the chat widget
|
|
230
|
-
|
|
231
|
-
2. Add `botMagicCode` configuration to disable default magic code feature
|
|
232
|
-
|
|
233
|
-
> :exclamation: `fwdUrl` **MUST** have the same `origin` as the chat widget URL
|
|
234
|
-
|
|
235
|
-
```js
|
|
236
|
-
const liveChatWidgetProps = {
|
|
237
|
-
chatSDK: chatSDK, // mandatory
|
|
238
|
-
chatConfig: chatConfig, // mandatory
|
|
239
|
-
webChatContainerProps: {
|
|
240
|
-
botMagicCode: {
|
|
241
|
-
disabled: true,
|
|
242
|
-
fwdUrl: 'http://localhost:8000/sample/MagicCodeForwarder.html'
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
ReactDOM.render(
|
|
248
|
-
<LiveChatWidget {...liveChatWidgetProps}/>,
|
|
249
|
-
document.getElementById("my-container")
|
|
250
|
-
);
|
|
251
|
-
```
|
|
252
|
-
|
|
253
224
|
## See Also
|
|
254
225
|
|
|
255
226
|
[Telemetry](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Telemetry.md)\
|
|
256
227
|
[Create LCW widget with Webpack5 and TypeScript](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/BuildingUsingWebpack5.md)\
|
|
257
228
|
[Omnichannel Features](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Features.md)\
|
|
258
229
|
[How to Add Visual Regression Tests](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/VisualRegressionTestingGuide.md)\
|
|
259
|
-
[Security](https://github.com/microsoft/omnichannel-chat-widget/blob/main/SECURITY.md)
|
|
230
|
+
[Security](https://github.com/microsoft/omnichannel-chat-widget/blob/main/SECURITY.md)\
|
|
231
|
+
[Third Party Cookie Support](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Tpc.md)\
|
|
232
|
+
[Storybook](https://microsoft.github.io/omnichannel-chat-widget/docs/storybook/)
|
|
@@ -56,6 +56,10 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
56
56
|
BroadcastEvent["RaiseErrorEvent"] = "RaiseErrorEvent";
|
|
57
57
|
BroadcastEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
58
58
|
BroadcastEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
59
|
+
BroadcastEvent["SigninCardReceived"] = "SignInCardReceived";
|
|
60
|
+
BroadcastEvent["BotAuthConfigRequest"] = "BotAuthConfigRequest";
|
|
61
|
+
BroadcastEvent["BotAuthConfigResponse"] = "BotAuthConfigResponse";
|
|
62
|
+
BroadcastEvent["HideChatVisibilityChangeEvent"] = "hideChatVisibilityChangeEvent";
|
|
59
63
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
60
64
|
let TelemetryEvent;
|
|
61
65
|
exports.TelemetryEvent = TelemetryEvent;
|
|
@@ -97,6 +101,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
97
101
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
98
102
|
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
99
103
|
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
104
|
+
TelemetryEvent["ChatVisibilityChanged"] = "ChatVisibilityChanged";
|
|
100
105
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
101
106
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
102
107
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -147,6 +152,11 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
147
152
|
TelemetryEvent["CustomerVoiceResponsePageLoaded"] = "CustomerVoiceResponsePageLoaded";
|
|
148
153
|
TelemetryEvent["CustomerVoiceFormResponseSubmitted"] = "CustomerVoiceFormResponseSubmitted";
|
|
149
154
|
TelemetryEvent["CustomerVoiceFormResponseError"] = "CustomerVoiceFormResponseError";
|
|
155
|
+
TelemetryEvent["BotAuthActivityEmptySasUrl"] = "BotAuthActivityEmptySasUrl";
|
|
156
|
+
TelemetryEvent["SetBotAuthProviderFetchConfig"] = "SetBotAuthProviderFetchConfig";
|
|
157
|
+
TelemetryEvent["SetBotAuthProviderHideCard"] = "SetBotAuthProviderHideCard";
|
|
158
|
+
TelemetryEvent["SetBotAuthProviderDisplayCard"] = "SetBotAuthProviderDisplayCard";
|
|
159
|
+
TelemetryEvent["SetBotAuthProviderNotFound"] = "SetBotAuthProviderNotFound";
|
|
150
160
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
151
161
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
152
162
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
6
|
+
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
7
7
|
var _Constants = require("./Constants");
|
|
8
8
|
var _DataStoreManager = require("./contextDataStore/DataStoreManager");
|
|
9
9
|
var _KeyCodes = require("./KeyCodes");
|
|
10
10
|
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
11
11
|
var _md5Typescript = require("md5-typescript");
|
|
12
|
+
var _this = void 0;
|
|
12
13
|
const getElementBySelector = selector => {
|
|
13
14
|
let element;
|
|
14
15
|
if (typeof selector === "string") {
|
|
@@ -334,4 +335,24 @@ exports.addDelayInMs = addDelayInMs;
|
|
|
334
335
|
const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
|
|
335
336
|
return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
|
|
336
337
|
};
|
|
337
|
-
|
|
338
|
+
|
|
339
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
340
|
+
exports.getBroadcastChannelName = getBroadcastChannelName;
|
|
341
|
+
const debounceLeading = function (fn) {
|
|
342
|
+
let ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3000;
|
|
343
|
+
let timeoutId;
|
|
344
|
+
return function () {
|
|
345
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
346
|
+
|
|
347
|
+
if (!timeoutId) {
|
|
348
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
349
|
+
args[_key] = arguments[_key];
|
|
350
|
+
}
|
|
351
|
+
fn.apply(_this, args);
|
|
352
|
+
}
|
|
353
|
+
timeoutId = setTimeout(() => {
|
|
354
|
+
timeoutId = null;
|
|
355
|
+
}, ms);
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
exports.debounceLeading = debounceLeading;
|
|
@@ -72,7 +72,7 @@ const HeaderStateful = props => {
|
|
|
72
72
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
73
73
|
hideTitle: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
74
74
|
hideIcon: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
75
|
-
hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.Prechat || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
75
|
+
hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || state.appStates.conversationState === _ConversationState.ConversationState.Prechat || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
76
76
|
};
|
|
77
77
|
const outOfOfficeControlProps = {
|
|
78
78
|
id: "oc-lcw-header",
|
package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BotAuthActivitySubscriber = void 0;
|
|
7
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
8
|
+
var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstants");
|
|
9
|
+
var _TelemetryHelper = require("../../../../common/telemetry/TelemetryHelper");
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
+
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); }
|
|
13
|
+
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
14
|
+
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
15
|
+
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
16
|
+
const fetchBotAuthConfigRetries = 3;
|
|
17
|
+
const fetchBotAuthConfigRetryInterval = 1000;
|
|
18
|
+
let response;
|
|
19
|
+
const extractSignInId = signInUrl => {
|
|
20
|
+
const result = botOauthUrlRegex.exec(signInUrl);
|
|
21
|
+
if (result && result[1]) {
|
|
22
|
+
return result[1];
|
|
23
|
+
}
|
|
24
|
+
return "";
|
|
25
|
+
};
|
|
26
|
+
const extractSasUrl = async attachment => {
|
|
27
|
+
let sasUrl = undefined;
|
|
28
|
+
if (attachment && attachment.content && attachment.content.tokenPostResource && attachment.content.tokenPostResource.sasUrl) {
|
|
29
|
+
sasUrl = attachment.content.tokenPostResource.sasUrl;
|
|
30
|
+
}
|
|
31
|
+
if (!sasUrl) {
|
|
32
|
+
const signInId = extractSignInId(attachment.content.buttons[0].value);
|
|
33
|
+
const getTestUrlEndpoint = `https://token.botframework.com/api/sas/gettesturl?signInId=${signInId}`;
|
|
34
|
+
try {
|
|
35
|
+
const response = await window.fetch(getTestUrlEndpoint);
|
|
36
|
+
if (response.status === 200) {
|
|
37
|
+
const responseJson = await response.json();
|
|
38
|
+
sasUrl = responseJson.sasUrl;
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
sasUrl = undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return sasUrl;
|
|
45
|
+
};
|
|
46
|
+
const fetchBotAuthConfig = async retries => {
|
|
47
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
48
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderFetchConfig
|
|
49
|
+
});
|
|
50
|
+
const botAuthConfigRequestEvent = {
|
|
51
|
+
eventName: _TelemetryConstants.BroadcastEvent.BotAuthConfigRequest
|
|
52
|
+
};
|
|
53
|
+
_omnichannelChatComponents.BroadcastService.postMessage(botAuthConfigRequestEvent);
|
|
54
|
+
const listener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.BotAuthConfigResponse).subscribe(data => {
|
|
55
|
+
var _data$payload, _data$payload2;
|
|
56
|
+
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;
|
|
57
|
+
listener.unsubscribe();
|
|
58
|
+
});
|
|
59
|
+
if (response !== undefined) {
|
|
60
|
+
//return response;
|
|
61
|
+
return response;
|
|
62
|
+
}
|
|
63
|
+
if (retries === 1) {
|
|
64
|
+
// Base Case
|
|
65
|
+
throw new Error();
|
|
66
|
+
}
|
|
67
|
+
await delay(fetchBotAuthConfigRetryInterval);
|
|
68
|
+
return await fetchBotAuthConfig(--retries);
|
|
69
|
+
};
|
|
70
|
+
class BotAuthActivitySubscriber {
|
|
71
|
+
constructor() {
|
|
72
|
+
_defineProperty(this, "observer", void 0);
|
|
73
|
+
_defineProperty(this, "signInCardSeen", void 0);
|
|
74
|
+
this.signInCardSeen = new Set();
|
|
75
|
+
}
|
|
76
|
+
applicable(activity) {
|
|
77
|
+
var _activity$attachments;
|
|
78
|
+
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;
|
|
79
|
+
}
|
|
80
|
+
async apply(activity) {
|
|
81
|
+
this.observer.next(false); // Hides card
|
|
82
|
+
const attachment = activity.attachments[0];
|
|
83
|
+
const signInUrl = attachment.content.buttons[0].value;
|
|
84
|
+
const signInId = extractSignInId(signInUrl);
|
|
85
|
+
if (!signInId) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (this.signInCardSeen.has(signInId)) {
|
|
89
|
+
// Prevents duplicate auth
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.signInCardSeen.add(signInId);
|
|
93
|
+
const sasUrl = await extractSasUrl(attachment);
|
|
94
|
+
const event = {
|
|
95
|
+
eventName: _TelemetryConstants.BroadcastEvent.SigninCardReceived,
|
|
96
|
+
payload: {
|
|
97
|
+
sasUrl
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
if (!sasUrl) {
|
|
101
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
102
|
+
Event: _TelemetryConstants.TelemetryEvent.BotAuthActivityEmptySasUrl,
|
|
103
|
+
Description: "SaS Url is empty"
|
|
104
|
+
});
|
|
105
|
+
return activity;
|
|
106
|
+
} else {
|
|
107
|
+
_omnichannelChatComponents.BroadcastService.postMessage(event);
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const response = await fetchBotAuthConfig(fetchBotAuthConfigRetries);
|
|
111
|
+
if (response === false) {
|
|
112
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
113
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderHideCard
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
117
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderDisplayCard
|
|
118
|
+
});
|
|
119
|
+
return activity;
|
|
120
|
+
}
|
|
121
|
+
} catch {
|
|
122
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
123
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderNotFound
|
|
124
|
+
});
|
|
125
|
+
//this is to ensure listener continues waiting for response
|
|
126
|
+
if (this.signInCardSeen.has(signInId)) {
|
|
127
|
+
this.signInCardSeen.delete(signInId);
|
|
128
|
+
}
|
|
129
|
+
return activity;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async next(activity) {
|
|
133
|
+
if (this.applicable(activity)) {
|
|
134
|
+
return await this.apply(activity);
|
|
135
|
+
}
|
|
136
|
+
return activity;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.BotAuthActivitySubscriber = BotAuthActivitySubscriber;
|
|
@@ -10,6 +10,7 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
|
|
|
10
10
|
var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
11
11
|
var _ChatAdapterShim = require("./ChatAdapterShim");
|
|
12
12
|
var _PauseActivitySubscriber = require("./ActivitySubscriber/PauseActivitySubscriber");
|
|
13
|
+
var _BotAuthActivitySubscriber = require("./ActivitySubscriber/BotAuthActivitySubscriber");
|
|
13
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
15
|
const createAdapter = async chatSDK => {
|
|
15
16
|
const chatAdapterOptionalParams = {
|
|
@@ -34,6 +35,7 @@ const createAdapter = async chatSDK => {
|
|
|
34
35
|
if (chatSDK.isMockModeOn !== true) {
|
|
35
36
|
adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
|
|
36
37
|
adapter.addSubscriber(new _PauseActivitySubscriber.PauseActivitySubscriber());
|
|
38
|
+
adapter.addSubscriber(new _BotAuthActivitySubscriber.BotAuthActivitySubscriber());
|
|
37
39
|
return adapter.chatAdapter;
|
|
38
40
|
}
|
|
39
41
|
return adapter;
|
|
@@ -17,9 +17,9 @@ var _utils = require("../../../common/utils");
|
|
|
17
17
|
var _authHelper = require("./authHelper");
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
19
|
const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
20
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
21
|
-
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;
|
|
22
|
-
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;
|
|
20
|
+
var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2, _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
21
|
+
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);
|
|
22
|
+
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);
|
|
23
23
|
|
|
24
24
|
//Unable to end chat if token has expired
|
|
25
25
|
if (props.getAuthToken) {
|
|
@@ -61,15 +61,20 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
61
61
|
chatSDK.requestId = chatSession.requestId;
|
|
62
62
|
}
|
|
63
63
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
// Only start embedded Postchat workflow if postchat context is set successfully else close chat
|
|
65
|
+
if (state.domainStates.postChatContext) {
|
|
66
|
+
dispatch({
|
|
67
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
68
|
+
payload: _ConversationState.ConversationState.PostchatLoading
|
|
69
|
+
});
|
|
70
|
+
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
71
|
+
const loadPostChatEvent = {
|
|
72
|
+
eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
|
|
73
|
+
};
|
|
74
|
+
_omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
|
|
75
|
+
} else {
|
|
76
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, true, false, true);
|
|
77
|
+
}
|
|
73
78
|
} else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
|
|
74
79
|
var _props$webChatContain, _props$webChatContain2;
|
|
75
80
|
dispatch({
|
|
@@ -39,7 +39,7 @@ var _Constants = require("../../../common/Constants");
|
|
|
39
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
41
|
const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
42
|
-
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;
|
|
42
|
+
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;
|
|
43
43
|
const localizedTexts = {
|
|
44
44
|
..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
|
|
45
45
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -47,8 +47,8 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
47
47
|
const disableNewLineMarkdownSupport = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.disableNewLineMarkdownSupport) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
|
|
48
48
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
49
49
|
const markdown = (0, _createMarkdown.createMarkdown)(((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableMarkdownMessageFormatting) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
|
|
50
|
-
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;
|
|
51
|
-
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;
|
|
50
|
+
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);
|
|
51
|
+
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);
|
|
52
52
|
|
|
53
53
|
// Initialize Web Chat's redux store
|
|
54
54
|
let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
|
|
@@ -70,16 +70,28 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
70
70
|
}
|
|
71
71
|
if (isPostChatEnabled === "true") {
|
|
72
72
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
// Only start embedded Postchat workflow if postchat context is set successfully else close chat
|
|
74
|
+
if (state.domainStates.postChatContext) {
|
|
75
|
+
_WebChatStoreLoader.WebChatStoreLoader.store = null;
|
|
76
|
+
dispatch({
|
|
77
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
78
|
+
payload: _ConversationState.ConversationState.PostchatLoading
|
|
79
|
+
});
|
|
80
|
+
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
81
|
+
const loadPostChatEvent = {
|
|
82
|
+
eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
|
|
83
|
+
};
|
|
84
|
+
_omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
|
|
85
|
+
} else {
|
|
86
|
+
dispatch({
|
|
87
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
88
|
+
payload: _ConversationState.ConversationState.InActive
|
|
89
|
+
});
|
|
90
|
+
dispatch({
|
|
91
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
|
|
92
|
+
payload: true
|
|
93
|
+
});
|
|
94
|
+
}
|
|
83
95
|
} else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
|
|
84
96
|
dispatch({
|
|
85
97
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -128,6 +140,7 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
128
140
|
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.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
129
141
|
onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
|
|
130
142
|
cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
143
|
+
sendTypingIndicator: true,
|
|
131
144
|
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
132
145
|
};
|
|
133
146
|
return webChatProps;
|
|
@@ -55,7 +55,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
55
55
|
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; }
|
|
56
56
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
57
57
|
const LiveChatWidgetStateful = props => {
|
|
58
|
-
var _props$webChatContain, _props$styleProps, _chatSDK$omnichannelC, _props$controlProps, _props$controlProps2, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$
|
|
58
|
+
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;
|
|
59
59
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
60
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
61
|
const [adapter, setAdapter] = (0, _useChatAdapterStore.default)();
|
|
@@ -214,7 +214,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
214
214
|
|
|
215
215
|
// useEffect for custom context
|
|
216
216
|
(0, _react2.useEffect)(() => {
|
|
217
|
-
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$
|
|
217
|
+
var _chatSDK$omnichannelC8, _chatSDK$omnichannelC9, _props$controlProps13;
|
|
218
218
|
// Add the custom context on receiving the SetCustomContext event
|
|
219
219
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
220
220
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -242,14 +242,33 @@ const LiveChatWidgetStateful = props => {
|
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
|
|
245
|
+
// Toggle chat visibility
|
|
246
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.HideChatVisibilityChangeEvent).subscribe(event => {
|
|
247
|
+
var _event$payload;
|
|
248
|
+
if ((event === null || event === void 0 ? void 0 : (_event$payload = event.payload) === null || _event$payload === void 0 ? void 0 : _event$payload.isChatHidden) !== undefined) {
|
|
249
|
+
var _event$payload2, _props$controlProps10;
|
|
250
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
251
|
+
Event: _TelemetryConstants.TelemetryEvent.ChatVisibilityChanged,
|
|
252
|
+
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)
|
|
253
|
+
});
|
|
254
|
+
if ((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideStartChatButton) {
|
|
255
|
+
var _event$payload3;
|
|
256
|
+
dispatch({
|
|
257
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
258
|
+
payload: event === null || event === void 0 ? void 0 : (_event$payload3 = event.payload) === null || _event$payload3 === void 0 ? void 0 : _event$payload3.isChatHidden
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
245
264
|
// Start chat from SDK Event
|
|
246
265
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
247
|
-
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$
|
|
266
|
+
var _chatSDK$omnichannelC4, _chatSDK$omnichannelC5, _props$controlProps11;
|
|
248
267
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
249
268
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
250
269
|
Description: "Start chat event received."
|
|
251
270
|
});
|
|
252
|
-
const persistedState = (0, _utils.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$
|
|
271
|
+
const persistedState = (0, _utils.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) ?? "");
|
|
253
272
|
|
|
254
273
|
// Chat not found in cache
|
|
255
274
|
if (persistedState === undefined) {
|
|
@@ -290,9 +309,9 @@ const LiveChatWidgetStateful = props => {
|
|
|
290
309
|
// End chat
|
|
291
310
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
292
311
|
if (state.appStates.hideStartChatButton === false) {
|
|
293
|
-
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$
|
|
312
|
+
var _chatSDK$omnichannelC6, _chatSDK$omnichannelC7, _props$controlProps12;
|
|
294
313
|
// This is to ensure to get latest state from cache in multitab
|
|
295
|
-
const persistedState = (0, _utils.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$
|
|
314
|
+
const persistedState = (0, _utils.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) ?? "");
|
|
296
315
|
if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
297
316
|
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
298
317
|
} else {
|
|
@@ -312,7 +331,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
312
331
|
});
|
|
313
332
|
|
|
314
333
|
// Listen to end chat event from other tabs
|
|
315
|
-
const endChatEventName = (0, _utils.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$
|
|
334
|
+
const endChatEventName = (0, _utils.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) ?? "");
|
|
316
335
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
317
336
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
318
337
|
return;
|
|
@@ -417,7 +436,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
417
436
|
|
|
418
437
|
// Publish chat widget state
|
|
419
438
|
(0, _react2.useEffect)(() => {
|
|
420
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$
|
|
439
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps14;
|
|
421
440
|
// Only activate these windows events when conversation state is active and chat widget is in popout mode
|
|
422
441
|
// Ghost chat scenarios
|
|
423
442
|
/* COMMENTING THIS CODE FOR PARITY WITH OLD LCW
|
|
@@ -435,7 +454,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
435
454
|
};
|
|
436
455
|
}*/
|
|
437
456
|
|
|
438
|
-
widgetStateEventName = (0, _utils.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$
|
|
457
|
+
widgetStateEventName = (0, _utils.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) ?? "");
|
|
439
458
|
const chatWidgetStateChangeEvent = {
|
|
440
459
|
eventName: widgetStateEventName,
|
|
441
460
|
payload: {
|
|
@@ -497,29 +516,29 @@ const LiveChatWidgetStateful = props => {
|
|
|
497
516
|
id: widgetElementId,
|
|
498
517
|
styles: generalStyles,
|
|
499
518
|
className: (_props$styleProps2 = props.styleProps) === null || _props$styleProps2 === void 0 ? void 0 : _props$styleProps2.className
|
|
500
|
-
}, !((_props$
|
|
519
|
+
}, !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hideChatButton) && !((_props$controlProps16 = props.controlProps) !== null && _props$controlProps16 !== void 0 && _props$controlProps16.hideStartChatButton) && (0, _componentController.shouldShowChatButton)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.chatButton) || /*#__PURE__*/_react2.default.createElement(_ChatButtonStateful.default, {
|
|
501
520
|
buttonProps: props.chatButtonProps,
|
|
502
521
|
outOfOfficeButtonProps: props.outOfOfficeChatButtonProps,
|
|
503
522
|
startChat: prepareStartChatRelay
|
|
504
|
-
})), !((_props$
|
|
523
|
+
})), !((_props$controlProps17 = props.controlProps) !== null && _props$controlProps17 !== void 0 && _props$controlProps17.hideProactiveChatPane) && (0, _componentController.shouldShowProactiveChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.proactiveChatPane) || /*#__PURE__*/_react2.default.createElement(_ProactiveChatPaneStateful.default, {
|
|
505
524
|
proactiveChatProps: props.proactiveChatPaneProps,
|
|
506
525
|
startChat: prepareStartChatRelay
|
|
507
|
-
})), !((_props$
|
|
526
|
+
})), !((_props$controlProps18 = props.controlProps) !== null && _props$controlProps18 !== void 0 && _props$controlProps18.hideHeader) && (0, _componentController.shouldShowHeader)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr3 = props.componentOverrides) === null || _props$componentOverr3 === void 0 ? void 0 : _props$componentOverr3.header) || /*#__PURE__*/_react2.default.createElement(_HeaderStateful.default, {
|
|
508
527
|
headerProps: props.headerProps,
|
|
509
528
|
outOfOfficeHeaderProps: props.outOfOfficeHeaderProps,
|
|
510
529
|
endChat: endChatRelay
|
|
511
|
-
})), !((_props$
|
|
530
|
+
})), !((_props$controlProps19 = props.controlProps) !== null && _props$controlProps19 !== void 0 && _props$controlProps19.hideLoadingPane) && (0, _componentController.shouldShowLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/_react2.default.createElement(_LoadingPaneStateful.default, props.loadingPaneProps)), !((_props$controlProps20 = props.controlProps) !== null && _props$controlProps20 !== void 0 && _props$controlProps20.hideOutOfOfficeHoursPane) && (0, _componentController.shouldShowOutOfOfficeHoursPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/_react2.default.createElement(_OOOHPaneStateful.default, props.outOfOfficeHoursPaneProps)), !((_props$controlProps21 = props.controlProps) !== null && _props$controlProps21 !== void 0 && _props$controlProps21.hideReconnectChatPane) && (0, _componentController.shouldShowReconnectChatPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/_react2.default.createElement(_ReconnectChatPaneStateful.default, {
|
|
512
531
|
reconnectChatProps: props.reconnectChatPaneProps,
|
|
513
532
|
initStartChat: initStartChatRelay
|
|
514
|
-
})), !((_props$
|
|
533
|
+
})), !((_props$controlProps22 = props.controlProps) !== null && _props$controlProps22 !== void 0 && _props$controlProps22.hidePreChatSurveyPane) && (0, _componentController.shouldShowPreChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PreChatSurveyPaneStateful.default, {
|
|
515
534
|
surveyProps: props.preChatSurveyPaneProps,
|
|
516
535
|
initStartChat: initStartChatRelay
|
|
517
|
-
})), !((_props$
|
|
536
|
+
})), !((_props$controlProps23 = props.controlProps) !== null && _props$controlProps23 !== void 0 && _props$controlProps23.hideCallingContainer) && (0, _componentController.shouldShowCallingContainer)(state) && /*#__PURE__*/_react2.default.createElement(_CallingContainerStateful.default, _extends({
|
|
518
537
|
voiceVideoCallingSdk: voiceVideoCallingSDK
|
|
519
|
-
}, props.callingContainerProps)), !((_props$
|
|
538
|
+
}, props.callingContainerProps)), !((_props$controlProps24 = props.controlProps) !== null && _props$controlProps24 !== void 0 && _props$controlProps24.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, props.webChatContainerProps)), !((_props$controlProps25 = props.controlProps) !== null && _props$controlProps25 !== void 0 && _props$controlProps25.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
|
|
520
539
|
setPostChatContext: setPostChatContextRelay,
|
|
521
540
|
prepareEndChat: prepareEndChatRelay
|
|
522
|
-
}))), !((_props$
|
|
541
|
+
}))), !((_props$controlProps26 = props.controlProps) !== null && _props$controlProps26 !== void 0 && _props$controlProps26.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, props.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), (0, _createFooter.createFooter)(props, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, props.emailTranscriptPane)))));
|
|
523
542
|
};
|
|
524
543
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
525
544
|
var _default = LiveChatWidgetStateful;
|