@microsoft/omnichannel-chat-widget 1.8.2-main.e3c1d40 → 1.8.2-main.f638bed

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 (71) hide show
  1. package/README.md +48 -1
  2. package/lib/cjs/common/Constants.js +16 -3
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
  4. package/lib/cjs/common/utils.js +27 -2
  5. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
  6. package/lib/cjs/components/draggable/DraggableChatWidget.js +16 -1
  7. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
  8. package/lib/cjs/components/livechatwidget/common/customEventHandler.js +53 -0
  9. package/lib/cjs/components/livechatwidget/common/endChat.js +18 -7
  10. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +32 -1
  11. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +18 -1
  12. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +31 -7
  13. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +15 -2
  14. package/lib/cjs/components/livechatwidget/common/startChat.js +6 -4
  15. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -12
  16. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +4 -3
  17. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +12 -6
  18. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +41 -0
  19. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +45 -0
  20. package/lib/cjs/contexts/common/CustomEventType.js +1 -0
  21. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +3 -1
  22. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
  23. package/lib/cjs/contexts/createReducer.js +30 -0
  24. package/lib/cjs/controller/componentController.js +2 -2
  25. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
  26. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
  27. package/lib/cjs/firstresponselatency/util.js +60 -31
  28. package/lib/cjs/plugins/newMessageEventHandler.js +12 -6
  29. package/lib/esm/common/Constants.js +14 -2
  30. package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
  31. package/lib/esm/common/utils.js +21 -0
  32. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
  33. package/lib/esm/components/draggable/DraggableChatWidget.js +16 -1
  34. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
  35. package/lib/esm/components/livechatwidget/common/customEventHandler.js +45 -0
  36. package/lib/esm/components/livechatwidget/common/endChat.js +18 -7
  37. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +32 -1
  38. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +16 -0
  39. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +33 -9
  40. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +16 -3
  41. package/lib/esm/components/livechatwidget/common/startChat.js +6 -4
  42. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -12
  43. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +4 -4
  44. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +12 -6
  45. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +33 -0
  46. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +38 -0
  47. package/lib/esm/contexts/common/CustomEventType.js +1 -0
  48. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +3 -1
  49. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
  50. package/lib/esm/contexts/createReducer.js +30 -0
  51. package/lib/esm/controller/componentController.js +2 -2
  52. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
  53. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
  54. package/lib/esm/firstresponselatency/util.js +57 -29
  55. package/lib/esm/plugins/newMessageEventHandler.js +12 -6
  56. package/lib/types/common/Constants.d.ts +13 -2
  57. package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -0
  58. package/lib/types/common/utils.d.ts +8 -0
  59. package/lib/types/components/livechatwidget/common/customEventHandler.d.ts +4 -0
  60. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -0
  61. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.d.ts +1 -1
  62. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.d.ts +1 -1
  63. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.d.ts +22 -0
  64. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +5 -0
  65. package/lib/types/contexts/common/CustomEventType.d.ts +6 -0
  66. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -0
  67. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
  68. package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +2 -2
  69. package/lib/types/firstresponselatency/util.d.ts +17 -0
  70. package/lib/types/plugins/newMessageEventHandler.d.ts +1 -1
  71. package/package.json +4 -4
@@ -51,23 +51,34 @@ const setSurveyMode = async (props, participantType, state, dispatch) => {
51
51
  };
52
52
 
53
53
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
- const renderSurvey = async (postChatContext, dispatch) => {
54
+ const renderSurvey = async (postChatContext, state, dispatch) => {
55
55
  if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
56
56
  setWidgetStateToInactive(dispatch);
57
57
  return;
58
58
  }
59
59
  if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
60
- await embedModePostChatWorkflow(postChatContext, dispatch);
60
+ await embedModePostChatWorkflow(postChatContext, state, dispatch);
61
61
  }
62
62
  };
63
63
 
64
64
  // Function for embed mode postchat workflow which is essentially same for both customer and agent
