@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.
Files changed (105) hide show
  1. package/README.md +7 -34
  2. package/lib/cjs/common/Constants.js +12 -3
  3. package/lib/cjs/common/storage/default/defaultCacheManager.js +2 -2
  4. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  5. package/lib/cjs/common/telemetry/TelemetryConstants.js +35 -4
  6. package/lib/cjs/common/telemetry/TelemetryHelper.js +2 -1
  7. package/lib/cjs/common/utils.js +23 -2
  8. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
  9. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  10. package/lib/cjs/components/headerstateful/HeaderStateful.js +5 -2
  11. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
  12. package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
  13. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  14. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
  15. package/lib/cjs/components/livechatwidget/common/endChat.js +43 -63
  16. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +11 -49
  17. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -7
  18. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -2
  19. package/lib/cjs/components/livechatwidget/common/startChat.js +83 -64
  20. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +91 -45
  21. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
  22. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  23. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  24. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  25. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
  26. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
  27. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  28. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  29. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  30. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  31. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  33. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +7 -3
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
  35. package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
  36. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +11 -7
  37. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +10 -4
  38. package/lib/cjs/contexts/createReducer.js +36 -2
  39. package/lib/cjs/hooks/useDebounce.js +28 -0
  40. package/lib/cjs/hooks/useWindowDimensions.js +30 -0
  41. package/lib/cjs/plugins/newMessageEventHandler.js +14 -0
  42. package/lib/esm/common/Constants.js +10 -2
  43. package/lib/esm/common/storage/default/defaultCacheManager.js +2 -2
  44. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  45. package/lib/esm/common/telemetry/TelemetryConstants.js +35 -4
  46. package/lib/esm/common/telemetry/TelemetryHelper.js +2 -1
  47. package/lib/esm/common/utils.js +20 -0
  48. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
  49. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  50. package/lib/esm/components/headerstateful/HeaderStateful.js +5 -2
  51. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
  52. package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
  53. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  54. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
  55. package/lib/esm/components/livechatwidget/common/endChat.js +45 -65
  56. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -51
  57. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +12 -7
  58. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -3
  59. package/lib/esm/components/livechatwidget/common/startChat.js +83 -64
  60. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +92 -46
  61. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
  62. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  63. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  64. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  65. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
  66. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
  67. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  68. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  69. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  70. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  71. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  72. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  73. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +5 -3
  74. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
  75. package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
  76. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +11 -7
  77. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +10 -4
  78. package/lib/esm/contexts/createReducer.js +36 -2
  79. package/lib/esm/hooks/useDebounce.js +22 -0
  80. package/lib/esm/hooks/useWindowDimensions.js +23 -0
  81. package/lib/esm/plugins/newMessageEventHandler.js +14 -0
  82. package/lib/types/common/Constants.d.ts +9 -0
  83. package/lib/types/common/storage/default/defaultCacheManager.d.ts +1 -1
  84. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -1
  85. package/lib/types/common/telemetry/TelemetryConstants.d.ts +31 -6
  86. package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -0
  87. package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
  88. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
  89. package/lib/types/common/utils.d.ts +1 -0
  90. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
  91. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
  92. package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
  93. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
  94. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
  95. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
  96. package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
  97. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
  98. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
  99. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +1 -1
  100. package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
  101. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -1
  102. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +11 -7
  103. package/lib/types/hooks/useDebounce.d.ts +3 -0
  104. package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
  105. package/package.json +3 -3
@@ -5,6 +5,7 @@ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
5
5
  import { defaultGeneralLoadingPaneStyleProps } from "./common/defaultStyleProps/defaultgeneralLoadingPaneStyleProps";
6
6
  import { findAllFocusableElement } from "../../common/utils";
7
7
  import useChatContextStore from "../../hooks/useChatContextStore";
8
+ import useWindowDimensions from "../../hooks/useWindowDimensions";
8
9
  import { errorUILoadingPaneStyleProps } from "./common/errorUIStyleProps/errorUILoadingPaneStyleProps";
