@microsoft/omnichannel-chat-widget 0.1.0-main.50fdaaa → 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.
Files changed (51) hide show
  1. package/lib/cjs/common/Constants.js +8 -1
  2. package/lib/cjs/common/telemetry/TelemetryConstants.js +22 -4
  3. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +11 -18
  4. package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -3
  5. package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
  6. package/lib/cjs/components/livechatwidget/common/endChat.js +38 -64
  7. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +10 -61
  8. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +6 -2
  9. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -2
  10. package/lib/cjs/components/livechatwidget/common/startChat.js +14 -6
  11. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +65 -25
  12. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  13. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
  14. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +1 -0
  15. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
  16. package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
  17. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +11 -7
  18. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +6 -2
  19. package/lib/cjs/contexts/createReducer.js +36 -2
  20. package/lib/esm/common/Constants.js +6 -0
  21. package/lib/esm/common/telemetry/TelemetryConstants.js +22 -4
  22. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +11 -18
  23. package/lib/esm/components/headerstateful/HeaderStateful.js +4 -3
  24. package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
  25. package/lib/esm/components/livechatwidget/common/endChat.js +40 -66
  26. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +12 -63
  27. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +6 -2
  28. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -3
  29. package/lib/esm/components/livechatwidget/common/startChat.js +14 -6
  30. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +65 -25
  31. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  32. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
  33. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +2 -0
  34. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
  35. package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
  36. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +11 -7
  37. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +6 -2
  38. package/lib/esm/contexts/createReducer.js +36 -2
  39. package/lib/types/common/Constants.d.ts +7 -0
  40. package/lib/types/common/telemetry/TelemetryConstants.d.ts +18 -6
  41. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
  42. package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
  43. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
  44. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
  45. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
  46. package/lib/types/components/livechatwidget/common/startChat.d.ts +1 -1
  47. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +1 -1
  48. package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
  49. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -1
  50. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +11 -7
  51. package/package.json +1 -1
@@ -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, maxUploadFileSize, localizedTexts) => {
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 (maxUploadFileSize && parseInt(maxUploadFileSize) * MBtoBRatio) > parseInt(attachmentSize);
68
+ return maxUploadFileSize * MBtoBRatio > parseInt(attachmentSize);
65
69
  };
66
- const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, localizedTexts) => {
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, maxUploadFileSize, localizedTexts) => _ref => {
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, maxUploadFileSize, localizedTexts));
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["SET_CONVERSATION_ENDED_BY_AGENT"] = 29] = "SET_CONVERSATION_ENDED_BY_AGENT";
40
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 30] = "SET_WIDGET_STATE";
41
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 31] = "SET_LIVE_CHAT_CONTEXT";
42
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 32] = "SET_BOT_OAUTH_SIGNIN_ID";
43
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 33] = "SET_WIDGET_SIZE";
44
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 34] = "SET_WIDGET_INSTANCE_ID";
45
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONFIG"] = 35] = "SET_LIVE_CHAT_CONFIG";
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 = {}));
@@ -31,7 +31,8 @@ const getLiveChatWidgetContextInitialState = props => {
31
31
  liveChatContext: undefined,
32
32
  customContext: undefined,
33
33
  widgetSize: undefined,
34
- widgetInstanceId: ""
34
+ widgetInstanceId: "",
35
+ initialChatSdkRequestId: ""
35
36
  },
36
37
  appStates: {
37
38
  conversationState: _ConversationState.ConversationState.Closed,
@@ -51,7 +52,10 @@ const getLiveChatWidgetContextInitialState = props => {
51
52
  },
52
53
  e2vvEnabled: false,
53
54
  unreadMessageCount: 0,
54
- conversationEndedByAgent: false
55
+ conversationEndedByAgentEventReceived: false,
56
+ conversationEndedBy: undefined,
57
+ postChatWorkflowInProgress: false,
58
+ shouldUseBotSurvey: false
55
59
  },
