@microsoft/omnichannel-chat-widget 1.8.2-main.3368d1f → 1.8.2-main.5195aba
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 +2 -0
- package/lib/cjs/common/Constants.js +11 -3
- package/lib/cjs/common/telemetry/TelemetryConstants.js +1 -0
- package/lib/cjs/common/utils.js +7 -1
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +28 -15
- package/lib/cjs/components/draggable/DraggableChatWidget.js +16 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +12 -2
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +2 -8
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
- package/lib/cjs/components/livechatwidget/common/endChat.js +18 -7
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +30 -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 +5 -3
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +22 -11
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +18 -14
- 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/queueOverflowHandlerMiddleware.js +45 -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/util.js +52 -27
- package/lib/cjs/plugins/newMessageEventHandler.js +12 -6
- package/lib/esm/common/Constants.js +9 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +1 -0
- package/lib/esm/common/utils.js +4 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +28 -15
- package/lib/esm/components/draggable/DraggableChatWidget.js +16 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +12 -2
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +2 -8
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
- package/lib/esm/components/livechatwidget/common/endChat.js +18 -7
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +30 -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 +5 -3
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +22 -11
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +18 -14
- 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/queueOverflowHandlerMiddleware.js +38 -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/util.js +49 -25
- package/lib/esm/plugins/newMessageEventHandler.js +12 -6
- package/lib/types/common/Constants.d.ts +8 -2
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +1 -0
- package/lib/types/common/utils.d.ts +5 -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/queueOverflowHandlerMiddleware.d.ts +5 -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/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).
|
|
@@ -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,7 @@ _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, "EndConversationDueToOverflow", "endconversationduetooverflow");
|
|
132
135
|
const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
|
|
133
136
|
_classCallCheck(this, Regex);
|
|
134
137
|
}), _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 +243,11 @@ exports.ConversationMode = ConversationMode;
|
|
|
240
243
|
ConversationMode["Regular"] = "192350000";
|
|
241
244
|
ConversationMode["Persistent"] = "192350001";
|
|
242
245
|
})(ConversationMode || (exports.ConversationMode = ConversationMode = {}));
|
|
246
|
+
let SurveyProvider;
|
|
247
|
+
exports.SurveyProvider = SurveyProvider;
|
|
248
|
+
(function (SurveyProvider) {
|
|
249
|
+
SurveyProvider["MicrosoftCopilotStudio"] = "600990001";
|
|
250
|
+
})(SurveyProvider || (exports.SurveyProvider = SurveyProvider = {}));
|
|
243
251
|
let LiveWorkItemState;
|
|
244
252
|
exports.LiveWorkItemState = LiveWorkItemState;
|
|
245
253
|
(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";
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
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;
|
|
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.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,8 @@ function getDeviceType() {
|
|
|
494
496
|
} else {
|
|
495
497
|
return "standard";
|
|
496
498
|
}
|
|
499
|
+
}
|
|
500
|
+
function isEndConversationDueToOverflowActivity(activity) {
|
|
501
|
+
var _activity$channelData, _activity$channelData2;
|
|
502
|
+
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
503
|
}
|
|
@@ -20,7 +20,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
20
20
|
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; }
|
|
21
21
|
let uiTimer;
|
|
22
22
|
const ChatButtonStateful = props => {
|
|
23
|
-
var _buttonProps$controlP, _props$buttonProps, _props$buttonProps$co, _props$buttonProps2, _props$buttonProps2$c, _props$buttonProps3, _props$buttonProps3$c;
|
|
23
|
+
var _buttonProps$controlP, _props$buttonProps, _props$buttonProps$co, _props$buttonProps2, _props$buttonProps2$c, _outOfOfficeButtonPro, _outOfOfficeButtonPro2, _props$buttonProps3, _props$buttonProps3$c;
|
|
24
24
|
// this is to ensure the telemetry is set only once and start the load timer
|
|
25
25
|
(0, _react.useEffect)(() => {
|
|
26
26
|
uiTimer = (0, _utils.createTimer)();
|
|
@@ -39,7 +39,10 @@ const ChatButtonStateful = props => {
|
|
|
39
39
|
} = props;
|
|
40
40
|
//Setting OutOfOperatingHours Flag
|
|
41
41
|
//Setting OutOfOperatingHours Flag - to string conversion to normalize the value (could be boolean from other states or string directly from config)
|
|
42
|
-
|
|
42
|
+
// Initialize with the current state value to prevent visual flicker
|
|
43
|
+
const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(() => {
|
|
44
|
+
return state.appStates.conversationState === _ConversationState.ConversationState.Closed && state.appStates.outsideOperatingHours;
|
|
45
|
+
});
|
|
43
46
|
const ref = (0, _react.useRef)(() => {
|
|
44
47
|
return;
|
|
45
48
|
});
|
|
@@ -71,33 +74,38 @@ const ChatButtonStateful = props => {
|
|
|
71
74
|
};
|
|
72
75
|
const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeChatButtonStyleProps.defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
73
76
|
const controlProps = {
|
|
77
|
+
...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps),
|
|
74
78
|
id: "oc-lcw-chat-button",
|
|
75
79
|
dir: state.domainStates.globalDir,
|
|
76
80
|
titleText: "Let's Chat!",
|
|
77
81
|
subtitleText: "We're online.",
|
|
78
82
|
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,
|
|
79
83
|
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",
|
|
80
|
-
onClick: () => ref.current(),
|
|
81
84
|
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,
|
|
82
|
-
|
|
85
|
+
// Regular chat button onClick - this will always take precedence
|
|
86
|
+
onClick: () => ref.current()
|
|
83
87
|
};
|
|
84
88
|
const outOfOfficeControlProps = {
|
|
89
|
+
// Only take specific properties from outOfOfficeButtonProps, never onClick
|
|
85
90
|
id: "oc-lcw-chat-button",
|
|
86
91
|
dir: state.domainStates.globalDir,
|
|
87
|
-
titleText: "We're Offline",
|
|
88
|
-
subtitleText: "No agents available",
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
titleText: (outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : (_outOfOfficeButtonPro = outOfOfficeButtonProps.controlProps) === null || _outOfOfficeButtonPro === void 0 ? void 0 : _outOfOfficeButtonPro.titleText) || "We're Offline",
|
|
93
|
+
subtitleText: (outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : (_outOfOfficeButtonPro2 = outOfOfficeButtonProps.controlProps) === null || _outOfOfficeButtonPro2 === void 0 ? void 0 : _outOfOfficeButtonPro2.subtitleText) || "No agents available",
|
|
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
|
+
// Out-of-office specific onClick - this will ALWAYS take precedence
|
|
97
|
+
onClick: () => {
|
|
98
|
+
if (state.appStates.isMinimized) {
|
|
99
|
+
dispatch({
|
|
100
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
101
|
+
payload: false
|
|
102
|
+
});
|
|
103
|
+
}
|
|
94
104
|
dispatch({
|
|
95
105
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
96
106
|
payload: _ConversationState.ConversationState.OutOfOffice
|
|
97
107
|
});
|
|
98
|
-
}
|
|
99
|
-
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,
|
|
100
|
-
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
|
|
108
|
+
}
|
|
101
109
|
};
|
|
102
110
|
(0, _react.useEffect)(() => {
|
|
103
111
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -123,8 +131,13 @@ const ChatButtonStateful = props => {
|
|
|
123
131
|
// If the conversation state is closed, check if we are outside operating hours
|
|
124
132
|
const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
|
|
125
133
|
setOutOfOperatingHours(isOutsideOperatingHours);
|
|
134
|
+
} else {
|
|
135
|
+
// If conversation state is not Closed, we should not be in out-of-office mode
|
|
136
|
+
if (outOfOperatingHours) {
|
|
137
|
+
setOutOfOperatingHours(false);
|
|
138
|
+
}
|
|
126
139
|
}
|
|
127
|
-
}, [state.appStates.conversationState]);
|
|
140
|
+
}, [state.appStates.conversationState, state.appStates.outsideOperatingHours, state.appStates.isMinimized]);
|
|
128
141
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.ChatButton, {
|
|
129
142
|
componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
|
|
130
143
|
controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
|
|
@@ -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,
|
|
@@ -37,7 +37,10 @@ const HeaderStateful = props => {
|
|
|
37
37
|
endChat
|
|
38
38
|
} = props;
|
|
39
39
|
//Setting OutOfOperatingHours Flag
|
|
40
|
-
|
|
40
|
+
// Initialize with the current state value to prevent visual flicker
|
|
41
|
+
const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(() => {
|
|
42
|
+
return state.appStates.conversationState === _ConversationState.ConversationState.Closed && state.appStates.outsideOperatingHours;
|
|
43
|
+
});
|
|
41
44
|
const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeHeaderStyleProps.defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
|
|
42
45
|
|
|
43
46
|
// For some reason state object is not getting updated values in this component
|
|
@@ -112,6 +115,13 @@ const HeaderStateful = props => {
|
|
|
112
115
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
113
116
|
payload: true
|
|
114
117
|
});
|
|
118
|
+
// Ensure conversation state remains Closed to maintain out-of-office mode
|
|
119
|
+
if (state.appStates.conversationState !== _ConversationState.ConversationState.Closed) {
|
|
120
|
+
dispatch({
|
|
121
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
122
|
+
payload: _ConversationState.ConversationState.Closed
|
|
123
|
+
});
|
|
124
|
+
}
|
|
115
125
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
116
126
|
Event: _TelemetryConstants.TelemetryEvent.MinimizeChatActionCompleted,
|
|
117
127
|
Description: "Header Minimize action completed."
|
|
@@ -141,7 +151,7 @@ const HeaderStateful = props => {
|
|
|
141
151
|
const isOutsideOperatingHours = state.appStates.outsideOperatingHours;
|
|
142
152
|
setOutOfOperatingHours(isOutsideOperatingHours);
|
|
143
153
|
}
|
|
144
|
-
}, [state.appStates.conversationState]);
|
|
154
|
+
}, [state.appStates.conversationState, state.appStates.outsideOperatingHours]);
|
|
145
155
|
if (props.draggable === true) {
|
|
146
156
|
var _generalStyleProps;
|
|
147
157
|
const styleProps = outOfOperatingHours || state.appStates.conversationState === _ConversationState.ConversationState.OutOfOffice ? outOfOfficeStyleProps : headerProps === null || headerProps === void 0 ? void 0 : headerProps.styleProps;
|
|
@@ -8,7 +8,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _ChatAdapterStore = require("../../contexts/ChatAdapterStore");
|
|
9
9
|
var _ChatContextStore = require("../../contexts/ChatContextStore");
|
|
10
10
|
var _ChatSDKStore = require("../../contexts/ChatSDKStore");
|
|
11
|
-
var _ErrorBoundary = _interopRequireDefault(require("../errorboundary/ErrorBoundary"));
|
|
12
11
|
var _FacadeChatSDK = require("../../common/facades/FacadeChatSDK");
|
|
13
12
|
var _FacadeChatSDKStore = require("../../contexts/FacadeChatSDKStore");
|
|
14
13
|
var _LiveChatWidgetStateful = _interopRequireDefault(require("./livechatwidgetstateful/LiveChatWidgetStateful"));
|
|
@@ -17,7 +16,6 @@ var _LiveChatWidgetContextInitialState = require("../../contexts/common/LiveChat
|
|
|
17
16
|
var _getMockChatSDKIfApplicable = require("./common/getMockChatSDKIfApplicable");
|
|
18
17
|
var _utils = require("../../common/utils");
|
|
19
18
|
var _liveChatConfigUtils = require("./common/liveChatConfigUtils");
|
|
20
|
-
var _startChatErrorHandler = require("./common/startChatErrorHandler");
|
|
21
19
|
var _overridePropsOnMockIfApplicable = _interopRequireDefault(require("./common/overridePropsOnMockIfApplicable"));
|
|
22
20
|
var _registerTelemetryLoggers = require("./common/registerTelemetryLoggers");
|
|
23
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -53,11 +51,7 @@ const LiveChatWidget = props => {
|
|
|
53
51
|
(0, _react.useEffect)(() => {
|
|
54
52
|
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
55
53
|
}, [dispatch]);
|
|
56
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
57
|
-
onError: error => {
|
|
58
|
-
(0, _startChatErrorHandler.logWidgetLoadWithUnexpectedError)(error);
|
|
59
|
-
}
|
|
60
|
-
}, /*#__PURE__*/_react.default.createElement(_FacadeChatSDKStore.FacadeChatSDKStore.Provider, {
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(_FacadeChatSDKStore.FacadeChatSDKStore.Provider, {
|
|
61
55
|
value: [facadeChatSDK, setFacadeChatSDK]
|
|
62
56
|
}, /*#__PURE__*/_react.default.createElement(_ChatSDKStore.ChatSDKStore.Provider, {
|
|
63
57
|
value: chatSDK
|
|
@@ -65,7 +59,7 @@ const LiveChatWidget = props => {
|
|
|
65
59
|
value: [adapter, setAdapter]
|
|
66
60
|
}, /*#__PURE__*/_react.default.createElement(_ChatContextStore.ChatContextStore.Provider, {
|
|
67
61
|
value: [state, dispatch]
|
|
68
|
-
}, /*#__PURE__*/_react.default.createElement(_LiveChatWidgetStateful.default, props)))))
|
|
62
|
+
}, /*#__PURE__*/_react.default.createElement(_LiveChatWidgetStateful.default, props)))));
|
|
69
63
|
};
|
|
70
64
|
exports.LiveChatWidget = LiveChatWidget;
|
|
71
65
|
var _default = LiveChatWidget;
|
|
@@ -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
|
});
|
|
@@ -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,9 @@ 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 _ConversationState = require("../../../contexts/common/ConversationState");
|
|
41
|
+
var _createReducer = require("../../../contexts/createReducer");
|
|
42
|
+
var _queueOverflowHandlerMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware");
|
|
40
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
44
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
45
|
const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
|
|
@@ -58,6 +61,20 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
58
61
|
let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
|
|
59
62
|
if (!webChatStore) {
|
|
60
63
|
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain7;
|
|
64
|
+
const addConversationalSurveyTagsCallback = action => {
|
|
65
|
+
var _inMemoryState$appSta;
|
|
66
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
67
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
68
|
+
payload: null
|
|
69
|
+
});
|
|
70
|
+
const isConversationalSurvey = (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.isConversationalSurvey;
|
|
71
|
+
if (isConversationalSurvey) {
|
|
72
|
+
if (!action.payload.activity.channelData.tags.includes(_Constants.Constants.c2ConversationalSurveyMessageTag)) {
|
|
73
|
+
action.payload.activity.channelData.tags.push(_Constants.Constants.c2ConversationalSurveyMessageTag);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return action;
|
|
77
|
+
};
|
|
61
78
|
const conversationEndCallback = async () => {
|
|
62
79
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
80
|
const conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK);
|
|
@@ -87,9 +104,21 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
87
104
|
});
|
|
88
105
|
}
|
|
89
106
|
};
|
|
107
|
+
const startConversationalSurveyCallback = async () => {
|
|
108
|
+
dispatch({
|
|
109
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY,
|
|
110
|
+
payload: true
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
const endConversationalSurveyCallback = async () => {
|
|
114
|
+
dispatch({
|
|
115
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
116
|
+
payload: _ConversationState.ConversationState.InActive
|
|
117
|
+
});
|
|
118
|
+
};
|
|
90
119
|
webChatStore = (0, _botframeworkWebchat.createStore)({},
|
|
91
120
|
//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,
|
|
121
|
+
_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, _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
122
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
123
|
...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
|
|
95
124
|
_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;
|
|
@@ -51,23 +51,34 @@ const setSurveyMode = async (props, participantType, state, dispatch) => {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
const renderSurvey = async (postChatContext, dispatch) => {
|
|
54
|
+
const renderSurvey = async (postChatContext, state, dispatch) => {
|
|
55
55
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
|
|
56
56
|
setWidgetStateToInactive(dispatch);
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
60
|
-
await embedModePostChatWorkflow(postChatContext, dispatch);
|
|
60
|
+
await embedModePostChatWorkflow(postChatContext, state, dispatch);
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
// Function for embed mode postchat workflow which is essentially same for both customer and agent
|
|
65
65
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
-
const embedModePostChatWorkflow = async (postChatContext, dispatch) => {
|
|
66
|
+
const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
|
|
67
67
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
68
68
|
Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
|
|
69
69
|
});
|
|
70
70
|
if (postChatContext) {
|
|
71
|
+
if (postChatContext.isConversationalSurveyEnabled && postChatContext.surveyProvider === _Constants.SurveyProvider.MicrosoftCopilotStudio) {
|
|
72
|
+
dispatch({
|
|
73
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
74
|
+
payload: _ConversationState.ConversationState.Postchat
|
|
75
|
+
});
|
|
76
|
+
dispatch({
|
|
77
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY,
|
|
78
|
+
payload: true
|
|
79
|
+
});
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
71
82
|
dispatch({
|
|
72
83
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
73
84
|
payload: _ConversationState.ConversationState.PostchatLoading
|
|
@@ -94,7 +105,7 @@ const initiatePostChat = async (props, conversationDetailsParam, state, dispatch
|
|
|
94
105
|
conversationDetails = conversationDetailsParam;
|
|
95
106
|
const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
|
|
96
107
|
await setSurveyMode(props, participantType, state, dispatch);
|
|
97
|
-
await renderSurvey(postchatContext, dispatch);
|
|
108
|
+
await renderSurvey(postchatContext, state, dispatch);
|
|
98
109
|
};
|
|
99
110
|
|
|
100
111
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -109,7 +120,14 @@ const isPostChatEnabled = (props, state) => {
|
|
|
109
120
|
exports.checkPostChatEnabled = isPostChatEnabled;
|
|
110
121
|
const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
|
|
111
122
|
try {
|
|
112
|
-
const
|
|
123
|
+
const postChatConfig = await (0, _liveChatConfigUtils.getPostChatSurveyConfig)(facadeChatSDK);
|
|
124
|
+
const postChatEnabled = postChatConfig.postChatEnabled;
|
|
125
|
+
if (postChatConfig.isConversationalSurveyEnabled) {
|
|
126
|
+
dispatch({
|
|
127
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_ENABLED,
|
|
128
|
+
payload: true
|
|
129
|
+
});
|
|
130
|
+
}
|
|
113
131
|
if (postChatEnabled) {
|
|
114
132
|
var _state$domainStates2;
|
|
115
133
|
if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
|
|
@@ -119,11 +137,17 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
|
|
|
119
137
|
Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
|
|
120
138
|
Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
|
|
121
139
|
});
|
|
140
|
+
|
|
141
|
+
// Merge postChatConfig with postChatSurveyContext
|
|
142
|
+
const mergedContext = {
|
|
143
|
+
...context,
|
|
144
|
+
...postChatConfig
|
|
145
|
+
};
|
|
122
146
|
dispatch({
|
|
123
147
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
|
|
124
|
-
payload:
|
|
148
|
+
payload: mergedContext
|
|
125
149
|
});
|
|
126
|
-
return
|
|
150
|
+
return mergedContext;
|
|
127
151
|
}
|
|
128
152
|
}
|
|
129
153
|
} catch (error) {
|