@microsoft/omnichannel-chat-widget 0.1.0-main.34fc37e → 0.1.0-main.3aede09
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/storage/default/defaultCacheManager.js +34 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -8
- package/lib/cjs/components/livechatwidget/common/authHelper.js +16 -3
- package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +3 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +12 -3
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +49 -41
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +6 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +10 -3
- package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -8
- package/lib/esm/components/livechatwidget/common/authHelper.js +14 -3
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +3 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +13 -4
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +48 -41
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +5 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +8 -3
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +5 -1
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +3 -2
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/package.json +2 -2
|
@@ -35,6 +35,8 @@ var _BotMagicCodeStore = require("./webchatcontroller/BotMagicCodeStore");
|
|
|
35
35
|
|
|
36
36
|
var _defaultAdaptiveCardStyles = require("./common/defaultStyles/defaultAdaptiveCardStyles");
|
|
37
37
|
|
|
38
|
+
var _defaultReceivedMessageAnchorStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles");
|
|
39
|
+
|
|
38
40
|
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); }
|
|
39
41
|
|
|
40
42
|
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; }
|
|
@@ -68,7 +70,7 @@ const createMagicCodeSuccessResponse = signin => {
|
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
const WebChatContainerStateful = props => {
|
|
71
|
-
var _props$adaptiveCardSt, _props$adaptiveCardSt2;
|
|
73
|
+
var _props$adaptiveCardSt, _props$adaptiveCardSt2, _props$renderingMiddl, _props$renderingMiddl2, _props$renderingMiddl3, _props$renderingMiddl4;
|
|
72
74
|
|
|
73
75
|
const {
|
|
74
76
|
BasicWebChat
|
|
@@ -153,7 +155,8 @@ const WebChatContainerStateful = props => {
|
|
|
153
155
|
.ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
|
|
154
156
|
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
|
|
155
157
|
height: '.75em';
|
|
156
|
-
marginLeft: '.25em';
|
|
158
|
+
marginLeft: '.25em';
|
|
159
|
+
filter:${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl = props.renderingMiddlewareProps) === null || _props$renderingMiddl === void 0 ? void 0 : (_props$renderingMiddl2 = _props$renderingMiddl.receivedMessageAnchorStyles) === null || _props$renderingMiddl2 === void 0 ? void 0 : _props$renderingMiddl2.filter) ?? "none"};
|
|
157
160
|
}
|
|
158
161
|
pre {
|
|
159
162
|
white-space: pre-wrap;
|
|
@@ -166,7 +169,7 @@ const WebChatContainerStateful = props => {
|
|
|
166
169
|
.ms_lcw_webchat_received_message a:visited,
|
|
167
170
|
.ms_lcw_webchat_received_message a:hover,
|
|
168
171
|
.ms_lcw_webchat_received_message a:active {
|
|
169
|
-
color:
|
|
172
|
+
color: ${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl3 = props.renderingMiddlewareProps) === null || _props$renderingMiddl3 === void 0 ? void 0 : (_props$renderingMiddl4 = _props$renderingMiddl3.receivedMessageAnchorStyles) === null || _props$renderingMiddl4 === void 0 ? void 0 : _props$renderingMiddl4.color) ?? (_defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === null || _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === void 0 ? void 0 : _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles.color)};
|
|
170
173
|
} `), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
171
174
|
styles: containerStyles
|
|
172
175
|
}, /*#__PURE__*/_react2.default.createElement(BasicWebChat, null)));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultReceivedMessageAnchorStyles = void 0;
|
|
7
|
+
const defaultReceivedMessageAnchorStyles = {
|
|
8
|
+
color: "white"
|
|
9
|
+
};
|
|
10
|
+
exports.defaultReceivedMessageAnchorStyles = defaultReceivedMessageAnchorStyles;
|
|
@@ -9,11 +9,18 @@ var _ConversationState = require("./ConversationState");
|
|
|
9
9
|
|
|
10
10
|
var _defaultMiddlewareLocalizedTexts = require("../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
11
11
|
|
|
12
|
+
var _utils = require("../../common/utils");
|
|
13
|
+
|
|
14
|
+
var _defaultClientDataStoreProvider = require("../../common/storage/default/defaultClientDataStoreProvider");
|
|
15
|
+
|
|
12
16
|
const getLiveChatWidgetContextInitialState = props => {
|
|
13
|
-
var _props$webChatContain;
|
|
17
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$webChatContain;
|
|
18
|
+
|
|
19
|
+
const widgetCacheId = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
20
|
+
const initialState = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)().getData(widgetCacheId, "localStorage");
|
|
14
21
|
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
22
|
+
if (!(0, _utils.isNullOrUndefined)(initialState)) {
|
|
23
|
+
return JSON.parse(initialState);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
const LiveChatWidgetContextInitialState = {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
3
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
|
+
import { getWidgetCacheId } from "../../utils";
|
|
5
|
+
import { defaultClientDataStoreProvider } from "./defaultClientDataStoreProvider";
|
|
6
|
+
export class defaultCacheManager {}
|
|
7
|
+
|
|
8
|
+
_defineProperty(defaultCacheManager, "InternalCache", {});
|
|
9
|
+
|
|
10
|
+
export const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId) => {
|
|
11
|
+
const widgetCacheId = getWidgetCacheId(orgid, widgetId, widgetInstanceId);
|
|
12
|
+
BroadcastService.getMessageByEventName(widgetCacheId).subscribe(msg => {
|
|
13
|
+
try {
|
|
14
|
+
defaultClientDataStoreProvider().setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error("Error in setting data to localstorage", error);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { inMemoryDataStore } from "./defaultInMemoryDataStore";
|
|
2
|
+
import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
|
|
3
|
+
import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
|
|
4
|
+
export const defaultClientDataStoreProvider = () => {
|
|
5
|
+
const isCookieAllowed = () => {
|
|
6
|
+
try {
|
|
7
|
+
localStorage;
|
|
8
|
+
sessionStorage;
|
|
9
|
+
return true;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
console.error("Third party cookie blocked");
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const TtlInMs = 15 * 60 * 1000; // 15 mins
|
|
17
|
+
|
|
18
|
+
const dataStoreProvider = {
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
setData: (key, data, type) => {
|
|
21
|
+
if (isCookieAllowed()) {
|
|
22
|
+
try {
|
|
23
|
+
if (key) {
|
|
24
|
+
const now = new Date();
|
|
25
|
+
const item = {
|
|
26
|
+
data: data,
|
|
27
|
+
expiry: now.getTime() + TtlInMs
|
|
28
|
+
};
|
|
29
|
+
const strItem = JSON.stringify(item);
|
|
30
|
+
|
|
31
|
+
if (type === "localStorage") {
|
|
32
|
+
localStorage.setItem(key, strItem);
|
|
33
|
+
} else {
|
|
34
|
+
sessionStorage.setItem(key, strItem);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
39
|
+
Event: TelemetryEvent.ClientDataStoreProviderFailed,
|
|
40
|
+
ExceptionDetails: error,
|
|
41
|
+
Description: "Unable to store data in localStorage."
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
const dataToCache = {
|
|
46
|
+
key: key,
|
|
47
|
+
data: data,
|
|
48
|
+
type: type
|
|
49
|
+
};
|
|
50
|
+
parent.postMessage(dataToCache, "*");
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
getData: (key, type) => {
|
|
55
|
+
if (isCookieAllowed()) {
|
|
56
|
+
let item;
|
|
57
|
+
|
|
58
|
+
if (type === "localStorage") {
|
|
59
|
+
item = localStorage.getItem(key);
|
|
60
|
+
} else {
|
|
61
|
+
item = sessionStorage.getItem(key);
|
|
62
|
+
} //Return item if not expired
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
let itemInJson = undefined;
|
|
66
|
+
|
|
67
|
+
if (item !== null) {
|
|
68
|
+
itemInJson = JSON.parse(item);
|
|
69
|
+
const now = new Date(); // compare the expiry time of the item with the current time
|
|
70
|
+
|
|
71
|
+
if (now.getTime() > itemInJson.expiry) {
|
|
72
|
+
// If the item is expired, delete the item from storage
|
|
73
|
+
// and return null
|
|
74
|
+
localStorage.removeItem(key);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return itemInJson.data;
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
// get data from in memory db when cookie is disabled
|
|
82
|
+
return inMemoryDataStore().getData(key);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
removeData: (key, type) => {
|
|
87
|
+
if (isCookieAllowed()) {
|
|
88
|
+
if (key) {
|
|
89
|
+
if (type === "localStorage") {
|
|
90
|
+
return localStorage.removeItem(key);
|
|
91
|
+
} else {
|
|
92
|
+
return sessionStorage.removeItem(key);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
// get data from in memory db when cookie is disabled
|
|
97
|
+
return inMemoryDataStore().removeData(key);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return dataStoreProvider;
|
|
102
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
|
|
2
|
+
import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
|
|
3
|
+
import { defaultCacheManager } from "./defaultCacheManager";
|
|
4
|
+
export const defaultInitializeInMemoryDataStore = widgetId => {
|
|
5
|
+
try {
|
|
6
|
+
localStorage;
|
|
7
|
+
} catch (error) {
|
|
8
|
+
// Register below events when localStorage is not accessible
|
|
9
|
+
// Listening to event raised from client browser
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
window.addEventListener("message", function (e) {
|
|
12
|
+
try {
|
|
13
|
+
if (e.data.key) {
|
|
14
|
+
const browserData = e.data;
|
|
15
|
+
|
|
16
|
+
if (defaultCacheManager.InternalCache[browserData.key]) {
|
|
17
|
+
delete defaultCacheManager.InternalCache[browserData.key];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
defaultCacheManager.InternalCache[browserData.key] = browserData.data;
|
|
21
|
+
}
|
|
22
|
+
} catch (error) {
|
|
23
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
24
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
25
|
+
ExceptionDetails: error,
|
|
26
|
+
Description: "Unable to register default in-memory cache."
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}); // send cache initialize message to client
|
|
30
|
+
|
|
31
|
+
if (defaultCacheManager.InternalCache === undefined || {}) {
|
|
32
|
+
parent.postMessage({
|
|
33
|
+
data: "cacheinitialize",
|
|
34
|
+
widgetId: widgetId
|
|
35
|
+
}, "*");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const inMemoryDataStore = () => {
|
|
40
|
+
const dataStoreProvider = {
|
|
41
|
+
getData: key => {
|
|
42
|
+
if (defaultCacheManager.InternalCache && defaultCacheManager.InternalCache[key]) {
|
|
43
|
+
return defaultCacheManager.InternalCache[key];
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
setData: (key, data) => {
|
|
48
|
+
try {
|
|
49
|
+
defaultCacheManager.InternalCache[key] = data;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
52
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
53
|
+
ExceptionDetails: error,
|
|
54
|
+
Description: "Unable to set data in default in-memory cache."
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
removeData: key => {
|
|
59
|
+
try {
|
|
60
|
+
defaultCacheManager.InternalCache[key] = {};
|
|
61
|
+
} catch (error) {
|
|
62
|
+
TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
|
|
63
|
+
Event: TelemetryEvent.InMemoryDataStoreFailed,
|
|
64
|
+
ExceptionDetails: error,
|
|
65
|
+
Description: "Unable to remove data from default in-memory cache."
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return dataStoreProvider;
|
|
71
|
+
};
|
|
@@ -89,6 +89,8 @@ export let TelemetryEvent;
|
|
|
89
89
|
TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
|
|
90
90
|
TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
|
|
91
91
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
92
|
+
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
93
|
+
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
92
94
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
93
95
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
94
96
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -159,6 +161,8 @@ export let TelemetryEvent;
|
|
|
159
161
|
TelemetryEvent["MessageSent"] = "MessageSent";
|
|
160
162
|
TelemetryEvent["MessageReceived"] = "MessageReceived";
|
|
161
163
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
164
|
+
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
165
|
+
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
162
166
|
})(TelemetryEvent || (TelemetryEvent = {}));
|
|
163
167
|
|
|
164
168
|
export class TelemetryConstants {
|
|
@@ -205,6 +209,8 @@ export class TelemetryConstants {
|
|
|
205
209
|
case TelemetryEvent.MessageReceived:
|
|
206
210
|
case TelemetryEvent.CustomContextReceived:
|
|
207
211
|
case TelemetryEvent.BrowserUnloadEventStarted:
|
|
212
|
+
case TelemetryEvent.NetworkDisconnected:
|
|
213
|
+
case TelemetryEvent.NetworkReconnected:
|
|
208
214
|
return ScenarioType.ACTIONS;
|
|
209
215
|
|
|
210
216
|
case TelemetryEvent.StartChatSDKCall:
|
|
@@ -84,14 +84,7 @@ export const FooterStateful = props => {
|
|
|
84
84
|
isAudioMuted: state.appStates.isAudioMuted
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
|
|
88
|
-
const footer = document.getElementById(footerId);
|
|
89
|
-
|
|
90
|
-
if (footer) {
|
|
91
|
-
footer.style.display = hideFooterDisplay ? "none" : "";
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Footer, {
|
|
87
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !hideFooterDisplay && /*#__PURE__*/React.createElement(Footer, {
|
|
95
88
|
componentOverrides: footerProps === null || footerProps === void 0 ? void 0 : footerProps.componentOverrides,
|
|
96
89
|
controlProps: controlProps,
|
|
97
90
|
styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
3
|
-
import { isNullOrEmptyString } from "../../../common/utils";
|
|
3
|
+
import { isNullOrEmptyString } from "../../../common/utils";
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const getAuthClientFunction = chatConfig => {
|
|
6
6
|
let authClientFunction = undefined;
|
|
7
7
|
|
|
8
8
|
if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
|
|
@@ -11,6 +11,13 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
11
11
|
authClientFunction = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveChatC = chatConfig.LiveChatConfigAuthSettings) === null || _chatConfig$LiveChatC === void 0 ? void 0 : _chatConfig$LiveChatC.msdyn_javascriptclientfunction) ?? undefined;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
return authClientFunction;
|
|
15
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
19
|
+
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
20
|
+
|
|
14
21
|
if (getAuthToken && authClientFunction) {
|
|
15
22
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
16
23
|
Event: TelemetryEvent.GetAuthTokenCalled
|
|
@@ -22,12 +29,16 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
22
29
|
chatSDK.setAuthTokenProvider(async () => {
|
|
23
30
|
return token;
|
|
24
31
|
});
|
|
32
|
+
return true;
|
|
25
33
|
} else {
|
|
26
34
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
27
35
|
Event: TelemetryEvent.ReceivedNullOrEmptyToken
|
|
28
36
|
});
|
|
37
|
+
return false;
|
|
29
38
|
}
|
|
30
39
|
}
|
|
40
|
+
|
|
41
|
+
return false;
|
|
31
42
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
43
|
|
|
33
44
|
|
|
@@ -36,4 +47,4 @@ const removeAuthTokenProvider = chatSDK => {
|
|
|
36
47
|
chatSDK.authenticatedUserToken = null;
|
|
37
48
|
};
|
|
38
49
|
|
|
39
|
-
export { handleAuthentication, removeAuthTokenProvider };
|
|
50
|
+
export { getAuthClientFunction, handleAuthentication, removeAuthTokenProvider };
|
|
@@ -3,25 +3,14 @@ import React from "react";
|
|
|
3
3
|
import { decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { shouldShowFooter } from "../../../controller/componentController";
|
|
5
5
|
export const createFooter = (props, state) => {
|
|
6
|
-
var _props$
|
|
6
|
+
var _props$controlProps, _props$componentOverr;
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
hideDownloadTranscriptButton: true,
|
|
11
|
-
hideEmailTranscriptButton: true,
|
|
12
|
-
hideAudioNotificationButton: true
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const footer = !((_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideFooter) && shouldShowFooter(state) ? decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.footer) || /*#__PURE__*/React.createElement(FooterStateful, {
|
|
8
|
+
const hideFooterDisplay = !((_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideFooter) && shouldShowFooter(state) ? false : true;
|
|
9
|
+
const footer = decodeComponentString((_props$componentOverr = props.componentOverrides) === null || _props$componentOverr === void 0 ? void 0 : _props$componentOverr.footer) || /*#__PURE__*/React.createElement(FooterStateful, {
|
|
16
10
|
footerProps: props.footerProps,
|
|
17
11
|
downloadTranscriptProps: props.downloadTranscriptProps,
|
|
18
12
|
audioNotificationProps: props.audioNotificationProps,
|
|
19
|
-
hideFooterDisplay:
|
|
20
|
-
}) : decodeComponentString((_props$componentOverr2 = props.componentOverrides) === null || _props$componentOverr2 === void 0 ? void 0 : _props$componentOverr2.footer) || /*#__PURE__*/React.createElement(FooterStateful, {
|
|
21
|
-
footerProps: footerPropsHidden,
|
|
22
|
-
downloadTranscriptProps: props.downloadTranscriptProps,
|
|
23
|
-
audioNotificationProps: props.audioNotificationProps,
|
|
24
|
-
hideFooterDisplay: true
|
|
13
|
+
hideFooterDisplay: hideFooterDisplay
|
|
25
14
|
});
|
|
26
15
|
return footer;
|
|
27
16
|
};
|
|
@@ -2,6 +2,8 @@ import { Constants } from "../../../common/Constants";
|
|
|
2
2
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
3
3
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
4
4
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
5
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
6
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
5
7
|
|
|
6
8
|
const isInternetConnected = async () => {
|
|
7
9
|
try {
|
|
@@ -18,8 +20,14 @@ export const createInternetConnectionChangeHandler = async () => {
|
|
|
18
20
|
const connected = await isInternetConnected();
|
|
19
21
|
|
|
20
22
|
if (!connected) {
|
|
23
|
+
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
24
|
+
Event: TelemetryEvent.NetworkDisconnected
|
|
25
|
+
});
|
|
21
26
|
NotificationHandler.notifyError(NotificationScenarios.InternetConnection, defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
|
|
22
27
|
} else {
|
|
28
|
+
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
29
|
+
Event: TelemetryEvent.NetworkReconnected
|
|
30
|
+
});
|
|
23
31
|
NotificationHandler.notifySuccess(NotificationScenarios.InternetConnection, defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
|
|
24
32
|
}
|
|
25
33
|
}; // Checking connection status on online & offline events due to possible false positives
|
|
@@ -14,7 +14,7 @@ import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurv
|
|
|
14
14
|
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
15
15
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
16
16
|
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
17
|
-
import { handleAuthentication } from "./authHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
import { getAuthClientFunction, handleAuthentication } from "./authHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
18
|
|
|
19
19
|
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
20
|
|
|
@@ -93,6 +93,17 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
93
93
|
try {
|
|
94
94
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
95
95
|
|
|
96
|
+
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
97
|
+
|
|
98
|
+
if (getAuthToken && authClientFunction) {
|
|
99
|
+
// set auth token to chat sdk before start chat
|
|
100
|
+
const authSuccess = await handleAuthentication(chatSDK, chatConfig, getAuthToken);
|
|
101
|
+
|
|
102
|
+
if (!authSuccess) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
96
107
|
let isStartChatSuccessful = false; //Check if chat retrieved from cache
|
|
97
108
|
|
|
98
109
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
@@ -115,9 +126,7 @@ const initStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAda
|
|
|
115
126
|
}); // Set custom context params
|
|
116
127
|
|
|
117
128
|
setCustomContextParams(chatSDK);
|
|
118
|
-
optionalParams = Object.assign({}, params, optionalParams);
|
|
119
|
-
|
|
120
|
-
await handleAuthentication(chatSDK, chatConfig, getAuthToken);
|
|
129
|
+
optionalParams = Object.assign({}, params, optionalParams);
|
|
121
130
|
await chatSDK.startChat(optionalParams);
|
|
122
131
|
isStartChatSuccessful = true;
|
|
123
132
|
} catch (error) {
|