@microsoft/omnichannel-chat-widget 0.1.0-main.ae3aa42 → 0.1.0-main.b59a07c
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/Constants.js +2 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +13 -2
- package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +8 -9
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +17 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +12 -4
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +1 -1
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +3 -13
- package/lib/cjs/components/livechatwidget/common/endChat.js +28 -13
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +4 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +49 -10
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +52 -5
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -5
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +22 -21
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
- package/lib/esm/common/Constants.js +2 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +13 -2
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +8 -6
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +8 -0
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +13 -5
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +1 -1
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +3 -13
- package/lib/esm/components/livechatwidget/common/endChat.js +25 -14
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +4 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +51 -14
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +47 -6
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +6 -7
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +22 -21
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/esm/plugins/newMessageEventHandler.js +10 -12
- package/lib/types/common/Constants.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +13 -4
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/utils.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +22 -21
- package/package.json +2 -2
|
@@ -7,8 +7,8 @@ import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontro
|
|
|
7
7
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
8
8
|
import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
|
|
9
9
|
import { Constants } from "../../../common/Constants";
|
|
10
|
+
import { getWidgetEndChatEventName } from "../../../common/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
11
|
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
12
|
const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
13
13
|
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
|
|
14
14
|
|
|
@@ -19,7 +19,7 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
19
19
|
if (isPostChatEnabled === "true" && (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === Constants.truePascal) {
|
|
20
20
|
const skipEndChatSDK = false;
|
|
21
21
|
const skipCloseChat = true;
|
|
22
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
22
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, true);
|
|
23
23
|
|
|
24
24
|
if (postChatSurveyMode === PostChatSurveyMode.Embed) {
|
|
25
25
|
const loadPostChatEvent = {
|
|
@@ -33,18 +33,27 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
} else {
|
|
36
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
36
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
|
|
37
37
|
}
|
|
38
38
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat) => {
|
|
41
|
+
const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
|
|
42
42
|
if (!skipEndChatSDK) {
|
|
43
43
|
try {
|
|
44
44
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
45
45
|
Event: TelemetryEvent.EndChatSDKCall
|
|
46
46
|
});
|
|
47
|
-
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
|
|
47
|
+
await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat()); // Need to clear these states immediately when chat ended from OC.
|
|
48
|
+
|
|
49
|
+
dispatch({
|
|
50
|
+
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
51
|
+
payload: undefined
|
|
52
|
+
});
|
|
53
|
+
dispatch({
|
|
54
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
55
|
+
payload: undefined
|
|
56
|
+
});
|
|
48
57
|
} catch (ex) {
|
|
49
58
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
50
59
|
Event: TelemetryEvent.EndChatSDKCallFailed,
|
|
@@ -52,6 +61,7 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
52
61
|
exception: ex
|
|
53
62
|
}
|
|
54
63
|
});
|
|
64
|
+
postMessageToOtherTab = false;
|
|
55
65
|
}
|
|
56
66
|
}
|
|
57
67
|
|
|
@@ -81,17 +91,18 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
81
91
|
type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
|
|
82
92
|
payload: null
|
|
83
93
|
});
|
|
84
|
-
dispatch({
|
|
85
|
-
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
86
|
-
payload: undefined
|
|
87
|
-
});
|
|
88
|
-
dispatch({
|
|
89
|
-
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
90
|
-
payload: undefined
|
|
91
|
-
});
|
|
92
94
|
BroadcastService.postMessage({
|
|
93
|
-
eventName: BroadcastEvent.
|
|
95
|
+
eventName: BroadcastEvent.ChatEnded
|
|
94
96
|
});
|
|
97
|
+
|
|
98
|
+
if (postMessageToOtherTab) {
|
|
99
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
|
|
100
|
+
|
|
101
|
+
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId);
|
|
102
|
+
BroadcastService.postMessage({
|
|
103
|
+
eventName: endChatEventName
|
|
104
|
+
});
|
|
105
|
+
}
|
|
95
106
|
} catch (error) {
|
|
96
107
|
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
97
108
|
Event: TelemetryEvent.CloseChatMethodException,
|
|
@@ -84,6 +84,10 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
84
84
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
85
85
|
payload: undefined
|
|
86
86
|
});
|
|
87
|
+
dispatch({
|
|
88
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
89
|
+
payload: undefined
|
|
90
|
+
});
|
|
87
91
|
};
|
|
88
92
|
|
|
89
93
|
webChatStore = createStore({}, //initial state
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChatSDKError
|
|
2
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
1
|
+
import { ChatSDKError } from "../../../common/Constants";
|
|
2
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
4
4
|
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
5
5
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
@@ -9,10 +9,13 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
|
9
9
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
10
10
|
import { createAdapter } from "./createAdapter";
|
|
11
11
|
import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
|
|
12
|
-
import { createTimer } from "../../../common/utils";
|
|
12
|
+
import { createTimer, getWidgetCacheId } from "../../../common/utils";
|
|
13
13
|
import { getReconnectIdForAuthenticatedChat, handleRedirectUnauthenticatedReconnectChat } from "./reconnectChatHelper";
|
|
14
14
|
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
15
|
-
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
15
|
+
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
16
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
|
|
18
|
+
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
19
|
|
|
17
20
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
18
21
|
var _props$reconnectChatP;
|
|
@@ -52,11 +55,13 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
52
55
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
53
56
|
payload: ConversationState.Prechat
|
|
54
57
|
});
|
|
58
|
+
setCustomContextParams(props, state);
|
|
55
59
|
} else {
|
|
56
60
|
dispatch({
|
|
57
61
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
58
62
|
payload: ConversationState.Loading
|
|
59
63
|
});
|
|
64
|
+
setCustomContextParams(props, state);
|
|
60
65
|
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
61
66
|
}
|
|
62
67
|
}
|
|
@@ -67,12 +72,29 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
67
72
|
try {
|
|
68
73
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
69
74
|
|
|
75
|
+
let isStartChatSuccessful = false;
|
|
76
|
+
|
|
77
|
+
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
78
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|
|
79
|
+
|
|
80
|
+
// Broadcasting limited cached chat details
|
|
81
|
+
BroadcastService.postMessage({
|
|
82
|
+
eventName: BroadcastEvent.ChatRetrievedFromCache,
|
|
83
|
+
payload: {
|
|
84
|
+
chatId: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.liveChatContext) === null || _persistedState$domai2 === void 0 ? void 0 : (_persistedState$domai3 = _persistedState$domai2.chatToken) === null || _persistedState$domai3 === void 0 ? void 0 : _persistedState$domai3.chatId,
|
|
85
|
+
requestId: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai4 = persistedState.domainStates) === null || _persistedState$domai4 === void 0 ? void 0 : (_persistedState$domai5 = _persistedState$domai4.liveChatContext) === null || _persistedState$domai5 === void 0 ? void 0 : _persistedState$domai5.requestId
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
70
90
|
try {
|
|
71
91
|
TelemetryTimers.WidgetLoadTimer = createTimer();
|
|
72
92
|
TelemetryHelper.logSDKEvent(LogLevel.INFO, {
|
|
73
93
|
Event: TelemetryEvent.StartChatSDKCall
|
|
74
94
|
});
|
|
75
|
-
|
|
95
|
+
optionalParams = Object.assign({}, params, optionalParams);
|
|
96
|
+
await chatSDK.startChat(optionalParams);
|
|
97
|
+
isStartChatSuccessful = true;
|
|
76
98
|
} catch (error) {
|
|
77
99
|
TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
|
|
78
100
|
Event: TelemetryEvent.StartChatMethodException,
|
|
@@ -80,6 +102,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
80
102
|
exception: `Failed to setup startChat: ${error}`
|
|
81
103
|
}
|
|
82
104
|
});
|
|
105
|
+
isStartChatSuccessful = false;
|
|
83
106
|
}
|
|
84
107
|
|
|
85
108
|
const newAdapter = await createAdapter(chatSDK);
|
|
@@ -107,10 +130,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
107
130
|
await setPostChatContextAndLoadSurvey(chatSDK, dispatch);
|
|
108
131
|
await updateSessionDataForTelemetry(chatSDK, dispatch); // Set app state to Active
|
|
109
132
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
133
|
+
if (isStartChatSuccessful) {
|
|
134
|
+
dispatch({
|
|
135
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
136
|
+
payload: ConversationState.Active
|
|
137
|
+
});
|
|
138
|
+
}
|
|
114
139
|
} else {
|
|
115
140
|
dispatch({
|
|
116
141
|
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
@@ -148,20 +173,21 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
148
173
|
|
|
149
174
|
|
|
150
175
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
151
|
-
var _DataStoreManager$cli, _persistedState$
|
|
176
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli, _persistedState$domai6;
|
|
152
177
|
|
|
153
|
-
const
|
|
178
|
+
const widgetStateEventName = getWidgetCacheId((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId) ?? "");
|
|
179
|
+
const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
154
180
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
155
181
|
|
|
156
|
-
if (persistedState !== null && persistedState !== void 0 && (_persistedState$
|
|
157
|
-
var _persistedState$
|
|
182
|
+
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai6 = persistedState.domainStates) !== null && _persistedState$domai6 !== void 0 && _persistedState$domai6.liveChatContext) {
|
|
183
|
+
var _persistedState$domai7;
|
|
158
184
|
|
|
159
185
|
dispatch({
|
|
160
186
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
161
187
|
payload: ConversationState.Loading
|
|
162
188
|
});
|
|
163
189
|
const optionalParams = {
|
|
164
|
-
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$
|
|
190
|
+
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
165
191
|
};
|
|
166
192
|
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
167
193
|
return true;
|
|
@@ -170,4 +196,15 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
170
196
|
}
|
|
171
197
|
};
|
|
172
198
|
|
|
199
|
+
const setCustomContextParams = (props, state) => {
|
|
200
|
+
var _props$chatConfig, _state$domainStates;
|
|
201
|
+
|
|
202
|
+
// Add custom context if any only for unauthenticated chat
|
|
203
|
+
if (!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) && (_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.customContext) {
|
|
204
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
205
|
+
customContext: state.domainStates.customContext
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
173
210
|
export { prepareStartChat, initStartChat };
|
|
@@ -4,7 +4,7 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/teleme
|
|
|
4
4
|
import { BroadcastService, decodeComponentString } from "@microsoft/omnichannel-chat-components";
|
|
5
5
|
import { Stack } from "@fluentui/react";
|
|
6
6
|
import React, { useEffect, useRef, useState } from "react";
|
|
7
|
-
import { createTimer, getLocaleDirection } from "../../../common/utils";
|
|
7
|
+
import { createTimer, getLocaleDirection, getWidgetCacheId, getWidgetEndChatEventName } from "../../../common/utils";
|
|
8
8
|
import { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat } from "../common/reconnectChatHelper";
|
|
9
9
|
import { initStartChat, prepareStartChat } from "../common/startChat";
|
|
10
10
|
import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
|
|
@@ -53,7 +53,8 @@ export const LiveChatWidgetStateful = props => {
|
|
|
53
53
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
|
|
54
54
|
}); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
55
|
|
|
56
|
-
const chatSDK = useChatSDKStore();
|
|
56
|
+
const chatSDK = useChatSDKStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
|
|
57
58
|
const [voiceVideoCallingSDK, setVoiceVideoCallingSDK] = useState(undefined);
|
|
58
59
|
const {
|
|
59
60
|
Composer
|
|
@@ -81,6 +82,10 @@ export const LiveChatWidgetStateful = props => {
|
|
|
81
82
|
type: LiveChatWidgetActionType.SET_SKIP_CHAT_BUTTON_RENDERING,
|
|
82
83
|
payload: ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.skipChatButtonRendering) || false
|
|
83
84
|
});
|
|
85
|
+
dispatch({
|
|
86
|
+
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
87
|
+
payload: false
|
|
88
|
+
});
|
|
84
89
|
initCallingSdk(chatSDK, setVoiceVideoCallingSDK).then(sdkCreated => {
|
|
85
90
|
sdkCreated && dispatch({
|
|
86
91
|
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
@@ -145,7 +150,20 @@ export const LiveChatWidgetStateful = props => {
|
|
|
145
150
|
}
|
|
146
151
|
}, [state.appStates.skipChatButtonRendering]);
|
|
147
152
|
useEffect(() => {
|
|
148
|
-
|
|
153
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
|
|
154
|
+
|
|
155
|
+
// Add the custom context on receiving the SetCustomContext event
|
|
156
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
157
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
158
|
+
Event: TelemetryEvent.CustomContextReceived,
|
|
159
|
+
Description: "CustomContext received."
|
|
160
|
+
});
|
|
161
|
+
dispatch({
|
|
162
|
+
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
163
|
+
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.StartProactiveChat).subscribe(msg => {
|
|
149
167
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
150
168
|
Event: TelemetryEvent.StartProactiveChatEventReceived,
|
|
151
169
|
Description: "Start proactive chat event received."
|
|
@@ -163,7 +181,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
163
181
|
}
|
|
164
182
|
}); // start chat from SDK Event
|
|
165
183
|
|
|
166
|
-
BroadcastService.getMessageByEventName(
|
|
184
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(() => {
|
|
167
185
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
168
186
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
169
187
|
Description: "Start chat event received."
|
|
@@ -179,7 +197,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
179
197
|
}
|
|
180
198
|
}); // end chat from SDK Event
|
|
181
199
|
|
|
182
|
-
BroadcastService.getMessageByEventName(
|
|
200
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.EndChat).subscribe(async () => {
|
|
183
201
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
184
202
|
Event: TelemetryEvent.EndChatEventReceived,
|
|
185
203
|
Description: "End chat event received."
|
|
@@ -192,6 +210,26 @@ export const LiveChatWidgetStateful = props => {
|
|
|
192
210
|
const skipCloseChat = false;
|
|
193
211
|
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
194
212
|
}
|
|
213
|
+
}); // Listen to end chat event from other tabs
|
|
214
|
+
|
|
215
|
+
const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId);
|
|
216
|
+
BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
217
|
+
endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
218
|
+
}); // Close popout window
|
|
219
|
+
|
|
220
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.ClosePopoutWindow).subscribe(() => {
|
|
221
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
222
|
+
Event: TelemetryEvent.ClosePopoutWindowEventRecevied,
|
|
223
|
+
Description: "Close popout window event received."
|
|
224
|
+
});
|
|
225
|
+
dispatch({
|
|
226
|
+
type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
227
|
+
payload: {
|
|
228
|
+
proactiveChatBodyTitle: "",
|
|
229
|
+
proactiveChatEnablePrechat: false,
|
|
230
|
+
proactiveChatInNewWindow: false
|
|
231
|
+
}
|
|
232
|
+
});
|
|
195
233
|
});
|
|
196
234
|
window.addEventListener("beforeunload", () => {
|
|
197
235
|
disposeTelemetryLoggers();
|
|
@@ -274,8 +312,11 @@ export const LiveChatWidgetStateful = props => {
|
|
|
274
312
|
const confirmationPaneProps = initConfirmationPropsComposer(props); // publish chat widget state
|
|
275
313
|
|
|
276
314
|
useEffect(() => {
|
|
315
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic;
|
|
316
|
+
|
|
317
|
+
const widgetStateEventName = getWidgetCacheId(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId);
|
|
277
318
|
const chatWidgetStateChangeEvent = {
|
|
278
|
-
eventName:
|
|
319
|
+
eventName: widgetStateEventName,
|
|
279
320
|
payload: { ...state
|
|
280
321
|
}
|
|
281
322
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HtmlAttributeNames, Regex } from "../../common/Constants";
|
|
2
2
|
import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
|
|
3
3
|
import React, { useEffect } from "react";
|
|
4
|
-
import { extractPreChatSurveyResponseValues, findAllFocusableElement, parseAdaptiveCardPayload } from "../../common/utils";
|
|
4
|
+
import { extractPreChatSurveyResponseValues, findAllFocusableElement, getWidgetCacheId, parseAdaptiveCardPayload } from "../../common/utils";
|
|
5
5
|
import { ConversationState } from "../../contexts/common/ConversationState";
|
|
6
6
|
import { DataStoreManager } from "../../common/contextDataStore/DataStoreManager";
|
|
7
7
|
import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
|
|
@@ -67,9 +67,10 @@ export const PreChatSurveyPaneStateful = props => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
try {
|
|
70
|
-
var _DataStoreManager$cli, _persistedState$domai;
|
|
70
|
+
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _DataStoreManager$cli, _persistedState$domai;
|
|
71
71
|
|
|
72
|
-
const
|
|
72
|
+
const widgetStateCacheId = getWidgetCacheId(((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$t = _state$domainStates.telemetryInternalData) === null || _state$domainStates$t === void 0 ? void 0 : _state$domainStates$t.orgId) ?? "", ((_state$domainStates$t2 = state.domainStates.telemetryInternalData) === null || _state$domainStates$t2 === void 0 ? void 0 : _state$domainStates$t2.widgetId) ?? "");
|
|
73
|
+
const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateCacheId, "localStorage");
|
|
73
74
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
74
75
|
let optionalParams = {};
|
|
75
76
|
|
|
@@ -83,9 +84,7 @@ export const PreChatSurveyPaneStateful = props => {
|
|
|
83
84
|
} else {
|
|
84
85
|
const prechatResponseValues = extractPreChatSurveyResponseValues(state.domainStates.preChatSurveyResponse, values);
|
|
85
86
|
optionalParams = {
|
|
86
|
-
|
|
87
|
-
preChatResponse: prechatResponseValues
|
|
88
|
-
}
|
|
87
|
+
preChatResponse: prechatResponseValues
|
|
89
88
|
};
|
|
90
89
|
setPreChatResponseEmail(values);
|
|
91
90
|
await initStartChat(optionalParams);
|
|
@@ -24,6 +24,14 @@ export const ProactiveChatPaneStateful = props => {
|
|
|
24
24
|
const handleProactiveChatInviteTimeout = () => {
|
|
25
25
|
if (!timeoutRemoved) {
|
|
26
26
|
setTimeoutRemoved(true);
|
|
27
|
+
dispatch({
|
|
28
|
+
type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
29
|
+
payload: {
|
|
30
|
+
proactiveChatBodyTitle: "",
|
|
31
|
+
proactiveChatEnablePrechat: false,
|
|
32
|
+
proactiveChatInNewWindow: false
|
|
33
|
+
}
|
|
34
|
+
});
|
|
27
35
|
dispatch({
|
|
28
36
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
29
37
|
payload: ConversationState.Closed
|
|
@@ -81,6 +89,14 @@ export const ProactiveChatPaneStateful = props => {
|
|
|
81
89
|
Event: TelemetryEvent.ProactiveChatClosed,
|
|
82
90
|
Description: "Proactive chat closed."
|
|
83
91
|
});
|
|
92
|
+
dispatch({
|
|
93
|
+
type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
94
|
+
payload: {
|
|
95
|
+
proactiveChatBodyTitle: "",
|
|
96
|
+
proactiveChatEnablePrechat: false,
|
|
97
|
+
proactiveChatInNewWindow: false
|
|
98
|
+
}
|
|
99
|
+
});
|
|
84
100
|
dispatch({
|
|
85
101
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
86
102
|
payload: ConversationState.Closed
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LogLevel } from "../../../../common/telemetry/TelemetryConstants";
|
|
2
2
|
import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
3
3
|
export function createWebChatTelemetry() {
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
5
|
const handleTelemetry = event => {
|
|
5
6
|
const {
|
|
6
7
|
level
|
|
@@ -10,25 +10,26 @@ export let LiveChatWidgetActionType;
|
|
|
10
10
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PREVIOUS_FOCUSED_ELEMENT"] = 6] = "SET_PREVIOUS_FOCUSED_ELEMENT";
|
|
11
11
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_OUTSIDE_OPERATING_HOURS"] = 7] = "SET_OUTSIDE_OPERATING_HOURS";
|
|
12
12
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRE_CHAT_SURVEY_RESPONSE"] = 8] = "SET_PRE_CHAT_SURVEY_RESPONSE";
|
|
13
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
14
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
15
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
16
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
17
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
18
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
19
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
20
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
21
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
22
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
23
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
24
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
25
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
26
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
27
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
28
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
29
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
30
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
31
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
32
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
33
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
13
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CUSTOM_CONTEXT"] = 9] = "SET_CUSTOM_CONTEXT";
|
|
14
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_CONFIRMATION"] = 10] = "SET_SHOW_CONFIRMATION";
|
|
15
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_EMAIL_TRANSCRIPT_PANE"] = 11] = "SET_SHOW_EMAIL_TRANSCRIPT_PANE";
|
|
16
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRECHAT_RESPONSE_EMAIL"] = 12] = "SET_PRECHAT_RESPONSE_EMAIL";
|
|
17
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_AUDIO_NOTIFICATION"] = 13] = "SET_AUDIO_NOTIFICATION";
|
|
18
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_E2VV_ENABLED"] = 14] = "SET_E2VV_ENABLED";
|
|
19
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_CONTEXT"] = 15] = "SET_POST_CHAT_CONTEXT";
|
|
20
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SHOW_CALLING_CONTAINER"] = 16] = "SHOW_CALLING_CONTAINER";
|
|
21
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INCOMING_CALL"] = 17] = "SET_INCOMING_CALL";
|
|
22
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_VIDEO_CALL"] = 18] = "DISABLE_VIDEO_CALL";
|
|
23
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_LOCAL_VIDEO"] = 19] = "DISABLE_LOCAL_VIDEO";
|
|
24
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_REMOTE_VIDEO"] = 20] = "DISABLE_REMOTE_VIDEO";
|
|
25
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CHAT_TOKEN"] = 21] = "SET_CHAT_TOKEN";
|
|
26
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SKIP_CHAT_BUTTON_RENDERING"] = 22] = "SET_SKIP_CHAT_BUTTON_RENDERING";
|
|
27
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PROACTIVE_CHAT_PARAMS"] = 23] = "SET_PROACTIVE_CHAT_PARAMS";
|
|
28
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_TELEMETRY_DATA"] = 24] = "SET_TELEMETRY_DATA";
|
|
29
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_RECONNECT_ID"] = 25] = "SET_RECONNECT_ID";
|
|
30
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_UNREAD_MESSAGE_COUNT"] = 26] = "SET_UNREAD_MESSAGE_COUNT";
|
|
31
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_FOCUS_CHAT_BUTTON"] = 27] = "SET_FOCUS_CHAT_BUTTON";
|
|
32
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT"] = 28] = "SET_CONVERSATION_ENDED_BY_AGENT";
|
|
33
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 29] = "SET_WIDGET_STATE";
|
|
34
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
|
|
34
35
|
})(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
|
|
@@ -18,7 +18,8 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
18
18
|
postChatContext: undefined,
|
|
19
19
|
telemetryInternalData: {},
|
|
20
20
|
globalDir: "ltr",
|
|
21
|
-
liveChatContext: undefined
|
|
21
|
+
liveChatContext: undefined,
|
|
22
|
+
customContext: undefined
|
|
22
23
|
},
|
|
23
24
|
appStates: {
|
|
24
25
|
conversationState: ConversationState.Closed,
|
|
@@ -61,6 +61,14 @@ export const createReducer = () => {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
case LiveChatWidgetActionType.SET_CUSTOM_CONTEXT:
|
|
65
|
+
return { ...state,
|
|
66
|
+
domainStates: { ...state.domainStates,
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
+
customContext: action.payload
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
64
72
|
case LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT:
|
|
65
73
|
return { ...state,
|
|
66
74
|
appStates: { ...state.appStates,
|
|
@@ -2,7 +2,6 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../common/telemetry/Te
|
|
|
2
2
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
3
3
|
import { Constants } from "../common/Constants";
|
|
4
4
|
import { TelemetryHelper } from "../common/telemetry/TelemetryHelper";
|
|
5
|
-
import { TelemetryManager } from "../common/telemetry/TelemetryManager";
|
|
6
5
|
export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
7
6
|
const onNewAdapterActivityHandler = activity => {
|
|
8
7
|
var _activity$channelData, _activity$channelData2, _activity$channelData3;
|
|
@@ -17,18 +16,16 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
17
16
|
|
|
18
17
|
const raiseMessageEvent = activity => {
|
|
19
18
|
if ((activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message) {
|
|
20
|
-
var
|
|
19
|
+
var _text, _text2, _activity$channelData4, _activity$from;
|
|
21
20
|
|
|
22
21
|
const payload = {
|
|
22
|
+
// To identify hidden contents vs empty content
|
|
23
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
text: activity === null || activity === void 0 ? void 0 : activity.text,
|
|
25
|
-
id: activity === null || activity === void 0 ? void 0 : activity.id,
|
|
24
|
+
text: (activity === null || activity === void 0 ? void 0 : (_text = activity.text) === null || _text === void 0 ? void 0 : _text.length) >= 1 ? `*contents hidden (${activity === null || activity === void 0 ? void 0 : (_text2 = activity.text) === null || _text2 === void 0 ? void 0 : _text2.length} chars)*` : "",
|
|
26
25
|
type: activity === null || activity === void 0 ? void 0 : activity.type,
|
|
27
26
|
timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
|
|
28
|
-
chatId: chatId,
|
|
29
27
|
userId: userId,
|
|
30
|
-
|
|
31
|
-
channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
|
|
28
|
+
tags: activity === null || activity === void 0 ? void 0 : (_activity$channelData4 = activity.channelData) === null || _activity$channelData4 === void 0 ? void 0 : _activity$channelData4.tags,
|
|
32
29
|
messageType: ""
|
|
33
30
|
};
|
|
34
31
|
|
|
@@ -45,18 +42,18 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
45
42
|
Description: "New message sent"
|
|
46
43
|
});
|
|
47
44
|
} else {
|
|
48
|
-
var _activity$
|
|
45
|
+
var _activity$channelData5, _activity$channelData6;
|
|
49
46
|
|
|
50
|
-
if (activity !== null && activity !== void 0 && (_activity$
|
|
47
|
+
if (activity !== null && activity !== void 0 && (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(Constants.systemMessageTag)) {
|
|
51
48
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
49
|
payload.messageType = Constants.systemMessageTag;
|
|
53
50
|
} else {
|
|
54
|
-
var _activity$
|
|
51
|
+
var _activity$channelData7, _activity$channelData8, _activity$channelData9;
|
|
55
52
|
|
|
56
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
54
|
const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
55
|
|
|
59
|
-
const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$
|
|
56
|
+
const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData7 = activity.channelData) !== null && _activity$channelData7 !== void 0 && _activity$channelData7.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData8 = activity.channelData) === null || _activity$channelData8 === void 0 ? void 0 : (_activity$channelData9 = _activity$channelData8.tags) === null || _activity$channelData9 === void 0 ? void 0 : _activity$channelData9.length) === 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
57
|
|
|
61
58
|
const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
|
|
62
59
|
|
|
@@ -74,7 +71,8 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
74
71
|
BroadcastService.postMessage(newMessageReceivedEvent);
|
|
75
72
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
76
73
|
Event: TelemetryEvent.MessageReceived,
|
|
77
|
-
Description: "New message received"
|
|
74
|
+
Description: "New message received",
|
|
75
|
+
Data: payload
|
|
78
76
|
});
|
|
79
77
|
}
|
|
80
78
|
}
|
|
@@ -15,7 +15,6 @@ export declare class Constants {
|
|
|
15
15
|
static readonly true = "true";
|
|
16
16
|
static readonly false = "false";
|
|
17
17
|
static readonly maximumUnreadMessageCount = 99;
|
|
18
|
-
static readonly widgetStateDataKey = "LcwChatWidgetState";
|
|
19
18
|
static readonly channelIdKey = "ChannelId-";
|
|
20
19
|
static readonly ChannelId = "lcw";
|
|
21
20
|
static readonly CustomerTag = "FromCustomer";
|
|
@@ -70,6 +69,7 @@ export declare class Constants {
|
|
|
70
69
|
static readonly OpenLinkIconCssClass = "webchat__markdown__external-link-icon";
|
|
71
70
|
static readonly internetConnectionTestUrl = "https://ocsdk-prod.azureedge.net/public/connecttest.txt";
|
|
72
71
|
static readonly internetConnectionTestUrlText = "Omnichannel Connect Test";
|
|
72
|
+
static readonly ChatWidgetStateChangedPrefix = "ChatWidgetStateChanged";
|
|
73
73
|
}
|
|
74
74
|
export declare const Regex: {
|
|
75
75
|
new (): {};
|
|
@@ -19,18 +19,24 @@ export declare enum LogLevel {
|
|
|
19
19
|
}
|
|
20
20
|
export declare enum BroadcastEvent {
|
|
21
21
|
LoadPostChatSurvey = "LoadPostChatSurvey",
|
|
22
|
-
|
|
22
|
+
ChatEnded = "ChatEnded",
|
|
23
23
|
NewMessageNotification = "NewMessageNotification",
|
|
24
24
|
UnreadMessageCount = "UnreadMessageCount",
|
|
25
|
-
|
|
25
|
+
StartProactiveChat = "StartProactiveChat",
|
|
26
26
|
ProactiveChatStartChat = "ProactiveChatStartChat",
|
|
27
27
|
ProactiveChatStartPopoutChat = "ProactiveChatStartPopoutChat",
|
|
28
|
+
ProactiveChatIsInPopoutMode = "ProactiveChatIsInPopoutMode",
|
|
29
|
+
ClosePopoutWindow = "ClosePopoutWindow",
|
|
28
30
|
InvalidAdaptiveCardFormat = "InvalidAdaptiveCardFormat",
|
|
29
31
|
NewMessageSent = "NewMessageSent",
|
|
30
32
|
NewMessageReceived = "NewMessageReceived",
|
|
31
33
|
RedirectPageRequest = "RedirectPageRequest",
|
|
34
|
+
StartChat = "StartChat",
|
|
32
35
|
StartChatSkippingChatButtonRendering = "StartChatSkippingChatButtonRendering",
|
|
33
|
-
StartUnauthenticatedReconnectChat = "StartUnauthenticatedReconnectChat"
|
|
36
|
+
StartUnauthenticatedReconnectChat = "StartUnauthenticatedReconnectChat",
|
|
37
|
+
EndChat = "EndChat",
|
|
38
|
+
SetCustomContext = "SetCustomContext",
|
|
39
|
+
ChatRetrievedFromCache = "ChatRetrievedFromCache"
|
|
34
40
|
}
|
|
35
41
|
export declare enum TelemetryEvent {
|
|
36
42
|
CallAdded = "CallAdded",
|
|
@@ -81,6 +87,7 @@ export declare enum TelemetryEvent {
|
|
|
81
87
|
StartChatEventRecevied = "StartChatEventReceived",
|
|
82
88
|
EndChatSDKCall = "EndChatCall",
|
|
83
89
|
EndChatEventReceived = "EndChatEventReceived",
|
|
90
|
+
ClosePopoutWindowEventRecevied = "ClosePopoutWindowEventRecevied",
|
|
84
91
|
OnNewMessageFailed = "OnNewMessageFailed",
|
|
85
92
|
OnNewMessageAudioNotificationFailed = "OnNewMessageAudioNotificationFailed",
|
|
86
93
|
DownloadTranscriptResponseNullOrUndefined = "DownloadTranscriptResponseNullOrUndefined",
|
|
@@ -129,11 +136,13 @@ export declare enum TelemetryEvent {
|
|
|
129
136
|
ReconnectChatStartNewConversation = "ReconnectChatStartNewConversation",
|
|
130
137
|
ReconnectChatMinimize = "ReconnectChatMinimize",
|
|
131
138
|
MessageSent = "MessageSent",
|
|
132
|
-
MessageReceived = "MessageReceived"
|
|
139
|
+
MessageReceived = "MessageReceived",
|
|
140
|
+
CustomContextReceived = "CustomContextReceived"
|
|
133
141
|
}
|
|
134
142
|
export interface TelemetryInput {
|
|
135
143
|
scenarioType: ScenarioType;
|
|
136
144
|
payload: TelemetryData;
|
|
145
|
+
telemetryInfo?: any;
|
|
137
146
|
}
|
|
138
147
|
export declare class TelemetryConstants {
|
|
139
148
|
private static map;
|