56
60
  uiStates: {
57
61
  showConfirmationPane: false,
@@ -264,12 +264,20 @@ const createReducer = () => {
264
264
  return {
265
265
  ...action.payload
266
266
  };
267
- case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT:
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
- conversationEndedByAgent: action.payload
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
  }
@@ -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");
@@ -129,6 +131,10 @@ _defineProperty(WebChatMiddlewareConstants, "nextVisibleActivity", "nextVisibleA
129
131
  _defineProperty(WebChatMiddlewareConstants, "timeBetweenTimestampGroups", 300000);
130
132
  _defineProperty(WebChatMiddlewareConstants, "maxTextLength", 6000);
131
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);
132
138
  export class MimeTypes {}
133
139
  _defineProperty(MimeTypes, "UnknownFileType", "application/octet-stream");
134
140
  export class LocaleConstants {}
@@ -54,6 +54,7 @@ export let BroadcastEvent;
54
54
  BroadcastEvent["SigninCardReceived"] = "SignInCardReceived";
55
55
  BroadcastEvent["BotAuthConfigRequest"] = "BotAuthConfigRequest";
56
56
  BroadcastEvent["BotAuthConfigResponse"] = "BotAuthConfigResponse";
57
+ BroadcastEvent["HideChatVisibilityChangeEvent"] = "hideChatVisibilityChangeEvent";
57
58
  })(BroadcastEvent || (BroadcastEvent = {}));
58
59
  export let TelemetryEvent;
59
60
  (function (TelemetryEvent) {
@@ -89,11 +90,10 @@ export let TelemetryEvent;
89
90
  TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
90
91
  TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
91
92
  TelemetryEvent["GetChatReconnectContextSDKCallFailed"] = "GetChatReconnectContextSDKCallFailed";
92
- TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
93
- TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
94
93
  TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
95
94
  TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
96
95
  TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
96
+ TelemetryEvent["ChatVisibilityChanged"] = "ChatVisibilityChanged";
97
97
  TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
98
98
  TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
99
99
  TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
@@ -101,6 +101,7 @@ export let TelemetryEvent;
101
101
  TelemetryEvent["WidgetLoadComplete"] = "WidgetLoadComplete";
102
102
  TelemetryEvent["WidgetLoadFailed"] = "WidgetLoadFailed";
103
103
  TelemetryEvent["StartChatMethodException"] = "StartChatMethodException";
104
+ TelemetryEvent["CloseChatCall"] = "CloseChatCall";
104
105
  TelemetryEvent["CloseChatMethodException"] = "CloseChatMethodException";
105
106
  TelemetryEvent["PrechatSurveyLoaded"] = "PrechatSurveyLoaded";
106
107
  TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
@@ -123,8 +124,6 @@ export let TelemetryEvent;
123
124
  TelemetryEvent["LoadingPaneLoaded"] = "LoadingPaneLoaded";
124
125
  TelemetryEvent["EmailTranscriptLoaded"] = "EmailTranscriptLoaded";
125
126
  TelemetryEvent["OutOfOfficePaneLoaded"] = "OutOfOfficePaneLoaded";
126
- TelemetryEvent["PostChatSurveyLoadingPaneLoaded"] = "PostChatSurveyLoadingPaneLoaded";
127
- TelemetryEvent["PostChatSurveyLoaded"] = "PostChatSurveyLoaded";
128
127
  TelemetryEvent["ConfirmationPaneLoaded"] = "ConfirmationPaneLoaded";
129
128
  TelemetryEvent["ProactiveChatPaneLoaded"] = "ProactiveChatPaneLoaded";
130
129
  TelemetryEvent["ReconnectChatPaneLoaded"] = "ReconnectChatPaneLoaded";
@@ -137,6 +136,7 @@ export let TelemetryEvent;
137
136
  TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
138
137
  TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
139
138
  TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
139
+ TelemetryEvent["AppStatesException"] = "AppStatesException";
140
140
  TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
141
141
  TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
142
142
  TelemetryEvent["GetAuthTokenFailed"] = "GetAuthTokenFailed";
@@ -152,12 +152,15 @@ export let TelemetryEvent;
152
152
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
153
153
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
154
154
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
155
+ TelemetryEvent["AttachmentUploadValidatorMiddlewareFailed"] = "AttachmentUploadValidatorMiddlewareFailed";
155
156
  TelemetryEvent["QueuePositionMessageRecieved"] = "QueuePositionMessageRecieved";
156
157
  TelemetryEvent["AverageWaitTimeMessageRecieved"] = "AverageWaitTimeMessageRecieved";
157
158
  TelemetryEvent["DataMaskingRuleApplied"] = "DataMaskingRuleApplied";
158
159
  TelemetryEvent["DataMaskingRuleApplyFailed"] = "DataMaskingRuleApplyFailed";
159
160
  TelemetryEvent["IC3ClientEvent"] = "IC3ClientEvent";
160
161
  TelemetryEvent["ConversationEndedThreadEventReceived"] = "ConversationEndedThreadEventReceived";
162
+ TelemetryEvent["ConversationEndedByCustomer"] = "ConversationEndedByCustomer";
163
+ TelemetryEvent["ConversationEndedByAgent"] = "ConversationEndedByAgent";
161
164
  TelemetryEvent["InvalidConfiguration"] = "InvalidConfiguration";
162
165
  TelemetryEvent["SendTypingIndicatorSucceeded"] = "SendTypingIndicatorSucceeded";
163
166
  TelemetryEvent["SendTypingIndicatorFailed"] = "SendTypingIndicatorFailed";
@@ -180,6 +183,15 @@ export let TelemetryEvent;
180
183
  TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
181
184
  TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
182
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";
183
195
  })(TelemetryEvent || (TelemetryEvent = {}));
