@microsoft/omnichannel-chat-widget 0.1.0-main.20562ae → 0.1.0-main.4188c11
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 +32 -4
- package/lib/cjs/common/telemetry/TelemetryConstants.js +9 -0
- package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +10 -1
- package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +33 -13
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +16 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +1 -1
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -2
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +1 -1
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +5 -14
- package/lib/cjs/components/livechatwidget/common/endChat.js +10 -9
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +7 -0
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +105 -20
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -15
- package/lib/cjs/components/livechatwidget/common/startChat.js +38 -29
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +30 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +45 -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 +28 -3
- package/lib/esm/common/telemetry/TelemetryConstants.js +9 -0
- package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +9 -1
- package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +36 -14
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +12 -1
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +1 -1
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -2
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +1 -1
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +5 -15
- package/lib/esm/components/livechatwidget/common/endChat.js +10 -9
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +6 -0
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +94 -20
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -13
- package/lib/esm/components/livechatwidget/common/startChat.js +39 -30
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -9
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +32 -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 +16 -1
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +9 -2
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -1
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +22 -21
- package/package.json +6 -7
|
@@ -4,27 +4,28 @@ export const consoleLogger = () => {
|
|
|
4
4
|
const consoleLogger = {
|
|
5
5
|
log: (logLevel, telemetryInput) => {
|
|
6
6
|
const payload = telemetryInput !== null && telemetryInput !== void 0 && telemetryInput.payload && Object.keys(telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.payload).length > 0 ? telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.payload : "";
|
|
7
|
+
const telemetryInfo = telemetryInput !== null && telemetryInput !== void 0 && telemetryInput.telemetryInfo && Object.keys(telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.telemetryInfo).length > 0 ? telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.telemetryInfo : "";
|
|
7
8
|
|
|
8
9
|
try {
|
|
9
10
|
switch (logLevel) {
|
|
10
11
|
case LogLevel.INFO:
|
|
11
|
-
console.info(Constants.LiveChatWidget, payload);
|
|
12
|
+
console.info(Constants.LiveChatWidget, payload, telemetryInfo);
|
|
12
13
|
break;
|
|
13
14
|
|
|
14
15
|
case LogLevel.DEBUG:
|
|
15
|
-
console.debug(Constants.LiveChatWidget, payload);
|
|
16
|
+
console.debug(Constants.LiveChatWidget, payload, telemetryInfo);
|
|
16
17
|
break;
|
|
17
18
|
|
|
18
19
|
case LogLevel.WARN:
|
|
19
|
-
console.warn(Constants.LiveChatWidget, payload);
|
|
20
|
+
console.warn(Constants.LiveChatWidget, payload, telemetryInfo);
|
|
20
21
|
break;
|
|
21
22
|
|
|
22
23
|
case LogLevel.ERROR:
|
|
23
|
-
console.error(Constants.LiveChatWidget, payload);
|
|
24
|
+
console.error(Constants.LiveChatWidget, payload, telemetryInfo);
|
|
24
25
|
break;
|
|
25
26
|
|
|
26
27
|
default:
|
|
27
|
-
console.debug(Constants.LiveChatWidget, payload);
|
|
28
|
+
console.debug(Constants.LiveChatWidget, payload, telemetryInfo);
|
|
28
29
|
break;
|
|
29
30
|
}
|
|
30
31
|
} catch (ex) {
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Constants, LocaleConstants } from "./Constants";
|
|
1
|
+
import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
|
|
2
2
|
import { KeyCodes } from "./KeyCodes";
|
|
3
3
|
|
|
4
4
|
const getElementBySelector = selector => {
|
|
@@ -276,4 +276,15 @@ export const createTimer = () => {
|
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
};
|
|
279
|
+
}; // Returns the domain of the org
|
|
280
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
281
|
+
|
|
282
|
+
export const getDomain = hostValue => {
|
|
283
|
+
for (let i = 0; i < AriaTelemetryConstants.lcwEUDomainNames.length; i++) {
|
|
284
|
+
if (hostValue.endsWith(AriaTelemetryConstants.lcwEUDomainNames[i])) {
|
|
285
|
+
return AriaTelemetryConstants.EU;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return AriaTelemetryConstants.Public;
|
|
279
290
|
};
|
|
@@ -177,6 +177,20 @@ export const CallingContainerStateful = props => {
|
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
|
+
window.addEventListener("beforeunload", () => {
|
|
181
|
+
if (state.uiStates.isIncomingCall) {
|
|
182
|
+
voiceVideoCallingSdk === null || voiceVideoCallingSdk === void 0 ? void 0 : voiceVideoCallingSdk.rejectCall();
|
|
183
|
+
} else {
|
|
184
|
+
voiceVideoCallingSdk === null || voiceVideoCallingSdk === void 0 ? void 0 : voiceVideoCallingSdk.stopCall();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
voiceVideoCallingSdk === null || voiceVideoCallingSdk === void 0 ? void 0 : voiceVideoCallingSdk.close();
|
|
188
|
+
dispatch({
|
|
189
|
+
type: LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
190
|
+
payload: false
|
|
191
|
+
});
|
|
192
|
+
resetCallingStates(true);
|
|
193
|
+
});
|
|
180
194
|
}, []);
|
|
181
195
|
const controlProps = {
|
|
182
196
|
id: "oc-lcw-callingcontainer",
|
|
@@ -26,7 +26,7 @@ export const ChatButtonStateful = props => {
|
|
|
26
26
|
dir: state.domainStates.globalDir,
|
|
27
27
|
titleText: "Let's Chat!",
|
|
28
28
|
subtitleText: "We're online.",
|
|
29
|
-
hideNotificationBubble:
|
|
29
|
+
hideNotificationBubble: (buttonProps === null || buttonProps === void 0 ? void 0 : (_buttonProps$controlP = buttonProps.controlProps) === null || _buttonProps$controlP === void 0 ? void 0 : _buttonProps$controlP.hideNotificationBubble) === true || state.appStates.isMinimized === false,
|
|
30
30
|
unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > Constants.maximumUnreadMessageCount ? Constants.maximumUnreadMessageCount.toString() + "+" : state.appStates.unreadMessageCount.toString() : "0",
|
|
31
31
|
onClick: async () => {
|
|
32
32
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
@@ -97,8 +97,7 @@ export const FooterStateful = props => {
|
|
|
97
97
|
styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
|
|
98
98
|
}), /*#__PURE__*/React.createElement(AudioNotificationStateful, {
|
|
99
99
|
audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? NewMessageNotificationSoundBase64,
|
|
100
|
-
|
|
101
|
-
isAudioMuted: state.appStates.isAudioMuted ?? false
|
|
100
|
+
isAudioMuted: state.appStates.isAudioMuted === null ? (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : _footerProps$controlP4.hideAudioNotificationButton) ?? false : state.appStates.isAudioMuted ?? false
|
|
102
101
|
}));
|
|
103
102
|
};
|
|
104
103
|
export default FooterStateful;
|
package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -127,7 +127,7 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
127
127
|
|
|
128
128
|
if (value.attachments && value.attachments.length > 0 && value.attachments[0].name) {
|
|
129
129
|
fileAttachmentName = value.attachments[0].name;
|
|
130
|
-
value.content = attachmentMessage
|
|
130
|
+
value.content = attachmentMessage ? attachmentMessage + " " + fileAttachmentName : "The following attachment was uploaded during the conversation: " + fileAttachmentName;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -9,7 +9,8 @@ import createAttachmentMiddleware from "../../../webchatcontainerstateful/webcha
|
|
|
9
9
|
import { createAvatarMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware";
|
|
10
10
|
import { createMarkdown } from "../createMarkdown";
|
|
11
11
|
import { groupActivitiesMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware";
|
|
12
|
-
import { typingIndicatorMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware";
|
|
12
|
+
import { typingIndicatorMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware";
|
|
13
|
+
import { createWebChatTelemetry } from "../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger"; // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
14
|
|
|
14
15
|
export const dummyDefaultProps = {
|
|
15
16
|
audioNotificationProps: {
|
|
@@ -252,18 +253,6 @@ export const dummyDefaultProps = {
|
|
|
252
253
|
width: "50px",
|
|
253
254
|
fontSize: "18px"
|
|
254
255
|
},
|
|
255
|
-
currentCallTimerStyleProps: {
|
|
256
|
-
borderRadius: "2px",
|
|
257
|
-
margin: "1px",
|
|
258
|
-
color: "#FFFFFF",
|
|
259
|
-
paddingTop: "18px",
|
|
260
|
-
fontSize: 12,
|
|
261
|
-
fontFamily: "Segoe UI, Arial, sans-serif",
|
|
262
|
-
backgroundColor: "darkgrey",
|
|
263
|
-
height: "45px",
|
|
264
|
-
width: "50px",
|
|
265
|
-
textAlign: "center"
|
|
266
|
-
},
|
|
267
256
|
videoTileStyleProps: {
|
|
268
257
|
width: "100%",
|
|
269
258
|
marginLeft: "auto",
|
|
@@ -1424,7 +1413,8 @@ export const dummyDefaultProps = {
|
|
|
1424
1413
|
},
|
|
1425
1414
|
authClientFunction: undefined,
|
|
1426
1415
|
isReconnectEnabled: undefined,
|
|
1427
|
-
reconnectId: undefined
|
|
1416
|
+
reconnectId: undefined,
|
|
1417
|
+
redirectInSameWindow: undefined
|
|
1428
1418
|
},
|
|
1429
1419
|
styleProps: {
|
|
1430
1420
|
generalStyles: {
|
|
@@ -1496,7 +1486,7 @@ export const dummyDefaultProps = {
|
|
|
1496
1486
|
internalErrorBoxClass: undefined,
|
|
1497
1487
|
internalRenderErrorBox: undefined,
|
|
1498
1488
|
locale: "en-US",
|
|
1499
|
-
onTelemetry:
|
|
1489
|
+
onTelemetry: createWebChatTelemetry(),
|
|
1500
1490
|
overrideLocalizedStrings: undefined,
|
|
1501
1491
|
renderMarkdown: createMarkdown(false, false),
|
|
1502
1492
|
scrollToEndButtonMiddleware: undefined,
|
|
@@ -44,7 +44,16 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
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,
|
|
@@ -81,14 +90,6 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
81
90
|
type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
|
|
82
91
|
payload: null
|
|
83
92
|
});
|
|
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
93
|
BroadcastService.postMessage({
|
|
93
94
|
eventName: BroadcastEvent.EndChat
|
|
94
95
|
});
|
|
@@ -17,6 +17,7 @@ import createConversationEndMiddleware from "../../webchatcontainerstateful/webc
|
|
|
17
17
|
import createDataMaskingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware";
|
|
18
18
|
import { createMarkdown } from "./createMarkdown";
|
|
19
19
|
import createMaxMessageSizeValidator from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator";
|
|
20
|
+
import { createWebChatTelemetry } from "../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
|
|
20
21
|
import { defaultAttachmentProps } from "../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps";
|
|
21
22
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
22
23
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
@@ -83,6 +84,10 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
83
84
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
84
85
|
payload: undefined
|
|
85
86
|
});
|
|
87
|
+
dispatch({
|
|
88
|
+
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
89
|
+
payload: undefined
|
|
90
|
+
});
|
|
86
91
|
};
|
|
87
92
|
|
|
88
93
|
webChatStore = createStore({}, //initial state
|
|
@@ -103,6 +108,7 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
|
|
|
103
108
|
avatarMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableAvatarMiddleware ? undefined : createAvatarMiddleware((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
|
|
104
109
|
groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
105
110
|
typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
111
|
+
onTelemetry: createWebChatTelemetry(),
|
|
106
112
|
...((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.webChatProps)
|
|
107
113
|
};
|
|
108
114
|
return webChatProps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "regenerator-runtime/runtime";
|
|
2
|
-
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
-
import {
|
|
2
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
3
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
4
4
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
5
5
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
6
6
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -46,33 +46,107 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
|
46
46
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
const handleUnauthenticatedReconnectChat = async (dispatch, reconnectId, initStartChat) => {
|
|
50
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(reconnectId);
|
|
49
|
+
const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
50
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
51
51
|
|
|
52
|
-
if (reconnectAvailabilityResponse
|
|
53
|
-
|
|
52
|
+
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
53
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
54
54
|
} else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
56
|
+
}
|
|
57
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
61
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
62
|
+
|
|
63
|
+
if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
64
|
+
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
65
|
+
}
|
|
66
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
70
|
+
const startUnauthenticatedReconnectChat = {
|
|
71
|
+
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
72
|
+
};
|
|
73
|
+
BroadcastService.postMessage(startUnauthenticatedReconnectChat);
|
|
74
|
+
const optionalParams = {
|
|
75
|
+
reconnectId: reconnectId
|
|
76
|
+
};
|
|
77
|
+
dispatch({
|
|
78
|
+
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
79
|
+
payload: reconnectId
|
|
80
|
+
});
|
|
81
|
+
dispatch({
|
|
82
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
83
|
+
payload: ConversationState.Loading
|
|
84
|
+
});
|
|
85
|
+
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
89
|
+
const redirectPageRequest = {
|
|
90
|
+
eventName: BroadcastEvent.RedirectPageRequest,
|
|
91
|
+
payload: {
|
|
92
|
+
redirectURL: redirectURL
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
BroadcastService.postMessage(redirectPageRequest);
|
|
96
|
+
|
|
97
|
+
if (redirectInSameWindow) {
|
|
98
|
+
window.location.href = redirectURL;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
|
|
103
|
+
return reconnectAvailabilityResponse && !reconnectAvailabilityResponse.reconnectId;
|
|
104
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
|
|
108
|
+
const startUnauthenticatedReconnectChat = {
|
|
109
|
+
eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
110
|
+
};
|
|
111
|
+
BroadcastService.postMessage(startUnauthenticatedReconnectChat); // Getting PreChat Survey Context
|
|
112
|
+
|
|
113
|
+
const parseToJson = false;
|
|
114
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
115
|
+
|
|
116
|
+
if (preChatSurveyResponse) {
|
|
58
117
|
dispatch({
|
|
59
|
-
type: LiveChatWidgetActionType.
|
|
60
|
-
payload:
|
|
118
|
+
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
119
|
+
payload: preChatSurveyResponse
|
|
61
120
|
});
|
|
121
|
+
dispatch({
|
|
122
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
123
|
+
payload: ConversationState.Prechat
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
62
126
|
dispatch({
|
|
63
127
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
64
128
|
payload: ConversationState.Loading
|
|
65
129
|
});
|
|
66
|
-
await initStartChat(
|
|
130
|
+
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
67
131
|
}
|
|
68
|
-
};
|
|
132
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
133
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
134
|
+
|
|
135
|
+
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
136
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
137
|
+
|
|
138
|
+
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
139
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
140
|
+
}
|
|
141
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
145
|
+
if (reconnectAvailabilityResponse.redirectURL) {
|
|
146
|
+
redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
|
|
147
|
+
} else {
|
|
148
|
+
await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
|
|
149
|
+
}
|
|
76
150
|
};
|
|
77
151
|
|
|
78
|
-
export { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat };
|
|
152
|
+
export { getChatReconnectContext, getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat, handleRedirectUnauthenticatedReconnectChat };
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import { RegisterLoggers, TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
2
2
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
3
3
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
4
|
-
import { version as chatComponentVersion } from "@microsoft/omnichannel-chat-components/package.json";
|
|
5
|
-
import { version as chatSdkVersion } from "@microsoft/omnichannel-chat-sdk/package.json";
|
|
6
4
|
import { defaultAriaConfig } from "../../../common/telemetry/defaultConfigs/defaultAriaConfig";
|
|
7
5
|
import { defaultInternalTelemetryData } from "../../../common/telemetry/defaultConfigs/defaultTelemetryInternalData";
|
|
8
6
|
import { defaultTelemetryConfiguration } from "../../../common/telemetry/defaultConfigs/defaultTelemetryConfiguration";
|
|
9
7
|
export const registerTelemetryLoggers = (props, dispatch) => {
|
|
10
8
|
var _props$liveChatContex, _props$liveChatContex2;
|
|
11
9
|
|
|
12
|
-
let widgetPackageInfo;
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
widgetPackageInfo = require("@microsoft/omnichannel-chat-widget/package.json");
|
|
16
|
-
} catch (error) {
|
|
17
|
-
widgetPackageInfo = "0.0.0-0";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
10
|
const telemetryConfig = { ...defaultTelemetryConfiguration,
|
|
21
11
|
...props.telemetryConfig
|
|
22
12
|
};
|
|
@@ -38,9 +28,9 @@ export const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
38
28
|
}
|
|
39
29
|
|
|
40
30
|
telemetryData = TelemetryHelper.addWidgetDataToTelemetry(telemetryConfig, telemetryData);
|
|
41
|
-
telemetryData.OCChatSDKVersion =
|
|
42
|
-
telemetryData.chatComponentVersion = chatComponentVersion;
|
|
43
|
-
telemetryData.chatWidgetVersion =
|
|
31
|
+
telemetryData.OCChatSDKVersion = telemetryConfig.OCChatSDKVersion ?? "0.0.0-0";
|
|
32
|
+
telemetryData.chatComponentVersion = telemetryConfig.chatComponentVersion ?? "0.0.0-0";
|
|
33
|
+
telemetryData.chatWidgetVersion = telemetryConfig.chatWidgetVersion ?? "0.0.0-0";
|
|
44
34
|
telemetryData.orgId = (_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;
|
|
45
35
|
telemetryData.widgetId = (_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;
|
|
46
36
|
telemetryData.orgUrl = (_props$chatSDK3 = props.chatSDK) === null || _props$chatSDK3 === void 0 ? void 0 : (_props$chatSDK3$omnic = _props$chatSDK3.omnichannelConfig) === null || _props$chatSDK3$omnic === void 0 ? void 0 : _props$chatSDK3$omnic.orgUrl;
|
|
@@ -10,46 +10,55 @@ import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
|
10
10
|
import { createAdapter } from "./createAdapter";
|
|
11
11
|
import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
|
|
12
12
|
import { createTimer } from "../../../common/utils";
|
|
13
|
-
import { getReconnectIdForAuthenticatedChat } from "./reconnectChatHelper";
|
|
13
|
+
import { getReconnectIdForAuthenticatedChat, handleRedirectUnauthenticatedReconnectChat } from "./reconnectChatHelper";
|
|
14
14
|
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
15
15
|
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
16
|
|
|
17
17
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
18
|
+
var _props$reconnectChatP;
|
|
19
|
+
|
|
18
20
|
if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
|
|
19
21
|
return;
|
|
20
|
-
} //
|
|
21
|
-
|
|
22
|
+
} // Redirecting if unauthenticated reconnect chat expired
|
|
22
23
|
|
|
23
|
-
const parseToJson = false;
|
|
24
|
-
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
25
|
-
const showPrechat = state.appStates.conversationState === ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
26
|
+
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
dispatch({
|
|
31
|
-
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
32
|
-
payload: reconnectId
|
|
33
|
-
});
|
|
34
|
-
dispatch({
|
|
35
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
36
|
-
payload: ConversationState.ReconnectChat
|
|
37
|
-
});
|
|
38
|
-
} else if (showPrechat) {
|
|
39
|
-
dispatch({
|
|
40
|
-
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
41
|
-
payload: preChatSurveyResponse
|
|
42
|
-
});
|
|
43
|
-
dispatch({
|
|
44
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
45
|
-
payload: ConversationState.Prechat
|
|
46
|
-
});
|
|
28
|
+
await handleRedirectUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
47
29
|
} else {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
// Getting PreChat Survey Context
|
|
31
|
+
const parseToJson = false;
|
|
32
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
33
|
+
const showPrechat = state.appStates.conversationState === ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
34
|
+
|
|
35
|
+
const reconnectId = await getReconnectIdForAuthenticatedChat(props, chatSDK);
|
|
36
|
+
|
|
37
|
+
if (reconnectId) {
|
|
38
|
+
dispatch({
|
|
39
|
+
type: LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
40
|
+
payload: reconnectId
|
|
41
|
+
});
|
|
42
|
+
dispatch({
|
|
43
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
44
|
+
payload: ConversationState.ReconnectChat
|
|
45
|
+
});
|
|
46
|
+
} else if (showPrechat) {
|
|
47
|
+
dispatch({
|
|
48
|
+
type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
49
|
+
payload: preChatSurveyResponse
|
|
50
|
+
});
|
|
51
|
+
dispatch({
|
|
52
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
53
|
+
payload: ConversationState.Prechat
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
dispatch({
|
|
57
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
58
|
+
payload: ConversationState.Loading
|
|
59
|
+
});
|
|
60
|
+
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
61
|
+
}
|
|
53
62
|
}
|
|
54
63
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
64
|
|
|
@@ -5,7 +5,7 @@ import { BroadcastService, decodeComponentString } from "@microsoft/omnichannel-
|
|
|
5
5
|
import { Stack } from "@fluentui/react";
|
|
6
6
|
import React, { useEffect, useRef, useState } from "react";
|
|
7
7
|
import { createTimer, getLocaleDirection } from "../../../common/utils";
|
|
8
|
-
import { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat } from "../common/reconnectChatHelper";
|
|
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";
|
|
11
11
|
import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
|
|
@@ -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,
|
|
@@ -91,7 +96,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
91
96
|
if (!((_props$controlProps3 = props.controlProps) !== null && _props$controlProps3 !== void 0 && _props$controlProps3.skipChatButtonRendering) && (_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
92
97
|
var _props$reconnectChatP2;
|
|
93
98
|
|
|
94
|
-
|
|
99
|
+
startUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, initStartChat);
|
|
95
100
|
} // Initialize global dir
|
|
96
101
|
|
|
97
102
|
|
|
@@ -101,13 +106,11 @@ export const LiveChatWidgetStateful = props => {
|
|
|
101
106
|
payload: globalDir
|
|
102
107
|
});
|
|
103
108
|
|
|
104
|
-
if ((_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.
|
|
109
|
+
if ((_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.liveChatContext) {
|
|
105
110
|
var _state$domainStates2;
|
|
106
111
|
|
|
107
112
|
const optionalParams = {
|
|
108
|
-
liveChatContext:
|
|
109
|
-
chatToken: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.chatToken
|
|
110
|
-
}
|
|
113
|
+
liveChatContext: (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.liveChatContext
|
|
111
114
|
};
|
|
112
115
|
initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
|
|
113
116
|
}
|
|
@@ -117,9 +120,9 @@ export const LiveChatWidgetStateful = props => {
|
|
|
117
120
|
var _props$reconnectChatP3;
|
|
118
121
|
|
|
119
122
|
if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
|
|
120
|
-
var _props$reconnectChatP4;
|
|
123
|
+
var _props$reconnectChatP4, _props$reconnectChatP5;
|
|
121
124
|
|
|
122
|
-
handleUnauthenticatedReconnectChat(dispatch, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, initStartChat);
|
|
125
|
+
handleUnauthenticatedReconnectChat(chatSDK, dispatch, setAdapter, (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId, initStartChat, (_props$reconnectChatP5 = props.reconnectChatPaneProps) === null || _props$reconnectChatP5 === void 0 ? void 0 : _props$reconnectChatP5.redirectInSameWindow);
|
|
123
126
|
} else {
|
|
124
127
|
getReconnectIdForAuthenticatedChat(props, chatSDK).then(authReconnectId => {
|
|
125
128
|
if (authReconnectId && !state.appStates.reconnectId) {
|
|
@@ -132,6 +135,10 @@ export const LiveChatWidgetStateful = props => {
|
|
|
132
135
|
payload: ConversationState.ReconnectChat
|
|
133
136
|
});
|
|
134
137
|
} else {
|
|
138
|
+
const chatStartedSkippingChatButtonRendering = {
|
|
139
|
+
eventName: BroadcastEvent.StartChatSkippingChatButtonRendering
|
|
140
|
+
};
|
|
141
|
+
BroadcastService.postMessage(chatStartedSkippingChatButtonRendering);
|
|
135
142
|
dispatch({
|
|
136
143
|
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
137
144
|
payload: ConversationState.Loading
|
|
@@ -143,6 +150,17 @@ export const LiveChatWidgetStateful = props => {
|
|
|
143
150
|
}
|
|
144
151
|
}, [state.appStates.skipChatButtonRendering]);
|
|
145
152
|
useEffect(() => {
|
|
153
|
+
// Add the custom context on receiving the SetCustomContext event
|
|
154
|
+
BroadcastService.getMessageByEventName(BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
155
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
156
|
+
Event: TelemetryEvent.CustomContextReceived,
|
|
157
|
+
Description: "CustomContext received."
|
|
158
|
+
});
|
|
159
|
+
dispatch({
|
|
160
|
+
type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
161
|
+
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
162
|
+
});
|
|
163
|
+
});
|
|
146
164
|
BroadcastService.getMessageByEventName("StartProactiveChat").subscribe(msg => {
|
|
147
165
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
148
166
|
Event: TelemetryEvent.StartProactiveChatEventReceived,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LogLevel } from "../../../../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
3
|
+
export function createWebChatTelemetry() {
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
const handleTelemetry = event => {
|
|
6
|
+
const {
|
|
7
|
+
level
|
|
8
|
+
} = event;
|
|
9
|
+
const loglevel = level ? level.toUpperCase() : "";
|
|
10
|
+
|
|
11
|
+
switch (loglevel) {
|
|
12
|
+
case LogLevel.DEBUG:
|
|
13
|
+
TelemetryHelper.logWebChatEvent(LogLevel.DEBUG, event);
|
|
14
|
+
break;
|
|
15
|
+
|
|
16
|
+
case LogLevel.WARN:
|
|
17
|
+
TelemetryHelper.logWebChatEvent(LogLevel.WARN, event);
|
|
18
|
+
break;
|
|
19
|
+
|
|
20
|
+
case LogLevel.ERROR:
|
|
21
|
+
TelemetryHelper.logWebChatEvent(LogLevel.ERROR, event);
|
|
22
|
+
break;
|
|
23
|
+
|
|
24
|
+
case LogLevel.INFO:
|
|
25
|
+
default:
|
|
26
|
+
TelemetryHelper.logWebChatEvent(LogLevel.INFO, event);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return handleTelemetry;
|
|
32
|
+
}
|