@microsoft/omnichannel-chat-widget 1.7.4-main.f0f5d34 → 1.7.4
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/facades/FacadeChatSDK.js +298 -0
- package/lib/cjs/common/facades/types/IFacadeChatSDKInput.js +1 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +7 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +12 -0
- package/lib/cjs/common/utils.js +2 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
- package/lib/cjs/components/footerstateful/FooterStateful.js +15 -13
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +26 -3
- package/lib/cjs/components/livechatwidget/common/authHelper.js +14 -5
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +9 -9
- package/lib/cjs/components/livechatwidget/common/endChat.js +40 -30
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +10 -6
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +2 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -12
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +54 -39
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +7 -7
- package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +63 -40
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -6
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +8 -0
- package/lib/cjs/contexts/FacadeChatSDKStore.js +10 -0
- package/lib/cjs/hooks/useFacadeChatSDKStore.js +17 -0
- package/lib/cjs/index.js +9 -2
- package/lib/cjs/plugins/createChatTranscript.js +2 -2
- package/lib/esm/common/facades/FacadeChatSDK.js +291 -0
- package/lib/esm/common/facades/types/IFacadeChatSDKInput.js +1 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +7 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +12 -0
- package/lib/esm/common/utils.js +2 -2
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
- package/lib/esm/components/footerstateful/FooterStateful.js +15 -13
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +26 -3
- package/lib/esm/components/livechatwidget/common/authHelper.js +14 -5
- package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -9
- package/lib/esm/components/livechatwidget/common/endChat.js +40 -30
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +10 -6
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +2 -4
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -12
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +55 -40
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
- package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +63 -40
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -6
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +8 -0
- package/lib/esm/contexts/FacadeChatSDKStore.js +4 -0
- package/lib/esm/hooks/useFacadeChatSDKStore.js +10 -0
- package/lib/esm/index.js +5 -4
- package/lib/esm/plugins/createChatTranscript.js +2 -2
- package/lib/types/common/facades/FacadeChatSDK.d.ts +71 -0
- package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +13 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +9 -2
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +7 -0
- package/lib/types/common/utils.d.ts +2 -1
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +3 -2
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +14 -1
- package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/initCallingSdk.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +3 -2
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +2 -1
- package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
- package/lib/types/contexts/FacadeChatSDKStore.d.ts +1 -0
- package/lib/types/hooks/useFacadeChatSDKStore.d.ts +3 -0
- package/lib/types/index.d.ts +4 -3
- package/lib/types/plugins/createChatTranscript.d.ts +2 -1
- package/package.json +4 -2
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FacadeChatSDK = void 0;
|
|
7
|
+
var _TelemetryConstants = require("../telemetry/TelemetryConstants");
|
|
8
|
+
var _authHelper = require("../../components/livechatwidget/common/authHelper");
|
|
9
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
10
|
+
var _TelemetryHelper = require("../telemetry/TelemetryHelper");
|
|
11
|
+
var _utils = require("../utils");
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
+
class FacadeChatSDK {
|
|
16
|
+
isSDKMocked() {
|
|
17
|
+
return this.sdkMocked;
|
|
18
|
+
}
|
|
19
|
+
getChatSDK() {
|
|
20
|
+
return this.chatSDK;
|
|
21
|
+
}
|
|
22
|
+
destroy() {
|
|
23
|
+
this.token = null;
|
|
24
|
+
this.expiration = 0;
|
|
25
|
+
}
|
|
26
|
+
isTokenSet() {
|
|
27
|
+
return !(0, _utils.isNullOrEmptyString)(this.token);
|
|
28
|
+
}
|
|
29
|
+
constructor(input) {
|
|
30
|
+
_defineProperty(this, "chatSDK", void 0);
|
|
31
|
+
_defineProperty(this, "chatConfig", void 0);
|
|
32
|
+
_defineProperty(this, "token", "");
|
|
33
|
+
_defineProperty(this, "expiration", 0);
|
|
34
|
+
_defineProperty(this, "isAuthenticated", void 0);
|
|
35
|
+
_defineProperty(this, "getAuthToken", void 0);
|
|
36
|
+
_defineProperty(this, "sdkMocked", void 0);
|
|
37
|
+
this.chatSDK = input.chatSDK;
|
|
38
|
+
this.chatConfig = input.chatConfig;
|
|
39
|
+
this.getAuthToken = input.getAuthToken;
|
|
40
|
+
this.isAuthenticated = input.isAuthenticated;
|
|
41
|
+
this.sdkMocked = input.isSDKMocked;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//set default expiration to zero, for undefined or missed exp in jwt
|
|
45
|
+
convertExpiration() {
|
|
46
|
+
let expiration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
47
|
+
// Converting expiration to seconds, if contains decimals or is identified as milliseconds
|
|
48
|
+
if (expiration.toString().length === 13) {
|
|
49
|
+
return Math.floor(expiration / 1000);
|
|
50
|
+
}
|
|
51
|
+
// If the epoch value is already in seconds, return it as is
|
|
52
|
+
return expiration;
|
|
53
|
+
}
|
|
54
|
+
isTokenExpired() {
|
|
55
|
+
// if expiration is 0, token is not going to be validated ( this is to cover the case of token with no expiration)
|
|
56
|
+
if (this.expiration === 0) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// obtain current time in seconds
|
|
61
|
+
const now = Math.floor(Date.now() / 1000);
|
|
62
|
+
|
|
63
|
+
// compare expiration time with current time
|
|
64
|
+
if (now > this.expiration) {
|
|
65
|
+
console.log("Token is expired", now, this.expiration, now > this.expiration);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
async setToken(token) {
|
|
71
|
+
// token must be not null, and must be new
|
|
72
|
+
if (!(0, _utils.isNullOrEmptyString)(token) && token !== this.token) {
|
|
73
|
+
var _this$token;
|
|
74
|
+
const instant = Math.floor(Date.now() / 1000);
|
|
75
|
+
this.token = token;
|
|
76
|
+
// decompose token
|
|
77
|
+
const tokenParts = (_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.split(".");
|
|
78
|
+
if (!tokenParts || tokenParts.length <= 1) {
|
|
79
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
80
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
|
|
81
|
+
Description: "Invalid token format",
|
|
82
|
+
ExceptionDetails: "Token must be in JWT format"
|
|
83
|
+
});
|
|
84
|
+
throw new Error("Invalid token format, must be in JWT format");
|
|
85
|
+
}
|
|
86
|
+
// decode token
|
|
87
|
+
const tokenDecoded = JSON.parse(atob(tokenParts[1]));
|
|
88
|
+
// calculate expiration time
|
|
89
|
+
this.expiration = this.convertExpiration(tokenDecoded.exp);
|
|
90
|
+
|
|
91
|
+
// this is a control , in case the getAuthToken function returns same token
|
|
92
|
+
if (this.expiration > 0 && this.expiration < instant) {
|
|
93
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
94
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenExpired,
|
|
95
|
+
Description: "New token is already expired",
|
|
96
|
+
ExceptionDetails: {
|
|
97
|
+
"Instant": instant,
|
|
98
|
+
"Expiration": this.expiration
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
throw new Error("New token is already expired, with epoch time " + this.expiration);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async tokenRing() {
|
|
106
|
+
// this is needed for storybooks, specifically for reconnect pane which requires authentication bypass
|
|
107
|
+
if (this.sdkMocked === true) {
|
|
108
|
+
return {
|
|
109
|
+
result: true,
|
|
110
|
+
message: "Authentication not needed"
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (!this.isAuthenticated) {
|
|
114
|
+
return {
|
|
115
|
+
result: true,
|
|
116
|
+
message: "Authentication not needed"
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (this.isTokenSet() && !this.isTokenExpired()) {
|
|
120
|
+
return {
|
|
121
|
+
result: true,
|
|
122
|
+
message: "Token is valid"
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (this.getAuthToken === undefined) {
|
|
126
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
127
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
|
|
128
|
+
Description: "GetAuthToken function is not present",
|
|
129
|
+
ExceptionDetails: "Missing function : " + (0, _authHelper.getAuthClientFunction)(this.chatConfig)
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
result: false,
|
|
133
|
+
message: "GetAuthToken function is not present"
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// if token is not set, or token is already expired , then go to grab a token
|
|
138
|
+
this.token = "";
|
|
139
|
+
this.expiration = 0;
|
|
140
|
+
try {
|
|
141
|
+
const ring = await (0, _authHelper.handleAuthentication)(this.chatSDK, this.chatConfig, this.getAuthToken);
|
|
142
|
+
if (ring.result === true && ring.token) {
|
|
143
|
+
await this.setToken(ring.token);
|
|
144
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
145
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenSuccess,
|
|
146
|
+
Description: "New Token obtained",
|
|
147
|
+
Data: {
|
|
148
|
+
"Token_Expiration": this.expiration
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
result: true,
|
|
153
|
+
message: "New Token obtained"
|
|
154
|
+
};
|
|
155
|
+
} else {
|
|
156
|
+
var _ring$error, _ring$error2;
|
|
157
|
+
console.error("Failed to get token", ring);
|
|
158
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
159
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
|
|
160
|
+
Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
|
|
161
|
+
ExceptionDetails: ring.error
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
result: false,
|
|
165
|
+
message: ((_ring$error2 = ring.error) === null || _ring$error2 === void 0 ? void 0 : _ring$error2.message) || "Failed to get token"
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
} catch (e) {
|
|
169
|
+
console.error("Unexpected error while getting token", e);
|
|
170
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
171
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
|
|
172
|
+
Description: "Unexpected error while getting token",
|
|
173
|
+
ExceptionDetails: e
|
|
174
|
+
});
|
|
175
|
+
return {
|
|
176
|
+
result: false,
|
|
177
|
+
message: "Unexpected error while getting token"
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async validateAndExecuteCall(functionName, fn) {
|
|
182
|
+
const pingResponse = await this.tokenRing();
|
|
183
|
+
if (pingResponse.result === true) {
|
|
184
|
+
return fn();
|
|
185
|
+
}
|
|
186
|
+
const executionErrorMessage = `Authentication failed: Process to get a token failed for ${functionName}, ${pingResponse.message}`;
|
|
187
|
+
//telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
|
|
188
|
+
console.error(executionErrorMessage);
|
|
189
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
190
|
+
eventName: _TelemetryConstants.BroadcastEvent.OnWidgetError,
|
|
191
|
+
payload: {
|
|
192
|
+
errorMessage: executionErrorMessage
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
throw new Error(executionErrorMessage);
|
|
196
|
+
}
|
|
197
|
+
async initialize() {
|
|
198
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
199
|
+
return this.validateAndExecuteCall("initialize", () => this.chatSDK.initialize(optionalParams));
|
|
200
|
+
}
|
|
201
|
+
async getChatReconnectContext() {
|
|
202
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
203
|
+
return this.validateAndExecuteCall("getChatReconnectContext", () => this.chatSDK.getChatReconnectContext(optionalParams));
|
|
204
|
+
}
|
|
205
|
+
async startChat() {
|
|
206
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
207
|
+
return this.validateAndExecuteCall("startChat", () => this.chatSDK.startChat(optionalParams));
|
|
208
|
+
}
|
|
209
|
+
async endChat() {
|
|
210
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
211
|
+
return this.validateAndExecuteCall("endChat", () => this.chatSDK.endChat(optionalParams));
|
|
212
|
+
}
|
|
213
|
+
async getCurrentLiveChatContext() {
|
|
214
|
+
return this.validateAndExecuteCall("getCurrentLiveChatContext", () => this.chatSDK.getCurrentLiveChatContext());
|
|
215
|
+
}
|
|
216
|
+
async getConversationDetails() {
|
|
217
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
218
|
+
return this.validateAndExecuteCall("getConversationDetails", () => this.chatSDK.getConversationDetails(optionalParams));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
222
|
+
async getPreChatSurvey() {
|
|
223
|
+
let parse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
224
|
+
//prechat survey is obtained from config object, which is not required to be authenticated
|
|
225
|
+
// removing the tokenRing function from this call for backward compatibility
|
|
226
|
+
// TODO :: wrap this function around authentication
|
|
227
|
+
return this.chatSDK.getPreChatSurvey(parse);
|
|
228
|
+
}
|
|
229
|
+
async getLiveChatConfig(optionalParams) {
|
|
230
|
+
return this.validateAndExecuteCall("getLiveChatConfig", () => this.chatSDK.getLiveChatConfig(optionalParams));
|
|
231
|
+
}
|
|
232
|
+
async getChatToken() {
|
|
233
|
+
let cached = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
234
|
+
let optionalParams = arguments.length > 1 ? arguments[1] : undefined;
|
|
235
|
+
return this.validateAndExecuteCall("getChatToken", () => this.chatSDK.getChatToken(cached, optionalParams));
|
|
236
|
+
}
|
|
237
|
+
async getCallingToken() {
|
|
238
|
+
return this.validateAndExecuteCall("getCallingToken", () => this.chatSDK.getCallingToken());
|
|
239
|
+
}
|
|
240
|
+
async getMessages() {
|
|
241
|
+
return this.validateAndExecuteCall("getMessages", () => this.chatSDK.getMessages());
|
|
242
|
+
}
|
|
243
|
+
async getDataMaskingRules() {
|
|
244
|
+
return this.validateAndExecuteCall("getDataMaskingRules", () => this.chatSDK.getDataMaskingRules());
|
|
245
|
+
}
|
|
246
|
+
async sendMessage(message) {
|
|
247
|
+
return this.validateAndExecuteCall("sendMessage", () => this.chatSDK.sendMessage(message));
|
|
248
|
+
}
|
|
249
|
+
async onNewMessage(onNewMessageCallback) {
|
|
250
|
+
let optionalParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
251
|
+
return this.validateAndExecuteCall("onNewMessage", () => this.chatSDK.onNewMessage(onNewMessageCallback, optionalParams));
|
|
252
|
+
}
|
|
253
|
+
async sendTypingEvent() {
|
|
254
|
+
return this.validateAndExecuteCall("sendTypingEvent", () => this.chatSDK.sendTypingEvent());
|
|
255
|
+
}
|
|
256
|
+
async onTypingEvent(onTypingEventCallback) {
|
|
257
|
+
return this.validateAndExecuteCall("onTypingEvent", () => this.chatSDK.onTypingEvent(onTypingEventCallback));
|
|
258
|
+
}
|
|
259
|
+
async onAgentEndSession(onAgentEndSessionCallback) {
|
|
260
|
+
return this.validateAndExecuteCall("onAgentEndSession", () => this.chatSDK.onAgentEndSession(onAgentEndSessionCallback));
|
|
261
|
+
}
|
|
262
|
+
async uploadFileAttachment(fileInfo) {
|
|
263
|
+
return this.validateAndExecuteCall("uploadFileAttachment", () => this.chatSDK.uploadFileAttachment(fileInfo));
|
|
264
|
+
}
|
|
265
|
+
async downloadFileAttachment(fileMetadata) {
|
|
266
|
+
return this.validateAndExecuteCall("downloadFileAttachment", () => this.chatSDK.downloadFileAttachment(fileMetadata));
|
|
267
|
+
}
|
|
268
|
+
async emailLiveChatTranscript(body) {
|
|
269
|
+
let optionalParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
270
|
+
return this.validateAndExecuteCall("emailLiveChatTranscript", () => this.chatSDK.emailLiveChatTranscript(body, optionalParams));
|
|
271
|
+
}
|
|
272
|
+
async getLiveChatTranscript() {
|
|
273
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
274
|
+
return this.validateAndExecuteCall("getLiveChatTranscript", () => this.chatSDK.getLiveChatTranscript(optionalParams));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// response from origin is unknown, but this definition breaks create adapter for shimAdapter, switching to any until type is returned from origin
|
|
278
|
+
async createChatAdapter() {
|
|
279
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
280
|
+
return this.validateAndExecuteCall("createChatAdapter", () => this.chatSDK.createChatAdapter(optionalParams));
|
|
281
|
+
}
|
|
282
|
+
async isVoiceVideoCallingEnabled() {
|
|
283
|
+
this.tokenRing();
|
|
284
|
+
return this.chatSDK.isVoiceVideoCallingEnabled();
|
|
285
|
+
}
|
|
286
|
+
async getVoiceVideoCalling() {
|
|
287
|
+
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
288
|
+
return this.validateAndExecuteCall("getVoiceVideoCalling", () => this.chatSDK.getVoiceVideoCalling(params));
|
|
289
|
+
}
|
|
290
|
+
async getPostChatSurveyContext() {
|
|
291
|
+
return this.validateAndExecuteCall("getPostChatSurveyContext", () => this.chatSDK.getPostChatSurveyContext());
|
|
292
|
+
}
|
|
293
|
+
async getAgentAvailability() {
|
|
294
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
295
|
+
return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
exports.FacadeChatSDK = FacadeChatSDK;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -65,6 +65,7 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
65
65
|
BroadcastEvent["UpdateConversationDataForTelemetry"] = "UpdateConversationDataForTelemetry";
|
|
66
66
|
BroadcastEvent["ContactIdNotFound"] = "ContactIdNotFound";
|
|
67
67
|
BroadcastEvent["SyncMinimize"] = "SyncMinimize";
|
|
68
|
+
BroadcastEvent["OnWidgetError"] = "OnWidgetError";
|
|
68
69
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
69
70
|
let TelemetryEvent;
|
|
70
71
|
exports.TelemetryEvent = TelemetryEvent;
|
|
@@ -121,6 +122,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
121
122
|
TelemetryEvent["CloseChatCall"] = "CloseChatCall";
|
|
122
123
|
TelemetryEvent["CloseChatMethodException"] = "CloseChatMethodException";
|
|
123
124
|
TelemetryEvent["PrechatSurveyLoaded"] = "PrechatSurveyLoaded";
|
|
125
|
+
TelemetryEvent["PrechatSurveyExpected"] = "PrechatSurveyExpected";
|
|
124
126
|
TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
|
|
125
127
|
TelemetryEvent["StartChatSDKCall"] = "StartChatCall";
|
|
126
128
|
TelemetryEvent["StartChatEventRecevied"] = "StartChatEventReceived";
|
|
@@ -187,6 +189,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
187
189
|
TelemetryEvent["SendTypingIndicatorSucceeded"] = "SendTypingIndicatorSucceeded";
|
|
188
190
|
TelemetryEvent["SendTypingIndicatorFailed"] = "SendTypingIndicatorFailed";
|
|
189
191
|
TelemetryEvent["WebChatEvent"] = "WebChatEvent";
|
|
192
|
+
TelemetryEvent["FacadeChatSDKEvent"] = "FacadeChatSDKEvent";
|
|
190
193
|
TelemetryEvent["PreChatSurveyStartChatMethodFailed"] = "PreChatSurveyStartChatMethodFailed";
|
|
191
194
|
TelemetryEvent["ChatAlreadyTriggered"] = "ChatAlreadyTriggered";
|
|
192
195
|
TelemetryEvent["StartProactiveChatEventReceived"] = "StartProactiveChatEventReceived";
|
|
@@ -217,6 +220,10 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
217
220
|
TelemetryEvent["ChatDisconnectThreadEventReceived"] = "ChatDisconnectThreadEventReceived";
|
|
218
221
|
TelemetryEvent["HiddenAdaptiveCardMessageReceived"] = "HiddenAdaptiveCardMessageReceived";
|
|
219
222
|
TelemetryEvent["EndingAdapterAfterDisconnectionError"] = "EndingAdapterAfterDisconnectionError";
|
|
223
|
+
TelemetryEvent["NewTokenSuccess"] = "NewTokenSuccess";
|
|
224
|
+
TelemetryEvent["NewTokenFailed"] = "NewTokenFailed";
|
|
225
|
+
TelemetryEvent["NewTokenExpired"] = "NewTokenExpired";
|
|
226
|
+
TelemetryEvent["TokenEmptyOrSame"] = "TokenEmptyOrSame";
|
|
220
227
|
})(TelemetryEvent || (exports.TelemetryEvent = TelemetryEvent = {}));
|
|
221
228
|
class TelemetryConstants {
|
|
222
229
|
static map(eventTypeOrScenarioType) {
|
|
@@ -21,6 +21,7 @@ class TelemetryHelper {
|
|
|
21
21
|
case _TelemetryConstants.ScenarioType.WEBCHAT:
|
|
22
22
|
return TelemetryHelper.conformToWebChatContract(level, input);
|
|
23
23
|
case _TelemetryConstants.ScenarioType.OCCHATSDK:
|
|
24
|
+
case _TelemetryConstants.ScenarioType.SDK:
|
|
24
25
|
return TelemetryHelper.conformToOCChatSDKContract(level, input);
|
|
25
26
|
case _TelemetryConstants.ScenarioType.ACTIONS:
|
|
26
27
|
return TelemetryHelper.conformToActionsContract(level, input);
|
|
@@ -156,6 +157,7 @@ class TelemetryHelper {
|
|
|
156
157
|
event.TransactionId = payload.TransactionId;
|
|
157
158
|
event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
|
|
158
159
|
event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
|
|
160
|
+
event.Description = payload.Description;
|
|
159
161
|
});
|
|
160
162
|
}
|
|
161
163
|
static addChatConfigDataToTelemetry(chatConfig, telemetryInternalData) {
|
|
@@ -262,4 +264,14 @@ _defineProperty(TelemetryHelper, "logWebChatEvent", (logLevel, payload) => {
|
|
|
262
264
|
}
|
|
263
265
|
};
|
|
264
266
|
_omnichannelChatComponents.BroadcastService.postMessage(telemetryEvent);
|
|
267
|
+
});
|
|
268
|
+
_defineProperty(TelemetryHelper, "logFacadeChatSDKEvent", (logLevel, payload) => {
|
|
269
|
+
const telemetryEvent = {
|
|
270
|
+
eventName: (payload === null || payload === void 0 ? void 0 : payload.Event) ?? _TelemetryConstants.TelemetryEvent.FacadeChatSDKEvent,
|
|
271
|
+
logLevel: logLevel,
|
|
272
|
+
payload: {
|
|
273
|
+
...payload
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
_omnichannelChatComponents.BroadcastService.postMessage(telemetryEvent);
|
|
265
277
|
});
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -390,7 +390,7 @@ const isThisSessionPopout = href => {
|
|
|
390
390
|
};
|
|
391
391
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
392
392
|
exports.isThisSessionPopout = isThisSessionPopout;
|
|
393
|
-
const getConversationDetailsCall = async function (
|
|
393
|
+
const getConversationDetailsCall = async function (facadeChatSDK) {
|
|
394
394
|
let liveChatContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
395
395
|
let conversationDetails = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
396
396
|
const optionalParams = {}; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
@@ -403,7 +403,7 @@ const getConversationDetailsCall = async function (chatSDK) {
|
|
|
403
403
|
Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallStarted,
|
|
404
404
|
Description: "Conversation details call started"
|
|
405
405
|
});
|
|
406
|
-
conversationDetails = await
|
|
406
|
+
conversationDetails = await facadeChatSDK.getConversationDetails(optionalParams);
|
|
407
407
|
} catch (error) {
|
|
408
408
|
checkContactIdError(error);
|
|
409
409
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -10,18 +10,14 @@ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components
|
|
|
10
10
|
var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
|
|
11
11
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
12
12
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
13
|
-
var
|
|
13
|
+
var _useFacadeChatSDKStore = _interopRequireDefault(require("../../hooks/useFacadeChatSDKStore"));
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
const CallingContainerStateful = props => {
|
|
18
18
|
var _props$controlProps, _props$controlProps2, _props$controlProps2$, _props$controlProps3, _props$controlProps3$, _props$controlProps3$2, _props$controlProps4, _props$controlProps4$, _props$controlProps4$2, _props$controlProps5;
|
|
19
|
-
//TODO : Close button confirmation implmentation is pending
|
|
20
|
-
|
|
21
19
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
22
|
-
|
|
23
|
-
const chatSDK = (0, _useChatSDKStore.default)();
|
|
24
|
-
|
|
20
|
+
const [facadeChatSDK] = (0, _useFacadeChatSDKStore.default)();
|
|
25
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
22
|
const {
|
|
27
23
|
voiceVideoCallingSdk
|
|
@@ -54,7 +50,7 @@ const CallingContainerStateful = props => {
|
|
|
54
50
|
(0, _react.useEffect)(() => {
|
|
55
51
|
const init = async () => {
|
|
56
52
|
try {
|
|
57
|
-
var _controlProps$current, _controlProps$current2, _controlProps$current3, _controlProps$current4;
|
|
53
|
+
var _controlProps$current, _controlProps$current2, _controlProps$current3, _controlProps$current4, _facadeChatSDK$getCha;
|
|
58
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
55
|
_TelemetryHelper.TelemetryHelper.callId = callId;
|
|
60
56
|
await voiceVideoCallingSdk.initialize({
|
|
@@ -63,7 +59,7 @@ const CallingContainerStateful = props => {
|
|
|
63
59
|
// HTML element id where video stream of the agent will be rendered
|
|
64
60
|
remoteVideoHTMLElementId: (_controlProps$current3 = controlProps.currentCallControlProps) === null || _controlProps$current3 === void 0 ? void 0 : (_controlProps$current4 = _controlProps$current3.nonActionIds) === null || _controlProps$current4 === void 0 ? void 0 : _controlProps$current4.remoteVideoTileId,
|
|
65
61
|
// HTML element id where video stream of the customer will be rendered
|
|
66
|
-
OCClient:
|
|
62
|
+
OCClient: (_facadeChatSDK$getCha = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha === void 0 ? void 0 : _facadeChatSDK$getCha.OCClient
|
|
67
63
|
});
|
|
68
64
|
} catch (e) {
|
|
69
65
|
_TelemetryHelper.TelemetryHelper.logCallingEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -14,9 +14,9 @@ var _NotificationHandler = require("../webchatcontainerstateful/webchatcontrolle
|
|
|
14
14
|
var _NotificationScenarios = require("../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
|
|
15
15
|
var _Constants = require("../../common/Constants");
|
|
16
16
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
17
|
-
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
18
|
-
var _useChatSDKStore = _interopRequireDefault(require("../../hooks/useChatSDKStore"));
|
|
19
17
|
var _defaultMiddlewareLocalizedTexts = require("../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
18
|
+
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
19
|
+
var _useFacadeChatSDKStore = _interopRequireDefault(require("../../hooks/useFacadeChatSDKStore"));
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -25,8 +25,7 @@ const EmailTranscriptPaneStateful = props => {
|
|
|
25
25
|
const initialTabIndexMap = new Map();
|
|
26
26
|
let elements = [];
|
|
27
27
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
28
|
-
|
|
29
|
-
const chatSDK = (0, _useChatSDKStore.default)();
|
|
28
|
+
const [facadeChatSDK] = (0, _useFacadeChatSDKStore.default)();
|
|
30
29
|
const [initialEmail, setInitialEmail] = (0, _react.useState)("");
|
|
31
30
|
const closeEmailTranscriptPane = () => {
|
|
32
31
|
dispatch({
|
|
@@ -54,7 +53,7 @@ const EmailTranscriptPaneStateful = props => {
|
|
|
54
53
|
attachmentMessage: (props === null || props === void 0 ? void 0 : props.attachmentMessage) ?? "The following attachment was uploaded during the conversation:"
|
|
55
54
|
};
|
|
56
55
|
try {
|
|
57
|
-
await (
|
|
56
|
+
await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.emailLiveChatTranscript(chatTranscriptBody, {
|
|
58
57
|
liveChatContext
|
|
59
58
|
}));
|
|
60
59
|
_NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.EmailAddressSaved, _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts === null || _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts === void 0 ? void 0 : _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS);
|
|
@@ -72,7 +71,7 @@ const EmailTranscriptPaneStateful = props => {
|
|
|
72
71
|
const message = (0, _utils.formatTemplateString)(_defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR, [email]);
|
|
73
72
|
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? message);
|
|
74
73
|
}
|
|
75
|
-
}, [props.attachmentMessage, props.bannerMessageOnError,
|
|
74
|
+
}, [props.attachmentMessage, props.bannerMessageOnError, facadeChatSDK, state.domainStates.liveChatContext]);
|
|
76
75
|
const controlProps = {
|
|
77
76
|
id: "oclcw-emailTranscriptDialogContainer",
|
|
78
77
|
dir: state.domainStates.globalDir,
|
|
@@ -8,6 +8,7 @@ var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _AudioNotificationStateful = _interopRequireDefault(require("./audionotificationstateful/AudioNotificationStateful"));
|
|
10
10
|
var _Constants = require("../../common/Constants");
|
|
11
|
+
var _ConversationState = require("../../contexts/common/ConversationState");
|
|
11
12
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
12
13
|
var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
|
|
13
14
|
var _Audios = require("../../assets/Audios");
|
|
@@ -16,13 +17,13 @@ var _NotificationScenarios = require("../webchatcontainerstateful/webchatcontrol
|
|
|
16
17
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
17
18
|
var _DownloadTranscriptStateful = require("./downloadtranscriptstateful/DownloadTranscriptStateful");
|
|
18
19
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
19
|
-
var
|
|
20
|
+
var _useFacadeChatSDKStore = _interopRequireDefault(require("../../hooks/useFacadeChatSDKStore"));
|
|
20
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
25
|
const FooterStateful = props => {
|
|
25
|
-
var _footerProps$controlP3
|
|
26
|
+
var _footerProps$controlP3;
|
|
26
27
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
27
28
|
// hideFooterDisplay - the purpose of this is to keep the footer always "active",
|
|
28
29
|
// but hide it visually in certain states (e.g., loading state) and show in some other states (e.g. active state).
|
|
@@ -33,8 +34,7 @@ const FooterStateful = props => {
|
|
|
33
34
|
audioNotificationProps,
|
|
34
35
|
hideFooterDisplay
|
|
35
36
|
} = props;
|
|
36
|
-
|
|
37
|
-
const chatSDK = (0, _useChatSDKStore.default)();
|
|
37
|
+
const [facadeChatSDK] = (0, _useFacadeChatSDKStore.default)();
|
|
38
38
|
const controlProps = {
|
|
39
39
|
id: "oc-lcw-footer",
|
|
40
40
|
dir: state.domainStates.globalDir,
|
|
@@ -44,7 +44,7 @@ const FooterStateful = props => {
|
|
|
44
44
|
Event: _TelemetryConstants.TelemetryEvent.DownloadTranscriptButtonClicked,
|
|
45
45
|
Description: "Download Transcript button clicked."
|
|
46
46
|
});
|
|
47
|
-
await (0, _DownloadTranscriptStateful.downloadTranscript)(
|
|
47
|
+
await (0, _DownloadTranscriptStateful.downloadTranscript)(facadeChatSDK, downloadTranscriptProps, state);
|
|
48
48
|
} catch (ex) {
|
|
49
49
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
50
50
|
Event: _TelemetryConstants.TelemetryEvent.DownloadTranscriptFailed,
|
|
@@ -90,21 +90,23 @@ const FooterStateful = props => {
|
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
(0, _react.useEffect)(() => {
|
|
93
|
-
if (state.appStates.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
94
|
+
if (state.appStates.isAudioMuted === null) {
|
|
95
|
+
var _footerProps$controlP4, _footerProps$controlP5, _footerProps$controlP6;
|
|
96
|
+
dispatch({
|
|
97
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
|
|
98
|
+
payload: footerProps !== null && footerProps !== void 0 && (_footerProps$controlP4 = footerProps.controlProps) !== null && _footerProps$controlP4 !== void 0 && _footerProps$controlP4.hideAudioNotificationButton ? true : (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP5 = footerProps.controlProps) === null || _footerProps$controlP5 === void 0 ? void 0 : (_footerProps$controlP6 = _footerProps$controlP5.audioNotificationButtonProps) === null || _footerProps$controlP6 === void 0 ? void 0 : _footerProps$controlP6.isAudioMuted) ?? false
|
|
99
|
+
});
|
|
100
|
+
}
|
|
99
101
|
}
|
|
100
|
-
}, []);
|
|
102
|
+
}, [state.appStates.conversationState]);
|
|
101
103
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !hideFooterDisplay && /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.Footer, {
|
|
102
104
|
componentOverrides: footerProps === null || footerProps === void 0 ? void 0 : footerProps.componentOverrides,
|
|
103
105
|
controlProps: controlProps,
|
|
104
106
|
styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
|
|
105
107
|
}), /*#__PURE__*/_react.default.createElement(_AudioNotificationStateful.default, {
|
|
106
108
|
audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? _Audios.NewMessageNotificationSoundBase64,
|
|
107
|
-
isAudioMuted: state.appStates.isAudioMuted
|
|
109
|
+
isAudioMuted: state.appStates.isAudioMuted ?? false
|
|
108
110
|
}));
|
|
109
111
|
};
|
|
110
112
|
exports.FooterStateful = FooterStateful;
|
package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -5,15 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.downloadTranscript = void 0;
|
|
7
7
|
var _Constants = require("../../../common/Constants");
|
|
8
|
-
var
|
|
8
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
+
var _utils = require("../../../common/utils");
|
|
10
|
+
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
11
|
+
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
9
12
|
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
13
|
+
var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
|
|
10
14
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
11
|
-
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
12
15
|
var _createChatTranscript = _interopRequireDefault(require("../../../plugins/createChatTranscript"));
|
|
13
|
-
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
14
|
-
var _utils = require("../../../common/utils");
|
|
15
16
|
var _createReducer = require("../../../contexts/createReducer");
|
|
16
|
-
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
const processDisplayName = displayName => {
|
|
19
19
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
@@ -163,9 +163,7 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
163
163
|
const str = docTypeTag + docStartTag + docMetaTag + bodyStartTag + mainTranscriptSection + beautifiedChats + divEndTag + bodyEndTag + docEndTag;
|
|
164
164
|
return str;
|
|
165
165
|
};
|
|
166
|
-
|
|
167
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
|
-
const downloadTranscript = async (chatSDK, downloadTranscriptProps, state) => {
|
|
166
|
+
const downloadTranscript = async (facadeChatSDK, downloadTranscriptProps, state) => {
|
|
169
167
|
var _state$domainStates;
|
|
170
168
|
// Need to keep existing live chat context for scenarios when transcript is downloaded after endchat
|
|
171
169
|
let liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext;
|
|
@@ -176,7 +174,7 @@ const downloadTranscript = async (chatSDK, downloadTranscriptProps, state) => {
|
|
|
176
174
|
});
|
|
177
175
|
liveChatContext = inMemoryState.domainStates.liveChatContext;
|
|
178
176
|
}
|
|
179
|
-
let data = await (
|
|
177
|
+
let data = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getLiveChatTranscript({
|
|
180
178
|
liveChatContext
|
|
181
179
|
}));
|
|
182
180
|
if (typeof data === _Constants.Constants.String) {
|
|
@@ -194,7 +192,7 @@ const downloadTranscript = async (chatSDK, downloadTranscriptProps, state) => {
|
|
|
194
192
|
const transcriptOptions = {
|
|
195
193
|
...webChatTranscript
|
|
196
194
|
};
|
|
197
|
-
await (0, _createChatTranscript.default)(data[_Constants.Constants.ChatMessagesJson],
|
|
195
|
+
await (0, _createChatTranscript.default)(data[_Constants.Constants.ChatMessagesJson], facadeChatSDK, false, transcriptOptions);
|
|
198
196
|
} else {
|
|
199
197
|
// Legacy Transcript
|
|
200
198
|
const chatTranscripts = window.btoa(encodeURIComponent(beautifyChatTranscripts(data[_Constants.Constants.ChatMessagesJson], renderMarkDown, attachmentMessage)));
|
|
@@ -88,6 +88,10 @@ const HeaderStateful = props => {
|
|
|
88
88
|
text: "We're Offline"
|
|
89
89
|
},
|
|
90
90
|
onMinimizeClick: () => {
|
|
91
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
92
|
+
Event: _TelemetryConstants.TelemetryEvent.HeaderMinimizeButtonClicked,
|
|
93
|
+
Description: "Header Minimize button clicked."
|
|
94
|
+
});
|
|
91
95
|
dispatch({
|
|
92
96
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
93
97
|
payload: true
|