@microsoft/omnichannel-chat-widget 0.1.0-main.eb80fb1 → 0.1.0-main.f514612
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/README.md +35 -11
- package/lib/cjs/common/Constants.js +54 -6
- package/lib/cjs/common/storage/default/defaultCacheManager.js +34 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +64 -6
- package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +17 -6
- package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -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 +89 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -4
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -40
- package/lib/cjs/components/footerstateful/FooterStateful.js +2 -10
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
- package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -10
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +65 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +32 -32
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +34 -19
- package/lib/cjs/components/livechatwidget/common/endChat.js +141 -50
- package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +1 -1
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +51 -9
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +144 -39
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +6 -17
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -9
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +171 -51
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +308 -81
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +19 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +96 -2
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +25 -48
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +45 -0
- package/lib/cjs/contexts/common/ConversationState.js +4 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +10 -7
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +17 -4
- package/lib/cjs/contexts/createReducer.js +24 -10
- package/lib/cjs/controller/componentController.js +5 -5
- package/lib/cjs/plugins/newMessageEventHandler.js +99 -0
- package/lib/esm/common/Constants.js +50 -5
- package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +60 -5
- package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +15 -6
- package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -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 +64 -1
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -7
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -36
- package/lib/esm/components/footerstateful/FooterStateful.js +2 -10
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
- package/lib/esm/components/headerstateful/HeaderStateful.js +15 -11
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +50 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +32 -31
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +34 -20
- package/lib/esm/components/livechatwidget/common/endChat.js +139 -50
- package/lib/esm/components/livechatwidget/common/initCallingSdk.js +1 -1
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +46 -11
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +134 -41
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +5 -14
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -9
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +165 -54
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +293 -84
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +20 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +86 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +23 -46
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +32 -0
- package/lib/esm/contexts/common/ConversationState.js +4 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +10 -7
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +15 -4
- package/lib/esm/contexts/createReducer.js +24 -9
- package/lib/esm/controller/componentController.js +5 -5
- package/lib/esm/plugins/newMessageEventHandler.js +82 -0
- package/lib/types/common/Constants.d.ts +27 -2
- package/lib/types/common/interfaces/IContextDataStore.d.ts +2 -2
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +46 -4
- 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 +8 -1
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +5 -2
- package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +5 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -2
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -1
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
- package/lib/types/contexts/common/ConversationState.d.ts +4 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +3 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +11 -8
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
- package/package.json +11 -12
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { WebChatActionType } from "../../enums/WebChatActionType";
|
|
2
|
+
import { Constants } from "../../../../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
3
|
+
|
|
4
|
+
const createMessageTimeStampMiddleware = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
dispatch
|
|
7
|
+
} = _ref;
|
|
8
|
+
return next => action => {
|
|
9
|
+
if (isApplicable(action)) {
|
|
10
|
+
return next(evaluateTagsAndOverrideTimeStamp(action));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return next(action);
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const isApplicable = action => {
|
|
18
|
+
return action.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && isPVAConversation(action) && isPayloadValid(action) && isValidChannel(action);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const isPayloadValid = action => {
|
|
22
|
+
var _action$payload;
|
|
23
|
+
|
|
24
|
+
return action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const isValidChannel = action => {
|
|
28
|
+
var _action$payload2, _action$payload2$acti;
|
|
29
|
+
|
|
30
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : _action$payload2$acti.channelId) === Constants.acsChannel;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const isPVAConversation = action => {
|
|
34
|
+
return !isTagIncluded(action, Constants.systemMessageTag) && !isTagIncluded(action, Constants.publicMessageTag) && !isRoleUserOn(action);
|
|
35
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
const isTagIncluded = (action, tag) => {
|
|
39
|
+
return isDataTagsPresent(action) && action.payload.activity.channelData.tags.includes(tag);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const isRoleUserOn = action => {
|
|
43
|
+
var _action$payload3, _action$payload3$acti, _action$payload3$acti2;
|
|
44
|
+
|
|
45
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : (_action$payload3$acti2 = _action$payload3$acti.from) === null || _action$payload3$acti2 === void 0 ? void 0 : _action$payload3$acti2.role) === Constants.userMessageTag;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const overrideTimeStamp = (timestampOriginal, timeStampNew) => {
|
|
49
|
+
return isTimestampValid(timeStampNew) ? timeStampNew : timestampOriginal;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const isTimestampValid = timeStamp => {
|
|
53
|
+
const regex = /(\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])(T)(\d{2})(:{1})(\d{2})(:{1})(\d{2})(.\d+)([Z]{1}))/;
|
|
54
|
+
return regex.test(timeStamp);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const isDataTagsPresent = action => {
|
|
58
|
+
var _action$payload4, _action$payload4$acti, _action$payload4$acti2;
|
|
59
|
+
|
|
60
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload4 = action.payload) === null || _action$payload4 === void 0 ? void 0 : (_action$payload4$acti = _action$payload4.activity) === null || _action$payload4$acti === void 0 ? void 0 : (_action$payload4$acti2 = _action$payload4$acti.channelData) === null || _action$payload4$acti2 === void 0 ? void 0 : _action$payload4$acti2.tags) && action.payload.activity.channelData.tags.length > 0;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const evaluateTagsAndOverrideTimeStamp = action => {
|
|
64
|
+
const tagValue = tagLookup(action, Constants.prefixTimestampTag);
|
|
65
|
+
|
|
66
|
+
if (tagValue) {
|
|
67
|
+
const newTimestamp = extractTimeStamp(tagValue);
|
|
68
|
+
action.payload.activity.timestamp = overrideTimeStamp(action.payload.activity.timestamp, newTimestamp);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return action;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const extractTimeStamp = timeStamp => {
|
|
75
|
+
if (timeStamp && timeStamp.length > 0) {
|
|
76
|
+
const ts = timeStamp.split(Constants.prefixTimestampTag);
|
|
77
|
+
|
|
78
|
+
if (ts && ts.length > 1) {
|
|
79
|
+
return ts[1];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return timeStamp;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const tagLookup = (action, tag) => {
|
|
87
|
+
if (!isDataTagsPresent(action)) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const tags = action.payload.activity.channelData.tags;
|
|
92
|
+
let value;
|
|
93
|
+
|
|
94
|
+
if (tags && tags.length > 0) {
|
|
95
|
+
for (let i = 0; i < tags.length; i++) {
|
|
96
|
+
value = tags[i];
|
|
97
|
+
|
|
98
|
+
if (value && value.indexOf(tag) > -1) {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export default createMessageTimeStampMiddleware;
|
|
@@ -17,22 +17,22 @@ const createConversationEndMiddleware = conversationEndCallback => _ref => {
|
|
|
17
17
|
var _action$payload;
|
|
18
18
|
|
|
19
19
|
if ((action === null || action === void 0 ? void 0 : action.type) == WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
|
|
20
|
-
var _activity$from, _activity$from2, _activity$
|
|
20
|
+
var _activity$from, _activity$from2, _activity$channelData7, _activity$channelData8;
|
|
21
21
|
|
|
22
22
|
const activity = action.payload.activity;
|
|
23
23
|
|
|
24
24
|
if (((_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) === DirectLineSenderRole.Bot && activity.channelId === "ACS_CHANNEL") {
|
|
25
|
-
var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4;
|
|
25
|
+
var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6;
|
|
26
26
|
|
|
27
27
|
// ACS
|
|
28
|
-
if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(Constants.systemMessageTag) && (_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && (_activity$channelData4 = _activity$channelData3.tags) !== null && _activity$channelData4 !== void 0 && _activity$channelData4.includes(Constants.agentEndConversationMessageTag)) {
|
|
28
|
+
if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(Constants.systemMessageTag) && ((_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && (_activity$channelData4 = _activity$channelData3.tags) !== null && _activity$channelData4 !== void 0 && _activity$channelData4.includes(Constants.agentEndConversationMessageTag) || (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(Constants.supervisorForceCloseMessageTag))) {
|
|
29
29
|
conversationEndCallback();
|
|
30
30
|
}
|
|
31
|
-
} else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === DirectLineSenderRole.Channel && ((_activity$
|
|
32
|
-
var _activity$
|
|
31
|
+
} else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === DirectLineSenderRole.Channel && ((_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : _activity$channelData7.type) === MessageTypes.Thread && (_activity$channelData8 = activity.channelData) !== null && _activity$channelData8 !== void 0 && _activity$channelData8.properties) {
|
|
32
|
+
var _activity$channelData9, _activity$channelData10, _activity$channelData11, _activity$channelData12;
|
|
33
33
|
|
|
34
34
|
// IC3
|
|
35
|
-
if (((_activity$
|
|
35
|
+
if (((_activity$channelData9 = activity.channelData) === null || _activity$channelData9 === void 0 ? void 0 : (_activity$channelData10 = _activity$channelData9.properties) === null || _activity$channelData10 === void 0 ? void 0 : _activity$channelData10.isdeleted) === Constants.truePascal || !((_activity$channelData11 = activity.channelData) !== null && _activity$channelData11 !== void 0 && (_activity$channelData12 = _activity$channelData11.properties) !== null && _activity$channelData12 !== void 0 && _activity$channelData12.containsExternalEntitiesListeningAll)) {
|
|
36
36
|
conversationEndCallback();
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -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
|
+
}
|
|
@@ -7,6 +7,8 @@ export let ConversationState;
|
|
|
7
7
|
ConversationState[ConversationState["OutOfOffice"] = 3] = "OutOfOffice";
|
|
8
8
|
ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
|
|
9
9
|
ConversationState[ConversationState["Active"] = 5] = "Active";
|
|
10
|
-
ConversationState[ConversationState["
|
|
11
|
-
ConversationState[ConversationState["
|
|
10
|
+
ConversationState[ConversationState["InActive"] = 6] = "InActive";
|
|
11
|
+
ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
|
|
12
|
+
ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
|
|
13
|
+
ConversationState[ConversationState["Closed"] = 9] = "Closed";
|
|
12
14
|
})(ConversationState || (ConversationState = {}));
|
|
@@ -10,13 +10,13 @@ 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["
|
|
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
20
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SHOW_CALLING_CONTAINER"] = 16] = "SHOW_CALLING_CONTAINER";
|
|
21
21
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INCOMING_CALL"] = 17] = "SET_INCOMING_CALL";
|
|
22
22
|
LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_VIDEO_CALL"] = 18] = "DISABLE_VIDEO_CALL";
|
|
@@ -32,4 +32,7 @@ export let LiveChatWidgetActionType;
|
|
|
32
32
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT"] = 28] = "SET_CONVERSATION_ENDED_BY_AGENT";
|
|
33
33
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 29] = "SET_WIDGET_STATE";
|
|
34
34
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
|
|
35
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 31] = "SET_BOT_OAUTH_SIGNIN_ID";
|
|
36
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 32] = "SET_WIDGET_SIZE";
|
|
37
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 33] = "SET_WIDGET_INSTANCE_ID";
|
|
35
38
|
})(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { ConversationState } from "./ConversationState";
|
|
2
2
|
import { defaultMiddlewareLocalizedTexts } from "../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
3
|
+
import { getWidgetCacheId, isNullOrUndefined } from "../../common/utils";
|
|
4
|
+
import { defaultClientDataStoreProvider } from "../../common/storage/default/defaultClientDataStoreProvider";
|
|
3
5
|
export const getLiveChatWidgetContextInitialState = props => {
|
|
4
|
-
var _props$webChatContain;
|
|
6
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$webChatContain;
|
|
7
|
+
|
|
8
|
+
const widgetCacheId = 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, (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
9
|
+
const initialState = defaultClientDataStoreProvider().getData(widgetCacheId, "localStorage");
|
|
10
|
+
|
|
11
|
+
if (!isNullOrUndefined(initialState)) {
|
|
12
|
+
return JSON.parse(initialState);
|
|
13
|
+
}
|
|
5
14
|
|
|
6
15
|
const LiveChatWidgetContextInitialState = {
|
|
7
16
|
domainStates: {
|
|
@@ -14,14 +23,16 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
14
23
|
postChatContext: undefined,
|
|
15
24
|
telemetryInternalData: {},
|
|
16
25
|
globalDir: "ltr",
|
|
17
|
-
liveChatContext: undefined
|
|
26
|
+
liveChatContext: undefined,
|
|
27
|
+
customContext: undefined,
|
|
28
|
+
widgetSize: undefined,
|
|
29
|
+
widgetInstanceId: ""
|
|
18
30
|
},
|
|
19
31
|
appStates: {
|
|
20
32
|
conversationState: ConversationState.Closed,
|
|
21
33
|
isMinimized: false,
|
|
22
34
|
previousElementOnFocusBeforeModalOpen: null,
|
|
23
35
|
outsideOperatingHours: false,
|
|
24
|
-
shouldShowPostChat: false,
|
|
25
36
|
preChatResponseEmail: "",
|
|
26
37
|
isAudioMuted: null,
|
|
27
38
|
newMessage: false,
|
|
@@ -47,5 +58,5 @@ export const getLiveChatWidgetContextInitialState = props => {
|
|
|
47
58
|
focusChatButton: false
|
|
48
59
|
}
|
|
49
60
|
};
|
|
50
|
-
return
|
|
61
|
+
return LiveChatWidgetContextInitialState;
|
|
51
62
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable indent */
|
|
2
2
|
import { LiveChatWidgetActionType } from "./common/LiveChatWidgetActionType";
|
|
3
|
-
import { TelemetryManager } from "../common/telemetry/TelemetryManager";
|
|
4
3
|
export const createReducer = () => {
|
|
5
4
|
const reducer = (state, action) => {
|
|
6
5
|
var _action$payload, _action$payload2, _action$payload3;
|
|
@@ -62,6 +61,14 @@ export const createReducer = () => {
|
|
|
62
61
|
}
|
|
63
62
|
};
|
|
64
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
|
+
|
|
65
72
|
case LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT:
|
|
66
73
|
return { ...state,
|
|
67
74
|
appStates: { ...state.appStates,
|
|
@@ -84,13 +91,6 @@ export const createReducer = () => {
|
|
|
84
91
|
}
|
|
85
92
|
};
|
|
86
93
|
|
|
87
|
-
case LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT:
|
|
88
|
-
return { ...state,
|
|
89
|
-
appStates: { ...state.appStates,
|
|
90
|
-
shouldShowPostChat: action.payload
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
94
|
case LiveChatWidgetActionType.SHOW_CALLING_CONTAINER:
|
|
95
95
|
return { ...state,
|
|
96
96
|
uiStates: { ...state.uiStates,
|
|
@@ -188,7 +188,6 @@ export const createReducer = () => {
|
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
case LiveChatWidgetActionType.SET_TELEMETRY_DATA:
|
|
191
|
-
TelemetryManager.InternalTelemetryData = action.payload;
|
|
192
191
|
return { ...state,
|
|
193
192
|
domainStates: { ...state.domainStates,
|
|
194
193
|
telemetryInternalData: action.payload
|
|
@@ -228,6 +227,22 @@ export const createReducer = () => {
|
|
|
228
227
|
}
|
|
229
228
|
};
|
|
230
229
|
|
|
230
|
+
case LiveChatWidgetActionType.SET_WIDGET_SIZE:
|
|
231
|
+
return { ...state,
|
|
232
|
+
domainStates: { ...state.domainStates,
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
|
+
widgetSize: action.payload
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
case LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID:
|
|
239
|
+
return { ...state,
|
|
240
|
+
domainStates: { ...state.domainStates,
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
|
+
widgetInstanceId: action.payload
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
231
246
|
default:
|
|
232
247
|
return state;
|
|
233
248
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConversationState } from "../contexts/common/ConversationState";
|
|
2
2
|
export const shouldShowChatButton = state => {
|
|
3
|
-
return state.appStates.isMinimized || state.appStates.conversationState === ConversationState.Closed;
|
|
3
|
+
return (state.appStates.isMinimized || state.appStates.conversationState === ConversationState.Closed) && state.appStates.skipChatButtonRendering == false; // Do not show chat button in case of popout
|
|
4
4
|
};
|
|
5
5
|
export const shouldShowProactiveChatPane = state => {
|
|
6
6
|
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.ProactiveChat;
|
|
@@ -9,22 +9,22 @@ export const shouldShowHeader = state => {
|
|
|
9
9
|
return !state.appStates.isMinimized && state.appStates.conversationState !== ConversationState.Closed && state.appStates.conversationState !== ConversationState.ProactiveChat;
|
|
10
10
|
};
|
|
11
11
|
export const shouldShowFooter = state => {
|
|
12
|
-
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Active;
|
|
12
|
+
return !state.appStates.isMinimized && (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.InActive);
|
|
13
13
|
};
|
|
14
14
|
export const shouldShowEmailTranscriptPane = state => {
|
|
15
15
|
return state.uiStates.showEmailTranscriptPane;
|
|
16
16
|
};
|
|
17
17
|
export const shouldShowWebChatContainer = state => {
|
|
18
|
-
return state.appStates.conversationState === ConversationState.Active;
|
|
18
|
+
return state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.InActive;
|
|
19
19
|
};
|
|
20
20
|
export const shouldShowLoadingPane = state => {
|
|
21
|
-
return !state.appStates.isMinimized &&
|
|
21
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Loading;
|
|
22
22
|
};
|
|
23
23
|
export const shouldShowReconnectChatPane = state => {
|
|
24
24
|
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.ReconnectChat;
|
|
25
25
|
};
|
|
26
26
|
export const shouldShowPostChatLoadingPane = state => {
|
|
27
|
-
return !state.appStates.isMinimized && state.appStates.
|
|
27
|
+
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.PostchatLoading;
|
|
28
28
|
};
|
|
29
29
|
export const shouldShowOutOfOfficeHoursPane = state => {
|
|
30
30
|
return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.OutOfOffice;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../common/telemetry/TelemetryConstants";
|
|
2
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
3
|
+
import { Constants } from "../common/Constants";
|
|
4
|
+
import { TelemetryHelper } from "../common/telemetry/TelemetryHelper";
|
|
5
|
+
export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
6
|
+
const onNewAdapterActivityHandler = activity => {
|
|
7
|
+
var _activity$channelData, _activity$channelData2, _activity$channelData3;
|
|
8
|
+
|
|
9
|
+
const isActivityMessage = (activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message;
|
|
10
|
+
const isNotHistoryMessage = isActivityMessage && !(activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(Constants.historyMessageTag)) && !(activity !== null && activity !== void 0 && (_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && _activity$channelData3.fromList);
|
|
11
|
+
|
|
12
|
+
if (isNotHistoryMessage) {
|
|
13
|
+
raiseMessageEvent(activity);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const raiseMessageEvent = activity => {
|
|
18
|
+
if ((activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message) {
|
|
19
|
+
var _text, _text2, _activity$channelData4, _activity$from;
|
|
20
|
+
|
|
21
|
+
const payload = {
|
|
22
|
+
// To identify hidden contents vs empty content
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
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)*` : "",
|
|
25
|
+
type: activity === null || activity === void 0 ? void 0 : activity.type,
|
|
26
|
+
timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
|
|
27
|
+
userId: userId,
|
|
28
|
+
tags: activity === null || activity === void 0 ? void 0 : (_activity$channelData4 = activity.channelData) === null || _activity$channelData4 === void 0 ? void 0 : _activity$channelData4.tags,
|
|
29
|
+
messageType: ""
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if ((activity === null || activity === void 0 ? void 0 : (_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) === Constants.userMessageTag) {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
payload.messageType = Constants.userMessageTag;
|
|
35
|
+
const newMessageSentEvent = {
|
|
36
|
+
eventName: BroadcastEvent.NewMessageSent,
|
|
37
|
+
payload: payload
|
|
38
|
+
};
|
|
39
|
+
BroadcastService.postMessage(newMessageSentEvent);
|
|
40
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
41
|
+
Event: TelemetryEvent.MessageSent,
|
|
42
|
+
Description: "New message sent"
|
|
43
|
+
});
|
|
44
|
+
} else {
|
|
45
|
+
var _activity$channelData5, _activity$channelData6;
|
|
46
|
+
|
|
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)) {
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
payload.messageType = Constants.systemMessageTag;
|
|
50
|
+
} else {
|
|
51
|
+
var _activity$channelData7, _activity$channelData8, _activity$channelData9;
|
|
52
|
+
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
|
|
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
|
|
57
|
+
|
|
58
|
+
const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
|
|
59
|
+
|
|
60
|
+
if (messageHasNoTags && messageHasNoText && messageHasNoAttachments) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
payload.messageType = Constants.userMessageTag;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const newMessageReceivedEvent = {
|
|
68
|
+
eventName: BroadcastEvent.NewMessageReceived,
|
|
69
|
+
payload: payload
|
|
70
|
+
};
|
|
71
|
+
BroadcastService.postMessage(newMessageReceivedEvent);
|
|
72
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
73
|
+
Event: TelemetryEvent.MessageReceived,
|
|
74
|
+
Description: "New message received",
|
|
75
|
+
Data: payload
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return onNewAdapterActivityHandler;
|
|
82
|
+
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export declare class Constants {
|
|
2
|
+
static readonly magicCodeBroadcastChannel = "MagicCodeChannel";
|
|
3
|
+
static readonly magicCodeResponseBroadcastChannel = "MagicCodeResponseChannel";
|
|
2
4
|
static readonly systemMessageTag = "system";
|
|
3
5
|
static readonly userMessageTag = "user";
|
|
6
|
+
static readonly historyMessageTag = "history";
|
|
4
7
|
static readonly agentEndConversationMessageTag = "agentendconversation";
|
|
8
|
+
static readonly supervisorForceCloseMessageTag = "supervisorforceclosedconversation";
|
|
5
9
|
static readonly receivedMessageClassName = "ms_lcw_webchat_received_message";
|
|
6
10
|
static readonly sentMessageClassName = "ms_lcw_webchat_sent_message";
|
|
7
11
|
static readonly webchatChannelId = "webchat";
|
|
@@ -13,7 +17,6 @@ export declare class Constants {
|
|
|
13
17
|
static readonly true = "true";
|
|
14
18
|
static readonly false = "false";
|
|
15
19
|
static readonly maximumUnreadMessageCount = 99;
|
|
16
|
-
static readonly widgetStateDataKey = "LcwChatWidgetState";
|
|
17
20
|
static readonly channelIdKey = "ChannelId-";
|
|
18
21
|
static readonly ChannelId = "lcw";
|
|
19
22
|
static readonly CustomerTag = "FromCustomer";
|
|
@@ -31,6 +34,10 @@ export declare class Constants {
|
|
|
31
34
|
static readonly queuePositionMessageTag = "queueposition";
|
|
32
35
|
static readonly averageWaitTimeMessageTag = "averagewaittime";
|
|
33
36
|
static readonly message = "message";
|
|
37
|
+
static readonly hiddenTag = "Hidden";
|
|
38
|
+
static readonly prefixTimestampTag = "ServerMessageTimestamp_";
|
|
39
|
+
static readonly acsChannel = "ACS_CHANNEL";
|
|
40
|
+
static readonly publicMessageTag = "public";
|
|
34
41
|
static readonly supportedAdaptiveCardContentTypes: Array<string>;
|
|
35
42
|
static readonly maxUploadFileSize = "500000";
|
|
36
43
|
static readonly imageRegex: RegExp;
|
|
@@ -56,7 +63,6 @@ export declare class Constants {
|
|
|
56
63
|
static readonly ProactiveChatInviteTimeoutInMs = 60000;
|
|
57
64
|
static readonly InputSubmit = "InputSubmit";
|
|
58
65
|
static readonly ReconnectIdAttributeName = "oc.reconnectid";
|
|
59
|
-
static readonly redirectPageRequest = "redirectPageRequest";
|
|
60
66
|
static readonly LiveChatWidget = "LiveChatWidgetNew";
|
|
61
67
|
static readonly GuidPattern = "xx-x-4m-ym-xxx";
|
|
62
68
|
static readonly Default = "default";
|
|
@@ -69,6 +75,9 @@ export declare class Constants {
|
|
|
69
75
|
static readonly OpenLinkIconCssClass = "webchat__markdown__external-link-icon";
|
|
70
76
|
static readonly internetConnectionTestUrl = "https://ocsdk-prod.azureedge.net/public/connecttest.txt";
|
|
71
77
|
static readonly internetConnectionTestUrlText = "Omnichannel Connect Test";
|
|
78
|
+
static readonly ChatWidgetStateChangedPrefix = "ChatWidgetStateChanged";
|
|
79
|
+
static readonly PostChatLoadingDurationInMs = 2000;
|
|
80
|
+
static readonly BrowserUnloadConfirmationMessage = "Do you want to leave chat?";
|
|
72
81
|
}
|
|
73
82
|
export declare const Regex: {
|
|
74
83
|
new (): {};
|
|
@@ -135,6 +144,12 @@ export declare enum ElementType {
|
|
|
135
144
|
export declare enum ChatSDKError {
|
|
136
145
|
WidgetUseOutsideOperatingHour = "WidgetUseOutsideOperatingHour"
|
|
137
146
|
}
|
|
147
|
+
export declare enum EnvironmentVersion {
|
|
148
|
+
prod = "prod",
|
|
149
|
+
dogfood = "df",
|
|
150
|
+
int = "int",
|
|
151
|
+
test = "test"
|
|
152
|
+
}
|
|
138
153
|
export declare class TranscriptConstants {
|
|
139
154
|
static readonly ChatTranscriptsBodyColor = "#F5F5F5";
|
|
140
155
|
static readonly TranscriptMessageEmojiMessageType = "http://schema.skype.com/emoji";
|
|
@@ -147,3 +162,13 @@ export declare class TranscriptConstants {
|
|
|
147
162
|
static readonly AgentDialogColor = "#2266E3";
|
|
148
163
|
static readonly AgentFontColor = "white";
|
|
149
164
|
}
|
|
165
|
+
export declare class AriaTelemetryConstants {
|
|
166
|
+
static readonly GERMANY_ENDPOINT: string;
|
|
167
|
+
static readonly GCCH_ENDPOINT: string;
|
|
168
|
+
static readonly DOD_ENDPOINT: string;
|
|
169
|
+
static readonly EUROPE_ENDPOINT: string;
|
|
170
|
+
static readonly MOONCAKE_ENDPOINT: string;
|
|
171
|
+
static readonly Public: string;
|
|
172
|
+
static readonly EU: string;
|
|
173
|
+
static readonly lcwEUDomainNames: Array<string>;
|
|
174
|
+
}
|
|
@@ -6,9 +6,9 @@ export interface IContextDataStore {
|
|
|
6
6
|
/**
|
|
7
7
|
* setData: Set data to data store
|
|
8
8
|
*/
|
|
9
|
-
setData: (key: string, value: string) => void;
|
|
9
|
+
setData: (key: string, value: any, type: string) => void;
|
|
10
10
|
/**
|
|
11
11
|
* removeData: Remove data from data store by key
|
|
12
12
|
*/
|
|
13
|
-
removeData
|
|
13
|
+
removeData: (key: string, type: string) => void;
|
|
14
14
|
}
|