@microsoft/omnichannel-chat-widget 1.7.8-main.29ce174 → 1.7.8-main.50111af
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 +57 -18
- package/lib/cjs/common/KeyCodes.js +6 -1
- package/lib/cjs/common/contextDataStore/DataStoreManager.js +6 -1
- package/lib/cjs/common/facades/FacadeChatSDK.js +385 -292
- package/lib/cjs/common/storage/default/defaultCacheManager.js +6 -3
- package/lib/cjs/common/telemetry/TelemetryConstants.js +137 -116
- package/lib/cjs/common/telemetry/TelemetryHelper.js +219 -181
- package/lib/cjs/common/telemetry/TelemetryManager.js +9 -2
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -5
- package/lib/cjs/components/headerstateful/HeaderStateful.js +3 -5
- 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/startChat.js +2 -23
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +3 -3
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +6 -4
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -6
- 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 +88 -58
- package/lib/cjs/plugins/newMessageEventHandler.js +102 -88
- package/lib/esm/common/Constants.js +57 -18
- package/lib/esm/common/KeyCodes.js +6 -1
- package/lib/esm/common/contextDataStore/DataStoreManager.js +6 -1
- package/lib/esm/common/facades/FacadeChatSDK.js +385 -292
- package/lib/esm/common/storage/default/defaultCacheManager.js +6 -1
- package/lib/esm/common/telemetry/TelemetryConstants.js +137 -116
- package/lib/esm/common/telemetry/TelemetryHelper.js +219 -181
- package/lib/esm/common/telemetry/TelemetryManager.js +9 -2
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -5
- package/lib/esm/components/headerstateful/HeaderStateful.js +3 -5
- 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/startChat.js +3 -24
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +3 -3
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +6 -4
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -6
- 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 +88 -58
- package/lib/esm/plugins/newMessageEventHandler.js +100 -86
- package/lib/types/common/facades/FacadeChatSDK.d.ts +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +8 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatProps.d.ts +2 -2
- 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 +18 -6
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
1
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
6
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -6,6 +9,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
6
9
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
10
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../../common/telemetry/TelemetryConstants";
|
|
8
11
|
import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
12
|
+
import { TelemetryManager } from "../../../../common/telemetry/TelemetryManager";
|
|
9
13
|
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
10
14
|
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
11
15
|
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
@@ -61,9 +65,10 @@ const fetchBotAuthConfig = async (retries, interval) => {
|
|
|
61
65
|
await delay(interval);
|
|
62
66
|
return await fetchBotAuthConfig(--retries, interval);
|
|
63
67
|
};
|
|
64
|
-
export
|
|
65
|
-
|
|
68
|
+
export let BotAuthActivitySubscriber = /*#__PURE__*/function () {
|
|
69
|
+
function BotAuthActivitySubscriber() {
|
|
66
70
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
71
|
+
_classCallCheck(this, BotAuthActivitySubscriber);
|
|
67
72
|
_defineProperty(this, "observer", void 0);
|
|
68
73
|
_defineProperty(this, "signInCardSeen", void 0);
|
|
69
74
|
_defineProperty(this, "fetchBotAuthConfigRetries", void 0);
|
|
@@ -78,69 +83,79 @@ export class BotAuthActivitySubscriber {
|
|
|
78
83
|
this.fetchBotAuthConfigRetryInterval = optionalParams.fetchBotAuthConfigRetryInterval;
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.observer.next(false); // Hides card
|
|
87
|
-
const attachment = activity.attachments[0];
|
|
88
|
-
const signInUrl = attachment.content.buttons[0].value;
|
|
89
|
-
const signInId = extractSignInId(signInUrl);
|
|
90
|
-
if (!signInId) {
|
|
91
|
-
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
92
|
-
Event: TelemetryEvent.BotAuthActivityUndefinedSignInId
|
|
93
|
-
});
|
|
94
|
-
return activity;
|
|
95
|
-
}
|
|
96
|
-
if (this.signInCardSeen.has(signInId)) {
|
|
97
|
-
// Prevents duplicate auth
|
|
98
|
-
return;
|
|
86
|
+
_createClass(BotAuthActivitySubscriber, [{
|
|
87
|
+
key: "applicable",
|
|
88
|
+
value: function applicable(activity) {
|
|
89
|
+
var _activity$attachments;
|
|
90
|
+
return (activity === null || activity === void 0 ? void 0 : (_activity$attachments = activity.attachments) === null || _activity$attachments === void 0 ? void 0 : _activity$attachments.length) > 0 && activity.attachments[0] && supportedSignInCardContentTypes.indexOf(activity.attachments[0].contentType) >= 0;
|
|
99
91
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
92
|
+
}, {
|
|
93
|
+
key: "apply",
|
|
94
|
+
value: async function apply(activity) {
|
|
95
|
+
var _TelemetryManager$Int;
|
|
96
|
+
this.observer.next(false); // Hides card
|
|
97
|
+
const attachment = activity.attachments[0];
|
|
98
|
+
const signInUrl = attachment.content.buttons[0].value;
|
|
99
|
+
const signInId = extractSignInId(signInUrl);
|
|
100
|
+
if (!signInId) {
|
|
101
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
102
|
+
Event: TelemetryEvent.BotAuthActivityUndefinedSignInId
|
|
103
|
+
});
|
|
104
|
+
return activity;
|
|
106
105
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
if (this.signInCardSeen.has(signInId)) {
|
|
107
|
+
// Prevents duplicate auth
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.signInCardSeen.add(signInId);
|
|
111
|
+
const sasUrl = await extractSasUrl(attachment);
|
|
112
|
+
const event = {
|
|
113
|
+
eventName: BroadcastEvent.SigninCardReceived,
|
|
114
|
+
payload: {
|
|
115
|
+
sasUrl,
|
|
116
|
+
conversationId: (_TelemetryManager$Int = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.conversationId
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
if (!sasUrl) {
|
|
120
120
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
121
|
-
Event: TelemetryEvent.
|
|
121
|
+
Event: TelemetryEvent.BotAuthActivityEmptySasUrl,
|
|
122
|
+
Description: "SaS Url is empty"
|
|
122
123
|
});
|
|
124
|
+
return activity;
|
|
123
125
|
} else {
|
|
126
|
+
BroadcastService.postMessage(event);
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const response = await fetchBotAuthConfig(this.fetchBotAuthConfigRetries, this.fetchBotAuthConfigRetryInterval);
|
|
130
|
+
if (response === false) {
|
|
131
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
132
|
+
Event: TelemetryEvent.SetBotAuthProviderHideCard
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
136
|
+
Event: TelemetryEvent.SetBotAuthProviderDisplayCard
|
|
137
|
+
});
|
|
138
|
+
return activity;
|
|
139
|
+
}
|
|
140
|
+
} catch {
|
|
124
141
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
125
|
-
Event: TelemetryEvent.
|
|
142
|
+
Event: TelemetryEvent.SetBotAuthProviderNotFound
|
|
126
143
|
});
|
|
144
|
+
//this is to ensure listener continues waiting for response
|
|
145
|
+
if (this.signInCardSeen.has(signInId)) {
|
|
146
|
+
this.signInCardSeen.delete(signInId);
|
|
147
|
+
}
|
|
127
148
|
return activity;
|
|
128
149
|
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
this.signInCardSeen.delete(signInId);
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "next",
|
|
153
|
+
value: async function next(activity) {
|
|
154
|
+
if (this.applicable(activity)) {
|
|
155
|
+
return await this.apply(activity);
|
|
136
156
|
}
|
|
137
157
|
return activity;
|
|
138
158
|
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return await this.apply(activity);
|
|
143
|
-
}
|
|
144
|
-
return activity;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
159
|
+
}]);
|
|
160
|
+
return BotAuthActivitySubscriber;
|
|
161
|
+
}();
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
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
|
-
export
|
|
5
|
-
|
|
7
|
+
export let DefaultActivitySubscriber = /*#__PURE__*/function () {
|
|
8
|
+
function DefaultActivitySubscriber() {
|
|
9
|
+
_classCallCheck(this, DefaultActivitySubscriber);
|
|
6
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
11
|
_defineProperty(this, "observer", void 0);
|
|
8
12
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
_createClass(DefaultActivitySubscriber, [{
|
|
14
|
+
key: "next",
|
|
15
|
+
value:
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
async function next(activity) {
|
|
18
|
+
this.observer.next(activity);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}]);
|
|
22
|
+
return DefaultActivitySubscriber;
|
|
23
|
+
}();
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
3
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
1
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
6
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -5,66 +8,76 @@ import { Constants } from "../../../../common/Constants";
|
|
|
5
8
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../../common/telemetry/TelemetryConstants";
|
|
6
9
|
import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
7
10
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
8
|
-
export
|
|
9
|
-
|
|
11
|
+
export let HiddenAdaptiveCardActivitySubscriber = /*#__PURE__*/function () {
|
|
12
|
+
function HiddenAdaptiveCardActivitySubscriber() {
|
|
13
|
+
_classCallCheck(this, HiddenAdaptiveCardActivitySubscriber);
|
|
10
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
15
|
_defineProperty(this, "observer", void 0);
|
|
12
16
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
_createClass(HiddenAdaptiveCardActivitySubscriber, [{
|
|
18
|
+
key: "apply",
|
|
19
|
+
value:
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
async function apply(activity) {
|
|
22
|
+
const {
|
|
23
|
+
attachments,
|
|
24
|
+
attachment
|
|
25
|
+
} = activity;
|
|
26
|
+
this.observer.next(false);
|
|
27
|
+
BroadcastService.postMessage({
|
|
28
|
+
eventName: BroadcastEvent.NewMessageReceived,
|
|
29
|
+
payload: {
|
|
30
|
+
attachments: attachments || [attachment],
|
|
31
|
+
text: "Custom Event"
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
29
36
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
38
|
+
}, {
|
|
39
|
+
key: "applicable",
|
|
40
|
+
value: function applicable(activity) {
|
|
41
|
+
const {
|
|
42
|
+
attachments,
|
|
43
|
+
attachment
|
|
44
|
+
} = activity;
|
|
36
45
|
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
// Use `attachments` or `attachment` (whichever exists)
|
|
47
|
+
const cards = attachments || [attachment];
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
// Check if contentType is "AdaptiveCard"
|
|
50
|
+
const adaptiveCard = cards === null || cards === void 0 ? void 0 : cards.find(
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
item => Constants.supportedAdaptiveCardContentTypes.indexOf(item === null || item === void 0 ? void 0 : item.contentType) >= 0);
|
|
53
|
+
if (adaptiveCard && adaptiveCard.content) {
|
|
54
|
+
const {
|
|
55
|
+
body
|
|
56
|
+
} = adaptiveCard.content;
|
|
57
|
+
if (Array.isArray(body)) {
|
|
58
|
+
// Check if all elements in `body` have `isVisible: false`
|
|
59
|
+
const allInvisible = body.every(item => item.isVisible === false);
|
|
60
|
+
if (allInvisible) {
|
|
61
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
62
|
+
Event: TelemetryEvent.HiddenAdaptiveCardMessageReceived,
|
|
63
|
+
Description: "All elements in AdaptiveCard are invisible"
|
|
64
|
+
});
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
57
67
|
}
|
|
58
68
|
}
|
|
69
|
+
return false;
|
|
59
70
|
}
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
71
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
+
}, {
|
|
74
|
+
key: "next",
|
|
75
|
+
value: async function next(activity) {
|
|
76
|
+
if (this.applicable(activity)) {
|
|
77
|
+
return await this.apply(activity);
|
|
78
|
+
}
|
|
79
|
+
return activity;
|
|
67
80
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
81
|
+
}]);
|
|
82
|
+
return HiddenAdaptiveCardActivitySubscriber;
|
|
83
|
+
}();
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js
CHANGED
|
@@ -1,28 +1,41 @@
|
|
|
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 { ActivityStreamHandler } from "../ActivityStreamHandler";
|
|
5
|
-
export
|
|
6
|
-
|
|
8
|
+
export let PauseActivitySubscriber = /*#__PURE__*/function () {
|
|
9
|
+
function PauseActivitySubscriber() {
|
|
10
|
+
_classCallCheck(this, PauseActivitySubscriber);
|
|
7
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
12
|
_defineProperty(this, "observer", void 0);
|
|
9
13
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
_createClass(PauseActivitySubscriber, [{
|
|
15
|
+
key: "apply",
|
|
16
|
+
value:
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
async function apply(activity) {
|
|
19
|
+
await ActivityStreamHandler.restorePromise;
|
|
20
|
+
return activity;
|
|
21
|
+
}
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
24
|
+
}, {
|
|
25
|
+
key: "applicable",
|
|
26
|
+
value: function applicable(activity) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
20
29
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
}, {
|
|
32
|
+
key: "next",
|
|
33
|
+
value: async function next(activity) {
|
|
34
|
+
if (this.applicable(activity)) {
|
|
35
|
+
return await this.apply(activity);
|
|
36
|
+
}
|
|
37
|
+
return activity;
|
|
25
38
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
39
|
+
}]);
|
|
40
|
+
return PauseActivitySubscriber;
|
|
41
|
+
}();
|
|
@@ -1,9 +1,12 @@
|
|
|
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 { DefaultActivitySubscriber } from "./ActivitySubscriber/DefaultActivitySubscriber";
|
|
5
8
|
import { shareObservable } from "./shareObservable";
|
|
6
|
-
export
|
|
9
|
+
export let ChatAdapterShim = /*#__PURE__*/function () {
|
|
7
10
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
11
|
|
|
9
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -11,7 +14,8 @@ export class ChatAdapterShim {
|
|
|
11
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
15
|
|
|
13
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
|
|
17
|
+
function ChatAdapterShim(chatAdapter) {
|
|
18
|
+
_classCallCheck(this, ChatAdapterShim);
|
|
15
19
|
_defineProperty(this, "chatAdapter", void 0);
|
|
16
20
|
_defineProperty(this, "activityObserver", void 0);
|
|
17
21
|
_defineProperty(this, "subscribers", void 0);
|
|
@@ -51,7 +55,11 @@ export class ChatAdapterShim {
|
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
_createClass(ChatAdapterShim, [{
|
|
59
|
+
key: "addSubscriber",
|
|
60
|
+
value: function addSubscriber(subscriber) {
|
|
61
|
+
this.subscribers.push(subscriber);
|
|
62
|
+
}
|
|
63
|
+
}]);
|
|
64
|
+
return ChatAdapterShim;
|
|
65
|
+
}();
|
|
@@ -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
|
-
export
|
|
7
|
+
export let Deferred = /*#__PURE__*/function () {
|
|
5
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
function Deferred() {
|
|
11
|
+
_classCallCheck(this, Deferred);
|
|
8
12
|
_defineProperty(this, "_promise", void 0);
|
|
9
13
|
_defineProperty(this, "_resolve", void 0);
|
|
10
14
|
_defineProperty(this, "_reject", () => {
|
|
@@ -23,7 +27,11 @@ export class Deferred {
|
|
|
23
27
|
this._reject = reject;
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
_createClass(Deferred, [{
|
|
31
|
+
key: "promise",
|
|
32
|
+
get: function () {
|
|
33
|
+
return this._promise;
|
|
34
|
+
}
|
|
35
|
+
}]);
|
|
36
|
+
return Deferred;
|
|
37
|
+
}();
|
|
@@ -6,7 +6,7 @@ import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/
|
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
8
|
const handleChatDisconnect = (props, state, setWebChatStyles) => {
|
|
9
|
-
var _state$appStates, _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2;
|
|
9
|
+
var _state$appStates, _state$domainStates, _state$domainStates$m, _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4;
|
|
10
10
|
const chatDisconnectState = state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived;
|
|
11
11
|
const chatDisconnectMessage = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$m = _state$domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_BANNER_CHAT_DISCONNECT) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_CHAT_DISCONNECT;
|
|
12
12
|
const hideSendBoxOnConversationEnd = props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd;
|
|
@@ -27,6 +27,8 @@ const handleChatDisconnect = (props, state, setWebChatStyles) => {
|
|
|
27
27
|
});
|
|
28
28
|
break;
|
|
29
29
|
case false:
|
|
30
|
+
// this means customer on purpose wants to hide the send box, we should not override it
|
|
31
|
+
if ((props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.webChatStyles) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.hideSendBox) === true) return;
|
|
30
32
|
if (hideSendBoxOnConversationEnd !== false) {
|
|
31
33
|
setWebChatStyles(styles => {
|
|
32
34
|
return {
|
|
@@ -203,7 +203,7 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
|
|
|
203
203
|
payload: undefined
|
|
204
204
|
});
|
|
205
205
|
// Always allow to close the chat for embedded mode irrespective of end chat errors
|
|
206
|
-
closeChatWidget(dispatch
|
|
206
|
+
closeChatWidget(dispatch);
|
|
207
207
|
facadeChatSDK.destroy();
|
|
208
208
|
}
|
|
209
209
|
}
|
|
@@ -327,21 +327,7 @@ export const endVoiceVideoCallIfOngoing = async (facadeChatSDK, dispatch) => {
|
|
|
327
327
|
}, callId);
|
|
328
328
|
}
|
|
329
329
|
};
|
|
330
|
-
const closeChatWidget =
|
|
331
|
-
var _state$appStates5;
|
|
332
|
-
if (state !== null && state !== void 0 && (_state$appStates5 = state.appStates) !== null && _state$appStates5 !== void 0 && _state$appStates5.hideStartChatButton) {
|
|
333
|
-
var _props$controlProps2, _props$controlProps3;
|
|
334
|
-
// Only close chat if header is enabled for popout
|
|
335
|
-
// TODO : This condition needs to be removed eventually when the filler UX is ready for popout, removing this condition would show a blank screen for OOB Widget
|
|
336
|
-
if ((props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideHeader) === undefined || (props === null || props === void 0 ? void 0 : (_props$controlProps3 = props.controlProps) === null || _props$controlProps3 === void 0 ? void 0 : _props$controlProps3.hideHeader) === false) {
|
|
337
|
-
dispatch({
|
|
338
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
339
|
-
payload: ConversationState.Closed
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
|
|
330
|
+
const closeChatWidget = dispatch => {
|
|
345
331
|
// Embedded chat
|
|
346
332
|
dispatch({
|
|
347
333
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
@@ -361,7 +347,7 @@ const chatTokenCleanUp = async dispatch => {
|
|
|
361
347
|
};
|
|
362
348
|
|
|
363
349
|
const getEndChatEventName = async (facadeChatSDK, props) => {
|
|
364
|
-
var _facadeChatSDK$getCha2, _facadeChatSDK$getCha3, _facadeChatSDK$getCha4, _facadeChatSDK$getCha5, _props$
|
|
365
|
-
return getWidgetEndChatEventName((_facadeChatSDK$getCha2 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha2 === void 0 ? void 0 : (_facadeChatSDK$getCha3 = _facadeChatSDK$getCha2.omnichannelConfig) === null || _facadeChatSDK$getCha3 === void 0 ? void 0 : _facadeChatSDK$getCha3.orgId, (_facadeChatSDK$getCha4 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha4 === void 0 ? void 0 : (_facadeChatSDK$getCha5 = _facadeChatSDK$getCha4.omnichannelConfig) === null || _facadeChatSDK$getCha5 === void 0 ? void 0 : _facadeChatSDK$getCha5.widgetId, (props === null || props === void 0 ? void 0 : (_props$
|
|
350
|
+
var _facadeChatSDK$getCha2, _facadeChatSDK$getCha3, _facadeChatSDK$getCha4, _facadeChatSDK$getCha5, _props$controlProps2;
|
|
351
|
+
return getWidgetEndChatEventName((_facadeChatSDK$getCha2 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha2 === void 0 ? void 0 : (_facadeChatSDK$getCha3 = _facadeChatSDK$getCha2.omnichannelConfig) === null || _facadeChatSDK$getCha3 === void 0 ? void 0 : _facadeChatSDK$getCha3.orgId, (_facadeChatSDK$getCha4 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha4 === void 0 ? void 0 : (_facadeChatSDK$getCha5 = _facadeChatSDK$getCha4.omnichannelConfig) === null || _facadeChatSDK$getCha5 === void 0 ? void 0 : _facadeChatSDK$getCha5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.widgetInstanceId) ?? "");
|
|
366
352
|
};
|
|
367
353
|
export { prepareEndChat, endChat };
|
|
@@ -2,7 +2,7 @@ import "regenerator-runtime/runtime";
|
|
|
2
2
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { ConversationMode, WidgetLoadCustomErrorString } from "../../../common/Constants";
|
|
4
4
|
import { checkContactIdError, isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
|
|
5
|
-
import {
|
|
5
|
+
import { removeAuthTokenProvider } from "./authHelper";
|
|
6
6
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
7
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
8
8
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
@@ -61,11 +61,6 @@ const getChatReconnectContext = async (facadeChatSDK, chatConfig, props, isAuthe
|
|
|
61
61
|
const chatReconnectOptionalParams = {
|
|
62
62
|
reconnectId: (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId
|
|
63
63
|
};
|
|
64
|
-
// Get auth token for getting chat reconnect context
|
|
65
|
-
if (isAuthenticatedChat) {
|
|
66
|
-
// handle authentication will throw error if auth token is not available, so no need to check for response
|
|
67
|
-
await handleAuthentication(facadeChatSDK.getChatSDK(), chatConfig, props.getAuthToken);
|
|
68
|
-
}
|
|
69
64
|
const reconnectChatContext = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getChatReconnectContext(chatReconnectOptionalParams));
|
|
70
65
|
if (isAuthenticatedChat) {
|
|
71
66
|
// remove auth token after reconnectId is fetched
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import { Constants, LiveWorkItemState,
|
|
2
|
+
import { Constants, LiveWorkItemState, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
3
3
|
import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty } from "../../../common/utils";
|
|
4
|
-
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
5
4
|
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
|
|
6
5
|
import { handleStartChatError, logWidgetLoadComplete } from "./startChatErrorHandler";
|
|
7
6
|
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
@@ -13,6 +12,7 @@ import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
|
13
12
|
import { chatSDKStateCleanUp } from "./endChat";
|
|
14
13
|
import { createAdapter } from "./createAdapter";
|
|
15
14
|
import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
|
|
15
|
+
import { createTrackingForFirstMessage } from "../../../firstresponselatency/FirstMessageTrackerFromBot";
|
|
16
16
|
import { isPersistentChatEnabled } from "./liveChatConfigUtils";
|
|
17
17
|
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
18
18
|
import { shouldSetPreChatIfPersistentChat } from "./persistentChatHelper";
|
|
@@ -25,20 +25,6 @@ let widgetInstanceId;
|
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
26
|
let popoutWidgetInstanceId;
|
|
27
27
|
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
const setAuthenticationIfApplicable = async (props, facadeChatSDK) => {
|
|
30
|
-
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
31
|
-
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
32
|
-
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
33
|
-
if (getAuthToken && authClientFunction) {
|
|
34
|
-
// set auth token to chat sdk before start chat
|
|
35
|
-
const authSuccess = await handleAuthentication(facadeChatSDK.getChatSDK(), chatConfig, getAuthToken);
|
|
36
|
-
if (!authSuccess.result) {
|
|
37
|
-
throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
29
|
const prepareStartChat = async (props, facadeChatSDK, state, dispatch, setAdapter) => {
|
|
44
30
|
optionalParams = {}; //Resetting to ensure no stale values
|
|
@@ -66,11 +52,6 @@ const prepareStartChat = async (props, facadeChatSDK, state, dispatch, setAdapte
|
|
|
66
52
|
const isProactiveChat = state.appStates.conversationState === ConversationState.ProactiveChat;
|
|
67
53
|
const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
|
|
68
54
|
|
|
69
|
-
// Setting auth settings to OC API to retrieve existing persistent chat session before start chat if any
|
|
70
|
-
if (isPersistentEnabled(props.chatConfig)) {
|
|
71
|
-
await setAuthenticationIfApplicable(props, facadeChatSDK);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
55
|
//Setting PreChat and intiate chat
|
|
75
56
|
await setPreChatAndInitiateChat(facadeChatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
|
|
76
57
|
};
|
|
@@ -145,6 +126,7 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
|
|
|
145
126
|
const optionalParams = {
|
|
146
127
|
isProactiveChat
|
|
147
128
|
};
|
|
129
|
+
createTrackingForFirstMessage();
|
|
148
130
|
await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
|
|
149
131
|
};
|
|
150
132
|
|
|
@@ -172,9 +154,6 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
|
|
|
172
154
|
Description: "Widget loading started"
|
|
173
155
|
});
|
|
174
156
|
|
|
175
|
-
// Auth token retrieval needs to happen during start chat to support pop-out chat
|
|
176
|
-
await setAuthenticationIfApplicable(props, facadeChatSDK);
|
|
177
|
-
|
|
178
157
|
//Check if chat retrieved from cache
|
|
179
158
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
180
159
|
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|