@microsoft/omnichannel-chat-widget 1.7.8-main.7a07fc5 → 1.7.8-main.8428c08
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 +66 -20
- package/lib/cjs/common/KeyCodes.js +6 -1
- package/lib/cjs/common/contextDataStore/DataStoreManager.js +6 -1
- package/lib/cjs/common/facades/FacadeChatSDK.js +392 -295
- package/lib/cjs/common/storage/default/defaultCacheManager.js +6 -3
- package/lib/cjs/common/telemetry/ScenarioMarker.js +66 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +179 -148
- package/lib/cjs/common/telemetry/TelemetryHelper.js +281 -250
- package/lib/cjs/common/telemetry/TelemetryManager.js +31 -11
- package/lib/cjs/common/telemetry/defaultConfigs/defaultAppInsightsConfig.js +11 -0
- package/lib/cjs/common/telemetry/interfaces/IAppInsightsConfig.js +1 -0
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +119 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +17 -14
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -4
- package/lib/cjs/components/footerstateful/FooterStateful.js +13 -8
- package/lib/cjs/components/headerstateful/HeaderStateful.js +24 -14
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +32 -19
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +71 -56
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +17 -8
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +65 -52
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +31 -18
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +14 -6
- package/lib/cjs/components/livechatwidget/common/Deferred.js +14 -6
- package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +3 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +4 -18
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +0 -5
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -1
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +7 -4
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +7 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +5 -26
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +7 -6
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +28 -20
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +12 -8
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -10
- package/lib/cjs/components/postchatsurveypanestateful/common/isValidSurveyUrl.js +28 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +9 -6
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +9 -7
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +4 -3
- package/lib/cjs/components/webchatcontainerstateful/common/DemoChatAdapter.js +88 -65
- package/lib/cjs/components/webchatcontainerstateful/common/DemoChatSDK.js +26 -7
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +49 -26
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +57 -35
- package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +62 -52
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +95 -61
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +53 -39
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +4 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +88 -60
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +18 -6
- package/lib/cjs/firstresponselatency/Constants.js +13 -0
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +118 -0
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +201 -0
- package/lib/cjs/firstresponselatency/util.js +98 -0
- package/lib/cjs/plugins/createChatTranscript.js +92 -62
- package/lib/cjs/plugins/newMessageEventHandler.js +102 -88
- package/lib/esm/common/Constants.js +64 -19
- package/lib/esm/common/KeyCodes.js +6 -1
- package/lib/esm/common/contextDataStore/DataStoreManager.js +6 -1
- package/lib/esm/common/facades/FacadeChatSDK.js +392 -295
- package/lib/esm/common/storage/default/defaultCacheManager.js +6 -1
- package/lib/esm/common/telemetry/ScenarioMarker.js +59 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +179 -148
- package/lib/esm/common/telemetry/TelemetryHelper.js +281 -250
- package/lib/esm/common/telemetry/TelemetryManager.js +31 -11
- package/lib/esm/common/telemetry/defaultConfigs/defaultAppInsightsConfig.js +4 -0
- package/lib/esm/common/telemetry/interfaces/IAppInsightsConfig.js +1 -0
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +111 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -14
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -4
- package/lib/esm/components/footerstateful/FooterStateful.js +13 -8
- package/lib/esm/components/headerstateful/HeaderStateful.js +24 -14
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +32 -19
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +71 -56
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +17 -8
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +65 -52
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +31 -18
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +14 -6
- package/lib/esm/components/livechatwidget/common/Deferred.js +14 -6
- package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +3 -1
- package/lib/esm/components/livechatwidget/common/endChat.js +4 -18
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +1 -6
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -1
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +7 -4
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +7 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +6 -27
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -6
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +28 -20
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +12 -8
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -10
- package/lib/esm/components/postchatsurveypanestateful/common/isValidSurveyUrl.js +21 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +9 -6
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +9 -7
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +4 -3
- package/lib/esm/components/webchatcontainerstateful/common/DemoChatAdapter.js +88 -65
- package/lib/esm/components/webchatcontainerstateful/common/DemoChatSDK.js +26 -7
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +49 -26
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +57 -35
- package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +63 -52
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +95 -61
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer.js +53 -39
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +88 -60
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +18 -6
- package/lib/esm/firstresponselatency/Constants.js +6 -0
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +112 -0
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +194 -0
- package/lib/esm/firstresponselatency/util.js +87 -0
- package/lib/esm/plugins/createChatTranscript.js +92 -62
- package/lib/esm/plugins/newMessageEventHandler.js +100 -86
- package/lib/types/common/Constants.d.ts +5 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +1 -0
- package/lib/types/common/telemetry/ScenarioMarker.d.ts +19 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +50 -33
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +5 -0
- package/lib/types/common/telemetry/defaultConfigs/defaultAppInsightsConfig.d.ts +2 -0
- package/lib/types/common/telemetry/interfaces/IAppInsightsConfig.d.ts +4 -0
- package/lib/types/common/telemetry/interfaces/IChatSDKLogger.d.ts +1 -0
- package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +2 -0
- package/lib/types/common/telemetry/loggers/appInsightsLogger.d.ts +5 -0
- package/lib/types/components/callingcontainerstateful/CallingContainerStateful.d.ts +2 -1
- package/lib/types/components/chatbuttonstateful/ChatButtonStateful.d.ts +2 -1
- package/lib/types/components/confirmationpanestateful/ConfirmationPaneStateful.d.ts +2 -1
- package/lib/types/components/dimlayer/DimLayer.d.ts +2 -1
- package/lib/types/components/draggable/DraggableChatWidget.d.ts +2 -2
- package/lib/types/components/draggable/DraggableEventEmitter.d.ts +2 -2
- package/lib/types/components/draggable/DraggableEventReceiver.d.ts +2 -2
- package/lib/types/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.d.ts +2 -1
- package/lib/types/components/footerstateful/FooterStateful.d.ts +2 -1
- package/lib/types/components/footerstateful/audionotificationstateful/AudioNotificationStateful.d.ts +2 -1
- package/lib/types/components/headerstateful/HeaderStateful.d.ts +2 -1
- package/lib/types/components/livechatwidget/LiveChatWidget.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/createFooter.d.ts +2 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/loadingpanestateful/LoadingPaneStateful.d.ts +2 -1
- package/lib/types/components/notificationpanestateful/NotificationPaneStateful.d.ts +2 -1
- package/lib/types/components/ooohpanestateful/OOOHPaneStateful.d.ts +2 -1
- package/lib/types/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.d.ts +2 -1
- package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -1
- package/lib/types/components/postchatsurveypanestateful/common/isValidSurveyUrl.d.ts +2 -0
- package/lib/types/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.d.ts +2 -1
- package/lib/types/components/proactivechatpanestateful/ProactiveChatPaneStateful.d.ts +2 -1
- package/lib/types/components/reconnectchatpanestateful/ReconnectChatPaneStateful.d.ts +2 -1
- package/lib/types/components/startchaterrorpanestateful/StartChatErrorPaneStateful.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/WebChatContainerStateful.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatProps.d.ts +2 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentContent.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AttachmentIcon.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/DownloadBlockedAttachment.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/MaliciousAttachment.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/ScanInProgressAttachment.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Spinner.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.d.ts +2 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -1
- package/lib/types/firstresponselatency/Constants.d.ts +30 -0
- package/lib/types/firstresponselatency/FirstMessageTrackerFromBot.d.ts +1 -0
- package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +22 -0
- package/lib/types/firstresponselatency/util.d.ts +7 -0
- package/package.json +27 -13
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
+
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); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
7
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../common/telemetry/TelemetryConstants";
|
|
8
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
9
|
+
import { TelemetryHelper } from "../common/telemetry/TelemetryHelper";
|
|
10
|
+
export let FirstResponseLatencyTracker = /*#__PURE__*/function () {
|
|
11
|
+
function FirstResponseLatencyTracker() {
|
|
12
|
+
_classCallCheck(this, FirstResponseLatencyTracker);
|
|
13
|
+
_defineProperty(this, "isABotConversation", false);
|
|
14
|
+
_defineProperty(this, "isStarted", false);
|
|
15
|
+
_defineProperty(this, "isEnded", false);
|
|
16
|
+
_defineProperty(this, "startTrackingMessage", void 0);
|
|
17
|
+
_defineProperty(this, "stopTrackingMessage", void 0);
|
|
18
|
+
_defineProperty(this, "isReady", false);
|
|
19
|
+
_defineProperty(this, "offlineNetworkListener", BroadcastService.getMessageByEventName(TelemetryEvent.NetworkDisconnected).subscribe(() => {
|
|
20
|
+
this.isStarted = false;
|
|
21
|
+
this.isEnded = false;
|
|
22
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
23
|
+
Event: TelemetryEvent.MessageStopLapTrackError,
|
|
24
|
+
Description: "Tracker Stopped due to network disconnection"
|
|
25
|
+
});
|
|
26
|
+
}));
|
|
27
|
+
_defineProperty(this, "fmltrackingListener", BroadcastService.getMessageByEventName(BroadcastEvent.FMLTrackingCompleted).subscribe(() => {
|
|
28
|
+
this.isReady = true;
|
|
29
|
+
BroadcastService.postMessage({
|
|
30
|
+
eventName: BroadcastEvent.FMLTrackingCompletedAck,
|
|
31
|
+
payload: null
|
|
32
|
+
});
|
|
33
|
+
}));
|
|
34
|
+
// Rehydrate message is received when the widget is reloaded, this is to ensure that we are not tracking messages that are not part of the current conversation
|
|
35
|
+
// No need to keep listerning for tracking, enforcing disconnection for the listners
|
|
36
|
+
_defineProperty(this, "rehydrateListener", BroadcastService.getMessageByEventName(TelemetryEvent.RehydrateMessageReceivedCompleted).subscribe(() => {
|
|
37
|
+
this.isReady = true;
|
|
38
|
+
}));
|
|
39
|
+
// Rehydrate message is received when the widget is reloaded, this is to ensure that we are not tracking messages that are not part of the current conversation
|
|
40
|
+
// No need to keep listerning for tracking, enforcing disconnection for the listners
|
|
41
|
+
_defineProperty(this, "historyListener", BroadcastService.getMessageByEventName(BroadcastEvent.HistoryMessageReceived).subscribe(() => {
|
|
42
|
+
this.isReady = true;
|
|
43
|
+
}));
|
|
44
|
+
// this is a workaround to ensure in reload we track effectively the messages
|
|
45
|
+
// we do have a mechanism in place to prevent log agent messages.
|
|
46
|
+
this.isABotConversation = true;
|
|
47
|
+
}
|
|
48
|
+
_createClass(FirstResponseLatencyTracker, [{
|
|
49
|
+
key: "createTrackingMessage",
|
|
50
|
+
value: function createTrackingMessage(payload, type) {
|
|
51
|
+
return {
|
|
52
|
+
Id: payload.Id,
|
|
53
|
+
role: payload.role,
|
|
54
|
+
timestamp: payload === null || payload === void 0 ? void 0 : payload.timestamp,
|
|
55
|
+
tags: payload.tags,
|
|
56
|
+
messageType: payload.messageType,
|
|
57
|
+
text: payload.text,
|
|
58
|
+
type: type,
|
|
59
|
+
checkTime: new Date().getTime()
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Tracking Functions
|
|
64
|
+
}, {
|
|
65
|
+
key: "startTracking",
|
|
66
|
+
value: function startTracking(payload) {
|
|
67
|
+
if (!this.isReady) return;
|
|
68
|
+
// this prevents to initiate tracking for multiple incoming messages
|
|
69
|
+
if (this.isStarted) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// this is to ensure we track only messages where bot is engaged
|
|
73
|
+
if (!this.isABotConversation) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// control of states to prevent clashing of messages
|
|
77
|
+
this.isStarted = true;
|
|
78
|
+
this.isEnded = false;
|
|
79
|
+
// The idea of using types is to enrich telemetry data
|
|
80
|
+
this.startTrackingMessage = this.createTrackingMessage(payload, "userMessage");
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "handleAgentMessage",
|
|
84
|
+
value: function handleAgentMessage(payload) {
|
|
85
|
+
var _payload$tags;
|
|
86
|
+
// this tag so far is only present in agent messages
|
|
87
|
+
if (payload !== null && payload !== void 0 && (_payload$tags = payload.tags) !== null && _payload$tags !== void 0 && _payload$tags.includes("public")) {
|
|
88
|
+
this.deregister();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "stopTracking",
|
|
93
|
+
value: function stopTracking(payload) {
|
|
94
|
+
var _this$stopTrackingMes, _this$startTrackingMe;
|
|
95
|
+
// this prevents execution for multiple incoming messages from the bot.
|
|
96
|
+
if (this.isEnded && !this.isStarted) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// control of states to prevent clashing of messages
|
|
101
|
+
this.isEnded = true;
|
|
102
|
+
this.isStarted = false;
|
|
103
|
+
|
|
104
|
+
// The idea of using types is to enrich telemetry data
|
|
105
|
+
this.stopTrackingMessage = this.createTrackingMessage(payload, "botMessage");
|
|
106
|
+
// calculating elapsed time
|
|
107
|
+
const elapsedTime = (((_this$stopTrackingMes = this.stopTrackingMessage) === null || _this$stopTrackingMes === void 0 ? void 0 : _this$stopTrackingMes.checkTime) ?? 0) - (((_this$startTrackingMe = this.startTrackingMessage) === null || _this$startTrackingMe === void 0 ? void 0 : _this$startTrackingMe.checkTime) ?? 0);
|
|
108
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
109
|
+
Event: TelemetryEvent.MessageLapTrack,
|
|
110
|
+
Description: "First response latency tracking",
|
|
111
|
+
CustomProperties: {
|
|
112
|
+
elapsedTime,
|
|
113
|
+
userMessage: this.startTrackingMessage,
|
|
114
|
+
botMessage: this.stopTrackingMessage
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// mechanism to ensure we track only allowed conversations
|
|
120
|
+
}, {
|
|
121
|
+
key: "isMessageFromValidSender",
|
|
122
|
+
value: function isMessageFromValidSender(payload) {
|
|
123
|
+
var _payload$tags2;
|
|
124
|
+
// agent scenario
|
|
125
|
+
if (payload !== null && payload !== void 0 && (_payload$tags2 = payload.tags) !== null && _payload$tags2 !== void 0 && _payload$tags2.includes("public")) {
|
|
126
|
+
this.handleAgentMessage(payload);
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "startClock",
|
|
133
|
+
value: function startClock(payload) {
|
|
134
|
+
try {
|
|
135
|
+
if (!payload || !payload.Id) {
|
|
136
|
+
throw new Error("Invalid payload");
|
|
137
|
+
}
|
|
138
|
+
this.startTracking(payload);
|
|
139
|
+
} catch (e) {
|
|
140
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
141
|
+
Event: TelemetryEvent.MessageStartLapTrackError,
|
|
142
|
+
Description: "Error while starting the clock",
|
|
143
|
+
ExceptionDetails: e,
|
|
144
|
+
CustomProperties: {
|
|
145
|
+
payload: payload
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "stopClock",
|
|
152
|
+
value: function stopClock(payload) {
|
|
153
|
+
try {
|
|
154
|
+
if (!payload || !payload.Id) {
|
|
155
|
+
throw new Error("Invalid payload");
|
|
156
|
+
}
|
|
157
|
+
if (!this.isMessageFromValidSender(payload)) return;
|
|
158
|
+
if (this.isABotConversation && this.isStarted) {
|
|
159
|
+
this.stopTracking(payload);
|
|
160
|
+
}
|
|
161
|
+
} catch (e) {
|
|
162
|
+
console.error("FRL : error while trying to stop the tracker", e);
|
|
163
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
164
|
+
Event: TelemetryEvent.MessageStopLapTrackError,
|
|
165
|
+
Description: "Error while stopping the clock",
|
|
166
|
+
ExceptionDetails: e,
|
|
167
|
+
CustomProperties: {
|
|
168
|
+
payload: payload
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
//reset state
|
|
172
|
+
this.startTrackingMessage = undefined;
|
|
173
|
+
this.stopTrackingMessage = undefined;
|
|
174
|
+
this.isStarted = false;
|
|
175
|
+
this.isEnded = false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}, {
|
|
179
|
+
key: "deregister",
|
|
180
|
+
value: function deregister() {
|
|
181
|
+
// Reset State
|
|
182
|
+
this.isABotConversation = false;
|
|
183
|
+
this.isStarted = false;
|
|
184
|
+
this.isEnded = false;
|
|
185
|
+
this.startTrackingMessage = undefined;
|
|
186
|
+
this.stopTrackingMessage = undefined;
|
|
187
|
+
this.offlineNetworkListener.unsubscribe();
|
|
188
|
+
this.fmltrackingListener.unsubscribe();
|
|
189
|
+
this.rehydrateListener.unsubscribe();
|
|
190
|
+
this.historyListener.unsubscribe();
|
|
191
|
+
}
|
|
192
|
+
}]);
|
|
193
|
+
return FirstResponseLatencyTracker;
|
|
194
|
+
}();
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ScenarioType } from "./Constants";
|
|
2
|
+
import { Constants } from "../common/Constants";
|
|
3
|
+
export const isHistoryMessage = (activity, startTime) => {
|
|
4
|
+
try {
|
|
5
|
+
if ((activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message) {
|
|
6
|
+
var _activity$channelData, _activity$channelData2;
|
|
7
|
+
// this is an old piece of code, probably no longer relevant
|
|
8
|
+
if (activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(Constants.historyMessageTag)) return true;
|
|
9
|
+
|
|
10
|
+
// Id is an epoch time in milliseconds , in utc format, for some reason is in a string format
|
|
11
|
+
if (activity !== null && activity !== void 0 && activity.id) {
|
|
12
|
+
/// activity.id is an string that contains epoch time in milliseconds
|
|
13
|
+
const activityId = parseInt(activity === null || activity === void 0 ? void 0 : activity.id);
|
|
14
|
+
|
|
15
|
+
// if the activity id is not a number, we default to new message
|
|
16
|
+
if (isNaN(activityId)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// if the activity id is less than the start time, it means that the message is a history message
|
|
21
|
+
if (activityId < startTime) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// anything else will be considered a new message
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
// if there is an error in parsing the activity id, we will consider it a new message
|
|
30
|
+
console.error("Error in parsing activity id: ", e);
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
export const buildMessagePayload = (activity, userId) => {
|
|
35
|
+
var _text, _text2, _activity$channelData3, _activity$from;
|
|
36
|
+
return {
|
|
37
|
+
// To identify hidden contents vs empty content
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
text: (activity === null || activity === void 0 ? void 0 : (_text = activity.text) === null || _text === void 0 ? void 0 : _text.length) >= 1 ? `*contents hidden (${activity === null || activity === void 0 ? void 0 : (_text2 = activity.text) === null || _text2 === void 0 ? void 0 : _text2.length} chars)*` : "",
|
|
40
|
+
type: activity === null || activity === void 0 ? void 0 : activity.type,
|
|
41
|
+
timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
|
|
42
|
+
userId: userId,
|
|
43
|
+
tags: activity === null || activity === void 0 ? void 0 : (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 ? void 0 : _activity$channelData3.tags,
|
|
44
|
+
messageType: "",
|
|
45
|
+
Id: activity === null || activity === void 0 ? void 0 : activity.id,
|
|
46
|
+
role: activity === null || activity === void 0 ? void 0 : (_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role,
|
|
47
|
+
isChatComplete: false
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export const polyfillMessagePayloadForEvent = (activity, payload, conversationId) => {
|
|
51
|
+
var _activity$conversatio, _attachments, _activity$from2;
|
|
52
|
+
return {
|
|
53
|
+
...payload,
|
|
54
|
+
channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
|
|
55
|
+
chatId: activity === null || activity === void 0 ? void 0 : (_activity$conversatio = activity.conversation) === null || _activity$conversatio === void 0 ? void 0 : _activity$conversatio.id,
|
|
56
|
+
conversationId: conversationId,
|
|
57
|
+
Id: activity === null || activity === void 0 ? void 0 : activity.id,
|
|
58
|
+
isChatComplete: false,
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
+
text: activity === null || activity === void 0 ? void 0 : activity.text,
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
attachment: (activity === null || activity === void 0 ? void 0 : (_attachments = activity.attachments) === null || _attachments === void 0 ? void 0 : _attachments.length) >= 1 ? activity === null || activity === void 0 ? void 0 : activity.attachments : [],
|
|
63
|
+
role: activity === null || activity === void 0 ? void 0 : (_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export const getScenarioType = activity => {
|
|
67
|
+
var _activity$from3, _activity$channelData4, _activity$channelData5;
|
|
68
|
+
if ((activity === null || activity === void 0 ? void 0 : (_activity$from3 = activity.from) === null || _activity$from3 === void 0 ? void 0 : _activity$from3.role) === Constants.userMessageTag) {
|
|
69
|
+
return ScenarioType.UserSendMessageStrategy;
|
|
70
|
+
}
|
|
71
|
+
if (activity !== null && activity !== void 0 && (_activity$channelData4 = activity.channelData) !== null && _activity$channelData4 !== void 0 && (_activity$channelData5 = _activity$channelData4.tags) !== null && _activity$channelData5 !== void 0 && _activity$channelData5.includes(Constants.systemMessageTag)) {
|
|
72
|
+
return ScenarioType.SystemMessageStrategy;
|
|
73
|
+
}
|
|
74
|
+
return ScenarioType.ReceivedMessageStrategy;
|
|
75
|
+
};
|
|
76
|
+
export const createTrackingMessage = (payload, type) => {
|
|
77
|
+
return {
|
|
78
|
+
Id: payload.Id,
|
|
79
|
+
role: payload.role,
|
|
80
|
+
timestamp: payload === null || payload === void 0 ? void 0 : payload.timestamp,
|
|
81
|
+
tags: payload.tags,
|
|
82
|
+
messageType: payload.messageType,
|
|
83
|
+
text: payload.text,
|
|
84
|
+
type: type,
|
|
85
|
+
checkTime: new Date().getTime()
|
|
86
|
+
};
|
|
87
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
+
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); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
1
4
|
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; }
|
|
2
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
6
|
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); }
|
|
@@ -6,11 +9,12 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
6
9
|
import { createFileAndDownload } from "../common/utils";
|
|
7
10
|
import defaultLibraryScripts from "../components/footerstateful/downloadtranscriptstateful/common/defaultLibraryScripts";
|
|
8
11
|
import DOMPurify from "dompurify";
|
|
9
|
-
|
|
12
|
+
let TranscriptHTMLBuilder = /*#__PURE__*/function () {
|
|
10
13
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
function TranscriptHTMLBuilder(options) {
|
|
13
16
|
var _this$options, _this$options2, _this$options3, _this$options4, _this$options5, _this$options6, _this$options7, _this$options8, _this$options9, _this$options10, _this$options11, _this$options12, _this$options13;
|
|
17
|
+
_classCallCheck(this, TranscriptHTMLBuilder);
|
|
14
18
|
_defineProperty(this, "options", void 0);
|
|
15
19
|
_defineProperty(this, "pageTitle", "Customer Transcript");
|
|
16
20
|
_defineProperty(this, "attachmentMessage", "The following attachment was uploaded during the conversation: ");
|
|
@@ -70,59 +74,79 @@ class TranscriptHTMLBuilder {
|
|
|
70
74
|
this.externalScripts = this.options.externalScripts;
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
_createClass(TranscriptHTMLBuilder, [{
|
|
78
|
+
key: "createMetaElement",
|
|
79
|
+
value: function createMetaElement() {
|
|
80
|
+
const htmlData = `
|
|
75
81
|
<meta charset="UTF-8">
|
|
76
82
|
`;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
83
|
+
return htmlData;
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "createTitleElement",
|
|
87
|
+
value: function createTitleElement() {
|
|
88
|
+
const htmlData = `<title> ${this.pageTitle} </title>`;
|
|
89
|
+
return htmlData;
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "createScriptElement",
|
|
93
|
+
value: function createScriptElement(src) {
|
|
94
|
+
let integrity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
95
|
+
let crossOrigin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
96
|
+
let referrerPolicy = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
97
|
+
return `<script src="${src}" ${integrity ? `integrity="${integrity}"` : ""} ${crossOrigin ? `crossorigin="${crossOrigin}"` : ""} ${referrerPolicy ? `referrerpolicy="${referrerPolicy}"` : ""}><\/script>`;
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "createWebChatScriptElement",
|
|
101
|
+
value: function createWebChatScriptElement() {
|
|
102
|
+
var _this$externalScripts, _this$externalScripts2, _this$externalScripts3, _this$externalScripts4, _this$externalScripts5, _this$externalScripts6, _this$externalScripts7, _this$externalScripts8, _this$externalScripts9, _this$externalScripts10;
|
|
103
|
+
return (_this$externalScripts = this.externalScripts) !== null && _this$externalScripts !== void 0 && (_this$externalScripts2 = _this$externalScripts.botframeworkWebChat) !== null && _this$externalScripts2 !== void 0 && _this$externalScripts2.src ? this.createScriptElement((_this$externalScripts3 = this.externalScripts) === null || _this$externalScripts3 === void 0 ? void 0 : (_this$externalScripts4 = _this$externalScripts3.botframeworkWebChat) === null || _this$externalScripts4 === void 0 ? void 0 : _this$externalScripts4.src, (_this$externalScripts5 = this.externalScripts) === null || _this$externalScripts5 === void 0 ? void 0 : (_this$externalScripts6 = _this$externalScripts5.botframeworkWebChat) === null || _this$externalScripts6 === void 0 ? void 0 : _this$externalScripts6.integrity, (_this$externalScripts7 = this.externalScripts) === null || _this$externalScripts7 === void 0 ? void 0 : (_this$externalScripts8 = _this$externalScripts7.botframeworkWebChat) === null || _this$externalScripts8 === void 0 ? void 0 : _this$externalScripts8.crossOrigin, (_this$externalScripts9 = this.externalScripts) === null || _this$externalScripts9 === void 0 ? void 0 : (_this$externalScripts10 = _this$externalScripts9.botframeworkWebChat) === null || _this$externalScripts10 === void 0 ? void 0 : _this$externalScripts10.referrerPolicy) : this.createScriptElement(defaultLibraryScripts.botframeworkWebChat.src);
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "createRxJsScriptElement",
|
|
107
|
+
value: function createRxJsScriptElement() {
|
|
108
|
+
var _this$externalScripts11, _this$externalScripts12, _this$externalScripts13, _this$externalScripts14, _this$externalScripts15, _this$externalScripts16, _this$externalScripts17, _this$externalScripts18, _this$externalScripts19, _this$externalScripts20;
|
|
109
|
+
return (_this$externalScripts11 = this.externalScripts) !== null && _this$externalScripts11 !== void 0 && (_this$externalScripts12 = _this$externalScripts11.rxJs) !== null && _this$externalScripts12 !== void 0 && _this$externalScripts12.src ? this.createScriptElement((_this$externalScripts13 = this.externalScripts) === null || _this$externalScripts13 === void 0 ? void 0 : (_this$externalScripts14 = _this$externalScripts13.rxJs) === null || _this$externalScripts14 === void 0 ? void 0 : _this$externalScripts14.src, (_this$externalScripts15 = this.externalScripts) === null || _this$externalScripts15 === void 0 ? void 0 : (_this$externalScripts16 = _this$externalScripts15.rxJs) === null || _this$externalScripts16 === void 0 ? void 0 : _this$externalScripts16.integrity, (_this$externalScripts17 = this.externalScripts) === null || _this$externalScripts17 === void 0 ? void 0 : (_this$externalScripts18 = _this$externalScripts17.rxJs) === null || _this$externalScripts18 === void 0 ? void 0 : _this$externalScripts18.crossOrigin, (_this$externalScripts19 = this.externalScripts) === null || _this$externalScripts19 === void 0 ? void 0 : (_this$externalScripts20 = _this$externalScripts19.rxJs) === null || _this$externalScripts20 === void 0 ? void 0 : _this$externalScripts20.referrerPolicy) : this.createScriptElement(defaultLibraryScripts.rxJs.src, defaultLibraryScripts.rxJs.integrity, defaultLibraryScripts.rxJs.crossOrigin, defaultLibraryScripts.rxJs.referrerPolicy);
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "createReactScriptElement",
|
|
113
|
+
value: function createReactScriptElement() {
|
|
114
|
+
var _this$externalScripts21, _this$externalScripts22, _this$externalScripts23, _this$externalScripts24, _this$externalScripts25, _this$externalScripts26, _this$externalScripts27, _this$externalScripts28, _this$externalScripts29, _this$externalScripts30;
|
|
115
|
+
return (_this$externalScripts21 = this.externalScripts) !== null && _this$externalScripts21 !== void 0 && (_this$externalScripts22 = _this$externalScripts21.react) !== null && _this$externalScripts22 !== void 0 && _this$externalScripts22.src ? this.createScriptElement((_this$externalScripts23 = this.externalScripts) === null || _this$externalScripts23 === void 0 ? void 0 : (_this$externalScripts24 = _this$externalScripts23.react) === null || _this$externalScripts24 === void 0 ? void 0 : _this$externalScripts24.src, (_this$externalScripts25 = this.externalScripts) === null || _this$externalScripts25 === void 0 ? void 0 : (_this$externalScripts26 = _this$externalScripts25.react) === null || _this$externalScripts26 === void 0 ? void 0 : _this$externalScripts26.integrity, (_this$externalScripts27 = this.externalScripts) === null || _this$externalScripts27 === void 0 ? void 0 : (_this$externalScripts28 = _this$externalScripts27.react) === null || _this$externalScripts28 === void 0 ? void 0 : _this$externalScripts28.crossOrigin, (_this$externalScripts29 = this.externalScripts) === null || _this$externalScripts29 === void 0 ? void 0 : (_this$externalScripts30 = _this$externalScripts29.react) === null || _this$externalScripts30 === void 0 ? void 0 : _this$externalScripts30.referrerPolicy) : this.createScriptElement(defaultLibraryScripts.react.src);
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "createReactDomScriptElement",
|
|
119
|
+
value: function createReactDomScriptElement() {
|
|
120
|
+
var _this$externalScripts31, _this$externalScripts32, _this$externalScripts33, _this$externalScripts34, _this$externalScripts35, _this$externalScripts36, _this$externalScripts37, _this$externalScripts38, _this$externalScripts39, _this$externalScripts40, _this$externalScripts41, _this$externalScripts42;
|
|
121
|
+
return (_this$externalScripts31 = this.externalScripts) !== null && _this$externalScripts31 !== void 0 && (_this$externalScripts32 = _this$externalScripts31.reactDom) !== null && _this$externalScripts32 !== void 0 && _this$externalScripts32.src ? this.createScriptElement((_this$externalScripts33 = this.externalScripts) === null || _this$externalScripts33 === void 0 ? void 0 : (_this$externalScripts34 = _this$externalScripts33.reactDom) === null || _this$externalScripts34 === void 0 ? void 0 : _this$externalScripts34.src, (_this$externalScripts35 = this.externalScripts) === null || _this$externalScripts35 === void 0 ? void 0 : (_this$externalScripts36 = _this$externalScripts35.reactDom) === null || _this$externalScripts36 === void 0 ? void 0 : _this$externalScripts36.integrity, (_this$externalScripts37 = this.externalScripts) === null || _this$externalScripts37 === void 0 ? void 0 : (_this$externalScripts38 = _this$externalScripts37.reactDom) === null || _this$externalScripts38 === void 0 ? void 0 : _this$externalScripts38.crossOrigin, (_this$externalScripts39 = this.externalScripts) === null || _this$externalScripts39 === void 0 ? void 0 : (_this$externalScripts40 = _this$externalScripts39.reactDom) === null || _this$externalScripts40 === void 0 ? void 0 : _this$externalScripts40.referrerPolicy) : this.createScriptElement(((_this$externalScripts41 = this.externalScripts) === null || _this$externalScripts41 === void 0 ? void 0 : (_this$externalScripts42 = _this$externalScripts41.reactDom) === null || _this$externalScripts42 === void 0 ? void 0 : _this$externalScripts42.src) ?? defaultLibraryScripts.reactDom.src);
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "createMarkdownItScriptElement",
|
|
125
|
+
value: function createMarkdownItScriptElement() {
|
|
126
|
+
var _this$externalScripts43, _this$externalScripts44, _this$externalScripts45, _this$externalScripts46, _this$externalScripts47, _this$externalScripts48, _this$externalScripts49, _this$externalScripts50, _this$externalScripts51, _this$externalScripts52;
|
|
127
|
+
return (_this$externalScripts43 = this.externalScripts) !== null && _this$externalScripts43 !== void 0 && (_this$externalScripts44 = _this$externalScripts43.markdownIt) !== null && _this$externalScripts44 !== void 0 && _this$externalScripts44.src ? this.createScriptElement((_this$externalScripts45 = this.externalScripts) === null || _this$externalScripts45 === void 0 ? void 0 : (_this$externalScripts46 = _this$externalScripts45.markdownIt) === null || _this$externalScripts46 === void 0 ? void 0 : _this$externalScripts46.src, (_this$externalScripts47 = this.externalScripts) === null || _this$externalScripts47 === void 0 ? void 0 : (_this$externalScripts48 = _this$externalScripts47.markdownIt) === null || _this$externalScripts48 === void 0 ? void 0 : _this$externalScripts48.integrity, (_this$externalScripts49 = this.externalScripts) === null || _this$externalScripts49 === void 0 ? void 0 : (_this$externalScripts50 = _this$externalScripts49.markdownIt) === null || _this$externalScripts50 === void 0 ? void 0 : _this$externalScripts50.crossOrigin, (_this$externalScripts51 = this.externalScripts) === null || _this$externalScripts51 === void 0 ? void 0 : (_this$externalScripts52 = _this$externalScripts51.markdownIt) === null || _this$externalScripts52 === void 0 ? void 0 : _this$externalScripts52.referrerPolicy) : this.createScriptElement(defaultLibraryScripts.markdownIt.src, defaultLibraryScripts.markdownIt.integrity, defaultLibraryScripts.markdownIt.crossOrigin);
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "createExternalScriptElements",
|
|
131
|
+
value: function createExternalScriptElements() {
|
|
132
|
+
const webChatScript = this.createWebChatScriptElement();
|
|
133
|
+
const rxJsScript = this.createRxJsScriptElement();
|
|
134
|
+
const reactScript = this.createReactScriptElement();
|
|
135
|
+
const reactDomScript = this.createReactDomScriptElement();
|
|
136
|
+
const markdownItScript = this.createMarkdownItScriptElement();
|
|
137
|
+
const htmlData = `
|
|
116
138
|
${webChatScript}
|
|
117
139
|
${rxJsScript}
|
|
118
140
|
${reactScript}
|
|
119
141
|
${reactDomScript}
|
|
120
142
|
${markdownItScript}
|
|
121
143
|
`;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
144
|
+
return htmlData;
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "createHeadElement",
|
|
148
|
+
value: function createHeadElement() {
|
|
149
|
+
const htmlData = `
|
|
126
150
|
<head>
|
|
127
151
|
${this.createMetaElement()}
|
|
128
152
|
${this.createTitleElement()}
|
|
@@ -168,7 +192,7 @@ class TranscriptHTMLBuilder {
|
|
|
168
192
|
<script>
|
|
169
193
|
class Translator {
|
|
170
194
|
static convertTranscriptMessageToActivity(message) {
|
|
171
|
-
const {created, OriginalMessageId, id, isControlMessage, content, tags, from, attachments, amsMetadata, amsReferences} = message;
|
|
195
|
+
const {created, OriginalMessageId, id, isControlMessage, content, tags, from, attachments, amsMetadata, amsReferences, amsreferences} = message;
|
|
172
196
|
|
|
173
197
|
//it's required to convert the id to a number, otherwise the webchat will not render the messages in the correct order
|
|
174
198
|
// if the OrginalMessageId is not present, we can use the id as the sequence id, which is always present.
|
|
@@ -215,7 +239,7 @@ class TranscriptHTMLBuilder {
|
|
|
215
239
|
}
|
|
216
240
|
|
|
217
241
|
// Attachments
|
|
218
|
-
if (amsReferences && amsMetadata) {
|
|
242
|
+
if ((amsReferences || amsreferences) && amsMetadata) {
|
|
219
243
|
const metadata = JSON.parse(amsMetadata);
|
|
220
244
|
const { fileName } = metadata[0];
|
|
221
245
|
const text = \`${this.attachmentMessage}\${fileName}\`;
|
|
@@ -239,7 +263,7 @@ class TranscriptHTMLBuilder {
|
|
|
239
263
|
// Message
|
|
240
264
|
if (content) {
|
|
241
265
|
// Adaptive card formatting
|
|
242
|
-
if (content.includes('"
|
|
266
|
+
if (content.includes('"attachments"') || content.includes('"suggestedActions"')) {
|
|
243
267
|
try {
|
|
244
268
|
const partialActivity = JSON.parse(content);
|
|
245
269
|
return {
|
|
@@ -362,10 +386,12 @@ class TranscriptHTMLBuilder {
|
|
|
362
386
|
<\/style>
|
|
363
387
|
</head>
|
|
364
388
|
`;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
389
|
+
return htmlData;
|
|
390
|
+
}
|
|
391
|
+
}, {
|
|
392
|
+
key: "createBodyElement",
|
|
393
|
+
value: function createBodyElement() {
|
|
394
|
+
const htmlData = `
|
|
369
395
|
<body>
|
|
370
396
|
<script>
|
|
371
397
|
if (!navigator.onLine) {
|
|
@@ -646,18 +672,22 @@ class TranscriptHTMLBuilder {
|
|
|
646
672
|
<\/script>
|
|
647
673
|
</body>
|
|
648
674
|
`;
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
675
|
+
return htmlData;
|
|
676
|
+
}
|
|
677
|
+
}, {
|
|
678
|
+
key: "createHTML",
|
|
679
|
+
value: function createHTML() {
|
|
680
|
+
const htmlData = `
|
|
653
681
|
<html>
|
|
654
682
|
${this.createHeadElement()}
|
|
655
683
|
${this.createBodyElement()}
|
|
656
684
|
</html>
|
|
657
685
|
`;
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
}
|
|
686
|
+
return htmlData;
|
|
687
|
+
}
|
|
688
|
+
}]);
|
|
689
|
+
return TranscriptHTMLBuilder;
|
|
690
|
+
}();
|
|
661
691
|
const createChatTranscript = async function (transcript, facadeChatSDK) {
|
|
662
692
|
let renderAttachments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
663
693
|
let transcriptOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
@@ -678,7 +708,7 @@ const createChatTranscript = async function (transcript, facadeChatSDK) {
|
|
|
678
708
|
messages = await Promise.all(transcriptMessages.map(async message => {
|
|
679
709
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
680
710
|
const {
|
|
681
|
-
amsReferences,
|
|
711
|
+
amsReferences = message.amsreferences,
|
|
682
712
|
amsMetadata
|
|
683
713
|
} = message;
|
|
684
714
|
if (amsReferences && amsMetadata) {
|