65
65
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
- const embedModePostChatWorkflow = async (postChatContext, dispatch) => {
66
+ const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
67
67
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
68
68
  Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
69
69
  });
70
70
  if (postChatContext) {
71
+ if (postChatContext.isConversationalSurveyEnabled && postChatContext.surveyProvider === _Constants.SurveyProvider.MicrosoftCopilotStudio) {
72
+ dispatch({
73
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
74
+ payload: _ConversationState.ConversationState.Postchat
75
+ });
76
+ dispatch({
77
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY,
78
+ payload: true
79
+ });
80
+ return;
81
+ }
71
82
  dispatch({
72
83
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
73
84
  payload: _ConversationState.ConversationState.PostchatLoading
@@ -94,7 +105,7 @@ const initiatePostChat = async (props, conversationDetailsParam, state, dispatch
94
105
  conversationDetails = conversationDetailsParam;
95
106
  const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
96
107
  await setSurveyMode(props, participantType, state, dispatch);
97
- await renderSurvey(postchatContext, dispatch);
108
+ await renderSurvey(postchatContext, state, dispatch);
98
109
  };
99
110
 
100
111
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -109,7 +120,14 @@ const isPostChatEnabled = (props, state) => {
109
120
  exports.checkPostChatEnabled = isPostChatEnabled;
110
121
  const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
111
122
  try {
112
- const postChatEnabled = await (0, _liveChatConfigUtils.isPostChatSurveyEnabled)(facadeChatSDK);
123
+ const postChatConfig = await (0, _liveChatConfigUtils.getPostChatSurveyConfig)(facadeChatSDK);
124
+ const postChatEnabled = postChatConfig.postChatEnabled;
125
+ if (postChatConfig.isConversationalSurveyEnabled) {
126
+ dispatch({
127
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_ENABLED,
128
+ payload: true
129
+ });
130
+ }
113
131
  if (postChatEnabled) {
114
132
  var _state$domainStates2;
115
133
  if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
@@ -119,11 +137,17 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
119
137
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
120
138
  Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
121
139
  });
140
+
141
+ // Merge postChatConfig with postChatSurveyContext
142
+ const mergedContext = {
143
+ ...context,
144
+ ...postChatConfig
145
+ };
122
146
  dispatch({
123
147
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
124
- payload: context
148
+ payload: mergedContext
125
149
  });
126
- return context;
150
+ return mergedContext;
127
151
  }
128
152
  }
129
153
  } catch (error) {
@@ -14,7 +14,14 @@ var _liveChatConfigUtils = require("./liveChatConfigUtils");
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
15
  const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persistedChat) => {
16
16
  try {
17
- const postChatEnabled = await (0, _liveChatConfigUtils.isPostChatSurveyEnabled)(facadeChatSDK);
17
+ const postChatConfig = await (0, _liveChatConfigUtils.getPostChatSurveyConfig)(facadeChatSDK);
18
+ if (postChatConfig.isConversationalSurveyEnabled) {
19
+ dispatch({
20
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_ENABLED,
21
+ payload: true
22
+ });
23
+ }
24
+ const postChatEnabled = postChatConfig.postChatEnabled;
18
25
  if (postChatEnabled) {
19
26
  if (!persistedChat) {
20
27
  _TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
@@ -27,9 +34,15 @@ const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persiste
27
34
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
28
35
  Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
29
36
  });
37
+
38
+ // Merge postChatConfig with postChatSurveyContext
39
+ const mergedContext = {
40
+ ...context,
41
+ ...postChatConfig
42
+ };
30
43
  dispatch({
31
44
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
32
- payload: context
45
+ payload: mergedContext
33
46
  });
34
47
  }
35
48
  }
@@ -154,7 +154,6 @@ const setPreChatAndInitiateChat = async (facadeChatSDK, dispatch, setAdapter, is
154
154
  const optionalParams = {
155
155
  isProactiveChat
156
156
  };
157
- (0, _FirstMessageTrackerFromBot.createTrackingForFirstMessage)();
158
157
  await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
159
158
  };
160
159
 
@@ -204,8 +203,12 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
204
203
  portalContactId: (_window$Microsoft = window.Microsoft) === null || _window$Microsoft === void 0 ? void 0 : (_window$Microsoft$Dyn = _window$Microsoft.Dynamic365) === null || _window$Microsoft$Dyn === void 0 ? void 0 : (_window$Microsoft$Dyn2 = _window$Microsoft$Dyn.Portal) === null || _window$Microsoft$Dyn2 === void 0 ? void 0 : (_window$Microsoft$Dyn3 = _window$Microsoft$Dyn2.User) === null || _window$Microsoft$Dyn3 === void 0 ? void 0 : _window$Microsoft$Dyn3.contactId
205
204
  };
