@microsoft/omnichannel-chat-widget 1.0.3 → 1.0.4-main.337860d
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/lib/cjs/common/Constants.js +4 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -1
- package/lib/cjs/common/utils.js +22 -2
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +7 -10
- package/lib/cjs/components/livechatwidget/common/endChat.js +32 -43
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +7 -11
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +2 -1
- package/lib/cjs/components/livechatwidget/common/startChat.js +49 -11
- package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +2 -1
- package/lib/esm/common/Constants.js +4 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +2 -1
- package/lib/esm/common/utils.js +20 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +7 -9
- package/lib/esm/components/livechatwidget/common/endChat.js +31 -41
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +7 -11
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +2 -1
- package/lib/esm/components/livechatwidget/common/startChat.js +50 -12
- package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +2 -1
- package/lib/types/common/Constants.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +3 -2
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +2 -3
- package/package.json +4 -5
|
@@ -112,6 +112,9 @@ _defineProperty(Constants, "SessionCacheSuffix", "session");
|
|
|
112
112
|
_defineProperty(Constants, "PopoutCacheSuffix", "popout");
|
|
113
113
|
// Visibility timeout for conversation details
|
|
114
114
|
_defineProperty(Constants, "LWICheckOnVisibilityTimeout", 3 * 60 * 1000);
|
|
115
|
+
// 3 minute
|
|
116
|
+
// Popup mode custom context response event message name
|
|
117
|
+
_defineProperty(Constants, "InitContextParamsResponse", "initContextParamsResponse");
|
|
115
118
|
const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
116
119
|
exports.Regex = Regex;
|
|
117
120
|
class HtmlIdNames {}
|
|
@@ -186,6 +189,7 @@ let ChatSDKError;
|
|
|
186
189
|
exports.ChatSDKError = ChatSDKError;
|
|
187
190
|
(function (ChatSDKError) {
|
|
188
191
|
ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
|
|
192
|
+
ChatSDKError["AuthContactIdNotFoundFailure"] = "AuthContactIdNotFoundFailure";
|
|
189
193
|
})(ChatSDKError || (exports.ChatSDKError = ChatSDKError = {}));
|
|
190
194
|
let EnvironmentVersion;
|
|
191
195
|
exports.EnvironmentVersion = EnvironmentVersion;
|
|
@@ -63,6 +63,7 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
63
63
|
BroadcastEvent["HideChatVisibilityChangeEvent"] = "hideChatVisibilityChangeEvent";
|
|
64
64
|
BroadcastEvent["UpdateSessionDataForTelemetry"] = "UpdateSessionDataForTelemetry";
|
|
65
65
|
BroadcastEvent["UpdateConversationDataForTelemetry"] = "UpdateConversationDataForTelemetry";
|
|
66
|
+
BroadcastEvent["ContactIdNotFound"] = "ContactIdNotFound";
|
|
66
67
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
67
68
|
let TelemetryEvent;
|
|
68
69
|
exports.TelemetryEvent = TelemetryEvent;
|
|
@@ -107,7 +108,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
107
108
|
TelemetryEvent["ChatVisibilityChanged"] = "ChatVisibilityChanged";
|
|
108
109
|
TelemetryEvent["EndChatSucceeded"] = "EndChatSucceeded";
|
|
109
110
|
TelemetryEvent["EndChatFailed"] = "EndChatFailed";
|
|
110
|
-
TelemetryEvent["
|
|
111
|
+
TelemetryEvent["SettingCustomContext"] = "SettingCustomContext";
|
|
111
112
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
112
113
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
113
114
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
6
|
+
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getConversationDetailsCall = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.checkContactIdError = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
7
7
|
var _Constants = require("./Constants");
|
|
8
8
|
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
9
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
10
|
var _DataStoreManager = require("./contextDataStore/DataStoreManager");
|
|
10
11
|
var _KeyCodes = require("./KeyCodes");
|
|
11
12
|
var _md5Typescript = require("md5-typescript");
|
|
@@ -385,8 +386,13 @@ const getConversationDetailsCall = async chatSDK => {
|
|
|
385
386
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
386
387
|
let conversationDetails = undefined;
|
|
387
388
|
try {
|
|
389
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
390
|
+
Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallStarted,
|
|
391
|
+
Description: "Conversation details call started"
|
|
392
|
+
});
|
|
388
393
|
conversationDetails = await chatSDK.getConversationDetails();
|
|
389
394
|
} catch (error) {
|
|
395
|
+
checkContactIdError(error);
|
|
390
396
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
391
397
|
Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallFailed,
|
|
392
398
|
ExceptionDetails: {
|
|
@@ -396,4 +402,18 @@ const getConversationDetailsCall = async chatSDK => {
|
|
|
396
402
|
}
|
|
397
403
|
return conversationDetails;
|
|
398
404
|
};
|
|
399
|
-
|
|
405
|
+
|
|
406
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
407
|
+
exports.getConversationDetailsCall = getConversationDetailsCall;
|
|
408
|
+
const checkContactIdError = e => {
|
|
409
|
+
if ((e === null || e === void 0 ? void 0 : e.message) === _Constants.ChatSDKError.AuthContactIdNotFoundFailure) {
|
|
410
|
+
const contactIdNotFoundErrorEvent = {
|
|
411
|
+
eventName: _TelemetryConstants.BroadcastEvent.ContactIdNotFound,
|
|
412
|
+
payload: {
|
|
413
|
+
error: e
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
_omnichannelChatComponents.BroadcastService.postMessage(contactIdNotFoundErrorEvent);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
exports.checkContactIdError = checkContactIdError;
|
package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -9,8 +9,6 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
|
|
|
9
9
|
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
10
10
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
11
11
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
12
|
-
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
12
|
const processDisplayName = displayName => {
|
|
15
13
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
16
14
|
const displayNameRegex = ".+:.+";
|
|
@@ -66,8 +64,6 @@ const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
|
|
|
66
64
|
}
|
|
67
65
|
if (renderMarkDown) {
|
|
68
66
|
transcriptContent = renderMarkDown(transcriptContent);
|
|
69
|
-
} else {
|
|
70
|
-
transcriptContent = _dompurify.default.sanitize(transcriptContent);
|
|
71
67
|
}
|
|
72
68
|
return transcriptContent;
|
|
73
69
|
};
|
|
@@ -164,12 +160,13 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
164
160
|
const downloadTranscript = async (chatSDK, renderMarkDown, bannerMessageOnError, attachmentMessage, state) => {
|
|
165
161
|
var _state$domainStates, _state$domainStates2, _state$domainStates2$;
|
|
166
162
|
// Need to keep existing request id for scenarios when trnascript is downloaded after endchat
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
163
|
+
const liveChatContext = {
|
|
164
|
+
chatToken: state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.chatToken,
|
|
165
|
+
requestId: state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.chatToken) === null || _state$domainStates2$ === void 0 ? void 0 : _state$domainStates2$.requestId
|
|
166
|
+
};
|
|
167
|
+
let data = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getLiveChatTranscript({
|
|
168
|
+
liveChatContext
|
|
169
|
+
}));
|
|
173
170
|
if (typeof data === _Constants.Constants.String) {
|
|
174
171
|
data = JSON.parse(data);
|
|
175
172
|
}
|
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.prepareEndChat = exports.
|
|
6
|
+
exports.prepareEndChat = exports.endChat = void 0;
|
|
7
|
+
var _Constants = require("../../../common/Constants");
|
|
7
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
+
var _authHelper = require("./authHelper");
|
|
10
|
+
var _utils = require("../../../common/utils");
|
|
11
|
+
var _renderSurveyHelpers = require("./renderSurveyHelpers");
|
|
8
12
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
13
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
10
14
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
11
15
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
12
16
|
var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
|
|
13
17
|
var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
14
|
-
var _utils = require("../../../common/utils");
|
|
15
|
-
var _authHelper = require("./authHelper");
|
|
16
|
-
var _renderSurveyHelpers = require("./renderSurveyHelpers");
|
|
17
|
-
var _Constants = require("../../../common/Constants");
|
|
18
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
19
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid) => {
|
|
20
20
|
try {
|
|
21
21
|
var _conversationDetails$, _state$domainStates, _state$domainStates2;
|
|
22
|
-
const conversationDetails = await
|
|
22
|
+
const conversationDetails = await (0, _utils.getConversationDetailsCall)(chatSDK);
|
|
23
23
|
|
|
24
24
|
// Use Case : When post chat is not configured
|
|
25
25
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : (_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === _Constants.Constants.false) {
|
|
@@ -125,18 +125,12 @@ const endChat = async function (props, chatSDK, state, dispatch, setAdapter, set
|
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
} finally {
|
|
128
|
-
var _state$appStates3;
|
|
129
128
|
dispatch({
|
|
130
129
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
131
130
|
payload: 0
|
|
132
131
|
});
|
|
133
|
-
//Always allow to close the chat for embedded mode irrespective of end chat errors
|
|
134
|
-
|
|
135
|
-
dispatch({
|
|
136
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
137
|
-
payload: _ConversationState.ConversationState.Closed
|
|
138
|
-
});
|
|
139
|
-
}
|
|
132
|
+
// Always allow to close the chat for embedded mode irrespective of end chat errors
|
|
133
|
+
closeChatWidget(dispatch, props, state);
|
|
140
134
|
}
|
|
141
135
|
}
|
|
142
136
|
if (postMessageToOtherTab && !(0, _utils.isNullOrEmptyString)(uwid)) {
|
|
@@ -150,10 +144,6 @@ const endChat = async function (props, chatSDK, state, dispatch, setAdapter, set
|
|
|
150
144
|
exports.endChat = endChat;
|
|
151
145
|
const endChatStateCleanUp = async dispatch => {
|
|
152
146
|
// Need to clear these states immediately when chat ended from OC.
|
|
153
|
-
dispatch({
|
|
154
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
155
|
-
payload: undefined
|
|
156
|
-
});
|
|
157
147
|
dispatch({
|
|
158
148
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
159
149
|
payload: undefined
|
|
@@ -202,6 +192,27 @@ const closeChatStateCleanUp = async dispatch => {
|
|
|
202
192
|
}
|
|
203
193
|
});
|
|
204
194
|
};
|
|
195
|
+
const closeChatWidget = (dispatch, props, state) => {
|
|
196
|
+
var _state$appStates3;
|
|
197
|
+
if (state !== null && state !== void 0 && (_state$appStates3 = state.appStates) !== null && _state$appStates3 !== void 0 && _state$appStates3.hideStartChatButton) {
|
|
198
|
+
var _props$controlProps2, _props$controlProps3;
|
|
199
|
+
// Only close chat if header is enabled for popout
|
|
200
|
+
// TODO : This condition needs to be removed eventually when the filler UX is ready for popout, removing this condition would show a blank screen for OOB Widget
|
|
201
|
+
if ((props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideHeader) === undefined || (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.hideHeader) === false) {
|
|
202
|
+
dispatch({
|
|
203
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
204
|
+
payload: _ConversationState.ConversationState.Closed
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Embedded chat
|
|
211
|
+
dispatch({
|
|
212
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
213
|
+
payload: _ConversationState.ConversationState.Closed
|
|
214
|
+
});
|
|
215
|
+
};
|
|
205
216
|
|
|
206
217
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
207
218
|
const handleAuthenticationIfEnabled = async (props, chatSDK) => {
|
|
@@ -239,28 +250,6 @@ const chatTokenCleanUp = async dispatch => {
|
|
|
239
250
|
|
|
240
251
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
241
252
|
const getEndChatEventName = async (chatSDK, props) => {
|
|
242
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$
|
|
243
|
-
return (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
247
|
-
const getConversationDetails = async chatSDK => {
|
|
248
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
249
|
-
let conversationDetails = undefined;
|
|
250
|
-
try {
|
|
251
|
-
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
252
|
-
Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallStarted,
|
|
253
|
-
Description: "Conversation details call started"
|
|
254
|
-
});
|
|
255
|
-
conversationDetails = await chatSDK.getConversationDetails();
|
|
256
|
-
} catch (error) {
|
|
257
|
-
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
258
|
-
Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallFailed,
|
|
259
|
-
ExceptionDetails: {
|
|
260
|
-
exception: `Get Conversation Details Call Failed : ${error}`
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
return conversationDetails;
|
|
265
|
-
};
|
|
266
|
-
exports.getConversationDetails = getConversationDetails;
|
|
253
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps4;
|
|
254
|
+
return (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.widgetInstanceId) ?? "");
|
|
255
|
+
};
|
|
@@ -4,22 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.initWebChatComposer = void 0;
|
|
7
|
+
var _Constants = require("../../../common/Constants");
|
|
7
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
8
|
-
var
|
|
9
|
+
var _utils = require("../../../common/utils");
|
|
10
|
+
var _HyperlinkTextOverrideRenderer = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer"));
|
|
9
11
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
10
12
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
11
13
|
var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
|
|
12
14
|
var _attachmentProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware"));
|
|
13
|
-
var _utils = require("../../../common/utils");
|
|
14
15
|
var _channelDataMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware"));
|
|
15
16
|
var _activityMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware");
|
|
16
17
|
var _attachmentMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware"));
|
|
17
18
|
var _attachmentUploadValidatorMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware"));
|
|
18
19
|
var _avatarMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware");
|
|
20
|
+
var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware");
|
|
19
21
|
var _conversationEndMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware"));
|
|
20
22
|
var _dataMaskingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware"));
|
|
21
23
|
var _createMarkdown = require("./createMarkdown");
|
|
22
24
|
var _maxMessageSizeValidator = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator"));
|
|
25
|
+
var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
|
|
26
|
+
var _botframeworkWebchat = require("botframework-webchat");
|
|
23
27
|
var _WebChatLogger = require("../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger");
|
|
24
28
|
var _defaultAttachmentProps = require("../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps");
|
|
25
29
|
var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
@@ -30,12 +34,6 @@ var _htmlPlayerMiddleware = _interopRequireDefault(require("../../webchatcontain
|
|
|
30
34
|
var _htmlTextMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware"));
|
|
31
35
|
var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware"));
|
|
32
36
|
var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
|
|
33
|
-
var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware");
|
|
34
|
-
var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
|
|
35
|
-
var _Constants = require("../../../common/Constants");
|
|
36
|
-
var _endChat = require("./endChat");
|
|
37
|
-
var _HyperlinkTextOverrideRenderer = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer"));
|
|
38
|
-
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
39
37
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
39
|
const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
@@ -54,7 +52,7 @@ const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
54
52
|
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
|
|
55
53
|
const conversationEndCallback = async () => {
|
|
56
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
-
const conversationDetails = await (0,
|
|
55
|
+
const conversationDetails = await (0, _utils.getConversationDetailsCall)(chatSDK);
|
|
58
56
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.ParticipantType.Bot) {
|
|
59
57
|
dispatch({
|
|
60
58
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
@@ -92,8 +90,6 @@ const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
92
90
|
markdownRenderers.forEach(renderer => {
|
|
93
91
|
text = renderer.render(text);
|
|
94
92
|
});
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
-
text = _dompurify.default.sanitize(text);
|
|
97
93
|
return text;
|
|
98
94
|
};
|
|
99
95
|
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.isReconnectEnabled = exports.handleChatReconnect = exports.getChatReconnectContext = void 0;
|
|
7
7
|
require("regenerator-runtime/runtime");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
-
var _authHelper = require("./authHelper");
|
|
10
9
|
var _utils = require("../../../common/utils");
|
|
10
|
+
var _authHelper = require("./authHelper");
|
|
11
11
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
12
12
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
13
13
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
@@ -75,6 +75,7 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
75
75
|
}
|
|
76
76
|
return reconnectChatContext;
|
|
77
77
|
} catch (error) {
|
|
78
|
+
(0, _utils.checkContactIdError)(error);
|
|
78
79
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
79
80
|
Event: _TelemetryConstants.TelemetryEvent.GetChatReconnectContextSDKCallFailed,
|
|
80
81
|
ExceptionDetails: {
|
|
@@ -130,7 +130,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
130
130
|
try {
|
|
131
131
|
var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
|
|
132
132
|
// Set custom context params
|
|
133
|
-
setCustomContextParams(props);
|
|
133
|
+
await setCustomContextParams(props);
|
|
134
134
|
const defaultOptionalParams = {
|
|
135
135
|
sendDefaultInitContext: true,
|
|
136
136
|
isProactiveChat: !!(params !== null && params !== void 0 && params.isProactiveChat),
|
|
@@ -140,6 +140,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
140
140
|
await chatSDK.startChat(startChatOptionalParams);
|
|
141
141
|
isStartChatSuccessful = true;
|
|
142
142
|
} catch (error) {
|
|
143
|
+
(0, _utils.checkContactIdError)(error);
|
|
143
144
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
144
145
|
Event: _TelemetryConstants.TelemetryEvent.StartChatMethodException,
|
|
145
146
|
ExceptionDetails: {
|
|
@@ -286,7 +287,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
286
287
|
};
|
|
287
288
|
|
|
288
289
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
289
|
-
const setCustomContextParams = props => {
|
|
290
|
+
const setCustomContextParams = async props => {
|
|
290
291
|
var _props$chatConfig, _props$chatConfig$Liv, _persistedState$domai8;
|
|
291
292
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
292
293
|
const isAuthenticatedChat = props !== null && props !== void 0 && (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
|
|
@@ -299,15 +300,22 @@ const setCustomContextParams = props => {
|
|
|
299
300
|
}
|
|
300
301
|
// Add custom context only for unauthenticated chat
|
|
301
302
|
const persistedState = (0, _utils.getStateFromCache)(widgetInstanceId);
|
|
302
|
-
|
|
303
|
-
|
|
303
|
+
const customContextLocal = (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai8 = persistedState.domainStates) === null || _persistedState$domai8 === void 0 ? void 0 : _persistedState$domai8.customContext) ?? (props === null || props === void 0 ? void 0 : props.initialCustomContext);
|
|
304
|
+
if (customContextLocal) {
|
|
304
305
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
305
|
-
Event: _TelemetryConstants.TelemetryEvent.
|
|
306
|
-
Description: "Setting custom context for
|
|
306
|
+
Event: _TelemetryConstants.TelemetryEvent.SettingCustomContext,
|
|
307
|
+
Description: "Setting custom context for unauthenticated chat"
|
|
307
308
|
});
|
|
308
309
|
optionalParams = Object.assign({}, optionalParams, {
|
|
309
|
-
customContext:
|
|
310
|
+
customContext: customContextLocal
|
|
310
311
|
});
|
|
312
|
+
} else {
|
|
313
|
+
const customContextFromParent = await getInitContextParamsForPopout();
|
|
314
|
+
if (!(0, _utils.isUndefinedOrEmpty)(customContextFromParent === null || customContextFromParent === void 0 ? void 0 : customContextFromParent.contextVariables)) {
|
|
315
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
316
|
+
customContext: customContextFromParent.contextVariables
|
|
317
|
+
});
|
|
318
|
+
}
|
|
311
319
|
}
|
|
312
320
|
};
|
|
313
321
|
const canStartPopoutChat = async props => {
|
|
@@ -316,9 +324,9 @@ const canStartPopoutChat = async props => {
|
|
|
316
324
|
}
|
|
317
325
|
popoutWidgetInstanceId = (0, _utils.getWidgetCacheIdfromProps)(props, true);
|
|
318
326
|
if (!(0, _utils.isNullOrEmptyString)(popoutWidgetInstanceId)) {
|
|
319
|
-
var _persistedState$
|
|
327
|
+
var _persistedState$domai9, _persistedState$appSt2;
|
|
320
328
|
const persistedState = (0, _utils.getStateFromCache)(popoutWidgetInstanceId);
|
|
321
|
-
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$
|
|
329
|
+
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt2 = persistedState.appStates) === null || _persistedState$appSt2 === void 0 ? void 0 : _persistedState$appSt2.conversationState) === _ConversationState.ConversationState.Active) {
|
|
322
330
|
// Initiate popout chat
|
|
323
331
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
324
332
|
eventName: _TelemetryConstants.BroadcastEvent.InitiateStartChatInPopoutMode
|
|
@@ -344,7 +352,7 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
344
352
|
});
|
|
345
353
|
try {
|
|
346
354
|
chatSDK.requestId = requestIdFromCache;
|
|
347
|
-
conversationDetails = await
|
|
355
|
+
conversationDetails = await (0, _utils.getConversationDetailsCall)(chatSDK);
|
|
348
356
|
if (Object.keys(conversationDetails).length === 0) {
|
|
349
357
|
chatSDK.requestId = currentRequestId;
|
|
350
358
|
return false;
|
|
@@ -369,4 +377,34 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
369
377
|
return false;
|
|
370
378
|
}
|
|
371
379
|
};
|
|
372
|
-
|
|
380
|
+
|
|
381
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
382
|
+
exports.checkIfConversationStillValid = checkIfConversationStillValid;
|
|
383
|
+
const getInitContextParamsForPopout = async () => {
|
|
384
|
+
return window.opener ? await getInitContextParamForPopoutFromOuterScope(window.opener) : null;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
388
|
+
const getInitContextParamForPopoutFromOuterScope = async scope => {
|
|
389
|
+
let payload;
|
|
390
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
391
|
+
let waitPromiseResolve;
|
|
392
|
+
const waitPromise = new Promise((res, rej) => {
|
|
393
|
+
waitPromiseResolve = res;
|
|
394
|
+
setTimeout(() => rej("Failed to find method in outer scope"), 5000);
|
|
395
|
+
}).catch(rej => console.warn(rej));
|
|
396
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
397
|
+
const getInitContextParamsFromParent = e => {
|
|
398
|
+
if (e.data && e.data.messageName == _Constants.Constants.InitContextParamsResponse) {
|
|
399
|
+
payload = e.data.payload;
|
|
400
|
+
waitPromiseResolve();
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
window.addEventListener("message", getInitContextParamsFromParent, false);
|
|
404
|
+
scope.postMessage({
|
|
405
|
+
messageName: _Constants.Constants.InitContextParamsResponse
|
|
406
|
+
}, "*");
|
|
407
|
+
await waitPromise;
|
|
408
|
+
window.removeEventListener("message", getInitContextParamsFromParent, false);
|
|
409
|
+
return payload;
|
|
410
|
+
};
|
|
@@ -9,6 +9,7 @@ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components
|
|
|
9
9
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
10
10
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
11
11
|
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
12
|
+
var _utils = require("../../../common/utils");
|
|
12
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
14
|
const updateSessionDataForTelemetry = async (chatSDK, dispatch) => {
|
|
14
15
|
if (chatSDK) {
|
|
@@ -34,7 +35,7 @@ exports.updateSessionDataForTelemetry = updateSessionDataForTelemetry;
|
|
|
34
35
|
const updateConversationDataForTelemetry = async (chatSDK, dispatch) => {
|
|
35
36
|
if (chatSDK) {
|
|
36
37
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
const liveWorkItem = await
|
|
38
|
+
const liveWorkItem = await (0, _utils.getConversationDetailsCall)(chatSDK);
|
|
38
39
|
const telemetryData = _TelemetryHelper.TelemetryHelper.addConversationDataToTelemetry(liveWorkItem, _TelemetryManager.TelemetryManager.InternalTelemetryData);
|
|
39
40
|
dispatch({
|
|
40
41
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_TELEMETRY_DATA,
|
|
@@ -105,6 +105,9 @@ _defineProperty(Constants, "SessionCacheSuffix", "session");
|
|
|
105
105
|
_defineProperty(Constants, "PopoutCacheSuffix", "popout");
|
|
106
106
|
// Visibility timeout for conversation details
|
|
107
107
|
_defineProperty(Constants, "LWICheckOnVisibilityTimeout", 3 * 60 * 1000);
|
|
108
|
+
// 3 minute
|
|
109
|
+
// Popup mode custom context response event message name
|
|
110
|
+
_defineProperty(Constants, "InitContextParamsResponse", "initContextParamsResponse");
|
|
108
111
|
export const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
109
112
|
export class HtmlIdNames {}
|
|
110
113
|
_defineProperty(HtmlIdNames, "MSLiveChatWidget", "MSLiveChatWidget");
|
|
@@ -168,6 +171,7 @@ export let ElementType;
|
|
|
168
171
|
export let ChatSDKError;
|
|
169
172
|
(function (ChatSDKError) {
|
|
170
173
|
ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
|
|
174
|
+
ChatSDKError["AuthContactIdNotFoundFailure"] = "AuthContactIdNotFoundFailure";
|
|
171
175
|
})(ChatSDKError || (ChatSDKError = {}));
|
|
172
176
|
export let EnvironmentVersion;
|
|
173
177
|
(function (EnvironmentVersion) {
|
|
@@ -58,6 +58,7 @@ export let BroadcastEvent;
|
|
|
58
58
|
BroadcastEvent["HideChatVisibilityChangeEvent"] = "hideChatVisibilityChangeEvent";
|
|
59
59
|
BroadcastEvent["UpdateSessionDataForTelemetry"] = "UpdateSessionDataForTelemetry";
|
|
60
60
|
BroadcastEvent["UpdateConversationDataForTelemetry"] = "UpdateConversationDataForTelemetry";
|
|
61
|
+
BroadcastEvent["ContactIdNotFound"] = "ContactIdNotFound";
|
|
61
62
|
})(BroadcastEvent || (BroadcastEvent = {}));
|
|
62
63
|
export let TelemetryEvent;
|
|
63
64
|
(function (TelemetryEvent) {
|
|
@@ -101,7 +102,7 @@ export let TelemetryEvent;
|
|
|
101
102
|
TelemetryEvent["ChatVisibilityChanged"] = "ChatVisibilityChanged";
|
|
102
103
|
TelemetryEvent["EndChatSucceeded"] = "EndChatSucceeded";
|
|
103
104
|
TelemetryEvent["EndChatFailed"] = "EndChatFailed";
|
|
104
|
-
TelemetryEvent["
|
|
105
|
+
TelemetryEvent["SettingCustomContext"] = "SettingCustomContext";
|
|
105
106
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
106
107
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
107
108
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var _this = this;
|
|
2
|
-
import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
|
|
2
|
+
import { AriaTelemetryConstants, ChatSDKError, Constants, LocaleConstants } from "./Constants";
|
|
3
3
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "./telemetry/TelemetryConstants";
|
|
4
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
5
|
import { DataStoreManager } from "./contextDataStore/DataStoreManager";
|
|
5
6
|
import { KeyCodes } from "./KeyCodes";
|
|
6
7
|
import { Md5 } from "md5-typescript";
|
|
@@ -353,8 +354,13 @@ export const getConversationDetailsCall = async chatSDK => {
|
|
|
353
354
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
354
355
|
let conversationDetails = undefined;
|
|
355
356
|
try {
|
|
357
|
+
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
358
|
+
Event: TelemetryEvent.GetConversationDetailsCallStarted,
|
|
359
|
+
Description: "Conversation details call started"
|
|
360
|
+
});
|
|
356
361
|
conversationDetails = await chatSDK.getConversationDetails();
|
|
357
362
|
} catch (error) {
|
|
363
|
+
checkContactIdError(error);
|
|
358
364
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
359
365
|
Event: TelemetryEvent.GetConversationDetailsCallFailed,
|
|
360
366
|
ExceptionDetails: {
|
|
@@ -363,4 +369,17 @@ export const getConversationDetailsCall = async chatSDK => {
|
|
|
363
369
|
});
|
|
364
370
|
}
|
|
365
371
|
return conversationDetails;
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
375
|
+
export const checkContactIdError = e => {
|
|
376
|
+
if ((e === null || e === void 0 ? void 0 : e.message) === ChatSDKError.AuthContactIdNotFoundFailure) {
|
|
377
|
+
const contactIdNotFoundErrorEvent = {
|
|
378
|
+
eventName: BroadcastEvent.ContactIdNotFound,
|
|
379
|
+
payload: {
|
|
380
|
+
error: e
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
BroadcastService.postMessage(contactIdNotFoundErrorEvent);
|
|
384
|
+
}
|
|
366
385
|
};
|
package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -3,7 +3,6 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
|
|
|
3
3
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
4
4
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
5
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
6
|
-
import DOMPurify from "dompurify";
|
|
7
6
|
const processDisplayName = displayName => {
|
|
8
7
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
9
8
|
const displayNameRegex = ".+:.+";
|
|
@@ -59,8 +58,6 @@ const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
|
|
|
59
58
|
}
|
|
60
59
|
if (renderMarkDown) {
|
|
61
60
|
transcriptContent = renderMarkDown(transcriptContent);
|
|
62
|
-
} else {
|
|
63
|
-
transcriptContent = DOMPurify.sanitize(transcriptContent);
|
|
64
61
|
}
|
|
65
62
|
return transcriptContent;
|
|
66
63
|
};
|
|
@@ -157,12 +154,13 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
157
154
|
export const downloadTranscript = async (chatSDK, renderMarkDown, bannerMessageOnError, attachmentMessage, state) => {
|
|
158
155
|
var _state$domainStates, _state$domainStates2, _state$domainStates2$;
|
|
159
156
|
// Need to keep existing request id for scenarios when trnascript is downloaded after endchat
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
157
|
+
const liveChatContext = {
|
|
158
|
+
chatToken: state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.chatToken,
|
|
159
|
+
requestId: state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.chatToken) === null || _state$domainStates2$ === void 0 ? void 0 : _state$domainStates2$.requestId
|
|
160
|
+
};
|
|
161
|
+
let data = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getLiveChatTranscript({
|
|
162
|
+
liveChatContext
|
|
163
|
+
}));
|
|
166
164
|
if (typeof data === Constants.String) {
|
|
167
165
|
data = JSON.parse(data);
|
|
168
166
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import { ConfirmationState, Constants, ConversationEndEntity } from "../../../common/Constants";
|
|
1
2
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
+
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
4
|
+
import { getConversationDetailsCall, getWidgetEndChatEventName, isNullOrEmptyString } from "../../../common/utils";
|
|
5
|
+
import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
|
|
2
6
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
3
7
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
4
8
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
5
9
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
10
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
7
11
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
8
|
-
import { getWidgetEndChatEventName, isNullOrEmptyString } from "../../../common/utils";
|
|
9
|
-
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
10
|
-
import { initiatePostChat, getPostChatContext } from "./renderSurveyHelpers";
|
|
11
|
-
import { Constants, ConversationEndEntity, ConfirmationState } from "../../../common/Constants";
|
|
12
12
|
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
14
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid) => {
|
|
15
15
|
try {
|
|
16
16
|
var _conversationDetails$, _state$domainStates, _state$domainStates2;
|
|
17
|
-
const conversationDetails = await
|
|
17
|
+
const conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
18
18
|
|
|
19
19
|
// Use Case : When post chat is not configured
|
|
20
20
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : (_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === Constants.false) {
|
|
@@ -119,18 +119,12 @@ const endChat = async function (props, chatSDK, state, dispatch, setAdapter, set
|
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
121
|
} finally {
|
|
122
|
-
var _state$appStates3;
|
|
123
122
|
dispatch({
|
|
124
123
|
type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
125
124
|
payload: 0
|
|
126
125
|
});
|
|
127
|
-
//Always allow to close the chat for embedded mode irrespective of end chat errors
|
|
128
|
-
|
|
129
|
-
dispatch({
|
|
130
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
131
|
-
payload: ConversationState.Closed
|
|
132
|
-
});
|
|
133
|
-
}
|
|
126
|
+
// Always allow to close the chat for embedded mode irrespective of end chat errors
|
|
127
|
+
closeChatWidget(dispatch, props, state);
|
|
134
128
|
}
|
|
135
129
|
}
|
|
136
130
|
if (postMessageToOtherTab && !isNullOrEmptyString(uwid)) {
|
|
@@ -143,10 +137,6 @@ const endChat = async function (props, chatSDK, state, dispatch, setAdapter, set
|
|
|
143
137
|
};
|
|
144
138
|
const endChatStateCleanUp = async dispatch => {
|
|
145
139
|
// Need to clear these states immediately when chat ended from OC.
|
|
146
|
-
dispatch({
|
|
147
|
-
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
148
|
-
payload: undefined
|
|
149
|
-
});
|
|
150
140
|
dispatch({
|
|
151
141
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
152
142
|
payload: undefined
|
|
@@ -195,6 +185,27 @@ const closeChatStateCleanUp = async dispatch => {
|
|
|
195
185
|
}
|
|
196
186
|
});
|
|
197
187
|
};
|
|
188
|
+
const closeChatWidget = (dispatch, props, state) => {
|
|
189
|
+
var _state$appStates3;
|
|
190
|
+
if (state !== null && state !== void 0 && (_state$appStates3 = state.appStates) !== null && _state$appStates3 !== void 0 && _state$appStates3.hideStartChatButton) {
|
|
191
|
+
var _props$controlProps2, _props$controlProps3;
|
|
192
|
+
// Only close chat if header is enabled for popout
|
|
193
|
+
// TODO : This condition needs to be removed eventually when the filler UX is ready for popout, removing this condition would show a blank screen for OOB Widget
|
|
194
|
+
if ((props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideHeader) === undefined || (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.hideHeader) === false) {
|
|
195
|
+
dispatch({
|
|
196
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
197
|
+
payload: ConversationState.Closed
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Embedded chat
|
|
204
|
+
dispatch({
|
|
205
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
206
|
+
payload: ConversationState.Closed
|
|
207
|
+
});
|
|
208
|
+
};
|
|
198
209
|
|
|
199
210
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
211
|
const handleAuthenticationIfEnabled = async (props, chatSDK) => {
|
|
@@ -232,28 +243,7 @@ const chatTokenCleanUp = async dispatch => {
|
|
|
232
243
|
|
|
233
244
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
245
|
const getEndChatEventName = async (chatSDK, props) => {
|
|
235
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$
|
|
236
|
-
return getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
|
-
const getConversationDetails = async chatSDK => {
|
|
241
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
|
-
let conversationDetails = undefined;
|
|
243
|
-
try {
|
|
244
|
-
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
245
|
-
Event: TelemetryEvent.GetConversationDetailsCallStarted,
|
|
246
|
-
Description: "Conversation details call started"
|
|
247
|
-
});
|
|
248
|
-
conversationDetails = await chatSDK.getConversationDetails();
|
|
249
|
-
} catch (error) {
|
|
250
|
-
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
251
|
-
Event: TelemetryEvent.GetConversationDetailsCallFailed,
|
|
252
|
-
ExceptionDetails: {
|
|
253
|
-
exception: `Get Conversation Details Call Failed : ${error}`
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
return conversationDetails;
|
|
246
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps4;
|
|
247
|
+
return getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.widgetInstanceId) ?? "");
|
|
258
248
|
};
|
|
259
|
-
export { prepareEndChat, endChat
|
|
249
|
+
export { prepareEndChat, endChat };
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
+
import { ConversationEndEntity, ParticipantType } from "../../../common/Constants";
|
|
1
2
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import {
|
|
3
|
+
import { changeLanguageCodeFormatForWebChat, getConversationDetailsCall } from "../../../common/utils";
|
|
4
|
+
import HyperlinkTextOverrideRenderer from "../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer";
|
|
3
5
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
4
6
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
7
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
6
8
|
import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
|
|
7
|
-
import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
|
|
8
9
|
import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
|
|
9
10
|
import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
|
|
10
11
|
import createAttachmentMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
|
|
11
12
|
import createAttachmentUploadValidatorMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware";
|
|
12
13
|
import { createAvatarMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware";
|
|
14
|
+
import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
|
|
13
15
|
import createConversationEndMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware";
|
|
14
16
|
import createDataMaskingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware";
|
|
15
17
|
import { createMarkdown } from "./createMarkdown";
|
|
16
18
|
import createMaxMessageSizeValidator from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator";
|
|
19
|
+
import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
|
|
20
|
+
import { createStore } from "botframework-webchat";
|
|
17
21
|
import { createWebChatTelemetry } from "../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
|
|
18
22
|
import { defaultAttachmentProps } from "../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps";
|
|
19
23
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
@@ -24,12 +28,6 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
|
|
|
24
28
|
import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
|
|
25
29
|
import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
|
|
26
30
|
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
27
|
-
import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
|
|
28
|
-
import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
|
|
29
|
-
import { ConversationEndEntity, ParticipantType } from "../../../common/Constants";
|
|
30
|
-
import { getConversationDetails } from "./endChat";
|
|
31
|
-
import HyperlinkTextOverrideRenderer from "../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer";
|
|
32
|
-
import DOMPurify from "dompurify";
|
|
33
31
|
|
|
34
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
33
|
export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
@@ -48,7 +46,7 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
48
46
|
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
|
|
49
47
|
const conversationEndCallback = async () => {
|
|
50
48
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
-
const conversationDetails = await
|
|
49
|
+
const conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
52
50
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot) {
|
|
53
51
|
dispatch({
|
|
54
52
|
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
@@ -86,8 +84,6 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
86
84
|
markdownRenderers.forEach(renderer => {
|
|
87
85
|
text = renderer.render(text);
|
|
88
86
|
});
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
-
text = DOMPurify.sanitize(text);
|
|
91
87
|
return text;
|
|
92
88
|
};
|
|
93
89
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "regenerator-runtime/runtime";
|
|
2
2
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
+
import { checkContactIdError, isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
|
|
3
4
|
import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
|
|
4
|
-
import { isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
|
|
5
5
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
6
6
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
7
7
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
@@ -69,6 +69,7 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
|
|
|
69
69
|
}
|
|
70
70
|
return reconnectChatContext;
|
|
71
71
|
} catch (error) {
|
|
72
|
+
checkContactIdError(error);
|
|
72
73
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
73
74
|
Event: TelemetryEvent.GetChatReconnectContextSDKCallFailed,
|
|
74
75
|
ExceptionDetails: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import { ChatSDKError, LiveWorkItemState } from "../../../common/Constants";
|
|
3
|
-
import { createTimer, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
2
|
+
import { ChatSDKError, Constants, LiveWorkItemState } from "../../../common/Constants";
|
|
3
|
+
import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
4
4
|
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
5
5
|
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
6
6
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
@@ -123,7 +123,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
123
123
|
try {
|
|
124
124
|
var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
|
|
125
125
|
// Set custom context params
|
|
126
|
-
setCustomContextParams(props);
|
|
126
|
+
await setCustomContextParams(props);
|
|
127
127
|
const defaultOptionalParams = {
|
|
128
128
|
sendDefaultInitContext: true,
|
|
129
129
|
isProactiveChat: !!(params !== null && params !== void 0 && params.isProactiveChat),
|
|
@@ -133,6 +133,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
133
133
|
await chatSDK.startChat(startChatOptionalParams);
|
|
134
134
|
isStartChatSuccessful = true;
|
|
135
135
|
} catch (error) {
|
|
136
|
+
checkContactIdError(error);
|
|
136
137
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
137
138
|
Event: TelemetryEvent.StartChatMethodException,
|
|
138
139
|
ExceptionDetails: {
|
|
@@ -278,7 +279,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
278
279
|
};
|
|
279
280
|
|
|
280
281
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
281
|
-
const setCustomContextParams = props => {
|
|
282
|
+
const setCustomContextParams = async props => {
|
|
282
283
|
var _props$chatConfig, _props$chatConfig$Liv, _persistedState$domai8;
|
|
283
284
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
284
285
|
const isAuthenticatedChat = props !== null && props !== void 0 && (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
|
|
@@ -291,15 +292,22 @@ const setCustomContextParams = props => {
|
|
|
291
292
|
}
|
|
292
293
|
// Add custom context only for unauthenticated chat
|
|
293
294
|
const persistedState = getStateFromCache(widgetInstanceId);
|
|
294
|
-
|
|
295
|
-
|
|
295
|
+
const customContextLocal = (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai8 = persistedState.domainStates) === null || _persistedState$domai8 === void 0 ? void 0 : _persistedState$domai8.customContext) ?? (props === null || props === void 0 ? void 0 : props.initialCustomContext);
|
|
296
|
+
if (customContextLocal) {
|
|
296
297
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
297
|
-
Event: TelemetryEvent.
|
|
298
|
-
Description: "Setting custom context for
|
|
298
|
+
Event: TelemetryEvent.SettingCustomContext,
|
|
299
|
+
Description: "Setting custom context for unauthenticated chat"
|
|
299
300
|
});
|
|
300
301
|
optionalParams = Object.assign({}, optionalParams, {
|
|
301
|
-
customContext:
|
|
302
|
+
customContext: customContextLocal
|
|
302
303
|
});
|
|
304
|
+
} else {
|
|
305
|
+
const customContextFromParent = await getInitContextParamsForPopout();
|
|
306
|
+
if (!isUndefinedOrEmpty(customContextFromParent === null || customContextFromParent === void 0 ? void 0 : customContextFromParent.contextVariables)) {
|
|
307
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
308
|
+
customContext: customContextFromParent.contextVariables
|
|
309
|
+
});
|
|
310
|
+
}
|
|
303
311
|
}
|
|
304
312
|
};
|
|
305
313
|
const canStartPopoutChat = async props => {
|
|
@@ -308,9 +316,9 @@ const canStartPopoutChat = async props => {
|
|
|
308
316
|
}
|
|
309
317
|
popoutWidgetInstanceId = getWidgetCacheIdfromProps(props, true);
|
|
310
318
|
if (!isNullOrEmptyString(popoutWidgetInstanceId)) {
|
|
311
|
-
var _persistedState$
|
|
319
|
+
var _persistedState$domai9, _persistedState$appSt2;
|
|
312
320
|
const persistedState = getStateFromCache(popoutWidgetInstanceId);
|
|
313
|
-
if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$
|
|
321
|
+
if (persistedState && !isUndefinedOrEmpty(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt2 = persistedState.appStates) === null || _persistedState$appSt2 === void 0 ? void 0 : _persistedState$appSt2.conversationState) === ConversationState.Active) {
|
|
314
322
|
// Initiate popout chat
|
|
315
323
|
BroadcastService.postMessage({
|
|
316
324
|
eventName: BroadcastEvent.InitiateStartChatInPopoutMode
|
|
@@ -336,7 +344,7 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
336
344
|
});
|
|
337
345
|
try {
|
|
338
346
|
chatSDK.requestId = requestIdFromCache;
|
|
339
|
-
conversationDetails = await chatSDK
|
|
347
|
+
conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
340
348
|
if (Object.keys(conversationDetails).length === 0) {
|
|
341
349
|
chatSDK.requestId = currentRequestId;
|
|
342
350
|
return false;
|
|
@@ -361,4 +369,34 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
361
369
|
return false;
|
|
362
370
|
}
|
|
363
371
|
};
|
|
372
|
+
|
|
373
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
374
|
+
const getInitContextParamsForPopout = async () => {
|
|
375
|
+
return window.opener ? await getInitContextParamForPopoutFromOuterScope(window.opener) : null;
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
379
|
+
const getInitContextParamForPopoutFromOuterScope = async scope => {
|
|
380
|
+
let payload;
|
|
381
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
382
|
+
let waitPromiseResolve;
|
|
383
|
+
const waitPromise = new Promise((res, rej) => {
|
|
384
|
+
waitPromiseResolve = res;
|
|
385
|
+
setTimeout(() => rej("Failed to find method in outer scope"), 5000);
|
|
386
|
+
}).catch(rej => console.warn(rej));
|
|
387
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
388
|
+
const getInitContextParamsFromParent = e => {
|
|
389
|
+
if (e.data && e.data.messageName == Constants.InitContextParamsResponse) {
|
|
390
|
+
payload = e.data.payload;
|
|
391
|
+
waitPromiseResolve();
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
window.addEventListener("message", getInitContextParamsFromParent, false);
|
|
395
|
+
scope.postMessage({
|
|
396
|
+
messageName: Constants.InitContextParamsResponse
|
|
397
|
+
}, "*");
|
|
398
|
+
await waitPromise;
|
|
399
|
+
window.removeEventListener("message", getInitContextParamsFromParent, false);
|
|
400
|
+
return payload;
|
|
401
|
+
};
|
|
364
402
|
export { prepareStartChat, initStartChat, setPreChatAndInitiateChat, checkIfConversationStillValid };
|
|
@@ -3,6 +3,7 @@ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
|
3
3
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
4
4
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
5
|
import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
6
|
+
import { getConversationDetailsCall } from "../../../common/utils";
|
|
6
7
|
|
|
7
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
9
|
export const updateSessionDataForTelemetry = async (chatSDK, dispatch) => {
|
|
@@ -28,7 +29,7 @@ export const updateSessionDataForTelemetry = async (chatSDK, dispatch) => {
|
|
|
28
29
|
const updateConversationDataForTelemetry = async (chatSDK, dispatch) => {
|
|
29
30
|
if (chatSDK) {
|
|
30
31
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
const liveWorkItem = await chatSDK
|
|
32
|
+
const liveWorkItem = await getConversationDetailsCall(chatSDK);
|
|
32
33
|
const telemetryData = TelemetryHelper.addConversationDataToTelemetry(liveWorkItem, TelemetryManager.InternalTelemetryData);
|
|
33
34
|
dispatch({
|
|
34
35
|
type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
|
|
@@ -84,6 +84,7 @@ export declare class Constants {
|
|
|
84
84
|
static readonly SessionCacheSuffix = "session";
|
|
85
85
|
static readonly PopoutCacheSuffix = "popout";
|
|
86
86
|
static readonly LWICheckOnVisibilityTimeout: number;
|
|
87
|
+
static readonly InitContextParamsResponse = "initContextParamsResponse";
|
|
87
88
|
}
|
|
88
89
|
export declare const Regex: {
|
|
89
90
|
new (): {};
|
|
@@ -154,7 +155,8 @@ export declare enum ElementType {
|
|
|
154
155
|
CallingContainerSDK = "CallingContainerSDK"
|
|
155
156
|
}
|
|
156
157
|
export declare enum ChatSDKError {
|
|
157
|
-
WidgetUseOutsideOperatingHour = "WidgetUseOutsideOperatingHour"
|
|
158
|
+
WidgetUseOutsideOperatingHour = "WidgetUseOutsideOperatingHour",
|
|
159
|
+
AuthContactIdNotFoundFailure = "AuthContactIdNotFoundFailure"
|
|
158
160
|
}
|
|
159
161
|
export declare enum EnvironmentVersion {
|
|
160
162
|
prod = "prod",
|
|
@@ -51,7 +51,8 @@ export declare enum BroadcastEvent {
|
|
|
51
51
|
InitiateStartChatInPopoutMode = "InitiateStartChatInPopoutMode",
|
|
52
52
|
HideChatVisibilityChangeEvent = "hideChatVisibilityChangeEvent",
|
|
53
53
|
UpdateSessionDataForTelemetry = "UpdateSessionDataForTelemetry",
|
|
54
|
-
UpdateConversationDataForTelemetry = "UpdateConversationDataForTelemetry"
|
|
54
|
+
UpdateConversationDataForTelemetry = "UpdateConversationDataForTelemetry",
|
|
55
|
+
ContactIdNotFound = "ContactIdNotFound"
|
|
55
56
|
}
|
|
56
57
|
export declare enum TelemetryEvent {
|
|
57
58
|
CallAdded = "CallAdded",
|
|
@@ -94,7 +95,7 @@ export declare enum TelemetryEvent {
|
|
|
94
95
|
ChatVisibilityChanged = "ChatVisibilityChanged",
|
|
95
96
|
EndChatSucceeded = "EndChatSucceeded",
|
|
96
97
|
EndChatFailed = "EndChatFailed",
|
|
97
|
-
|
|
98
|
+
SettingCustomContext = "SettingCustomContext",
|
|
98
99
|
WebChatLoaded = "WebChatLoaded",
|
|
99
100
|
LCWChatButtonClicked = "LCWChatButtonClicked",
|
|
100
101
|
LCWChatButtonShow = "LCWChatButtonShow",
|
|
@@ -31,3 +31,4 @@ export declare const getBroadcastChannelName: (widgetId: string, widgetInstanceI
|
|
|
31
31
|
export declare const getWidgetCacheIdfromProps: (props: any, popoutChat?: boolean) => string;
|
|
32
32
|
export declare const debounceLeading: (fn: any, ms?: number) => (...args: any[]) => void;
|
|
33
33
|
export declare const getConversationDetailsCall: (chatSDK: any) => Promise<any>;
|
|
34
|
+
export declare const checkContactIdError: (e: any) => void;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Dispatch } from "react";
|
|
2
2
|
import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
|
|
3
|
-
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
4
3
|
import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
|
|
4
|
+
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
5
5
|
declare const prepareEndChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any, uwid: string) => Promise<void>;
|
|
6
6
|
declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, setWebChatStyles: any, adapter: any, skipEndChatSDK?: boolean | undefined, skipCloseChat?: boolean | undefined, postMessageToOtherTab?: boolean | undefined, uwid?: string) => Promise<void>;
|
|
7
|
-
|
|
8
|
-
export { prepareEndChat, endChat, getConversationDetails };
|
|
7
|
+
export { prepareEndChat, endChat };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4-main.337860d",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -74,9 +74,8 @@
|
|
|
74
74
|
"webpack-cli": "^4.9.2"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@
|
|
78
|
-
"@microsoft/omnichannel-chat-
|
|
79
|
-
"@microsoft/omnichannel-chat-sdk": "1.3.0",
|
|
77
|
+
"@microsoft/omnichannel-chat-components": "^1.0.1",
|
|
78
|
+
"@microsoft/omnichannel-chat-sdk": "1.4.1",
|
|
80
79
|
"abort-controller-es5": "^2.0.1",
|
|
81
80
|
"dompurify": "^2.3.4",
|
|
82
81
|
"markdown-it": "^12.3.2",
|
|
@@ -111,4 +110,4 @@
|
|
|
111
110
|
"**/abort-controller-es5": "^2.0.1",
|
|
112
111
|
"**/minimist": "1.2.6"
|
|
113
112
|
}
|
|
114
|
-
}
|
|
113
|
+
}
|