@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
|
@@ -1,10 +1,14 @@
|
|
|
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); }
|
|
4
7
|
import MockAdapter from "./mockadapter";
|
|
5
8
|
import { ParticipantType } from "../../../common/Constants";
|
|
6
|
-
export
|
|
7
|
-
|
|
9
|
+
export let MockChatSDK = /*#__PURE__*/function () {
|
|
10
|
+
function MockChatSDK() {
|
|
11
|
+
_classCallCheck(this, MockChatSDK);
|
|
8
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
13
|
_defineProperty(this, "sleep", ms => new Promise(r => setTimeout(r, ms)));
|
|
10
14
|
_defineProperty(this, "isMockModeOn", true);
|
|
@@ -14,63 +18,93 @@ export class MockChatSDK {
|
|
|
14
18
|
orgUrl: "https://contoso.crm.dynamics.com"
|
|
15
19
|
});
|
|
16
20
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
_createClass(MockChatSDK, [{
|
|
22
|
+
key: "initialize",
|
|
23
|
+
value: async function initialize() {
|
|
24
|
+
return this.getLiveChatConfig();
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
key: "startChat",
|
|
28
|
+
value: async function startChat() {
|
|
29
|
+
await this.sleep(1000);
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
key: "endChat",
|
|
33
|
+
value: function endChat() {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
key: "getChatToken",
|
|
38
|
+
value: function getChatToken() {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "createChatAdapter",
|
|
43
|
+
value: function createChatAdapter() {
|
|
44
|
+
return new MockAdapter();
|
|
45
|
+
}
|
|
32
46
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
48
|
+
}, {
|
|
49
|
+
key: "getPreChatSurvey",
|
|
50
|
+
value: function getPreChatSurvey(parseToJson) {
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
key: "getConversationDetails",
|
|
55
|
+
value: function getConversationDetails() {
|
|
56
|
+
return {
|
|
57
|
+
State: "Active",
|
|
58
|
+
conversationId: "",
|
|
59
|
+
canRenderPostChat: "",
|
|
60
|
+
participantType: ParticipantType.User
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "getCurrentLiveChatContext",
|
|
65
|
+
value: function getCurrentLiveChatContext() {
|
|
66
|
+
return {
|
|
67
|
+
chatToken: {},
|
|
68
|
+
requestId: ""
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "onNewMessage",
|
|
73
|
+
value: function onNewMessage() {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "getChatReconnectContext",
|
|
78
|
+
value: function getChatReconnectContext() {
|
|
79
|
+
return {
|
|
80
|
+
reconnectId: "123"
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "getVoiceVideoCalling",
|
|
85
|
+
value: function getVoiceVideoCalling() {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "setAuthTokenProvider",
|
|
90
|
+
value: function setAuthTokenProvider() {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
key: "getLiveChatConfig",
|
|
95
|
+
value: function getLiveChatConfig() {
|
|
96
|
+
return {
|
|
97
|
+
LiveWSAndLiveChatEngJoin: {
|
|
98
|
+
msdyn_postconversationsurveyenable: "true",
|
|
99
|
+
msdyn_conversationmode: "192350000"
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
key: "sendTypingEvent",
|
|
105
|
+
value: function sendTypingEvent() {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}]);
|
|
109
|
+
return MockChatSDK;
|
|
110
|
+
}();
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
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); } }
|
|
2
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
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); }
|
|
4
|
-
export
|
|
7
|
+
export let BotMagicCodeStore = /*#__PURE__*/_createClass(function BotMagicCodeStore() {
|
|
8
|
+
_classCallCheck(this, BotMagicCodeStore);
|
|
9
|
+
});
|
|
5
10
|
_defineProperty(BotMagicCodeStore, "botOAuthSignInId", "");
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
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); } }
|
|
2
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
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); }
|
|
4
|
-
export
|
|
7
|
+
export let WebChatStoreLoader = /*#__PURE__*/_createClass(function WebChatStoreLoader() {
|
|
8
|
+
_classCallCheck(this, WebChatStoreLoader);
|
|
9
|
+
});
|
|
5
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
11
|
_defineProperty(WebChatStoreLoader, "store", void 0);
|
|
@@ -1,56 +1,70 @@
|
|
|
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); }
|
|
4
7
|
import DOMPurify from "dompurify";
|
|
5
8
|
import { HtmlAttributeNames } from "../../../../common/Constants";
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
let HyperlinkTextOverrideRenderer = /*#__PURE__*/function () {
|
|
10
|
+
function HyperlinkTextOverrideRenderer(hyperlinkTextOverride) {
|
|
11
|
+
_classCallCheck(this, HyperlinkTextOverrideRenderer);
|
|
8
12
|
_defineProperty(this, "hyperlinkTextOverride", void 0);
|
|
9
13
|
this.hyperlinkTextOverride = hyperlinkTextOverride;
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
_createClass(HyperlinkTextOverrideRenderer, [{
|
|
16
|
+
key: "convertTextToHtmlNode",
|
|
17
|
+
value: function convertTextToHtmlNode(text) {
|
|
18
|
+
const htmlNode = document.createElement(HtmlAttributeNames.div);
|
|
19
|
+
try {
|
|
20
|
+
text = DOMPurify.sanitize(text, {
|
|
21
|
+
ADD_ATTR: ["target"]
|
|
22
|
+
});
|
|
23
|
+
htmlNode.innerHTML = text;
|
|
24
|
+
} catch {
|
|
25
|
+
return htmlNode;
|
|
26
|
+
}
|
|
19
27
|
return htmlNode;
|
|
20
28
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
}, {
|
|
30
|
+
key: "processANode",
|
|
31
|
+
value: function processANode(htmlNode) {
|
|
32
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
33
|
+
const aTags = htmlNode.getElementsByTagName(HtmlAttributeNames.aTagName);
|
|
34
|
+
for (let index = 0; index < aTags.length; index++) {
|
|
35
|
+
const aNode = aTags[index];
|
|
36
|
+
if (!aNode || !aNode.tagName || aNode.tagName.toLowerCase() !== HtmlAttributeNames.aTagName || !aNode.href) continue;
|
|
37
|
+
if (aNode.href !== aNode.text.trim()) {
|
|
38
|
+
aNode.text = aNode.href;
|
|
39
|
+
}
|
|
31
40
|
}
|
|
32
41
|
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
}, {
|
|
43
|
+
key: "applicable",
|
|
44
|
+
value: function applicable(text) {
|
|
45
|
+
if (!this.hyperlinkTextOverride) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const htmlNode = this.convertTextToHtmlNode(text);
|
|
50
|
+
const aNodes = htmlNode.getElementsByTagName(HtmlAttributeNames.aTagName);
|
|
51
|
+
return !!aNodes && aNodes.length && aNodes.length > 0;
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
37
55
|
}
|
|
38
|
-
|
|
56
|
+
}, {
|
|
57
|
+
key: "render",
|
|
58
|
+
value: function render(text) {
|
|
59
|
+
if (!this.applicable(text)) {
|
|
60
|
+
return text;
|
|
61
|
+
}
|
|
39
62
|
const htmlNode = this.convertTextToHtmlNode(text);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} catch {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
render(text) {
|
|
47
|
-
if (!this.applicable(text)) {
|
|
63
|
+
this.processANode(htmlNode);
|
|
64
|
+
text = htmlNode.innerHTML;
|
|
48
65
|
return text;
|
|
49
66
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return text;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
67
|
+
}]);
|
|
68
|
+
return HyperlinkTextOverrideRenderer;
|
|
69
|
+
}();
|
|
56
70
|
export default HyperlinkTextOverrideRenderer;
|
|
@@ -35,6 +35,10 @@ export const DeliveredTimestamp = _ref => {
|
|
|
35
35
|
return /*#__PURE__*/React.createElement("span", {
|
|
36
36
|
dir: "ltr"
|
|
37
37
|
}, getTimestampHourMinute(timestamp));
|
|
38
|
+
} else {
|
|
39
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
40
|
+
dir: dir
|
|
41
|
+
}, getTimestampHourMinute(timestamp));
|
|
38
42
|
}
|
|
39
43
|
return timeString;
|
|
40
44
|
};
|
|
@@ -1,3 +1,8 @@
|
|
|
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 _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
5
|
+
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); }
|
|
1
6
|
import { HtmlClassNames, HtmlIdNames } from "../../../../common/Constants";
|
|
2
7
|
import { NotificationLevel } from "../enums/NotificationLevel";
|
|
3
8
|
import { WebChatActionType } from "../enums/WebChatActionType";
|
|
@@ -5,73 +10,96 @@ import { WebChatStoreLoader } from "../WebChatStoreLoader";
|
|
|
5
10
|
import { setFocusOnSendBox } from "../../../../common/utils";
|
|
6
11
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
12
|
import { BroadcastEvent } from "../../../../common/telemetry/TelemetryConstants";
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
WebChatStoreLoader.store.dispatch({
|
|
12
|
-
type: WebChatActionType.WEB_CHAT_SET_NOTIFICATION,
|
|
13
|
-
payload: {
|
|
14
|
-
id,
|
|
15
|
-
level,
|
|
16
|
-
message
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
NotificationHandler.setFocusOnNotificationCloseButton();
|
|
20
|
-
}
|
|
13
|
+
export let NotificationHandler = /*#__PURE__*/function () {
|
|
14
|
+
function NotificationHandler() {
|
|
15
|
+
_classCallCheck(this, NotificationHandler);
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
_createClass(NotificationHandler, null, [{
|
|
18
|
+
key: "notify",
|
|
19
|
+
value: function notify(id, level, message) {
|
|
20
|
+
if (WebChatStoreLoader.store) {
|
|
21
|
+
WebChatStoreLoader.store.dispatch({
|
|
22
|
+
type: WebChatActionType.WEB_CHAT_SET_NOTIFICATION,
|
|
23
|
+
payload: {
|
|
24
|
+
id,
|
|
25
|
+
level,
|
|
26
|
+
message
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
NotificationHandler.setFocusOnNotificationCloseButton();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
key: "dismissNotification",
|
|
34
|
+
value: function dismissNotification(id) {
|
|
35
|
+
if (WebChatStoreLoader.store) {
|
|
36
|
+
WebChatStoreLoader.store.dispatch({
|
|
37
|
+
type: WebChatActionType.WEB_CHAT_DISMISS_NOTIFICATION,
|
|
38
|
+
payload: {
|
|
39
|
+
id
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
key: "notifyError",
|
|
46
|
+
value: function notifyError(id, message) {
|
|
47
|
+
BroadcastService.postMessage({
|
|
48
|
+
eventName: BroadcastEvent.OnWidgetError,
|
|
26
49
|
payload: {
|
|
27
|
-
|
|
50
|
+
errorMessage: message
|
|
28
51
|
}
|
|
29
52
|
});
|
|
53
|
+
this.notify(id, NotificationLevel.Error, message);
|
|
30
54
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
55
|
+
}, {
|
|
56
|
+
key: "notifyWarning",
|
|
57
|
+
value: function notifyWarning(id, message) {
|
|
58
|
+
this.notify(id, NotificationLevel.Warning, message);
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "notifyInfo",
|
|
62
|
+
value: function notifyInfo(id, message) {
|
|
63
|
+
this.notify(id, NotificationLevel.Info, message);
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "notifySuccess",
|
|
67
|
+
value: function notifySuccess(id, message) {
|
|
68
|
+
this.notify(id, NotificationLevel.Success, message);
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
key: "notifyWithLevel",
|
|
72
|
+
value: function notifyWithLevel(id, message, level) {
|
|
73
|
+
if (!level) {
|
|
74
|
+
this.notifyInfo(id, message);
|
|
75
|
+
} else {
|
|
76
|
+
this.notify(id, level, message);
|
|
37
77
|
}
|
|
38
|
-
});
|
|
39
|
-
this.notify(id, NotificationLevel.Error, message);
|
|
40
|
-
}
|
|
41
|
-
static notifyWarning(id, message) {
|
|
42
|
-
this.notify(id, NotificationLevel.Warning, message);
|
|
43
|
-
}
|
|
44
|
-
static notifyInfo(id, message) {
|
|
45
|
-
this.notify(id, NotificationLevel.Info, message);
|
|
46
|
-
}
|
|
47
|
-
static notifySuccess(id, message) {
|
|
48
|
-
this.notify(id, NotificationLevel.Success, message);
|
|
49
|
-
}
|
|
50
|
-
static notifyWithLevel(id, message, level) {
|
|
51
|
-
if (!level) {
|
|
52
|
-
this.notifyInfo(id, message);
|
|
53
|
-
} else {
|
|
54
|
-
this.notify(id, level, message);
|
|
55
78
|
}
|
|
56
|
-
}
|
|
57
79
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
expandButton.
|
|
63
|
-
|
|
80
|
+
/* Bypass WebChat behavior and focus on banner close button */
|
|
81
|
+
}, {
|
|
82
|
+
key: "setFocusOnNotificationCloseButton",
|
|
83
|
+
value: function setFocusOnNotificationCloseButton() {
|
|
84
|
+
const expandButton = document.querySelector(`#${HtmlIdNames.MSLiveChatWidget} .${HtmlClassNames.webChatBannerExpandButton}`);
|
|
85
|
+
if (expandButton) {
|
|
86
|
+
expandButton.focus();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const closeButton = document.querySelector(`#${HtmlIdNames.MSLiveChatWidget} .${HtmlClassNames.webChatBannerCloseButton}`);
|
|
90
|
+
if (closeButton) {
|
|
91
|
+
closeButton.focus();
|
|
92
|
+
NotificationHandler.registerOnCloseEvent(closeButton);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
64
95
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
96
|
+
}, {
|
|
97
|
+
key: "registerOnCloseEvent",
|
|
98
|
+
value: function registerOnCloseEvent(button) {
|
|
99
|
+
button.onclick = () => {
|
|
100
|
+
setFocusOnSendBox();
|
|
101
|
+
};
|
|
70
102
|
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
setFocusOnSendBox();
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
103
|
+
}]);
|
|
104
|
+
return NotificationHandler;
|
|
105
|
+
}();
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { ConversationState } from "./ConversationState";
|
|
2
|
-
import { defaultMiddlewareLocalizedTexts } from "../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
3
|
-
import { getWidgetCacheIdfromProps, isNullOrUndefined } from "../../common/utils";
|
|
4
|
-
import { defaultClientDataStoreProvider } from "../../common/storage/default/defaultClientDataStoreProvider";
|
|
5
1
|
import { ConfirmationState, Constants, ConversationEndEntity, StorageType } from "../../common/Constants";
|
|
2
|
+
import { getWidgetCacheIdfromProps, isNullOrUndefined } from "../../common/utils";
|
|
3
|
+
import { ConversationState } from "./ConversationState";
|
|
6
4
|
import { StartChatFailureType } from "./StartChatFailureType";
|
|
5
|
+
import { defaultClientDataStoreProvider } from "../../common/storage/default/defaultClientDataStoreProvider";
|
|
6
|
+
import { defaultMiddlewareLocalizedTexts } from "../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
7
7
|
export const getLiveChatWidgetContextInitialState = props => {
|
|
8
8
|
var _props$controlProps, _props$webChatContain;
|
|
9
|
+
const isOutsideOperatingHours = () => {
|
|
10
|
+
var _props$chatConfig, _props$chatConfig$Liv, _props$chatConfig$Liv2;
|
|
11
|
+
return ((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : (_props$chatConfig$Liv2 = _props$chatConfig$Liv.OutOfOperatingHours) === null || _props$chatConfig$Liv2 === void 0 ? void 0 : _props$chatConfig$Liv2.toString().toLowerCase()) === "true";
|
|
12
|
+
};
|
|
9
13
|
const widgetCacheId = getWidgetCacheIdfromProps(props);
|
|
10
14
|
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.cacheTtlInMins) ?? Constants.CacheTtlInMinutes;
|
|
11
15
|
const storageType = (props === null || props === void 0 ? void 0 : props.useSessionStorage) === true ? StorageType.sessionStorage : StorageType.localStorage;
|
|
@@ -22,6 +26,14 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
22
26
|
if (initialStateFromCache.appStates.conversationState === ConversationState.Prechat) {
|
|
23
27
|
initialStateFromCache.appStates.conversationState = ConversationState.Closed;
|
|
24
28
|
}
|
|
29
|
+
|
|
30
|
+
// we are always setting the chatConfig from the props to avoid any issues with the cache
|
|
31
|
+
initialStateFromCache.domainStates.liveChatConfig = props.chatConfig;
|
|
32
|
+
|
|
33
|
+
// Cache the result of isOutsideOperatingHours() to ensure consistency
|
|
34
|
+
const outsideOperatingHours = isOutsideOperatingHours();
|
|
35
|
+
initialStateFromCache.appStates.outsideOperatingHours = outsideOperatingHours;
|
|
36
|
+
initialStateFromCache.appStates.conversationState = outsideOperatingHours ? ConversationState.OutOfOffice : initialStateFromCache.appStates.conversationState;
|
|
25
37
|
return initialStateFromCache;
|
|
26
38
|
}
|
|
27
39
|
const LiveChatWidgetContextInitialState = {
|
|
@@ -46,11 +58,11 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
46
58
|
startChatFailureType: StartChatFailureType.Generic
|
|
47
59
|
},
|
|
48
60
|
appStates: {
|
|
49
|
-
conversationState: ConversationState.Closed,
|
|
61
|
+
conversationState: isOutsideOperatingHours() ? ConversationState.OutOfOffice : ConversationState.Closed,
|
|
50
62
|
isMinimized: undefined,
|
|
51
63
|
previousElementIdOnFocusBeforeModalOpen: null,
|
|
52
64
|
startChatFailed: false,
|
|
53
|
-
outsideOperatingHours:
|
|
65
|
+
outsideOperatingHours: isOutsideOperatingHours(),
|
|
54
66
|
preChatResponseEmail: "",
|
|
55
67
|
isAudioMuted: null,
|
|
56
68
|
newMessage: false,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export let ScenarioType;
|
|
2
|
+
(function (ScenarioType) {
|
|
3
|
+
ScenarioType["UserSendMessageStrategy"] = "UserSendMessageStrategy";
|
|
4
|
+
ScenarioType["SystemMessageStrategy"] = "SystemMessageStrategy";
|
|
5
|
+
ScenarioType["ReceivedMessageStrategy"] = "ReceivedMessageStrategy";
|
|
6
|
+
})(ScenarioType || (ScenarioType = {}));
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
3
|
+
import { TelemetryHelper } from "../common/telemetry/TelemetryHelper";
|
|
4
|
+
import { createTrackingMessage } from "./util";
|
|
5
|
+
|
|
6
|
+
// This tracker is event based, this is since we are tracking events coming from different sources
|
|
7
|
+
// with different timeline, therefore this is a functional approach to track the events, instead of a class based approach
|
|
8
|
+
export const createTrackingForFirstMessage = () => {
|
|
9
|
+
// Reset the tracking variables
|
|
10
|
+
let startTracking = false;
|
|
11
|
+
let stopTracking = false;
|
|
12
|
+
let startTime = 0;
|
|
13
|
+
let stopTime = 0;
|
|
14
|
+
let stopTrackingMessage;
|
|
15
|
+
let flag = false;
|
|
16
|
+
const isMessageFromValidSender = payload => {
|
|
17
|
+
var _payload$tags;
|
|
18
|
+
// agent scenario
|
|
19
|
+
if (payload !== null && payload !== void 0 && (_payload$tags = payload.tags) !== null && _payload$tags !== void 0 && _payload$tags.includes("public")) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
const widgetLoadListener = BroadcastService.getMessageByEventName(TelemetryEvent.WidgetStartChatCompleted).subscribe(() => {
|
|
25
|
+
if (startTracking) return;
|
|
26
|
+
startTracking = true;
|
|
27
|
+
startTime = new Date().getTime();
|
|
28
|
+
});
|
|
29
|
+
const newMessageListener = BroadcastService.getMessageByEventName(BroadcastEvent.NewMessageReceived).subscribe(message => {
|
|
30
|
+
const payload = message.payload;
|
|
31
|
+
|
|
32
|
+
// we only care for bot, so we need to check if the message is from the bot
|
|
33
|
+
// pending to add typing message indicator signal detection
|
|
34
|
+
|
|
35
|
+
if (isMessageFromValidSender(payload)) {
|
|
36
|
+
if (startTracking && !stopTracking) {
|
|
37
|
+
stopTime = new Date().getTime();
|
|
38
|
+
const elapsedTime = stopTime - startTime;
|
|
39
|
+
stopTracking = true;
|
|
40
|
+
stopTrackingMessage = createTrackingMessage(payload, "botMessage");
|
|
41
|
+
notifyFMLTrackingCompleted();
|
|
42
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
43
|
+
Event: TelemetryEvent.BotFirstMessageLapTrack,
|
|
44
|
+
Description: "First Message from Bot latency tracking",
|
|
45
|
+
CustomProperties: {
|
|
46
|
+
elapsedTime,
|
|
47
|
+
widgetLoadedAt: startTime,
|
|
48
|
+
botMessage: stopTrackingMessage
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// this track only first message, if coming from the bot or not
|
|
55
|
+
// the only difference is that it logs only those from bot
|
|
56
|
+
disconnectListener();
|
|
57
|
+
});
|
|
58
|
+
const notifyFMLTrackingCompleted = () => {
|
|
59
|
+
ackListener();
|
|
60
|
+
// Retry sending until flag is true, but do not block the main thread
|
|
61
|
+
const interval = setInterval(() => {
|
|
62
|
+
if (flag) {
|
|
63
|
+
clearInterval(interval);
|
|
64
|
+
} else {
|
|
65
|
+
BroadcastService.postMessage({
|
|
66
|
+
eventName: BroadcastEvent.FMLTrackingCompleted,
|
|
67
|
+
payload: null
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}, 100);
|
|
71
|
+
};
|
|
72
|
+
const ackListener = () => {
|
|
73
|
+
const listen = BroadcastService.getMessageByEventName(BroadcastEvent.FMLTrackingCompletedAck).subscribe(() => {
|
|
74
|
+
flag = true;
|
|
75
|
+
listen.unsubscribe();
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// 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
|
|
80
|
+
// No need to keep listerning for tracking, enforcing disconnection for the listners
|
|
81
|
+
const rehydrateListener = BroadcastService.getMessageByEventName(TelemetryEvent.RehydrateMessageReceivedCompleted).subscribe(() => {
|
|
82
|
+
startTracking = false;
|
|
83
|
+
stopTracking = false;
|
|
84
|
+
disconnectListener();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// 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
|
|
88
|
+
// No need to keep listerning for tracking, enforcing disconnection for the listners
|
|
89
|
+
const historyListener = BroadcastService.getMessageByEventName(BroadcastEvent.HistoryMessageReceived).subscribe(() => {
|
|
90
|
+
startTracking = false;
|
|
91
|
+
stopTracking = false;
|
|
92
|
+
disconnectListener();
|
|
93
|
+
});
|
|
94
|
+
const offlineNetworkListener = BroadcastService.getMessageByEventName(TelemetryEvent.NetworkDisconnected).subscribe(() => {
|
|
95
|
+
startTracking = false;
|
|
96
|
+
stopTracking = false;
|
|
97
|
+
disconnectListener();
|
|
98
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
99
|
+
Event: TelemetryEvent.BotFirstMessageLapTrackError,
|
|
100
|
+
Description: "Tracker Stopped due to network disconnection"
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// this is to ensure that we are not tracking messages that are not part of the current conversation
|
|
105
|
+
const disconnectListener = () => {
|
|
106
|
+
historyListener.unsubscribe();
|
|
107
|
+
rehydrateListener.unsubscribe();
|
|
108
|
+
newMessageListener.unsubscribe();
|
|
109
|
+
widgetLoadListener.unsubscribe();
|
|
110
|
+
offlineNetworkListener.unsubscribe();
|
|
111
|
+
};
|
|
112
|
+
};
|