@microsoft/omnichannel-chat-widget 0.1.0-main.ae3aa42 → 0.1.0-main.dbc1afa
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 +6 -1
- 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 +1 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +1 -1
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +0 -12
- package/lib/cjs/components/livechatwidget/common/endChat.js +27 -12
- 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 +32 -2
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -5
- 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 +6 -1
- 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 +1 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +1 -1
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +0 -12
- package/lib/esm/components/livechatwidget/common/endChat.js +24 -13
- 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 +29 -3
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +6 -7
- 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 +6 -3
- 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
|
@@ -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,6 +150,19 @@ export const LiveChatWidgetStateful = props => {
|
|
|
145
150
|
}
|
|
146
151
|
}, [state.appStates.skipChatButtonRendering]);
|
|
147
152
|
useEffect(() => {
|
|
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
|
+
});
|
|
148
166
|
BroadcastService.getMessageByEventName("StartProactiveChat").subscribe(msg => {
|
|
149
167
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
150
168
|
Event: TelemetryEvent.StartProactiveChatEventReceived,
|
|
@@ -192,6 +210,11 @@ 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);
|
|
195
218
|
});
|
|
196
219
|
window.addEventListener("beforeunload", () => {
|
|
197
220
|
disposeTelemetryLoggers();
|
|
@@ -274,8 +297,11 @@ export const LiveChatWidgetStateful = props => {
|
|
|
274
297
|
const confirmationPaneProps = initConfirmationPropsComposer(props); // publish chat widget state
|
|
275
298
|
|
|
276
299
|
useEffect(() => {
|
|
300
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic;
|
|
301
|
+
|
|
302
|
+
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
303
|
const chatWidgetStateChangeEvent = {
|
|
278
|
-
eventName:
|
|
304
|
+
eventName: widgetStateEventName,
|
|
279
305
|
payload: { ...state
|
|
280
306
|
}
|
|
281
307
|
};
|
|
@@ -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);
|
|
@@ -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 (): {};
|
|
@@ -22,7 +22,6 @@ export declare enum BroadcastEvent {
|
|
|
22
22
|
EndChat = "ChatEnded",
|
|
23
23
|
NewMessageNotification = "NewMessageNotification",
|
|
24
24
|
UnreadMessageCount = "UnreadMessageCount",
|
|
25
|
-
ChatWidgetStateChanged = "ChatWidgetStateChanged",
|
|
26
25
|
ProactiveChatStartChat = "ProactiveChatStartChat",
|
|
27
26
|
ProactiveChatStartPopoutChat = "ProactiveChatStartPopoutChat",
|
|
28
27
|
InvalidAdaptiveCardFormat = "InvalidAdaptiveCardFormat",
|
|
@@ -30,7 +29,9 @@ export declare enum BroadcastEvent {
|
|
|
30
29
|
NewMessageReceived = "NewMessageReceived",
|
|
31
30
|
RedirectPageRequest = "RedirectPageRequest",
|
|
32
31
|
StartChatSkippingChatButtonRendering = "StartChatSkippingChatButtonRendering",
|
|
33
|
-
StartUnauthenticatedReconnectChat = "StartUnauthenticatedReconnectChat"
|
|
32
|
+
StartUnauthenticatedReconnectChat = "StartUnauthenticatedReconnectChat",
|
|
33
|
+
SetCustomContext = "SetCustomContext",
|
|
34
|
+
ChatRetrievedFromCache = "ChatRetrievedFromCache"
|
|
34
35
|
}
|
|
35
36
|
export declare enum TelemetryEvent {
|
|
36
37
|
CallAdded = "CallAdded",
|
|
@@ -129,11 +130,13 @@ export declare enum TelemetryEvent {
|
|
|
129
130
|
ReconnectChatStartNewConversation = "ReconnectChatStartNewConversation",
|
|
130
131
|
ReconnectChatMinimize = "ReconnectChatMinimize",
|
|
131
132
|
MessageSent = "MessageSent",
|
|
132
|
-
MessageReceived = "MessageReceived"
|
|
133
|
+
MessageReceived = "MessageReceived",
|
|
134
|
+
CustomContextReceived = "CustomContextReceived"
|
|
133
135
|
}
|
|
134
136
|
export interface TelemetryInput {
|
|
135
137
|
scenarioType: ScenarioType;
|
|
136
138
|
payload: TelemetryData;
|
|
139
|
+
telemetryInfo?: any;
|
|
137
140
|
}
|
|
138
141
|
export declare class TelemetryConstants {
|
|
139
142
|
private static map;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface BaseTelemetryData {
|
|
2
|
+
Data?: any;
|
|
3
|
+
}
|
|
4
|
+
export interface ConfigValidationTelemetryData extends BaseTelemetryData {
|
|
2
5
|
Event?: string;
|
|
3
6
|
RequestId?: string;
|
|
4
7
|
LCWVersion?: string;
|
|
@@ -8,7 +11,7 @@ export interface ConfigValidationTelemetryData {
|
|
|
8
11
|
ExceptionDetails?: object;
|
|
9
12
|
Domain?: string;
|
|
10
13
|
}
|
|
11
|
-
export interface LoadTelemetryData {
|
|
14
|
+
export interface LoadTelemetryData extends BaseTelemetryData {
|
|
12
15
|
Event?: string;
|
|
13
16
|
ResourcePath?: string;
|
|
14
17
|
ElapsedTimeInMilliseconds?: number;
|
|
@@ -20,18 +23,18 @@ export interface LoadTelemetryData {
|
|
|
20
23
|
OCChatWidgetVersion?: string;
|
|
21
24
|
OCChatComponentsVersion?: string;
|
|
22
25
|
}
|
|
23
|
-
export interface MessageProcessingErrorData {
|
|
26
|
+
export interface MessageProcessingErrorData extends BaseTelemetryData {
|
|
24
27
|
Event: string;
|
|
25
28
|
ExceptionDetails: object;
|
|
26
29
|
}
|
|
27
|
-
export interface OCChatSDKTelemetryData {
|
|
30
|
+
export interface OCChatSDKTelemetryData extends BaseTelemetryData {
|
|
28
31
|
RequestId: string;
|
|
29
32
|
Event?: string;
|
|
30
33
|
ElapsedTimeInMilliseconds?: number;
|
|
31
34
|
TransactionId: string;
|
|
32
35
|
ExceptionDetails?: object;
|
|
33
36
|
}
|
|
34
|
-
export interface IC3ClientTelemetryData {
|
|
37
|
+
export interface IC3ClientTelemetryData extends BaseTelemetryData {
|
|
35
38
|
SubscriptionId?: string;
|
|
36
39
|
EndpointUrl?: string;
|
|
37
40
|
EndpointId?: string;
|
|
@@ -42,7 +45,7 @@ export interface IC3ClientTelemetryData {
|
|
|
42
45
|
ShouldBubbleToHost?: boolean;
|
|
43
46
|
Description?: string;
|
|
44
47
|
}
|
|
45
|
-
export interface WebChatTelemetryData {
|
|
48
|
+
export interface WebChatTelemetryData extends BaseTelemetryData {
|
|
46
49
|
data?: any;
|
|
47
50
|
dimensions?: any;
|
|
48
51
|
duration?: number;
|
|
@@ -53,7 +56,7 @@ export interface WebChatTelemetryData {
|
|
|
53
56
|
name?: string;
|
|
54
57
|
type?: string;
|
|
55
58
|
}
|
|
56
|
-
export interface ACSAdapterTelemetryData {
|
|
59
|
+
export interface ACSAdapterTelemetryData extends BaseTelemetryData {
|
|
57
60
|
Description?: string;
|
|
58
61
|
ACSUserId?: string;
|
|
59
62
|
ChatThreadId?: string;
|
|
@@ -63,14 +66,14 @@ export interface ACSAdapterTelemetryData {
|
|
|
63
66
|
ErrorCode?: string;
|
|
64
67
|
ExceptionDetails?: any;
|
|
65
68
|
}
|
|
66
|
-
export interface ActionTelemetryData {
|
|
69
|
+
export interface ActionTelemetryData extends BaseTelemetryData {
|
|
67
70
|
Event?: string;
|
|
68
71
|
ElapsedTimeInMilliseconds?: number;
|
|
69
72
|
ActionType?: string;
|
|
70
73
|
ExceptionDetails?: object;
|
|
71
74
|
Description?: string;
|
|
72
75
|
}
|
|
73
|
-
export interface CallingTelemetryData {
|
|
76
|
+
export interface CallingTelemetryData extends BaseTelemetryData {
|
|
74
77
|
CallId?: string;
|
|
75
78
|
Event?: string;
|
|
76
79
|
ElapsedTimeInMilliseconds?: number;
|
|
@@ -22,3 +22,5 @@ export declare const isNullOrEmptyString: (s: string) => boolean;
|
|
|
22
22
|
export declare const newGuid: () => string;
|
|
23
23
|
export declare const createTimer: () => ITimer;
|
|
24
24
|
export declare const getDomain: (hostValue: any) => string;
|
|
25
|
+
export declare const getWidgetCacheId: (orgId: string, widgetId: string) => string;
|
|
26
|
+
export declare const getWidgetEndChatEventName: (orgId: string, widgetId: string) => string;
|
|
@@ -3,5 +3,5 @@ import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetA
|
|
|
3
3
|
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
4
4
|
import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidgetContext";
|
|
5
5
|
declare const prepareEndChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, state: ILiveChatWidgetContext) => Promise<void>;
|
|
6
|
-
declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, skipEndChatSDK?: boolean | undefined, skipCloseChat?: boolean | undefined) => Promise<void>;
|
|
6
|
+
declare const endChat: (props: ILiveChatWidgetProps, chatSDK: any, setAdapter: any, setWebChatStyles: any, dispatch: Dispatch<ILiveChatWidgetAction>, adapter: any, skipEndChatSDK?: boolean | undefined, skipCloseChat?: boolean | undefined, postMessageToOtherTab?: boolean | undefined) => Promise<void>;
|
|
7
7
|
export { prepareEndChat, endChat };
|
|
@@ -8,25 +8,26 @@ export declare enum LiveChatWidgetActionType {
|
|
|
8
8
|
SET_PREVIOUS_FOCUSED_ELEMENT = 6,
|
|
9
9
|
SET_OUTSIDE_OPERATING_HOURS = 7,
|
|
10
10
|
SET_PRE_CHAT_SURVEY_RESPONSE = 8,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
11
|
+
SET_CUSTOM_CONTEXT = 9,
|
|
12
|
+
SET_SHOW_CONFIRMATION = 10,
|
|
13
|
+
SET_SHOW_EMAIL_TRANSCRIPT_PANE = 11,
|
|
14
|
+
SET_PRECHAT_RESPONSE_EMAIL = 12,
|
|
15
|
+
SET_AUDIO_NOTIFICATION = 13,
|
|
16
|
+
SET_E2VV_ENABLED = 14,
|
|
17
|
+
SET_POST_CHAT_CONTEXT = 15,
|
|
18
|
+
SHOW_CALLING_CONTAINER = 16,
|
|
19
|
+
SET_INCOMING_CALL = 17,
|
|
20
|
+
DISABLE_VIDEO_CALL = 18,
|
|
21
|
+
DISABLE_LOCAL_VIDEO = 19,
|
|
22
|
+
DISABLE_REMOTE_VIDEO = 20,
|
|
23
|
+
SET_CHAT_TOKEN = 21,
|
|
24
|
+
SET_SKIP_CHAT_BUTTON_RENDERING = 22,
|
|
25
|
+
SET_PROACTIVE_CHAT_PARAMS = 23,
|
|
26
|
+
SET_TELEMETRY_DATA = 24,
|
|
27
|
+
SET_RECONNECT_ID = 25,
|
|
28
|
+
SET_UNREAD_MESSAGE_COUNT = 26,
|
|
29
|
+
SET_FOCUS_CHAT_BUTTON = 27,
|
|
30
|
+
SET_CONVERSATION_ENDED_BY_AGENT = 28,
|
|
31
|
+
SET_WIDGET_STATE = 29,
|
|
32
|
+
SET_LIVE_CHAT_CONTEXT = 30
|
|
32
33
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "0.1.0-main.
|
|
3
|
+
"version": "0.1.0-main.dbc1afa",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@fluentui/react": "^8.49.1",
|
|
77
|
-
"@microsoft/omnichannel-chat-components": "^0.1.0-main.
|
|
77
|
+
"@microsoft/omnichannel-chat-components": "^0.1.0-main.423d0ce",
|
|
78
78
|
"@microsoft/omnichannel-chat-sdk": "1.0.1-main.077d17c",
|
|
79
79
|
"abort-controller-es5": "^2.0.1",
|
|
80
80
|
"dompurify": "^2.3.4",
|