@microsoft/omnichannel-chat-widget 0.1.0-main.8e79cb8 → 0.1.0-main.99bac9c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/lib/cjs/common/Constants.js +16 -0
- 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 +33 -2
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +31 -18
- package/lib/cjs/common/utils.js +65 -6
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -3
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -5
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
- package/lib/cjs/components/footerstateful/FooterStateful.js +5 -13
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +10 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -7
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +65 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- 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/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +29 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +55 -23
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +20 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +153 -85
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +260 -95
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +98 -2
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +4 -1
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +14 -6
- package/lib/cjs/contexts/createReducer.js +18 -2
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/esm/common/Constants.js +16 -0
- 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 +33 -2
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +29 -13
- package/lib/esm/common/utils.js +49 -4
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +21 -6
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -5
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
- package/lib/esm/components/footerstateful/FooterStateful.js +5 -13
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -2
- package/lib/esm/components/headerstateful/HeaderStateful.js +14 -7
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +50 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- 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/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +29 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +56 -23
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +19 -5
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +56 -37
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +148 -86
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +254 -98
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +87 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +4 -1
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +12 -6
- package/lib/esm/contexts/createReducer.js +18 -2
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/types/common/Constants.d.ts +8 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- 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 +25 -4
- package/lib/types/common/utils.d.ts +7 -3
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +3 -2
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +5 -2
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/package.json +4 -3
|
@@ -77,10 +77,10 @@ const createReducer = () => {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
case _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
80
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID:
|
|
81
81
|
return { ...state,
|
|
82
82
|
appStates: { ...state.appStates,
|
|
83
|
-
|
|
83
|
+
previousElementIdOnFocusBeforeModalOpen: action.payload
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
|
|
@@ -235,6 +235,22 @@ const createReducer = () => {
|
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
237
|
|
|
238
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_SIZE:
|
|
239
|
+
return { ...state,
|
|
240
|
+
domainStates: { ...state.domainStates,
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
|
+
widgetSize: action.payload
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID:
|
|
247
|
+
return { ...state,
|
|
248
|
+
domainStates: { ...state.domainStates,
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
250
|
+
widgetInstanceId: action.payload
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
238
254
|
default:
|
|
239
255
|
return state;
|
|
240
256
|
}
|
|
@@ -8,7 +8,7 @@ exports.shouldShowWebChatContainer = exports.shouldShowReconnectChatPane = expor
|
|
|
8
8
|
var _ConversationState = require("../contexts/common/ConversationState");
|
|
9
9
|
|
|
10
10
|
const shouldShowChatButton = state => {
|
|
11
|
-
return state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed;
|
|
11
|
+
return (state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed) && state.appStates.skipChatButtonRendering == false; // Do not show chat button in case of popout
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.shouldShowChatButton = shouldShowChatButton;
|
|
@@ -44,7 +44,7 @@ const shouldShowWebChatContainer = state => {
|
|
|
44
44
|
exports.shouldShowWebChatContainer = shouldShowWebChatContainer;
|
|
45
45
|
|
|
46
46
|
const shouldShowLoadingPane = state => {
|
|
47
|
-
return !state.appStates.isMinimized &&
|
|
47
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
exports.shouldShowLoadingPane = shouldShowLoadingPane;
|
|
@@ -56,7 +56,7 @@ const shouldShowReconnectChatPane = state => {
|
|
|
56
56
|
exports.shouldShowReconnectChatPane = shouldShowReconnectChatPane;
|
|
57
57
|
|
|
58
58
|
const shouldShowPostChatLoadingPane = state => {
|
|
59
|
-
return !state.appStates.isMinimized && state.appStates.
|
|
59
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
exports.shouldShowPostChatLoadingPane = shouldShowPostChatLoadingPane;
|
|
@@ -4,6 +4,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
4
4
|
|
|
5
5
|
export class Constants {}
|
|
6
6
|
|
|
7
|
+
_defineProperty(Constants, "magicCodeBroadcastChannel", "MagicCodeChannel");
|
|
8
|
+
|
|
9
|
+
_defineProperty(Constants, "magicCodeResponseBroadcastChannel", "MagicCodeResponseChannel");
|
|
10
|
+
|
|
7
11
|
_defineProperty(Constants, "systemMessageTag", "system");
|
|
8
12
|
|
|
9
13
|
_defineProperty(Constants, "userMessageTag", "user");
|
|
@@ -70,6 +74,14 @@ _defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
|
|
|
70
74
|
|
|
71
75
|
_defineProperty(Constants, "message", "message");
|
|
72
76
|
|
|
77
|
+
_defineProperty(Constants, "hiddenTag", "Hidden");
|
|
78
|
+
|
|
79
|
+
_defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
|
|
80
|
+
|
|
81
|
+
_defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
|
|
82
|
+
|
|
83
|
+
_defineProperty(Constants, "publicMessageTag", "public");
|
|
84
|
+
|
|
73
85
|
_defineProperty(Constants, "supportedAdaptiveCardContentTypes", ["application/vnd.microsoft.card.adaptive", "application/vnd.microsoft.card.audio", "application/vnd.microsoft.card.hero", "application/vnd.microsoft.card.receipt", "application/vnd.microsoft.card.thumbnail", "application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"]);
|
|
74
86
|
|
|
75
87
|
_defineProperty(Constants, "maxUploadFileSize", "500000");
|
|
@@ -146,6 +158,10 @@ _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect
|
|
|
146
158
|
|
|
147
159
|
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
148
160
|
|
|
161
|
+
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
162
|
+
|
|
163
|
+
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
164
|
+
|
|
149
165
|
export const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
150
166
|
export class HtmlIdNames {}
|
|
151
167
|
|
|
@@ -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
|
+
};
|
|
@@ -26,19 +26,29 @@ export let BroadcastEvent; // Events being logged
|
|
|
26
26
|
|
|
27
27
|
(function (BroadcastEvent) {
|
|
28
28
|
BroadcastEvent["LoadPostChatSurvey"] = "LoadPostChatSurvey";
|
|
29
|
-
BroadcastEvent["
|
|
29
|
+
BroadcastEvent["ChatEnded"] = "ChatEnded";
|
|
30
30
|
BroadcastEvent["NewMessageNotification"] = "NewMessageNotification";
|
|
31
31
|
BroadcastEvent["UnreadMessageCount"] = "UnreadMessageCount";
|
|
32
|
+
BroadcastEvent["StartProactiveChat"] = "StartProactiveChat";
|
|
32
33
|
BroadcastEvent["ProactiveChatStartChat"] = "ProactiveChatStartChat";
|
|
33
34
|
BroadcastEvent["ProactiveChatStartPopoutChat"] = "ProactiveChatStartPopoutChat";
|
|
35
|
+
BroadcastEvent["ProactiveChatIsInPopoutMode"] = "ProactiveChatIsInPopoutMode";
|
|
36
|
+
BroadcastEvent["ResetProactiveChatParams"] = "ResetProactiveChatParams";
|
|
34
37
|
BroadcastEvent["InvalidAdaptiveCardFormat"] = "InvalidAdaptiveCardFormat";
|
|
35
38
|
BroadcastEvent["NewMessageSent"] = "NewMessageSent";
|
|
36
39
|
BroadcastEvent["NewMessageReceived"] = "NewMessageReceived";
|
|
37
40
|
BroadcastEvent["RedirectPageRequest"] = "RedirectPageRequest";
|
|
41
|
+
BroadcastEvent["StartChat"] = "StartChat";
|
|
38
42
|
BroadcastEvent["StartChatSkippingChatButtonRendering"] = "StartChatSkippingChatButtonRendering";
|
|
39
43
|
BroadcastEvent["StartUnauthenticatedReconnectChat"] = "StartUnauthenticatedReconnectChat";
|
|
44
|
+
BroadcastEvent["InitiateEndChat"] = "InitiateEndChat";
|
|
40
45
|
BroadcastEvent["SetCustomContext"] = "SetCustomContext";
|
|
41
46
|
BroadcastEvent["ChatRetrievedFromCache"] = "ChatRetrievedFromCache";
|
|
47
|
+
BroadcastEvent["MaximizeChat"] = "MaximizeChat";
|
|
48
|
+
BroadcastEvent["ChatInitiated"] = "ChatInitiated";
|
|
49
|
+
BroadcastEvent["CloseChat"] = "CloseChat";
|
|
50
|
+
BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
|
|
51
|
+
BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
|
|
42
52
|
})(BroadcastEvent || (BroadcastEvent = {}));
|
|
43
53
|
|
|
44
54
|
export let TelemetryEvent;
|
|
@@ -79,6 +89,8 @@ export let TelemetryEvent;
|
|
|
79
89
|
TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
|
|
80
90
|
TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
|
|
81
91
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
92
|
+
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
93
|
+
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
82
94
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
83
95
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
84
96
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -90,8 +102,9 @@ export let TelemetryEvent;
|
|
|
90
102
|
TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
|
|
91
103
|
TelemetryEvent["StartChatSDKCall"] = "StartChatCall";
|
|
92
104
|
TelemetryEvent["StartChatEventRecevied"] = "StartChatEventReceived";
|
|
93
|
-
TelemetryEvent["EndChatSDKCall"] = "
|
|
105
|
+
TelemetryEvent["EndChatSDKCall"] = "EndChatSDKCall";
|
|
94
106
|
TelemetryEvent["EndChatEventReceived"] = "EndChatEventReceived";
|
|
107
|
+
TelemetryEvent["WindowClosed"] = "WindowClosed";
|
|
95
108
|
TelemetryEvent["OnNewMessageFailed"] = "OnNewMessageFailed";
|
|
96
109
|
TelemetryEvent["OnNewMessageAudioNotificationFailed"] = "OnNewMessageAudioNotificationFailed";
|
|
97
110
|
TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
|
|
@@ -116,6 +129,12 @@ export let TelemetryEvent;
|
|
|
116
129
|
TelemetryEvent["EmailTranscriptButtonClicked"] = "EmailTranscriptButtonClicked";
|
|
117
130
|
TelemetryEvent["EmailTranscriptCancelButtonClicked"] = "EmailTranscriptCancelButtonClicked";
|
|
118
131
|
TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
|
|
132
|
+
TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
|
|
133
|
+
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
134
|
+
TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
|
|
135
|
+
TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
|
|
136
|
+
TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
|
|
137
|
+
TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
|
|
119
138
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
120
139
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
121
140
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
@@ -142,12 +161,18 @@ export let TelemetryEvent;
|
|
|
142
161
|
TelemetryEvent["MessageSent"] = "MessageSent";
|
|
143
162
|
TelemetryEvent["MessageReceived"] = "MessageReceived";
|
|
144
163
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
164
|
+
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
165
|
+
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
145
166
|
})(TelemetryEvent || (TelemetryEvent = {}));
|
|
146
167
|
|
|
147
168
|
export class TelemetryConstants {
|
|
148
169
|
static map(eventTypeOrScenarioType) {
|
|
149
170
|
switch (eventTypeOrScenarioType) {
|
|
150
171
|
case TelemetryEvent.ParseAdaptiveCardFailed:
|
|
172
|
+
case TelemetryEvent.ReceivedNullOrEmptyToken:
|
|
173
|
+
case TelemetryEvent.GetAuthTokenCalled:
|
|
174
|
+
case TelemetryEvent.SuppressBotMagicCodeSucceeded:
|
|
175
|
+
case TelemetryEvent.SuppressBotMagicCodeFailed:
|
|
151
176
|
return ScenarioType.CONFIG_VALIDATION;
|
|
152
177
|
|
|
153
178
|
case TelemetryEvent.WebChatLoaded:
|
|
@@ -187,6 +212,11 @@ export class TelemetryConstants {
|
|
|
187
212
|
case TelemetryEvent.MessageSent:
|
|
188
213
|
case TelemetryEvent.MessageReceived:
|
|
189
214
|
case TelemetryEvent.CustomContextReceived:
|
|
215
|
+
case TelemetryEvent.BrowserUnloadEventStarted:
|
|
216
|
+
case TelemetryEvent.NetworkDisconnected:
|
|
217
|
+
case TelemetryEvent.NetworkReconnected:
|
|
218
|
+
case TelemetryEvent.AudioToggleButtonClicked:
|
|
219
|
+
case TelemetryEvent.EmailTranscriptCancelButtonClicked:
|
|
190
220
|
return ScenarioType.ACTIONS;
|
|
191
221
|
|
|
192
222
|
case TelemetryEvent.StartChatSDKCall:
|
|
@@ -203,6 +233,7 @@ export class TelemetryConstants {
|
|
|
203
233
|
case TelemetryEvent.EndChatSDKCallFailed:
|
|
204
234
|
case TelemetryEvent.PostChatContextCallFailed:
|
|
205
235
|
case TelemetryEvent.PostChatContextCallSucceed:
|
|
236
|
+
case TelemetryEvent.GetConversationDetailsException:
|
|
206
237
|
return ScenarioType.SDK;
|
|
207
238
|
|
|
208
239
|
case TelemetryEvent.VideoCallAcceptButtonClick:
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getDomain, isNullOrEmptyString, isNullOrUndefined } from "../../utils";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { AWTPiiKind } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
|
|
2
|
+
import { AWTLogManager } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/webjs/AriaSDK";
|
|
3
|
+
import { AWTCustomerContentKind, AWTPiiKind, AWTPropertyType } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
|
|
5
4
|
import { Constants, AriaTelemetryConstants, EnvironmentVersion } from "../../Constants";
|
|
6
5
|
import { TelemetryManager } from "../TelemetryManager";
|
|
7
6
|
export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, collectiorUriForTelemetry, ariaTelemetryApplicationName) => {
|
|
@@ -49,18 +48,35 @@ export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, colle
|
|
|
49
48
|
const ariaLogger = {
|
|
50
49
|
log: (logLevel, telemetryInput) => {
|
|
51
50
|
try {
|
|
52
|
-
|
|
53
|
-
const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.telemetryInfo;
|
|
54
|
-
const eventProperties = new AWTEventProperties();
|
|
55
|
-
eventProperties.setName(telemetryInput.scenarioType);
|
|
51
|
+
var _telemetryInput$telem;
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
53
|
+
const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$telem = telemetryInput.telemetryInfo) === null || _telemetryInput$telem === void 0 ? void 0 : _telemetryInput$telem.telemetryInfo; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
|
|
55
|
+
const eventProperties = {
|
|
56
|
+
name: telemetryInput.scenarioType,
|
|
57
|
+
properties: {}
|
|
58
|
+
};
|
|
62
59
|
|
|
63
|
-
|
|
60
|
+
if (telemetryInfo) {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
+
Object.keys(telemetryInfo).forEach((key, index) => {
|
|
63
|
+
if (!isNullOrUndefined(telemetryInfo[key]) && !isNullOrEmptyString(telemetryInfo[key])) {
|
|
64
|
+
const property = {
|
|
65
|
+
value: typeof telemetryInfo[key] === "object" ? JSON.stringify(telemetryInfo[key]) : telemetryInfo[key],
|
|
66
|
+
type: typeof telemetryInfo[key] === "number" ? AWTPropertyType.Double : AWTPropertyType.String,
|
|
67
|
+
pii: AWTPiiKind.NotSet,
|
|
68
|
+
cc: AWTCustomerContentKind.NotSet
|
|
69
|
+
};
|
|
70
|
+
eventProperties.properties[key] = property;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const nameProperty = {
|
|
74
|
+
value: Constants.LiveChatWidget,
|
|
75
|
+
type: AWTPropertyType.String,
|
|
76
|
+
pii: AWTPiiKind.GenericData,
|
|
77
|
+
cc: AWTCustomerContentKind.NotSet
|
|
78
|
+
};
|
|
79
|
+
eventProperties.properties[ariaTelemetryApplicationName] = nameProperty;
|
|
64
80
|
}
|
|
65
81
|
|
|
66
82
|
logger() ? logger().logEvent(eventProperties) : console.log("Unable to initialize aria logger");
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
|
|
2
|
+
import { DataStoreManager } from "./contextDataStore/DataStoreManager";
|
|
2
3
|
import { KeyCodes } from "./KeyCodes";
|
|
3
4
|
import { BroadcastEvent } from "./telemetry/TelemetryConstants";
|
|
5
|
+
import { Md5 } from "md5-typescript";
|
|
4
6
|
|
|
5
7
|
const getElementBySelector = selector => {
|
|
6
8
|
let element;
|
|
@@ -289,9 +291,52 @@ export const getDomain = hostValue => {
|
|
|
289
291
|
|
|
290
292
|
return AriaTelemetryConstants.Public;
|
|
291
293
|
};
|
|
292
|
-
export const getWidgetCacheId = (orgId, widgetId) => {
|
|
293
|
-
|
|
294
|
+
export const getWidgetCacheId = (orgId, widgetId, widgetInstanceId) => {
|
|
295
|
+
const widgetCacheId = `${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
296
|
+
return Md5.init(widgetCacheId);
|
|
294
297
|
};
|
|
295
|
-
export const getWidgetEndChatEventName = (orgId, widgetId) => {
|
|
296
|
-
|
|
298
|
+
export const getWidgetEndChatEventName = (orgId, widgetId, widgetInstanceId) => {
|
|
299
|
+
if (!isNullOrEmptyString(widgetInstanceId)) {
|
|
300
|
+
return `${BroadcastEvent.ChatEnded}_${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return `${BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
|
|
304
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
305
|
+
|
|
306
|
+
export const getStateFromCache = (orgId, widgetId, widgetInstanceId) => {
|
|
307
|
+
// Getting updated state from cache
|
|
308
|
+
try {
|
|
309
|
+
if (DataStoreManager.clientDataStore) {
|
|
310
|
+
var _DataStoreManager$cli;
|
|
311
|
+
|
|
312
|
+
const widgetStateEventName = getWidgetCacheId(orgId, widgetId, widgetInstanceId);
|
|
313
|
+
const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
314
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
315
|
+
return persistedState;
|
|
316
|
+
} else {
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
} catch (error) {
|
|
320
|
+
console.log(error);
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
324
|
+
|
|
325
|
+
export const isUndefinedOrEmpty = object => {
|
|
326
|
+
if (object) {
|
|
327
|
+
if (Object.keys(object).length === 0) {
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return false;
|
|
332
|
+
} else {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
336
|
+
|
|
337
|
+
export const addDelayInMs = ms => {
|
|
338
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
339
|
+
};
|
|
340
|
+
export const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
|
|
341
|
+
return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
|
|
297
342
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import React, { useEffect, useState } from "react";
|
|
3
|
-
import { ChatButton } from "@microsoft/omnichannel-chat-components";
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { BroadcastService, ChatButton } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { Constants } from "../../common/Constants";
|
|
5
5
|
import { setFocusOnElement } from "../../common/utils";
|
|
6
6
|
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
@@ -10,7 +10,7 @@ import { TelemetryTimers } from "../../common/telemetry/TelemetryManager";
|
|
|
10
10
|
import { defaultOutOfOfficeChatButtonStyleProps } from "./common/styleProps/defaultOutOfOfficeChatButtonStyleProps";
|
|
11
11
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
12
12
|
export const ChatButtonStateful = props => {
|
|
13
|
-
var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP;
|
|
13
|
+
var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP, _props$buttonProps, _props$buttonProps$co, _props$buttonProps2, _props$buttonProps2$c, _props$buttonProps3, _props$buttonProps3$c;
|
|
14
14
|
|
|
15
15
|
const [state, dispatch] = useChatContextStore();
|
|
16
16
|
const {
|
|
@@ -20,6 +20,7 @@ export const ChatButtonStateful = props => {
|
|
|
20
20
|
} = props; //Setting OutOfOperatingHours Flag
|
|
21
21
|
|
|
22
22
|
const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_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.OutOfOperatingHours) === "True");
|
|
23
|
+
const proactiveChatInNewWindow = useRef(state.appStates.proactiveChatStates.proactiveChatInNewWindow);
|
|
23
24
|
const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
24
25
|
const controlProps = {
|
|
25
26
|
id: "oc-lcw-chat-button",
|
|
@@ -27,13 +28,18 @@ export const ChatButtonStateful = props => {
|
|
|
27
28
|
titleText: "Let's Chat!",
|
|
28
29
|
subtitleText: "We're online.",
|
|
29
30
|
hideNotificationBubble: (buttonProps === null || buttonProps === void 0 ? void 0 : (_buttonProps$controlP = buttonProps.controlProps) === null || _buttonProps$controlP === void 0 ? void 0 : _buttonProps$controlP.hideNotificationBubble) === true || state.appStates.isMinimized === false,
|
|
30
|
-
unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > Constants.maximumUnreadMessageCount ?
|
|
31
|
+
unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > Constants.maximumUnreadMessageCount ? (_props$buttonProps = props.buttonProps) === null || _props$buttonProps === void 0 ? void 0 : (_props$buttonProps$co = _props$buttonProps.controlProps) === null || _props$buttonProps$co === void 0 ? void 0 : _props$buttonProps$co.largeUnreadMessageString : state.appStates.unreadMessageCount.toString() : "0",
|
|
31
32
|
onClick: async () => {
|
|
32
33
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
33
34
|
Event: TelemetryEvent.LCWChatButtonClicked
|
|
34
35
|
});
|
|
35
36
|
|
|
36
|
-
if (
|
|
37
|
+
if (proactiveChatInNewWindow.current) {
|
|
38
|
+
const proactiveChatIsInPopoutModeEvent = {
|
|
39
|
+
eventName: BroadcastEvent.ProactiveChatIsInPopoutMode
|
|
40
|
+
};
|
|
41
|
+
BroadcastService.postMessage(proactiveChatIsInPopoutModeEvent);
|
|
42
|
+
} else if (state.appStates.isMinimized) {
|
|
37
43
|
dispatch({
|
|
38
44
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
39
45
|
payload: false
|
|
@@ -42,6 +48,7 @@ export const ChatButtonStateful = props => {
|
|
|
42
48
|
await startChat();
|
|
43
49
|
}
|
|
44
50
|
},
|
|
51
|
+
unreadMessageString: (_props$buttonProps2 = props.buttonProps) === null || _props$buttonProps2 === void 0 ? void 0 : (_props$buttonProps2$c = _props$buttonProps2.controlProps) === null || _props$buttonProps2$c === void 0 ? void 0 : _props$buttonProps2$c.unreadMessageString,
|
|
45
52
|
...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps)
|
|
46
53
|
};
|
|
47
54
|
const outOfOfficeControlProps = {
|
|
@@ -50,6 +57,10 @@ export const ChatButtonStateful = props => {
|
|
|
50
57
|
titleText: "We're Offline",
|
|
51
58
|
subtitleText: "No agents available",
|
|
52
59
|
onClick: async () => {
|
|
60
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
61
|
+
Event: TelemetryEvent.LCWChatButtonClicked
|
|
62
|
+
});
|
|
63
|
+
|
|
53
64
|
if (state.appStates.isMinimized) {
|
|
54
65
|
dispatch({
|
|
55
66
|
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
@@ -62,6 +73,7 @@ export const ChatButtonStateful = props => {
|
|
|
62
73
|
});
|
|
63
74
|
}
|
|
64
75
|
},
|
|
76
|
+
unreadMessageString: (_props$buttonProps3 = props.buttonProps) === null || _props$buttonProps3 === void 0 ? void 0 : (_props$buttonProps3$c = _props$buttonProps3.controlProps) === null || _props$buttonProps3$c === void 0 ? void 0 : _props$buttonProps3$c.unreadMessageString,
|
|
65
77
|
...(outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.controlProps)
|
|
66
78
|
};
|
|
67
79
|
useEffect(() => {
|
|
@@ -83,6 +95,9 @@ export const ChatButtonStateful = props => {
|
|
|
83
95
|
});
|
|
84
96
|
}
|
|
85
97
|
}, []);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
proactiveChatInNewWindow.current = state.appStates.proactiveChatStates.proactiveChatInNewWindow;
|
|
100
|
+
}, [state.appStates.proactiveChatStates.proactiveChatInNewWindow]);
|
|
86
101
|
return /*#__PURE__*/React.createElement(ChatButton, {
|
|
87
102
|
componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
|
|
88
103
|
controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
|
|
@@ -17,7 +17,6 @@ export const ConfirmationPaneStateful = props => {
|
|
|
17
17
|
const {
|
|
18
18
|
prepareEndChat
|
|
19
19
|
} = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
20
|
|
|
22
21
|
const [adapter] = useChatAdapterStore();
|
|
23
22
|
const controlProps = {
|
|
@@ -55,12 +54,12 @@ export const ConfirmationPaneStateful = props => {
|
|
|
55
54
|
type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
|
|
56
55
|
payload: false
|
|
57
56
|
});
|
|
58
|
-
const
|
|
57
|
+
const previousFocusedElementId = state.appStates.previousElementIdOnFocusBeforeModalOpen;
|
|
59
58
|
|
|
60
|
-
if (
|
|
61
|
-
setFocusOnElement(
|
|
59
|
+
if (previousFocusedElementId) {
|
|
60
|
+
setFocusOnElement("#" + previousFocusedElementId);
|
|
62
61
|
dispatch({
|
|
63
|
-
type: LiveChatWidgetActionType.
|
|
62
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
64
63
|
payload: null
|
|
65
64
|
});
|
|
66
65
|
} else {
|
|
@@ -25,16 +25,16 @@ export const EmailTranscriptPaneStateful = props => {
|
|
|
25
25
|
type: LiveChatWidgetActionType.SET_SHOW_EMAIL_TRANSCRIPT_PANE,
|
|
26
26
|
payload: false
|
|
27
27
|
});
|
|
28
|
-
const
|
|
28
|
+
const previousFocusedElementId = state.appStates.previousElementIdOnFocusBeforeModalOpen;
|
|
29
29
|
|
|
30
|
-
if (
|
|
31
|
-
setFocusOnElement(
|
|
30
|
+
if (previousFocusedElementId) {
|
|
31
|
+
setFocusOnElement("#" + previousFocusedElementId);
|
|
32
32
|
} else {
|
|
33
33
|
setFocusOnSendBox();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
dispatch({
|
|
37
|
-
type: LiveChatWidgetActionType.
|
|
37
|
+
type: LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT_ID,
|
|
38
38
|
payload: null
|
|
39
39
|
});
|
|
40
40
|
setTabIndices(elements, initialTabIndexMap, true);
|