@microsoft/omnichannel-chat-widget 1.7.4-main.9edefc7 → 1.7.4-main.b7b6783
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 +5 -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 +4 -5
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
- 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 +21 -22
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +3 -3
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +2 -3
- package/lib/cjs/components/livechatwidget/common/persistentChatHelper.js +4 -4
- 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 +45 -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 +33 -33
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
- 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 +5 -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 +4 -5
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
- 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 +21 -22
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +3 -3
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +2 -4
- package/lib/esm/components/livechatwidget/common/persistentChatHelper.js +4 -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 +46 -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 +33 -33
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
- 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 +6 -1
- 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/persistentChatHelper.d.ts +1 -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/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -1
- 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 +2 -2
|
@@ -12,7 +12,7 @@ var _defaultTypingIndicatorBubbleStyles = require("./defaultStyles/defaultTyping
|
|
|
12
12
|
var _defaultTypingIndicatorContainerStyles = require("./defaultStyles/defaultTypingIndicatorContainerStyles");
|
|
13
13
|
var _defaultTypingIndicatorMessageStyles = require("./defaultStyles/defaultTypingIndicatorMessageStyles");
|
|
14
14
|
var _ = require("../../../../..");
|
|
15
|
-
var
|
|
15
|
+
var _useFacadeChatSDKStore = _interopRequireDefault(require("../../../../../hooks/useFacadeChatSDKStore"));
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
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); }
|
|
18
18
|
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; }
|
|
@@ -29,10 +29,10 @@ const TypingIndicator = _ref => {
|
|
|
29
29
|
activeTyping,
|
|
30
30
|
visible
|
|
31
31
|
} = _ref;
|
|
32
|
-
|
|
33
|
-
const chatSDK = (0, _useChatSDKStore.default)();
|
|
32
|
+
const [facadeChatSDK] = (0, _useFacadeChatSDKStore.default)();
|
|
34
33
|
const [state] = (0, _.useChatContextStore)();
|
|
35
|
-
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
const debounceTyping = (0, _react.useCallback)((0, _utils.debounceLeading)(() => facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.sendTypingEvent()), []);
|
|
36
36
|
if (!activeTyping || Object.keys(activeTyping).length === 0 || ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.LiveChatVersion) === 1 && !visible) {
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FacadeChatSDKStore = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
|
|
9
|
+
const FacadeChatSDKStore = /*#__PURE__*/(0, _react.createContext)([undefined, facadeChatSDK => {}]);
|
|
10
|
+
exports.FacadeChatSDKStore = FacadeChatSDKStore;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _FacadeChatSDKStore = require("../contexts/FacadeChatSDKStore");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
const useFacadeChatSDKStore = () => {
|
|
10
|
+
const facadeChatSDK = (0, _react.useContext)(_FacadeChatSDKStore.FacadeChatSDKStore);
|
|
11
|
+
if (!facadeChatSDK) {
|
|
12
|
+
throw new Error("This hook is not called on component that is descendants of <FacadeSDKStore.Provider>, or FacadeSDKStore is not passed into LiveChatWidget component.");
|
|
13
|
+
}
|
|
14
|
+
return facadeChatSDK;
|
|
15
|
+
};
|
|
16
|
+
var _default = useFacadeChatSDKStore;
|
|
17
|
+
exports.default = _default;
|
package/lib/cjs/index.js
CHANGED
|
@@ -63,11 +63,18 @@ Object.defineProperty(exports, "useChatSDKStore", {
|
|
|
63
63
|
return _useChatSDKStore.default;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
+
Object.defineProperty(exports, "useFacadeChatSDKStore", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _useFacadeChatSDKStore.default;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
66
72
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
67
|
-
var _useChatContextStore = _interopRequireDefault(require("./hooks/useChatContextStore"));
|
|
68
|
-
var _useChatSDKStore = _interopRequireDefault(require("./hooks/useChatSDKStore"));
|
|
69
73
|
var _utils = require("./common/utils");
|
|
70
74
|
var _ConversationState = require("./contexts/common/ConversationState");
|
|
75
|
+
var _useChatContextStore = _interopRequireDefault(require("./hooks/useChatContextStore"));
|
|
76
|
+
var _useChatSDKStore = _interopRequireDefault(require("./hooks/useChatSDKStore"));
|
|
77
|
+
var _useFacadeChatSDKStore = _interopRequireDefault(require("./hooks/useFacadeChatSDKStore"));
|
|
71
78
|
var _LiveChatWidget = _interopRequireDefault(require("./components/livechatwidget/LiveChatWidget"));
|
|
72
79
|
var _getMockChatSDKIfApplicable = require("./components/livechatwidget/common/getMockChatSDKIfApplicable");
|
|
73
80
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -653,7 +653,7 @@ class TranscriptHTMLBuilder {
|
|
|
653
653
|
return htmlData;
|
|
654
654
|
}
|
|
655
655
|
}
|
|
656
|
-
const createChatTranscript = async function (transcript,
|
|
656
|
+
const createChatTranscript = async function (transcript, facadeChatSDK) {
|
|
657
657
|
let renderAttachments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
658
658
|
let transcriptOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
659
659
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
@@ -680,7 +680,7 @@ const createChatTranscript = async function (transcript, chatSDK) {
|
|
|
680
680
|
id: references[0],
|
|
681
681
|
type: metadata[0].contentType
|
|
682
682
|
};
|
|
683
|
-
const blob = await
|
|
683
|
+
const blob = await facadeChatSDK.downloadFileAttachment(fileMetadata);
|
|
684
684
|
const base64 = await convertBlobToBase64(blob);
|
|
685
685
|
message.contentUrl = base64;
|
|
686
686
|
}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
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
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
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
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../telemetry/TelemetryConstants";
|
|
5
|
+
import { getAuthClientFunction, handleAuthentication } from "../../components/livechatwidget/common/authHelper";
|
|
6
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
|
+
import { TelemetryHelper } from "../telemetry/TelemetryHelper";
|
|
8
|
+
import { isNullOrEmptyString } from "../utils";
|
|
9
|
+
export class FacadeChatSDK {
|
|
10
|
+
isSDKMocked() {
|
|
11
|
+
return this.sdkMocked;
|
|
12
|
+
}
|
|
13
|
+
getChatSDK() {
|
|
14
|
+
return this.chatSDK;
|
|
15
|
+
}
|
|
16
|
+
destroy() {
|
|
17
|
+
this.token = null;
|
|
18
|
+
this.expiration = 0;
|
|
19
|
+
}
|
|
20
|
+
isTokenSet() {
|
|
21
|
+
return !isNullOrEmptyString(this.token);
|
|
22
|
+
}
|
|
23
|
+
constructor(input) {
|
|
24
|
+
_defineProperty(this, "chatSDK", void 0);
|
|
25
|
+
_defineProperty(this, "chatConfig", void 0);
|
|
26
|
+
_defineProperty(this, "token", "");
|
|
27
|
+
_defineProperty(this, "expiration", 0);
|
|
28
|
+
_defineProperty(this, "isAuthenticated", void 0);
|
|
29
|
+
_defineProperty(this, "getAuthToken", void 0);
|
|
30
|
+
_defineProperty(this, "sdkMocked", void 0);
|
|
31
|
+
this.chatSDK = input.chatSDK;
|
|
32
|
+
this.chatConfig = input.chatConfig;
|
|
33
|
+
this.getAuthToken = input.getAuthToken;
|
|
34
|
+
this.isAuthenticated = input.isAuthenticated;
|
|
35
|
+
this.sdkMocked = input.isSDKMocked;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//set default expiration to zero, for undefined or missed exp in jwt
|
|
39
|
+
convertExpiration() {
|
|
40
|
+
let expiration = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
41
|
+
// Converting expiration to seconds, if contains decimals or is identified as milliseconds
|
|
42
|
+
if (expiration.toString().length === 13) {
|
|
43
|
+
return Math.floor(expiration / 1000);
|
|
44
|
+
}
|
|
45
|
+
// If the epoch value is already in seconds, return it as is
|
|
46
|
+
return expiration;
|
|
47
|
+
}
|
|
48
|
+
isTokenExpired() {
|
|
49
|
+
// if expiration is 0, token is not going to be validated ( this is to cover the case of token with no expiration)
|
|
50
|
+
if (this.expiration === 0) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// obtain current time in seconds
|
|
55
|
+
const now = Math.floor(Date.now() / 1000);
|
|
56
|
+
|
|
57
|
+
// compare expiration time with current time
|
|
58
|
+
if (now > this.expiration) {
|
|
59
|
+
console.log("Token is expired", now, this.expiration, now > this.expiration);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
async setToken(token) {
|
|
65
|
+
// token must be not null, and must be new
|
|
66
|
+
if (!isNullOrEmptyString(token) && token !== this.token) {
|
|
67
|
+
var _this$token;
|
|
68
|
+
const instant = Math.floor(Date.now() / 1000);
|
|
69
|
+
this.token = token;
|
|
70
|
+
// decompose token
|
|
71
|
+
const tokenParts = (_this$token = this.token) === null || _this$token === void 0 ? void 0 : _this$token.split(".");
|
|
72
|
+
if (!tokenParts || tokenParts.length <= 1) {
|
|
73
|
+
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
74
|
+
Event: TelemetryEvent.NewTokenFailed,
|
|
75
|
+
Description: "Invalid token format",
|
|
76
|
+
ExceptionDetails: "Token must be in JWT format"
|
|
77
|
+
});
|
|
78
|
+
throw new Error("Invalid token format, must be in JWT format");
|
|
79
|
+
}
|
|
80
|
+
// decode token
|
|
81
|
+
const tokenDecoded = JSON.parse(atob(tokenParts[1]));
|
|
82
|
+
// calculate expiration time
|
|
83
|
+
this.expiration = this.convertExpiration(tokenDecoded.exp);
|
|
84
|
+
|
|
85
|
+
// this is a control , in case the getAuthToken function returns same token
|
|
86
|
+
if (this.expiration > 0 && this.expiration < instant) {
|
|
87
|
+
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
88
|
+
Event: TelemetryEvent.NewTokenExpired,
|
|
89
|
+
Description: "New token is already expired",
|
|
90
|
+
ExceptionDetails: {
|
|
91
|
+
"Instant": instant,
|
|
92
|
+
"Expiration": this.expiration
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
throw new Error("New token is already expired, with epoch time " + this.expiration);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async tokenRing() {
|
|
100
|
+
// this is needed for storybooks, specifically for reconnect pane which requires authentication bypass
|
|
101
|
+
if (this.sdkMocked === true) {
|
|
102
|
+
return {
|
|
103
|
+
result: true,
|
|
104
|
+
message: "Authentication not needed"
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (!this.isAuthenticated) {
|
|
108
|
+
return {
|
|
109
|
+
result: true,
|
|
110
|
+
message: "Authentication not needed"
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (this.isTokenSet() && !this.isTokenExpired()) {
|
|
114
|
+
return {
|
|
115
|
+
result: true,
|
|
116
|
+
message: "Token is valid"
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (this.getAuthToken === undefined) {
|
|
120
|
+
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
121
|
+
Event: TelemetryEvent.NewTokenFailed,
|
|
122
|
+
Description: "GetAuthToken function is not present",
|
|
123
|
+
ExceptionDetails: "Missing function : " + getAuthClientFunction(this.chatConfig)
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
result: false,
|
|
127
|
+
message: "GetAuthToken function is not present"
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// if token is not set, or token is already expired , then go to grab a token
|
|
132
|
+
this.token = "";
|
|
133
|
+
this.expiration = 0;
|
|
134
|
+
try {
|
|
135
|
+
const ring = await handleAuthentication(this.chatSDK, this.chatConfig, this.getAuthToken);
|
|
136
|
+
if (ring.result === true && ring.token) {
|
|
137
|
+
await this.setToken(ring.token);
|
|
138
|
+
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.INFO, {
|
|
139
|
+
Event: TelemetryEvent.NewTokenSuccess,
|
|
140
|
+
Description: "New Token obtained",
|
|
141
|
+
Data: {
|
|
142
|
+
"Token_Expiration": this.expiration
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
result: true,
|
|
147
|
+
message: "New Token obtained"
|
|
148
|
+
};
|
|
149
|
+
} else {
|
|
150
|
+
var _ring$error, _ring$error2;
|
|
151
|
+
console.error("Failed to get token", ring);
|
|
152
|
+
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
153
|
+
Event: TelemetryEvent.NewTokenFailed,
|
|
154
|
+
Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
|
|
155
|
+
ExceptionDetails: ring.error
|
|
156
|
+
});
|
|
157
|
+
return {
|
|
158
|
+
result: false,
|
|
159
|
+
message: ((_ring$error2 = ring.error) === null || _ring$error2 === void 0 ? void 0 : _ring$error2.message) || "Failed to get token"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
console.error("Unexpected error while getting token", e);
|
|
164
|
+
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
165
|
+
Event: TelemetryEvent.NewTokenFailed,
|
|
166
|
+
Description: "Unexpected error while getting token",
|
|
167
|
+
ExceptionDetails: e
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
result: false,
|
|
171
|
+
message: "Unexpected error while getting token"
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async validateAndExecuteCall(functionName, fn) {
|
|
176
|
+
const pingResponse = await this.tokenRing();
|
|
177
|
+
if (pingResponse.result === true) {
|
|
178
|
+
return fn();
|
|
179
|
+
}
|
|
180
|
+
const executionErrorMessage = `Authentication failed: Process to get a token failed for ${functionName}, ${pingResponse.message}`;
|
|
181
|
+
//telemetry is already logged in tokenRing, so no need to log again, just return the error and communicate to the console
|
|
182
|
+
console.error(executionErrorMessage);
|
|
183
|
+
BroadcastService.postMessage({
|
|
184
|
+
eventName: BroadcastEvent.OnWidgetError,
|
|
185
|
+
payload: {
|
|
186
|
+
errorMessage: executionErrorMessage
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
throw new Error(executionErrorMessage);
|
|
190
|
+
}
|
|
191
|
+
async initialize() {
|
|
192
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
193
|
+
return this.validateAndExecuteCall("initialize", () => this.chatSDK.initialize(optionalParams));
|
|
194
|
+
}
|
|
195
|
+
async getChatReconnectContext() {
|
|
196
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
197
|
+
return this.validateAndExecuteCall("getChatReconnectContext", () => this.chatSDK.getChatReconnectContext(optionalParams));
|
|
198
|
+
}
|
|
199
|
+
async startChat() {
|
|
200
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
201
|
+
return this.validateAndExecuteCall("startChat", () => this.chatSDK.startChat(optionalParams));
|
|
202
|
+
}
|
|
203
|
+
async endChat() {
|
|
204
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
205
|
+
return this.validateAndExecuteCall("endChat", () => this.chatSDK.endChat(optionalParams));
|
|
206
|
+
}
|
|
207
|
+
async getCurrentLiveChatContext() {
|
|
208
|
+
return this.validateAndExecuteCall("getCurrentLiveChatContext", () => this.chatSDK.getCurrentLiveChatContext());
|
|
209
|
+
}
|
|
210
|
+
async getConversationDetails() {
|
|
211
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
212
|
+
return this.validateAndExecuteCall("getConversationDetails", () => this.chatSDK.getConversationDetails(optionalParams));
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
216
|
+
async getPreChatSurvey() {
|
|
217
|
+
let parse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
218
|
+
//prechat survey is obtained from config object, which is not required to be authenticated
|
|
219
|
+
// removing the tokenRing function from this call for backward compatibility
|
|
220
|
+
// TODO :: wrap this function around authentication
|
|
221
|
+
return this.chatSDK.getPreChatSurvey(parse);
|
|
222
|
+
}
|
|
223
|
+
async getLiveChatConfig(optionalParams) {
|
|
224
|
+
return this.validateAndExecuteCall("getLiveChatConfig", () => this.chatSDK.getLiveChatConfig(optionalParams));
|
|
225
|
+
}
|
|
226
|
+
async getChatToken() {
|
|
227
|
+
let cached = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
228
|
+
let optionalParams = arguments.length > 1 ? arguments[1] : undefined;
|
|
229
|
+
return this.validateAndExecuteCall("getChatToken", () => this.chatSDK.getChatToken(cached, optionalParams));
|
|
230
|
+
}
|
|
231
|
+
async getCallingToken() {
|
|
232
|
+
return this.validateAndExecuteCall("getCallingToken", () => this.chatSDK.getCallingToken());
|
|
233
|
+
}
|
|
234
|
+
async getMessages() {
|
|
235
|
+
return this.validateAndExecuteCall("getMessages", () => this.chatSDK.getMessages());
|
|
236
|
+
}
|
|
237
|
+
async getDataMaskingRules() {
|
|
238
|
+
return this.validateAndExecuteCall("getDataMaskingRules", () => this.chatSDK.getDataMaskingRules());
|
|
239
|
+
}
|
|
240
|
+
async sendMessage(message) {
|
|
241
|
+
return this.validateAndExecuteCall("sendMessage", () => this.chatSDK.sendMessage(message));
|
|
242
|
+
}
|
|
243
|
+
async onNewMessage(onNewMessageCallback) {
|
|
244
|
+
let optionalParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
245
|
+
return this.validateAndExecuteCall("onNewMessage", () => this.chatSDK.onNewMessage(onNewMessageCallback, optionalParams));
|
|
246
|
+
}
|
|
247
|
+
async sendTypingEvent() {
|
|
248
|
+
return this.validateAndExecuteCall("sendTypingEvent", () => this.chatSDK.sendTypingEvent());
|
|
249
|
+
}
|
|
250
|
+
async onTypingEvent(onTypingEventCallback) {
|
|
251
|
+
return this.validateAndExecuteCall("onTypingEvent", () => this.chatSDK.onTypingEvent(onTypingEventCallback));
|
|
252
|
+
}
|
|
253
|
+
async onAgentEndSession(onAgentEndSessionCallback) {
|
|
254
|
+
return this.validateAndExecuteCall("onAgentEndSession", () => this.chatSDK.onAgentEndSession(onAgentEndSessionCallback));
|
|
255
|
+
}
|
|
256
|
+
async uploadFileAttachment(fileInfo) {
|
|
257
|
+
return this.validateAndExecuteCall("uploadFileAttachment", () => this.chatSDK.uploadFileAttachment(fileInfo));
|
|
258
|
+
}
|
|
259
|
+
async downloadFileAttachment(fileMetadata) {
|
|
260
|
+
return this.validateAndExecuteCall("downloadFileAttachment", () => this.chatSDK.downloadFileAttachment(fileMetadata));
|
|
261
|
+
}
|
|
262
|
+
async emailLiveChatTranscript(body) {
|
|
263
|
+
let optionalParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
264
|
+
return this.validateAndExecuteCall("emailLiveChatTranscript", () => this.chatSDK.emailLiveChatTranscript(body, optionalParams));
|
|
265
|
+
}
|
|
266
|
+
async getLiveChatTranscript() {
|
|
267
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
268
|
+
return this.validateAndExecuteCall("getLiveChatTranscript", () => this.chatSDK.getLiveChatTranscript(optionalParams));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// response from origin is unknown, but this definition breaks create adapter for shimAdapter, switching to any until type is returned from origin
|
|
272
|
+
async createChatAdapter() {
|
|
273
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
274
|
+
return this.validateAndExecuteCall("createChatAdapter", () => this.chatSDK.createChatAdapter(optionalParams));
|
|
275
|
+
}
|
|
276
|
+
async isVoiceVideoCallingEnabled() {
|
|
277
|
+
this.tokenRing();
|
|
278
|
+
return this.chatSDK.isVoiceVideoCallingEnabled();
|
|
279
|
+
}
|
|
280
|
+
async getVoiceVideoCalling() {
|
|
281
|
+
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
282
|
+
return this.validateAndExecuteCall("getVoiceVideoCalling", () => this.chatSDK.getVoiceVideoCalling(params));
|
|
283
|
+
}
|
|
284
|
+
async getPostChatSurveyContext() {
|
|
285
|
+
return this.validateAndExecuteCall("getPostChatSurveyContext", () => this.chatSDK.getPostChatSurveyContext());
|
|
286
|
+
}
|
|
287
|
+
async getAgentAvailability() {
|
|
288
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
289
|
+
return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -182,6 +182,7 @@ export let TelemetryEvent;
|
|
|
182
182
|
TelemetryEvent["SendTypingIndicatorSucceeded"] = "SendTypingIndicatorSucceeded";
|
|
183
183
|
TelemetryEvent["SendTypingIndicatorFailed"] = "SendTypingIndicatorFailed";
|
|
184
184
|
TelemetryEvent["WebChatEvent"] = "WebChatEvent";
|
|
185
|
+
TelemetryEvent["FacadeChatSDKEvent"] = "FacadeChatSDKEvent";
|
|
185
186
|
TelemetryEvent["PreChatSurveyStartChatMethodFailed"] = "PreChatSurveyStartChatMethodFailed";
|
|
186
187
|
TelemetryEvent["ChatAlreadyTriggered"] = "ChatAlreadyTriggered";
|
|
187
188
|
TelemetryEvent["StartProactiveChatEventReceived"] = "StartProactiveChatEventReceived";
|
|
@@ -212,6 +213,10 @@ export let TelemetryEvent;
|
|
|
212
213
|
TelemetryEvent["ChatDisconnectThreadEventReceived"] = "ChatDisconnectThreadEventReceived";
|
|
213
214
|
TelemetryEvent["HiddenAdaptiveCardMessageReceived"] = "HiddenAdaptiveCardMessageReceived";
|
|
214
215
|
TelemetryEvent["EndingAdapterAfterDisconnectionError"] = "EndingAdapterAfterDisconnectionError";
|
|
216
|
+
TelemetryEvent["NewTokenSuccess"] = "NewTokenSuccess";
|
|
217
|
+
TelemetryEvent["NewTokenFailed"] = "NewTokenFailed";
|
|
218
|
+
TelemetryEvent["NewTokenExpired"] = "NewTokenExpired";
|
|
219
|
+
TelemetryEvent["TokenEmptyOrSame"] = "TokenEmptyOrSame";
|
|
215
220
|
})(TelemetryEvent || (TelemetryEvent = {}));
|
|
216
221
|
export class TelemetryConstants {
|
|
217
222
|
static map(eventTypeOrScenarioType) {
|
|
@@ -15,6 +15,7 @@ export class TelemetryHelper {
|
|
|
15
15
|
case ScenarioType.WEBCHAT:
|
|
16
16
|
return TelemetryHelper.conformToWebChatContract(level, input);
|
|
17
17
|
case ScenarioType.OCCHATSDK:
|
|
18
|
+
case ScenarioType.SDK:
|
|
18
19
|
return TelemetryHelper.conformToOCChatSDKContract(level, input);
|
|
19
20
|
case ScenarioType.ACTIONS:
|
|
20
21
|
return TelemetryHelper.conformToActionsContract(level, input);
|
|
@@ -150,6 +151,7 @@ export class TelemetryHelper {
|
|
|
150
151
|
event.TransactionId = payload.TransactionId;
|
|
151
152
|
event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
|
|
152
153
|
event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
|
|
154
|
+
event.Description = payload.Description;
|
|
153
155
|
});
|
|
154
156
|
}
|
|
155
157
|
static addChatConfigDataToTelemetry(chatConfig, telemetryInternalData) {
|
|
@@ -255,4 +257,14 @@ _defineProperty(TelemetryHelper, "logWebChatEvent", (logLevel, payload) => {
|
|
|
255
257
|
}
|
|
256
258
|
};
|
|
257
259
|
BroadcastService.postMessage(telemetryEvent);
|
|
260
|
+
});
|
|
261
|
+
_defineProperty(TelemetryHelper, "logFacadeChatSDKEvent", (logLevel, payload) => {
|
|
262
|
+
const telemetryEvent = {
|
|
263
|
+
eventName: (payload === null || payload === void 0 ? void 0 : payload.Event) ?? TelemetryEvent.FacadeChatSDKEvent,
|
|
264
|
+
logLevel: logLevel,
|
|
265
|
+
payload: {
|
|
266
|
+
...payload
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
BroadcastService.postMessage(telemetryEvent);
|
|
258
270
|
});
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -357,7 +357,7 @@ export const isThisSessionPopout = href => {
|
|
|
357
357
|
return false;
|
|
358
358
|
};
|
|
359
359
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
360
|
-
export const getConversationDetailsCall = async function (
|
|
360
|
+
export const getConversationDetailsCall = async function (facadeChatSDK) {
|
|
361
361
|
let liveChatContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
362
362
|
let conversationDetails = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
363
363
|
const optionalParams = {}; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
@@ -370,7 +370,7 @@ export const getConversationDetailsCall = async function (chatSDK) {
|
|
|
370
370
|
Event: TelemetryEvent.GetConversationDetailsCallStarted,
|
|
371
371
|
Description: "Conversation details call started"
|
|
372
372
|
});
|
|
373
|
-
conversationDetails = await
|
|
373
|
+
conversationDetails = await facadeChatSDK.getConversationDetails(optionalParams);
|
|
374
374
|
} catch (error) {
|
|
375
375
|
checkContactIdError(error);
|
|
376
376
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
@@ -4,15 +4,11 @@ import { CallingContainer } from "@microsoft/omnichannel-chat-components";
|
|
|
4
4
|
import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
|
|
5
5
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
6
6
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
7
|
-
import
|
|
7
|
+
import useFacadeSDKStore from "../../hooks/useFacadeChatSDKStore";
|
|
8
8
|
export const CallingContainerStateful = props => {
|
|
9
9
|
var _props$controlProps, _props$controlProps2, _props$controlProps2$, _props$controlProps3, _props$controlProps3$, _props$controlProps3$2, _props$controlProps4, _props$controlProps4$, _props$controlProps4$2, _props$controlProps5;
|
|
10
|
-
//TODO : Close button confirmation implmentation is pending
|
|
11
|
-
|
|
12
10
|
const [state, dispatch] = useChatContextStore();
|
|
13
|
-
|
|
14
|
-
const chatSDK = useChatSDKStore();
|
|
15
|
-
|
|
11
|
+
const [facadeChatSDK] = useFacadeSDKStore();
|
|
16
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
13
|
const {
|
|
18
14
|
voiceVideoCallingSdk
|
|
@@ -45,7 +41,7 @@ export const CallingContainerStateful = props => {
|
|
|
45
41
|
useEffect(() => {
|
|
46
42
|
const init = async () => {
|
|
47
43
|
try {
|
|
48
|
-
var _controlProps$current, _controlProps$current2, _controlProps$current3, _controlProps$current4;
|
|
44
|
+
var _controlProps$current, _controlProps$current2, _controlProps$current3, _controlProps$current4, _facadeChatSDK$getCha;
|
|
49
45
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
46
|
TelemetryHelper.callId = callId;
|
|
51
47
|
await voiceVideoCallingSdk.initialize({
|
|
@@ -54,7 +50,7 @@ export const CallingContainerStateful = props => {
|
|
|
54
50
|
// HTML element id where video stream of the agent will be rendered
|
|
55
51
|
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,
|
|
56
52
|
// HTML element id where video stream of the customer will be rendered
|
|
57
|
-
OCClient:
|
|
53
|
+
OCClient: (_facadeChatSDK$getCha = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha === void 0 ? void 0 : _facadeChatSDK$getCha.OCClient
|
|
58
54
|
});
|
|
59
55
|
} catch (e) {
|
|
60
56
|
TelemetryHelper.logCallingEvent(LogLevel.ERROR, {
|
|
@@ -8,16 +8,15 @@ import { NotificationHandler } from "../webchatcontainerstateful/webchatcontroll
|
|
|
8
8
|
import { NotificationScenarios } from "../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
9
9
|
import { Regex } from "../../common/Constants";
|
|
10
10
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
11
|
-
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
12
|
-
import useChatSDKStore from "../../hooks/useChatSDKStore";
|
|
13
11
|
import { defaultMiddlewareLocalizedTexts } from "../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
12
|
+
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
13
|
+
import useFacadeSDKStore from "../../hooks/useFacadeChatSDKStore";
|
|
14
14
|
export const EmailTranscriptPaneStateful = props => {
|
|
15
15
|
var _props$controlProps;
|
|
16
16
|
const initialTabIndexMap = new Map();
|
|
17
17
|
let elements = [];
|
|
18
18
|
const [state, dispatch] = useChatContextStore();
|
|
19
|
-
|
|
20
|
-
const chatSDK = useChatSDKStore();
|
|
19
|
+
const [facadeChatSDK] = useFacadeSDKStore();
|
|
21
20
|
const [initialEmail, setInitialEmail] = useState("");
|
|
22
21
|
const closeEmailTranscriptPane = () => {
|
|
23
22
|
dispatch({
|
|
@@ -45,7 +44,7 @@ export const EmailTranscriptPaneStateful = props => {
|
|
|
45
44
|
attachmentMessage: (props === null || props === void 0 ? void 0 : props.attachmentMessage) ?? "The following attachment was uploaded during the conversation:"
|
|
46
45
|
};
|
|
47
46
|
try {
|
|
48
|
-
await (
|
|
47
|
+
await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.emailLiveChatTranscript(chatTranscriptBody, {
|
|
49
48
|
liveChatContext
|
|
50
49
|
}));
|
|
51
50
|
NotificationHandler.notifySuccess(NotificationScenarios.EmailAddressSaved, defaultMiddlewareLocalizedTexts === null || defaultMiddlewareLocalizedTexts === void 0 ? void 0 : defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_SUCCESS);
|
|
@@ -63,7 +62,7 @@ export const EmailTranscriptPaneStateful = props => {
|
|
|
63
62
|
const message = formatTemplateString(defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_FILE_EMAIL_ADDRESS_RECORDED_ERROR, [email]);
|
|
64
63
|
NotificationHandler.notifyError(NotificationScenarios.EmailTranscriptError, (props === null || props === void 0 ? void 0 : props.bannerMessageOnError) ?? message);
|
|
65
64
|
}
|
|
66
|
-
}, [props.attachmentMessage, props.bannerMessageOnError,
|
|
65
|
+
}, [props.attachmentMessage, props.bannerMessageOnError, facadeChatSDK, state.domainStates.liveChatContext]);
|
|
67
66
|
const controlProps = {
|
|
68
67
|
id: "oclcw-emailTranscriptDialogContainer",
|
|
69
68
|
dir: state.domainStates.globalDir,
|
|
@@ -2,6 +2,7 @@ import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConsta
|
|
|
2
2
|
import React, { useEffect } from "react";
|
|
3
3
|
import AudioNotificationStateful from "./audionotificationstateful/AudioNotificationStateful";
|
|
4
4
|
import { Constants } from "../../common/Constants";
|
|
5
|
+
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
5
6
|
import { Footer } from "@microsoft/omnichannel-chat-components";
|
|
6
7
|
import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
|
|
7
8
|
import { NewMessageNotificationSoundBase64 } from "../../assets/Audios";
|
|
@@ -10,8 +11,7 @@ import { NotificationScenarios } from "../webchatcontainerstateful/webchatcontro
|
|
|
10
11
|
import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
|
|
11
12
|
import { downloadTranscript } from "./downloadtranscriptstateful/DownloadTranscriptStateful";
|
|
12
13
|
import useChatContextStore from "../../hooks/useChatContextStore";
|
|
13
|
-
import
|
|
14
|
-
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
14
|
+
import useFacadeSDKStore from "../../hooks/useFacadeChatSDKStore";
|
|
15
15
|
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
17
|
export const FooterStateful = props => {
|
|
@@ -26,8 +26,7 @@ export const FooterStateful = props => {
|
|
|
26
26
|
audioNotificationProps,
|
|
27
27
|
hideFooterDisplay
|
|
28
28
|
} = props;
|
|
29
|
-
|
|
30
|
-
const chatSDK = useChatSDKStore();
|
|
29
|
+
const [facadeChatSDK] = useFacadeSDKStore();
|
|
31
30
|
const controlProps = {
|
|
32
31
|
id: "oc-lcw-footer",
|
|
33
32
|
dir: state.domainStates.globalDir,
|
|
@@ -37,7 +36,7 @@ export const FooterStateful = props => {
|
|
|
37
36
|
Event: TelemetryEvent.DownloadTranscriptButtonClicked,
|
|
38
37
|
Description: "Download Transcript button clicked."
|
|
39
38
|
});
|
|
40
|
-
await downloadTranscript(
|
|
39
|
+
await downloadTranscript(facadeChatSDK, downloadTranscriptProps, state);
|
|
41
40
|
} catch (ex) {
|
|
42
41
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
43
42
|
Event: TelemetryEvent.DownloadTranscriptFailed,
|
package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Constants, TranscriptConstants } from "../../../common/Constants";
|
|
2
|
-
import {
|
|
2
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
+
import { createFileAndDownload, isNullOrUndefined } from "../../../common/utils";
|
|
4
|
+
import DOMPurify from "dompurify";
|
|
5
|
+
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
3
6
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
7
|
+
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
4
8
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
6
9
|
import createChatTranscript from "../../../plugins/createChatTranscript";
|
|
7
|
-
import DOMPurify from "dompurify";
|
|
8
|
-
import { createFileAndDownload, isNullOrUndefined } from "../../../common/utils";
|
|
9
10
|
import { executeReducer } from "../../../contexts/createReducer";
|
|
10
|
-
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
11
11
|
const processDisplayName = displayName => {
|
|
12
12
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
13
13
|
const displayNameRegex = ".+:.+";
|
|
@@ -156,9 +156,7 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
156
156
|
const str = docTypeTag + docStartTag + docMetaTag + bodyStartTag + mainTranscriptSection + beautifiedChats + divEndTag + bodyEndTag + docEndTag;
|
|
157
157
|
return str;
|
|
158
158
|
};
|
|
159
|
-
|
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
161
|
-
export const downloadTranscript = async (chatSDK, downloadTranscriptProps, state) => {
|
|
159
|
+
export const downloadTranscript = async (facadeChatSDK, downloadTranscriptProps, state) => {
|
|
162
160
|
var _state$domainStates;
|
|
163
161
|
// Need to keep existing live chat context for scenarios when transcript is downloaded after endchat
|
|
164
162
|
let liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext;
|
|
@@ -169,7 +167,7 @@ export const downloadTranscript = async (chatSDK, downloadTranscriptProps, state
|
|
|
169
167
|
});
|
|
170
168
|
liveChatContext = inMemoryState.domainStates.liveChatContext;
|
|
171
169
|
}
|
|
172
|
-
let data = await (
|
|
170
|
+
let data = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getLiveChatTranscript({
|
|
173
171
|
liveChatContext
|
|
174
172
|
}));
|
|
175
173
|
if (typeof data === Constants.String) {
|
|
@@ -187,7 +185,7 @@ export const downloadTranscript = async (chatSDK, downloadTranscriptProps, state
|
|
|
187
185
|
const transcriptOptions = {
|
|
188
186
|
...webChatTranscript
|
|
189
187
|
};
|
|
190
|
-
await createChatTranscript(data[Constants.ChatMessagesJson],
|
|
188
|
+
await createChatTranscript(data[Constants.ChatMessagesJson], facadeChatSDK, false, transcriptOptions);
|
|
191
189
|
} else {
|
|
192
190
|
// Legacy Transcript
|
|
193
191
|
const chatTranscripts = window.btoa(encodeURIComponent(beautifyChatTranscripts(data[Constants.ChatMessagesJson], renderMarkDown, attachmentMessage)));
|