@microsoft/omnichannel-chat-widget 0.1.0-main.4188c11 → 0.1.0-main.592da7b
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 +32 -0
- package/lib/cjs/common/Constants.js +14 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +15 -3
- package/lib/cjs/common/utils.js +16 -2
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -3
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +10 -1
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +7 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +24 -6
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +86 -31
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +142 -45
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -6
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/cjs/controller/componentController.js +1 -1
- package/lib/esm/common/Constants.js +14 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +15 -3
- package/lib/esm/common/utils.js +7 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +21 -6
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -2
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +7 -1
- package/lib/esm/components/livechatwidget/common/endChat.js +21 -6
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +7 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +85 -34
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +134 -46
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/esm/controller/componentController.js +1 -1
- package/lib/types/common/Constants.d.ts +7 -1
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +16 -4
- package/lib/types/common/utils.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
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)
|
|
14
16
|
1. [See Also](#see-also)
|
|
15
17
|
|
|
16
18
|
## Introduction
|
|
@@ -218,6 +220,36 @@ const customizedFooterProp: IFooterProps = {
|
|
|
218
220
|
|
|
219
221
|
> :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
|
|
220
222
|
|
|
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
|
+
|
|
221
253
|
## See Also
|
|
222
254
|
|
|
223
255
|
[Telemetry](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Telemetry.md)\
|
|
@@ -13,6 +13,10 @@ class Constants {}
|
|
|
13
13
|
|
|
14
14
|
exports.Constants = Constants;
|
|
15
15
|
|
|
16
|
+
_defineProperty(Constants, "magicCodeBroadcastChannel", "MagicCodeChannel");
|
|
17
|
+
|
|
18
|
+
_defineProperty(Constants, "magicCodeResponseBroadcastChannel", "MagicCodeResponseChannel");
|
|
19
|
+
|
|
16
20
|
_defineProperty(Constants, "systemMessageTag", "system");
|
|
17
21
|
|
|
18
22
|
_defineProperty(Constants, "userMessageTag", "user");
|
|
@@ -45,8 +49,6 @@ _defineProperty(Constants, "false", "false");
|
|
|
45
49
|
|
|
46
50
|
_defineProperty(Constants, "maximumUnreadMessageCount", 99);
|
|
47
51
|
|
|
48
|
-
_defineProperty(Constants, "widgetStateDataKey", "LcwChatWidgetState");
|
|
49
|
-
|
|
50
52
|
_defineProperty(Constants, "channelIdKey", "ChannelId-");
|
|
51
53
|
|
|
52
54
|
_defineProperty(Constants, "ChannelId", "lcw");
|
|
@@ -81,6 +83,14 @@ _defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
|
|
|
81
83
|
|
|
82
84
|
_defineProperty(Constants, "message", "message");
|
|
83
85
|
|
|
86
|
+
_defineProperty(Constants, "hiddenTag", "Hidden");
|
|
87
|
+
|
|
88
|
+
_defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
|
|
89
|
+
|
|
90
|
+
_defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
|
|
91
|
+
|
|
92
|
+
_defineProperty(Constants, "publicMessageTag", "public");
|
|
93
|
+
|
|
84
94
|
_defineProperty(Constants, "supportedAdaptiveCardContentTypes", ["application/vnd.microsoft.card.adaptive", "application/vnd.microsoft.card.audio", "application/vnd.microsoft.card.hero", "application/vnd.microsoft.card.receipt", "application/vnd.microsoft.card.thumbnail", "application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"]);
|
|
85
95
|
|
|
86
96
|
_defineProperty(Constants, "maxUploadFileSize", "500000");
|
|
@@ -155,6 +165,8 @@ _defineProperty(Constants, "internetConnectionTestUrl", "https://ocsdk-prod.azur
|
|
|
155
165
|
|
|
156
166
|
_defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect Test");
|
|
157
167
|
|
|
168
|
+
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
169
|
+
|
|
158
170
|
const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
159
171
|
exports.Regex = Regex;
|
|
160
172
|
|
|
@@ -37,19 +37,28 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
37
37
|
|
|
38
38
|
(function (BroadcastEvent) {
|
|
39
39
|
BroadcastEvent["LoadPostChatSurvey"] = "LoadPostChatSurvey";
|
|
40
|
-
BroadcastEvent["
|
|
40
|
+
BroadcastEvent["ChatEnded"] = "ChatEnded";
|
|
41
41
|
BroadcastEvent["NewMessageNotification"] = "NewMessageNotification";
|
|
42
42
|
BroadcastEvent["UnreadMessageCount"] = "UnreadMessageCount";
|
|
43
|
-
BroadcastEvent["
|
|
43
|
+
BroadcastEvent["StartProactiveChat"] = "StartProactiveChat";
|
|
44
44
|
BroadcastEvent["ProactiveChatStartChat"] = "ProactiveChatStartChat";
|
|
45
45
|
BroadcastEvent["ProactiveChatStartPopoutChat"] = "ProactiveChatStartPopoutChat";
|
|
46
|
+
BroadcastEvent["ProactiveChatIsInPopoutMode"] = "ProactiveChatIsInPopoutMode";
|
|
47
|
+
BroadcastEvent["ResetProactiveChatParams"] = "ResetProactiveChatParams";
|
|
46
48
|
BroadcastEvent["InvalidAdaptiveCardFormat"] = "InvalidAdaptiveCardFormat";
|
|
47
49
|
BroadcastEvent["NewMessageSent"] = "NewMessageSent";
|
|
48
50
|
BroadcastEvent["NewMessageReceived"] = "NewMessageReceived";
|
|
49
51
|
BroadcastEvent["RedirectPageRequest"] = "RedirectPageRequest";
|
|
52
|
+
BroadcastEvent["StartChat"] = "StartChat";
|
|
50
53
|
BroadcastEvent["StartChatSkippingChatButtonRendering"] = "StartChatSkippingChatButtonRendering";
|
|
51
54
|
BroadcastEvent["StartUnauthenticatedReconnectChat"] = "StartUnauthenticatedReconnectChat";
|
|
55
|
+
BroadcastEvent["InitiateEndChat"] = "InitiateEndChat";
|
|
52
56
|
BroadcastEvent["SetCustomContext"] = "SetCustomContext";
|
|
57
|
+
BroadcastEvent["ChatRetrievedFromCache"] = "ChatRetrievedFromCache";
|
|
58
|
+
BroadcastEvent["MaximizeChat"] = "MaximizeChat";
|
|
59
|
+
BroadcastEvent["ChatInitiated"] = "ChatInitiated";
|
|
60
|
+
BroadcastEvent["CloseChat"] = "CloseChat";
|
|
61
|
+
BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
|
|
53
62
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
54
63
|
|
|
55
64
|
let TelemetryEvent;
|
|
@@ -102,8 +111,9 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
102
111
|
TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
|
|
103
112
|
TelemetryEvent["StartChatSDKCall"] = "StartChatCall";
|
|
104
113
|
TelemetryEvent["StartChatEventRecevied"] = "StartChatEventReceived";
|
|
105
|
-
TelemetryEvent["EndChatSDKCall"] = "
|
|
114
|
+
TelemetryEvent["EndChatSDKCall"] = "EndChatSDKCall";
|
|
106
115
|
TelemetryEvent["EndChatEventReceived"] = "EndChatEventReceived";
|
|
116
|
+
TelemetryEvent["WindowClosed"] = "WindowClosed";
|
|
107
117
|
TelemetryEvent["OnNewMessageFailed"] = "OnNewMessageFailed";
|
|
108
118
|
TelemetryEvent["OnNewMessageAudioNotificationFailed"] = "OnNewMessageAudioNotificationFailed";
|
|
109
119
|
TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
|
|
@@ -128,6 +138,8 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
128
138
|
TelemetryEvent["EmailTranscriptButtonClicked"] = "EmailTranscriptButtonClicked";
|
|
129
139
|
TelemetryEvent["EmailTranscriptCancelButtonClicked"] = "EmailTranscriptCancelButtonClicked";
|
|
130
140
|
TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
|
|
141
|
+
TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
|
|
142
|
+
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
131
143
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
132
144
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
133
145
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
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.isNullOrUndefined = exports.isNullOrEmptyString = exports.getTimestampHourMinute = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = void 0;
|
|
6
|
+
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = void 0;
|
|
7
7
|
|
|
8
8
|
var _Constants = require("./Constants");
|
|
9
9
|
|
|
10
10
|
var _KeyCodes = require("./KeyCodes");
|
|
11
11
|
|
|
12
|
+
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
13
|
+
|
|
12
14
|
const getElementBySelector = selector => {
|
|
13
15
|
let element;
|
|
14
16
|
|
|
@@ -348,4 +350,16 @@ const getDomain = hostValue => {
|
|
|
348
350
|
return _Constants.AriaTelemetryConstants.Public;
|
|
349
351
|
};
|
|
350
352
|
|
|
351
|
-
exports.getDomain = getDomain;
|
|
353
|
+
exports.getDomain = getDomain;
|
|
354
|
+
|
|
355
|
+
const getWidgetCacheId = (orgId, widgetId) => {
|
|
356
|
+
return `${_Constants.Constants.ChatWidgetStateChangedPrefix}_${orgId}_${widgetId}`;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
exports.getWidgetCacheId = getWidgetCacheId;
|
|
360
|
+
|
|
361
|
+
const getWidgetEndChatEventName = (orgId, widgetId) => {
|
|
362
|
+
return `${_TelemetryConstants.BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
exports.getWidgetEndChatEventName = getWidgetEndChatEventName;
|
|
@@ -34,7 +34,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
34
34
|
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; }
|
|
35
35
|
|
|
36
36
|
const ChatButtonStateful = props => {
|
|
37
|
-
var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP;
|
|
37
|
+
var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP, _props$buttonProps, _props$buttonProps$co, _props$buttonProps2, _props$buttonProps2$c, _props$buttonProps3, _props$buttonProps3$c;
|
|
38
38
|
|
|
39
39
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
40
40
|
const {
|
|
@@ -44,6 +44,7 @@ const ChatButtonStateful = props => {
|
|
|
44
44
|
} = props; //Setting OutOfOperatingHours Flag
|
|
45
45
|
|
|
46
46
|
const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(((_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.OutOfOperatingHours) === "True");
|
|
47
|
+
const proactiveChatInNewWindow = (0, _react.useRef)(state.appStates.proactiveChatStates.proactiveChatInNewWindow);
|
|
47
48
|
const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeChatButtonStyleProps.defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
48
49
|
const controlProps = {
|
|
49
50
|
id: "oc-lcw-chat-button",
|
|
@@ -51,13 +52,19 @@ const ChatButtonStateful = props => {
|
|
|
51
52
|
titleText: "Let's Chat!",
|
|
52
53
|
subtitleText: "We're online.",
|
|
53
54
|
hideNotificationBubble: (buttonProps === null || buttonProps === void 0 ? void 0 : (_buttonProps$controlP = buttonProps.controlProps) === null || _buttonProps$controlP === void 0 ? void 0 : _buttonProps$controlP.hideNotificationBubble) === true || state.appStates.isMinimized === false,
|
|
54
|
-
unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > _Constants.Constants.maximumUnreadMessageCount ?
|
|
55
|
+
unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > _Constants.Constants.maximumUnreadMessageCount ? (_props$buttonProps = props.buttonProps) === null || _props$buttonProps === void 0 ? void 0 : (_props$buttonProps$co = _props$buttonProps.controlProps) === null || _props$buttonProps$co === void 0 ? void 0 : _props$buttonProps$co.largeUnreadMessageString : state.appStates.unreadMessageCount.toString() : "0",
|
|
55
56
|
onClick: async () => {
|
|
56
57
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
57
58
|
Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked
|
|
58
59
|
});
|
|
59
60
|
|
|
60
|
-
if (
|
|
61
|
+
if (proactiveChatInNewWindow.current) {
|
|
62
|
+
const proactiveChatIsInPopoutModeEvent = {
|
|
63
|
+
eventName: _TelemetryConstants.BroadcastEvent.ProactiveChatIsInPopoutMode
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
_omnichannelChatComponents.BroadcastService.postMessage(proactiveChatIsInPopoutModeEvent);
|
|
67
|
+
} else if (state.appStates.isMinimized) {
|
|
61
68
|
dispatch({
|
|
62
69
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
63
70
|
payload: false
|
|
@@ -66,6 +73,7 @@ const ChatButtonStateful = props => {
|
|
|
66
73
|
await startChat();
|
|
67
74
|
}
|
|
68
75
|
},
|
|
76
|
+
unreadMessageString: (_props$buttonProps2 = props.buttonProps) === null || _props$buttonProps2 === void 0 ? void 0 : (_props$buttonProps2$c = _props$buttonProps2.controlProps) === null || _props$buttonProps2$c === void 0 ? void 0 : _props$buttonProps2$c.unreadMessageString,
|
|
69
77
|
...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps)
|
|
70
78
|
};
|
|
71
79
|
const outOfOfficeControlProps = {
|
|
@@ -74,6 +82,10 @@ const ChatButtonStateful = props => {
|
|
|
74
82
|
titleText: "We're Offline",
|
|
75
83
|
subtitleText: "No agents available",
|
|
76
84
|
onClick: async () => {
|
|
85
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
86
|
+
Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked
|
|
87
|
+
});
|
|
88
|
+
|
|
77
89
|
if (state.appStates.isMinimized) {
|
|
78
90
|
dispatch({
|
|
79
91
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -86,6 +98,7 @@ const ChatButtonStateful = props => {
|
|
|
86
98
|
});
|
|
87
99
|
}
|
|
88
100
|
},
|
|
101
|
+
unreadMessageString: (_props$buttonProps3 = props.buttonProps) === null || _props$buttonProps3 === void 0 ? void 0 : (_props$buttonProps3$c = _props$buttonProps3.controlProps) === null || _props$buttonProps3$c === void 0 ? void 0 : _props$buttonProps3$c.unreadMessageString,
|
|
89
102
|
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
|
|
90
103
|
};
|
|
91
104
|
(0, _react.useEffect)(() => {
|
|
@@ -107,6 +120,9 @@ const ChatButtonStateful = props => {
|
|
|
107
120
|
});
|
|
108
121
|
}
|
|
109
122
|
}, []);
|
|
123
|
+
(0, _react.useEffect)(() => {
|
|
124
|
+
proactiveChatInNewWindow.current = state.appStates.proactiveChatStates.proactiveChatInNewWindow;
|
|
125
|
+
}, [state.appStates.proactiveChatStates.proactiveChatInNewWindow]);
|
|
110
126
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.ChatButton, {
|
|
111
127
|
componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
|
|
112
128
|
controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
|
package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -116,8 +116,17 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
116
116
|
let fileAttachmentName = _Constants.TranscriptConstants.DefaultFileAttachmentName;
|
|
117
117
|
let dialogColor = _Constants.TranscriptConstants.CustomerDialogColor;
|
|
118
118
|
let fontColor = _Constants.TranscriptConstants.CustomerFontColor;
|
|
119
|
+
const isSystemMessage = value.tags && value.tags.toLowerCase().indexOf(_Constants.Constants.systemMessageTag) !== -1;
|
|
120
|
+
const isControlMessage = value.isControlMessage && value.isControlMessage === true;
|
|
119
121
|
|
|
120
|
-
|
|
122
|
+
const isAdaptiveCard = value.contentType && value.contentType.toLowerCase() === _Constants.TranscriptConstants.AdaptiveCardType;
|
|
123
|
+
|
|
124
|
+
const isInternalMessage = value.deliveryMode && value.deliveryMode.toLowerCase() === _Constants.TranscriptConstants.InternalMode;
|
|
125
|
+
|
|
126
|
+
const isHiddenMessage = value.tags && value.tags.toLowerCase().indexOf(_Constants.Constants.hiddenTag.toLowerCase()) !== -1;
|
|
127
|
+
const shouldIgnoreMessage = isSystemMessage || isControlMessage || isAdaptiveCard || isInternalMessage || isHiddenMessage;
|
|
128
|
+
|
|
129
|
+
if (shouldIgnoreMessage) {
|
|
121
130
|
return;
|
|
122
131
|
} else if (value.from) {
|
|
123
132
|
if (value.from.application) {
|
|
@@ -337,7 +337,9 @@ const dummyDefaultProps = {
|
|
|
337
337
|
hideChatTextContainer: false,
|
|
338
338
|
hideChatSubtitle: false,
|
|
339
339
|
hideChatTitle: false,
|
|
340
|
-
hideNotificationBubble: true
|
|
340
|
+
hideNotificationBubble: true,
|
|
341
|
+
unreadMessageString: "new messages",
|
|
342
|
+
largeUnreadMessageString: "99+"
|
|
341
343
|
},
|
|
342
344
|
styleProps: {
|
|
343
345
|
generalStyleProps: {
|
|
@@ -1697,6 +1699,10 @@ const dummyDefaultProps = {
|
|
|
1697
1699
|
MIDDLEWARE_MESSAGE_RETRY: "Retry",
|
|
1698
1700
|
PRECHAT_REQUIRED_FIELD_MISSING_MESSAGE: "{0} field is required",
|
|
1699
1701
|
MARKDOWN_EXTERNAL_LINK_ALT: "Opens in a new window; external."
|
|
1702
|
+
},
|
|
1703
|
+
botMagicCode: {
|
|
1704
|
+
disabled: false,
|
|
1705
|
+
fwdUrl: ""
|
|
1700
1706
|
}
|
|
1701
1707
|
},
|
|
1702
1708
|
telemetryConfig: undefined
|
|
@@ -23,6 +23,8 @@ var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostCh
|
|
|
23
23
|
|
|
24
24
|
var _Constants = require("../../../common/Constants");
|
|
25
25
|
|
|
26
|
+
var _utils = require("../../../common/utils");
|
|
27
|
+
|
|
26
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
29
|
const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
28
30
|
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
|
|
@@ -34,7 +36,7 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
34
36
|
if (isPostChatEnabled === "true" && (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
|
|
35
37
|
const skipEndChatSDK = false;
|
|
36
38
|
const skipCloseChat = true;
|
|
37
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
39
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, true);
|
|
38
40
|
|
|
39
41
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
40
42
|
const loadPostChatEvent = {
|
|
@@ -49,14 +51,14 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
} else {
|
|
52
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
54
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
|
|
53
55
|
}
|
|
54
56
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
57
|
|
|
56
58
|
|
|
57
59
|
exports.prepareEndChat = prepareEndChat;
|
|
58
60
|
|
|
59
|
-
const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat) => {
|
|
61
|
+
const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
|
|
60
62
|
if (!skipEndChatSDK) {
|
|
61
63
|
try {
|
|
62
64
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -65,6 +67,10 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
65
67
|
|
|
66
68
|
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat()); // Need to clear these states immediately when chat ended from OC.
|
|
67
69
|
|
|
70
|
+
dispatch({
|
|
71
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
72
|
+
payload: undefined
|
|
73
|
+
});
|
|
68
74
|
dispatch({
|
|
69
75
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
70
76
|
payload: undefined
|
|
@@ -80,6 +86,8 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
80
86
|
exception: ex
|
|
81
87
|
}
|
|
82
88
|
});
|
|
89
|
+
|
|
90
|
+
postMessageToOtherTab = false;
|
|
83
91
|
}
|
|
84
92
|
}
|
|
85
93
|
|
|
@@ -109,10 +117,20 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
109
117
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
|
|
110
118
|
payload: null
|
|
111
119
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
dispatch({
|
|
121
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
122
|
+
payload: 0
|
|
115
123
|
});
|
|
124
|
+
|
|
125
|
+
if (postMessageToOtherTab) {
|
|
126
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
|
|
127
|
+
|
|
128
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId);
|
|
129
|
+
|
|
130
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
131
|
+
eventName: endChatEventName
|
|
132
|
+
});
|
|
133
|
+
}
|
|
116
134
|
} catch (error) {
|
|
117
135
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
118
136
|
Event: _TelemetryConstants.TelemetryEvent.CloseChatMethodException,
|
|
@@ -63,11 +63,15 @@ var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcont
|
|
|
63
63
|
|
|
64
64
|
var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
|
|
65
65
|
|
|
66
|
+
var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware");
|
|
67
|
+
|
|
68
|
+
var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
|
|
69
|
+
|
|
66
70
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
67
71
|
|
|
68
72
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
73
|
const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
70
|
-
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;
|
|
74
|
+
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;
|
|
71
75
|
|
|
72
76
|
const localizedTexts = { ..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
|
|
73
77
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -130,7 +134,7 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
130
134
|
};
|
|
131
135
|
|
|
132
136
|
webChatStore = (0, _botframeworkWebchat.createStore)({}, //initial state
|
|
133
|
-
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
+
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _messageTimestampMiddleware.default, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
138
|
...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
|
|
135
139
|
_WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
|
|
136
140
|
} // Initialize the remaining Web Chat props
|
|
@@ -148,7 +152,8 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
148
152
|
groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
149
153
|
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,
|
|
150
154
|
onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
|
|
151
|
-
|
|
155
|
+
cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
156
|
+
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
152
157
|
};
|
|
153
158
|
return webChatProps;
|
|
154
159
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.prepareStartChat = exports.initStartChat = void 0;
|
|
6
|
+
exports.setupChatState = exports.prepareStartChat = exports.initStartChat = void 0;
|
|
7
7
|
|
|
8
8
|
var _Constants = require("../../../common/Constants");
|
|
9
9
|
|
|
@@ -35,7 +35,11 @@ var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurve
|
|
|
35
35
|
|
|
36
36
|
var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
|
|
37
37
|
|
|
38
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
39
|
+
|
|
38
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
|
|
39
43
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
40
44
|
var _props$reconnectChatP;
|
|
41
45
|
|
|
@@ -49,11 +53,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
49
53
|
|
|
50
54
|
await (0, _reconnectChatHelper.handleRedirectUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
51
55
|
} else {
|
|
52
|
-
// Getting
|
|
53
|
-
const parseToJson = false;
|
|
54
|
-
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
55
|
-
const showPrechat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
56
|
-
|
|
56
|
+
// Getting reconnectId for authenticated chat
|
|
57
57
|
const reconnectId = await (0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK);
|
|
58
58
|
|
|
59
59
|
if (reconnectId) {
|
|
@@ -65,32 +65,61 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
65
65
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
66
66
|
payload: _ConversationState.ConversationState.ReconnectChat
|
|
67
67
|
});
|
|
68
|
-
} else if (showPrechat) {
|
|
69
|
-
dispatch({
|
|
70
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
71
|
-
payload: preChatSurveyResponse
|
|
72
|
-
});
|
|
73
|
-
dispatch({
|
|
74
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
75
|
-
payload: _ConversationState.ConversationState.Prechat
|
|
76
|
-
});
|
|
77
68
|
} else {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
payload: _ConversationState.ConversationState.Loading
|
|
81
|
-
});
|
|
82
|
-
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
69
|
+
setCustomContextParams(props, chatSDK);
|
|
70
|
+
setupChatState(chatSDK, dispatch, setAdapter, state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat, state.appStates.proactiveChatStates.proactiveChatEnablePrechat);
|
|
83
71
|
}
|
|
84
72
|
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.prepareStartChat = prepareStartChat;
|
|
76
|
+
|
|
77
|
+
const setupChatState = async (chatSDK, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
|
|
78
|
+
// Getting PreChat Survey Context
|
|
79
|
+
const parseToJson = false;
|
|
80
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
81
|
+
const showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse;
|
|
82
|
+
|
|
83
|
+
if (showPrechat) {
|
|
84
|
+
dispatch({
|
|
85
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
86
|
+
payload: preChatSurveyResponse
|
|
87
|
+
});
|
|
88
|
+
dispatch({
|
|
89
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
90
|
+
payload: _ConversationState.ConversationState.Prechat
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
dispatch({
|
|
94
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
95
|
+
payload: _ConversationState.ConversationState.Loading
|
|
96
|
+
});
|
|
97
|
+
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
98
|
+
}
|
|
85
99
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
100
|
|
|
87
101
|
|
|
88
|
-
exports.
|
|
102
|
+
exports.setupChatState = setupChatState;
|
|
89
103
|
|
|
90
104
|
const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
|
|
91
105
|
try {
|
|
92
106
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
93
107
|
|
|
108
|
+
let isStartChatSuccessful = false;
|
|
109
|
+
|
|
110
|
+
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
111
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|
|
112
|
+
|
|
113
|
+
// Broadcasting limited cached chat details
|
|
114
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
115
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatRetrievedFromCache,
|
|
116
|
+
payload: {
|
|
117
|
+
chatId: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.liveChatContext) === null || _persistedState$domai2 === void 0 ? void 0 : (_persistedState$domai3 = _persistedState$domai2.chatToken) === null || _persistedState$domai3 === void 0 ? void 0 : _persistedState$domai3.chatId,
|
|
118
|
+
requestId: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai4 = persistedState.domainStates) === null || _persistedState$domai4 === void 0 ? void 0 : (_persistedState$domai5 = _persistedState$domai4.liveChatContext) === null || _persistedState$domai5 === void 0 ? void 0 : _persistedState$domai5.requestId
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
94
123
|
try {
|
|
95
124
|
_TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
|
|
96
125
|
|
|
@@ -98,7 +127,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
98
127
|
Event: _TelemetryConstants.TelemetryEvent.StartChatSDKCall
|
|
99
128
|
});
|
|
100
129
|
|
|
101
|
-
|
|
130
|
+
optionalParams = Object.assign({}, params, optionalParams);
|
|
131
|
+
await chatSDK.startChat(optionalParams);
|
|
132
|
+
isStartChatSuccessful = true;
|
|
102
133
|
} catch (error) {
|
|
103
134
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
104
135
|
Event: _TelemetryConstants.TelemetryEvent.StartChatMethodException,
|
|
@@ -106,6 +137,8 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
106
137
|
exception: `Failed to setup startChat: ${error}`
|
|
107
138
|
}
|
|
108
139
|
});
|
|
140
|
+
|
|
141
|
+
isStartChatSuccessful = false;
|
|
109
142
|
}
|
|
110
143
|
|
|
111
144
|
const newAdapter = await (0, _createAdapter.createAdapter)(chatSDK);
|
|
@@ -133,10 +166,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
133
166
|
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
134
167
|
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch); // Set app state to Active
|
|
135
168
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
169
|
+
if (isStartChatSuccessful) {
|
|
170
|
+
dispatch({
|
|
171
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
172
|
+
payload: _ConversationState.ConversationState.Active
|
|
173
|
+
});
|
|
174
|
+
}
|
|
140
175
|
} else {
|
|
141
176
|
dispatch({
|
|
142
177
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
@@ -171,6 +206,8 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
171
206
|
payload: _ConversationState.ConversationState.OutOfOffice
|
|
172
207
|
});
|
|
173
208
|
}
|
|
209
|
+
} finally {
|
|
210
|
+
optionalParams = {};
|
|
174
211
|
}
|
|
175
212
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
176
213
|
|
|
@@ -178,24 +215,42 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
178
215
|
exports.initStartChat = initStartChat;
|
|
179
216
|
|
|
180
217
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
181
|
-
var _DataStoreManager$cli, _persistedState$
|
|
218
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli, _persistedState$domai6;
|
|
182
219
|
|
|
183
|
-
const
|
|
220
|
+
const widgetStateEventName = (0, _utils.getWidgetCacheId)((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId) ?? "");
|
|
221
|
+
const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
184
222
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
185
223
|
|
|
186
|
-
if (persistedState !== null && persistedState !== void 0 && (_persistedState$
|
|
187
|
-
var _persistedState$
|
|
224
|
+
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai6 = persistedState.domainStates) !== null && _persistedState$domai6 !== void 0 && _persistedState$domai6.liveChatContext) {
|
|
225
|
+
var _persistedState$domai7;
|
|
188
226
|
|
|
189
227
|
dispatch({
|
|
190
228
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
191
229
|
payload: _ConversationState.ConversationState.Loading
|
|
192
230
|
});
|
|
193
231
|
const optionalParams = {
|
|
194
|
-
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$
|
|
232
|
+
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
195
233
|
};
|
|
196
234
|
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
197
235
|
return true;
|
|
198
236
|
} else {
|
|
199
237
|
return false;
|
|
200
238
|
}
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const setCustomContextParams = (props, chatSDK) => {
|
|
242
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4, _DataStoreManager$cli2, _props$chatConfig, _persistedState$domai8;
|
|
243
|
+
|
|
244
|
+
// Add custom context if any only for unauthenticated chat
|
|
245
|
+
const widgetStateEventName = (0, _utils.getWidgetCacheId)((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId) ?? "");
|
|
246
|
+
const widgetStateFromCache = (_DataStoreManager$cli2 = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli2 === void 0 ? void 0 : _DataStoreManager$cli2.getData(widgetStateEventName, "localStorage");
|
|
247
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
248
|
+
|
|
249
|
+
if (!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) && persistedState !== null && persistedState !== void 0 && (_persistedState$domai8 = persistedState.domainStates) !== null && _persistedState$domai8 !== void 0 && _persistedState$domai8.customContext) {
|
|
250
|
+
var _persistedState$domai9;
|
|
251
|
+
|
|
252
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
253
|
+
customContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.customContext
|
|
254
|
+
});
|
|
255
|
+
}
|
|
201
256
|
};
|