206
205
  const startChatOptionalParams = Object.assign({}, params, optionalParams, defaultOptionalParams);
206
+ // startTime is used to determine if a message is history or new, better to be set before creating the adapter to get bandwidth
207
+ const startTime = new Date().getTime();
208
+ (0, _FirstMessageTrackerFromBot.createTrackingForFirstMessage)();
207
209
  await facadeChatSDK.startChat(startChatOptionalParams);
208
210
  isStartChatSuccessful = true;
211
+ await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, startTime, props);
209
212
  } catch (error) {
210
213
  (0, _utils.checkContactIdError)(error);
211
214
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
@@ -223,7 +226,6 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
223
226
  isStartChatSuccessful = false;
224
227
  throw error;
225
228
  }
226
- await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, props);
227
229
 
228
230
  // Set app state to Active
229
231
  if (isStartChatSuccessful) {
@@ -274,7 +276,7 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
274
276
 
275
277
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
276
278
  exports.initStartChat = initStartChat;
277
- const createAdapterAndSubscribe = async (facadeChatSDK, dispatch, setAdapter, props) => {
279
+ const createAdapterAndSubscribe = async (facadeChatSDK, dispatch, setAdapter, startTime, props) => {
278
280
  // New adapter creation
279
281
  const newAdapter = await (0, _createAdapter.createAdapter)(facadeChatSDK, props);
280
282
  setAdapter(newAdapter);
@@ -285,7 +287,7 @@ const createAdapterAndSubscribe = async (facadeChatSDK, dispatch, setAdapter, pr
285
287
  });
286
288
  if (chatToken !== null && chatToken !== void 0 && chatToken.chatId && chatToken !== null && chatToken !== void 0 && chatToken.visitorId) {
287
289
  var _newAdapter$activity$;
288
- newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe((0, _newMessageEventHandler.createOnNewAdapterActivityHandler)(chatToken.chatId, chatToken.visitorId));
290
+ newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe((0, _newMessageEventHandler.createOnNewAdapterActivityHandler)(chatToken.chatId, chatToken.visitorId, startTime));
289
291
  }
290
292
  };
291
293
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -57,6 +57,7 @@ var _startProactiveChat = require("../common/startProactiveChat");
57
57
  var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useChatAdapterStore"));
58
58
  var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
59
59
  var _useFacadeChatSDKStore = _interopRequireDefault(require("../../../hooks/useFacadeChatSDKStore"));
60
+ var _customEventHandler = require("../common/customEventHandler");
60
61
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61
62
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
62
63
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -421,7 +422,7 @@ const LiveChatWidgetStateful = props => {
421
422
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
422
423
  var _msg$payload5, _msg$payload6, _msg$payload7, _msg$payload9, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
423
424
  // If chat is out of operating hours chat widget sets the conversation state to OutOfOffice.
424
- if (state.appStates.outsideOperatingHours === true) {
425
+ if (state.appStates.outsideOperatingHours && state.appStates.conversationState !== _ConversationState.ConversationState.Active) {
425
426
  dispatch({
426
427
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
427
428
  payload: false
@@ -588,6 +589,9 @@ const LiveChatWidgetStateful = props => {
588
589
  }
589
590
  });
590
591
 
592
+ // subscribe custom event
593
+ (0, _customEventHandler.subscribeToSendCustomEvent)(_omnichannelChatComponents.BroadcastService, facadeChatSDK, _customEventHandler.customEventCallback);
594
+
591
595
  // Check for TPC and log in telemetry if blocked
592
596
  (0, _defaultClientDataStoreProvider.isCookieAllowed)();
593
597
  return () => {
@@ -619,12 +623,15 @@ const LiveChatWidgetStateful = props => {
619
623
  payload: null
620
624
  });
621
625
  if ("participantsRemoved" in event && (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta5 = inMemoryState.appStates) === null || _inMemoryState$appSta5 === void 0 ? void 0 : _inMemoryState$appSta5.conversationState) === _ConversationState.ConversationState.Active) {
622
- setWebChatStyles(styles => {
623
- return {
624
- ...styles,
625
- hideSendBox: true
626
- };
627
- });
626
+ var _inMemoryState$appSta6;
627
+ if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta6 = inMemoryState.appStates) === null || _inMemoryState$appSta6 === void 0 ? void 0 : _inMemoryState$appSta6.isConversationalSurveyEnabled) === false) {
628
+ setWebChatStyles(styles => {
629
+ return {
630
+ ...styles,
631
+ hideSendBox: true
632
+ };
633
+ });
634
+ }
628
635
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
629
636
  Event: _TelemetryConstants.TelemetryEvent.ParticipantsRemovedEvent,
630
637
  Description: "Participants removed event received."
@@ -720,7 +727,15 @@ const LiveChatWidgetStateful = props => {
720
727
  (0, _endChat.endChat)(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
721
728
  return;
722
729
  }
723
- if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === _Constants.ConversationEndEntity.Bot) {
730
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
731
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
732
+ payload: null
733
+ });
734
+ let isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
735
+
736
+ // In conversational survey, we need to check post chat survey logics before we set ConversationState to InActive
737
+ // Hence setting ConversationState to InActive will be done later in the post chat flows
738
+ if (!isConversationalSurveyEnabled && ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === _Constants.ConversationEndEntity.Bot)) {
724
739
  dispatch({
725
740
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
726
741
  payload: _ConversationState.ConversationState.InActive
@@ -761,13 +776,13 @@ const LiveChatWidgetStateful = props => {
761
776
 
762
777
  // Handle Chat disconnect cases
763
778
  (0, _react2.useEffect)(() => {
764
- var _inMemoryState$appSta6;
779
+ var _inMemoryState$appSta7;
765
780
  const inMemoryState = (0, _createReducer.executeReducer)(state, {
766
781
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
767
782
  payload: null
768
783
  });
769
784
  (0, _chatDisconnectHelper.handleChatDisconnect)(props, inMemoryState, setWebChatStyles);
770
- const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta6 = inMemoryState.appStates) === null || _inMemoryState$appSta6 === void 0 ? void 0 : _inMemoryState$appSta6.chatDisconnectEventReceived;
785
+ const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta7 = inMemoryState.appStates) === null || _inMemoryState$appSta7 === void 0 ? void 0 : _inMemoryState$appSta7.chatDisconnectEventReceived;
771
786
  if (chatDisconnectState && adapter) {
772
787
  try {
773
788
  adapter.end();
@@ -895,8 +910,8 @@ const LiveChatWidgetStateful = props => {
895
910
  margin-left: .25em;
896
911
  }
897
912
  ${(sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight) && `
898
- textarea.webchat__send-box-text-box__html-text-area {
899
- min-height: ${sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight};
913
+ .webchat__auto-resize-textarea.webchat__send-box-text-box__text-area {
914
+ min-height: ${sendBoxTextArea === null || sendBoxTextArea === void 0 ? void 0 : sendBoxTextArea.minHeight} !important;
900
915
  }`}
901
916
  `), /*#__PURE__*/_react2.default.createElement(_DraggableChatWidget.default, chatWidgetDraggableConfig, /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
902
917
  userID: userID,
@@ -14,13 +14,13 @@ var _WebChatActionType = require("../../enums/WebChatActionType");
14
14
  ******/
15
15
 
16
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
17
- const channelDataMiddleware = _ref => {
17
+ const channelDataMiddleware = addConversationalSurveyTagsCallback => _ref => {
18
18
  let {
19
19
  dispatch
20
20
  } = _ref;
21
21
  return next => action => {
22
- var _action$payload, _action$payload$activ;
23
- if ((action === null || action === void 0 ? void 0 : action.type) === _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY_PENDING && action !== null && action !== void 0 && (_action$payload = action.payload) !== null && _action$payload !== void 0 && (_action$payload$activ = _action$payload.activity) !== null && _action$payload$activ !== void 0 && _action$payload$activ.channelData) {
22
+ var _action, _action2, _action2$payload, _action2$payload$acti;
23
+ if (((_action = action) === null || _action === void 0 ? void 0 : _action.type) === _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY_PENDING && (_action2 = action) !== null && _action2 !== void 0 && (_action2$payload = _action2.payload) !== null && _action2$payload !== void 0 && (_action2$payload$acti = _action2$payload.activity) !== null && _action2$payload$acti !== void 0 && _action2$payload$acti.channelData) {
24
24
  const channelIdTag = `${_Constants.Constants.channelIdKey}${_Constants.Constants.ChannelId}`;
25
25
  const customerMessageTag = `${_Constants.Constants.CustomerTag}`;
26
26
  if (action.payload.activity.channelData.tags) {
@@ -34,6 +34,7 @@ const channelDataMiddleware = _ref => {
34
34
  action.payload.activity.channelData.tags = [channelIdTag];
35
35
  action.payload.activity.channelData.tags.push(customerMessageTag);
36
36
  }
37
+ action = addConversationalSurveyTagsCallback(action);
37
38
  action.payload.activity.channelData.metadata = {
38
39
  deliveryMode: _omnichannelChatSdk.DeliveryMode.Bridged
39
40
  };
@@ -16,27 +16,33 @@ var _WebChatActionType = require("../../enums/WebChatActionType");
16
16
  ******/
17
17
 
18
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
19
- const createConversationEndMiddleware = conversationEndCallback => _ref => {
19
+ const createConversationEndMiddleware = (conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback) => _ref => {
20
20
  let {
21
21
  dispatch
22
22
  } = _ref;
23
23
  return next => action => {
24
24
  var _action$payload;
25
25
  if ((action === null || action === void 0 ? void 0 : action.type) == _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
26
- var _activity$from2, _activity$channelData7, _activity$channelData8;
26
+ var _activity$from2, _activity$channelData17, _activity$channelData18;
27
27
  const activity = action.payload.activity;
28
28
  if (activity.channelId === "ACS_CHANNEL") {
29
29
  var _activity$from;
30
30
  if (((_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) === _DirectLineSenderRole.DirectLineSenderRole.Bot) {
31
- var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6;
31
+ var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6, _activity$channelData7, _activity$channelData8, _activity$channelData9, _activity$channelData10, _activity$channelData11, _activity$channelData12, _activity$channelData13, _activity$channelData14, _activity$channelData15, _activity$channelData16;
32
32
  if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(_Constants.Constants.systemMessageTag) && ((_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && (_activity$channelData4 = _activity$channelData3.tags) !== null && _activity$channelData4 !== void 0 && _activity$channelData4.includes(_Constants.Constants.agentEndConversationMessageTag) || (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(_Constants.Constants.supervisorForceCloseMessageTag))) {
33
33
  conversationEndCallback();
34
34
  }
35
+ if ((_activity$channelData7 = activity.channelData) !== null && _activity$channelData7 !== void 0 && (_activity$channelData8 = _activity$channelData7.tags) !== null && _activity$channelData8 !== void 0 && _activity$channelData8.includes(_Constants.Constants.systemMessageTag) && ((_activity$channelData9 = activity.channelData) !== null && _activity$channelData9 !== void 0 && (_activity$channelData10 = _activity$channelData9.tags) !== null && _activity$channelData10 !== void 0 && _activity$channelData10.includes(_Constants.Constants.startConversationalSurveyMessageTag) || (_activity$channelData11 = activity.channelData) !== null && _activity$channelData11 !== void 0 && (_activity$channelData12 = _activity$channelData11.tags) !== null && _activity$channelData12 !== void 0 && _activity$channelData12.includes(_Constants.Constants.startConversationalSurveyMessageTag))) {
36
+ startConversationalSurveyCallback();
37
+ }
38
+ if ((_activity$channelData13 = activity.channelData) !== null && _activity$channelData13 !== void 0 && (_activity$channelData14 = _activity$channelData13.tags) !== null && _activity$channelData14 !== void 0 && _activity$channelData14.includes(_Constants.Constants.systemMessageTag) && (_activity$channelData15 = activity.channelData) !== null && _activity$channelData15 !== void 0 && (_activity$channelData16 = _activity$channelData15.tags) !== null && _activity$channelData16 !== void 0 && _activity$channelData16.includes(_Constants.Constants.endConversationalSurveyMessageTag)) {
39
+ endConversationalSurveyCallback();
40
+ }
35
41
  }
36
- } else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel && ((_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : _activity$channelData7.type) === _MessageType.MessageTypes.Thread && (_activity$channelData8 = activity.channelData) !== null && _activity$channelData8 !== void 0 && _activity$channelData8.properties) {
37
- var _activity$channelData9, _activity$channelData10, _activity$channelData11, _activity$channelData12;
42
+ } else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel && ((_activity$channelData17 = activity.channelData) === null || _activity$channelData17 === void 0 ? void 0 : _activity$channelData17.type) === _MessageType.MessageTypes.Thread && (_activity$channelData18 = activity.channelData) !== null && _activity$channelData18 !== void 0 && _activity$channelData18.properties) {
43
+ var _activity$channelData19, _activity$channelData20, _activity$channelData21, _activity$channelData22;
38
44
  // IC3
39
- if (((_activity$channelData9 = activity.channelData) === null || _activity$channelData9 === void 0 ? void 0 : (_activity$channelData10 = _activity$channelData9.properties) === null || _activity$channelData10 === void 0 ? void 0 : _activity$channelData10.isdeleted) === _Constants.Constants.truePascal || !((_activity$channelData11 = activity.channelData) !== null && _activity$channelData11 !== void 0 && (_activity$channelData12 = _activity$channelData11.properties) !== null && _activity$channelData12 !== void 0 && _activity$channelData12.containsExternalEntitiesListeningAll)) {
45
+ if (((_activity$channelData19 = activity.channelData) === null || _activity$channelData19 === void 0 ? void 0 : (_activity$channelData20 = _activity$channelData19.properties) === null || _activity$channelData20 === void 0 ? void 0 : _activity$channelData20.isdeleted) === _Constants.Constants.truePascal || !((_activity$channelData21 = activity.channelData) !== null && _activity$channelData21 !== void 0 && (_activity$channelData22 = _activity$channelData21.properties) !== null && _activity$channelData22 !== void 0 && _activity$channelData22.containsExternalEntitiesListeningAll)) {
40
46
  conversationEndCallback();
41
47
  }
42
48
  }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isValidCustomEvent = exports.default = void 0;
7
+ var _Constants = require("../../../../../common/Constants");
8
+ var _WebChatActionType = require("../../enums/WebChatActionType");
9
+ /******
10
+ * CustomEventMiddleware
11
+ *
12
+ * This middleware is invoked when a custom event is received.
13
+ * The callback is then invoked to handle the custom event.
14
+ ******/
15
+
16
+ const isValidCustomEvent = activity => {
17
+ var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6, _activity$channelData7, _activity$from, _activity$channelData8, _activity$channelData9, _activity$channelData10, _activity$channelData11;
18
+ return !!(activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.metadata) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.customEvent && typeof (activity === null || activity === void 0 ? void 0 : (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 ? void 0 : (_activity$channelData4 = _activity$channelData3.metadata) === null || _activity$channelData4 === void 0 ? void 0 : _activity$channelData4.customEvent) === _Constants.Constants.String && (activity === null || activity === void 0 ? void 0 : (_activity$channelData5 = activity.channelData) === null || _activity$channelData5 === void 0 ? void 0 : (_activity$channelData6 = _activity$channelData5.metadata) === null || _activity$channelData6 === void 0 ? void 0 : (_activity$channelData7 = _activity$channelData6.customEvent) === null || _activity$channelData7 === void 0 ? void 0 : _activity$channelData7.toLowerCase()) === _Constants.Constants.true && (activity === null || activity === void 0 ? void 0 : (_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) !== _Constants.Constants.userMessageTag && typeof (activity === null || activity === void 0 ? void 0 : (_activity$channelData8 = activity.channelData) === null || _activity$channelData8 === void 0 ? void 0 : (_activity$channelData9 = _activity$channelData8.metadata) === null || _activity$channelData9 === void 0 ? void 0 : _activity$channelData9.customEventName) === _Constants.Constants.String && activity !== null && activity !== void 0 && (_activity$channelData10 = activity.channelData) !== null && _activity$channelData10 !== void 0 && (_activity$channelData11 = _activity$channelData10.metadata) !== null && _activity$channelData11 !== void 0 && _activity$channelData11.customEventValue);
19
+ };
20
+ exports.isValidCustomEvent = isValidCustomEvent;
21
+ const createCustomEventMiddleware = broadcastservice => () => next => action => {
22
+ var _action$payload;
23
+ if ((action === null || action === void 0 ? void 0 : action.type) == _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
24
+ const activity = action.payload.activity;
25
+ if (isValidCustomEvent(activity)) {
26
+ const customEvent = {
27
+ eventName: _Constants.Constants.onCustomEvent,
28
+ payload: {
29
+ messageId: activity.messageid ?? activity.id,
30
+ customEventName: activity.channelData.metadata.customEventName,
31
+ customEventValue: activity.channelData.metadata.customEventValue
32
+ }
33
+ };
34
+ broadcastservice.postMessage(customEvent);
35
+ return;
36
+ }
37
+ }
38
+ return next(action);
39
+ };
40
+ var _default = createCustomEventMiddleware;
41
+ exports.default = _default;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createQueueOverflowMiddleware = void 0;
7
+ var _WebChatActionType = require("../../enums/WebChatActionType");
8
+ var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
9
+ var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
10
+ var _LiveChatWidgetActionType = require("../../../../../contexts/common/LiveChatWidgetActionType");
11
+ var _createReducer = require("../../../../../contexts/createReducer");
12
+ var _utils = require("../../../../../common/utils");
13
+ const queueOverflowHandlingHelper = async (state, dispatch) => {
14
+ const {
15
+ appStates
16
+ } = (0, _createReducer.executeReducer)(state, {
17
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
18
+ payload: undefined
19
+ });
20
+ if (!appStates.chatDisconnectEventReceived) {
21
+ dispatch({
22
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
23
+ payload: true
24
+ });
25
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
26
+ Event: _TelemetryConstants.TelemetryEvent.QueueOverflowEvent,
27
+ Description: "Set chat disconnect event received."
28
+ });
29
+ }
30
+ };
31
+ const createQueueOverflowMiddleware = (state, dispatch) => () => next => action => {
32
+ var _action$payload;
33
+ if ((action === null || action === void 0 ? void 0 : action.type) == _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
34
+ const activity = action.payload.activity;
35
+ if ((0, _utils.isEndConversationDueToOverflowActivity)(activity)) {
36
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
37
+ Event: _TelemetryConstants.TelemetryEvent.QueueOverflowEvent,
38
+ Description: "Queue overflow event received."
39
+ });
40
+ queueOverflowHandlingHelper(state, dispatch);
41
+ }
42
+ }
43
+ return next(action);
44
+ };
45
+ exports.createQueueOverflowMiddleware = createQueueOverflowMiddleware;
@@ -0,0 +1 @@
1
+ "use strict";
@@ -52,5 +52,7 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
52
52
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 42] = "SET_SURVEY_MODE";
53
53
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 43] = "SET_CONFIRMATION_STATE";
54
54
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 44] = "SET_POST_CHAT_PARTICIPANT_TYPE";
55
- LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 45] = "GET_IN_MEMORY_STATE";
55
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_ENABLED"] = 45] = "SET_CONVERSATIONAL_SURVEY_ENABLED";
56
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_DISPLAY"] = 46] = "SET_CONVERSATIONAL_SURVEY_DISPLAY";
57
+ LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 47] = "GET_IN_MEMORY_STATE";
56
58
  })(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
@@ -83,7 +83,9 @@ const getLiveChatWidgetContextInitialState = props => {
83
83
  conversationEndedBy: _Constants.ConversationEndEntity.NotSet,
84
84
  chatDisconnectEventReceived: false,
85
85
  selectedSurveyMode: null,
86
- postChatParticipantType: undefined
86
+ postChatParticipantType: undefined,
87
+ isConversationalSurvey: false,
88
+ isConversationalSurveyEnabled: false
87
89
  },
88
90
  uiStates: {
89
91
  showConfirmationPane: false,
@@ -656,6 +656,36 @@ const reducer = (state, action) => {
656
656
  postChatParticipantType: action.payload
657
657
  }
658
658
  };
659
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_ENABLED:
660
+ inMemory = {
661
+ ...inMemory,
662
+ appStates: {
663
+ ...inMemory.appStates,
664
+ isConversationalSurveyEnabled: action.payload
665
+ }
666
+ };
667
+ return {
668
+ ...state,
669
+ appStates: {
670
+ ...state.appStates,
671
+ isConversationalSurveyEnabled: action.payload
672
+ }
673
+ };
674
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY:
675
+ inMemory = {
676
+ ...inMemory,
677
+ appStates: {
678
+ ...inMemory.appStates,
679
+ isConversationalSurvey: action.payload
680
+ }
681
+ };
682
+ return {
683
+ ...state,
684
+ appStates: {
685
+ ...state.appStates,
686
+ isConversationalSurvey: action.payload
687
+ }
688
+ };
659
689
  case _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE:
660
690
  return inMemory;
661
691
  default:
@@ -27,7 +27,7 @@ const shouldShowEmailTranscriptPane = state => {
27
27
  };
28
28
  exports.shouldShowEmailTranscriptPane = shouldShowEmailTranscriptPane;
29
29
  const shouldShowWebChatContainer = state => {
30
- return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.InActive;
30
+ return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.InActive || state.appStates.conversationState === _ConversationState.ConversationState.Postchat && state.appStates.isConversationalSurveyEnabled && state.appStates.isConversationalSurvey;
31
31
  };
32
32
  exports.shouldShowWebChatContainer = shouldShowWebChatContainer;
33
33
  const shouldShowLoadingPane = state => {
@@ -60,7 +60,7 @@ const shouldShowConfirmationPane = state => {
60
60
  };
61
61
  exports.shouldShowConfirmationPane = shouldShowConfirmationPane;
62
62
  const shouldShowPostChatSurveyPane = state => {
63
- return state.appStates.conversationState === _ConversationState.ConversationState.Postchat;
63
+ return state.appStates.conversationState === _ConversationState.ConversationState.Postchat && !state.appStates.isConversationalSurvey;
64
64
  };
65
65
  exports.shouldShowPostChatSurveyPane = shouldShowPostChatSurveyPane;
66
66
  const shouldShowCallingContainer = state => {