@microsoft/omnichannel-chat-widget 1.6.4 → 1.6.5-main.ab77d74
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/components/livechatwidget/common/endChat.js +26 -7
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +1 -2
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +13 -1
- package/lib/cjs/plugins/createChatTranscript.js +7 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +26 -7
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +1 -2
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +13 -1
- package/lib/esm/plugins/createChatTranscript.js +7 -0
- package/package.json +3 -3
|
@@ -6,21 +6,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.prepareEndChat = exports.endVoiceVideoCallIfOngoing = exports.endChatStateCleanUp = exports.endChat = exports.closeChatStateCleanUp = exports.chatSDKStateCleanUp = exports.callingStateCleanUp = void 0;
|
|
7
7
|
var _Constants = require("../../../common/Constants");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
-
var _authHelper = require("./authHelper");
|
|
10
9
|
var _utils = require("../../../common/utils");
|
|
11
10
|
var _renderSurveyHelpers = require("./renderSurveyHelpers");
|
|
12
11
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
13
12
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
14
13
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
15
14
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
15
|
+
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
16
16
|
var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
|
|
17
17
|
var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
|
|
18
|
-
var
|
|
18
|
+
var _createReducer = require("../../../contexts/createReducer");
|
|
19
|
+
var _authHelper = require("./authHelper");
|
|
20
|
+
var _reconnectChatHelper = require("./reconnectChatHelper");
|
|
19
21
|
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
20
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
23
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
22
24
|
try {
|
|
23
25
|
var _conversationDetails$, _state$domainStates, _state$appStates3;
|
|
26
|
+
const {
|
|
27
|
+
chatConfig
|
|
28
|
+
} = props;
|
|
29
|
+
|
|
24
30
|
// Use Case: If call is ongoing, end the call by simulating end call button click
|
|
25
31
|
endVoiceVideoCallIfOngoing(chatSDK, dispatch);
|
|
26
32
|
const conversationDetails = await (0, _utils.getConversationDetailsCall)(chatSDK);
|
|
@@ -80,12 +86,25 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
80
86
|
Description: `${_Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat} ${state === null || state === void 0 ? void 0 : (_state$appStates4 = state.appStates) === null || _state$appStates4 === void 0 ? void 0 : _state$appStates4.conversationEndedBy}.`
|
|
81
87
|
});
|
|
82
88
|
}
|
|
83
|
-
|
|
89
|
+
const persistentEnabled = (0, _reconnectChatHelper.isPersistentEnabled)(chatConfig);
|
|
90
|
+
const {
|
|
91
|
+
appStates
|
|
92
|
+
} = (0, _createReducer.executeReducer)(state, {
|
|
93
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
94
|
+
payload: undefined
|
|
95
|
+
});
|
|
96
|
+
const endedByCustomer = (appStates === null || appStates === void 0 ? void 0 : appStates.conversationEndedBy) === "Customer";
|
|
84
97
|
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
const commonParams = [props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter];
|
|
100
|
+
if (persistentEnabled && endedByCustomer) {
|
|
101
|
+
await endChat(...commonParams, true, false, true);
|
|
102
|
+
} else {
|
|
103
|
+
await endChat(...commonParams, false, true, true);
|
|
104
|
+
if (postchatContext) {
|
|
105
|
+
await (0, _renderSurveyHelpers.initiatePostChat)(props, conversationDetails, state, dispatch, postchatContext);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
89
108
|
}
|
|
90
109
|
} catch (error) {
|
|
91
110
|
var _props$controlProps;
|
|
@@ -40,7 +40,7 @@ var _toastMiddleware = _interopRequireDefault(require("../../webchatcontainersta
|
|
|
40
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
41
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
42
|
const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) => {
|
|
43
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$
|
|
43
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain13, _props$webChatContain14, _defaultWebChatContai, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai2, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai3, _props$webChatContain23, _props$webChatContain24;
|
|
44
44
|
// Add a hook to make all links open a new window
|
|
45
45
|
postDomPurifyActivities();
|
|
46
46
|
const localizedTexts = {
|
|
@@ -120,7 +120,6 @@ const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) => {
|
|
|
120
120
|
// Initialize the remaining Web Chat props
|
|
121
121
|
const webChatProps = {
|
|
122
122
|
..._defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps,
|
|
123
|
-
userID: ((_state$domainStates$c = state.domainStates.chatToken) === null || _state$domainStates$c === void 0 ? void 0 : _state$domainStates$c.visitorId) || "teamsvisitor",
|
|
124
123
|
dir: state.domainStates.globalDir,
|
|
125
124
|
locale: (0, _utils.changeLanguageCodeFormatForWebChat)((0, _omnichannelChatSdk.getLocaleStringFromId)((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
|
|
126
125
|
store: webChatStore,
|
|
@@ -358,7 +358,19 @@ const LiveChatWidgetStateful = props => {
|
|
|
358
358
|
|
|
359
359
|
// Start chat from SDK Event
|
|
360
360
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
|
|
361
|
-
var _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
361
|
+
var _props$chatConfig4, _props$chatConfig4$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
362
|
+
// If chat is out of operating hours chat widget sets the conversation state to OutOfOffice.
|
|
363
|
+
if ((props === null || props === void 0 ? void 0 : (_props$chatConfig4 = props.chatConfig) === null || _props$chatConfig4 === void 0 ? void 0 : (_props$chatConfig4$Li = _props$chatConfig4.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig4$Li === void 0 ? void 0 : _props$chatConfig4$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
364
|
+
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
365
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
366
|
+
payload: false
|
|
367
|
+
});
|
|
368
|
+
dispatch({
|
|
369
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
370
|
+
payload: _ConversationState.ConversationState.OutOfOffice
|
|
371
|
+
});
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
362
374
|
// If the startChat event is not initiated by the same tab. Ignore the call
|
|
363
375
|
if (!(0, _utils.isNullOrUndefined)(msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload6 = msg.payload) === null || _msg$payload6 === void 0 ? void 0 : _msg$payload6.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
364
376
|
return;
|
|
@@ -64,6 +64,12 @@ class TranscriptHTMLBuilder {
|
|
|
64
64
|
this.disableNewLineMarkdownSupport = this.options.disableNewLineMarkdownSupport;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
createMetaElement() {
|
|
68
|
+
const htmlData = `
|
|
69
|
+
<meta charset="UTF-8">
|
|
70
|
+
`;
|
|
71
|
+
return htmlData;
|
|
72
|
+
}
|
|
67
73
|
createTitleElement() {
|
|
68
74
|
const htmlData = `<title> ${this.pageTitle} </title>`;
|
|
69
75
|
return htmlData;
|
|
@@ -81,6 +87,7 @@ class TranscriptHTMLBuilder {
|
|
|
81
87
|
createHeadElement() {
|
|
82
88
|
const htmlData = `
|
|
83
89
|
<head>
|
|
90
|
+
${this.createMetaElement()}
|
|
84
91
|
${this.createTitleElement()}
|
|
85
92
|
${this.createExternalScriptElements()}
|
|
86
93
|
<script>
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { ConfirmationState, Constants, ConversationEndEntity, ParticipantType, PrepareEndChatDescriptionConstants } from "../../../common/Constants";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
-
import { handleAuthentication } from "./authHelper";
|
|
4
3
|
import { getConversationDetailsCall, getWidgetEndChatEventName } from "../../../common/utils";
|
|
5
4
|
import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
|
|
6
5
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
6
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
8
7
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
9
8
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
9
|
+
import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
10
10
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
11
11
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
12
|
-
import {
|
|
12
|
+
import { executeReducer } from "../../../contexts/createReducer";
|
|
13
|
+
import { handleAuthentication } from "./authHelper";
|
|
14
|
+
import { isPersistentEnabled } from "./reconnectChatHelper";
|
|
13
15
|
import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
|
|
14
16
|
|
|
15
17
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
18
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
17
19
|
try {
|
|
18
20
|
var _conversationDetails$, _state$domainStates, _state$appStates3;
|
|
21
|
+
const {
|
|
22
|
+
chatConfig
|
|
23
|
+
} = props;
|
|
24
|
+
|
|
19
25
|
// Use Case: If call is ongoing, end the call by simulating end call button click
|
|
20
26
|
endVoiceVideoCallIfOngoing(chatSDK, dispatch);
|
|
21
27
|
const conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
@@ -75,12 +81,25 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
75
81
|
Description: `${PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat} ${state === null || state === void 0 ? void 0 : (_state$appStates4 = state.appStates) === null || _state$appStates4 === void 0 ? void 0 : _state$appStates4.conversationEndedBy}.`
|
|
76
82
|
});
|
|
77
83
|
}
|
|
78
|
-
|
|
84
|
+
const persistentEnabled = isPersistentEnabled(chatConfig);
|
|
85
|
+
const {
|
|
86
|
+
appStates
|
|
87
|
+
} = executeReducer(state, {
|
|
88
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
89
|
+
payload: undefined
|
|
90
|
+
});
|
|
91
|
+
const endedByCustomer = (appStates === null || appStates === void 0 ? void 0 : appStates.conversationEndedBy) === "Customer";
|
|
79
92
|
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
+
const commonParams = [props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter];
|
|
95
|
+
if (persistentEnabled && endedByCustomer) {
|
|
96
|
+
await endChat(...commonParams, true, false, true);
|
|
97
|
+
} else {
|
|
98
|
+
await endChat(...commonParams, false, true, true);
|
|
99
|
+
if (postchatContext) {
|
|
100
|
+
await initiatePostChat(props, conversationDetails, state, dispatch, postchatContext);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
84
103
|
}
|
|
85
104
|
} catch (error) {
|
|
86
105
|
var _props$controlProps;
|
|
@@ -34,7 +34,7 @@ import createToastMiddleware from "../../webchatcontainerstateful/webchatcontrol
|
|
|
34
34
|
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
36
|
export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) => {
|
|
37
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$
|
|
37
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain13, _props$webChatContain14, _defaultWebChatContai, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai2, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai3, _props$webChatContain23, _props$webChatContain24;
|
|
38
38
|
// Add a hook to make all links open a new window
|
|
39
39
|
postDomPurifyActivities();
|
|
40
40
|
const localizedTexts = {
|
|
@@ -114,7 +114,6 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
|
|
|
114
114
|
// Initialize the remaining Web Chat props
|
|
115
115
|
const webChatProps = {
|
|
116
116
|
...defaultWebChatContainerStatefulProps.webChatProps,
|
|
117
|
-
userID: ((_state$domainStates$c = state.domainStates.chatToken) === null || _state$domainStates$c === void 0 ? void 0 : _state$domainStates$c.visitorId) || "teamsvisitor",
|
|
118
117
|
dir: state.domainStates.globalDir,
|
|
119
118
|
locale: changeLanguageCodeFormatForWebChat(getLocaleStringFromId((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
|
|
120
119
|
store: webChatStore,
|
|
@@ -350,7 +350,19 @@ export const LiveChatWidgetStateful = props => {
|
|
|
350
350
|
|
|
351
351
|
// Start chat from SDK Event
|
|
352
352
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
|
|
353
|
-
var _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
353
|
+
var _props$chatConfig4, _props$chatConfig4$Li, _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
354
|
+
// If chat is out of operating hours chat widget sets the conversation state to OutOfOffice.
|
|
355
|
+
if ((props === null || props === void 0 ? void 0 : (_props$chatConfig4 = props.chatConfig) === null || _props$chatConfig4 === void 0 ? void 0 : (_props$chatConfig4$Li = _props$chatConfig4.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig4$Li === void 0 ? void 0 : _props$chatConfig4$Li.OutOfOperatingHours.toLowerCase()) === "true") {
|
|
356
|
+
(state === null || state === void 0 ? void 0 : state.appStates.isMinimized) && dispatch({
|
|
357
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
358
|
+
payload: false
|
|
359
|
+
});
|
|
360
|
+
dispatch({
|
|
361
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
362
|
+
payload: ConversationState.OutOfOffice
|
|
363
|
+
});
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
354
366
|
// If the startChat event is not initiated by the same tab. Ignore the call
|
|
355
367
|
if (!isNullOrUndefined(msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload6 = msg.payload) === null || _msg$payload6 === void 0 ? void 0 : _msg$payload6.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
356
368
|
return;
|
|
@@ -60,6 +60,12 @@ class TranscriptHTMLBuilder {
|
|
|
60
60
|
this.disableNewLineMarkdownSupport = this.options.disableNewLineMarkdownSupport;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
createMetaElement() {
|
|
64
|
+
const htmlData = `
|
|
65
|
+
<meta charset="UTF-8">
|
|
66
|
+
`;
|
|
67
|
+
return htmlData;
|
|
68
|
+
}
|
|
63
69
|
createTitleElement() {
|
|
64
70
|
const htmlData = `<title> ${this.pageTitle} </title>`;
|
|
65
71
|
return htmlData;
|
|
@@ -77,6 +83,7 @@ class TranscriptHTMLBuilder {
|
|
|
77
83
|
createHeadElement() {
|
|
78
84
|
const htmlData = `
|
|
79
85
|
<head>
|
|
86
|
+
${this.createMetaElement()}
|
|
80
87
|
${this.createTitleElement()}
|
|
81
88
|
${this.createExternalScriptElements()}
|
|
82
89
|
<script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5-main.ab77d74",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@microsoft/omnichannel-chat-components": "1.1.5",
|
|
78
|
-
"@microsoft/omnichannel-chat-sdk": "^1.8.
|
|
78
|
+
"@microsoft/omnichannel-chat-sdk": "^1.8.2",
|
|
79
79
|
"abort-controller-es5": "^2.0.1",
|
|
80
80
|
"dompurify": "^2.3.4",
|
|
81
81
|
"markdown-it": "^12.3.2",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"p-defer-es5": "^2.0.1",
|
|
87
87
|
"sanitize-html": "2.12.1",
|
|
88
88
|
"slack-markdown-it": "^1.0.5",
|
|
89
|
-
"simple-update-in":"2.2.0"
|
|
89
|
+
"simple-update-in": "2.2.0"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"storybook": "start-storybook -p 6006",
|