@microsoft/omnichannel-chat-widget 1.8.3 → 1.8.4-main.21aec08
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 +27 -0
- package/lib/cjs/common/Constants.js +7 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
- package/lib/cjs/common/telemetry/AppInsightsEvents.js +14 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +46 -2
- package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +29 -13
- package/lib/cjs/common/utils/SecureEventBus.js +307 -0
- package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
- package/lib/cjs/common/utils.js +14 -1
- 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 +290 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +17 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +33 -10
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -7
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- 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 +123 -28
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +37 -8
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +46 -22
- 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 +103 -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 +57 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +121 -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 +1058 -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/citationsMiddleware.js +6 -1
- 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 +7 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
- package/lib/esm/common/telemetry/AppInsightsEvents.js +14 -9
- package/lib/esm/common/telemetry/TelemetryConstants.js +44 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +30 -14
- package/lib/esm/common/utils/SecureEventBus.js +328 -0
- package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
- package/lib/esm/common/utils.js +11 -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 +283 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +10 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +33 -10
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +16 -7
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- 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 +124 -29
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +39 -10
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +46 -22
- 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 +96 -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 +49 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +114 -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 +1080 -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/citationsMiddleware.js +6 -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 +6 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +41 -2
- package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
- package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
- package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
- package/lib/types/common/utils.d.ts +9 -1
- 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/liveChatConfigUtils.d.ts +11 -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 +11 -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/interfaces/IExtendedChatConffig.d.ts +15 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +6 -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
package/README.md
CHANGED
|
@@ -268,6 +268,33 @@ const customizedFooterProp: IFooterProps = {
|
|
|
268
268
|
setOnCustomEvent((event) => console.log(event));
|
|
269
269
|
```
|
|
270
270
|
|
|
271
|
+
#### Trigger initiateEndChat event
|
|
272
|
+
Customer can trigger the initiateEndChat event via BroadcastService to end a chat session.
|
|
273
|
+
When needed, the payload below could be triggered:
|
|
274
|
+
```js
|
|
275
|
+
const endChatEvent = {
|
|
276
|
+
eventName: "InitiateEndChat",
|
|
277
|
+
payload: {
|
|
278
|
+
skipSessionCloseForPersistentChat: true
|
|
279
|
+
} //optional payload
|
|
280
|
+
};
|
|
281
|
+
BroadcastService.postMessage(endChatEvent);
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
The payload of the event is optional, only needed when force closing of a persistent chat session is not required.
|
|
285
|
+
When chat widget receives the event without any payload, it will:
|
|
286
|
+
1. set the widget to closed state, the widget panel will be minimized. Post chat survey will not be displayed.
|
|
287
|
+
2. trigger a sessionclose service network request to OmniChannel services.
|
|
288
|
+
|
|
289
|
+
If skipSessionCloseForPersistentChat is set to true. The session close network request will not be triggered, instead, if postChat survey is available, post chat survey will be displayed.
|
|
290
|
+
|
|
291
|
+
After successfully processed initiateEndChat event. The CloseChat event is broadcasted.
|
|
292
|
+
```js
|
|
293
|
+
BroadcastService.getMessageByEventName("CloseChat").subscribe(async (msg) => {
|
|
294
|
+
console.log("close chat received: ", msg);
|
|
295
|
+
//more actions to unmount component and resources
|
|
296
|
+
})
|
|
297
|
+
```
|
|
271
298
|
## See Also
|
|
272
299
|
|
|
273
300
|
[Customizations Dev Guide](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/customizations/getstarted.md)\
|
|
@@ -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");
|
|
@@ -138,6 +143,7 @@ _defineProperty(Constants, "customEventName", "customEventName");
|
|
|
138
143
|
_defineProperty(Constants, "customEventValue", "customEventValue");
|
|
139
144
|
_defineProperty(Constants, "Hidden", "Hidden");
|
|
140
145
|
_defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
|
|
146
|
+
_defineProperty(Constants, "SkipSessionCloseForPersistentChatFlag", "skipSessionCloseForPersistentChat");
|
|
141
147
|
const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
|
|
142
148
|
_classCallCheck(this, Regex);
|
|
143
149
|
}), _defineProperty(_class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[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]?)\\])$"), _class);
|
|
@@ -373,6 +379,7 @@ _defineProperty(PrepareEndChatDescriptionConstants, "ConversationEndedBy", "Conv
|
|
|
373
379
|
_defineProperty(PrepareEndChatDescriptionConstants, "PrepareEndChatError", "There's an error while preparing to end chat. Closing chat widget.");
|
|
374
380
|
_defineProperty(PrepareEndChatDescriptionConstants, "WidgetLoadFailedAfterSessionInit", "SessionInit was successful, but widget load failed. Ending chat to avoid ghost chats in OC.");
|
|
375
381
|
_defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceived", "Received InitiateEndChat BroadcastEvent while conversation state is not Active. Ending chat.");
|
|
382
|
+
_defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceivedActiveChat", "Received InitiateEndChat BroadcastEvent while conversation state is Active. Updating conversation states.");
|
|
376
383
|
_defineProperty(PrepareEndChatDescriptionConstants, "EndChatReceivedFromOtherTabs", "Received EndChat BroadcastEvent from other tabs. Closing this chat.");
|
|
377
384
|
_defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseChatOnFailureOrPostChat", "Customer is trying to close chat widget on start chat failure or post chat pane.");
|
|
378
385
|
_defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseInactiveChat", "Chat was Inactive and customer is trying to close chat widget or refreshing the page.");
|
|
@@ -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,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.AppInsightsEventMapping = void 0;
|
|
7
7
|
const AppInsightsEventMapping = {
|
|
8
8
|
"LCWChatButtonClicked": "LCWChatButtonActionStarted",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
9
|
+
"UXLCWChatButtonLoadingStart": "LiveChatWidgetChatButtonLoadingStarted",
|
|
10
|
+
"UXLCWChatButtonLoadingCompleted": "LiveChatWidgetChatButtonLoadingCompleted",
|
|
11
|
+
"UXPrechatPaneStart": "PrechatSurveyStarted",
|
|
12
|
+
"UXPrechatPaneCompleted": "PrechatSurveyCompleted",
|
|
13
|
+
"PrechatSubmitted": "PrechatSurveySubmitCompleted",
|
|
14
14
|
"EndChatEventReceived": "EndChatEventReceivedCompleted",
|
|
15
15
|
"EmailTranscriptSent": "EmailTranscriptActionCompleted",
|
|
16
16
|
"EmailTranscriptFailed": "EmailTranscriptActionFailed",
|
|
@@ -18,14 +18,19 @@ const AppInsightsEventMapping = {
|
|
|
18
18
|
"HeaderMinimizeButtonClicked": "MinimizeChatActionStarted",
|
|
19
19
|
"DownloadTranscriptButtonClicked": "DownloadTranscriptActionStarted",
|
|
20
20
|
"EmailTranscriptButtonClicked": "EmailTranscriptButtonActionStarted",
|
|
21
|
-
"CustomerVoiceFormResponseSubmitted": "CustomerVoiceFormResponseSubmitCompleted",
|
|
22
|
-
"StartProactiveChatEventReceived": "StartProactiveChatEventReceivedCompleted",
|
|
23
21
|
"ProactiveChatRejected": "ProactiveChatTimeOutCompleted",
|
|
24
22
|
"MessageSent": "MessageSentCompleted",
|
|
25
23
|
"MessageReceived": "MessageReceivedCompleted",
|
|
26
24
|
"SystemMessageReceived": "SystemMessageReceivedCompleted",
|
|
27
|
-
"RehydrateMessageReceived": "
|
|
25
|
+
"RehydrateMessageReceived": "ChatHistoryMessageReceivedCompleted",
|
|
28
26
|
"CustomContextReceived": "CustomContextReceivedCompleted",
|
|
29
|
-
"
|
|
27
|
+
"NewTokenValidationStarted": "AuthTokenValidationStarted",
|
|
28
|
+
"NewTokenValidationCompleted": "AuthTokenValidationCompleted",
|
|
29
|
+
"NewTokenValidationFailed": "AuthTokenValidationFailed",
|
|
30
|
+
"UXPostChatPaneStarted": "PostChatSurveyStarted",
|
|
31
|
+
"UXPostChatPaneCompleted": "PostChatSurveyCompleted",
|
|
32
|
+
"WidgetLoadStarted": "ChatSessionInitializationStarted",
|
|
33
|
+
"WidgetLoadComplete": "ChatSessionInitializationCompleted",
|
|
34
|
+
"WidgetLoadFailed": "ChatSessionInitializationFailed"
|
|
30
35
|
};
|
|
31
36
|
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,39 @@ 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["LCWPersistentHistoryReturnedNull"] = "LCWPersistentHistoryReturnedNull";
|
|
310
|
+
TelemetryEvent["LCWLazyLoadInitializationStarted"] = "LCWLazyLoadInitializationStarted";
|
|
311
|
+
TelemetryEvent["LCWLazyLoadContainerNotFound"] = "LCWLazyLoadContainerNotFound";
|
|
312
|
+
TelemetryEvent["LCWLazyLoadInitializationCompleted"] = "LCWLazyLoadInitializationCompleted";
|
|
313
|
+
TelemetryEvent["LCWLazyLoadSessionMetrics"] = "LCWLazyLoadSessionMetrics";
|
|
314
|
+
TelemetryEvent["LCWLazyLoadTargetElementNotFound"] = "LCWLazyLoadTargetElementNotFound";
|
|
315
|
+
TelemetryEvent["LCWLazyLoadScrollFailed"] = "LCWLazyLoadScrollFailed";
|
|
316
|
+
TelemetryEvent["LCWLazyLoadActivityMounted"] = "LCWLazyLoadActivityMounted";
|
|
317
|
+
TelemetryEvent["LCWLazyLoadReset"] = "LCWLazyLoadReset";
|
|
318
|
+
TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
|
|
319
|
+
TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
|
|
320
|
+
TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
|
|
321
|
+
TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
|
|
322
|
+
TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
|
|
323
|
+
TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
|
|
324
|
+
TelemetryEvent["StartChatComplete"] = "StartChatComplete";
|
|
291
325
|
})(TelemetryEvent || (exports.TelemetryEvent = TelemetryEvent = {}));
|
|
292
326
|
let TelemetryConstants = /*#__PURE__*/function () {
|
|
293
327
|
function TelemetryConstants() {
|
|
@@ -355,6 +389,9 @@ let TelemetryConstants = /*#__PURE__*/function () {
|
|
|
355
389
|
case TelemetryEvent.PostChatWorkflowFromAgent:
|
|
356
390
|
case TelemetryEvent.PostChatWorkflowFromBot:
|
|
357
391
|
case TelemetryEvent.AppStatesException:
|
|
392
|
+
case TelemetryEvent.SecureEventBusUnauthorizedDispatch:
|
|
393
|
+
case TelemetryEvent.SecureEventBusListenerError:
|
|
394
|
+
case TelemetryEvent.SecureEventBusDispatchError:
|
|
358
395
|
return ScenarioType.ACTIONS;
|
|
359
396
|
case TelemetryEvent.StartChatSDKCall:
|
|
360
397
|
case TelemetryEvent.StartChatEventReceived:
|
|
@@ -415,4 +452,11 @@ let TelemetryConstants = /*#__PURE__*/function () {
|
|
|
415
452
|
}]);
|
|
416
453
|
return TelemetryConstants;
|
|
417
454
|
}();
|
|
418
|
-
exports.TelemetryConstants = TelemetryConstants;
|
|
455
|
+
exports.TelemetryConstants = TelemetryConstants;
|
|
456
|
+
let ConversationStage;
|
|
457
|
+
exports.ConversationStage = ConversationStage;
|
|
458
|
+
(function (ConversationStage) {
|
|
459
|
+
ConversationStage["Initialization"] = "Initialization";
|
|
460
|
+
ConversationStage["CSREngagement"] = "CSR Engagement";
|
|
461
|
+
ConversationStage["ConversationEnd"] = "Conversation End";
|
|
462
|
+
})(ConversationStage || (exports.ConversationStage = ConversationStage = {}));
|
|
@@ -50,7 +50,7 @@ const RegisterLoggers = () => {
|
|
|
50
50
|
loggers.push((0, _consoleLogger.consoleLogger)());
|
|
51
51
|
}
|
|
52
52
|
if (((_TelemetryManager$Int9 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int9 === void 0 ? void 0 : (_TelemetryManager$Int10 = _TelemetryManager$Int9.telemetryConfig) === null || _TelemetryManager$Int10 === void 0 ? void 0 : _TelemetryManager$Int10.telemetryDisabled) === false) {
|
|
53
|
-
var _TelemetryManager$Int11, _TelemetryManager$Int20, _TelemetryManager$Int21, _TelemetryManager$Int22, _TelemetryManager$Int23;
|
|
53
|
+
var _TelemetryManager$Int11, _TelemetryManager$Int20, _TelemetryManager$Int21, _TelemetryManager$Int22, _TelemetryManager$Int23, _TelemetryManager$Int24, _TelemetryManager$Int25, _TelemetryManager$Int26;
|
|
54
54
|
if ((_TelemetryManager$Int11 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int11 !== void 0 && _TelemetryManager$Int11.ariaConfig) {
|
|
55
55
|
var _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14, _TelemetryManager$Int15, _TelemetryManager$Int16, _TelemetryManager$Int17, _TelemetryManager$Int18, _TelemetryManager$Int19;
|
|
56
56
|
loggers.push((0, _ariaTelemetryLogger.ariaTelemetryLogger)(((_TelemetryManager$Int12 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : (_TelemetryManager$Int13 = _TelemetryManager$Int12.ariaConfig) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.ariaTelemetryKey) ?? _defaultAriaConfig.defaultAriaConfig.ariaTelemetryKey, ((_TelemetryManager$Int14 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : (_TelemetryManager$Int15 = _TelemetryManager$Int14.ariaConfig) === null || _TelemetryManager$Int15 === void 0 ? void 0 : _TelemetryManager$Int15.disableCookieUsage) ?? _defaultAriaConfig.defaultAriaConfig.disableCookieUsage, ((_TelemetryManager$Int16 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int16 === void 0 ? void 0 : (_TelemetryManager$Int17 = _TelemetryManager$Int16.ariaConfig) === null || _TelemetryManager$Int17 === void 0 ? void 0 : _TelemetryManager$Int17.collectorUriForTelemetry) ?? _defaultAriaConfig.defaultAriaConfig.collectorUriForTelemetry, ((_TelemetryManager$Int18 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int18 === void 0 ? void 0 : (_TelemetryManager$Int19 = _TelemetryManager$Int18.ariaConfig) === null || _TelemetryManager$Int19 === void 0 ? void 0 : _TelemetryManager$Int19.ariaTelemetryApplicationName) ?? _defaultAriaConfig.defaultAriaConfig.ariaTelemetryApplicationName));
|
|
@@ -61,12 +61,15 @@ const RegisterLoggers = () => {
|
|
|
61
61
|
loggers.push(logger);
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
const chatConfigAppInsightsKey = (_TelemetryManager$Int22 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int22 === void 0 ? void 0 : _TelemetryManager$Int22.chatConfigAppInsightsKey;
|
|
65
|
+
const appInsightsKeyFromUser = (_TelemetryManager$Int23 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int23 === void 0 ? void 0 : (_TelemetryManager$Int24 = _TelemetryManager$Int23.appInsightsConfig) === null || _TelemetryManager$Int24 === void 0 ? void 0 : _TelemetryManager$Int24.appInsightsKey;
|
|
66
|
+
// when chatConfig has AppInsightsInstrumentationKey
|
|
67
|
+
if (chatConfigAppInsightsKey) {
|
|
68
|
+
loggers.push((0, _appInsightsLogger.appInsightsLogger)(chatConfigAppInsightsKey));
|
|
69
|
+
}
|
|
70
|
+
// when key set through appInsightsConfig
|
|
71
|
+
else if (appInsightsKeyFromUser && ((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : (_TelemetryManager$Int26 = _TelemetryManager$Int25.appInsightsConfig) === null || _TelemetryManager$Int26 === void 0 ? void 0 : _TelemetryManager$Int26.appInsightsDisabled) === false) {
|
|
72
|
+
loggers.push((0, _appInsightsLogger.appInsightsLogger)(appInsightsKeyFromUser));
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
};
|
|
@@ -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["
|
|
18
|
-
AllowedKeys["
|
|
19
|
-
AllowedKeys["
|
|
20
|
-
AllowedKeys["
|
|
17
|
+
AllowedKeys["OrganizationId"] = "powerplatform.analytics.resource.organization.id";
|
|
18
|
+
AllowedKeys["ConversationId"] = "powerplatform.analytics.resource.id";
|
|
19
|
+
AllowedKeys["ElapsedTimeInMilliseconds"] = "Duration";
|
|
20
|
+
AllowedKeys["Description"] = "omnichannel.description";
|
|
21
|
+
AllowedKeys["ChannelId"] = "omnichannel.channel.type";
|
|
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,11 +92,11 @@ 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);
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
const eventProperties = setEventProperties(trackingEventName, telemetryInfo);
|
|
98
|
+
_logger.trackTrace({
|
|
99
|
+
message: trackingEventName,
|
|
103
100
|
properties: eventProperties
|
|
104
101
|
});
|
|
105
102
|
}
|
|
@@ -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["powerplatform.analytics.subscenario"] = 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;
|