184
196
  export class TelemetryConstants {
185
197
  static map(eventTypeOrScenarioType) {
@@ -234,6 +246,12 @@ export class TelemetryConstants {
234
246
  case TelemetryEvent.CustomerVoiceResponsePageLoaded:
235
247
  case TelemetryEvent.CustomerVoiceFormResponseSubmitted:
236
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:
237
255
  return ScenarioType.ACTIONS;
238
256
  case TelemetryEvent.StartChatSDKCall:
239
257
  case TelemetryEvent.StartChatEventRecevied:
@@ -4,21 +4,17 @@ import React, { useEffect } from "react";
4
4
  import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
5
5
  import { DimLayer } from "../dimlayer/DimLayer";
6
6
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
7
- import { NotificationHandler } from "../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
8
- import { NotificationScenarios } from "../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
9
7
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
10
8
  import useChatAdapterStore from "../../hooks/useChatAdapterStore";
11
9
  import useChatContextStore from "../../hooks/useChatContextStore";
10
+ import { ConversationEndEntity } from "../../contexts/common/ConversationEndEntity";
12
11
 
13
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
13
  export const ConfirmationPaneStateful = props => {
15
14
  const initialTabIndexMap = new Map();
16
15
  let elements = [];
17
16
  const [state, dispatch] = useChatContextStore();
18
- const {
19
- prepareEndChat
20
- } = props;
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
22
18
  const [adapter] = useChatAdapterStore();
23
19
  const controlProps = {
24
20
  id: "oc-lcw-confirmation-pane",
@@ -32,18 +28,15 @@ export const ConfirmationPaneStateful = props => {
32
28
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
33
29
  payload: false
34
30
  });
35
- try {
36
- setTabIndices(elements, initialTabIndexMap, true);
37
- await prepareEndChat(adapter, state);
38
- } catch (ex) {
39
- TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
40
- Event: TelemetryEvent.GetConversationDetailsCallFailed,
41
- ExceptionDetails: {
42
- exception: `Get Conversation Details Call Failed : ${ex}`
43
- }
44
- });
45
- NotificationHandler.notifyError(NotificationScenarios.Connection, "Get Conversation Details Call Failed: " + ex);
46
- }
31
+ setTabIndices(elements, initialTabIndexMap, true);
32
+ dispatch({
33
+ type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
34
+ payload: ConversationEndEntity.Customer
35
+ });
36
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
37
+ Event: TelemetryEvent.ConversationEndedByCustomer,
38
+ Description: "Conversation is ended by customer."
39
+ });
47
40
  },
