@microsoft/omnichannel-chat-widget 1.4.1-main.e64f91f → 1.4.1-main.e6586cc
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 +3 -5
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +11 -9
- package/lib/esm/components/livechatwidget/common/endChat.js +3 -5
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +11 -9
- package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +1 -1
- package/package.json +2 -2
|
@@ -19,7 +19,7 @@ var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
20
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
21
21
|
try {
|
|
22
|
-
var _conversationDetails$, _state$domainStates
|
|
22
|
+
var _conversationDetails$, _state$domainStates;
|
|
23
23
|
// Use Case: If call is ongoing, end the call by simulating end call button click
|
|
24
24
|
endVoiceVideoCallIfOngoing(chatSDK, dispatch);
|
|
25
25
|
const conversationDetails = await (0, _utils.getConversationDetailsCall)(chatSDK);
|
|
@@ -44,10 +44,8 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
// Use Case: Can render post chat scenarios
|
|
47
|
-
await (0, _renderSurveyHelpers.getPostChatContext)(chatSDK, state, dispatch);
|
|
48
|
-
|
|
49
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
-
const postchatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext;
|
|
48
|
+
const postchatContext = (await (0, _renderSurveyHelpers.getPostChatContext)(chatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
|
|
51
49
|
if (postchatContext === undefined) {
|
|
52
50
|
var _state$appStates2;
|
|
53
51
|
// For Customer intiated conversations, just close chat widget
|
|
@@ -66,7 +64,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
66
64
|
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, true, true);
|
|
67
65
|
|
|
68
66
|
// Initiate post chat render
|
|
69
|
-
if (
|
|
67
|
+
if (postchatContext) {
|
|
70
68
|
await (0, _renderSurveyHelpers.initiatePostChat)(props, conversationDetails, state, dispatch, postchatContext);
|
|
71
69
|
return;
|
|
72
70
|
}
|
|
@@ -48,24 +48,25 @@ const setSurveyMode = async (props, participantType, state, dispatch) => {
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
const renderSurvey = async (postChatContext, dispatch) => {
|
|
52
54
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
|
|
53
55
|
setWidgetStateToInactive(dispatch);
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
58
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
57
|
-
await embedModePostChatWorkflow(
|
|
59
|
+
await embedModePostChatWorkflow(postChatContext, dispatch);
|
|
58
60
|
}
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
// Function for embed mode postchat workflow which is essentially same for both customer and agent
|
|
62
64
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
-
const embedModePostChatWorkflow = async (
|
|
64
|
-
var _state$domainStates2;
|
|
65
|
+
const embedModePostChatWorkflow = async (postChatContext, dispatch) => {
|
|
65
66
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
66
67
|
Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
|
|
67
68
|
});
|
|
68
|
-
if (
|
|
69
|
+
if (postChatContext) {
|
|
69
70
|
dispatch({
|
|
70
71
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
71
72
|
payload: _ConversationState.ConversationState.PostchatLoading
|
|
@@ -76,7 +77,7 @@ const embedModePostChatWorkflow = async (state, dispatch) => {
|
|
|
76
77
|
payload: _ConversationState.ConversationState.Postchat
|
|
77
78
|
});
|
|
78
79
|
} else {
|
|
79
|
-
const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${
|
|
80
|
+
const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${postChatContext}`;
|
|
80
81
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
81
82
|
Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
|
|
82
83
|
ExceptionDetails: {
|
|
@@ -92,7 +93,7 @@ const initiatePostChat = async (props, conversationDetailsParam, state, dispatch
|
|
|
92
93
|
conversationDetails = conversationDetailsParam;
|
|
93
94
|
const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
|
|
94
95
|
await setSurveyMode(props, participantType, state, dispatch);
|
|
95
|
-
await renderSurvey(
|
|
96
|
+
await renderSurvey(postchatContext, dispatch);
|
|
96
97
|
};
|
|
97
98
|
|
|
98
99
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -107,8 +108,8 @@ const isPostChatEnabled = (props, state) => {
|
|
|
107
108
|
exports.checkPostChatEnabled = isPostChatEnabled;
|
|
108
109
|
const getPostChatContext = async (chatSDK, state, dispatch) => {
|
|
109
110
|
try {
|
|
110
|
-
var _state$
|
|
111
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
111
|
+
var _state$domainStates2;
|
|
112
|
+
if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
|
|
112
113
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
114
|
const context = await chatSDK.getPostChatSurveyContext();
|
|
114
115
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -119,6 +120,7 @@ const getPostChatContext = async (chatSDK, state, dispatch) => {
|
|
|
119
120
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
|
|
120
121
|
payload: context
|
|
121
122
|
});
|
|
123
|
+
return context;
|
|
122
124
|
}
|
|
123
125
|
} catch (error) {
|
|
124
126
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -14,7 +14,7 @@ import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
15
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
16
16
|
try {
|
|
17
|
-
var _conversationDetails$, _state$domainStates
|
|
17
|
+
var _conversationDetails$, _state$domainStates;
|
|
18
18
|
// Use Case: If call is ongoing, end the call by simulating end call button click
|
|
19
19
|
endVoiceVideoCallIfOngoing(chatSDK, dispatch);
|
|
20
20
|
const conversationDetails = await getConversationDetailsCall(chatSDK);
|
|
@@ -39,10 +39,8 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// Use Case: Can render post chat scenarios
|
|
42
|
-
await getPostChatContext(chatSDK, state, dispatch);
|
|
43
|
-
|
|
44
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
-
const postchatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext;
|
|
43
|
+
const postchatContext = (await getPostChatContext(chatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
|
|
46
44
|
if (postchatContext === undefined) {
|
|
47
45
|
var _state$appStates2;
|
|
48
46
|
// For Customer intiated conversations, just close chat widget
|
|
@@ -61,7 +59,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
|
|
|
61
59
|
endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, true, true);
|
|
62
60
|
|
|
63
61
|
// Initiate post chat render
|
|
64
|
-
if (
|
|
62
|
+
if (postchatContext) {
|
|
65
63
|
await initiatePostChat(props, conversationDetails, state, dispatch, postchatContext);
|
|
66
64
|
return;
|
|
67
65
|
}
|
|
@@ -42,24 +42,25 @@ const setSurveyMode = async (props, participantType, state, dispatch) => {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
const renderSurvey = async (postChatContext, dispatch) => {
|
|
46
48
|
if (postChatSurveyMode === PostChatSurveyMode.Link) {
|
|
47
49
|
setWidgetStateToInactive(dispatch);
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
52
|
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
51
|
-
await embedModePostChatWorkflow(
|
|
53
|
+
await embedModePostChatWorkflow(postChatContext, dispatch);
|
|
52
54
|
}
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
// Function for embed mode postchat workflow which is essentially same for both customer and agent
|
|
56
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
-
const embedModePostChatWorkflow = async (
|
|
58
|
-
var _state$domainStates2;
|
|
59
|
+
const embedModePostChatWorkflow = async (postChatContext, dispatch) => {
|
|
59
60
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
60
61
|
Event: TelemetryEvent.EmbedModePostChatWorkflowStarted
|
|
61
62
|
});
|
|
62
|
-
if (
|
|
63
|
+
if (postChatContext) {
|
|
63
64
|
dispatch({
|
|
64
65
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
65
66
|
payload: ConversationState.PostchatLoading
|
|
@@ -70,7 +71,7 @@ const embedModePostChatWorkflow = async (state, dispatch) => {
|
|
|
70
71
|
payload: ConversationState.Postchat
|
|
71
72
|
});
|
|
72
73
|
} else {
|
|
73
|
-
const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${
|
|
74
|
+
const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${postChatContext}`;
|
|
74
75
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
75
76
|
Event: TelemetryEvent.AppStatesException,
|
|
76
77
|
ExceptionDetails: {
|
|
@@ -86,7 +87,7 @@ const initiatePostChat = async (props, conversationDetailsParam, state, dispatch
|
|
|
86
87
|
conversationDetails = conversationDetailsParam;
|
|
87
88
|
const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
|
|
88
89
|
await setSurveyMode(props, participantType, state, dispatch);
|
|
89
|
-
await renderSurvey(
|
|
90
|
+
await renderSurvey(postchatContext, dispatch);
|
|
90
91
|
};
|
|
91
92
|
|
|
92
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -99,8 +100,8 @@ const isPostChatEnabled = (props, state) => {
|
|
|
99
100
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
101
|
const getPostChatContext = async (chatSDK, state, dispatch) => {
|
|
101
102
|
try {
|
|
102
|
-
var _state$
|
|
103
|
-
if ((state === null || state === void 0 ? void 0 : (_state$
|
|
103
|
+
var _state$domainStates2;
|
|
104
|
+
if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
|
|
104
105
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
106
|
const context = await chatSDK.getPostChatSurveyContext();
|
|
106
107
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
@@ -111,6 +112,7 @@ const getPostChatContext = async (chatSDK, state, dispatch) => {
|
|
|
111
112
|
type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
|
|
112
113
|
payload: context
|
|
113
114
|
});
|
|
115
|
+
return context;
|
|
114
116
|
}
|
|
115
117
|
} catch (error) {
|
|
116
118
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
@@ -4,6 +4,6 @@ import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidget
|
|
|
4
4
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
5
5
|
declare const initiatePostChat: (props: ILiveChatWidgetProps, conversationDetailsParam: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, postchatContext: any) => Promise<void>;
|
|
6
6
|
declare const isPostChatEnabled: (props: ILiveChatWidgetProps, state: ILiveChatWidgetContext) => boolean;
|
|
7
|
-
declare const getPostChatContext: (chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<
|
|
7
|
+
declare const getPostChatContext: (chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<any>;
|
|
8
8
|
declare const setWidgetStateToInactive: (dispatch: Dispatch<ILiveChatWidgetAction>) => Promise<void>;
|
|
9
9
|
export { initiatePostChat, setWidgetStateToInactive, getPostChatContext, isPostChatEnabled as checkPostChatEnabled };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.4.1-main.
|
|
3
|
+
"version": "1.4.1-main.e6586cc",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"webpack-cli": "^4.9.2"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@microsoft/omnichannel-chat-components": "^1.0.
|
|
77
|
+
"@microsoft/omnichannel-chat-components": "^1.0.8",
|
|
78
78
|
"@microsoft/omnichannel-chat-sdk": "1.5.4",
|
|
79
79
|
"abort-controller-es5": "^2.0.1",
|
|
80
80
|
"dompurify": "^2.3.4",
|