@microsoft/omnichannel-chat-widget 1.0.4-main.d4abfe6 → 1.0.5-main.53e6741
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 +1 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +1 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +3 -2
- package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryInternalData.js +1 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +22 -2
- package/lib/cjs/common/utils.js +22 -2
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -6
- package/lib/cjs/components/livechatwidget/common/endChat.js +8 -30
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +19 -9
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +2 -1
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +3 -2
- package/lib/cjs/components/livechatwidget/common/startChat.js +25 -10
- package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +2 -1
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +8 -0
- package/lib/esm/common/Constants.js +1 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +1 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +3 -2
- package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryInternalData.js +1 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +22 -2
- package/lib/esm/common/utils.js +20 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +10 -6
- package/lib/esm/components/livechatwidget/common/endChat.js +7 -28
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +19 -9
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +2 -1
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +3 -2
- package/lib/esm/components/livechatwidget/common/startChat.js +26 -11
- package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +2 -1
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +8 -0
- package/lib/types/common/Constants.d.ts +2 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -1
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +3 -3
- package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +2 -3
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +1 -1
- package/package.json +3 -4
|
@@ -189,6 +189,7 @@ let ChatSDKError;
|
|
|
189
189
|
exports.ChatSDKError = ChatSDKError;
|
|
190
190
|
(function (ChatSDKError) {
|
|
191
191
|
ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
|
|
192
|
+
ChatSDKError["AuthContactIdNotFoundFailure"] = "AuthContactIdNotFoundFailure";
|
|
192
193
|
})(ChatSDKError || (exports.ChatSDKError = ChatSDKError = {}));
|
|
193
194
|
let EnvironmentVersion;
|
|
194
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;
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.TelemetryHelper = void 0;
|
|
7
7
|
var _TelemetryConstants = require("./TelemetryConstants");
|
|
8
|
-
var _utils = require("../utils");
|
|
9
|
-
var _TelemetryManager = require("./TelemetryManager");
|
|
10
8
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
|
+
var _TelemetryManager = require("./TelemetryManager");
|
|
10
|
+
var _utils = require("../utils");
|
|
11
11
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
12
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
13
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -96,6 +96,7 @@ class TelemetryHelper {
|
|
|
96
96
|
return TelemetryHelper.populate(level, payload, event => {
|
|
97
97
|
var _TelemetryManager$Int11, _TelemetryManager$Int12, _TelemetryManager$Int13;
|
|
98
98
|
event.Event = payload.Event;
|
|
99
|
+
event.Description = payload.Description;
|
|
99
100
|
event.ResourcePath = payload.ResourcePath;
|
|
100
101
|
event.WidgetState = payload.WidgetState;
|
|
101
102
|
event.ChatState = payload.ChatState;
|
|
@@ -9,10 +9,29 @@ var _AriaSDK = require("@microsoft/omnichannel-chat-sdk/lib/external/aria/webjs/
|
|
|
9
9
|
var _Enums = require("@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums");
|
|
10
10
|
var _Constants = require("../../Constants");
|
|
11
11
|
var _TelemetryManager = require("../TelemetryManager");
|
|
12
|
+
const AWTDefaultConfiguration = {
|
|
13
|
+
collectorUri: "https://browser.pipe.aria.microsoft.com/Collector/3.0/",
|
|
14
|
+
cacheMemorySizeLimitInNumberOfEvents: 10000,
|
|
15
|
+
disableCookiesUsage: false,
|
|
16
|
+
canSendStatEvent: eventName => {
|
|
17
|
+
return true;
|
|
18
|
+
},
|
|
19
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
20
|
+
clockSkewRefreshDurationInMins: 0
|
|
21
|
+
};
|
|
12
22
|
const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, collectiorUriForTelemetry, ariaTelemetryApplicationName) => {
|
|
13
23
|
let _logger;
|
|
24
|
+
|
|
25
|
+
// AWTLogManager is a global variable. Reset after a logEvent() is required to prevent collisions with other components using AWTLogManager.
|
|
26
|
+
const resetAriaLogger = function () {
|
|
27
|
+
let configuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : AWTDefaultConfiguration;
|
|
28
|
+
_AriaSDK.AWTLogManager.flushAndTeardown();
|
|
29
|
+
_AriaSDK.AWTLogManager._isInitialized = false; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
30
|
+
_AriaSDK.AWTLogManager._isDestroyed = false; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
31
|
+
_logger = _AriaSDK.AWTLogManager.initialize(ariaTelemetryKey, configuration);
|
|
32
|
+
};
|
|
14
33
|
const logger = () => {
|
|
15
|
-
if (
|
|
34
|
+
if (!(0, _utils.isNullOrEmptyString)(ariaTelemetryKey)) {
|
|
16
35
|
const configuration = {
|
|
17
36
|
disableCookiesUsage: disabledCookieUsage
|
|
18
37
|
};
|
|
@@ -32,7 +51,7 @@ const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, collectiorUr
|
|
|
32
51
|
}
|
|
33
52
|
}
|
|
34
53
|
try {
|
|
35
|
-
|
|
54
|
+
resetAriaLogger(configuration);
|
|
36
55
|
if (_logger === undefined) {
|
|
37
56
|
_logger = _AriaSDK.AWTLogManager.getLogger(ariaTelemetryKey);
|
|
38
57
|
}
|
|
@@ -74,6 +93,7 @@ const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, collectiorUr
|
|
|
74
93
|
eventProperties.properties[ariaTelemetryApplicationName] = nameProperty;
|
|
75
94
|
}
|
|
76
95
|
logger() ? logger().logEvent(eventProperties) : console.log("Unable to initialize aria logger");
|
|
96
|
+
resetAriaLogger();
|
|
77
97
|
} catch (error) {
|
|
78
98
|
console.error("Error in logging telemetry to Aria logger:" + error);
|
|
79
99
|
}
|
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,6 +9,8 @@ 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 }; }
|
|
12
14
|
const processDisplayName = displayName => {
|
|
13
15
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
14
16
|
const displayNameRegex = ".+:.+";
|
|
@@ -64,6 +66,8 @@ const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
|
|
|
64
66
|
}
|
|
65
67
|
if (renderMarkDown) {
|
|
66
68
|
transcriptContent = renderMarkDown(transcriptContent);
|
|
69
|
+
} else {
|
|
70
|
+
transcriptContent = _dompurify.default.sanitize(transcriptContent);
|
|
67
71
|
}
|
|
68
72
|
return transcriptContent;
|
|
69
73
|
};
|
|
@@ -160,12 +164,13 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
160
164
|
const downloadTranscript = async (chatSDK, renderMarkDown, bannerMessageOnError, attachmentMessage, state) => {
|
|
161
165
|
var _state$domainStates, _state$domainStates2, _state$domainStates2$;
|
|
162
166
|
// Need to keep existing request id for scenarios when trnascript is downloaded after endchat
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
const liveChatContext = {
|
|
168
|
+
chatToken: state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.chatToken,
|
|
169
|
+
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
|
|
170
|
+
};
|
|
171
|
+
let data = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getLiveChatTranscript({
|
|
172
|
+
liveChatContext
|
|
173
|
+
}));
|
|
169
174
|
if (typeof data === _Constants.Constants.String) {
|
|
170
175
|
data = JSON.parse(data);
|
|
171
176
|
}
|
|
@@ -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) {
|
|
@@ -56,7 +56,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
56
56
|
|
|
57
57
|
// Initiate post chat render
|
|
58
58
|
if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.postChatContext) {
|
|
59
|
-
await (0, _renderSurveyHelpers.initiatePostChat)(props, conversationDetails, state, dispatch);
|
|
59
|
+
await (0, _renderSurveyHelpers.initiatePostChat)(props, conversationDetails, state, dispatch, postchatContext);
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
} catch (error) {
|
|
@@ -252,26 +252,4 @@ const chatTokenCleanUp = async dispatch => {
|
|
|
252
252
|
const getEndChatEventName = async (chatSDK, props) => {
|
|
253
253
|
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps4;
|
|
254
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
|
-
};
|
|
256
|
-
|
|
257
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
|
-
const getConversationDetails = async chatSDK => {
|
|
259
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
260
|
-
let conversationDetails = undefined;
|
|
261
|
-
try {
|
|
262
|
-
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
263
|
-
Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallStarted,
|
|
264
|
-
Description: "Conversation details call started"
|
|
265
|
-
});
|
|
266
|
-
conversationDetails = await chatSDK.getConversationDetails();
|
|
267
|
-
} catch (error) {
|
|
268
|
-
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
269
|
-
Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallFailed,
|
|
270
|
-
ExceptionDetails: {
|
|
271
|
-
exception: `Get Conversation Details Call Failed : ${error}`
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
return conversationDetails;
|
|
276
|
-
};
|
|
277
|
-
exports.getConversationDetails = getConversationDetails;
|
|
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,15 +34,13 @@ 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
|
|
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"));
|
|
37
|
+
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
38
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
40
|
const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
41
41
|
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain13, _props$webChatContain14, _defaultWebChatContai, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
42
|
+
// Add a hook to make all links open a new window
|
|
43
|
+
postDomPurifyActivities();
|
|
42
44
|
const localizedTexts = {
|
|
43
45
|
..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
|
|
44
46
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -53,7 +55,7 @@ const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
53
55
|
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
|
|
54
56
|
const conversationEndCallback = async () => {
|
|
55
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
-
const conversationDetails = await (0,
|
|
58
|
+
const conversationDetails = await (0, _utils.getConversationDetailsCall)(chatSDK);
|
|
57
59
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.ParticipantType.Bot) {
|
|
58
60
|
dispatch({
|
|
59
61
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
@@ -91,9 +93,17 @@ const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
91
93
|
markdownRenderers.forEach(renderer => {
|
|
92
94
|
text = renderer.render(text);
|
|
93
95
|
});
|
|
96
|
+
text = _dompurify.default.sanitize(text);
|
|
94
97
|
return text;
|
|
95
98
|
};
|
|
96
|
-
|
|
99
|
+
function postDomPurifyActivities() {
|
|
100
|
+
_dompurify.default.addHook("afterSanitizeAttributes", function (node) {
|
|
101
|
+
// set all elements owning target to target=_blank
|
|
102
|
+
if ("target" in node) {
|
|
103
|
+
node.setAttribute("target", "_blank");
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
97
107
|
// Initialize the remaining Web Chat props
|
|
98
108
|
const webChatProps = {
|
|
99
109
|
..._defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps,
|
|
@@ -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: {
|
|
@@ -87,10 +87,11 @@ const embedModePostChatWorkflow = async (state, dispatch) => {
|
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
-
const initiatePostChat = async (props, conversationDetailsParam, state, dispatch) => {
|
|
90
|
+
const initiatePostChat = async (props, conversationDetailsParam, state, dispatch, postchatContext) => {
|
|
91
91
|
var _conversationDetails;
|
|
92
92
|
conversationDetails = conversationDetailsParam;
|
|
93
|
-
|
|
93
|
+
const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
|
|
94
|
+
await setSurveyMode(props, participantType, state, dispatch);
|
|
94
95
|
await renderSurvey(state, dispatch);
|
|
95
96
|
};
|
|
96
97
|
|
|
@@ -99,7 +99,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
99
99
|
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
100
100
|
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.hideErrorUIPane;
|
|
101
101
|
try {
|
|
102
|
-
var _newAdapter$activity$, _TelemetryTimers$
|
|
102
|
+
var _newAdapter$activity$, _TelemetryTimers$Widg2;
|
|
103
103
|
//Start widget load timer
|
|
104
104
|
_TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
|
|
105
105
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -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: {
|
|
@@ -174,10 +175,16 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
177
|
if (persistedState) {
|
|
178
|
+
var _TelemetryTimers$Widg;
|
|
177
179
|
dispatch({
|
|
178
180
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
179
181
|
payload: persistedState
|
|
180
182
|
});
|
|
183
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
184
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
185
|
+
Description: "Widget load complete. Persisted state retrieved",
|
|
186
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
187
|
+
});
|
|
181
188
|
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
|
|
182
189
|
return;
|
|
183
190
|
}
|
|
@@ -191,7 +198,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
191
198
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
192
199
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
193
200
|
Description: "Widget load complete",
|
|
194
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$
|
|
201
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
|
|
195
202
|
});
|
|
196
203
|
|
|
197
204
|
// Set post chat context in state
|
|
@@ -201,15 +208,10 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
201
208
|
// Updating chat session detail for telemetry
|
|
202
209
|
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch);
|
|
203
210
|
} catch (ex) {
|
|
204
|
-
|
|
205
|
-
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
206
|
-
ExceptionDetails: {
|
|
207
|
-
Exception: `Widget load Failed: ${ex}`
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.Connection, "Start Chat Failed: " + ex);
|
|
211
|
+
var _TelemetryTimers$Widg4;
|
|
211
212
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
212
213
|
if (ex.message === _Constants.ChatSDKError.WidgetUseOutsideOperatingHour) {
|
|
214
|
+
var _TelemetryTimers$Widg3;
|
|
213
215
|
dispatch({
|
|
214
216
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
215
217
|
payload: true
|
|
@@ -218,8 +220,21 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
218
220
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
219
221
|
payload: _ConversationState.ConversationState.OutOfOffice
|
|
220
222
|
});
|
|
223
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
224
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
|
|
225
|
+
Description: "Widget load complete. Widget is OOOH.",
|
|
226
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
227
|
+
});
|
|
221
228
|
return;
|
|
222
229
|
}
|
|
230
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
231
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
232
|
+
ExceptionDetails: {
|
|
233
|
+
Exception: `Widget load Failed: ${ex}`
|
|
234
|
+
},
|
|
235
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
|
|
236
|
+
});
|
|
237
|
+
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.Connection, "Start Chat Failed: " + ex);
|
|
223
238
|
dispatch({
|
|
224
239
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
225
240
|
payload: true
|
|
@@ -351,7 +366,7 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
351
366
|
});
|
|
352
367
|
try {
|
|
353
368
|
chatSDK.requestId = requestIdFromCache;
|
|
354
|
-
conversationDetails = await
|
|
369
|
+
conversationDetails = await (0, _utils.getConversationDetailsCall)(chatSDK);
|
|
355
370
|
if (Object.keys(conversationDetails).length === 0) {
|
|
356
371
|
chatSDK.requestId = currentRequestId;
|
|
357
372
|
return false;
|
|
@@ -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,
|
|
@@ -142,6 +142,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
142
142
|
}
|
|
143
143
|
if (isChatValid === false) {
|
|
144
144
|
if (localState) {
|
|
145
|
+
// adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
|
|
146
|
+
if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true) {
|
|
147
|
+
await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, _startChat.initStartChat, state);
|
|
148
|
+
// If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
|
|
149
|
+
if (state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
145
153
|
await (0, _startChat.setPreChatAndInitiateChat)(chatSDK, dispatch, setAdapter, undefined, undefined, localState, props);
|
|
146
154
|
return;
|
|
147
155
|
} else {
|
|
@@ -171,6 +171,7 @@ export let ElementType;
|
|
|
171
171
|
export let ChatSDKError;
|
|
172
172
|
(function (ChatSDKError) {
|
|
173
173
|
ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
|
|
174
|
+
ChatSDKError["AuthContactIdNotFoundFailure"] = "AuthContactIdNotFoundFailure";
|
|
174
175
|
})(ChatSDKError || (ChatSDKError = {}));
|
|
175
176
|
export let EnvironmentVersion;
|
|
176
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) {
|
|
@@ -2,9 +2,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
2
2
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
3
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
4
|
import { ScenarioType, TelemetryEvent } from "./TelemetryConstants";
|
|
5
|
-
import { newGuid } from "../utils";
|
|
6
|
-
import { TelemetryManager } from "./TelemetryManager";
|
|
7
5
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
6
|
+
import { TelemetryManager } from "./TelemetryManager";
|
|
7
|
+
import { newGuid } from "../utils";
|
|
8
8
|
export class TelemetryHelper {
|
|
9
9
|
static buildTelemetryEvent(level, input) {
|
|
10
10
|
switch (input.scenarioType) {
|
|
@@ -90,6 +90,7 @@ export class TelemetryHelper {
|
|
|
90
90
|
return TelemetryHelper.populate(level, payload, event => {
|
|
91
91
|
var _TelemetryManager$Int11, _TelemetryManager$Int12, _TelemetryManager$Int13;
|
|
92
92
|
event.Event = payload.Event;
|
|
93
|
+
event.Description = payload.Description;
|
|
93
94
|
event.ResourcePath = payload.ResourcePath;
|
|
94
95
|
event.WidgetState = payload.WidgetState;
|
|
95
96
|
event.ChatState = payload.ChatState;
|
|
@@ -3,10 +3,29 @@ import { AWTLogManager } from "@microsoft/omnichannel-chat-sdk/lib/external/aria
|
|
|
3
3
|
import { AWTCustomerContentKind, AWTPiiKind, AWTPropertyType } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
|
|
4
4
|
import { Constants, AriaTelemetryConstants, EnvironmentVersion } from "../../Constants";
|
|
5
5
|
import { TelemetryManager } from "../TelemetryManager";
|
|
6
|
+
const AWTDefaultConfiguration = {
|
|
7
|
+
collectorUri: "https://browser.pipe.aria.microsoft.com/Collector/3.0/",
|
|
8
|
+
cacheMemorySizeLimitInNumberOfEvents: 10000,
|
|
9
|
+
disableCookiesUsage: false,
|
|
10
|
+
canSendStatEvent: eventName => {
|
|
11
|
+
return true;
|
|
12
|
+
},
|
|
13
|
+
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
14
|
+
clockSkewRefreshDurationInMins: 0
|
|
15
|
+
};
|
|
6
16
|
export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, collectiorUriForTelemetry, ariaTelemetryApplicationName) => {
|
|
7
17
|
let _logger;
|
|
18
|
+
|
|
19
|
+
// AWTLogManager is a global variable. Reset after a logEvent() is required to prevent collisions with other components using AWTLogManager.
|
|
20
|
+
const resetAriaLogger = function () {
|
|
21
|
+
let configuration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : AWTDefaultConfiguration;
|
|
22
|
+
AWTLogManager.flushAndTeardown();
|
|
23
|
+
AWTLogManager._isInitialized = false; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
24
|
+
AWTLogManager._isDestroyed = false; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
25
|
+
_logger = AWTLogManager.initialize(ariaTelemetryKey, configuration);
|
|
26
|
+
};
|
|
8
27
|
const logger = () => {
|
|
9
|
-
if (
|
|
28
|
+
if (!isNullOrEmptyString(ariaTelemetryKey)) {
|
|
10
29
|
const configuration = {
|
|
11
30
|
disableCookiesUsage: disabledCookieUsage
|
|
12
31
|
};
|
|
@@ -26,7 +45,7 @@ export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, colle
|
|
|
26
45
|
}
|
|
27
46
|
}
|
|
28
47
|
try {
|
|
29
|
-
|
|
48
|
+
resetAriaLogger(configuration);
|
|
30
49
|
if (_logger === undefined) {
|
|
31
50
|
_logger = AWTLogManager.getLogger(ariaTelemetryKey);
|
|
32
51
|
}
|
|
@@ -68,6 +87,7 @@ export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, colle
|
|
|
68
87
|
eventProperties.properties[ariaTelemetryApplicationName] = nameProperty;
|
|
69
88
|
}
|
|
70
89
|
logger() ? logger().logEvent(eventProperties) : console.log("Unable to initialize aria logger");
|
|
90
|
+
resetAriaLogger();
|
|
71
91
|
} catch (error) {
|
|
72
92
|
console.error("Error in logging telemetry to Aria logger:" + error);
|
|
73
93
|
}
|
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,6 +3,7 @@ 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";
|
|
6
7
|
const processDisplayName = displayName => {
|
|
7
8
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
8
9
|
const displayNameRegex = ".+:.+";
|
|
@@ -58,6 +59,8 @@ const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
|
|
|
58
59
|
}
|
|
59
60
|
if (renderMarkDown) {
|
|
60
61
|
transcriptContent = renderMarkDown(transcriptContent);
|
|
62
|
+
} else {
|
|
63
|
+
transcriptContent = DOMPurify.sanitize(transcriptContent);
|
|
61
64
|
}
|
|
62
65
|
return transcriptContent;
|
|
63
66
|
};
|
|
@@ -154,12 +157,13 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
154
157
|
export const downloadTranscript = async (chatSDK, renderMarkDown, bannerMessageOnError, attachmentMessage, state) => {
|
|
155
158
|
var _state$domainStates, _state$domainStates2, _state$domainStates2$;
|
|
156
159
|
// Need to keep existing request id for scenarios when trnascript is downloaded after endchat
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
const liveChatContext = {
|
|
161
|
+
chatToken: state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.chatToken,
|
|
162
|
+
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
|
|
163
|
+
};
|
|
164
|
+
let data = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getLiveChatTranscript({
|
|
165
|
+
liveChatContext
|
|
166
|
+
}));
|
|
163
167
|
if (typeof data === Constants.String) {
|
|
164
168
|
data = JSON.parse(data);
|
|
165
169
|
}
|
|
@@ -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) {
|
|
@@ -51,7 +51,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
51
51
|
|
|
52
52
|
// Initiate post chat render
|
|
53
53
|
if (state !== null && state !== void 0 && (_state$domainStates2 = state.domainStates) !== null && _state$domainStates2 !== void 0 && _state$domainStates2.postChatContext) {
|
|
54
|
-
await initiatePostChat(props, conversationDetails, state, dispatch);
|
|
54
|
+
await initiatePostChat(props, conversationDetails, state, dispatch, postchatContext);
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
} catch (error) {
|
|
@@ -246,25 +246,4 @@ const getEndChatEventName = async (chatSDK, props) => {
|
|
|
246
246
|
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps4;
|
|
247
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) ?? "");
|
|
248
248
|
};
|
|
249
|
-
|
|
250
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
251
|
-
const getConversationDetails = async chatSDK => {
|
|
252
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
-
let conversationDetails = undefined;
|
|
254
|
-
try {
|
|
255
|
-
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
256
|
-
Event: TelemetryEvent.GetConversationDetailsCallStarted,
|
|
257
|
-
Description: "Conversation details call started"
|
|
258
|
-
});
|
|
259
|
-
conversationDetails = await chatSDK.getConversationDetails();
|
|
260
|
-
} catch (error) {
|
|
261
|
-
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
262
|
-
Event: TelemetryEvent.GetConversationDetailsCallFailed,
|
|
263
|
-
ExceptionDetails: {
|
|
264
|
-
exception: `Get Conversation Details Call Failed : ${error}`
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
return conversationDetails;
|
|
269
|
-
};
|
|
270
|
-
export { prepareEndChat, endChat, getConversationDetails };
|
|
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,15 +28,13 @@ 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
|
|
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";
|
|
31
|
+
import DOMPurify from "dompurify";
|
|
32
32
|
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
34
|
export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
35
35
|
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain13, _props$webChatContain14, _defaultWebChatContai, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
36
|
+
// Add a hook to make all links open a new window
|
|
37
|
+
postDomPurifyActivities();
|
|
36
38
|
const localizedTexts = {
|
|
37
39
|
...defaultMiddlewareLocalizedTexts,
|
|
38
40
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -47,7 +49,7 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
47
49
|
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
|
|
48
50
|
const conversationEndCallback = async () => {
|
|
49
51
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
-
const conversationDetails = await
|
|
52
|
+
const conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
51
53
|
if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot) {
|
|
52
54
|
dispatch({
|
|
53
55
|
type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
@@ -85,9 +87,17 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
85
87
|
markdownRenderers.forEach(renderer => {
|
|
86
88
|
text = renderer.render(text);
|
|
87
89
|
});
|
|
90
|
+
text = DOMPurify.sanitize(text);
|
|
88
91
|
return text;
|
|
89
92
|
};
|
|
90
|
-
|
|
93
|
+
function postDomPurifyActivities() {
|
|
94
|
+
DOMPurify.addHook("afterSanitizeAttributes", function (node) {
|
|
95
|
+
// set all elements owning target to target=_blank
|
|
96
|
+
if ("target" in node) {
|
|
97
|
+
node.setAttribute("target", "_blank");
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
91
101
|
// Initialize the remaining Web Chat props
|
|
92
102
|
const webChatProps = {
|
|
93
103
|
...defaultWebChatContainerStatefulProps.webChatProps,
|
|
@@ -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: {
|
|
@@ -81,10 +81,11 @@ const embedModePostChatWorkflow = async (state, dispatch) => {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
-
const initiatePostChat = async (props, conversationDetailsParam, state, dispatch) => {
|
|
84
|
+
const initiatePostChat = async (props, conversationDetailsParam, state, dispatch, postchatContext) => {
|
|
85
85
|
var _conversationDetails;
|
|
86
86
|
conversationDetails = conversationDetailsParam;
|
|
87
|
-
|
|
87
|
+
const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
|
|
88
|
+
await setSurveyMode(props, participantType, state, dispatch);
|
|
88
89
|
await renderSurvey(state, dispatch);
|
|
89
90
|
};
|
|
90
91
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import { ChatSDKError, Constants, LiveWorkItemState } from "../../../common/Constants";
|
|
3
|
-
import { createTimer, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
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";
|
|
@@ -92,7 +92,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
92
92
|
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
93
93
|
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.hideErrorUIPane;
|
|
94
94
|
try {
|
|
95
|
-
var _newAdapter$activity$, _TelemetryTimers$
|
|
95
|
+
var _newAdapter$activity$, _TelemetryTimers$Widg2;
|
|
96
96
|
//Start widget load timer
|
|
97
97
|
TelemetryTimers.WidgetLoadTimer = createTimer();
|
|
98
98
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
@@ -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: {
|
|
@@ -167,10 +168,16 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
167
168
|
});
|
|
168
169
|
}
|
|
169
170
|
if (persistedState) {
|
|
171
|
+
var _TelemetryTimers$Widg;
|
|
170
172
|
dispatch({
|
|
171
173
|
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
172
174
|
payload: persistedState
|
|
173
175
|
});
|
|
176
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
177
|
+
Event: TelemetryEvent.WidgetLoadComplete,
|
|
178
|
+
Description: "Widget load complete. Persisted state retrieved",
|
|
179
|
+
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
180
|
+
});
|
|
174
181
|
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
175
182
|
return;
|
|
176
183
|
}
|
|
@@ -184,7 +191,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
184
191
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
185
192
|
Event: TelemetryEvent.WidgetLoadComplete,
|
|
186
193
|
Description: "Widget load complete",
|
|
187
|
-
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$
|
|
194
|
+
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
|
|
188
195
|
});
|
|
189
196
|
|
|
190
197
|
// Set post chat context in state
|
|
@@ -194,15 +201,10 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
194
201
|
// Updating chat session detail for telemetry
|
|
195
202
|
await updateSessionDataForTelemetry(chatSDK, dispatch);
|
|
196
203
|
} catch (ex) {
|
|
197
|
-
|
|
198
|
-
Event: TelemetryEvent.WidgetLoadFailed,
|
|
199
|
-
ExceptionDetails: {
|
|
200
|
-
Exception: `Widget load Failed: ${ex}`
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
NotificationHandler.notifyError(NotificationScenarios.Connection, "Start Chat Failed: " + ex);
|
|
204
|
+
var _TelemetryTimers$Widg4;
|
|
204
205
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
206
|
if (ex.message === ChatSDKError.WidgetUseOutsideOperatingHour) {
|
|
207
|
+
var _TelemetryTimers$Widg3;
|
|
206
208
|
dispatch({
|
|
207
209
|
type: LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
208
210
|
payload: true
|
|
@@ -211,8 +213,21 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
211
213
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
212
214
|
payload: ConversationState.OutOfOffice
|
|
213
215
|
});
|
|
216
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
217
|
+
Event: TelemetryEvent.WidgetLoadComplete,
|
|
218
|
+
Description: "Widget load complete. Widget is OOOH.",
|
|
219
|
+
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
220
|
+
});
|
|
214
221
|
return;
|
|
215
222
|
}
|
|
223
|
+
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
224
|
+
Event: TelemetryEvent.WidgetLoadFailed,
|
|
225
|
+
ExceptionDetails: {
|
|
226
|
+
Exception: `Widget load Failed: ${ex}`
|
|
227
|
+
},
|
|
228
|
+
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
|
|
229
|
+
});
|
|
230
|
+
NotificationHandler.notifyError(NotificationScenarios.Connection, "Start Chat Failed: " + ex);
|
|
216
231
|
dispatch({
|
|
217
232
|
type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
218
233
|
payload: true
|
|
@@ -343,7 +358,7 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
343
358
|
});
|
|
344
359
|
try {
|
|
345
360
|
chatSDK.requestId = requestIdFromCache;
|
|
346
|
-
conversationDetails = await chatSDK
|
|
361
|
+
conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
347
362
|
if (Object.keys(conversationDetails).length === 0) {
|
|
348
363
|
chatSDK.requestId = currentRequestId;
|
|
349
364
|
return false;
|
|
@@ -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,
|
|
@@ -134,6 +134,14 @@ export const LiveChatWidgetStateful = props => {
|
|
|
134
134
|
}
|
|
135
135
|
if (isChatValid === false) {
|
|
136
136
|
if (localState) {
|
|
137
|
+
// adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
|
|
138
|
+
if (isReconnectEnabled(props.chatConfig) === true) {
|
|
139
|
+
await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
140
|
+
// If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
|
|
141
|
+
if (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.ReconnectChat) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
137
145
|
await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, undefined, undefined, localState, props);
|
|
138
146
|
return;
|
|
139
147
|
} else {
|
|
@@ -155,7 +155,8 @@ export declare enum ElementType {
|
|
|
155
155
|
CallingContainerSDK = "CallingContainerSDK"
|
|
156
156
|
}
|
|
157
157
|
export declare enum ChatSDKError {
|
|
158
|
-
WidgetUseOutsideOperatingHour = "WidgetUseOutsideOperatingHour"
|
|
158
|
+
WidgetUseOutsideOperatingHour = "WidgetUseOutsideOperatingHour",
|
|
159
|
+
AuthContactIdNotFoundFailure = "AuthContactIdNotFoundFailure"
|
|
159
160
|
}
|
|
160
161
|
export declare enum EnvironmentVersion {
|
|
161
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",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { LogLevel, TelemetryEvent, TelemetryInput } from "./TelemetryConstants";
|
|
2
1
|
import { BaseContract, TelemetryContract } from "./definitions/Contracts";
|
|
3
2
|
import { TelemetryData } from "./definitions/Payload";
|
|
3
|
+
import { LogLevel, TelemetryEvent, TelemetryInput } from "./TelemetryConstants";
|
|
4
4
|
import ChatConfig from "@microsoft/omnichannel-chat-sdk/lib/core/ChatConfig";
|
|
5
|
-
import LiveChatContext from "@microsoft/omnichannel-chat-sdk/lib/core/LiveChatContext";
|
|
6
|
-
import LiveWorkItemDetails from "@microsoft/omnichannel-chat-sdk/lib/core/LiveWorkItemDetails";
|
|
7
5
|
import { IInternalTelemetryData } from "./interfaces/IInternalTelemetryData";
|
|
8
6
|
import { ITelemetryConfig } from "./interfaces/ITelemetryConfig";
|
|
7
|
+
import LiveChatContext from "@microsoft/omnichannel-chat-sdk/lib/core/LiveChatContext";
|
|
8
|
+
import LiveWorkItemDetails from "@microsoft/omnichannel-chat-sdk/lib/core/LiveWorkItemDetails";
|
|
9
9
|
export interface TelemetryEventWrapper {
|
|
10
10
|
Event: TelemetryEvent;
|
|
11
11
|
Description?: string;
|
|
@@ -22,6 +22,7 @@ export interface LoadTelemetryData extends BaseTelemetryData {
|
|
|
22
22
|
OCChatSDKVersion?: string;
|
|
23
23
|
OCChatWidgetVersion?: string;
|
|
24
24
|
OCChatComponentsVersion?: string;
|
|
25
|
+
Description?: string;
|
|
25
26
|
}
|
|
26
27
|
export interface MessageProcessingErrorData extends BaseTelemetryData {
|
|
27
28
|
Event: string;
|
|
@@ -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 };
|
|
@@ -2,7 +2,7 @@ import { Dispatch } from "react";
|
|
|
2
2
|
import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
|
|
3
3
|
import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
|
|
4
4
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
5
|
-
declare const initiatePostChat: (props: ILiveChatWidgetProps, conversationDetailsParam: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction
|
|
5
|
+
declare const initiatePostChat: (props: ILiveChatWidgetProps, conversationDetailsParam: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, postchatContext: any) => Promise<void>;
|
|
6
6
|
declare const isPostChatEnabled: (props: ILiveChatWidgetProps, state: ILiveChatWidgetContext) => boolean;
|
|
7
7
|
declare const getPostChatContext: (chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
|
|
8
8
|
declare const setWidgetStateToInactive: (dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
|
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.5-main.53e6741",
|
|
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.2",
|
|
80
79
|
"abort-controller-es5": "^2.0.1",
|
|
81
80
|
"dompurify": "^2.3.4",
|
|
82
81
|
"markdown-it": "^12.3.2",
|