9
10
  export const LoadingPaneStateful = props => {
10
11
  var _props$styleProps;
@@ -31,6 +32,10 @@ export const LoadingPaneStateful = props => {
31
32
  hideSpinnerText: true,
32
33
  ...props.controlProps
33
34
  };
35
+ const {
36
+ height,
37
+ width
38
+ } = useWindowDimensions();
34
39
 
35
40
  // Move focus to the first button
36
41
  useEffect(() => {
@@ -46,7 +51,9 @@ export const LoadingPaneStateful = props => {
46
51
  return /*#__PURE__*/React.createElement(LoadingPane, {
47
52
  componentOverrides: props.componentOverrides,
48
53
  controlProps: state.appStates.isStartChatFailing ? errorUIControlProps : controlProps,
49
- styleProps: state.appStates.isStartChatFailing ? errorUIStyleProps : styleProps
54
+ styleProps: state.appStates.isStartChatFailing ? errorUIStyleProps : styleProps,
55
+ windowWidth: width,
56
+ windowHeight: height
50
57
  });
51
58
  };
52
59
  export default LoadingPaneStateful;
@@ -15,7 +15,9 @@ export const PostChatSurveyPaneStateful = props => {
15
15
  display: state.appStates.isMinimized ? "none" : ""
16
16
  });
17
17
  let surveyInviteLink = "";
18
- if (state.domainStates.postChatContext.surveyInviteLink) {
18
+ if (state.appStates.shouldUseBotSurvey && state.domainStates.postChatContext.botSurveyInviteLink) {
19
+ surveyInviteLink = state.domainStates.postChatContext.botSurveyInviteLink + "&embed=" + (postChatSurveyMode === PostChatSurveyMode.Embed).toString() + "&compact=" + (props.isCustomerVoiceSurveyCompact ?? true).toString() + "&lang=" + (state.domainStates.postChatContext.formsProLocale ?? "en") + "&showmultilingual=false";
20
+ } else {
19
21
  surveyInviteLink = state.domainStates.postChatContext.surveyInviteLink + "&embed=" + (postChatSurveyMode === PostChatSurveyMode.Embed).toString() + "&compact=" + (props.isCustomerVoiceSurveyCompact ?? true).toString() + "&lang=" + (state.domainStates.postChatContext.formsProLocale ?? "en") + "&showmultilingual=false";
20
22
  }
21
23
  const styleProps = {
@@ -112,7 +112,7 @@ export const PreChatSurveyPaneStateful = props => {
112
112
  }
113
113
  if (current && current.tagName.toLowerCase() == HtmlAttributeNames.div && current.childElementCount > 0) {
114
114
  const input = current.children[0].children;
115
- if (input && input.length > 0 && input[0].className != HtmlAttributeNames.adaptiveCardToggleInputClassName) {
115
+ if ((input === null || input === void 0 ? void 0 : input.length) > 0 && input[0].className != HtmlAttributeNames.adaptiveCardToggleInputClassName && input[0].className != HtmlAttributeNames.adaptiveCardActionSetClassName) {
116
116
  input[0].setAttribute(HtmlAttributeNames.ariaLabel, value);
117
117
  }
118
118
  }
@@ -1,7 +1,7 @@
1
1
  export const defaultGeneralPreChatSurveyPaneStyleProps = {
2
2
  borderStyle: "solid",
3
3
  borderRadius: "inherit",
4
- borderWidth: "3px",
4
+ borderWidth: "0px",
5
5
  backgroundColor: "#FFFFFF",
6
6
  borderColor: "#F1F1F1",
7
7
  overflowY: "auto",
@@ -26,10 +26,12 @@ export const ReconnectChatPaneStateful = props => {
26
26
  };
27
27
  await initStartChat(optionalParams);
28
28
  } else {
29
+ var _state$domainStates;
29
30
  dispatch({
30
31
  type: LiveChatWidgetActionType.SET_RECONNECT_ID,
31
32
  payload: undefined
32
33
  });
34
+ chatSDK.requestId = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.initialChatSdkRequestId;
33
35
  const parseToJson = false;
34
36
  const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
35
37
  if (preChatSurveyResponse) {
@@ -6,6 +6,7 @@ const FileAttachmentIconMap = {
6
6
  "aac": AudioIcon,
7
7
  "aiff": AudioIcon,
8
8
  "alac": AudioIcon,
9
+ "amr": AudioIcon,
9
10
  "avchd": VideoIcon,
10
11
  "avi": VideoIcon,
11
12
  "bmp": ImageIcon,
@@ -44,6 +45,7 @@ const FileAttachmentIconMap = {
44
45
  "vsdx": VisioIcon,
45
46
  "wav": AudioIcon,
46
47
  "webm": VideoIcon,
48
+ "webp": ImageIcon,
47
49
  "wma": AudioIcon,
48
50
  "wmv": VideoIcon,
49
51
  "xls": ExcelIcon,
@@ -51,9 +51,7 @@ export const activityStatusMiddleware = () => next => args => {
51
51
  style: {
52
52
  padding: "2px"
53
53
  }
54
- }, sendState === SendStatus.Sending && /*#__PURE__*/React.createElement(SendingTimestamp, {
55
- args: args
56
- }), sendState === SendStatus.SendFailed && /*#__PURE__*/React.createElement(NotDeliveredTimestamp, {
54
+ }, sendState === SendStatus.Sending && /*#__PURE__*/React.createElement(SendingTimestamp, null), sendState === SendStatus.SendFailed && /*#__PURE__*/React.createElement(NotDeliveredTimestamp, {
57
55
  args: args
58
56
  }), sendState === SendStatus.Sent && /*#__PURE__*/React.createElement(DeliveredTimestamp, {
59
57
  args: args,
@@ -229,7 +229,8 @@ const createAttachmentMiddleware = enableInlinePlaying => {
229
229
  renderer: next
230
230
  });
231
231
  }
232
- if (fileExtension === "txt") {
232
+ const isUnknownImageObject = contentType.toLowerCase().includes("image") && !imageExtension;
233
+ if (fileExtension === "txt" || isUnknownImageObject) {
233
234
  return /*#__PURE__*/React.createElement(Attachment, {
234
235
  iconData: iconData,
235
236
  textCard: patchAttachment(card, {
@@ -1,3 +1,3 @@
1
1
  export const defaultSystemMessageBoxStyles = {
2
- maxWidth: "75%"
2
+ maxWidth: "90%"
3
3
  };
@@ -1,3 +1,3 @@
1
1
  export const defaultUserMessageBoxStyles = {
2
- maxWidth: "75%"
2
+ maxWidth: "90%"
3
3
  };
@@ -1,5 +1,4 @@
1
1
  import React, { useCallback, useEffect, useRef } from "react";
2
- import { HtmlAttributeNames } from "../../../../../../common/Constants";
3
2
  import { KeyCodes } from "../../../../../../common/KeyCodes";
4
3
  import { Stack } from "@fluentui/react";
5
4
  import { defaultMiddlewareLocalizedTexts } from "../../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
@@ -50,9 +49,8 @@ export const NotDeliveredTimestamp = _ref => {
50
49
  timestampWebChatNodes[1].innerText = getTimestampHourMinute(timestamp);
51
50
  }
52
51
  }, [timestampRef]);
53
- const onRetryClick = useCallback(async event => {
52
+ const onRetryClick = useCallback(async () => {
54
53
  var _activity$channelData;
55
- removeNotDeliveredTimestamp(event);
56
54
  activity.previousClientActivityID = (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.clientActivityID;
57
55
  await postActivity(activity);
58
56
  focus("sendBox");
@@ -60,19 +58,9 @@ export const NotDeliveredTimestamp = _ref => {
60
58
  const onRetryKeyEnter = event => {
61
59
  if (event.code === KeyCodes.ENTER) {
62
60
  event.preventDefault();
63
- onRetryClick(event);
61
+ onRetryClick();
64
62
  }
65
63
  };
66
- const removeNotDeliveredTimestamp = event => {
67
- let parent = event.target.parentElement;
68
- while (parent.tagName !== HtmlAttributeNames.listItem) {
69
- parent = parent.parentElement;
70
- if (parent.tagName === HtmlAttributeNames.unorderedList) {
71
- return;
72
- }
73
- }
74
- parent.parentNode.removeChild(parent);
75
- };
76
64
  return /*#__PURE__*/React.createElement(Stack, {
77
65
  style: contentStyles,
78
66
  dir: dir,
@@ -2,29 +2,20 @@ import React from "react";
2
2
  import { Stack } from "@fluentui/react";
3
3
  import { defaultMiddlewareLocalizedTexts } from "../../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
4
4
  import { defaultTimestampContentStyles } from "../defaultStyles/defaultTimestampContentStyles";
5
- import { getTimestampHourMinute } from "../../../../../../common/utils";
6
5
  import { useChatContextStore } from "../../../../../..";
7
6
 
8
7
  /* eslint @typescript-eslint/no-explicit-any: "off" */
9
- export const SendingTimestamp = _ref => {
8
+ export const SendingTimestamp = () => {
10
9
  var _state$domainStates$r, _state$domainStates$r2, _state$domainStates$m;
11
- let {
12
- args
13
- } = _ref;
14
10
  const [state] = useChatContextStore();
15
11
  const dir = ((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.timestampDir) ?? state.domainStates.globalDir;
16
12
  const contentStyles = {
17
13
  ...defaultTimestampContentStyles,
18
14
  ...((_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.timestampContentStyleProps)
19
15
  };
20
- const {
21
- activity: {
22
- timestamp
23
- }
24
- } = args;
25
16
  return /*#__PURE__*/React.createElement(Stack, {
26
17
  style: contentStyles,
27
18
  dir: dir,
28
19
  horizontal: true
29
- }, /*#__PURE__*/React.createElement("span", null, " ", getTimestampHourMinute(timestamp)), /*#__PURE__*/React.createElement("span", null, " \xA0-\xA0 "), /*#__PURE__*/React.createElement("span", null, " ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_SENDING) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_SENDING, " "));
20
+ }, /*#__PURE__*/React.createElement("span", null, " ", ((_state$domainStates$m = state.domainStates.middlewareLocalizedTexts) === null || _state$domainStates$m === void 0 ? void 0 : _state$domainStates$m.MIDDLEWARE_MESSAGE_SENDING) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_MESSAGE_SENDING, " "));
30
21
  };
@@ -1,16 +1,17 @@
1
1
  /******
2
2
  * TypingIndicatorMiddleware
3
- *
3
+ *
4
4
  * This middleware changes the component that shows who's actively typing. It uses the default Microsoft LiveChatWidget styles.
5
5
  ******/
6
6
 
7
- import React from "react";
7
+ import React, { useCallback } from "react";
8
8
  import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
9
9
  import { defaultMiddlewareLocalizedTexts } from "../../../common/defaultProps/defaultMiddlewareLocalizedTexts";
10
10
  import { defaultTypingIndicatorBubbleStyles } from "./defaultStyles/defaultTypingIndicatorBubbleStyles";
11
11
  import { defaultTypingIndicatorContainerStyles } from "./defaultStyles/defaultTypingIndicatorContainerStyles";
12
12
  import { defaultTypingIndicatorMessageStyles } from "./defaultStyles/defaultTypingIndicatorMessageStyles";
13
13
  import { useChatContextStore } from "../../../../..";
14
+ import { debounceLeading } from "../../../../../common/utils";
14
15
  import useChatSDKStore from "../../../../../hooks/useChatSDKStore";
15
16
 
16
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -23,6 +24,7 @@ const TypingIndicator = _ref => {
23
24
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
25
  const chatSDK = useChatSDKStore();
25
26
  const [state] = useChatContextStore();
27
+ const debounceTyping = useCallback(debounceLeading(() => chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.sendTypingEvent()), []);
26
28
  if (!activeTyping || Object.keys(activeTyping).length === 0 || ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.LiveChatVersion) === 1 && !visible) {
27
29
  return null;
28
30
  }
@@ -32,7 +34,7 @@ const TypingIndicator = _ref => {
32
34
  var _state$domainStates$l2;
33
35
  //visible is set to false if the current user is typing, in which case, we just send typing indicator to OC
34
36
  if (((_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.LiveChatVersion) === 2 && !visible) {
35
- chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.sendTypingEvent();
37
+ debounceTyping();
36
38
  return null;
37
39
  }
38
40
  activeTyping.splice(i, 1);
@@ -4,26 +4,30 @@
4
4
  * Checks if the attachment being uploaded satisfies Omnichannel's requirement on file extensions and file size.
5
5
  ******/
6
6
 
7
+ import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
7
8
  import { NotificationHandler } from "../../notification/NotificationHandler";
8
9
  import { NotificationScenarios } from "../../enums/NotificationScenarios";
9
10
  import { WebChatActionType } from "../../enums/WebChatActionType";
11
+ import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
12
+ import { AMSConstants } from "../../../../../common/Constants";
10
13
  const MBtoBRatio = 1000000;
11
14
 
12
15
  /*
13
16
  * If an attachment is invalid, delete this attachment from the attachments list
14
17
  * If the result attachment list is empty, return a dummy action
15
18
  */
16
- const validateAttachment = (action, allowedFileExtensions, maxUploadFileSize, localizedTexts) => {
19
+ const validateAttachment = (action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts) => {
17
20
  var _action$payload, _action$payload$activ, _action$payload2, _action$payload2$acti, _action$payload2$acti2, _action$payload3, _action$payload3$acti, _action$payload3$acti2;
18
21
  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;
19
22
  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;
20
23
  if (attachments) {
21
24
  for (let i = 0; i < attachments.length; i++) {
25
+ const maxUploadFileSize = getMaxUploadFileSize(maxFileSizeSupportedByDynamics, attachments[i].contentType);
22
26
  const fileExtensionValid = validateFileExtension(attachments[i], allowedFileExtensions);
23
27
  const fileSizeValid = validateFileSize(attachmentSizes[i], maxUploadFileSize);
24
28
  const fileIsEmpty = parseInt(attachmentSizes[i]) == 0;
25
29
  if (!fileExtensionValid || !fileSizeValid || fileIsEmpty) {
26
- NotificationHandler.notifyError(NotificationScenarios.AttachmentError, buildErrorMessage(attachments[i].name, fileExtensionValid, fileSizeValid, fileIsEmpty, maxUploadFileSize, localizedTexts));
30
+ NotificationHandler.notifyError(NotificationScenarios.AttachmentError, buildErrorMessage(attachments[i].name, fileExtensionValid, fileSizeValid, fileIsEmpty, maxUploadFileSize.toString(), maxFileSizeSupportedByDynamics, localizedTexts));
27
31
  attachments.splice(i, 1);
28
32
  attachmentSizes.splice(i, 1);
29
33
  i--;
@@ -55,58 +59,118 @@ const validateFileExtension = (attachment, allowedFileExtensions) => {
55
59
  return allExtensions.indexOf(fileExtension) > -1;
56
60
  };
57
61
  const validateFileSize = (attachmentSize, maxUploadFileSize) => {
58
- return (maxUploadFileSize && parseInt(maxUploadFileSize) * MBtoBRatio) > parseInt(attachmentSize);
62
+ return maxUploadFileSize * MBtoBRatio > parseInt(attachmentSize);
59
63
  };
60
- const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, localizedTexts) => {
64
+ const getMaxUploadFileSize = (maxFileSizeSupportedByDynamicsStr, contentType) => {
65
+ const maxFileSizeSupportedByDynamics = maxFileSizeSupportedByDynamicsStr && parseInt(maxFileSizeSupportedByDynamicsStr) ? parseInt(maxFileSizeSupportedByDynamicsStr) : AMSConstants.maxSupportedFileSize;
66
+ const amsAttachmentSizeLimit = isImage(contentType) ? AMSConstants.maxSupportedImageSize : AMSConstants.maxSupportedFileSize;
67
+ // Takes the smallest max file size configure betteween AMS and Dynamics Config
68
+ return maxFileSizeSupportedByDynamics < amsAttachmentSizeLimit ? maxFileSizeSupportedByDynamics : amsAttachmentSizeLimit;
69
+ };
70
+ const isImage = contentType => {
71
+ return AMSConstants.supportedImagesMimeTypes.includes(contentType);
72
+ };
73
+ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
61
74
  let errorMessage = "";
62
75
  if (!fileName || !maxUploadFileSize) {
76
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
77
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
78
+ Description: "Attachment validation failed",
79
+ ExceptionDetails: {
80
+ ErrorDetails: "File provided is null"
81
+ }
82
+ });
63
83
  return localizedTexts.MIDDLEWARE_BANNER_FILE_NULL_ERROR ?? "";
64
84
  }
65
85
  if (!supportedFileExtension && !supportedFileSize) {
66
- errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, localizedTexts);
86
+ errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
67
87
  } else if (!supportedFileSize) {
68
- errorMessage = getFileSizeErrorMessage(maxUploadFileSize, localizedTexts);
88
+ errorMessage = getFileSizeErrorMessage(maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
69
89
  } else if (!supportedFileExtension) {
70
90
  errorMessage = getFileExtensionErrorMessage(fileName, localizedTexts);
71
91
  } else if (fileIsEmpty) {
92
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
93
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
94
+ Description: "Attachment validation failed",
95
+ ExceptionDetails: {
96
+ ErrorDetails: "File provided is empty"
97
+ }
98
+ });
72
99
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR ?? "";
73
100
  } else {
101
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
102
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
103
+ Description: "Attachment validation failed",
104
+ ExceptionDetails: {
105
+ ErrorDetails: `Unexpected error: supportedFileExtension=${supportedFileExtension} supportedFileSize=${supportedFileSize} fileIsEmpty=${!fileIsEmpty}`
106
+ }
107
+ });
74
108
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_ERROR_MESSAGE ?? "";
75
109
  }
76
110
  return errorMessage;
77
111
  };
78
- const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, localizedTexts) => {
112
+ const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
79
113
  const index = fileName.lastIndexOf(".");
80
- let errorMessage;
114
+ let errorMessage, exceptionDetails;
81
115
  if (index < 0) {
82
116
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR;
117
+ exceptionDetails = `File exceeded the allowed limit of ${maxUploadFileSize} MB and File provided without file extension`;
83
118
  } else {
84
119
  var _errorMessage;
85
120
  const fileExtension = fileName.substring(index);
86
121
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR;
122
+ exceptionDetails = `File exceeds the allowed limit of ${maxUploadFileSize} MB and ${fileExtension} files are not supported`;
87
123
  if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{1}")) {
88
124
  errorMessage = errorMessage.replace("{1}", fileExtension);
89
125
  }
90
126
  }
127
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
128
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
129
+ Description: "Attachment validation failed",
130
+ ExceptionDetails: {
131
+ ErrorDetails: `${exceptionDetails} Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
132
+ }
133
+ });
91
134
  return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
92
135
  };
93
136
  const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
94
137
  const index = fileName.lastIndexOf(".");
95
138
  if (index < 0) {
139
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
140
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
141
+ Description: "Attachment validation failed",
142
+ ExceptionDetails: {
143
+ ErrorDetails: "File provided without file extension"
144
+ }
145
+ });
96
146
  return localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION ?? "";
97
147
  } else {
98
148
  const fileExtension = fileName.substring(index);
149
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
150
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
151
+ Description: "Attachment validation failed",
152
+ ExceptionDetails: {
153
+ ErrorDetails: `${fileExtension} files extension is not supported.`
154
+ }
155
+ });
99
156
  const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
100
157
  return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", fileExtension) : errorMessage : "";
101
158
  }
102
159
  };
103
- const getFileSizeErrorMessage = (maxUploadFileSize, localizedTexts) => {
160
+ const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
161
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
162
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
163
+ Description: "Attachment validation failed",
164
+ ExceptionDetails: {
165
+ ErrorDetails: `File exceeds the allowed limit of ${maxUploadFileSize}MB. Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
166
+ }
167
+ });
104
168
  const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
105
169
  return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
106
170
  };
107
171
 
108
172
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
109
- const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxUploadFileSize, localizedTexts) => _ref => {
173
+ const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts) => _ref => {
110
174
  let {
111
175
  dispatch
112
176
  } = _ref;
@@ -117,7 +181,7 @@ const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxUpl
117
181
  payload
118
182
  } = action;
119
183
  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)) {
120
- return next(validateAttachment(action, allowedFileExtensions, maxUploadFileSize, localizedTexts));
184
+ return next(validateAttachment(action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts));
121
185
  }
122
186
  }
123
187
  return next(action);
@@ -0,0 +1,5 @@
1
+ export let ConversationEndEntity;
2
+ (function (ConversationEndEntity) {
3
+ ConversationEndEntity[ConversationEndEntity["Customer"] = 0] = "Customer";
4
+ ConversationEndEntity[ConversationEndEntity["Agent"] = 1] = "Agent";
5
+ })(ConversationEndEntity || (ConversationEndEntity = {}));
@@ -29,11 +29,15 @@ export let LiveChatWidgetActionType;
29
29
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_RECONNECT_ID"] = 26] = "SET_RECONNECT_ID";
30
30
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_UNREAD_MESSAGE_COUNT"] = 27] = "SET_UNREAD_MESSAGE_COUNT";
31
31
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_FOCUS_CHAT_BUTTON"] = 28] = "SET_FOCUS_CHAT_BUTTON";
32
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT"] = 29] = "SET_CONVERSATION_ENDED_BY_AGENT";
33
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 30] = "SET_WIDGET_STATE";
34
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 31] = "SET_LIVE_CHAT_CONTEXT";
35
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 32] = "SET_BOT_OAUTH_SIGNIN_ID";
36
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 33] = "SET_WIDGET_SIZE";
37
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 34] = "SET_WIDGET_INSTANCE_ID";
38
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONFIG"] = 35] = "SET_LIVE_CHAT_CONFIG";
32
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED"] = 29] = "SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED";
33
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY"] = 30] = "SET_CONVERSATION_ENDED_BY";
34
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 31] = "SET_WIDGET_STATE";
35
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 32] = "SET_LIVE_CHAT_CONTEXT";
36
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 33] = "SET_BOT_OAUTH_SIGNIN_ID";
37
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 34] = "SET_WIDGET_SIZE";
38
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 35] = "SET_WIDGET_INSTANCE_ID";
39
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONFIG"] = 36] = "SET_LIVE_CHAT_CONFIG";
40
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_WORKFLOW_IN_PROGRESS"] = 37] = "SET_POST_CHAT_WORKFLOW_IN_PROGRESS";
41
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INITIAL_CHAT_SDK_REQUEST_ID"] = 38] = "SET_INITIAL_CHAT_SDK_REQUEST_ID";
42
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOULD_USE_BOT_SURVEY"] = 39] = "SET_SHOULD_USE_BOT_SURVEY";
39
43
  })(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
@@ -2,10 +2,12 @@ import { ConversationState } from "./ConversationState";
2
2
  import { defaultMiddlewareLocalizedTexts } from "../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
3
3
  import { getWidgetCacheId, isNullOrUndefined } from "../../common/utils";
4
4
  import { defaultClientDataStoreProvider } from "../../common/storage/default/defaultClientDataStoreProvider";
5
+ import { Constants } from "../../common/Constants";
5
6
  export const getLiveChatWidgetContextInitialState = props => {
6
- var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$webChatContain;
7
+ var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$controlProps2, _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) ?? "");
8
- const initialState = defaultClientDataStoreProvider().getData(widgetCacheId, "localStorage");
9
+ const cacheTtlInMins = (props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.cacheTtlInMins) ?? Constants.CacheTtlInMinutes;
10
+ const initialState = defaultClientDataStoreProvider(cacheTtlInMins).getData(widgetCacheId, "localStorage");
9
11
  if (!isNullOrUndefined(initialState)) {
10
12
  return JSON.parse(initialState);
11
13
  }
@@ -23,7 +25,8 @@ export const getLiveChatWidgetContextInitialState = props => {
23
25
  liveChatContext: undefined,
24
26
  customContext: undefined,
25
27
  widgetSize: undefined,
26
- widgetInstanceId: ""
28
+ widgetInstanceId: "",
29
+ initialChatSdkRequestId: ""
27
30
  },
28
31
  appStates: {
29
32
  conversationState: ConversationState.Closed,
@@ -43,7 +46,10 @@ export const getLiveChatWidgetContextInitialState = props => {
43
46
  },
44
47
  e2vvEnabled: false,
45
48
  unreadMessageCount: 0,
46
- conversationEndedByAgent: false
49
+ conversationEndedByAgentEventReceived: false,
50
+ conversationEndedBy: undefined,
51
+ postChatWorkflowInProgress: false,
52
+ shouldUseBotSurvey: false
47
53
  },
48
54
  uiStates: {
49
55
  showConfirmationPane: false,
@@ -258,12 +258,20 @@ export const createReducer = () => {
258
258
  return {
259
259
  ...action.payload
260
260
  };
261
- case LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT:
261
+ case LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED:
262
262
  return {
263
263
  ...state,
264
264
  appStates: {
265
265
  ...state.appStates,
266
- conversationEndedByAgent: action.payload
266
+ conversationEndedByAgentEventReceived: action.payload
267
+ }
268
+ };
269
+ case LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY:
270
+ return {
271
+ ...state,
272
+ appStates: {
273
+ ...state.appStates,
274
+ conversationEndedBy: action.payload
267
275
  }
268
276
  };
269
277
  case LiveChatWidgetActionType.SET_WIDGET_SIZE:
@@ -293,6 +301,32 @@ export const createReducer = () => {
293
301
  liveChatConfig: action.payload
294
302
  }
295
303
  };
304
+ case LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS:
305
+ return {
306
+ ...state,
307
+ appStates: {
308
+ ...state.appStates,
309
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
310
+ postChatWorkflowInProgress: action.payload
311
+ }
312
+ };
313
+ case LiveChatWidgetActionType.SET_INITIAL_CHAT_SDK_REQUEST_ID:
314
+ return {
315
+ ...state,
316
+ domainStates: {
317
+ ...state.domainStates,
318
+ initialChatSdkRequestId: action.payload
319
+ }
320
+ };
321
+ case LiveChatWidgetActionType.SET_SHOULD_USE_BOT_SURVEY:
322
+ return {
323
+ ...state,
324
+ appStates: {
325
+ ...state.appStates,
326
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
327
+ shouldUseBotSurvey: action.payload
328
+ }
329
+ };
296
330
  default:
297
331
  return state;
298
332
  }
@@ -0,0 +1,22 @@
1
+ import { useRef, useEffect } from "react";
2
+ export default function useDebounce(func) {
3
+ let delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
4
+ const timer = useRef();
5
+ useEffect(() => {
6
+ return () => {
7
+ if (!timer.current) return;
8
+ clearTimeout(timer.current);
9
+ };
10
+ }, []);
11
+ const debouncedFunction = function () {
12
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
13
+ args[_key] = arguments[_key];
14
+ }
15
+ const newTimer = setTimeout(() => {
16
+ func(...args);
17
+ }, delay);
18
+ clearTimeout(timer.current);
19
+ timer.current = newTimer;
20
+ };
21
+ return debouncedFunction;
22
+ }
@@ -0,0 +1,23 @@
1
+ import { useState, useEffect } from "react";
2
+ import useDebounce from "./useDebounce";
3
+ function getWindowDimensions() {
4
+ const {
5
+ innerWidth: width,
6
+ innerHeight: height
7
+ } = window;
8
+ return {
9
+ width,
10
+ height
11
+ };
12
+ }
13
+ export default function useWindowDimensions() {
14
+ let delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 200;
15
+ const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
16
+ const handleResize = () => setWindowDimensions(getWindowDimensions());
17
+ const debouncedHandleResize = useDebounce(handleResize, delay);
18
+ useEffect(() => {
19
+ window.addEventListener("resize", debouncedHandleResize);
20
+ return () => window.removeEventListener("resize", debouncedHandleResize);
21
+ }, []);
22
+ return windowDimensions;
23
+ }
@@ -9,6 +9,7 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
9
9
  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.historyMessageTag)) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 ? void 0 : _activity$channelData3.fromList));
10
10
  raiseMessageEvent(activity, isHistoryMessage);
11
11
  };
12
+ let isHistoryMessageReceivedEventRasied = false;
12
13
  const raiseMessageEvent = (activity, isHistoryMessage) => {
13
14
  if ((activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message) {
14
15
  var _text, _text2, _activity$channelData4, _activity$from;
@@ -39,6 +40,10 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
39
40
  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)) {
40
41
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
42
  payload.messageType = Constants.systemMessageTag;
43
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
44
+ Event: TelemetryEvent.SystemMessageReceived,
45
+ Description: "System message received"
46
+ });
42
47
  } else {
43
48
  var _activity$channelData7, _activity$channelData8, _activity$channelData9;
44
49
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -63,6 +68,15 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
63
68
  Description: "New message received",
64
69
  Data: payload
65
70
  });
71
+ } else {
72
+ if (!isHistoryMessageReceivedEventRasied) {
73
+ isHistoryMessageReceivedEventRasied = true;
74
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
75
+ Event: TelemetryEvent.HistoryMessageReceived,
76
+ Description: "History message received",
77
+ Data: payload
78
+ });
79
+ }
66
80
  }
67
81
  }
68
82
  }