@microsoft/omnichannel-chat-widget 1.7.3-main.7a38853 → 1.7.3-main.9d92cc9
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/telemetry/TelemetryConstants.js +1 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +20 -5
- package/lib/cjs/components/livechatwidget/common/startChat.js +15 -10
- package/lib/esm/common/telemetry/TelemetryConstants.js +1 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +20 -5
- package/lib/esm/components/livechatwidget/common/startChat.js +15 -10
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +1 -0
- package/package.json +2 -2
|
@@ -101,6 +101,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
101
101
|
TelemetryEvent["GetConversationDetailsCallStarted"] = "GetConversationDetailsCallStarted";
|
|
102
102
|
TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
|
|
103
103
|
TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
|
|
104
|
+
TelemetryEvent["DisconnectEndChatSDKCallFailed"] = "DisconnectEndChatSDKCallFailed";
|
|
104
105
|
TelemetryEvent["GetChatReconnectContextSDKCallStarted"] = "GetChatReconnectContextSDKCallStarted";
|
|
105
106
|
TelemetryEvent["GetChatReconnectContextSDKCallFailed"] = "GetChatReconnectContextSDKCallFailed";
|
|
106
107
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
@@ -141,12 +141,27 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
141
141
|
await (0, _authHelper.handleAuthentication)(chatSDK, props.chatConfig, props.getAuthToken);
|
|
142
142
|
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
143
143
|
} catch (ex) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
144
|
+
var _inMemoryState$appSta;
|
|
145
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
146
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
147
|
+
payload: null
|
|
149
148
|
});
|
|
149
|
+
// if the chat was disconnected or ended by the agent, we don't want to log the error
|
|
150
|
+
if (!(inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$appSta = inMemoryState.appStates) !== null && _inMemoryState$appSta !== void 0 && _inMemoryState$appSta.chatDisconnectEventReceived)) {
|
|
151
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
152
|
+
Event: _TelemetryConstants.TelemetryEvent.EndChatSDKCallFailed,
|
|
153
|
+
ExceptionDetails: {
|
|
154
|
+
exception: ex
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
159
|
+
Event: _TelemetryConstants.TelemetryEvent.DisconnectEndChatSDKCallFailed,
|
|
160
|
+
ExceptionDetails: {
|
|
161
|
+
exception: ex
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
150
165
|
postMessageToOtherTab = false;
|
|
151
166
|
} finally {
|
|
152
167
|
await endChatStateCleanUp(dispatch);
|
|
@@ -30,6 +30,20 @@ let widgetInstanceId;
|
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
31
|
let popoutWidgetInstanceId;
|
|
32
32
|
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
const setAuthenticationIfApplicable = async (props, chatSDK) => {
|
|
35
|
+
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
36
|
+
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
37
|
+
const authClientFunction = (0, _authHelper.getAuthClientFunction)(chatConfig);
|
|
38
|
+
if (getAuthToken && authClientFunction) {
|
|
39
|
+
// set auth token to chat sdk before start chat
|
|
40
|
+
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, getAuthToken);
|
|
41
|
+
if (!authSuccess) {
|
|
42
|
+
throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
33
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
48
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
35
49
|
optionalParams = {}; //Resetting to ensure no stale values
|
|
@@ -55,6 +69,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
55
69
|
// Setting Proactive chat settings
|
|
56
70
|
const isProactiveChat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat;
|
|
57
71
|
const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
|
|
72
|
+
await setAuthenticationIfApplicable(props, chatSDK);
|
|
58
73
|
|
|
59
74
|
//Setting PreChat and intiate chat
|
|
60
75
|
await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
|
|
@@ -132,8 +147,6 @@ exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
|
132
147
|
const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
133
148
|
var _state$domainStates5, _state$domainStates5$, _state$domainStates5$2;
|
|
134
149
|
let isStartChatSuccessful = false;
|
|
135
|
-
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
136
|
-
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
137
150
|
const persistentChatEnabled = await (0, _liveChatConfigUtils.isPersistentChatEnabled)(state === null || state === void 0 ? void 0 : (_state$domainStates5 = state.domainStates) === null || _state$domainStates5 === void 0 ? void 0 : (_state$domainStates5$ = _state$domainStates5.liveChatConfig) === null || _state$domainStates5$ === void 0 ? void 0 : (_state$domainStates5$2 = _state$domainStates5$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates5$2 === void 0 ? void 0 : _state$domainStates5$2.msdyn_conversationmode);
|
|
138
151
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === _ConversationState.ConversationState.Closed) {
|
|
139
152
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
@@ -153,14 +166,6 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
153
166
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadStarted,
|
|
154
167
|
Description: "Widget loading started"
|
|
155
168
|
});
|
|
156
|
-
const authClientFunction = (0, _authHelper.getAuthClientFunction)(chatConfig);
|
|
157
|
-
if (getAuthToken && authClientFunction) {
|
|
158
|
-
// set auth token to chat sdk before start chat
|
|
159
|
-
const authSuccess = await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, getAuthToken);
|
|
160
|
-
if (!authSuccess) {
|
|
161
|
-
throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
169
|
|
|
165
170
|
//Check if chat retrieved from cache
|
|
166
171
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
@@ -95,6 +95,7 @@ export let TelemetryEvent;
|
|
|
95
95
|
TelemetryEvent["GetConversationDetailsCallStarted"] = "GetConversationDetailsCallStarted";
|
|
96
96
|
TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
|
|
97
97
|
TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
|
|
98
|
+
TelemetryEvent["DisconnectEndChatSDKCallFailed"] = "DisconnectEndChatSDKCallFailed";
|
|
98
99
|
TelemetryEvent["GetChatReconnectContextSDKCallStarted"] = "GetChatReconnectContextSDKCallStarted";
|
|
99
100
|
TelemetryEvent["GetChatReconnectContextSDKCallFailed"] = "GetChatReconnectContextSDKCallFailed";
|
|
100
101
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
@@ -135,12 +135,27 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
135
135
|
await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
|
|
136
136
|
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
137
137
|
} catch (ex) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
138
|
+
var _inMemoryState$appSta;
|
|
139
|
+
const inMemoryState = executeReducer(state, {
|
|
140
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
141
|
+
payload: null
|
|
143
142
|
});
|
|
143
|
+
// if the chat was disconnected or ended by the agent, we don't want to log the error
|
|
144
|
+
if (!(inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$appSta = inMemoryState.appStates) !== null && _inMemoryState$appSta !== void 0 && _inMemoryState$appSta.chatDisconnectEventReceived)) {
|
|
145
|
+
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
146
|
+
Event: TelemetryEvent.EndChatSDKCallFailed,
|
|
147
|
+
ExceptionDetails: {
|
|
148
|
+
exception: ex
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
TelemetryHelper.logSDKEvent(LogLevel.WARN, {
|
|
153
|
+
Event: TelemetryEvent.DisconnectEndChatSDKCallFailed,
|
|
154
|
+
ExceptionDetails: {
|
|
155
|
+
exception: ex
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
144
159
|
postMessageToOtherTab = false;
|
|
145
160
|
} finally {
|
|
146
161
|
await endChatStateCleanUp(dispatch);
|
|
@@ -25,6 +25,20 @@ let widgetInstanceId;
|
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
26
|
let popoutWidgetInstanceId;
|
|
27
27
|
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
const setAuthenticationIfApplicable = async (props, chatSDK) => {
|
|
30
|
+
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
31
|
+
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
32
|
+
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
33
|
+
if (getAuthToken && authClientFunction) {
|
|
34
|
+
// set auth token to chat sdk before start chat
|
|
35
|
+
const authSuccess = await handleAuthentication(chatSDK, chatConfig, getAuthToken);
|
|
36
|
+
if (!authSuccess) {
|
|
37
|
+
throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
28
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
43
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
30
44
|
optionalParams = {}; //Resetting to ensure no stale values
|
|
@@ -50,6 +64,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
50
64
|
// Setting Proactive chat settings
|
|
51
65
|
const isProactiveChat = state.appStates.conversationState === ConversationState.ProactiveChat;
|
|
52
66
|
const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat;
|
|
67
|
+
await setAuthenticationIfApplicable(props, chatSDK);
|
|
53
68
|
|
|
54
69
|
//Setting PreChat and intiate chat
|
|
55
70
|
await setPreChatAndInitiateChat(chatSDK, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat, state, props);
|
|
@@ -125,8 +140,6 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
125
140
|
const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
126
141
|
var _state$domainStates5, _state$domainStates5$, _state$domainStates5$2;
|
|
127
142
|
let isStartChatSuccessful = false;
|
|
128
|
-
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
129
|
-
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
130
143
|
const persistentChatEnabled = await isPersistentChatEnabled(state === null || state === void 0 ? void 0 : (_state$domainStates5 = state.domainStates) === null || _state$domainStates5 === void 0 ? void 0 : (_state$domainStates5$ = _state$domainStates5.liveChatConfig) === null || _state$domainStates5$ === void 0 ? void 0 : (_state$domainStates5$2 = _state$domainStates5$.LiveWSAndLiveChatEngJoin) === null || _state$domainStates5$2 === void 0 ? void 0 : _state$domainStates5$2.msdyn_conversationmode);
|
|
131
144
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === ConversationState.Closed) {
|
|
132
145
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
@@ -146,14 +159,6 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
146
159
|
Event: TelemetryEvent.WidgetLoadStarted,
|
|
147
160
|
Description: "Widget loading started"
|
|
148
161
|
});
|
|
149
|
-
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
150
|
-
if (getAuthToken && authClientFunction) {
|
|
151
|
-
// set auth token to chat sdk before start chat
|
|
152
|
-
const authSuccess = await handleAuthentication(chatSDK, chatConfig, getAuthToken);
|
|
153
|
-
if (!authSuccess) {
|
|
154
|
-
throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
162
|
|
|
158
163
|
//Check if chat retrieved from cache
|
|
159
164
|
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
@@ -88,6 +88,7 @@ export declare enum TelemetryEvent {
|
|
|
88
88
|
GetConversationDetailsCallStarted = "GetConversationDetailsCallStarted",
|
|
89
89
|
GetConversationDetailsCallFailed = "GetConversationDetailsCallFailed",
|
|
90
90
|
EndChatSDKCallFailed = "EndChatSDKCallFailed",
|
|
91
|
+
DisconnectEndChatSDKCallFailed = "DisconnectEndChatSDKCallFailed",
|
|
91
92
|
GetChatReconnectContextSDKCallStarted = "GetChatReconnectContextSDKCallStarted",
|
|
92
93
|
GetChatReconnectContextSDKCallFailed = "GetChatReconnectContextSDKCallFailed",
|
|
93
94
|
ParseAdaptiveCardFailed = "ParseAdaptiveCardFailed",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.7.3-main.
|
|
3
|
+
"version": "1.7.3-main.9d92cc9",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@microsoft/omnichannel-chat-components": "1.1.5",
|
|
78
78
|
"@microsoft/omnichannel-chat-sdk": "^1.9.5",
|
|
79
79
|
"abort-controller-es5": "^2.0.1",
|
|
80
|
-
"dompurify": "^2.
|
|
80
|
+
"dompurify": "^2.5.4",
|
|
81
81
|
"markdown-it": "^12.3.2",
|
|
82
82
|
"markdown-it-attrs": "^4.1.6",
|
|
83
83
|
"markdown-it-attrs-es5": "^2.0.2",
|