@microsoft/omnichannel-chat-widget 0.1.0-main.52da005 → 0.1.0-main.52fa2fc
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 +7 -34
- package/lib/cjs/common/Constants.js +12 -3
- package/lib/cjs/common/storage/default/defaultCacheManager.js +2 -2
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
- package/lib/cjs/common/telemetry/TelemetryConstants.js +35 -4
- package/lib/cjs/common/telemetry/TelemetryHelper.js +2 -1
- package/lib/cjs/common/utils.js +23 -2
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +5 -2
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
- package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
- package/lib/cjs/components/livechatwidget/common/endChat.js +43 -63
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +11 -49
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -7
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -2
- package/lib/cjs/components/livechatwidget/common/startChat.js +83 -64
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +91 -45
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +7 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
- package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +11 -7
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +10 -4
- package/lib/cjs/contexts/createReducer.js +36 -2
- package/lib/cjs/hooks/useDebounce.js +28 -0
- package/lib/cjs/hooks/useWindowDimensions.js +30 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +14 -0
- package/lib/esm/common/Constants.js +10 -2
- package/lib/esm/common/storage/default/defaultCacheManager.js +2 -2
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +35 -4
- package/lib/esm/common/telemetry/TelemetryHelper.js +2 -1
- package/lib/esm/common/utils.js +20 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +5 -2
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
- package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
- package/lib/esm/components/livechatwidget/common/endChat.js +45 -65
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -51
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +12 -7
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +83 -64
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +92 -46
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +5 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
- package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +11 -7
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +10 -4
- package/lib/esm/contexts/createReducer.js +36 -2
- package/lib/esm/hooks/useDebounce.js +22 -0
- package/lib/esm/hooks/useWindowDimensions.js +23 -0
- package/lib/esm/plugins/newMessageEventHandler.js +14 -0
- package/lib/types/common/Constants.d.ts +9 -0
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +1 -1
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +31 -6
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +11 -7
- package/lib/types/hooks/useDebounce.d.ts +3 -0
- package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
- package/package.json +3 -3
|
@@ -4,9 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
|
|
7
8
|
var _NotificationHandler = require("../../notification/NotificationHandler");
|
|
8
9
|
var _NotificationScenarios = require("../../enums/NotificationScenarios");
|
|
9
10
|
var _WebChatActionType = require("../../enums/WebChatActionType");
|
|
11
|
+
var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
|
|
12
|
+
var _Constants = require("../../../../../common/Constants");
|
|
10
13
|
/******
|
|
11
14
|
* AttachmentUploadValidatorMiddleware
|
|
12
15
|
*
|
|
@@ -19,17 +22,18 @@ const MBtoBRatio = 1000000;
|
|
|
19
22
|
* If an attachment is invalid, delete this attachment from the attachments list
|
|
20
23
|
* If the result attachment list is empty, return a dummy action
|
|
21
24
|
*/
|
|
22
|
-
const validateAttachment = (action, allowedFileExtensions,
|
|
25
|
+
const validateAttachment = (action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
23
26
|
var _action$payload, _action$payload$activ, _action$payload2, _action$payload2$acti, _action$payload2$acti2, _action$payload3, _action$payload3$acti, _action$payload3$acti2;
|
|
24
27
|
const attachments = action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$activ = _action$payload.activity) === null || _action$payload$activ === void 0 ? void 0 : _action$payload$activ.attachments;
|
|
25
28
|
const attachmentSizes = 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$acti2 = _action$payload2$acti.channelData) === null || _action$payload2$acti2 === void 0 ? void 0 : _action$payload2$acti2.attachmentSizes;
|
|
26
29
|
if (attachments) {
|
|
27
30
|
for (let i = 0; i < attachments.length; i++) {
|
|
31
|
+
const maxUploadFileSize = getMaxUploadFileSize(maxFileSizeSupportedByDynamics, attachments[i].contentType);
|
|
28
32
|
const fileExtensionValid = validateFileExtension(attachments[i], allowedFileExtensions);
|
|
29
33
|
const fileSizeValid = validateFileSize(attachmentSizes[i], maxUploadFileSize);
|
|
30
34
|
const fileIsEmpty = parseInt(attachmentSizes[i]) == 0;
|
|
31
35
|
if (!fileExtensionValid || !fileSizeValid || fileIsEmpty) {
|
|
32
|
-
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.AttachmentError, buildErrorMessage(attachments[i].name, fileExtensionValid, fileSizeValid, fileIsEmpty, maxUploadFileSize, localizedTexts));
|
|
36
|
+
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.AttachmentError, buildErrorMessage(attachments[i].name, fileExtensionValid, fileSizeValid, fileIsEmpty, maxUploadFileSize.toString(), maxFileSizeSupportedByDynamics, localizedTexts));
|
|
33
37
|
attachments.splice(i, 1);
|
|
34
38
|
attachmentSizes.splice(i, 1);
|
|
35
39
|
i--;
|
|
@@ -61,58 +65,118 @@ const validateFileExtension = (attachment, allowedFileExtensions) => {
|
|
|
61
65
|
return allExtensions.indexOf(fileExtension) > -1;
|
|
62
66
|
};
|
|
63
67
|
const validateFileSize = (attachmentSize, maxUploadFileSize) => {
|
|
64
|
-
return
|
|
68
|
+
return maxUploadFileSize * MBtoBRatio > parseInt(attachmentSize);
|
|
65
69
|
};
|
|
66
|
-
const
|
|
70
|
+
const getMaxUploadFileSize = (maxFileSizeSupportedByDynamicsStr, contentType) => {
|
|
71
|
+
const maxFileSizeSupportedByDynamics = maxFileSizeSupportedByDynamicsStr && parseInt(maxFileSizeSupportedByDynamicsStr) ? parseInt(maxFileSizeSupportedByDynamicsStr) : _Constants.AMSConstants.maxSupportedFileSize;
|
|
72
|
+
const amsAttachmentSizeLimit = isImage(contentType) ? _Constants.AMSConstants.maxSupportedImageSize : _Constants.AMSConstants.maxSupportedFileSize;
|
|
73
|
+
// Takes the smallest max file size configure betteween AMS and Dynamics Config
|
|
74
|
+
return maxFileSizeSupportedByDynamics < amsAttachmentSizeLimit ? maxFileSizeSupportedByDynamics : amsAttachmentSizeLimit;
|
|
75
|
+
};
|
|
76
|
+
const isImage = contentType => {
|
|
77
|
+
return _Constants.AMSConstants.supportedImagesMimeTypes.includes(contentType);
|
|
78
|
+
};
|
|
79
|
+
const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
67
80
|
let errorMessage = "";
|
|
68
81
|
if (!fileName || !maxUploadFileSize) {
|
|
82
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
83
|
+
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
84
|
+
Description: "Attachment validation failed",
|
|
85
|
+
ExceptionDetails: {
|
|
86
|
+
ErrorDetails: "File provided is null"
|
|
87
|
+
}
|
|
88
|
+
});
|
|
69
89
|
return localizedTexts.MIDDLEWARE_BANNER_FILE_NULL_ERROR ?? "";
|
|
70
90
|
}
|
|
71
91
|
if (!supportedFileExtension && !supportedFileSize) {
|
|
72
|
-
errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, localizedTexts);
|
|
92
|
+
errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
73
93
|
} else if (!supportedFileSize) {
|
|
74
|
-
errorMessage = getFileSizeErrorMessage(maxUploadFileSize, localizedTexts);
|
|
94
|
+
errorMessage = getFileSizeErrorMessage(maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
|
|
75
95
|
} else if (!supportedFileExtension) {
|
|
76
96
|
errorMessage = getFileExtensionErrorMessage(fileName, localizedTexts);
|
|
77
97
|
} else if (fileIsEmpty) {
|
|
98
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
99
|
+
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
100
|
+
Description: "Attachment validation failed",
|
|
101
|
+
ExceptionDetails: {
|
|
102
|
+
ErrorDetails: "File provided is empty"
|
|
103
|
+
}
|
|
104
|
+
});
|
|
78
105
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR ?? "";
|
|
79
106
|
} else {
|
|
107
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
108
|
+
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
109
|
+
Description: "Attachment validation failed",
|
|
110
|
+
ExceptionDetails: {
|
|
111
|
+
ErrorDetails: `Unexpected error: supportedFileExtension=${supportedFileExtension} supportedFileSize=${supportedFileSize} fileIsEmpty=${!fileIsEmpty}`
|
|
112
|
+
}
|
|
113
|
+
});
|
|
80
114
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_ERROR_MESSAGE ?? "";
|
|
81
115
|
}
|
|
82
116
|
return errorMessage;
|
|
83
117
|
};
|
|
84
|
-
const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, localizedTexts) => {
|
|
118
|
+
const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
85
119
|
const index = fileName.lastIndexOf(".");
|
|
86
|
-
let errorMessage;
|
|
120
|
+
let errorMessage, exceptionDetails;
|
|
87
121
|
if (index < 0) {
|
|
88
122
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR;
|
|
123
|
+
exceptionDetails = `File exceeded the allowed limit of ${maxUploadFileSize} MB and File provided without file extension`;
|
|
89
124
|
} else {
|
|
90
125
|
var _errorMessage;
|
|
91
126
|
const fileExtension = fileName.substring(index);
|
|
92
127
|
errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR;
|
|
128
|
+
exceptionDetails = `File exceeds the allowed limit of ${maxUploadFileSize} MB and ${fileExtension} files are not supported`;
|
|
93
129
|
if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{1}")) {
|
|
94
130
|
errorMessage = errorMessage.replace("{1}", fileExtension);
|
|
95
131
|
}
|
|
96
132
|
}
|
|
133
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
134
|
+
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
135
|
+
Description: "Attachment validation failed",
|
|
136
|
+
ExceptionDetails: {
|
|
137
|
+
ErrorDetails: `${exceptionDetails} Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${_Constants.AMSConstants.maxSupportedImageSize} AMS file size limit=${_Constants.AMSConstants.maxSupportedFileSize}`
|
|
138
|
+
}
|
|
139
|
+
});
|
|
97
140
|
return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
|
|
98
141
|
};
|
|
99
142
|
const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
|
|
100
143
|
const index = fileName.lastIndexOf(".");
|
|
101
144
|
if (index < 0) {
|
|
145
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
146
|
+
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
147
|
+
Description: "Attachment validation failed",
|
|
148
|
+
ExceptionDetails: {
|
|
149
|
+
ErrorDetails: "File provided without file extension"
|
|
150
|
+
}
|
|
151
|
+
});
|
|
102
152
|
return localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION ?? "";
|
|
103
153
|
} else {
|
|
104
154
|
const fileExtension = fileName.substring(index);
|
|
155
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
156
|
+
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
157
|
+
Description: "Attachment validation failed",
|
|
158
|
+
ExceptionDetails: {
|
|
159
|
+
ErrorDetails: `${fileExtension} files extension is not supported.`
|
|
160
|
+
}
|
|
161
|
+
});
|
|
105
162
|
const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
|
|
106
163
|
return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", fileExtension) : errorMessage : "";
|
|
107
164
|
}
|
|
108
165
|
};
|
|
109
|
-
const getFileSizeErrorMessage = (maxUploadFileSize, localizedTexts) => {
|
|
166
|
+
const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
|
|
167
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
168
|
+
Event: _TelemetryConstants.TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
|
|
169
|
+
Description: "Attachment validation failed",
|
|
170
|
+
ExceptionDetails: {
|
|
171
|
+
ErrorDetails: `File exceeds the allowed limit of ${maxUploadFileSize}MB. Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${_Constants.AMSConstants.maxSupportedImageSize} AMS file size limit=${_Constants.AMSConstants.maxSupportedFileSize}`
|
|
172
|
+
}
|
|
173
|
+
});
|
|
110
174
|
const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
|
|
111
175
|
return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
|
|
112
176
|
};
|
|
113
177
|
|
|
114
178
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
115
|
-
const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions,
|
|
179
|
+
const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts) => _ref => {
|
|
116
180
|
let {
|
|
117
181
|
dispatch
|
|
118
182
|
} = _ref;
|
|
@@ -123,7 +187,7 @@ const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxUpl
|
|
|
123
187
|
payload
|
|
124
188
|
} = action;
|
|
125
189
|
if (payload !== null && payload !== void 0 && (_payload$activity = payload.activity) !== null && _payload$activity !== void 0 && _payload$activity.attachments && payload !== null && payload !== void 0 && (_payload$activity2 = payload.activity) !== null && _payload$activity2 !== void 0 && (_payload$activity2$ch = _payload$activity2.channelData) !== null && _payload$activity2$ch !== void 0 && _payload$activity2$ch.attachmentSizes && (payload === null || payload === void 0 ? void 0 : (_payload$activity3 = payload.activity) === null || _payload$activity3 === void 0 ? void 0 : (_payload$activity3$at = _payload$activity3.attachments) === null || _payload$activity3$at === void 0 ? void 0 : _payload$activity3$at.length) === (payload === null || payload === void 0 ? void 0 : (_payload$activity4 = payload.activity) === null || _payload$activity4 === void 0 ? void 0 : (_payload$activity4$ch = _payload$activity4.channelData) === null || _payload$activity4$ch === void 0 ? void 0 : (_payload$activity4$ch2 = _payload$activity4$ch.attachmentSizes) === null || _payload$activity4$ch2 === void 0 ? void 0 : _payload$activity4$ch2.length)) {
|
|
126
|
-
return next(validateAttachment(action, allowedFileExtensions,
|
|
190
|
+
return next(validateAttachment(action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts));
|
|
127
191
|
}
|
|
128
192
|
}
|
|
129
193
|
return next(action);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ConversationEndEntity = void 0;
|
|
7
|
+
let ConversationEndEntity;
|
|
8
|
+
exports.ConversationEndEntity = ConversationEndEntity;
|
|
9
|
+
(function (ConversationEndEntity) {
|
|
10
|
+
ConversationEndEntity[ConversationEndEntity["Customer"] = 0] = "Customer";
|
|
11
|
+
ConversationEndEntity[ConversationEndEntity["Agent"] = 1] = "Agent";
|
|
12
|
+
})(ConversationEndEntity || (exports.ConversationEndEntity = ConversationEndEntity = {}));
|
|
@@ -36,11 +36,15 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
36
36
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_RECONNECT_ID"] = 26] = "SET_RECONNECT_ID";
|
|
37
37
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_UNREAD_MESSAGE_COUNT"] = 27] = "SET_UNREAD_MESSAGE_COUNT";
|
|
38
38
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_FOCUS_CHAT_BUTTON"] = 28] = "SET_FOCUS_CHAT_BUTTON";
|
|
39
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
40
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
41
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
42
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
43
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
44
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
45
|
-
LiveChatWidgetActionType[LiveChatWidgetActionType["
|
|
39
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED"] = 29] = "SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED";
|
|
40
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY"] = 30] = "SET_CONVERSATION_ENDED_BY";
|
|
41
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 31] = "SET_WIDGET_STATE";
|
|
42
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 32] = "SET_LIVE_CHAT_CONTEXT";
|
|
43
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 33] = "SET_BOT_OAUTH_SIGNIN_ID";
|
|
44
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 34] = "SET_WIDGET_SIZE";
|
|
45
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 35] = "SET_WIDGET_INSTANCE_ID";
|
|
46
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONFIG"] = 36] = "SET_LIVE_CHAT_CONFIG";
|
|
47
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_WORKFLOW_IN_PROGRESS"] = 37] = "SET_POST_CHAT_WORKFLOW_IN_PROGRESS";
|
|
48
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INITIAL_CHAT_SDK_REQUEST_ID"] = 38] = "SET_INITIAL_CHAT_SDK_REQUEST_ID";
|
|
49
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOULD_USE_BOT_SURVEY"] = 39] = "SET_SHOULD_USE_BOT_SURVEY";
|
|
46
50
|
})(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
|
|
@@ -8,10 +8,12 @@ var _ConversationState = require("./ConversationState");
|
|
|
8
8
|
var _defaultMiddlewareLocalizedTexts = require("../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
9
9
|
var _utils = require("../../common/utils");
|
|
10
10
|
var _defaultClientDataStoreProvider = require("../../common/storage/default/defaultClientDataStoreProvider");
|
|
11
|
+
var _Constants = require("../../common/Constants");
|
|
11
12
|
const getLiveChatWidgetContextInitialState = props => {
|
|
12
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$webChatContain;
|
|
13
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$controlProps2, _props$webChatContain;
|
|
13
14
|
const widgetCacheId = (0, _utils.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) ?? "");
|
|
14
|
-
const
|
|
15
|
+
const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.cacheTtlInMins) ?? _Constants.Constants.CacheTtlInMinutes;
|
|
16
|
+
const initialState = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)(cacheTtlInMins).getData(widgetCacheId, "localStorage");
|
|
15
17
|
if (!(0, _utils.isNullOrUndefined)(initialState)) {
|
|
16
18
|
return JSON.parse(initialState);
|
|
17
19
|
}
|
|
@@ -29,7 +31,8 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
29
31
|
liveChatContext: undefined,
|
|
30
32
|
customContext: undefined,
|
|
31
33
|
widgetSize: undefined,
|
|
32
|
-
widgetInstanceId: ""
|
|
34
|
+
widgetInstanceId: "",
|
|
35
|
+
initialChatSdkRequestId: ""
|
|
33
36
|
},
|
|
34
37
|
appStates: {
|
|
35
38
|
conversationState: _ConversationState.ConversationState.Closed,
|
|
@@ -49,7 +52,10 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
49
52
|
},
|
|
50
53
|
e2vvEnabled: false,
|
|
51
54
|
unreadMessageCount: 0,
|
|
52
|
-
|
|
55
|
+
conversationEndedByAgentEventReceived: false,
|
|
56
|
+
conversationEndedBy: undefined,
|
|
57
|
+
postChatWorkflowInProgress: false,
|
|
58
|
+
shouldUseBotSurvey: false
|
|
53
59
|
},
|
|
54
60
|
uiStates: {
|
|
55
61
|
showConfirmationPane: false,
|
|
@@ -264,12 +264,20 @@ const createReducer = () => {
|
|
|
264
264
|
return {
|
|
265
265
|
...action.payload
|
|
266
266
|
};
|
|
267
|
-
case _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
267
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED:
|
|
268
268
|
return {
|
|
269
269
|
...state,
|
|
270
270
|
appStates: {
|
|
271
271
|
...state.appStates,
|
|
272
|
-
|
|
272
|
+
conversationEndedByAgentEventReceived: action.payload
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY:
|
|
276
|
+
return {
|
|
277
|
+
...state,
|
|
278
|
+
appStates: {
|
|
279
|
+
...state.appStates,
|
|
280
|
+
conversationEndedBy: action.payload
|
|
273
281
|
}
|
|
274
282
|
};
|
|
275
283
|
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_SIZE:
|
|
@@ -299,6 +307,32 @@ const createReducer = () => {
|
|
|
299
307
|
liveChatConfig: action.payload
|
|
300
308
|
}
|
|
301
309
|
};
|
|
310
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS:
|
|
311
|
+
return {
|
|
312
|
+
...state,
|
|
313
|
+
appStates: {
|
|
314
|
+
...state.appStates,
|
|
315
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
316
|
+
postChatWorkflowInProgress: action.payload
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_INITIAL_CHAT_SDK_REQUEST_ID:
|
|
320
|
+
return {
|
|
321
|
+
...state,
|
|
322
|
+
domainStates: {
|
|
323
|
+
...state.domainStates,
|
|
324
|
+
initialChatSdkRequestId: action.payload
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_USE_BOT_SURVEY:
|
|
328
|
+
return {
|
|
329
|
+
...state,
|
|
330
|
+
appStates: {
|
|
331
|
+
...state.appStates,
|
|
332
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
333
|
+
shouldUseBotSurvey: action.payload
|
|
334
|
+
}
|
|
335
|
+
};
|
|
302
336
|
default:
|
|
303
337
|
return state;
|
|
304
338
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useDebounce;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
function useDebounce(func) {
|
|
9
|
+
let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
|
|
10
|
+
const timer = (0, _react.useRef)();
|
|
11
|
+
(0, _react.useEffect)(() => {
|
|
12
|
+
return () => {
|
|
13
|
+
if (!timer.current) return;
|
|
14
|
+
clearTimeout(timer.current);
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
const debouncedFunction = function () {
|
|
18
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
19
|
+
args[_key] = arguments[_key];
|
|
20
|
+
}
|
|
21
|
+
const newTimer = setTimeout(() => {
|
|
22
|
+
func(...args);
|
|
23
|
+
}, delay);
|
|
24
|
+
clearTimeout(timer.current);
|
|
25
|
+
timer.current = newTimer;
|
|
26
|
+
};
|
|
27
|
+
return debouncedFunction;
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useWindowDimensions;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _useDebounce = _interopRequireDefault(require("./useDebounce"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function getWindowDimensions() {
|
|
11
|
+
const {
|
|
12
|
+
innerWidth: width,
|
|
13
|
+
innerHeight: height
|
|
14
|
+
} = window;
|
|
15
|
+
return {
|
|
16
|
+
width,
|
|
17
|
+
height
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function useWindowDimensions() {
|
|
21
|
+
let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 200;
|
|
22
|
+
const [windowDimensions, setWindowDimensions] = (0, _react.useState)(getWindowDimensions());
|
|
23
|
+
const handleResize = () => setWindowDimensions(getWindowDimensions());
|
|
24
|
+
const debouncedHandleResize = (0, _useDebounce.default)(handleResize, delay);
|
|
25
|
+
(0, _react.useEffect)(() => {
|
|
26
|
+
window.addEventListener("resize", debouncedHandleResize);
|
|
27
|
+
return () => window.removeEventListener("resize", debouncedHandleResize);
|
|
28
|
+
}, []);
|
|
29
|
+
return windowDimensions;
|
|
30
|
+
}
|
|
@@ -15,6 +15,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
15
15
|
const isHistoryMessage = isActivityMessage && ((activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : (_activity$channelData2 = _activity$channelData.tags) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.includes(_Constants.Constants.historyMessageTag)) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 ? void 0 : _activity$channelData3.fromList));
|
|
16
16
|
raiseMessageEvent(activity, isHistoryMessage);
|
|
17
17
|
};
|
|
18
|
+
let isHistoryMessageReceivedEventRasied = false;
|
|
18
19
|
const raiseMessageEvent = (activity, isHistoryMessage) => {
|
|
19
20
|
if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants.Constants.message) {
|
|
20
21
|
var _text, _text2, _activity$channelData4, _activity$from;
|
|
@@ -45,6 +46,10 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
45
46
|
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.Constants.systemMessageTag)) {
|
|
46
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
48
|
payload.messageType = _Constants.Constants.systemMessageTag;
|
|
49
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
50
|
+
Event: _TelemetryConstants.TelemetryEvent.SystemMessageReceived,
|
|
51
|
+
Description: "System message received"
|
|
52
|
+
});
|
|
48
53
|
} else {
|
|
49
54
|
var _activity$channelData7, _activity$channelData8, _activity$channelData9;
|
|
50
55
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -69,6 +74,15 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
69
74
|
Description: "New message received",
|
|
70
75
|
Data: payload
|
|
71
76
|
});
|
|
77
|
+
} else {
|
|
78
|
+
if (!isHistoryMessageReceivedEventRasied) {
|
|
79
|
+
isHistoryMessageReceivedEventRasied = true;
|
|
80
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
81
|
+
Event: _TelemetryConstants.TelemetryEvent.HistoryMessageReceived,
|
|
82
|
+
Description: "History message received",
|
|
83
|
+
Data: payload
|
|
84
|
+
});
|
|
85
|
+
}
|
|
72
86
|
}
|
|
73
87
|
}
|
|
74
88
|
}
|
|
@@ -21,6 +21,8 @@ _defineProperty(Constants, "truePascal", "True");
|
|
|
21
21
|
_defineProperty(Constants, "true", "true");
|
|
22
22
|
_defineProperty(Constants, "false", "false");
|
|
23
23
|
_defineProperty(Constants, "maximumUnreadMessageCount", 99);
|
|
24
|
+
_defineProperty(Constants, "userParticipantTypeTag", "User");
|
|
25
|
+
_defineProperty(Constants, "botParticipantTypeTag", "Bot");
|
|
24
26
|
_defineProperty(Constants, "channelIdKey", "ChannelId-");
|
|
25
27
|
_defineProperty(Constants, "ChannelId", "lcw");
|
|
26
28
|
_defineProperty(Constants, "CustomerTag", "FromCustomer");
|
|
@@ -44,8 +46,8 @@ _defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
|
|
|
44
46
|
_defineProperty(Constants, "publicMessageTag", "public");
|
|
45
47
|
_defineProperty(Constants, "supportedAdaptiveCardContentTypes", ["application/vnd.microsoft.card.adaptive", "application/vnd.microsoft.card.audio", "application/vnd.microsoft.card.hero", "application/vnd.microsoft.card.receipt", "application/vnd.microsoft.card.thumbnail", "application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"]);
|
|
46
48
|
_defineProperty(Constants, "maxUploadFileSize", "500000");
|
|
47
|
-
_defineProperty(Constants, "imageRegex", /(\.)(jpeg|jpg|jiff|png|gif|bmp)$/i);
|
|
48
|
-
_defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|flac|mp2|mp3|pcm|wav|wma)$/i);
|
|
49
|
+
_defineProperty(Constants, "imageRegex", /(\.)(jpeg|jpg|jiff|png|gif|bmp|webp)$/i);
|
|
50
|
+
_defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|amr|flac|mp2|mp3|pcm|wav|wma)$/i);
|
|
49
51
|
_defineProperty(Constants, "videoMediaRegex", /(\.)(avchd|avi|flv|mpe|mpeg|mpg|mpv|mp4|m4p|m4v|mov|qt|swf|webm|wmv)$/i);
|
|
50
52
|
_defineProperty(Constants, "chromeSupportedInlineMediaRegex", /(\.)(aac|mp3|wav|mp4)$/i);
|
|
51
53
|
_defineProperty(Constants, "firefoxSupportedInlineMediaRegex", /(\.)(aac|flac|mp3|wav|mp4|mov)$/i);
|
|
@@ -82,6 +84,7 @@ _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect
|
|
|
82
84
|
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
83
85
|
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
84
86
|
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
87
|
+
_defineProperty(Constants, "CacheTtlInMinutes", 15);
|
|
85
88
|
export const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
86
89
|
export class HtmlIdNames {}
|
|
87
90
|
_defineProperty(HtmlIdNames, "MSLiveChatWidget", "MSLiveChatWidget");
|
|
@@ -122,11 +125,16 @@ _defineProperty(HtmlAttributeNames, "noreferrerTag", "noreferrer");
|
|
|
122
125
|
_defineProperty(HtmlAttributeNames, "adaptiveCardClassName", "ac-adaptiveCard");
|
|
123
126
|
_defineProperty(HtmlAttributeNames, "adaptiveCardTextBlockClassName", "ac-textBlock");
|
|
124
127
|
_defineProperty(HtmlAttributeNames, "adaptiveCardToggleInputClassName", "ac-toggleInput");
|
|
128
|
+
_defineProperty(HtmlAttributeNames, "adaptiveCardActionSetClassName", "ac-actionSet");
|
|
125
129
|
export class WebChatMiddlewareConstants {}
|
|
126
130
|
_defineProperty(WebChatMiddlewareConstants, "nextVisibleActivity", "nextVisibleActivity");
|
|
127
131
|
_defineProperty(WebChatMiddlewareConstants, "timeBetweenTimestampGroups", 300000);
|
|
128
132
|
_defineProperty(WebChatMiddlewareConstants, "maxTextLength", 6000);
|
|
129
133
|
_defineProperty(WebChatMiddlewareConstants, "adaptiveCard", "AdaptiveCard");
|
|
134
|
+
export class AMSConstants {}
|
|
135
|
+
_defineProperty(AMSConstants, "supportedImagesMimeTypes", ["image/jpeg", "image/png", "image/gif", "image/heic", "image/webp"]);
|
|
136
|
+
_defineProperty(AMSConstants, "maxSupportedImageSize", 20);
|
|
137
|
+
_defineProperty(AMSConstants, "maxSupportedFileSize", 300);
|
|
130
138
|
export class MimeTypes {}
|
|
131
139
|
_defineProperty(MimeTypes, "UnknownFileType", "application/octet-stream");
|
|
132
140
|
export class LocaleConstants {}
|
|
@@ -6,11 +6,11 @@ import { getWidgetCacheId } from "../../utils";
|
|
|
6
6
|
import { defaultClientDataStoreProvider } from "./defaultClientDataStoreProvider";
|
|
7
7
|
export class defaultCacheManager {}
|
|
8
8
|
_defineProperty(defaultCacheManager, "InternalCache", {});
|
|
9
|
-
export const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId) => {
|
|
9
|
+
export const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId, ttlInMins) => {
|
|
10
10
|
const widgetCacheId = getWidgetCacheId(orgid, widgetId, widgetInstanceId);
|
|
11
11
|
BroadcastService.getMessageByEventName(widgetCacheId).subscribe(msg => {
|
|
12
12
|
try {
|
|
13
|
-
defaultClientDataStoreProvider().setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
13
|
+
defaultClientDataStoreProvider(ttlInMins).setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
14
14
|
} catch (error) {
|
|
15
15
|
console.error("Error in setting data to localstorage", error);
|
|
16
16
|
}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
3
|
import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
|
|
4
|
-
|
|
4
|
+
import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
|
|
5
|
+
import { inMemoryDataStore } from "./defaultInMemoryDataStore";
|
|
6
|
+
export const defaultClientDataStoreProvider = function () {
|
|
7
|
+
let cacheTtlinMins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
8
|
+
let ttlInMs = 0;
|
|
5
9
|
const isCookieAllowed = () => {
|
|
6
10
|
try {
|
|
7
11
|
localStorage;
|
|
8
12
|
sessionStorage;
|
|
9
13
|
return true;
|
|
10
14
|
} catch (error) {
|
|
11
|
-
|
|
15
|
+
if (!window.TPCWarningShown) {
|
|
16
|
+
console.warn("Third party cookies blocked.");
|
|
17
|
+
window.TPCWarningShown = true;
|
|
18
|
+
}
|
|
12
19
|
return false;
|
|
13
20
|
}
|
|
14
21
|
};
|
|
15
|
-
|
|
22
|
+
if (ttlInMs == 0) {
|
|
23
|
+
ttlInMs = cacheTtlinMins * 60 * 1000;
|
|
24
|
+
}
|
|
16
25
|
const dataStoreProvider = {
|
|
17
26
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
27
|
setData: (key, data, type) => {
|
|
@@ -22,7 +31,7 @@ export const defaultClientDataStoreProvider = () => {
|
|
|
22
31
|
const now = new Date();
|
|
23
32
|
const item = {
|
|
24
33
|
data: data,
|
|
25
|
-
expiry: now.getTime() +
|
|
34
|
+
expiry: now.getTime() + ttlInMs
|
|
26
35
|
};
|
|
27
36
|
const strItem = JSON.stringify(item);
|
|
28
37
|
if (type === "localStorage") {
|
|
@@ -49,6 +49,12 @@ export let BroadcastEvent;
|
|
|
49
49
|
BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
|
|
50
50
|
BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
|
|
51
51
|
BroadcastEvent["RaiseErrorEvent"] = "RaiseErrorEvent";
|
|
52
|
+
BroadcastEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
53
|
+
BroadcastEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
54
|
+
BroadcastEvent["SigninCardReceived"] = "SignInCardReceived";
|
|
55
|
+
BroadcastEvent["BotAuthConfigRequest"] = "BotAuthConfigRequest";
|
|
56
|
+
BroadcastEvent["BotAuthConfigResponse"] = "BotAuthConfigResponse";
|
|
57
|
+
BroadcastEvent["HideChatVisibilityChangeEvent"] = "hideChatVisibilityChangeEvent";
|
|
52
58
|
})(BroadcastEvent || (BroadcastEvent = {}));
|
|
53
59
|
export let TelemetryEvent;
|
|
54
60
|
(function (TelemetryEvent) {
|
|
@@ -84,11 +90,10 @@ export let TelemetryEvent;
|
|
|
84
90
|
TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
|
|
85
91
|
TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
|
|
86
92
|
TelemetryEvent["GetChatReconnectContextSDKCallFailed"] = "GetChatReconnectContextSDKCallFailed";
|
|
87
|
-
TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
|
|
88
|
-
TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
|
|
89
93
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
90
94
|
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
91
95
|
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
96
|
+
TelemetryEvent["ChatVisibilityChanged"] = "ChatVisibilityChanged";
|
|
92
97
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
93
98
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
94
99
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -96,6 +101,7 @@ export let TelemetryEvent;
|
|
|
96
101
|
TelemetryEvent["WidgetLoadComplete"] = "WidgetLoadComplete";
|
|
97
102
|
TelemetryEvent["WidgetLoadFailed"] = "WidgetLoadFailed";
|
|
98
103
|
TelemetryEvent["StartChatMethodException"] = "StartChatMethodException";
|
|
104
|
+
TelemetryEvent["CloseChatCall"] = "CloseChatCall";
|
|
99
105
|
TelemetryEvent["CloseChatMethodException"] = "CloseChatMethodException";
|
|
100
106
|
TelemetryEvent["PrechatSurveyLoaded"] = "PrechatSurveyLoaded";
|
|
101
107
|
TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
|
|
@@ -109,6 +115,7 @@ export let TelemetryEvent;
|
|
|
109
115
|
TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
|
|
110
116
|
TelemetryEvent["EmailTranscriptSent"] = "EmailTranscriptSent";
|
|
111
117
|
TelemetryEvent["EmailTranscriptFailed"] = "EmailTranscriptFailed";
|
|
118
|
+
TelemetryEvent["ErrorUIPaneLoaded"] = "ErrorUIPaneLoaded";
|
|
112
119
|
TelemetryEvent["DownloadTranscriptFailed"] = "DownloadTranscriptFailed";
|
|
113
120
|
TelemetryEvent["StartChatFailed"] = "StartChatFailed";
|
|
114
121
|
TelemetryEvent["IC3ThreadUpdateEventReceived"] = "IC3ThreadUpdateEventReceived";
|
|
@@ -117,8 +124,6 @@ export let TelemetryEvent;
|
|
|
117
124
|
TelemetryEvent["LoadingPaneLoaded"] = "LoadingPaneLoaded";
|
|
118
125
|
TelemetryEvent["EmailTranscriptLoaded"] = "EmailTranscriptLoaded";
|
|
119
126
|
TelemetryEvent["OutOfOfficePaneLoaded"] = "OutOfOfficePaneLoaded";
|
|
120
|
-
TelemetryEvent["PostChatSurveyLoadingPaneLoaded"] = "PostChatSurveyLoadingPaneLoaded";
|
|
121
|
-
TelemetryEvent["PostChatSurveyLoaded"] = "PostChatSurveyLoaded";
|
|
122
127
|
TelemetryEvent["ConfirmationPaneLoaded"] = "ConfirmationPaneLoaded";
|
|
123
128
|
TelemetryEvent["ProactiveChatPaneLoaded"] = "ProactiveChatPaneLoaded";
|
|
124
129
|
TelemetryEvent["ReconnectChatPaneLoaded"] = "ReconnectChatPaneLoaded";
|
|
@@ -131,6 +136,7 @@ export let TelemetryEvent;
|
|
|
131
136
|
TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
|
|
132
137
|
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
133
138
|
TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
|
|
139
|
+
TelemetryEvent["AppStatesException"] = "AppStatesException";
|
|
134
140
|
TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
|
|
135
141
|
TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
|
|
136
142
|
TelemetryEvent["GetAuthTokenFailed"] = "GetAuthTokenFailed";
|
|
@@ -138,15 +144,23 @@ export let TelemetryEvent;
|
|
|
138
144
|
TelemetryEvent["CustomerVoiceResponsePageLoaded"] = "CustomerVoiceResponsePageLoaded";
|
|
139
145
|
TelemetryEvent["CustomerVoiceFormResponseSubmitted"] = "CustomerVoiceFormResponseSubmitted";
|
|
140
146
|
TelemetryEvent["CustomerVoiceFormResponseError"] = "CustomerVoiceFormResponseError";
|
|
147
|
+
TelemetryEvent["BotAuthActivityEmptySasUrl"] = "BotAuthActivityEmptySasUrl";
|
|
148
|
+
TelemetryEvent["SetBotAuthProviderFetchConfig"] = "SetBotAuthProviderFetchConfig";
|
|
149
|
+
TelemetryEvent["SetBotAuthProviderHideCard"] = "SetBotAuthProviderHideCard";
|
|
150
|
+
TelemetryEvent["SetBotAuthProviderDisplayCard"] = "SetBotAuthProviderDisplayCard";
|
|
151
|
+
TelemetryEvent["SetBotAuthProviderNotFound"] = "SetBotAuthProviderNotFound";
|
|
141
152
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
142
153
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
143
154
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
155
|
+
TelemetryEvent["AttachmentUploadValidatorMiddlewareFailed"] = "AttachmentUploadValidatorMiddlewareFailed";
|
|
144
156
|
TelemetryEvent["QueuePositionMessageRecieved"] = "QueuePositionMessageRecieved";
|
|
145
157
|
TelemetryEvent["AverageWaitTimeMessageRecieved"] = "AverageWaitTimeMessageRecieved";
|
|
146
158
|
TelemetryEvent["DataMaskingRuleApplied"] = "DataMaskingRuleApplied";
|
|
147
159
|
TelemetryEvent["DataMaskingRuleApplyFailed"] = "DataMaskingRuleApplyFailed";
|
|
148
160
|
TelemetryEvent["IC3ClientEvent"] = "IC3ClientEvent";
|
|
149
161
|
TelemetryEvent["ConversationEndedThreadEventReceived"] = "ConversationEndedThreadEventReceived";
|
|
162
|
+
TelemetryEvent["ConversationEndedByCustomer"] = "ConversationEndedByCustomer";
|
|
163
|
+
TelemetryEvent["ConversationEndedByAgent"] = "ConversationEndedByAgent";
|
|
150
164
|
TelemetryEvent["InvalidConfiguration"] = "InvalidConfiguration";
|
|
151
165
|
TelemetryEvent["SendTypingIndicatorSucceeded"] = "SendTypingIndicatorSucceeded";
|
|
152
166
|
TelemetryEvent["SendTypingIndicatorFailed"] = "SendTypingIndicatorFailed";
|
|
@@ -164,9 +178,20 @@ export let TelemetryEvent;
|
|
|
164
178
|
TelemetryEvent["ReconnectChatMinimize"] = "ReconnectChatMinimize";
|
|
165
179
|
TelemetryEvent["MessageSent"] = "MessageSent";
|
|
166
180
|
TelemetryEvent["MessageReceived"] = "MessageReceived";
|
|
181
|
+
TelemetryEvent["SystemMessageReceived"] = "SystemMessageReceived";
|
|
182
|
+
TelemetryEvent["HistoryMessageReceived"] = "HistoryMessageReceived";
|
|
167
183
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
168
184
|
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
169
185
|
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
186
|
+
TelemetryEvent["LinkModePostChatWorkflowStarted"] = "LinkModePostChatWorkflowStarted";
|
|
187
|
+
TelemetryEvent["EmbedModePostChatWorkflowStarted"] = "EmbedModePostChatWorkflowStarted";
|
|
188
|
+
TelemetryEvent["PostChatWorkflowFromCustomer"] = "PostChatWorkflowFromCustomer";
|
|
189
|
+
TelemetryEvent["PostChatWorkflowFromAgent"] = "PostChatWorkflowFromAgent";
|
|
190
|
+
TelemetryEvent["PostChatWorkflowFromBot"] = "PostChatWorkflowFromBot";
|
|
191
|
+
TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
|
|
192
|
+
TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
|
|
193
|
+
TelemetryEvent["PostChatSurveyLoadingPaneLoaded"] = "PostChatSurveyLoadingPaneLoaded";
|
|
194
|
+
TelemetryEvent["PostChatSurveyLoaded"] = "PostChatSurveyLoaded";
|
|
170
195
|
})(TelemetryEvent || (TelemetryEvent = {}));
|
|
171
196
|
export class TelemetryConstants {
|
|
172
197
|
static map(eventTypeOrScenarioType) {
|
|
@@ -221,6 +246,12 @@ export class TelemetryConstants {
|
|
|
221
246
|
case TelemetryEvent.CustomerVoiceResponsePageLoaded:
|
|
222
247
|
case TelemetryEvent.CustomerVoiceFormResponseSubmitted:
|
|
223
248
|
case TelemetryEvent.CustomerVoiceFormResponseError:
|
|
249
|
+
case TelemetryEvent.LinkModePostChatWorkflowStarted:
|
|
250
|
+
case TelemetryEvent.EmbedModePostChatWorkflowStarted:
|
|
251
|
+
case TelemetryEvent.PostChatWorkflowFromCustomer:
|
|
252
|
+
case TelemetryEvent.PostChatWorkflowFromAgent:
|
|
253
|
+
case TelemetryEvent.PostChatWorkflowFromBot:
|
|
254
|
+
case TelemetryEvent.AppStatesException:
|
|
224
255
|
return ScenarioType.ACTIONS;
|
|
225
256
|
case TelemetryEvent.StartChatSDKCall:
|
|
226
257
|
case TelemetryEvent.StartChatEventRecevied:
|