@microsoft/omnichannel-chat-widget 1.8.3 → 1.8.4-main.424a580
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/common/Constants.js +5 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
- package/lib/cjs/common/telemetry/AppInsightsEvents.js +4 -5
- package/lib/cjs/common/telemetry/TelemetryConstants.js +44 -2
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +26 -10
- package/lib/cjs/common/utils/SecureEventBus.js +307 -0
- package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +20 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +287 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +7 -1
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -7
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
- package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +22 -3
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +29 -2
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +36 -5
- package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +47 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +50 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
- package/lib/esm/common/Constants.js +5 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
- package/lib/esm/common/telemetry/AppInsightsEvents.js +4 -5
- package/lib/esm/common/telemetry/TelemetryConstants.js +42 -1
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +27 -11
- package/lib/esm/common/utils/SecureEventBus.js +328 -0
- package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +20 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +280 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +7 -1
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +16 -7
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +7 -3
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
- package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +23 -4
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -4
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +39 -5
- package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
- package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +39 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +48 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/esm/plugins/newMessageEventHandler.js +4 -1
- package/lib/types/common/Constants.d.ts +4 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +39 -2
- package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
- package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
- package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +12 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +6 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +3 -3
|
@@ -45,6 +45,10 @@ _defineProperty(Constants, "botParticipantTypeTag", "Bot");
|
|
|
45
45
|
_defineProperty(Constants, "channelIdKey", "ChannelId-");
|
|
46
46
|
_defineProperty(Constants, "ChannelId", "lcw");
|
|
47
47
|
_defineProperty(Constants, "CustomerTag", "FromCustomer");
|
|
48
|
+
// LCW only tags (Only applicable on client-side for additional processing, not recognized by service)
|
|
49
|
+
_defineProperty(Constants, "persistentChatHistoryMessageTag", "PersistentChatHistory");
|
|
50
|
+
_defineProperty(Constants, "persistentChatHistoryMessagePullTriggerTag", "PersistentChatHistoryMessagePullTrigger");
|
|
51
|
+
_defineProperty(Constants, "conversationDividerTag", "ConversationDivider");
|
|
48
52
|
// gifUploadMiddleware
|
|
49
53
|
_defineProperty(Constants, "GifContentType", "image/gif");
|
|
50
54
|
// htmlPlayerMiddleware
|
|
@@ -64,6 +68,7 @@ _defineProperty(Constants, "queuePositionMessageTag", "queueposition");
|
|
|
64
68
|
_defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
|
|
65
69
|
_defineProperty(Constants, "message", "message");
|
|
66
70
|
_defineProperty(Constants, "hiddenTag", "Hidden");
|
|
71
|
+
_defineProperty(Constants, "typing", "typing");
|
|
67
72
|
// messageTimestampMiddleware
|
|
68
73
|
_defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
|
|
69
74
|
_defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
|
|
@@ -487,6 +487,12 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
487
487
|
reconnectableChatsParams.authenticatedUserToken = this.token;
|
|
488
488
|
return this.validateAndExecuteCall("getReconnectableChats", () => this.chatSDK.OCClient.getReconnectableChats(reconnectableChatsParams));
|
|
489
489
|
}
|
|
490
|
+
}, {
|
|
491
|
+
key: "fetchPersistentConversationHistory",
|
|
492
|
+
value: async function fetchPersistentConversationHistory() {
|
|
493
|
+
let getPersistentChatHistoryOptionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
494
|
+
return this.validateAndExecuteCall("getPersistentChatHistory", () => this.chatSDK.getPersistentChatHistory(getPersistentChatHistoryOptionalParams));
|
|
495
|
+
}
|
|
490
496
|
}]);
|
|
491
497
|
return FacadeChatSDK;
|
|
492
498
|
}();
|
|
@@ -6,9 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.AppInsightsEventMapping = void 0;
|
|
7
7
|
const AppInsightsEventMapping = {
|
|
8
8
|
"LCWChatButtonClicked": "LCWChatButtonActionStarted",
|
|
9
|
-
"WidgetLoadStarted": "WidgetStartChatStarted",
|
|
10
|
-
"WidgetLoadComplete": "WidgetStartChatCompleted",
|
|
11
|
-
"WidgetLoadFailed": "WidgetStartChatFailed",
|
|
12
9
|
"PrechatSubmitted": "PrechatSubmitCompleted",
|
|
13
10
|
"StartChatEventRecevied": "StartChatEventReceivedCompleted",
|
|
14
11
|
"EndChatEventReceived": "EndChatEventReceivedCompleted",
|
|
@@ -24,8 +21,10 @@ const AppInsightsEventMapping = {
|
|
|
24
21
|
"MessageSent": "MessageSentCompleted",
|
|
25
22
|
"MessageReceived": "MessageReceivedCompleted",
|
|
26
23
|
"SystemMessageReceived": "SystemMessageReceivedCompleted",
|
|
27
|
-
"RehydrateMessageReceived": "
|
|
24
|
+
"RehydrateMessageReceived": "ChatHistoryMessageReceivedCompleted",
|
|
28
25
|
"CustomContextReceived": "CustomContextReceivedCompleted",
|
|
29
|
-
"
|
|
26
|
+
"NewTokenValidationStarted": "AuthTokenValidationStarted",
|
|
27
|
+
"NewTokenValidationCompleted": "AuthTokenValidationCompleted",
|
|
28
|
+
"NewTokenValidationFailed": "AuthTokenValidationFailed"
|
|
30
29
|
};
|
|
31
30
|
exports.AppInsightsEventMapping = AppInsightsEventMapping;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TelemetryEvent = exports.TelemetryConstants = exports.ScenarioType = exports.LogLevel = exports.BroadcastEvent = void 0;
|
|
6
|
+
exports.TelemetryEvent = exports.TelemetryConstants = exports.ScenarioType = exports.LogLevel = exports.ConversationStage = exports.BroadcastEvent = void 0;
|
|
7
7
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
8
|
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); } }
|
|
9
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -73,10 +73,12 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
73
73
|
BroadcastEvent["OnWidgetError"] = "OnWidgetError";
|
|
74
74
|
BroadcastEvent["FMLTrackingCompletedAck"] = "FMLTrackingCompletedAck";
|
|
75
75
|
BroadcastEvent["FMLTrackingCompleted"] = "FMLTrackingCompleted";
|
|
76
|
+
BroadcastEvent["PersistentConversationReset"] = "PersistentConversationReset";
|
|
76
77
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
77
78
|
let TelemetryEvent;
|
|
78
79
|
exports.TelemetryEvent = TelemetryEvent;
|
|
79
80
|
(function (TelemetryEvent) {
|
|
81
|
+
TelemetryEvent["FetchPersistentChatHistoryFailed"] = "FetchPersistentChatHistoryFailed";
|
|
80
82
|
TelemetryEvent["CallAdded"] = "CallAdded";
|
|
81
83
|
TelemetryEvent["LocalVideoStreamAdded"] = "LocalVideoStreamAdded";
|
|
82
84
|
TelemetryEvent["LocalVideoStreamRemoved"] = "LocalVideoStreamRemoved";
|
|
@@ -122,6 +124,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
122
124
|
TelemetryEvent["EndChatFailed"] = "EndChatFailed";
|
|
123
125
|
TelemetryEvent["SettingCustomContext"] = "SettingCustomContext";
|
|
124
126
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
127
|
+
TelemetryEvent["PersistentChatHistoryEnabled"] = "PersistentChatHistoryEnabled";
|
|
125
128
|
TelemetryEvent["LCWChatButtonActionCompleted"] = "LCWChatButtonActionCompleted";
|
|
126
129
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
127
130
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -286,8 +289,37 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
286
289
|
TelemetryEvent["UXCitationPaneCompleted"] = "UXCitationPaneCompleted";
|
|
287
290
|
TelemetryEvent["UXLiveChatWidgetStart"] = "UXLiveChatWidgetStart";
|
|
288
291
|
TelemetryEvent["UXLiveChatWidgetCompleted"] = "UXLiveChatWidgetCompleted";
|
|
292
|
+
TelemetryEvent["UXPostChatPaneStarted"] = "UXPostChatPaneStarted";
|
|
293
|
+
TelemetryEvent["UXPostChatPaneCompleted"] = "UXPostChatPaneCompleted";
|
|
289
294
|
TelemetryEvent["AppInsightsInitialized"] = "AppInsightsInitialized";
|
|
290
295
|
TelemetryEvent["AppInsightsInitFailed"] = "AppInsightsInitFailed";
|
|
296
|
+
TelemetryEvent["ConvertPersistentChatHistoryMessageToActivityFailed"] = "ConvertPersistentChatHistoryMessageToActivityFailed";
|
|
297
|
+
TelemetryEvent["UXLCWPersistentChatHistoryInitialized"] = "UXLCWPersistentChatHistoryInitialized";
|
|
298
|
+
TelemetryEvent["LCWPersistentChatHistoryFetchStarted"] = "LCWPersistentChatHistoryFetchStarted";
|
|
299
|
+
TelemetryEvent["LCWPersistentChatHistoryFetchCompleted"] = "LCWPersistentChatHistoryFetchCompleted";
|
|
300
|
+
TelemetryEvent["LCWPersistentChatHistoryFetchFailed"] = "LCWPersistentChatHistoryFetchFailed";
|
|
301
|
+
TelemetryEvent["LCWWebChatStorePollingStarted"] = "LCWWebChatStorePollingStarted";
|
|
302
|
+
TelemetryEvent["LCWWebChatStoreReady"] = "LCWWebChatStoreReady";
|
|
303
|
+
TelemetryEvent["LCWWebChatConnected"] = "LCWWebChatConnected";
|
|
304
|
+
TelemetryEvent["LCWWebChatDisconnected"] = "LCWWebChatDisconnected";
|
|
305
|
+
TelemetryEvent["LCWWebChatConnectionCheckFailed"] = "LCWWebChatConnectionCheckFailed";
|
|
306
|
+
TelemetryEvent["LCWPersistentConversationHandlerInitialized"] = "LCWPersistentConversationHandlerInitialized";
|
|
307
|
+
TelemetryEvent["LCWPersistentHistoryPullBlocked"] = "LCWPersistentHistoryPullBlocked";
|
|
308
|
+
TelemetryEvent["LCWPersistentHistoryPullCompleted"] = "LCWPersistentHistoryPullCompleted";
|
|
309
|
+
TelemetryEvent["LCWLazyLoadInitializationStarted"] = "LCWLazyLoadInitializationStarted";
|
|
310
|
+
TelemetryEvent["LCWLazyLoadContainerNotFound"] = "LCWLazyLoadContainerNotFound";
|
|
311
|
+
TelemetryEvent["LCWLazyLoadInitializationCompleted"] = "LCWLazyLoadInitializationCompleted";
|
|
312
|
+
TelemetryEvent["LCWLazyLoadSessionMetrics"] = "LCWLazyLoadSessionMetrics";
|
|
313
|
+
TelemetryEvent["LCWLazyLoadTargetElementNotFound"] = "LCWLazyLoadTargetElementNotFound";
|
|
314
|
+
TelemetryEvent["LCWLazyLoadScrollFailed"] = "LCWLazyLoadScrollFailed";
|
|
315
|
+
TelemetryEvent["LCWLazyLoadActivityMounted"] = "LCWLazyLoadActivityMounted";
|
|
316
|
+
TelemetryEvent["LCWLazyLoadReset"] = "LCWLazyLoadReset";
|
|
317
|
+
TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
|
|
318
|
+
TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
|
|
319
|
+
TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
|
|
320
|
+
TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
|
|
321
|
+
TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
|
|
322
|
+
TelemetryEvent["StartChatComplete"] = "StartChatComplete";
|
|
291
323
|
})(TelemetryEvent || (exports.TelemetryEvent = TelemetryEvent = {}));
|
|
292
324
|
let TelemetryConstants = /*#__PURE__*/function () {
|
|
293
325
|
function TelemetryConstants() {
|
|
@@ -355,6 +387,9 @@ let TelemetryConstants = /*#__PURE__*/function () {
|
|
|
355
387
|
case TelemetryEvent.PostChatWorkflowFromAgent:
|
|
356
388
|
case TelemetryEvent.PostChatWorkflowFromBot:
|
|
357
389
|
case TelemetryEvent.AppStatesException:
|
|
390
|
+
case TelemetryEvent.SecureEventBusUnauthorizedDispatch:
|
|
391
|
+
case TelemetryEvent.SecureEventBusListenerError:
|
|
392
|
+
case TelemetryEvent.SecureEventBusDispatchError:
|
|
358
393
|
return ScenarioType.ACTIONS;
|
|
359
394
|
case TelemetryEvent.StartChatSDKCall:
|
|
360
395
|
case TelemetryEvent.StartChatEventReceived:
|
|
@@ -415,4 +450,11 @@ let TelemetryConstants = /*#__PURE__*/function () {
|
|
|
415
450
|
}]);
|
|
416
451
|
return TelemetryConstants;
|
|
417
452
|
}();
|
|
418
|
-
exports.TelemetryConstants = TelemetryConstants;
|
|
453
|
+
exports.TelemetryConstants = TelemetryConstants;
|
|
454
|
+
let ConversationStage;
|
|
455
|
+
exports.ConversationStage = ConversationStage;
|
|
456
|
+
(function (ConversationStage) {
|
|
457
|
+
ConversationStage["Initialization"] = "Initialization";
|
|
458
|
+
ConversationStage["CSREngagement"] = "CSR Engagement";
|
|
459
|
+
ConversationStage["ConversationEnd"] = "Conversation End";
|
|
460
|
+
})(ConversationStage || (exports.ConversationStage = ConversationStage = {}));
|
|
@@ -14,15 +14,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
14
14
|
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; }
|
|
15
15
|
var AllowedKeys;
|
|
16
16
|
(function (AllowedKeys) {
|
|
17
|
-
AllowedKeys["
|
|
17
|
+
AllowedKeys["OrganizationId"] = "OrganizationId";
|
|
18
|
+
AllowedKeys["ConversationId"] = "LiveWorkItemId";
|
|
19
|
+
AllowedKeys["ElapsedTimeInMilliseconds"] = "Duration";
|
|
18
20
|
AllowedKeys["Description"] = "Description";
|
|
19
|
-
AllowedKeys["
|
|
20
|
-
AllowedKeys["ChannelId"] = "ChannelId";
|
|
21
|
+
AllowedKeys["ChannelId"] = "ChannelType";
|
|
21
22
|
AllowedKeys["LCWRuntimeId"] = "ClientSessionId";
|
|
22
|
-
AllowedKeys["ConversationId"] = "LiveWorkItemId";
|
|
23
|
-
AllowedKeys["ChatId"] = "ChatThreadId";
|
|
24
|
-
AllowedKeys["OrganizationId"] = "OrganizationId";
|
|
25
|
-
AllowedKeys["ElapsedTimeInMilliseconds"] = "DurationInMilliseconds";
|
|
26
23
|
})(AllowedKeys || (AllowedKeys = {}));
|
|
27
24
|
let initializationPromise = null;
|
|
28
25
|
const appInsightsLogger = appInsightsKey => {
|
|
@@ -95,9 +92,9 @@ const appInsightsLogger = appInsightsKey => {
|
|
|
95
92
|
if (!_logger) return;
|
|
96
93
|
const eventName = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$paylo = telemetryInput.payload) === null || _telemetryInput$paylo === void 0 ? void 0 : _telemetryInput$paylo.Event;
|
|
97
94
|
const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$telem = telemetryInput.telemetryInfo) === null || _telemetryInput$telem === void 0 ? void 0 : _telemetryInput$telem.telemetryInfo;
|
|
98
|
-
const eventProperties = setEventProperties(telemetryInfo);
|
|
99
95
|
if (eventName) {
|
|
100
96
|
const trackingEventName = getTrackingEventName(logLevel, eventName);
|
|
97
|
+
const eventProperties = setEventProperties(trackingEventName, telemetryInfo);
|
|
101
98
|
_logger.trackEvent({
|
|
102
99
|
name: trackingEventName,
|
|
103
100
|
properties: eventProperties
|
|
@@ -116,17 +113,36 @@ const appInsightsLogger = appInsightsKey => {
|
|
|
116
113
|
};
|
|
117
114
|
|
|
118
115
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
119
|
-
function setEventProperties(telemetryInfo) {
|
|
116
|
+
function setEventProperties(eventName, telemetryInfo) {
|
|
120
117
|
const eventProperties = {};
|
|
121
118
|
if (telemetryInfo) {
|
|
122
119
|
for (const key in AllowedKeys) {
|
|
123
|
-
const finalKey = AllowedKeys[key]; // get renamed keys for LCWRuntimeId, ConversationId
|
|
120
|
+
const finalKey = AllowedKeys[key]; // get renamed keys for LCWRuntimeId, ConversationId
|
|
124
121
|
const value = telemetryInfo[key];
|
|
125
122
|
if (value !== undefined && value !== null && value !== "") {
|
|
126
123
|
eventProperties[finalKey] = value;
|
|
127
124
|
}
|
|
128
125
|
}
|
|
129
126
|
}
|
|
127
|
+
// Include exception details in description for error events
|
|
128
|
+
if (telemetryInfo !== null && telemetryInfo !== void 0 && telemetryInfo.ExceptionDetails) {
|
|
129
|
+
eventProperties[AllowedKeys.Description] = JSON.stringify(telemetryInfo.ExceptionDetails);
|
|
130
|
+
}
|
|
131
|
+
const customProperties = (() => {
|
|
132
|
+
if (!(telemetryInfo !== null && telemetryInfo !== void 0 && telemetryInfo.CustomProperties)) {
|
|
133
|
+
return {};
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
return typeof telemetryInfo.CustomProperties === "string" ? JSON.parse(telemetryInfo.CustomProperties) : telemetryInfo.CustomProperties;
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.warn("Failed to parse CustomProperties:", error);
|
|
139
|
+
return {};
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
// Additional properties
|
|
143
|
+
eventProperties["ConversationStage"] = customProperties.ConversationStage ?? _TelemetryConstants.ConversationStage.CSREngagement;
|
|
144
|
+
eventProperties["Scenario"] = "Conversation Diagnostics";
|
|
145
|
+
eventProperties["OperationName"] = eventName.includes(": ") ? eventName.split(": ")[1] : eventName;
|
|
130
146
|
return eventProperties;
|
|
131
147
|
}
|
|
132
148
|
function getTrackingEventName(logLevel, eventName) {
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _TelemetryHelper = require("../telemetry/TelemetryHelper");
|
|
8
|
+
var _TelemetryConstants = require("../telemetry/TelemetryConstants");
|
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
|
+
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); } }
|
|
11
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
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
|
+
/**
|
|
16
|
+
* SecureEventBus class implementing the singleton pattern for secure event communication.
|
|
17
|
+
* Provides authentication-based event dispatching to prevent unauthorized external access.
|
|
18
|
+
*/
|
|
19
|
+
let SecureEventBus = /*#__PURE__*/function () {
|
|
20
|
+
/**
|
|
21
|
+
* Private constructor to enforce singleton pattern.
|
|
22
|
+
* Generates a unique authentication token for this session.
|
|
23
|
+
*/
|
|
24
|
+
function SecureEventBus() {
|
|
25
|
+
_classCallCheck(this, SecureEventBus);
|
|
26
|
+
_defineProperty(this, "listeners", new Map());
|
|
27
|
+
_defineProperty(this, "authToken", void 0);
|
|
28
|
+
_defineProperty(this, "eventCounter", 0);
|
|
29
|
+
// Generate a secure, unique token for this session
|
|
30
|
+
this.authToken = this.generateAuthToken();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get the singleton instance of SecureEventBus.
|
|
35
|
+
* Creates a new instance if one doesn't exist.
|
|
36
|
+
*
|
|
37
|
+
* @returns The singleton instance of SecureEventBus
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
_createClass(SecureEventBus, [{
|
|
45
|
+
key: "generateAuthToken",
|
|
46
|
+
value:
|
|
47
|
+
/**
|
|
48
|
+
* Generate a cryptographically secure authentication token.
|
|
49
|
+
* Uses crypto.getRandomValues when available, falls back to Math.random.
|
|
50
|
+
*
|
|
51
|
+
* @private
|
|
52
|
+
* @returns A 64-character hexadecimal string representing the authentication token
|
|
53
|
+
*/
|
|
54
|
+
function generateAuthToken() {
|
|
55
|
+
const array = new Uint8Array(32);
|
|
56
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
57
|
+
crypto.getRandomValues(array);
|
|
58
|
+
} else {
|
|
59
|
+
// Fallback for environments without crypto.getRandomValues
|
|
60
|
+
for (let i = 0; i < array.length; i++) {
|
|
61
|
+
array[i] = Math.floor(Math.random() * 256);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return Array.from(array, byte => byte.toString(16).padStart(2, "0")).join("");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get the authentication token for this SecureEventBus instance.
|
|
69
|
+
* This token is required for dispatching events and should only be used internally.
|
|
70
|
+
*
|
|
71
|
+
* @returns The authentication token string
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
76
|
+
* const token = eventBus.getAuthToken();
|
|
77
|
+
* eventBus.dispatch('myEvent', { data: 'value' }, token);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
}, {
|
|
81
|
+
key: "getAuthToken",
|
|
82
|
+
value: function getAuthToken() {
|
|
83
|
+
return this.authToken;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Dispatch an event with authentication to all registered listeners.
|
|
88
|
+
* Verifies the authentication token before dispatching to prevent unauthorized access.
|
|
89
|
+
*
|
|
90
|
+
* @param eventName - The name of the event to dispatch
|
|
91
|
+
* @param payload - The data to send with the event (optional)
|
|
92
|
+
* @param token - Authentication token (must match the internal token)
|
|
93
|
+
* @returns true if event was successfully dispatched, false if unauthorized or error occurred
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
98
|
+
* const token = eventBus.getAuthToken();
|
|
99
|
+
*
|
|
100
|
+
* // Dispatch with payload
|
|
101
|
+
* const success = eventBus.dispatch('userAction', { action: 'click', target: 'button' }, token);
|
|
102
|
+
*
|
|
103
|
+
* // Dispatch without payload
|
|
104
|
+
* eventBus.dispatch('windowClosed', undefined, token);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
+
}, {
|
|
109
|
+
key: "dispatch",
|
|
110
|
+
value: function dispatch(eventName, payload, token) {
|
|
111
|
+
// Verify authentication token
|
|
112
|
+
if (token !== this.authToken) {
|
|
113
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
114
|
+
Event: _TelemetryConstants.TelemetryEvent.SecureEventBusUnauthorizedDispatch,
|
|
115
|
+
Description: `Unauthorized event dispatch attempt blocked: ${eventName}`,
|
|
116
|
+
ExceptionDetails: {
|
|
117
|
+
eventName,
|
|
118
|
+
providedToken: token ? "provided" : "missing",
|
|
119
|
+
expectedToken: "secured"
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
const listeners = this.listeners.get(eventName);
|
|
125
|
+
if (!listeners || listeners.length === 0) {
|
|
126
|
+
return true; // No listeners, but not an error
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Dispatch to all registered listeners
|
|
130
|
+
try {
|
|
131
|
+
listeners.forEach(listener => {
|
|
132
|
+
try {
|
|
133
|
+
listener.callback(payload);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
136
|
+
Event: _TelemetryConstants.TelemetryEvent.SecureEventBusListenerError,
|
|
137
|
+
Description: `Error in event listener for event: ${eventName}`,
|
|
138
|
+
ExceptionDetails: error
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return true;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
145
|
+
Event: _TelemetryConstants.TelemetryEvent.SecureEventBusDispatchError,
|
|
146
|
+
Description: `Error dispatching event: ${eventName}`,
|
|
147
|
+
ExceptionDetails: error
|
|
148
|
+
});
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Subscribe to an event with a callback function.
|
|
155
|
+
* The callback will be executed whenever the specified event is dispatched.
|
|
156
|
+
*
|
|
157
|
+
* @param eventName - The name of the event to listen for
|
|
158
|
+
* @param callback - The function to execute when the event is fired
|
|
159
|
+
* @returns A function that can be called to unsubscribe from the event
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
164
|
+
*
|
|
165
|
+
* // Subscribe to an event
|
|
166
|
+
* const unsubscribe = eventBus.subscribe('chatMessage', (message) => {
|
|
167
|
+
* console.log('New message:', message.text);
|
|
168
|
+
* console.log('From user:', message.userId);
|
|
169
|
+
* });
|
|
170
|
+
*
|
|
171
|
+
* // Later, unsubscribe
|
|
172
|
+
* unsubscribe();
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
176
|
+
}, {
|
|
177
|
+
key: "subscribe",
|
|
178
|
+
value: function subscribe(eventName, callback) {
|
|
179
|
+
const listenerId = `listener_${++this.eventCounter}`;
|
|
180
|
+
if (!this.listeners.has(eventName)) {
|
|
181
|
+
this.listeners.set(eventName, []);
|
|
182
|
+
}
|
|
183
|
+
const listeners = this.listeners.get(eventName);
|
|
184
|
+
if (!listeners) {
|
|
185
|
+
throw new Error(`Listeners for event "${eventName}" not found.`);
|
|
186
|
+
}
|
|
187
|
+
const listener = {
|
|
188
|
+
callback,
|
|
189
|
+
id: listenerId
|
|
190
|
+
};
|
|
191
|
+
listeners.push(listener);
|
|
192
|
+
|
|
193
|
+
// Return unsubscribe function
|
|
194
|
+
return () => {
|
|
195
|
+
const currentListeners = this.listeners.get(eventName);
|
|
196
|
+
if (currentListeners) {
|
|
197
|
+
const index = currentListeners.findIndex(l => l.id === listenerId);
|
|
198
|
+
if (index !== -1) {
|
|
199
|
+
currentListeners.splice(index, 1);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Clean up empty listener arrays
|
|
203
|
+
if (currentListeners.length === 0) {
|
|
204
|
+
this.listeners.delete(eventName);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Remove all listeners for a specific event.
|
|
212
|
+
* This completely removes the event from the internal listeners map.
|
|
213
|
+
*
|
|
214
|
+
* @param eventName - The name of the event to remove all listeners for
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
219
|
+
*
|
|
220
|
+
* // Remove all listeners for 'chatClosed' event
|
|
221
|
+
* eventBus.removeAllListeners('chatClosed');
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
}, {
|
|
225
|
+
key: "removeAllListeners",
|
|
226
|
+
value: function removeAllListeners(eventName) {
|
|
227
|
+
this.listeners.delete(eventName);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Clear all listeners for all events.
|
|
232
|
+
* This resets the entire event bus to its initial state.
|
|
233
|
+
* Useful for cleanup during application shutdown or testing.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
238
|
+
*
|
|
239
|
+
* // Clear all event listeners
|
|
240
|
+
* eventBus.clear();
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
}, {
|
|
244
|
+
key: "clear",
|
|
245
|
+
value: function clear() {
|
|
246
|
+
this.listeners.clear();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Get the number of listeners for a specific event.
|
|
251
|
+
* Useful for debugging and monitoring purposes.
|
|
252
|
+
*
|
|
253
|
+
* @param eventName - The name of the event to count listeners for
|
|
254
|
+
* @returns The number of listeners registered for the event
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
259
|
+
*
|
|
260
|
+
* // Check how many listeners are registered for 'userAction'
|
|
261
|
+
* const count = eventBus.getListenerCount('userAction');
|
|
262
|
+
* console.log(`${count} listeners registered for userAction`);
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
}, {
|
|
266
|
+
key: "getListenerCount",
|
|
267
|
+
value: function getListenerCount(eventName) {
|
|
268
|
+
var _this$listeners$get;
|
|
269
|
+
return ((_this$listeners$get = this.listeners.get(eventName)) === null || _this$listeners$get === void 0 ? void 0 : _this$listeners$get.length) || 0;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Get all registered event names.
|
|
274
|
+
* Returns an array of event names that currently have listeners.
|
|
275
|
+
* Useful for debugging and monitoring purposes.
|
|
276
|
+
*
|
|
277
|
+
* @returns An array of event names that have registered listeners
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```typescript
|
|
281
|
+
* const eventBus = SecureEventBus.getInstance();
|
|
282
|
+
*
|
|
283
|
+
* // Get all registered events
|
|
284
|
+
* const events = eventBus.getRegisteredEvents();
|
|
285
|
+
* console.log('Active events:', events);
|
|
286
|
+
* // Output: ['userAction', 'chatMessage', 'windowResize']
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
}, {
|
|
290
|
+
key: "getRegisteredEvents",
|
|
291
|
+
value: function getRegisteredEvents() {
|
|
292
|
+
return Array.from(this.listeners.keys());
|
|
293
|
+
}
|
|
294
|
+
}], [{
|
|
295
|
+
key: "getInstance",
|
|
296
|
+
value: function getInstance() {
|
|
297
|
+
if (!SecureEventBus.instance) {
|
|
298
|
+
SecureEventBus.instance = new SecureEventBus();
|
|
299
|
+
}
|
|
300
|
+
return SecureEventBus.instance;
|
|
301
|
+
}
|
|
302
|
+
}]);
|
|
303
|
+
return SecureEventBus;
|
|
304
|
+
}();
|
|
305
|
+
_defineProperty(SecureEventBus, "instance", null);
|
|
306
|
+
var _default = SecureEventBus;
|
|
307
|
+
exports.default = _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _SecureEventBus = _interopRequireDefault(require("./SecureEventBus"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
const dispatchCustomEvent = (name, payload) => {
|
|
11
|
+
try {
|
|
12
|
+
const eventBus = _SecureEventBus.default.getInstance();
|
|
13
|
+
const authToken = eventBus.getAuthToken();
|
|
14
|
+
|
|
15
|
+
// Dispatch through the secure event bus instead of global window
|
|
16
|
+
const success = eventBus.dispatch(name, payload, authToken);
|
|
17
|
+
if (!success) {
|
|
18
|
+
console.error("Failed to dispatch secure event:", name);
|
|
19
|
+
}
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error("Error dispatching secure custom event:", name, payload, error);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var _default = dispatchCustomEvent;
|
|
25
|
+
exports.default = _default;
|
|
@@ -26,7 +26,10 @@ const ChatButtonStateful = props => {
|
|
|
26
26
|
uiTimer = (0, _utils.createTimer)();
|
|
27
27
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
28
28
|
Event: _TelemetryConstants.TelemetryEvent.UXLCWChatButtonLoadingStart,
|
|
29
|
-
Description: "Chat button loading started"
|
|
29
|
+
Description: "Chat button loading started",
|
|
30
|
+
CustomProperties: {
|
|
31
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
32
|
+
}
|
|
30
33
|
});
|
|
31
34
|
}, []);
|
|
32
35
|
|
|
@@ -49,7 +52,10 @@ const ChatButtonStateful = props => {
|
|
|
49
52
|
ref.current = async () => {
|
|
50
53
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
51
54
|
Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked,
|
|
52
|
-
Description: "Chat button click action started"
|
|
55
|
+
Description: "Chat button click action started",
|
|
56
|
+
CustomProperties: {
|
|
57
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
58
|
+
}
|
|
53
59
|
});
|
|
54
60
|
if (state.appStates.isMinimized) {
|
|
55
61
|
dispatch({
|
|
@@ -69,7 +75,10 @@ const ChatButtonStateful = props => {
|
|
|
69
75
|
}
|
|
70
76
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
71
77
|
Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonActionCompleted,
|
|
72
|
-
Description: "Chat button action completed"
|
|
78
|
+
Description: "Chat button action completed",
|
|
79
|
+
CustomProperties: {
|
|
80
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
81
|
+
}
|
|
73
82
|
});
|
|
74
83
|
};
|
|
75
84
|
const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeChatButtonStyleProps.defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
@@ -123,7 +132,10 @@ const ChatButtonStateful = props => {
|
|
|
123
132
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
124
133
|
Event: _TelemetryConstants.TelemetryEvent.UXLCWChatButtonLoadingCompleted,
|
|
125
134
|
Description: "Chat button loading completed",
|
|
126
|
-
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
135
|
+
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed,
|
|
136
|
+
CustomProperties: {
|
|
137
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
138
|
+
}
|
|
127
139
|
});
|
|
128
140
|
}, []);
|
|
129
141
|
(0, _react.useEffect)(() => {
|
|
@@ -42,7 +42,7 @@ const CitationPaneStateful = props => {
|
|
|
42
42
|
const [paneStyle, setPaneStyle] = (0, _react.useState)(null);
|
|
43
43
|
const [isReady, setIsReady] = (0, _react.useState)(false);
|
|
44
44
|
|
|
45
|
-
//
|
|
45
|
+
// Initial focus pattern (mirrors ConfirmationPaneStateful): focus first focusable element (will re-attempt after visibility becomes true)
|
|
46
46
|
(0, _react.useEffect)(() => {
|
|
47
47
|
(0, _utils.preventFocusToMoveOutOfElement)(controlId);
|
|
48
48
|
const focusableElements = (0, _utils.findAllFocusableElement)(`#${controlId}`);
|
|
@@ -64,6 +64,25 @@ const CitationPaneStateful = props => {
|
|
|
64
64
|
});
|
|
65
65
|
}, []);
|
|
66
66
|
|
|
67
|
+
// Retry focus once pane is actually visible (isReady) in case initial attempt occurred while wrapper was visibility:hidden
|
|
68
|
+
(0, _react.useEffect)(() => {
|
|
69
|
+
if (!isReady) return;
|
|
70
|
+
const focusableElements = (0, _utils.findAllFocusableElement)(`#${controlId}`);
|
|
71
|
+
if (focusableElements && focusableElements.length > 0) {
|
|
72
|
+
const first = focusableElements[0];
|
|
73
|
+
// If focused element is not already inside the pane, move focus
|
|
74
|
+
if (!first.contains(document.activeElement) && !(document.activeElement && document.activeElement.id.startsWith(controlId))) {
|
|
75
|
+
requestAnimationFrame(() => {
|
|
76
|
+
if (first.isConnected) {
|
|
77
|
+
first.focus({
|
|
78
|
+
preventScroll: true
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, [isReady, controlId]);
|
|
85
|
+
|
|
67
86
|
// Compute the widget bounds and set pane style accordingly (95% of widget size
|
|
68
87
|
// and centered inside the widget). If the widget container can't be found,
|
|
69
88
|
// fall back to the default pane styles from defaultCitationPaneProps.
|
|
@@ -70,7 +70,10 @@ const HeaderStateful = props => {
|
|
|
70
70
|
var _props$headerProps, _props$headerProps$co, _props$headerProps$co2;
|
|
71
71
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
72
72
|
Event: _TelemetryConstants.TelemetryEvent.HeaderCloseButtonClicked,
|
|
73
|
-
Description: "Header Close action started."
|
|
73
|
+
Description: "Header Close action started.",
|
|
74
|
+
CustomProperties: {
|
|
75
|
+
ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd
|
|
76
|
+
}
|
|
74
77
|
});
|
|
75
78
|
if (localConfirmationPaneState.current !== _Constants.ConfirmationState.Ok) {
|
|
76
79
|
dispatch({
|
|
@@ -85,7 +88,10 @@ const HeaderStateful = props => {
|
|
|
85
88
|
}
|
|
86
89
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
87
90
|
Event: _TelemetryConstants.TelemetryEvent.CloseChatActionCompleted,
|
|
88
|
-
Description: "Header Close action completed."
|
|
91
|
+
Description: "Header Close action completed.",
|
|
92
|
+
CustomProperties: {
|
|
93
|
+
ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd
|
|
94
|
+
}
|
|
89
95
|
});
|
|
90
96
|
const closeButtonId = ((_props$headerProps = props.headerProps) === null || _props$headerProps === void 0 ? void 0 : (_props$headerProps$co = _props$headerProps.controlProps) === null || _props$headerProps$co === void 0 ? void 0 : (_props$headerProps$co2 = _props$headerProps$co.closeButtonProps) === null || _props$headerProps$co2 === void 0 ? void 0 : _props$headerProps$co2.id) ?? `${controlProps.id}-close-button`;
|
|
91
97
|
if (closeButtonId) {
|