48
41
  onCancel: () => {
49
42
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
@@ -7,6 +7,7 @@ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
7
7
  import { defaultOutOfOfficeHeaderStyleProps } from "./common/styleProps/defaultOutOfOfficeHeaderStyleProps";
8
8
  import useChatAdapterStore from "../../hooks/useChatAdapterStore";
9
9
  import useChatContextStore from "../../hooks/useChatContextStore";
10
+ import { ConversationEndEntity } from "../../contexts/common/ConversationEndEntity";
10
11
  export const HeaderStateful = props => {
11
12
  var _state$domainStates$l, _state$domainStates$l2, _headerProps$controlP, _headerProps$controlP2, _headerProps$controlP3, _outOfOfficeHeaderPro;
12
13
  const [state, dispatch] = useChatContextStore();
@@ -21,7 +22,7 @@ export const HeaderStateful = props => {
21
22
  const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True");
22
23
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
23
24
  const conversationState = useRef(state.appStates.conversationState);
24
- const conversationEndedByAgent = useRef(state.appStates.conversationEndedByAgent);
25
+ const conversationEndedBy = useRef(state.appStates.conversationEndedBy);
25
26
  const controlProps = {
26
27
  id: "oc-lcw-header",
27
28
  dir: state.domainStates.globalDir,
@@ -41,7 +42,7 @@ export const HeaderStateful = props => {
41
42
  Event: TelemetryEvent.HeaderCloseButtonClicked,
42
43
  Description: "Header Close button clicked."
43
44
  });
44
- if (conversationState.current === ConversationState.Active || conversationEndedByAgent.current) {
45
+ if (conversationState.current === ConversationState.Active || conversationEndedBy.current === ConversationEndEntity.Agent) {
45
46
  dispatch({
46
47
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
47
48
  payload: true
@@ -87,7 +88,7 @@ export const HeaderStateful = props => {
87
88
  if (state.appStates.conversationState) {
88
89
  conversationState.current = state.appStates.conversationState;
89
90
  }
90
- conversationEndedByAgent.current = state.appStates.conversationEndedByAgent;
91
+ conversationEndedBy.current = state.appStates.conversationEndedBy;
91
92
  }, [state.appStates]);
92
93
  return /*#__PURE__*/React.createElement(Header, {
93
94
  componentOverrides: headerProps === null || headerProps === void 0 ? void 0 : headerProps.componentOverrides,
@@ -0,0 +1,30 @@
1
+ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
3
+ import { ConversationEndEntity } from "../../../contexts/common/ConversationEndEntity";
4
+ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
+ import { checkPostChatEnabled } from "./setPostChatContextAndLoadSurvey";
6
+ const handleAgentEndConversation = (props, state, dispatch) => {
7
+ const isPostChatEnabled = checkPostChatEnabled(props, state);
8
+ if (isPostChatEnabled) {
9
+ if (!state.appStates.postChatWorkflowInProgress) {
10
+ dispatch({
11
+ type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
12
+ payload: ConversationEndEntity.Agent
13
+ });
14
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
15
+ Event: TelemetryEvent.ConversationEndedByAgent,
16
+ Description: "Conversation is ended from agent side"
17
+ });
18
+ }
19
+ } else {
20
+ dispatch({
21
+ type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
22
+ payload: ConversationEndEntity.Agent
23
+ });
24
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
25
+ Event: TelemetryEvent.ConversationEndedByAgent,
26
+ Description: "Conversation is ended from agent side"
27
+ });
28
+ }
29
+ };
30
+ export { handleAgentEndConversation };