@microsoft/omnichannel-chat-widget 1.8.2-main.e3c1d40 → 1.8.2-main.f638bed
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 +48 -1
- package/lib/cjs/common/Constants.js +16 -3
- package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/cjs/common/utils.js +27 -2
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
- package/lib/cjs/components/draggable/DraggableChatWidget.js +16 -1
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
- package/lib/cjs/components/livechatwidget/common/customEventHandler.js +53 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +18 -7
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +32 -1
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +18 -1
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +31 -7
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +15 -2
- package/lib/cjs/components/livechatwidget/common/startChat.js +6 -4
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -12
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +4 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +12 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +41 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +45 -0
- package/lib/cjs/contexts/common/CustomEventType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +3 -1
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
- package/lib/cjs/contexts/createReducer.js +30 -0
- package/lib/cjs/controller/componentController.js +2 -2
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
- package/lib/cjs/firstresponselatency/util.js +60 -31
- package/lib/cjs/plugins/newMessageEventHandler.js +12 -6
- package/lib/esm/common/Constants.js +14 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/esm/common/utils.js +21 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
- package/lib/esm/components/draggable/DraggableChatWidget.js +16 -1
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
- package/lib/esm/components/livechatwidget/common/customEventHandler.js +45 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +18 -7
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +32 -1
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +16 -0
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +33 -9
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +16 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +6 -4
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -12
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +4 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +12 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +33 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +38 -0
- package/lib/esm/contexts/common/CustomEventType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +3 -1
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
- package/lib/esm/contexts/createReducer.js +30 -0
- package/lib/esm/controller/componentController.js +2 -2
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
- package/lib/esm/firstresponselatency/util.js +57 -29
- package/lib/esm/plugins/newMessageEventHandler.js +12 -6
- package/lib/types/common/Constants.d.ts +13 -2
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -0
- package/lib/types/common/utils.d.ts +8 -0
- package/lib/types/components/livechatwidget/common/customEventHandler.d.ts +4 -0
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.d.ts +22 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/CustomEventType.d.ts +6 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
- package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +2 -2
- package/lib/types/firstresponselatency/util.d.ts +17 -0
- package/lib/types/plugins/newMessageEventHandler.d.ts +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -101,6 +101,8 @@ A javascript sample widget can be found in this repo [here](https://github.com/m
|
|
|
101
101
|
|
|
102
102
|
A typescript sample widget can be found [here](https://github.com/microsoft/omnichannel-chat-widget/tree/main/chat-widget/samples/typescript-sample). To build it, do ```yarn install``` then ```yarn build``` then ```yarn start``` from typescript sample project root. See [Create LiveChatWidget with Webpack5 and TypeScript](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/BuildingUsingWebpack5.md) for additional typescript sample project resources.
|
|
103
103
|
|
|
104
|
+
```react-scripts``` has deprecated to build the sample project, please refer to vite building instructions: [BuildingUsingVite.md](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/BuildingUsingVite.md)
|
|
105
|
+
|
|
104
106
|
## Components
|
|
105
107
|
|
|
106
108
|
For a detailed guide on how to customize each component with sample usages, please see our new [Developer Guide](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/customizations/getstarted.md).
|
|
@@ -221,6 +223,51 @@ const customizedFooterProp: IFooterProps = {
|
|
|
221
223
|
|
|
222
224
|
> :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
|
|
223
225
|
|
|
226
|
+
#### Bidirectional Custom Events
|
|
227
|
+
- Sending events from a hosting web page to bots/agents
|
|
228
|
+
- Register a function to post event
|
|
229
|
+
```js
|
|
230
|
+
//define sendCustomEvent function
|
|
231
|
+
const sendCustomEvent = (payload) => {
|
|
232
|
+
const customEvent = {
|
|
233
|
+
eventName: "sendCustomEvent",
|
|
234
|
+
payload
|
|
235
|
+
};
|
|
236
|
+
BroadcastService.postMessage(customEvent);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
//attach the sendCustomEvent function to window object
|
|
240
|
+
window["sendCustomEvent"] = sendCustomEvent;
|
|
241
|
+
|
|
242
|
+
//invoke the sendCustomEvent function with some customized payload
|
|
243
|
+
window.sendCustomEvent({
|
|
244
|
+
customEventName: "TestEvent",
|
|
245
|
+
customEventValue: {
|
|
246
|
+
boolVar: true,
|
|
247
|
+
displayableVar: {
|
|
248
|
+
isDisplayable: true,
|
|
249
|
+
value: "From C2: "+ new Date().toISOString()
|
|
250
|
+
},
|
|
251
|
+
numberVar: -10.5,
|
|
252
|
+
stringVar: "Hello from C2 str: " + new Date().toISOString()
|
|
253
|
+
}
|
|
254
|
+
})
|
|
255
|
+
```
|
|
256
|
+
- Receiving events from bots/agents
|
|
257
|
+
```js
|
|
258
|
+
//define setOnCustomEvent function
|
|
259
|
+
const setOnCustomEvent = (callback) => {
|
|
260
|
+
BroadcastService.getMessageByEventName("onCustomEvent").subscribe((event) => {
|
|
261
|
+
if (event && typeof callback === "function") {
|
|
262
|
+
callback(event);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
//set callback function
|
|
268
|
+
setOnCustomEvent((event) => console.log(event));
|
|
269
|
+
```
|
|
270
|
+
|
|
224
271
|
## See Also
|
|
225
272
|
|
|
226
273
|
[Customizations Dev Guide](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/customizations/getstarted.md)\
|
|
@@ -230,4 +277,4 @@ const customizedFooterProp: IFooterProps = {
|
|
|
230
277
|
[How to Add Visual Regression Tests](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/VisualRegressionTestingGuide.md)\
|
|
231
278
|
[Security](https://github.com/microsoft/omnichannel-chat-widget/blob/main/SECURITY.md)\
|
|
232
279
|
[Third Party Cookie Support](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Tpc.md)\
|
|
233
|
-
[Storybook](https://microsoft.github.io/omnichannel-chat-widget/docs/storybook/)
|
|
280
|
+
[Storybook](https://microsoft.github.io/omnichannel-chat-widget/docs/storybook/)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WidgetLoadTelemetryMessage = exports.WidgetLoadCustomErrorString = exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.StartChatErrorPaneConstants = exports.Regex = exports.PrepareEndChatDescriptionConstants = exports.PostChatSurveyTelemetryMessage = exports.ParticipantType = exports.NotificationPaneConstants = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.AriaTelemetryConstants = exports.AppInsightsTelemetryMessage = exports.AMSConstants = void 0;
|
|
6
|
+
exports.WidgetLoadTelemetryMessage = exports.WidgetLoadCustomErrorString = exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.SurveyProvider = exports.StorageType = exports.StartChatErrorPaneConstants = exports.Regex = exports.PrepareEndChatDescriptionConstants = exports.PostChatSurveyTelemetryMessage = exports.ParticipantType = exports.NotificationPaneConstants = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.AriaTelemetryConstants = exports.AppInsightsTelemetryMessage = exports.AMSConstants = void 0;
|
|
7
7
|
var _class;
|
|
8
8
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -23,6 +23,9 @@ _defineProperty(Constants, "channelMessageTag", "channel");
|
|
|
23
23
|
_defineProperty(Constants, "historyMessageTag", "history");
|
|
24
24
|
_defineProperty(Constants, "agentEndConversationMessageTag", "agentendconversation");
|
|
25
25
|
_defineProperty(Constants, "supervisorForceCloseMessageTag", "supervisorforceclosedconversation");
|
|
26
|
+
_defineProperty(Constants, "endConversationalSurveyMessageTag", "endconversationalsurvey");
|
|
27
|
+
_defineProperty(Constants, "startConversationalSurveyMessageTag", "startconversationalsurvey");
|
|
28
|
+
_defineProperty(Constants, "c2ConversationalSurveyMessageTag", "c2conversationalsurvey");
|
|
26
29
|
_defineProperty(Constants, "receivedMessageClassName", "ms_lcw_webchat_received_message");
|
|
27
30
|
_defineProperty(Constants, "sentMessageClassName", "ms_lcw_webchat_sent_message");
|
|
28
31
|
_defineProperty(Constants, "webchatChannelId", "webchat");
|
|
@@ -112,8 +115,7 @@ _defineProperty(Constants, "TargetRelationshipAttributes", "noopener noreferrer"
|
|
|
112
115
|
// Markdown icons
|
|
113
116
|
_defineProperty(Constants, "OpenLinkIconCssClass", "webchat__render-markdown__external-link-icon");
|
|
114
117
|
// internet connection test
|
|
115
|
-
_defineProperty(Constants, "
|
|
116
|
-
_defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect Test");
|
|
118
|
+
_defineProperty(Constants, "internetConnectionTestPath", "/livechatwidget/version.txt");
|
|
117
119
|
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
118
120
|
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
119
121
|
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
@@ -129,6 +131,12 @@ _defineProperty(Constants, "InitContextParamsResponse", "initContextParamsRespon
|
|
|
129
131
|
_defineProperty(Constants, "OCOriginalMessageId", "OriginalMessageId");
|
|
130
132
|
_defineProperty(Constants, "WebchatSequenceIdAttribute", "webchat:sequence-id");
|
|
131
133
|
_defineProperty(Constants, "MessageSequenceIdOverride", "MessageSequenceIdOverride");
|
|
134
|
+
_defineProperty(Constants, "sendCustomEvent", "sendCustomEvent");
|
|
135
|
+
_defineProperty(Constants, "onCustomEvent", "onCustomEvent");
|
|
136
|
+
_defineProperty(Constants, "customEventName", "customEventName");
|
|
137
|
+
_defineProperty(Constants, "customEventValue", "customEventValue");
|
|
138
|
+
_defineProperty(Constants, "Hidden", "Hidden");
|
|
139
|
+
_defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
|
|
132
140
|
const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
|
|
133
141
|
_classCallCheck(this, Regex);
|
|
134
142
|
}), _defineProperty(_class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[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]?)\\])$"), _class);
|
|
@@ -240,6 +248,11 @@ exports.ConversationMode = ConversationMode;
|
|
|
240
248
|
ConversationMode["Regular"] = "192350000";
|
|
241
249
|
ConversationMode["Persistent"] = "192350001";
|
|
242
250
|
})(ConversationMode || (exports.ConversationMode = ConversationMode = {}));
|
|
251
|
+
let SurveyProvider;
|
|
252
|
+
exports.SurveyProvider = SurveyProvider;
|
|
253
|
+
(function (SurveyProvider) {
|
|
254
|
+
SurveyProvider["MicrosoftCopilotStudio"] = "600990001";
|
|
255
|
+
})(SurveyProvider || (exports.SurveyProvider = SurveyProvider = {}));
|
|
243
256
|
let LiveWorkItemState;
|
|
244
257
|
exports.LiveWorkItemState = LiveWorkItemState;
|
|
245
258
|
(function (LiveWorkItemState) {
|
|
@@ -190,6 +190,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
190
190
|
TelemetryEvent["BotAuthActivityUndefinedSignInId"] = "BotAuthActivityUndefinedSignInId";
|
|
191
191
|
TelemetryEvent["ThirdPartyCookiesBlocked"] = "ThirdPartyCookiesBlocked";
|
|
192
192
|
TelemetryEvent["ParticipantsRemovedEvent"] = "ParticipantsRemovedEvent";
|
|
193
|
+
TelemetryEvent["QueueOverflowEvent"] = "QueueOverflowEvent";
|
|
193
194
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
194
195
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
195
196
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
@@ -228,6 +229,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
228
229
|
TelemetryEvent["SystemMessageReceived"] = "SystemMessageReceived";
|
|
229
230
|
TelemetryEvent["RehydrateMessageReceived"] = "RehydrateMessageReceived";
|
|
230
231
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
232
|
+
TelemetryEvent["CustomEventAction"] = "CustomEventAction";
|
|
231
233
|
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
232
234
|
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
233
235
|
TelemetryEvent["LinkModePostChatWorkflowStarted"] = "LinkModePostChatWorkflowStarted";
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.formatTemplateString = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
6
|
+
exports.getCustomEventValue = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.formatTemplateString = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.createFileAndDownload = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
7
7
|
exports.getDeviceType = getDeviceType;
|
|
8
|
-
exports.
|
|
8
|
+
exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = void 0;
|
|
9
|
+
exports.isEndConversationDueToOverflowActivity = isEndConversationDueToOverflowActivity;
|
|
10
|
+
exports.setTabIndices = exports.setOcUserAgent = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isValidCustomEvent = exports.isUndefinedOrEmpty = exports.isThisSessionPopout = exports.isNullOrUndefined = exports.isNullOrEmptyString = void 0;
|
|
9
11
|
var _Constants = require("./Constants");
|
|
10
12
|
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
11
13
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
@@ -494,4 +496,27 @@ function getDeviceType() {
|
|
|
494
496
|
} else {
|
|
495
497
|
return "standard";
|
|
496
498
|
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
//Bots expect a payload containing:
|
|
502
|
+
//1. customEventName: this should be string describe the event name
|
|
503
|
+
//2. customEventValue: given the value is from customer with unknown type, it is required to stringify the payload later
|
|
504
|
+
const isValidCustomEvent = payload => {
|
|
505
|
+
if (_Constants.Constants.customEventName in payload && payload.customEventName && typeof payload.customEventName === _Constants.Constants.String && _Constants.Constants.customEventValue in payload && payload.customEventValue) return true;
|
|
506
|
+
return false;
|
|
507
|
+
};
|
|
508
|
+
exports.isValidCustomEvent = isValidCustomEvent;
|
|
509
|
+
const getCustomEventValue = customEventPayload => {
|
|
510
|
+
let returnVal = "";
|
|
511
|
+
try {
|
|
512
|
+
returnVal = typeof customEventPayload.customEventValue === _Constants.Constants.String ? customEventPayload.customEventValue : JSON.stringify(customEventPayload.customEventValue);
|
|
513
|
+
} catch (error) {
|
|
514
|
+
console.error(error);
|
|
515
|
+
}
|
|
516
|
+
return returnVal;
|
|
517
|
+
};
|
|
518
|
+
exports.getCustomEventValue = getCustomEventValue;
|
|
519
|
+
function isEndConversationDueToOverflowActivity(activity) {
|
|
520
|
+
var _activity$channelData, _activity$channelData2;
|
|
521
|
+
return (activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.tags) && Array.isArray(activity === null || activity === void 0 ? void 0 : (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.tags) && activity.channelData.tags.includes(_Constants.Constants.EndConversationDueToOverflow);
|
|
497
522
|
}
|
|
@@ -74,7 +74,6 @@ const ChatButtonStateful = props => {
|
|
|
74
74
|
};
|
|
75
75
|
const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeChatButtonStyleProps.defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
76
76
|
const controlProps = {
|
|
77
|
-
...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps),
|
|
78
77
|
id: "oc-lcw-chat-button",
|
|
79
78
|
dir: state.domainStates.globalDir,
|
|
80
79
|
titleText: "Let's Chat!",
|
|
@@ -83,7 +82,8 @@ const ChatButtonStateful = props => {
|
|
|
83
82
|
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",
|
|
84
83
|
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,
|
|
85
84
|
// Regular chat button onClick - this will always take precedence
|
|
86
|
-
onClick: () => ref.current()
|
|
85
|
+
onClick: () => ref.current(),
|
|
86
|
+
...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps)
|
|
87
87
|
};
|
|
88
88
|
const outOfOfficeControlProps = {
|
|
89
89
|
// Only take specific properties from outOfOfficeButtonProps, never onClick
|
|
@@ -92,7 +92,6 @@ const ChatButtonStateful = props => {
|
|
|
92
92
|
titleText: (outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : (_outOfOfficeButtonPro = outOfOfficeButtonProps.controlProps) === null || _outOfOfficeButtonPro === void 0 ? void 0 : _outOfOfficeButtonPro.titleText) || "We're Offline",
|
|
93
93
|
subtitleText: (outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : (_outOfOfficeButtonPro2 = outOfOfficeButtonProps.controlProps) === null || _outOfOfficeButtonPro2 === void 0 ? void 0 : _outOfOfficeButtonPro2.subtitleText) || "No agents available",
|
|
94
94
|
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,
|
|
95
|
-
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps),
|
|
96
95
|
// Out-of-office specific onClick - this will ALWAYS take precedence
|
|
97
96
|
onClick: () => {
|
|
98
97
|
if (state.appStates.isMinimized) {
|
|
@@ -105,7 +104,8 @@ const ChatButtonStateful = props => {
|
|
|
105
104
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
106
105
|
payload: _ConversationState.ConversationState.OutOfOffice
|
|
107
106
|
});
|
|
108
|
-
}
|
|
107
|
+
},
|
|
108
|
+
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
|
|
109
109
|
};
|
|
110
110
|
(0, _react.useEffect)(() => {
|
|
111
111
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -34,8 +34,11 @@ const DraggableChatWidget = props => {
|
|
|
34
34
|
};
|
|
35
35
|
const calculateOffsetsWithinViewport = (0, _react.useCallback)((id, offset, delta) => {
|
|
36
36
|
const draggableElement = document.getElementById(id);
|
|
37
|
+
if ((0, _utils.isNullOrUndefined)(draggableElement)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
37
40
|
const positionRelativeToViewport = draggableElement.getBoundingClientRect();
|
|
38
|
-
if ((0, _utils.isNullOrUndefined)(
|
|
41
|
+
if ((0, _utils.isNullOrUndefined)(positionRelativeToViewport) || (0, _utils.isNullOrUndefined)(offset.offsetLeft) || (0, _utils.isNullOrUndefined)(offset.offsetTop)) {
|
|
39
42
|
return;
|
|
40
43
|
}
|
|
41
44
|
let offsetLeft = offset.offsetLeft;
|
|
@@ -77,6 +80,9 @@ const DraggableChatWidget = props => {
|
|
|
77
80
|
}
|
|
78
81
|
const cacheInitialPosition = () => {
|
|
79
82
|
const draggableElement = document.getElementById(props.elementId);
|
|
83
|
+
if ((0, _utils.isNullOrUndefined)(draggableElement)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
80
86
|
const offsetLeft = draggableElement.offsetLeft;
|
|
81
87
|
const offsetTop = draggableElement.offsetTop;
|
|
82
88
|
setInitialPosition({
|
|
@@ -86,6 +92,9 @@ const DraggableChatWidget = props => {
|
|
|
86
92
|
};
|
|
87
93
|
const calculateOffsets = () => {
|
|
88
94
|
const draggableElement = document.getElementById(props.elementId);
|
|
95
|
+
if ((0, _utils.isNullOrUndefined)(draggableElement)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
89
98
|
const offsetLeft = draggableElement.offsetLeft;
|
|
90
99
|
const offsetTop = draggableElement.offsetTop;
|
|
91
100
|
|
|
@@ -120,6 +129,9 @@ const DraggableChatWidget = props => {
|
|
|
120
129
|
resetPosition(initialPosition);
|
|
121
130
|
} else if (state.appStates.isMinimized) {
|
|
122
131
|
const draggableElement = document.getElementById(props.elementId);
|
|
132
|
+
if ((0, _utils.isNullOrUndefined)(draggableElement)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
123
135
|
const offsetLeft = draggableElement.offsetLeft;
|
|
124
136
|
const offsetTop = draggableElement.offsetTop;
|
|
125
137
|
if (!cachedPosition) {
|
|
@@ -144,6 +156,9 @@ const DraggableChatWidget = props => {
|
|
|
144
156
|
|
|
145
157
|
// Update position via DOM manipulation to prevent <Stack/> continuously rendering on style change causing high CPU spike
|
|
146
158
|
const draggableElement = document.getElementById(props.elementId);
|
|
159
|
+
if ((0, _utils.isNullOrUndefined)(draggableElement)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
147
162
|
repositionElement(draggableElement, offsetLeft, offsetTop);
|
|
148
163
|
setPosition({
|
|
149
164
|
offsetLeft,
|
|
@@ -13,34 +13,47 @@ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
|
13
13
|
var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
14
14
|
var _createReducer = require("../../../contexts/createReducer");
|
|
15
15
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
16
|
-
const
|
|
16
|
+
const getRegionBasedInternetTestUrl = widgetSnippet => {
|
|
17
|
+
var _widgetSnippet$match;
|
|
18
|
+
if (!widgetSnippet) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
|
|
22
|
+
const baseCdnUrl = (_widgetSnippet$match = widgetSnippet.match(widgetSnippetSourceRegex)) === null || _widgetSnippet$match === void 0 ? void 0 : _widgetSnippet$match[1];
|
|
23
|
+
return baseCdnUrl ? `${baseCdnUrl}${_Constants.Constants.internetConnectionTestPath}` : null;
|
|
24
|
+
};
|
|
25
|
+
const isInternetConnected = async testUrl => {
|
|
17
26
|
try {
|
|
18
|
-
const response = await fetch(
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
const response = await fetch(testUrl, {
|
|
28
|
+
method: "GET",
|
|
29
|
+
cache: "no-cache"
|
|
30
|
+
});
|
|
31
|
+
return response.ok;
|
|
21
32
|
} catch {
|
|
22
33
|
return false;
|
|
23
34
|
}
|
|
24
35
|
};
|
|
25
36
|
const createInternetConnectionChangeHandler = async state => {
|
|
26
37
|
const handler = async () => {
|
|
27
|
-
|
|
38
|
+
var _inMemoryState$domain, _inMemoryState$domain2;
|
|
28
39
|
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
29
40
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
30
41
|
payload: null
|
|
31
42
|
});
|
|
43
|
+
const testUrl = getRegionBasedInternetTestUrl((_inMemoryState$domain = inMemoryState.domainStates.liveChatConfig) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.LiveWSAndLiveChatEngJoin) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.msdyn_widgetsnippet);
|
|
44
|
+
const connected = testUrl ? await isInternetConnected(testUrl) : false;
|
|
32
45
|
if (!connected) {
|
|
33
|
-
var _inMemoryState$
|
|
46
|
+
var _inMemoryState$domain3, _inMemoryState$domain4;
|
|
34
47
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
35
48
|
Event: _TelemetryConstants.TelemetryEvent.NetworkDisconnected
|
|
36
49
|
});
|
|
37
|
-
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
50
|
+
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.middlewareLocalizedTexts) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
|
|
38
51
|
} else {
|
|
39
|
-
var _inMemoryState$
|
|
52
|
+
var _inMemoryState$domain5, _inMemoryState$domain6;
|
|
40
53
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
41
54
|
Event: _TelemetryConstants.TelemetryEvent.NetworkReconnected
|
|
42
55
|
});
|
|
43
|
-
_NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
56
|
+
_NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain5 = inMemoryState.domainStates) === null || _inMemoryState$domain5 === void 0 ? void 0 : (_inMemoryState$domain6 = _inMemoryState$domain5.middlewareLocalizedTexts) === null || _inMemoryState$domain6 === void 0 ? void 0 : _inMemoryState$domain6.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
|
|
44
57
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
45
58
|
eventName: _TelemetryConstants.BroadcastEvent.NetworkReconnected
|
|
46
59
|
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.subscribeToSendCustomEvent = exports.customEventCallback = void 0;
|
|
7
|
+
var _Constants = require("../../../common/Constants");
|
|
8
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
9
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
10
|
+
var _utils = require("../../../common/utils");
|
|
11
|
+
const customEventCallback = facadeChatSDK => event => {
|
|
12
|
+
if (!(_Constants.Constants.payload in event)) return;
|
|
13
|
+
if ((0, _utils.isValidCustomEvent)(event.payload)) {
|
|
14
|
+
const customEventPayload = event.payload;
|
|
15
|
+
try {
|
|
16
|
+
const customEventValueStr = (0, _utils.getCustomEventValue)(customEventPayload);
|
|
17
|
+
const customEventName = customEventPayload.customEventName;
|
|
18
|
+
const messageMeta = {
|
|
19
|
+
customEvent: _Constants.Constants.true,
|
|
20
|
+
customEventName: customEventName,
|
|
21
|
+
customEventValue: customEventValueStr
|
|
22
|
+
};
|
|
23
|
+
const messagePayload = {
|
|
24
|
+
content: "",
|
|
25
|
+
tags: [_Constants.Constants.Hidden],
|
|
26
|
+
metadata: messageMeta,
|
|
27
|
+
timestamp: new Date()
|
|
28
|
+
};
|
|
29
|
+
facadeChatSDK.sendMessage(messagePayload);
|
|
30
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.DEBUG, {
|
|
31
|
+
Event: _TelemetryConstants.TelemetryEvent.CustomEventAction,
|
|
32
|
+
Description: "Sent customEvent.",
|
|
33
|
+
CustomProperties: {
|
|
34
|
+
customEventName,
|
|
35
|
+
lengthCustomEventValue: customEventValueStr.length
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
} catch (error) {
|
|
39
|
+
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
40
|
+
Event: _TelemetryConstants.TelemetryEvent.CustomEventAction,
|
|
41
|
+
Description: "Failed to process CustomEvent.",
|
|
42
|
+
ExceptionDetails: {
|
|
43
|
+
error
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.customEventCallback = customEventCallback;
|
|
50
|
+
const subscribeToSendCustomEvent = (broadcastService, facadeChatSDK, customEventCallback) => {
|
|
51
|
+
broadcastService.getMessageByEventName(_Constants.Constants.sendCustomEvent).subscribe(customEventCallback(facadeChatSDK));
|
|
52
|
+
};
|
|
53
|
+
exports.subscribeToSendCustomEvent = subscribeToSendCustomEvent;
|
|
@@ -21,7 +21,7 @@ var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
|
21
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
22
|
const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
23
23
|
try {
|
|
24
|
-
var _conversationDetails$, _state$domainStates, _state$
|
|
24
|
+
var _conversationDetails$, _state$domainStates, _state$appStates5;
|
|
25
25
|
const {
|
|
26
26
|
chatConfig
|
|
27
27
|
} = props;
|
|
@@ -32,7 +32,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
|
|
|
32
32
|
|
|
33
33
|
// Use Case: When post chat is not configured
|
|
34
34
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : (_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === _Constants.Constants.false) {
|
|
35
|
-
var _state$appStates;
|
|
35
|
+
var _state$appStates, _state$appStates2, _state$appStates3;
|
|
36
36
|
// If ended by customer, just close chat
|
|
37
37
|
if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.conversationEndedBy) === _Constants.ConversationEndEntity.Customer) {
|
|
38
38
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -43,6 +43,13 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// Use Case: If ended by Agent, stay chat in InActive state
|
|
46
|
+
let isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
|
|
47
|
+
if (isConversationalSurveyEnabled && ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.conversationEndedBy) === _Constants.ConversationEndEntity.Bot)) {
|
|
48
|
+
dispatch({
|
|
49
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
50
|
+
payload: _ConversationState.ConversationState.InActive
|
|
51
|
+
});
|
|
52
|
+
}
|
|
46
53
|
return;
|
|
47
54
|
}
|
|
48
55
|
|
|
@@ -58,7 +65,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
|
|
|
58
65
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
66
|
const postchatContext = (await (0, _renderSurveyHelpers.getPostChatContext)(facadeChatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
|
|
60
67
|
if (postchatContext === undefined) {
|
|
61
|
-
var _state$
|
|
68
|
+
var _state$appStates4;
|
|
62
69
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
63
70
|
eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
|
|
64
71
|
payload: {
|
|
@@ -67,7 +74,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
|
|
|
67
74
|
});
|
|
68
75
|
|
|
69
76
|
// For Customer intiated conversations, just close chat widget
|
|
70
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
77
|
+
if ((state === null || state === void 0 ? void 0 : (_state$appStates4 = state.appStates) === null || _state$appStates4 === void 0 ? void 0 : _state$appStates4.conversationEndedBy) === _Constants.ConversationEndEntity.Customer) {
|
|
71
78
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
72
79
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
73
80
|
Description: _Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat
|
|
@@ -85,11 +92,11 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
|
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
// Log PrepareEndChat if conversation ended by customer (bot and agent cases are handled in LiveChatWidgetStateful.tsx)
|
|
88
|
-
if (state !== null && state !== void 0 && (_state$
|
|
89
|
-
var _state$
|
|
95
|
+
if (state !== null && state !== void 0 && (_state$appStates5 = state.appStates) !== null && _state$appStates5 !== void 0 && _state$appStates5.conversationEndedBy) {
|
|
96
|
+
var _state$appStates6;
|
|
90
97
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
91
98
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
92
|
-
Description: `${_Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat} ${state === null || state === void 0 ? void 0 : (_state$
|
|
99
|
+
Description: `${_Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat} ${state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.conversationEndedBy}.`
|
|
93
100
|
});
|
|
94
101
|
}
|
|
95
102
|
const persistentEnabled = (0, _reconnectChatHelper.isPersistentEnabled)(chatConfig);
|
|
@@ -265,6 +272,10 @@ const closeChatStateCleanUp = dispatch => {
|
|
|
265
272
|
payload: undefined
|
|
266
273
|
});
|
|
267
274
|
// dispatch({ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE, payload: ConversationState.Closed });
|
|
275
|
+
dispatch({
|
|
276
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY,
|
|
277
|
+
payload: false
|
|
278
|
+
});
|
|
268
279
|
dispatch({
|
|
269
280
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
270
281
|
payload: undefined
|
|
@@ -37,6 +37,11 @@ var _htmlPlayerMiddleware = _interopRequireDefault(require("../../webchatcontain
|
|
|
37
37
|
var _htmlTextMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware"));
|
|
38
38
|
var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware"));
|
|
39
39
|
var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
|
|
40
|
+
var _customEventMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware"));
|
|
41
|
+
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
42
|
+
var _createReducer = require("../../../contexts/createReducer");
|
|
43
|
+
var _queueOverflowHandlerMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware");
|
|
44
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
40
45
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
46
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
47
|
const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
|
|
@@ -58,6 +63,20 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
58
63
|
let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
|
|
59
64
|
if (!webChatStore) {
|
|
60
65
|
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain7;
|
|
66
|
+
const addConversationalSurveyTagsCallback = action => {
|
|
67
|
+
var _inMemoryState$appSta;
|
|
68
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
69
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
70
|
+
payload: null
|
|
71
|
+
});
|
|
72
|
+
const isConversationalSurvey = (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.isConversationalSurvey;
|
|
73
|
+
if (isConversationalSurvey) {
|
|
74
|
+
if (!action.payload.activity.channelData.tags.includes(_Constants.Constants.c2ConversationalSurveyMessageTag)) {
|
|
75
|
+
action.payload.activity.channelData.tags.push(_Constants.Constants.c2ConversationalSurveyMessageTag);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return action;
|
|
79
|
+
};
|
|
61
80
|
const conversationEndCallback = async () => {
|
|
62
81
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
82
|
const conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK);
|
|
@@ -87,9 +106,21 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
87
106
|
});
|
|
88
107
|
}
|
|
89
108
|
};
|
|
109
|
+
const startConversationalSurveyCallback = async () => {
|
|
110
|
+
dispatch({
|
|
111
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY,
|
|
112
|
+
payload: true
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
const endConversationalSurveyCallback = async () => {
|
|
116
|
+
dispatch({
|
|
117
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
118
|
+
payload: _ConversationState.ConversationState.InActive
|
|
119
|
+
});
|
|
120
|
+
};
|
|
90
121
|
webChatStore = (0, _botframeworkWebchat.createStore)({},
|
|
91
122
|
//initial state
|
|
92
|
-
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
|
|
123
|
+
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), (0, _customEventMiddleware.default)(_omnichannelChatComponents.BroadcastService), (0, _queueOverflowHandlerMiddleware.createQueueOverflowMiddleware)(state, dispatch), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
|
|
93
124
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
125
|
...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
|
|
95
126
|
_WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = void 0;
|
|
6
|
+
exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = exports.getPostChatSurveyConfig = void 0;
|
|
7
7
|
var _Constants = require("../../../common/Constants");
|
|
8
8
|
var _utils = require("../../../common/utils");
|
|
9
9
|
const isPostChatSurveyEnabled = async facadeChatSDK => {
|
|
@@ -13,6 +13,23 @@ const isPostChatSurveyEnabled = async facadeChatSDK => {
|
|
|
13
13
|
return postChatEnabled === "true";
|
|
14
14
|
};
|
|
15
15
|
exports.isPostChatSurveyEnabled = isPostChatSurveyEnabled;
|
|
16
|
+
const getPostChatSurveyConfig = async facadeChatSDK => {
|
|
17
|
+
var _chatConfig$LiveWSAnd2, _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4, _chatConfig$LiveWSAnd5, _chatConfig$LiveWSAnd6, _chatConfig$LiveWSAnd7, _chatConfig$LiveWSAnd8, _chatConfig$LiveWSAnd9, _chatConfig$LiveWSAnd10;
|
|
18
|
+
const chatConfig = await facadeChatSDK.getLiveChatConfig();
|
|
19
|
+
const postChatEnabled = (_chatConfig$LiveWSAnd2 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd2 === void 0 ? void 0 : _chatConfig$LiveWSAnd2.msdyn_postconversationsurveyenable.toString().toLowerCase();
|
|
20
|
+
const agentSurveyMode = (_chatConfig$LiveWSAnd3 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd3 === void 0 ? void 0 : (_chatConfig$LiveWSAnd4 = _chatConfig$LiveWSAnd3.msdyn_postconversationsurveymode) === null || _chatConfig$LiveWSAnd4 === void 0 ? void 0 : _chatConfig$LiveWSAnd4.toString();
|
|
21
|
+
const botSurveyMode = (_chatConfig$LiveWSAnd5 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd5 === void 0 ? void 0 : (_chatConfig$LiveWSAnd6 = _chatConfig$LiveWSAnd5.msdyn_postconversationsurveybotsurveymode) === null || _chatConfig$LiveWSAnd6 === void 0 ? void 0 : _chatConfig$LiveWSAnd6.toString();
|
|
22
|
+
const surveyProvider = (_chatConfig$LiveWSAnd7 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd7 === void 0 ? void 0 : (_chatConfig$LiveWSAnd8 = _chatConfig$LiveWSAnd7.msdyn_surveyprovider) === null || _chatConfig$LiveWSAnd8 === void 0 ? void 0 : _chatConfig$LiveWSAnd8.toString();
|
|
23
|
+
const isConversationalSurveyEnabled = (_chatConfig$LiveWSAnd9 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd9 === void 0 ? void 0 : (_chatConfig$LiveWSAnd10 = _chatConfig$LiveWSAnd9.msdyn_isConversationalPostChatSurveyEnabled) === null || _chatConfig$LiveWSAnd10 === void 0 ? void 0 : _chatConfig$LiveWSAnd10.toString().toLowerCase();
|
|
24
|
+
return {
|
|
25
|
+
postChatEnabled: postChatEnabled === "true",
|
|
26
|
+
agentSurveyMode: agentSurveyMode,
|
|
27
|
+
botSurveyMode: botSurveyMode,
|
|
28
|
+
surveyProvider: surveyProvider,
|
|
29
|
+
isConversationalSurveyEnabled: isConversationalSurveyEnabled === "true"
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.getPostChatSurveyConfig = getPostChatSurveyConfig;
|
|
16
33
|
const isPersistentChatEnabled = conversationMode => {
|
|
17
34
|
if ((0, _utils.isNullOrUndefined)(conversationMode)) {
|
|
18
35
|
return false;
|