@microsoft/omnichannel-chat-widget 1.8.1-main.565f247 → 1.8.1-main.5ac9acf
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/facades/FacadeChatSDK.js +49 -7
- package/lib/cjs/common/telemetry/TelemetryConstants.js +4 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +2 -2
- package/lib/cjs/common/utils/xssUtils.js +79 -0
- package/lib/cjs/common/utils.js +3 -0
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
- package/lib/cjs/components/errorboundary/ErrorBoundary.js +68 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +15 -4
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
- package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +12 -5
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +4 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +2 -2
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +55 -9
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -19
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +23 -2
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +14 -5
- package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +1 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +49 -7
- package/lib/esm/common/telemetry/TelemetryConstants.js +4 -0
- package/lib/esm/common/telemetry/TelemetryManager.js +2 -2
- package/lib/esm/common/utils/xssUtils.js +72 -0
- package/lib/esm/common/utils.js +3 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
- package/lib/esm/components/errorboundary/ErrorBoundary.js +59 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +16 -5
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +1 -1
- package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +12 -5
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +4 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +2 -2
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +53 -8
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -19
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +23 -2
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +14 -5
- package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +1 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -0
- package/lib/types/common/utils/xssUtils.d.ts +29 -0
- package/lib/types/components/errorboundary/ErrorBoundary.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/persistentChatHelper.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
- package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +2 -1
- package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +1 -0
- package/package.json +2 -2
|
@@ -109,7 +109,7 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
109
109
|
token: last3digits
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
|
-
throw new Error("Invalid token format, must be in JWT format");
|
|
112
|
+
throw new Error("Authentication Setup Error: Invalid token format, must be in JWT format");
|
|
113
113
|
}
|
|
114
114
|
try {
|
|
115
115
|
const payload = this.enforceBase64Encoding(tokenParts[1]);
|
|
@@ -131,9 +131,9 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
131
131
|
token: last3digits
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
|
-
throw new Error("Invalid token payload, payload is not valid JSON");
|
|
134
|
+
throw new Error("Authentication Setup Error: Invalid token payload, payload is not valid JSON");
|
|
135
135
|
} catch (e) {
|
|
136
|
-
console.error("Failed to decode token", e);
|
|
136
|
+
console.error("Authentication Setup Error: Failed to decode token", e);
|
|
137
137
|
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
138
138
|
Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationFailed,
|
|
139
139
|
Description: "Failed to decode token",
|
|
@@ -142,7 +142,7 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
142
142
|
token: last3digits
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
|
-
throw new Error("Failed to decode token");
|
|
145
|
+
throw new Error("Authentication Setup Error: Failed to decode authentication token");
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
}, {
|
|
@@ -166,7 +166,7 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
166
166
|
"Token": last3digits
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
|
-
throw new Error(
|
|
169
|
+
throw new Error("Authentication Setup Error: New authentication token is already expired");
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -280,9 +280,9 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
280
280
|
if (pingResponse.result === true) {
|
|
281
281
|
return fn();
|
|
282
282
|
}
|
|
283
|
-
const executionErrorMessage =
|
|
283
|
+
const executionErrorMessage = "Authentication Setup Error: Token validation failed - GetAuthToken function is not present";
|
|
284
284
|
//telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
|
|
285
|
-
console.error(executionErrorMessage);
|
|
285
|
+
console.error(`${executionErrorMessage} Additional details: Process to get a token failed for ${functionName}, ${pingResponse.message}`);
|
|
286
286
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
287
287
|
eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
|
|
288
288
|
payload: {
|
|
@@ -445,6 +445,48 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
445
445
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
446
446
|
return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
|
|
447
447
|
}
|
|
448
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
449
|
+
}, {
|
|
450
|
+
key: "getReconnectableChats",
|
|
451
|
+
value: async function getReconnectableChats() {
|
|
452
|
+
let reconnectableChatsParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
453
|
+
/**
|
|
454
|
+
*
|
|
455
|
+
* This is a particular case, we dont expose getReconnectableChats in the SDK,
|
|
456
|
+
* The only way to use is by tunneling directly from the SDK to OCSDK,
|
|
457
|
+
*
|
|
458
|
+
* In case of prechat, the function is called before any formal authentication is made,
|
|
459
|
+
* this is an specific case for persistent chats, to prevent the survey be loaded again for an on going chat,
|
|
460
|
+
*
|
|
461
|
+
* In this case, we check for existance of the token , otherwise we perform the authentication, error is propagated in case of issues.
|
|
462
|
+
*
|
|
463
|
+
* Once the token is obtained , this will be added to the params to call the function.
|
|
464
|
+
*
|
|
465
|
+
* This is a particular case, should not be taken as pattern.
|
|
466
|
+
*
|
|
467
|
+
*/
|
|
468
|
+
|
|
469
|
+
if (this.token === null || this.token === "") {
|
|
470
|
+
// If token is not set, try to get it using tokenRing
|
|
471
|
+
const pingResponse = await this.tokenRing();
|
|
472
|
+
if (pingResponse.result === false) {
|
|
473
|
+
const errorMessage = "Authentication Setup Error: Token validation failed for reconnectable chats";
|
|
474
|
+
//telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
|
|
475
|
+
console.error(`Authentication failed: Process to get a token failed for getReconnectableChats, ${pingResponse.message}`);
|
|
476
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
477
|
+
eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
|
|
478
|
+
payload: {
|
|
479
|
+
errorMessage: errorMessage
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
throw new Error(errorMessage);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// Always override the token in params regardless of how getReconnectableChats was called
|
|
487
|
+
reconnectableChatsParams.authenticatedUserToken = this.token;
|
|
488
|
+
return this.validateAndExecuteCall("getReconnectableChats", () => this.chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams));
|
|
489
|
+
}
|
|
448
490
|
}]);
|
|
449
491
|
return FacadeChatSDK;
|
|
450
492
|
}();
|
|
@@ -112,6 +112,8 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
112
112
|
TelemetryEvent["DisconnectEndChatSDKCallFailed"] = "DisconnectEndChatSDKCallFailed";
|
|
113
113
|
TelemetryEvent["GetChatReconnectContextSDKCallStarted"] = "GetChatReconnectContextSDKCallStarted";
|
|
114
114
|
TelemetryEvent["GetChatReconnectContextSDKCallFailed"] = "GetChatReconnectContextSDKCallFailed";
|
|
115
|
+
TelemetryEvent["CheckContactIdError"] = "checkContactIdError";
|
|
116
|
+
TelemetryEvent["GetChatReconnectContextSDKCallSucceeded"] = "GetChatReconnectContextSDKCallSucceeded";
|
|
115
117
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
116
118
|
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
117
119
|
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
@@ -179,6 +181,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
179
181
|
TelemetryEvent["CustomerVoiceResponsePageLoaded"] = "CustomerVoiceResponsePageLoaded";
|
|
180
182
|
TelemetryEvent["CustomerVoiceFormResponseSubmitted"] = "CustomerVoiceFormResponseSubmitted";
|
|
181
183
|
TelemetryEvent["CustomerVoiceFormResponseError"] = "CustomerVoiceFormResponseError";
|
|
184
|
+
TelemetryEvent["CustomerVoiceFormsError"] = "CustomerVoiceFormsError";
|
|
182
185
|
TelemetryEvent["BotAuthActivityEmptySasUrl"] = "BotAuthActivityEmptySasUrl";
|
|
183
186
|
TelemetryEvent["SetBotAuthProviderFetchConfig"] = "SetBotAuthProviderFetchConfig";
|
|
184
187
|
TelemetryEvent["SetBotAuthProviderHideCard"] = "SetBotAuthProviderHideCard";
|
|
@@ -256,6 +259,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
256
259
|
TelemetryEvent["UXNotificationPaneCompleted"] = "UXNotificationPaneCompleted";
|
|
257
260
|
TelemetryEvent["UXOutOfOfficeHoursPaneStart"] = "UXOutOfOfficeHoursPaneStart";
|
|
258
261
|
TelemetryEvent["UXOutOfOfficeHoursPaneCompleted"] = "UXOutOfOfficeHoursPaneCompleted";
|
|
262
|
+
TelemetryEvent["XSSTextDetected"] = "XSSTextDetected";
|
|
259
263
|
TelemetryEvent["UXPostChatLoadingPaneStart"] = "UXPostChatLoadingPaneStart";
|
|
260
264
|
TelemetryEvent["UXPostChatLoadingPaneCompleted"] = "UXPostChatLoadingPaneCompleted";
|
|
261
265
|
TelemetryEvent["UXPrechatPaneStart"] = "UXPrechatPaneStart";
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.disposeLoggers = exports.TelemetryTimers = exports.TelemetryManager = exports.RegisterLoggers = void 0;
|
|
7
7
|
var _TelemetryConstants = require("./TelemetryConstants");
|
|
8
8
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
|
+
var _TelemetryHelper = require("./TelemetryHelper");
|
|
10
|
+
var _appInsightsLogger = require("./loggers/appInsightsLogger");
|
|
9
11
|
var _ariaTelemetryLogger = require("./loggers/ariaTelemetryLogger");
|
|
10
12
|
var _consoleLogger = require("./loggers/consoleLogger");
|
|
11
13
|
var _defaultAriaConfig = require("./defaultConfigs/defaultAriaConfig");
|
|
12
|
-
var _TelemetryHelper = require("./TelemetryHelper");
|
|
13
|
-
var _appInsightsLogger = require("./loggers/appInsightsLogger");
|
|
14
14
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
15
15
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.detectAndCleanXSS = void 0;
|
|
7
|
+
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
/**
|
|
10
|
+
* Detects potential Cross-Site Scripting (XSS) attacks in text input and sanitizes the content.
|
|
11
|
+
*
|
|
12
|
+
* This function performs comprehensive XSS detection using pattern matching for common attack vectors
|
|
13
|
+
* and then sanitizes the input using DOMPurify with strict configuration. It's designed to protect
|
|
14
|
+
* against various XSS techniques including script injection, event handler injection, style-based
|
|
15
|
+
* attacks, and encoded payloads.
|
|
16
|
+
*
|
|
17
|
+
* Security patterns detected:
|
|
18
|
+
* - JavaScript protocol URLs (javascript:)
|
|
19
|
+
* - HTML event handlers (onmouseover, onclick, etc.)
|
|
20
|
+
* - Script tags (<script>)
|
|
21
|
+
* - CSS expression() functions
|
|
22
|
+
* - CSS url() functions
|
|
23
|
+
* - Position-based CSS attacks (position: fixed/absolute)
|
|
24
|
+
* - VBScript protocol URLs
|
|
25
|
+
* - Data URLs with HTML content
|
|
26
|
+
* - Fragment identifiers with escaped quotes
|
|
27
|
+
* - HTML entity-encoded angle brackets
|
|
28
|
+
*
|
|
29
|
+
* @param text - The input text to be analyzed and sanitized
|
|
30
|
+
* @returns An object containing:
|
|
31
|
+
* - cleanText: The sanitized version of the input text with all HTML tags and attributes removed
|
|
32
|
+
* - isXSSDetected: Boolean flag indicating whether potential XSS patterns were found in the original text
|
|
33
|
+
*/
|
|
34
|
+
const detectAndCleanXSS = text => {
|
|
35
|
+
// Comprehensive array of regular expressions to detect common XSS attack patterns
|
|
36
|
+
const xssPatterns = [/javascript\s*:/gi,
|
|
37
|
+
// JavaScript protocol URLs (with optional spaces)
|
|
38
|
+
/vbscript\s*:/gi,
|
|
39
|
+
// VBScript protocol URLs (with optional spaces)
|
|
40
|
+
/on\w+\s*=/gi,
|
|
41
|
+
// HTML event handlers (onmouseover, onclick, onload, etc.)
|
|
42
|
+
/<\s*script/gi,
|
|
43
|
+
// Script tag opening (with optional spaces)
|
|
44
|
+
/expression\s*\(/gi,
|
|
45
|
+
// CSS expression() function (IE-specific)
|
|
46
|
+
/url\s*\(/gi,
|
|
47
|
+
// CSS url() function
|
|
48
|
+
/style\s*=.*position\s*:\s*fixed/gi,
|
|
49
|
+
// CSS position fixed attacks
|
|
50
|
+
/style\s*=.*position\s*:\s*absolute/gi,
|
|
51
|
+
// CSS position absolute attacks
|
|
52
|
+
/data\s*:\s*text\s*\/\s*html/gi,
|
|
53
|
+
// Data URLs containing HTML
|
|
54
|
+
/#.*\\"/gi,
|
|
55
|
+
// Fragment identifiers with escaped quotes
|
|
56
|
+
/>.*</gi // HTML entity-encoded angle brackets indicating tag structure
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
// Check if any XSS patterns are detected in the input text
|
|
60
|
+
const isXSSDetected = xssPatterns.some(pattern => pattern.test(text));
|
|
61
|
+
|
|
62
|
+
// Clean the text using DOMPurify with strict config
|
|
63
|
+
const cleanText = _dompurify.default.sanitize(text, {
|
|
64
|
+
ALLOWED_TAGS: [],
|
|
65
|
+
// No HTML tags allowed in title
|
|
66
|
+
ALLOWED_ATTR: [],
|
|
67
|
+
KEEP_CONTENT: true,
|
|
68
|
+
// Keep text content
|
|
69
|
+
ALLOW_DATA_ATTR: false,
|
|
70
|
+
ALLOW_UNKNOWN_PROTOCOLS: false,
|
|
71
|
+
SANITIZE_DOM: true,
|
|
72
|
+
FORCE_BODY: false
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
cleanText,
|
|
76
|
+
isXSSDetected
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
exports.detectAndCleanXSS = detectAndCleanXSS;
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -421,6 +421,9 @@ const getConversationDetailsCall = async function (facadeChatSDK) {
|
|
|
421
421
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
422
422
|
exports.getConversationDetailsCall = getConversationDetailsCall;
|
|
423
423
|
const checkContactIdError = e => {
|
|
424
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
425
|
+
Event: _TelemetryConstants.TelemetryEvent.CheckContactIdError
|
|
426
|
+
});
|
|
424
427
|
if ((e === null || e === void 0 ? void 0 : e.message) === _omnichannelChatSdk.ChatSDKErrorName.AuthContactIdNotFoundFailure) {
|
|
425
428
|
const contactIdNotFoundErrorEvent = {
|
|
426
429
|
eventName: _TelemetryConstants.BroadcastEvent.ContactIdNotFound,
|
|
@@ -84,9 +84,13 @@ const ConfirmationPaneStateful = props => {
|
|
|
84
84
|
(0, _react.useEffect)(() => {
|
|
85
85
|
(0, _utils.preventFocusToMoveOutOfElement)(controlProps.id);
|
|
86
86
|
const focusableElements = (0, _utils.findAllFocusableElement)(`#${controlProps.id}`);
|
|
87
|
-
|
|
88
|
-
focusableElements[0]
|
|
89
|
-
|
|
87
|
+
requestAnimationFrame(() => {
|
|
88
|
+
if (focusableElements && focusableElements.length > 0 && focusableElements[0]) {
|
|
89
|
+
focusableElements[0].focus({
|
|
90
|
+
preventScroll: true
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
90
94
|
elements = (0, _utils.findParentFocusableElementsWithoutChildContainer)(controlProps.id);
|
|
91
95
|
(0, _utils.setTabIndices)(elements, initialTabIndexMap, false);
|
|
92
96
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
+
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); }
|
|
15
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
16
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
17
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
18
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
19
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
+
const RenderChildrenFunction = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
children
|
|
25
|
+
} = _ref;
|
|
26
|
+
return typeof children === 'function' ? children() : children;
|
|
27
|
+
};
|
|
28
|
+
let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
29
|
+
_inherits(ErrorBoundary, _Component);
|
|
30
|
+
var _super = _createSuper(ErrorBoundary);
|
|
31
|
+
function ErrorBoundary(props) {
|
|
32
|
+
var _this;
|
|
33
|
+
_classCallCheck(this, ErrorBoundary);
|
|
34
|
+
_this = _super.call(this, props);
|
|
35
|
+
_this.state = {
|
|
36
|
+
hasError: false
|
|
37
|
+
};
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
_createClass(ErrorBoundary, [{
|
|
41
|
+
key: "componentDidCatch",
|
|
42
|
+
value: function componentDidCatch(error) {
|
|
43
|
+
const {
|
|
44
|
+
onError
|
|
45
|
+
} = this.props;
|
|
46
|
+
this.setState({
|
|
47
|
+
hasError: true
|
|
48
|
+
});
|
|
49
|
+
if (onError) {
|
|
50
|
+
onError(error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
key: "render",
|
|
55
|
+
value: function render() {
|
|
56
|
+
const {
|
|
57
|
+
children
|
|
58
|
+
} = this.props;
|
|
59
|
+
const {
|
|
60
|
+
hasError
|
|
61
|
+
} = this.state;
|
|
62
|
+
return !hasError && /*#__PURE__*/_react.default.createElement(RenderChildrenFunction, null, children);
|
|
63
|
+
}
|
|
64
|
+
}]);
|
|
65
|
+
return ErrorBoundary;
|
|
66
|
+
}(_react.Component);
|
|
67
|
+
var _default = ErrorBoundary;
|
|
68
|
+
exports.default = _default;
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _ChatAdapterStore = require("../../contexts/ChatAdapterStore");
|
|
9
9
|
var _ChatContextStore = require("../../contexts/ChatContextStore");
|
|
10
10
|
var _ChatSDKStore = require("../../contexts/ChatSDKStore");
|
|
11
|
+
var _ErrorBoundary = _interopRequireDefault(require("../errorboundary/ErrorBoundary"));
|
|
11
12
|
var _FacadeChatSDK = require("../../common/facades/FacadeChatSDK");
|
|
12
13
|
var _FacadeChatSDKStore = require("../../contexts/FacadeChatSDKStore");
|
|
13
14
|
var _LiveChatWidgetStateful = _interopRequireDefault(require("./livechatwidgetstateful/LiveChatWidgetStateful"));
|
|
@@ -15,12 +16,15 @@ var _createReducer = require("../../contexts/createReducer");
|
|
|
15
16
|
var _LiveChatWidgetContextInitialState = require("../../contexts/common/LiveChatWidgetContextInitialState");
|
|
16
17
|
var _getMockChatSDKIfApplicable = require("./common/getMockChatSDKIfApplicable");
|
|
17
18
|
var _utils = require("../../common/utils");
|
|
19
|
+
var _liveChatConfigUtils = require("./common/liveChatConfigUtils");
|
|
20
|
+
var _startChatErrorHandler = require("./common/startChatErrorHandler");
|
|
18
21
|
var _overridePropsOnMockIfApplicable = _interopRequireDefault(require("./common/overridePropsOnMockIfApplicable"));
|
|
22
|
+
var _registerTelemetryLoggers = require("./common/registerTelemetryLoggers");
|
|
19
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
25
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
26
|
const LiveChatWidget = props => {
|
|
23
|
-
var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv;
|
|
27
|
+
var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig2, _props$chatConfig2$Li;
|
|
24
28
|
const reducer = (0, _createReducer.createReducer)();
|
|
25
29
|
const [state, dispatch] = (0, _react.useReducer)(reducer, (0, _LiveChatWidgetContextInitialState.getLiveChatWidgetContextInitialState)(props));
|
|
26
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -34,7 +38,7 @@ const LiveChatWidget = props => {
|
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
const isAuthenticatedChat = !!((_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);
|
|
41
|
+
const isAuthenticatedChat = !!((_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) || (0, _liveChatConfigUtils.isPersistentChatEnabled)((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_conversationmode);
|
|
38
42
|
if (!facadeChatSDK) {
|
|
39
43
|
var _props$mock2;
|
|
40
44
|
setFacadeChatSDK(new _FacadeChatSDK.FacadeChatSDK({
|
|
@@ -46,7 +50,14 @@ const LiveChatWidget = props => {
|
|
|
46
50
|
"isSDKMocked": !(0, _utils.isNullOrUndefined)(props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type)
|
|
47
51
|
}, disableReauthentication));
|
|
48
52
|
}
|
|
49
|
-
|
|
53
|
+
(0, _react.useEffect)(() => {
|
|
54
|
+
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
55
|
+
}, [dispatch]);
|
|
56
|
+
return /*#__PURE__*/_react.default.createElement(_ErrorBoundary.default, {
|
|
57
|
+
onError: error => {
|
|
58
|
+
(0, _startChatErrorHandler.logWidgetLoadWithUnexpectedError)(error);
|
|
59
|
+
}
|
|
60
|
+
}, /*#__PURE__*/_react.default.createElement(_FacadeChatSDKStore.FacadeChatSDKStore.Provider, {
|
|
50
61
|
value: [facadeChatSDK, setFacadeChatSDK]
|
|
51
62
|
}, /*#__PURE__*/_react.default.createElement(_ChatSDKStore.ChatSDKStore.Provider, {
|
|
52
63
|
value: chatSDK
|
|
@@ -54,7 +65,7 @@ const LiveChatWidget = props => {
|
|
|
54
65
|
value: [adapter, setAdapter]
|
|
55
66
|
}, /*#__PURE__*/_react.default.createElement(_ChatContextStore.ChatContextStore.Provider, {
|
|
56
67
|
value: [state, dispatch]
|
|
57
|
-
}, /*#__PURE__*/_react.default.createElement(_LiveChatWidgetStateful.default, props)))));
|
|
68
|
+
}, /*#__PURE__*/_react.default.createElement(_LiveChatWidgetStateful.default, props))))));
|
|
58
69
|
};
|
|
59
70
|
exports.LiveChatWidget = LiveChatWidget;
|
|
60
71
|
var _default = LiveChatWidget;
|
|
@@ -13,7 +13,7 @@ const isPostChatSurveyEnabled = async facadeChatSDK => {
|
|
|
13
13
|
return postChatEnabled === "true";
|
|
14
14
|
};
|
|
15
15
|
exports.isPostChatSurveyEnabled = isPostChatSurveyEnabled;
|
|
16
|
-
const isPersistentChatEnabled =
|
|
16
|
+
const isPersistentChatEnabled = conversationMode => {
|
|
17
17
|
if ((0, _utils.isNullOrUndefined)(conversationMode)) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
@@ -6,16 +6,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.shouldSetPreChatIfPersistentChat = void 0;
|
|
7
7
|
var _liveChatConfigUtils = require("./liveChatConfigUtils");
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
const shouldSetPreChatIfPersistentChat = async (
|
|
10
|
-
const persistentEnabled =
|
|
9
|
+
const shouldSetPreChatIfPersistentChat = async (facadeChatSDK, conversationMode, showPreChat) => {
|
|
10
|
+
const persistentEnabled = (0, _liveChatConfigUtils.isPersistentChatEnabled)(conversationMode);
|
|
11
11
|
let skipPreChat = false;
|
|
12
12
|
if (persistentEnabled) {
|
|
13
|
+
// Access private properties using type assertions
|
|
14
|
+
const chatSDK = facadeChatSDK.getChatSDK();
|
|
15
|
+
|
|
16
|
+
// Use type assertion to bypass private access restriction
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
const sdkAsAny = chatSDK;
|
|
19
|
+
// most likely this is not set , the facade will take care of it
|
|
13
20
|
const reconnectableChatsParams = {
|
|
14
|
-
authenticatedUserToken:
|
|
15
|
-
requestId:
|
|
21
|
+
authenticatedUserToken: sdkAsAny.authenticatedUserToken,
|
|
22
|
+
requestId: sdkAsAny.requestId
|
|
16
23
|
};
|
|
17
24
|
try {
|
|
18
|
-
const reconnectableChatsResponse = await
|
|
25
|
+
const reconnectableChatsResponse = await facadeChatSDK.getReconnectableChats(reconnectableChatsParams);
|
|
19
26
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
|
20
27
|
// Skip rendering prechat on existing persistent chat session
|
|
21
28
|
skipPreChat = true;
|
|
@@ -73,6 +73,10 @@ const getChatReconnectContext = async (facadeChatSDK, chatConfig, props, isAuthe
|
|
|
73
73
|
// AuthToken will be reset later at start chat
|
|
74
74
|
(0, _authHelper.removeAuthTokenProvider)(facadeChatSDK.getChatSDK());
|
|
75
75
|
}
|
|
76
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
77
|
+
Event: _TelemetryConstants.TelemetryEvent.GetChatReconnectContextSDKCallSucceeded,
|
|
78
|
+
Description: "Reconnect context SDK call succeeded"
|
|
79
|
+
});
|
|
76
80
|
return reconnectChatContext;
|
|
77
81
|
}
|
|
78
82
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -75,7 +75,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
|
|
|
75
75
|
const parseToJson = false;
|
|
76
76
|
const preChatSurveyResponse = (props === null || props === void 0 ? void 0 : (_props$preChatSurveyP = props.preChatSurveyPaneProps) === null || _props$preChatSurveyP === void 0 ? void 0 : (_props$preChatSurveyP2 = _props$preChatSurveyP.controlProps) === null || _props$preChatSurveyP2 === void 0 ? void 0 : _props$preChatSurveyP2.payload) ?? (await facadeChatSDK.getPreChatSurvey(parseToJson));
|
|
77
77
|
let showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse && !(props !== null && props !== void 0 && (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hidePreChatSurveyPane);
|
|
78
|
-
showPrechat = await (0, _persistentChatHelper.shouldSetPreChatIfPersistentChat)(facadeChatSDK
|
|
78
|
+
showPrechat = await (0, _persistentChatHelper.shouldSetPreChatIfPersistentChat)(facadeChatSDK, state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$l = _state$domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_conversationmode, showPrechat);
|
|
79
79
|
if (showPrechat) {
|
|
80
80
|
var _state$domainStates2, _state$domainStates2$, _state$domainStates2$2, _state$domainStates2$3;
|
|
81
81
|
const isOutOfOperatingHours = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.liveChatConfig) === null || _state$domainStates2$ === void 0 ? void 0 : (_state$domainStates2$2 = _state$domainStates2$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates2$2 === void 0 ? void 0 : (_state$domainStates2$3 = _state$domainStates2$2.OutOfOperatingHours) === null || _state$domainStates2$3 === void 0 ? void 0 : _state$domainStates2$3.toString().toLowerCase()) === "true";
|
|
@@ -163,7 +163,7 @@ exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
|
163
163
|
const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
164
164
|
var _state$domainStates7, _state$domainStates7$, _state$domainStates7$2;
|
|
165
165
|
let isStartChatSuccessful = false;
|
|
166
|
-
const persistentChatEnabled =
|
|
166
|
+
const persistentChatEnabled = (0, _liveChatConfigUtils.isPersistentChatEnabled)(state === null || state === void 0 ? void 0 : (_state$domainStates7 = state.domainStates) === null || _state$domainStates7 === void 0 ? void 0 : (_state$domainStates7$ = _state$domainStates7.liveChatConfig) === null || _state$domainStates7$ === void 0 ? void 0 : (_state$domainStates7$2 = _state$domainStates7$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates7$2 === void 0 ? void 0 : _state$domainStates7$2.msdyn_conversationmode);
|
|
167
167
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
168
168
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
169
169
|
(0, _endChat.chatSDKStateCleanUp)(facadeChatSDK.getChatSDK());
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.logWidgetLoadComplete = exports.handleStartChatError = void 0;
|
|
6
|
+
exports.logWidgetLoadWithUnexpectedError = exports.logWidgetLoadComplete = exports.handleStartChatError = void 0;
|
|
7
7
|
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _Constants = require("../../../common/Constants");
|
|
@@ -15,6 +15,11 @@ var _StartChatFailureType = require("../../../contexts/common/StartChatFailureTy
|
|
|
15
15
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
16
16
|
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
17
17
|
var _utils = require("../../../common/utils");
|
|
18
|
+
// Helper function to check if error is authentication-related
|
|
19
|
+
const isAuthenticationError = errorMessage => {
|
|
20
|
+
return errorMessage === _Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString || errorMessage.startsWith("Authentication Setup Error:") || errorMessage.includes("Token validation failed") || errorMessage.includes("Authentication token");
|
|
21
|
+
};
|
|
22
|
+
|
|
18
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
24
|
const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStartChatSuccessful) => {
|
|
20
25
|
var _props$controlProps;
|
|
@@ -23,19 +28,16 @@ const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStartChatSuc
|
|
|
23
28
|
return;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
// Handle
|
|
27
|
-
if (ex.message
|
|
31
|
+
// Handle authentication-related errors
|
|
32
|
+
if (isAuthenticationError(ex.message)) {
|
|
28
33
|
dispatch({
|
|
29
34
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
30
35
|
payload: _StartChatFailureType.StartChatFailureType.AuthSetupError
|
|
31
36
|
});
|
|
32
|
-
// set conversation to error to enforce error UI pane
|
|
33
|
-
dispatch({
|
|
34
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
35
|
-
payload: _ConversationState.ConversationState.Error
|
|
36
|
-
});
|
|
37
37
|
logWidgetLoadCompleteWithError(ex);
|
|
38
|
+
// Don't return early - let the generic error handling logic handle hideErrorUIPane and telemetry
|
|
38
39
|
}
|
|
40
|
+
|
|
39
41
|
if (ex.message === _Constants.WidgetLoadCustomErrorString.NetworkErrorString) {
|
|
40
42
|
logWidgetLoadCompleteWithError(ex);
|
|
41
43
|
}
|
|
@@ -58,8 +60,11 @@ const handleStartChatError = (dispatch, facadeChatSDK, props, ex, isStartChatSuc
|
|
|
58
60
|
case _omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK:
|
|
59
61
|
handleUninitializedChatSDK(ex);
|
|
60
62
|
break;
|
|
61
|
-
// Handle the case indicating failure to retrieve an authenticated chat conversation
|
|
62
63
|
case _omnichannelChatSdk.ChatSDKErrorName.AuthenticatedChatConversationRetrievalFailure:
|
|
64
|
+
dispatch({
|
|
65
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
66
|
+
payload: _StartChatFailureType.StartChatFailureType.Unauthorized
|
|
67
|
+
});
|
|
63
68
|
logWidgetLoadCompleteWithError(ex);
|
|
64
69
|
break;
|
|
65
70
|
case _omnichannelChatSdk.ChatSDKErrorName.InvalidConversation:
|
|
@@ -112,6 +117,9 @@ const logWidgetLoadFailed = ex => {
|
|
|
112
117
|
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
113
118
|
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
114
119
|
}
|
|
120
|
+
if (ex !== null && ex !== void 0 && ex.exceptionDetails) {
|
|
121
|
+
exDetails.ChatSDKExceptionDetails = ex.exceptionDetails;
|
|
122
|
+
}
|
|
115
123
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
116
124
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
117
125
|
Description: "Widget load complete with error",
|
|
@@ -141,6 +149,9 @@ const logWidgetLoadCompleteWithError = ex => {
|
|
|
141
149
|
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
142
150
|
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
143
151
|
}
|
|
152
|
+
if (ex !== null && ex !== void 0 && ex.exceptionDetails) {
|
|
153
|
+
exDetails.ChatSDKExceptionDetails = ex.exceptionDetails;
|
|
154
|
+
}
|
|
144
155
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
145
156
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
146
157
|
Description: "Widget load complete with error",
|
|
@@ -148,8 +159,37 @@ const logWidgetLoadCompleteWithError = ex => {
|
|
|
148
159
|
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
|
|
149
160
|
});
|
|
150
161
|
};
|
|
162
|
+
const logWidgetLoadWithUnexpectedError = ex => {
|
|
163
|
+
var _TelemetryTimers$Widg4;
|
|
164
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
165
|
+
const details = {
|
|
166
|
+
message: (ex === null || ex === void 0 ? void 0 : ex.message) || "An unexpected error occurred",
|
|
167
|
+
stack: (ex === null || ex === void 0 ? void 0 : ex.stack) || "No stack trace available"
|
|
168
|
+
};
|
|
169
|
+
let additionalDetails = "";
|
|
170
|
+
try {
|
|
171
|
+
additionalDetails = JSON.stringify(details);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
additionalDetails = "Failed to stringify error details";
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
177
|
+
const exDetails = {
|
|
178
|
+
Exception: `Widget load with unexpected error: ${additionalDetails}`
|
|
179
|
+
};
|
|
180
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
181
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
182
|
+
}
|
|
183
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
184
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
185
|
+
Description: "Widget load with unexpected error",
|
|
186
|
+
ExceptionDetails: exDetails,
|
|
187
|
+
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
|
|
188
|
+
});
|
|
189
|
+
};
|
|
151
190
|
|
|
152
191
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
192
|
+
exports.logWidgetLoadWithUnexpectedError = logWidgetLoadWithUnexpectedError;
|
|
153
193
|
const forceEndChat = facadeChatSDK => {
|
|
154
194
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
155
195
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
@@ -200,6 +240,12 @@ const handleChatTokenRetrievalFailure = (dispatch, ex) => {
|
|
|
200
240
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
201
241
|
payload: _StartChatFailureType.StartChatFailureType.Unauthorized
|
|
202
242
|
});
|
|
243
|
+
} else {
|
|
244
|
+
// For other authentication-related token retrieval failures, set as AuthSetupError
|
|
245
|
+
dispatch({
|
|
246
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_START_CHAT_FAILURE_TYPE,
|
|
247
|
+
payload: _StartChatFailureType.StartChatFailureType.AuthSetupError
|
|
248
|
+
});
|
|
203
249
|
}
|
|
204
250
|
logWidgetLoadCompleteWithError(ex);
|
|
205
251
|
}
|