@microsoft/omnichannel-chat-widget 1.8.2-main.fc93d3d → 1.8.3-main.1381896
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -1
- package/lib/cjs/common/Constants.js +10 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +7 -5
- package/lib/cjs/common/utils.js +27 -2
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
- package/lib/cjs/components/citationpanestateful/CitationDim.js +29 -0
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +199 -0
- package/lib/cjs/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +70 -0
- package/lib/cjs/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +4 -4
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +54 -1
- package/lib/cjs/components/livechatwidget/common/customEventHandler.js +53 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +34 -4
- package/lib/cjs/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +12 -5
- package/lib/cjs/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +23 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +8 -6
- package/lib/cjs/components/livechatwidget/interfaces/IMockProps.js +8 -2
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +45 -11
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +114 -13
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -12
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +62 -3
- package/lib/cjs/components/webchatcontainerstateful/common/utils/fontUtils.js +28 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +42 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +139 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +41 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +54 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +45 -0
- package/lib/cjs/contexts/common/CustomEventType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +46 -45
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
- package/lib/cjs/firstresponselatency/util.js +24 -10
- package/lib/cjs/index.js +9 -1
- package/lib/cjs/plugins/createChatTranscript.js +13 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +2 -2
- package/lib/esm/common/Constants.js +10 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +6 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +7 -5
- package/lib/esm/common/utils.js +21 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
- package/lib/esm/components/citationpanestateful/CitationDim.js +20 -0
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +188 -0
- package/lib/esm/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.js +61 -0
- package/lib/esm/components/confirmationpanestateful/interfaces/IConfirmationPaneLocalizedTexts.js +1 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +4 -4
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +4 -5
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +54 -1
- package/lib/esm/components/livechatwidget/common/customEventHandler.js +45 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +35 -5
- package/lib/esm/components/livechatwidget/common/getMockChatSDKIfApplicable.js +4 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -6
- package/lib/esm/components/livechatwidget/common/overridePropsOnMockIfApplicable.js +2 -1
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +23 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +8 -6
- package/lib/esm/components/livechatwidget/interfaces/IMockProps.js +3 -3
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +45 -11
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +114 -14
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +43 -12
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatSDK.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +55 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/fontUtils.js +21 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/ICitation.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +36 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +133 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +33 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +46 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +38 -0
- package/lib/esm/contexts/common/CustomEventType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +46 -45
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -0
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
- package/lib/esm/firstresponselatency/util.js +21 -8
- package/lib/esm/index.js +1 -0
- package/lib/esm/plugins/createChatTranscript.js +13 -0
- package/lib/esm/plugins/newMessageEventHandler.js +3 -3
- package/lib/types/common/Constants.d.ts +10 -2
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +6 -0
- package/lib/types/common/utils.d.ts +8 -0
- package/lib/types/components/citationpanestateful/CitationDim.d.ts +5 -0
- package/lib/types/components/citationpanestateful/CitationPaneStateful.d.ts +4 -0
- package/lib/types/components/citationpanestateful/common/defaultProps/defaultCitationPaneProps.d.ts +11 -0
- package/lib/types/components/citationpanestateful/interfaces/ICitationPaneStatefulProps.d.ts +19 -0
- package/lib/types/components/confirmationpanestateful/common/defaultProps/defaultConfirmationPaneLocalizedTexts.d.ts +1 -1
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/customEventHandler.d.ts +4 -0
- package/lib/types/components/livechatwidget/common/getMockChatSDKIfApplicable.d.ts +2 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
- package/lib/types/components/livechatwidget/interfaces/IMockProps.d.ts +5 -3
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatAdapter.d.ts +4 -2
- package/lib/types/components/webchatcontainerstateful/common/DesignerChatSDK.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +8 -1
- package/lib/types/components/webchatcontainerstateful/common/utils/fontUtils.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/ICitation.d.ts +12 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.d.ts +8 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.d.ts +22 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/CustomEventType.d.ts +6 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +46 -45
- package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +2 -2
- package/lib/types/firstresponselatency/util.d.ts +1 -0
- package/lib/types/index.d.ts +1 -0
- package/package.json +5 -4
- /package/lib/cjs/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
- /package/lib/esm/components/{confirmationpanestateful/interfaces/IConfirmationPaneLocalizedText.js → citationpanestateful/interfaces/ICitationPaneStatefulProps.js} +0 -0
- /package/lib/types/components/confirmationpanestateful/interfaces/{IConfirmationPaneLocalizedText.d.ts → IConfirmationPaneLocalizedTexts.d.ts} +0 -0
|
@@ -12,54 +12,96 @@ var _util = require("./util");
|
|
|
12
12
|
// with different timeline, therefore this is a functional approach to track the events, instead of a class based approach
|
|
13
13
|
const createTrackingForFirstMessage = () => {
|
|
14
14
|
// Reset the tracking variables
|
|
15
|
-
let
|
|
16
|
-
let stopTracking = false;
|
|
15
|
+
let isTracking = false;
|
|
17
16
|
let startTime = 0;
|
|
18
17
|
let stopTime = 0;
|
|
19
|
-
let stopTrackingMessage;
|
|
18
|
+
let stopTrackingMessage = null;
|
|
20
19
|
let flag = false;
|
|
20
|
+
let trackingTimeoutId;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the message payload is from a valid sender (not an agent).
|
|
24
|
+
* Returns false if the message is from an agent (tag 'public'), true otherwise.
|
|
25
|
+
*/
|
|
21
26
|
const isMessageFromValidSender = payload => {
|
|
22
27
|
var _payload$tags;
|
|
23
|
-
// agent scenario
|
|
24
28
|
if (payload !== null && payload !== void 0 && (_payload$tags = payload.tags) !== null && _payload$tags !== void 0 && _payload$tags.includes("public")) {
|
|
25
29
|
return false;
|
|
26
30
|
}
|
|
27
31
|
return true;
|
|
28
32
|
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Listener for widget load completion event.
|
|
36
|
+
* Starts tracking the time for the first bot message after widget loads.
|
|
37
|
+
* Sets a 5-second timeout to auto-reset if no bot message is received.
|
|
38
|
+
*/
|
|
29
39
|
const widgetLoadListener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.TelemetryEvent.WidgetLoadComplete).subscribe(() => {
|
|
30
|
-
if (
|
|
31
|
-
|
|
40
|
+
if (isTracking) return;
|
|
41
|
+
isTracking = true;
|
|
32
42
|
startTime = new Date().getTime();
|
|
43
|
+
// Start a 5-second timeout to auto-stop tracking if not stopped
|
|
44
|
+
if (trackingTimeoutId) {
|
|
45
|
+
clearTimeout(trackingTimeoutId);
|
|
46
|
+
}
|
|
47
|
+
trackingTimeoutId = setTimeout(() => {
|
|
48
|
+
if (isTracking) {
|
|
49
|
+
// Reset state and disengage, no telemetry or FMLTrackingCompleted
|
|
50
|
+
isTracking = false;
|
|
51
|
+
startTime = 0;
|
|
52
|
+
stopTime = 0;
|
|
53
|
+
stopTrackingMessage = null;
|
|
54
|
+
trackingTimeoutId = undefined;
|
|
55
|
+
disconnectListener();
|
|
56
|
+
}
|
|
57
|
+
}, 10000); //adding more time since it meassures from widget load complete till message received
|
|
33
58
|
});
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Listener for new bot message event.
|
|
62
|
+
* If a valid bot message is received, stops tracking and logs telemetry.
|
|
63
|
+
* If the message is invalid, resets and disengages listeners.
|
|
64
|
+
*/
|
|
34
65
|
const newMessageListener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.NewMessageReceived).subscribe(message => {
|
|
35
66
|
const payload = message.payload;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
stopTime = new Date().getTime();
|
|
43
|
-
const elapsedTime = stopTime - startTime;
|
|
44
|
-
stopTracking = true;
|
|
45
|
-
stopTrackingMessage = (0, _util.createTrackingMessage)(payload, "botMessage");
|
|
46
|
-
notifyFMLTrackingCompleted();
|
|
47
|
-
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
48
|
-
Event: _TelemetryConstants.TelemetryEvent.BotFirstMessageLapTrack,
|
|
49
|
-
Description: "First Message from Bot latency tracking",
|
|
50
|
-
CustomProperties: {
|
|
51
|
-
elapsedTime,
|
|
52
|
-
widgetLoadedAt: startTime,
|
|
53
|
-
botMessage: stopTrackingMessage
|
|
54
|
-
}
|
|
55
|
-
});
|
|
67
|
+
if (!isMessageFromValidSender(payload)) {
|
|
68
|
+
// If not valid, stop everything and clean up
|
|
69
|
+
isTracking = false;
|
|
70
|
+
if (trackingTimeoutId) {
|
|
71
|
+
clearTimeout(trackingTimeoutId);
|
|
72
|
+
trackingTimeoutId = undefined;
|
|
56
73
|
}
|
|
74
|
+
disconnectListener();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (isTracking) {
|
|
78
|
+
isTracking = false;
|
|
79
|
+
// Clear the timeout if it exists
|
|
80
|
+
if (trackingTimeoutId) {
|
|
81
|
+
clearTimeout(trackingTimeoutId);
|
|
82
|
+
trackingTimeoutId = undefined;
|
|
83
|
+
}
|
|
84
|
+
stopTime = new Date().getTime();
|
|
85
|
+
const elapsedTime = stopTime - startTime;
|
|
86
|
+
stopTrackingMessage = (0, _util.createTrackingMessage)(payload, "botMessage");
|
|
87
|
+
notifyFMLTrackingCompleted();
|
|
88
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
89
|
+
Event: _TelemetryConstants.TelemetryEvent.BotFirstMessageLapTrack,
|
|
90
|
+
Description: "First Message from Bot latency tracking",
|
|
91
|
+
CustomProperties: {
|
|
92
|
+
elapsedTime,
|
|
93
|
+
widgetLoadedAt: startTime,
|
|
94
|
+
botMessage: stopTrackingMessage
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
disconnectListener();
|
|
57
98
|
}
|
|
58
|
-
|
|
59
|
-
// this track only first message, if coming from the bot or not
|
|
60
|
-
// the only difference is that it logs only those from bot
|
|
61
|
-
disconnectListener();
|
|
62
99
|
});
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Notifies that FML (First Message Latency) tracking is completed.
|
|
103
|
+
* Retries sending the completion event until acknowledged.
|
|
104
|
+
*/
|
|
63
105
|
const notifyFMLTrackingCompleted = () => {
|
|
64
106
|
ackListener();
|
|
65
107
|
// Retry sending until flag is true, but do not block the main thread
|
|
@@ -74,6 +116,11 @@ const createTrackingForFirstMessage = () => {
|
|
|
74
116
|
}
|
|
75
117
|
}, 100);
|
|
76
118
|
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Listener for FMLTrackingCompletedAck event.
|
|
122
|
+
* Sets the flag to true when acknowledgment is received.
|
|
123
|
+
*/
|
|
77
124
|
const ackListener = () => {
|
|
78
125
|
const listen = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.FMLTrackingCompletedAck).subscribe(() => {
|
|
79
126
|
flag = true;
|
|
@@ -83,22 +130,32 @@ const createTrackingForFirstMessage = () => {
|
|
|
83
130
|
|
|
84
131
|
// 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
|
|
85
132
|
// No need to keep listerning for tracking, enforcing disconnection for the listners
|
|
133
|
+
/**
|
|
134
|
+
* Listener for widget rehydration event.
|
|
135
|
+
* Resets tracking and disconnects listeners when widget is reloaded.
|
|
136
|
+
*/
|
|
86
137
|
const rehydrateListener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.TelemetryEvent.RehydrateMessageReceived).subscribe(() => {
|
|
87
|
-
|
|
88
|
-
stopTracking = false;
|
|
138
|
+
isTracking = false;
|
|
89
139
|
disconnectListener();
|
|
90
140
|
});
|
|
91
141
|
|
|
92
142
|
// 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
|
|
93
143
|
// No need to keep listerning for tracking, enforcing disconnection for the listners
|
|
144
|
+
/**
|
|
145
|
+
* Listener for history message event.
|
|
146
|
+
* Resets tracking and disconnects listeners when history is loaded.
|
|
147
|
+
*/
|
|
94
148
|
const historyListener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.HistoryMessageReceived).subscribe(() => {
|
|
95
|
-
|
|
96
|
-
stopTracking = false;
|
|
149
|
+
isTracking = false;
|
|
97
150
|
disconnectListener();
|
|
98
151
|
});
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Listener for network disconnection event.
|
|
155
|
+
* Resets tracking, disconnects listeners, and logs a telemetry error.
|
|
156
|
+
*/
|
|
99
157
|
const offlineNetworkListener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.TelemetryEvent.NetworkDisconnected).subscribe(() => {
|
|
100
|
-
|
|
101
|
-
stopTracking = false;
|
|
158
|
+
isTracking = false;
|
|
102
159
|
disconnectListener();
|
|
103
160
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
104
161
|
Event: _TelemetryConstants.TelemetryEvent.BotFirstMessageLapTrackError,
|
|
@@ -107,7 +164,15 @@ const createTrackingForFirstMessage = () => {
|
|
|
107
164
|
});
|
|
108
165
|
|
|
109
166
|
// this is to ensure that we are not tracking messages that are not part of the current conversation
|
|
167
|
+
/**
|
|
168
|
+
* Disconnects all listeners and clears the tracking timeout.
|
|
169
|
+
* Used for cleanup when tracking is stopped or reset.
|
|
170
|
+
*/
|
|
110
171
|
const disconnectListener = () => {
|
|
172
|
+
if (trackingTimeoutId) {
|
|
173
|
+
clearTimeout(trackingTimeoutId);
|
|
174
|
+
trackingTimeoutId = undefined;
|
|
175
|
+
}
|
|
111
176
|
historyListener.unsubscribe();
|
|
112
177
|
rehydrateListener.unsubscribe();
|
|
113
178
|
newMessageListener.unsubscribe();
|
|
@@ -17,14 +17,13 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
|
|
|
17
17
|
function FirstResponseLatencyTracker() {
|
|
18
18
|
_classCallCheck(this, FirstResponseLatencyTracker);
|
|
19
19
|
_defineProperty(this, "isABotConversation", false);
|
|
20
|
-
_defineProperty(this, "
|
|
21
|
-
_defineProperty(this, "isEnded", false);
|
|
20
|
+
_defineProperty(this, "isTracking", false);
|
|
22
21
|
_defineProperty(this, "startTrackingMessage", void 0);
|
|
23
22
|
_defineProperty(this, "stopTrackingMessage", void 0);
|
|
24
23
|
_defineProperty(this, "isReady", false);
|
|
24
|
+
_defineProperty(this, "trackingTimeoutId", void 0);
|
|
25
25
|
_defineProperty(this, "offlineNetworkListener", _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.TelemetryEvent.NetworkDisconnected).subscribe(() => {
|
|
26
|
-
this.
|
|
27
|
-
this.isEnded = false;
|
|
26
|
+
this.isTracking = false;
|
|
28
27
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
29
28
|
Event: _TelemetryConstants.TelemetryEvent.MessageStopLapTrackError,
|
|
30
29
|
Description: "Tracker Stopped due to network disconnection"
|
|
@@ -72,7 +71,7 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
|
|
|
72
71
|
value: function startTracking(payload) {
|
|
73
72
|
if (!this.isReady) return;
|
|
74
73
|
// this prevents to initiate tracking for multiple incoming messages
|
|
75
|
-
if (this.
|
|
74
|
+
if (this.isTracking) {
|
|
76
75
|
return;
|
|
77
76
|
}
|
|
78
77
|
// this is to ensure we track only messages where bot is engaged
|
|
@@ -80,10 +79,24 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
|
|
|
80
79
|
return;
|
|
81
80
|
}
|
|
82
81
|
// control of states to prevent clashing of messages
|
|
83
|
-
this.
|
|
84
|
-
this.isEnded = false;
|
|
82
|
+
this.isTracking = true;
|
|
85
83
|
// The idea of using types is to enrich telemetry data
|
|
86
84
|
this.startTrackingMessage = this.createTrackingMessage(payload, "userMessage");
|
|
85
|
+
|
|
86
|
+
// Start a 5-second timeout to auto-stop tracking if not stopped
|
|
87
|
+
if (this.trackingTimeoutId) {
|
|
88
|
+
clearTimeout(this.trackingTimeoutId);
|
|
89
|
+
}
|
|
90
|
+
this.trackingTimeoutId = setTimeout(() => {
|
|
91
|
+
// this means the start process is in progress, but the end wasn't called within the time limit
|
|
92
|
+
if (this.isTracking) {
|
|
93
|
+
// Reset state variables and skip stopTracking
|
|
94
|
+
this.isTracking = false;
|
|
95
|
+
this.startTrackingMessage = undefined;
|
|
96
|
+
this.stopTrackingMessage = undefined;
|
|
97
|
+
this.trackingTimeoutId = undefined;
|
|
98
|
+
}
|
|
99
|
+
}, 5000);
|
|
87
100
|
}
|
|
88
101
|
}, {
|
|
89
102
|
key: "handleAgentMessage",
|
|
@@ -99,13 +112,16 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
|
|
|
99
112
|
value: function stopTracking(payload) {
|
|
100
113
|
var _this$stopTrackingMes, _this$startTrackingMe;
|
|
101
114
|
// this prevents execution for multiple incoming messages from the bot.
|
|
102
|
-
if (
|
|
115
|
+
if (!this.isTracking) {
|
|
103
116
|
return;
|
|
104
117
|
}
|
|
105
|
-
|
|
118
|
+
// Clear the timeout if it exists
|
|
119
|
+
if (this.trackingTimeoutId) {
|
|
120
|
+
clearTimeout(this.trackingTimeoutId);
|
|
121
|
+
this.trackingTimeoutId = undefined;
|
|
122
|
+
}
|
|
106
123
|
// control of states to prevent clashing of messages
|
|
107
|
-
this.
|
|
108
|
-
this.isStarted = false;
|
|
124
|
+
this.isTracking = false;
|
|
109
125
|
|
|
110
126
|
// The idea of using types is to enrich telemetry data
|
|
111
127
|
this.stopTrackingMessage = this.createTrackingMessage(payload, "botMessage");
|
|
@@ -160,12 +176,16 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
|
|
|
160
176
|
if (!payload || !payload.Id) {
|
|
161
177
|
throw new Error("Invalid payload");
|
|
162
178
|
}
|
|
163
|
-
|
|
164
|
-
if
|
|
179
|
+
|
|
180
|
+
// Only allow stopTracking if sender is valid and tracking is active
|
|
181
|
+
if (!this.isMessageFromValidSender(payload)) {
|
|
182
|
+
// Do not change isTracking or stopTrackingMessage
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (this.isABotConversation && this.isTracking) {
|
|
165
186
|
this.stopTracking(payload);
|
|
166
187
|
}
|
|
167
188
|
} catch (e) {
|
|
168
|
-
console.error("FRL : error while trying to stop the tracker", e);
|
|
169
189
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
170
190
|
Event: _TelemetryConstants.TelemetryEvent.MessageStopLapTrackError,
|
|
171
191
|
Description: "Error while stopping the clock",
|
|
@@ -174,11 +194,6 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
|
|
|
174
194
|
payload: payload
|
|
175
195
|
}
|
|
176
196
|
});
|
|
177
|
-
//reset state
|
|
178
|
-
this.startTrackingMessage = undefined;
|
|
179
|
-
this.stopTrackingMessage = undefined;
|
|
180
|
-
this.isStarted = false;
|
|
181
|
-
this.isEnded = false;
|
|
182
197
|
}
|
|
183
198
|
}
|
|
184
199
|
}, {
|
|
@@ -186,10 +201,13 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
|
|
|
186
201
|
value: function deregister() {
|
|
187
202
|
// Reset State
|
|
188
203
|
this.isABotConversation = false;
|
|
189
|
-
this.
|
|
190
|
-
this.isEnded = false;
|
|
204
|
+
this.isTracking = false;
|
|
191
205
|
this.startTrackingMessage = undefined;
|
|
192
206
|
this.stopTrackingMessage = undefined;
|
|
207
|
+
if (this.trackingTimeoutId) {
|
|
208
|
+
clearTimeout(this.trackingTimeoutId);
|
|
209
|
+
this.trackingTimeoutId = undefined;
|
|
210
|
+
}
|
|
193
211
|
this.offlineNetworkListener.unsubscribe();
|
|
194
212
|
this.fmltrackingListener.unsubscribe();
|
|
195
213
|
this.rehydrateListener.unsubscribe();
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.polyfillMessagePayloadForEvent = exports.isHistoryMessage = exports.getScenarioType = exports.extractTimestampFromId = exports.createTrackingMessage = exports.buildMessagePayload = void 0;
|
|
6
|
+
exports.polyfillMessagePayloadForEvent = exports.maskPayloadText = exports.isHistoryMessage = exports.getScenarioType = exports.extractTimestampFromId = exports.createTrackingMessage = exports.buildMessagePayload = void 0;
|
|
7
7
|
var _Constants = require("./Constants");
|
|
8
8
|
var _Constants2 = require("../common/Constants");
|
|
9
|
+
const DELTA_WITHIN_LIMITS_IN_MS = 250;
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* Determines whether a given activity is a historical message.
|
|
11
13
|
*
|
|
@@ -23,19 +25,21 @@ var _Constants2 = require("../common/Constants");
|
|
|
23
25
|
* - If the ID is valid and the timestamp is older than the start time, the message is historical.
|
|
24
26
|
*/
|
|
25
27
|
const isHistoryMessage = (activity, startTime) => {
|
|
26
|
-
var _activity$channelData
|
|
28
|
+
var _activity$channelData;
|
|
27
29
|
// Only process message activities
|
|
28
30
|
if ((activity === null || activity === void 0 ? void 0 : activity.type) !== _Constants2.Constants.message) {
|
|
29
31
|
return false;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
//
|
|
33
|
-
if (activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 &&
|
|
34
|
+
// Prioritize legacy history tag
|
|
35
|
+
if (activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && _activity$channelData.tags && activity.channelData.tags.includes(_Constants2.Constants.historyMessageTag)) {
|
|
34
36
|
return true;
|
|
35
37
|
}
|
|
36
38
|
const activityId = extractTimestampFromId(activity);
|
|
37
39
|
const isValidId = !isNaN(activityId) && activityId > 0;
|
|
38
|
-
const
|
|
40
|
+
const difference = startTime - activityId;
|
|
41
|
+
// Only consider historical if activityId < startTime and difference >= DELTA_WITHIN_LIMITS_IN_MS
|
|
42
|
+
const isOlderThanStartTime = activityId < startTime && difference >= DELTA_WITHIN_LIMITS_IN_MS;
|
|
39
43
|
const isHistoryById = isValidId && isOlderThanStartTime;
|
|
40
44
|
return isHistoryById;
|
|
41
45
|
};
|
|
@@ -64,7 +68,7 @@ const extractTimestampFromId = activity => {
|
|
|
64
68
|
};
|
|
65
69
|
exports.extractTimestampFromId = extractTimestampFromId;
|
|
66
70
|
const buildMessagePayload = (activity, userId) => {
|
|
67
|
-
var _text, _text2, _activity$
|
|
71
|
+
var _text, _text2, _activity$channelData2, _activity$from;
|
|
68
72
|
return {
|
|
69
73
|
// To identify hidden contents vs empty content
|
|
70
74
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -72,7 +76,7 @@ const buildMessagePayload = (activity, userId) => {
|
|
|
72
76
|
type: activity === null || activity === void 0 ? void 0 : activity.type,
|
|
73
77
|
timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
|
|
74
78
|
userId: userId,
|
|
75
|
-
tags: activity === null || activity === void 0 ? void 0 : (_activity$
|
|
79
|
+
tags: (activity === null || activity === void 0 ? void 0 : (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.tags) || [],
|
|
76
80
|
messageType: "",
|
|
77
81
|
Id: activity === null || activity === void 0 ? void 0 : activity.id,
|
|
78
82
|
role: activity === null || activity === void 0 ? void 0 : (_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role,
|
|
@@ -98,9 +102,9 @@ const polyfillMessagePayloadForEvent = (activity, payload, conversationId) => {
|
|
|
98
102
|
};
|
|
99
103
|
exports.polyfillMessagePayloadForEvent = polyfillMessagePayloadForEvent;
|
|
100
104
|
const getScenarioType = activity => {
|
|
101
|
-
var _activity$from3, _activity$
|
|
105
|
+
var _activity$from3, _activity$channelData3;
|
|
102
106
|
const role = activity === null || activity === void 0 ? void 0 : (_activity$from3 = activity.from) === null || _activity$from3 === void 0 ? void 0 : _activity$from3.role;
|
|
103
|
-
const tags = activity === null || activity === void 0 ? void 0 : (_activity$
|
|
107
|
+
const tags = activity === null || activity === void 0 ? void 0 : (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 ? void 0 : _activity$channelData3.tags;
|
|
104
108
|
if (role === _Constants2.Constants.userMessageTag) {
|
|
105
109
|
return _Constants.ScenarioType.UserSendMessageStrategy;
|
|
106
110
|
}
|
|
@@ -122,4 +126,14 @@ const createTrackingMessage = (payload, type) => {
|
|
|
122
126
|
checkTime: new Date().getTime()
|
|
123
127
|
};
|
|
124
128
|
};
|
|
125
|
-
exports.createTrackingMessage = createTrackingMessage;
|
|
129
|
+
exports.createTrackingMessage = createTrackingMessage;
|
|
130
|
+
const maskPayloadText = payload => {
|
|
131
|
+
if (!payload) {
|
|
132
|
+
return payload;
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
...payload,
|
|
136
|
+
text: "*contents hidden*"
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
exports.maskPayloadText = maskPayloadText;
|
package/lib/cjs/index.js
CHANGED
|
@@ -14,7 +14,8 @@ var _exportNames = {
|
|
|
14
14
|
useChatSDKStore: true,
|
|
15
15
|
useFacadeChatSDKStore: true,
|
|
16
16
|
LiveChatWidget: true,
|
|
17
|
-
getMockChatSDKIfApplicable: true
|
|
17
|
+
getMockChatSDKIfApplicable: true,
|
|
18
|
+
LiveChatWidgetMockType: true
|
|
18
19
|
};
|
|
19
20
|
Object.defineProperty(exports, "BroadcastService", {
|
|
20
21
|
enumerable: true,
|
|
@@ -34,6 +35,12 @@ Object.defineProperty(exports, "LiveChatWidget", {
|
|
|
34
35
|
return _LiveChatWidget.default;
|
|
35
36
|
}
|
|
36
37
|
});
|
|
38
|
+
Object.defineProperty(exports, "LiveChatWidgetMockType", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _IMockProps.LiveChatWidgetMockType;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
37
44
|
Object.defineProperty(exports, "decodeComponentString", {
|
|
38
45
|
enumerable: true,
|
|
39
46
|
get: function () {
|
|
@@ -90,6 +97,7 @@ var _useChatSDKStore = _interopRequireDefault(require("./hooks/useChatSDKStore")
|
|
|
90
97
|
var _useFacadeChatSDKStore = _interopRequireDefault(require("./hooks/useFacadeChatSDKStore"));
|
|
91
98
|
var _LiveChatWidget = _interopRequireDefault(require("./components/livechatwidget/LiveChatWidget"));
|
|
92
99
|
var _getMockChatSDKIfApplicable = require("./components/livechatwidget/common/getMockChatSDKIfApplicable");
|
|
100
|
+
var _IMockProps = require("./components/livechatwidget/interfaces/IMockProps");
|
|
93
101
|
var _renderingmiddlewares = require("./components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares");
|
|
94
102
|
Object.keys(_renderingmiddlewares).forEach(function (key) {
|
|
95
103
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -705,10 +705,23 @@ const createChatTranscript = async function (transcript, facadeChatSDK) {
|
|
|
705
705
|
reader.readAsDataURL(blob);
|
|
706
706
|
});
|
|
707
707
|
};
|
|
708
|
+
|
|
709
|
+
// Configure DOMPurify to remove target attribute from br tags
|
|
710
|
+
const hook = function (node) {
|
|
711
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
712
|
+
// Remove target attribute from br tags as it causes them to display as literal text
|
|
713
|
+
if (node.tagName === "BR" && node.hasAttribute("target")) {
|
|
714
|
+
node.removeAttribute("target");
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
_dompurify.default.addHook("afterSanitizeAttributes", hook);
|
|
708
718
|
let messages = transcriptMessages.filter(message => {
|
|
709
719
|
message.content = _dompurify.default.sanitize(message.content);
|
|
710
720
|
return message;
|
|
711
721
|
});
|
|
722
|
+
|
|
723
|
+
// Clean up the hook after processing all messages
|
|
724
|
+
_dompurify.default.removeHook("afterSanitizeAttributes", hook);
|
|
712
725
|
if (renderAttachments) {
|
|
713
726
|
messages = await Promise.all(transcriptMessages.map(async message => {
|
|
714
727
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
@@ -71,7 +71,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
|
|
|
71
71
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
72
72
|
Event: _TelemetryConstants.TelemetryEvent.RehydrateMessageReceived,
|
|
73
73
|
Description: "History message received",
|
|
74
|
-
CustomProperties: payload
|
|
74
|
+
CustomProperties: (0, _util.maskPayloadText)(payload)
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
};
|
|
@@ -108,7 +108,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
|
|
|
108
108
|
_TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
109
109
|
Event: _TelemetryConstants.TelemetryEvent.MessageReceived,
|
|
110
110
|
Description: "New message received",
|
|
111
|
-
CustomProperties: payload
|
|
111
|
+
CustomProperties: (0, _util.maskPayloadText)(payload)
|
|
112
112
|
});
|
|
113
113
|
};
|
|
114
114
|
const raiseMessageEvent = activity => {
|
|
@@ -25,6 +25,7 @@ _defineProperty(Constants, "webchatChannelId", "webchat");
|
|
|
25
25
|
_defineProperty(Constants, "markdown", "markdown");
|
|
26
26
|
_defineProperty(Constants, "actionType", "actionType");
|
|
27
27
|
_defineProperty(Constants, "markDownSystemMessageClass", "webchat__basic-transcript__activity-markdown-body");
|
|
28
|
+
_defineProperty(Constants, "MARKDOWN_LIST_INDENTATION", " ");
|
|
28
29
|
_defineProperty(Constants, "String", "string");
|
|
29
30
|
_defineProperty(Constants, "ChatMessagesJson", "chatMessagesJson");
|
|
30
31
|
_defineProperty(Constants, "truePascal", "True");
|
|
@@ -108,8 +109,7 @@ _defineProperty(Constants, "TargetRelationshipAttributes", "noopener noreferrer"
|
|
|
108
109
|
// Markdown icons
|
|
109
110
|
_defineProperty(Constants, "OpenLinkIconCssClass", "webchat__render-markdown__external-link-icon");
|
|
110
111
|
// internet connection test
|
|
111
|
-
_defineProperty(Constants, "
|
|
112
|
-
_defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect Test");
|
|
112
|
+
_defineProperty(Constants, "internetConnectionTestPath", "/livechatwidget/version.txt");
|
|
113
113
|
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
114
114
|
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
115
115
|
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
@@ -125,6 +125,12 @@ _defineProperty(Constants, "InitContextParamsResponse", "initContextParamsRespon
|
|
|
125
125
|
_defineProperty(Constants, "OCOriginalMessageId", "OriginalMessageId");
|
|
126
126
|
_defineProperty(Constants, "WebchatSequenceIdAttribute", "webchat:sequence-id");
|
|
127
127
|
_defineProperty(Constants, "MessageSequenceIdOverride", "MessageSequenceIdOverride");
|
|
128
|
+
_defineProperty(Constants, "sendCustomEvent", "sendCustomEvent");
|
|
129
|
+
_defineProperty(Constants, "onCustomEvent", "onCustomEvent");
|
|
130
|
+
_defineProperty(Constants, "customEventName", "customEventName");
|
|
131
|
+
_defineProperty(Constants, "customEventValue", "customEventValue");
|
|
132
|
+
_defineProperty(Constants, "Hidden", "Hidden");
|
|
133
|
+
_defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
|
|
128
134
|
export const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
|
|
129
135
|
_classCallCheck(this, Regex);
|
|
130
136
|
}), _defineProperty(_class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\])$"), _class);
|
|
@@ -178,6 +184,8 @@ _defineProperty(HtmlAttributeNames, "adaptiveCardClassName", "ac-adaptiveCard");
|
|
|
178
184
|
_defineProperty(HtmlAttributeNames, "adaptiveCardTextBlockClassName", "ac-textBlock");
|
|
179
185
|
_defineProperty(HtmlAttributeNames, "adaptiveCardToggleInputClassName", "ac-toggleInput");
|
|
180
186
|
_defineProperty(HtmlAttributeNames, "adaptiveCardActionSetClassName", "ac-actionSet");
|
|
187
|
+
_defineProperty(HtmlAttributeNames, "ocwCitationPaneClassName", "ocw-citation-pane");
|
|
188
|
+
_defineProperty(HtmlAttributeNames, "ocwCitationPaneTitle", "Citation");
|
|
181
189
|
export let WebChatMiddlewareConstants = /*#__PURE__*/_createClass(function WebChatMiddlewareConstants() {
|
|
182
190
|
_classCallCheck(this, WebChatMiddlewareConstants);
|
|
183
191
|
});
|
|
@@ -148,6 +148,7 @@ export let TelemetryEvent;
|
|
|
148
148
|
TelemetryEvent["EmailTranscriptLoaded"] = "EmailTranscriptLoaded";
|
|
149
149
|
TelemetryEvent["OutOfOfficePaneLoaded"] = "OutOfOfficePaneLoaded";
|
|
150
150
|
TelemetryEvent["ConfirmationPaneLoaded"] = "ConfirmationPaneLoaded";
|
|
151
|
+
TelemetryEvent["CitationPaneLoaded"] = "CitationPaneLoaded";
|
|
151
152
|
TelemetryEvent["ProactiveChatPaneLoaded"] = "ProactiveChatPaneLoaded";
|
|
152
153
|
TelemetryEvent["ReconnectChatPaneLoaded"] = "ReconnectChatPaneLoaded";
|
|
153
154
|
TelemetryEvent["HeaderCloseButtonClicked"] = "HeaderCloseButtonClicked";
|
|
@@ -184,10 +185,12 @@ export let TelemetryEvent;
|
|
|
184
185
|
TelemetryEvent["BotAuthActivityUndefinedSignInId"] = "BotAuthActivityUndefinedSignInId";
|
|
185
186
|
TelemetryEvent["ThirdPartyCookiesBlocked"] = "ThirdPartyCookiesBlocked";
|
|
186
187
|
TelemetryEvent["ParticipantsRemovedEvent"] = "ParticipantsRemovedEvent";
|
|
188
|
+
TelemetryEvent["QueueOverflowEvent"] = "QueueOverflowEvent";
|
|
187
189
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
188
190
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
189
191
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
190
192
|
TelemetryEvent["AttachmentUploadValidatorMiddlewareFailed"] = "AttachmentUploadValidatorMiddlewareFailed";
|
|
193
|
+
TelemetryEvent["CitationMiddlewareFailed"] = "CitationMiddlewareFailed";
|
|
191
194
|
TelemetryEvent["QueuePositionMessageRecieved"] = "QueuePositionMessageRecieved";
|
|
192
195
|
TelemetryEvent["AverageWaitTimeMessageRecieved"] = "AverageWaitTimeMessageRecieved";
|
|
193
196
|
TelemetryEvent["DataMaskingRuleApplied"] = "DataMaskingRuleApplied";
|
|
@@ -222,6 +225,7 @@ export let TelemetryEvent;
|
|
|
222
225
|
TelemetryEvent["SystemMessageReceived"] = "SystemMessageReceived";
|
|
223
226
|
TelemetryEvent["RehydrateMessageReceived"] = "RehydrateMessageReceived";
|
|
224
227
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
228
|
+
TelemetryEvent["CustomEventAction"] = "CustomEventAction";
|
|
225
229
|
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
226
230
|
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
227
231
|
TelemetryEvent["LinkModePostChatWorkflowStarted"] = "LinkModePostChatWorkflowStarted";
|
|
@@ -271,7 +275,9 @@ export let TelemetryEvent;
|
|
|
271
275
|
TelemetryEvent["UXLCWChatButtonLoadingStart"] = "UXLCWChatButtonLoadingStart";
|
|
272
276
|
TelemetryEvent["UXLCWChatButtonLoadingCompleted"] = "UXLCWChatButtonLoadingCompleted";
|
|
273
277
|
TelemetryEvent["UXConfirmationPaneStart"] = "UXConfirmationPaneStart";
|
|
278
|
+
TelemetryEvent["UXCitationPaneStart"] = "UXCitationPaneStart";
|
|
274
279
|
TelemetryEvent["UXConfirmationPaneCompleted"] = "UXConfirmationPaneCompleted";
|
|
280
|
+
TelemetryEvent["UXCitationPaneCompleted"] = "UXCitationPaneCompleted";
|
|
275
281
|
TelemetryEvent["UXLiveChatWidgetStart"] = "UXLiveChatWidgetStart";
|
|
276
282
|
TelemetryEvent["UXLiveChatWidgetCompleted"] = "UXLiveChatWidgetCompleted";
|
|
277
283
|
TelemetryEvent["AppInsightsInitialized"] = "AppInsightsInitialized";
|
|
@@ -230,11 +230,13 @@ export let TelemetryHelper = /*#__PURE__*/function () {
|
|
|
230
230
|
}, {
|
|
231
231
|
key: "postTelemetryEvent",
|
|
232
232
|
value: function postTelemetryEvent(eventName, logLevel, payload) {
|
|
233
|
+
var _TelemetryManager$Int16;
|
|
233
234
|
const telemetryEvent = {
|
|
234
235
|
eventName,
|
|
235
236
|
logLevel,
|
|
236
237
|
payload: {
|
|
237
|
-
...payload
|
|
238
|
+
...payload,
|
|
239
|
+
runtimeId: (_TelemetryManager$Int16 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int16 === void 0 ? void 0 : _TelemetryManager$Int16.lcwRuntimeId
|
|
238
240
|
}
|
|
239
241
|
};
|
|
240
242
|
BroadcastService.postMessage(telemetryEvent);
|
|
@@ -260,11 +262,11 @@ _defineProperty(TelemetryHelper, "logActionEvent", (logLevel, payload) => {
|
|
|
260
262
|
TelemetryHelper.postTelemetryEvent((payload === null || payload === void 0 ? void 0 : payload.Event) ?? "", logLevel, payload);
|
|
261
263
|
});
|
|
262
264
|
_defineProperty(TelemetryHelper, "logSDKEvent", (logLevel, payload) => {
|
|
263
|
-
var _TelemetryManager$
|
|
265
|
+
var _TelemetryManager$Int17;
|
|
264
266
|
TelemetryHelper.postTelemetryEvent((payload === null || payload === void 0 ? void 0 : payload.Event) ?? "", logLevel, {
|
|
265
267
|
...payload,
|
|
266
268
|
TransactionId: newGuid(),
|
|
267
|
-
RequestId: (_TelemetryManager$
|
|
269
|
+
RequestId: (_TelemetryManager$Int17 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int17 === void 0 ? void 0 : _TelemetryManager$Int17.currentRequestId
|
|
268
270
|
});
|
|
269
271
|
});
|
|
270
272
|
_defineProperty(TelemetryHelper, "logConfigDataEvent", (logLevel, payload) => {
|
|
@@ -299,12 +301,12 @@ _defineProperty(TelemetryHelper, "logFacadeChatSDKEventToAllTelemetry", (logLeve
|
|
|
299
301
|
});
|
|
300
302
|
});
|
|
301
303
|
_defineProperty(TelemetryHelper, "logSDKEventToAllTelemetry", (logLevel, payload) => {
|
|
302
|
-
var _TelemetryManager$
|
|
304
|
+
var _TelemetryManager$Int18;
|
|
303
305
|
TelemetryHelper.postTelemetryEvent((payload === null || payload === void 0 ? void 0 : payload.Event) ?? "", logLevel, {
|
|
304
306
|
...{
|
|
305
307
|
...payload,
|
|
306
308
|
TransactionId: newGuid(),
|
|
307
|
-
RequestId: (_TelemetryManager$
|
|
309
|
+
RequestId: (_TelemetryManager$Int18 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int18 === void 0 ? void 0 : _TelemetryManager$Int18.currentRequestId
|
|
308
310
|
},
|
|
309
311
|
LogToAll: true
|
|
310
312
|
});
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -453,4 +453,25 @@ export function getDeviceType() {
|
|
|
453
453
|
} else {
|
|
454
454
|
return "standard";
|
|
455
455
|
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
//Bots expect a payload containing:
|
|
459
|
+
//1. customEventName: this should be string describe the event name
|
|
460
|
+
//2. customEventValue: given the value is from customer with unknown type, it is required to stringify the payload later
|
|
461
|
+
export const isValidCustomEvent = payload => {
|
|
462
|
+
if (Constants.customEventName in payload && payload.customEventName && typeof payload.customEventName === Constants.String && Constants.customEventValue in payload && payload.customEventValue) return true;
|
|
463
|
+
return false;
|
|
464
|
+
};
|
|
465
|
+
export const getCustomEventValue = customEventPayload => {
|
|
466
|
+
let returnVal = "";
|
|
467
|
+
try {
|
|
468
|
+
returnVal = typeof customEventPayload.customEventValue === Constants.String ? customEventPayload.customEventValue : JSON.stringify(customEventPayload.customEventValue);
|
|
469
|
+
} catch (error) {
|
|
470
|
+
console.error(error);
|
|
471
|
+
}
|
|
472
|
+
return returnVal;
|
|
473
|
+
};
|
|
474
|
+
export function isEndConversationDueToOverflowActivity(activity) {
|
|
475
|
+
var _activity$channelData, _activity$channelData2;
|
|
476
|
+
return (activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.tags) && Array.isArray(activity === null || activity === void 0 ? void 0 : (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.tags) && activity.channelData.tags.includes(Constants.EndConversationDueToOverflow);
|
|
456
477
|
}
|