@microsoft/omnichannel-chat-widget 1.8.2-main.5199342 → 1.8.2-main.d82a79b

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 (62) hide show
  1. package/README.md +2 -0
  2. package/lib/cjs/common/Constants.js +11 -3
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +1 -0
  4. package/lib/cjs/common/utils.js +7 -1
  5. package/lib/cjs/components/draggable/DraggableChatWidget.js +16 -1
  6. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
  7. package/lib/cjs/components/livechatwidget/common/endChat.js +18 -7
  8. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +30 -1
  9. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +18 -1
  10. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +31 -7
  11. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +15 -2
  12. package/lib/cjs/components/livechatwidget/common/startChat.js +6 -4
  13. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +22 -11
  14. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +18 -14
  15. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +4 -3
  16. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +12 -6
  17. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +45 -0
  18. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +3 -1
  19. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
  20. package/lib/cjs/contexts/createReducer.js +30 -0
  21. package/lib/cjs/controller/componentController.js +2 -2
  22. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
  23. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
  24. package/lib/cjs/firstresponselatency/util.js +60 -31
  25. package/lib/cjs/plugins/newMessageEventHandler.js +12 -6
  26. package/lib/esm/common/Constants.js +9 -2
  27. package/lib/esm/common/telemetry/TelemetryConstants.js +1 -0
  28. package/lib/esm/common/utils.js +4 -0
  29. package/lib/esm/components/draggable/DraggableChatWidget.js +16 -1
  30. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
  31. package/lib/esm/components/livechatwidget/common/endChat.js +18 -7
  32. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +30 -1
  33. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +16 -0
  34. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +33 -9
  35. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +16 -3
  36. package/lib/esm/components/livechatwidget/common/startChat.js +6 -4
  37. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +22 -11
  38. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +18 -14
  39. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +4 -4
  40. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +12 -6
  41. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +38 -0
  42. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +3 -1
  43. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
  44. package/lib/esm/contexts/createReducer.js +30 -0
  45. package/lib/esm/controller/componentController.js +2 -2
  46. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
  47. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
  48. package/lib/esm/firstresponselatency/util.js +57 -29
  49. package/lib/esm/plugins/newMessageEventHandler.js +12 -6
  50. package/lib/types/common/Constants.d.ts +8 -2
  51. package/lib/types/common/telemetry/TelemetryConstants.d.ts +1 -0
  52. package/lib/types/common/utils.d.ts +5 -0
  53. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -0
  54. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.d.ts +1 -1
  55. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.d.ts +1 -1
  56. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +5 -0
  57. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -0
  58. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
  59. package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +2 -2
  60. package/lib/types/firstresponselatency/util.d.ts +17 -0
  61. package/lib/types/plugins/newMessageEventHandler.d.ts +1 -1
  62. package/package.json +4 -4
@@ -17,14 +17,13 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
17
17
  function FirstResponseLatencyTracker() {
18
18
  _classCallCheck(this, FirstResponseLatencyTracker);
19
19
  _defineProperty(this, "isABotConversation", false);
20
- _defineProperty(this, "isStarted", false);
21
- _defineProperty(this, "isEnded", false);
20
+ _defineProperty(this, "isTracking", false);
22
21
  _defineProperty(this, "startTrackingMessage", void 0);
23
22
  _defineProperty(this, "stopTrackingMessage", void 0);
24
23
  _defineProperty(this, "isReady", false);
24
+ _defineProperty(this, "trackingTimeoutId", void 0);
25
25
  _defineProperty(this, "offlineNetworkListener", _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.TelemetryEvent.NetworkDisconnected).subscribe(() => {
26
- this.isStarted = false;
27
- this.isEnded = false;
26
+ this.isTracking = false;
28
27
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
29
28
  Event: _TelemetryConstants.TelemetryEvent.MessageStopLapTrackError,
30
29
  Description: "Tracker Stopped due to network disconnection"
@@ -72,7 +71,7 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
72
71
  value: function startTracking(payload) {
73
72
  if (!this.isReady) return;
74
73
  // this prevents to initiate tracking for multiple incoming messages
75
- if (this.isStarted) {
74
+ if (this.isTracking) {
76
75
  return;
77
76
  }
78
77
  // this is to ensure we track only messages where bot is engaged
@@ -80,10 +79,24 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
80
79
  return;
81
80
  }
82
81
  // control of states to prevent clashing of messages
83
- this.isStarted = true;
84
- this.isEnded = false;
82
+ this.isTracking = true;
85
83
  // The idea of using types is to enrich telemetry data
86
84
  this.startTrackingMessage = this.createTrackingMessage(payload, "userMessage");
85
+
86
+ // Start a 5-second timeout to auto-stop tracking if not stopped
87
+ if (this.trackingTimeoutId) {
88
+ clearTimeout(this.trackingTimeoutId);
89
+ }
90
+ this.trackingTimeoutId = setTimeout(() => {
91
+ // this means the start process is in progress, but the end wasn't called within the time limit
92
+ if (this.isTracking) {
93
+ // Reset state variables and skip stopTracking
94
+ this.isTracking = false;
95
+ this.startTrackingMessage = undefined;
96
+ this.stopTrackingMessage = undefined;
97
+ this.trackingTimeoutId = undefined;
98
+ }
99
+ }, 5000);
87
100
  }
88
101
  }, {
89
102
  key: "handleAgentMessage",
@@ -99,13 +112,16 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
99
112
  value: function stopTracking(payload) {
100
113
  var _this$stopTrackingMes, _this$startTrackingMe;
101
114
  // this prevents execution for multiple incoming messages from the bot.
102
- if (this.isEnded && !this.isStarted) {
115
+ if (!this.isTracking) {
103
116
  return;
104
117
  }
105
-
118
+ // Clear the timeout if it exists
119
+ if (this.trackingTimeoutId) {
120
+ clearTimeout(this.trackingTimeoutId);
121
+ this.trackingTimeoutId = undefined;
122
+ }
106
123
  // control of states to prevent clashing of messages
107
- this.isEnded = true;
108
- this.isStarted = false;
124
+ this.isTracking = false;
109
125
 
110
126
  // The idea of using types is to enrich telemetry data
111
127
  this.stopTrackingMessage = this.createTrackingMessage(payload, "botMessage");
@@ -160,12 +176,16 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
160
176
  if (!payload || !payload.Id) {
161
177
  throw new Error("Invalid payload");
162
178
  }
163
- if (!this.isMessageFromValidSender(payload)) return;
164
- if (this.isABotConversation && this.isStarted) {
179
+
180
+ // Only allow stopTracking if sender is valid and tracking is active
181
+ if (!this.isMessageFromValidSender(payload)) {
182
+ // Do not change isTracking or stopTrackingMessage
183
+ return;
184
+ }
185
+ if (this.isABotConversation && this.isTracking) {
165
186
  this.stopTracking(payload);
166
187
  }
167
188
  } catch (e) {
168
- console.error("FRL : error while trying to stop the tracker", e);
169
189
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
170
190
  Event: _TelemetryConstants.TelemetryEvent.MessageStopLapTrackError,
171
191
  Description: "Error while stopping the clock",
@@ -174,11 +194,6 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
174
194
  payload: payload
175
195
  }
176
196
  });
177
- //reset state
178
- this.startTrackingMessage = undefined;
179
- this.stopTrackingMessage = undefined;
180
- this.isStarted = false;
181
- this.isEnded = false;
182
197
  }
183
198
  }
184
199
  }, {
@@ -186,10 +201,13 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
186
201
  value: function deregister() {
187
202
  // Reset State
188
203
  this.isABotConversation = false;
189
- this.isStarted = false;
190
- this.isEnded = false;
204
+ this.isTracking = false;
191
205
  this.startTrackingMessage = undefined;
192
206
  this.stopTrackingMessage = undefined;
207
+ if (this.trackingTimeoutId) {
208
+ clearTimeout(this.trackingTimeoutId);
209
+ this.trackingTimeoutId = undefined;
210
+ }
193
211
  this.offlineNetworkListener.unsubscribe();
194
212
  this.fmltrackingListener.unsubscribe();
195
213
  this.rehydrateListener.unsubscribe();
@@ -3,43 +3,72 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.polyfillMessagePayloadForEvent = exports.isHistoryMessage = exports.getScenarioType = exports.createTrackingMessage = exports.buildMessagePayload = void 0;
6
+ exports.polyfillMessagePayloadForEvent = exports.isHistoryMessage = exports.getScenarioType = exports.extractTimestampFromId = exports.createTrackingMessage = exports.buildMessagePayload = void 0;
7
7
  var _Constants = require("./Constants");
8
8
  var _Constants2 = require("../common/Constants");
9
+ const DELTA_WITHIN_LIMITS_IN_MS = 250;
10
+
11
+ /**
12
+ * Determines whether a given activity is a historical message.
13
+ *
14
+ * This function checks if the activity is a message type and uses a combination
15
+ * of legacy tags and timestamp-based logic to determine if the message is historical.
16
+ *
17
+ * @param {IActivity} activity - The activity object to evaluate.
18
+ * @param {number} startTime - The start time (in milliseconds since epoch) to compare against.
19
+ * @returns {boolean} - Returns true if the activity is a historical message, false otherwise.
20
+ *
21
+ * Logic:
22
+ * - If the activity type is not a message, it is not historical.
23
+ * - If the activity contains a legacy history message tag, it is considered historical.
24
+ * - Otherwise, the function extracts a timestamp from the activity ID using `extractTimestampFromId`.
25
+ * - If the ID is valid and the timestamp is older than the start time, the message is historical.
26
+ */
9
27
  const isHistoryMessage = (activity, startTime) => {
10
- try {
11
- if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants2.Constants.message) {
12
- var _activity$channelData, _activity$channelData2;
13
- // this is an old piece of code, probably no longer relevant
14
- if (activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(_Constants2.Constants.historyMessageTag)) return true;
28
+ var _activity$channelData;
29
+ // Only process message activities
30
+ if ((activity === null || activity === void 0 ? void 0 : activity.type) !== _Constants2.Constants.message) {
31
+ return false;
32
+ }
15
33
 
16
- // Id is an epoch time in milliseconds , in utc format, for some reason is in a string format
17
- if (activity !== null && activity !== void 0 && activity.id) {
18
- /// activity.id is an string that contains epoch time in milliseconds
19
- const activityId = parseInt(activity === null || activity === void 0 ? void 0 : activity.id);
34
+ // Prioritize legacy history tag
35
+ if (activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && _activity$channelData.tags && activity.channelData.tags.includes(_Constants2.Constants.historyMessageTag)) {
36
+ return true;
37
+ }
38
+ const activityId = extractTimestampFromId(activity);
39
+ const isValidId = !isNaN(activityId) && activityId > 0;
40
+ const difference = startTime - activityId;
41
+ // Only consider historical if activityId < startTime and difference >= DELTA_WITHIN_LIMITS_IN_MS
42
+ const isOlderThanStartTime = activityId < startTime && difference >= DELTA_WITHIN_LIMITS_IN_MS;
43
+ const isHistoryById = isValidId && isOlderThanStartTime;
44
+ return isHistoryById;
45
+ };
46
+ exports.isHistoryMessage = isHistoryMessage;
47
+ const extractTimestampFromId = activity => {
48
+ const id = (activity === null || activity === void 0 ? void 0 : activity.id) ?? "";
20
49
 
21
- // if the activity id is not a number, we default to new message
22
- if (isNaN(activityId)) {
23
- return false;
24
- }
50
+ // Helper function to get timestamp fallback
51
+ const getTimestampFallback = () => {
52
+ const timestamp = new Date((activity === null || activity === void 0 ? void 0 : activity.timestamp) ?? "").getTime();
53
+ return isNaN(timestamp) ? 0 : timestamp;
54
+ };
25
55
 
26
- // if the activity id is less than the start time, it means that the message is a history message
27
- if (activityId < startTime) {
28
- return true;
29
- }
30
- }
31
- // anything else will be considered a new message
32
- return false;
33
- }
34
- } catch (e) {
35
- // if there is an error in parsing the activity id, we will consider it a new message
36
- console.error("Error in parsing activity id: ", e);
56
+ // Check if ID looks like a UUID (contains dashes or is very long)
57
+ const UUID_LENGTH_THRESHOLD = 13; // Threshold to distinguish UUIDs from epoch timestamps
58
+ if (id.includes("-") || id.length > UUID_LENGTH_THRESHOLD) {
59
+ // Likely UUID, use timestamp instead
60
+ return getTimestampFallback();
37
61
  }
38
- return false;
62
+ const activityId = parseInt(id);
63
+ // if activity id is not a number, then we use timestamp field
64
+ if (isNaN(activityId)) {
65
+ return getTimestampFallback();
66
+ }
67
+ return activityId;
39
68
  };
40
- exports.isHistoryMessage = isHistoryMessage;
69
+ exports.extractTimestampFromId = extractTimestampFromId;
41
70
  const buildMessagePayload = (activity, userId) => {
42
- var _text, _text2, _activity$channelData3, _activity$from;
71
+ var _text, _text2, _activity$channelData2, _activity$from;
43
72
  return {
44
73
  // To identify hidden contents vs empty content
45
74
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -47,7 +76,7 @@ const buildMessagePayload = (activity, userId) => {
47
76
  type: activity === null || activity === void 0 ? void 0 : activity.type,
48
77
  timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
49
78
  userId: userId,
50
- tags: activity === null || activity === void 0 ? void 0 : (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 ? void 0 : _activity$channelData3.tags,
79
+ tags: (activity === null || activity === void 0 ? void 0 : (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.tags) || [],
51
80
  messageType: "",
52
81
  Id: activity === null || activity === void 0 ? void 0 : activity.id,
53
82
  role: activity === null || activity === void 0 ? void 0 : (_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role,
@@ -73,9 +102,9 @@ const polyfillMessagePayloadForEvent = (activity, payload, conversationId) => {
73
102
  };
74
103
  exports.polyfillMessagePayloadForEvent = polyfillMessagePayloadForEvent;
75
104
  const getScenarioType = activity => {
76
- var _activity$from3, _activity$channelData4;
105
+ var _activity$from3, _activity$channelData3;
77
106
  const role = activity === null || activity === void 0 ? void 0 : (_activity$from3 = activity.from) === null || _activity$from3 === void 0 ? void 0 : _activity$from3.role;
78
- const tags = activity === null || activity === void 0 ? void 0 : (_activity$channelData4 = activity.channelData) === null || _activity$channelData4 === void 0 ? void 0 : _activity$channelData4.tags;
107
+ const tags = activity === null || activity === void 0 ? void 0 : (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 ? void 0 : _activity$channelData3.tags;
79
108
  if (role === _Constants2.Constants.userMessageTag) {
80
109
  return _Constants.ScenarioType.UserSendMessageStrategy;
81
110
  }
@@ -12,13 +12,13 @@ var _Constants2 = require("../common/Constants");
12
12
  var _FirstResponseLatencyTracker = require("../firstresponselatency/FirstResponseLatencyTracker");
13
13
  var _TelemetryHelper = require("../common/telemetry/TelemetryHelper");
14
14
  var _TelemetryManager = require("../common/telemetry/TelemetryManager");
15
- const createOnNewAdapterActivityHandler = (chatId, userId) => {
15
+ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
16
16
  // Hooking the message tracker in the listener, a bit invasive but easier to control.
17
17
  const firstResponseLatencyTracker = new _FirstResponseLatencyTracker.FirstResponseLatencyTracker();
18
18
  // epoch time in utc for when start to listen.
19
19
  // We dont longer have a mechanism to know if a message is history or new, so any message older than the time we start listening will be considered a history message.
20
20
  // this is a workaround for the fact that we dont have a way to identify if a message is history or new, and it will provide consistency across different scenarios
21
- const startTime = new Date().getTime();
21
+
22
22
  let isHistoryMessageReceivedEventRaised = false;
23
23
  const onNewAdapterActivityHandler = activity => {
24
24
  raiseMessageEvent(activity);
@@ -41,6 +41,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
41
41
  });
42
42
  };
43
43
  const systemMessageStrategy = activity => {
44
+ var _TelemetryManager$Int3;
44
45
  const payload = (0, _util.buildMessagePayload)(activity, userId);
45
46
  payload.messageType = _Constants2.Constants.systemMessageTag;
46
47
  if ((0, _util.isHistoryMessage)(activity, startTime)) {
@@ -48,6 +49,11 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
48
49
  historyMessageStrategy((0, _util.polyfillMessagePayloadForEvent)(activity, payload, (_TelemetryManager$Int2 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int2 === void 0 ? void 0 : _TelemetryManager$Int2.conversationId));
49
50
  return;
50
51
  }
52
+ const newMessageReceivedEvent = {
53
+ eventName: _TelemetryConstants.BroadcastEvent.NewMessageReceived,
54
+ payload: (0, _util.polyfillMessagePayloadForEvent)(activity, payload, (_TelemetryManager$Int3 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int3 === void 0 ? void 0 : _TelemetryManager$Int3.conversationId)
55
+ };
56
+ _omnichannelChatComponents.BroadcastService.postMessage(newMessageReceivedEvent);
51
57
  _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
52
58
  Event: _TelemetryConstants.TelemetryEvent.SystemMessageReceived,
53
59
  Description: "System message received"
@@ -83,20 +89,20 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
83
89
  return true;
84
90
  };
85
91
  const receivedMessageStrategy = activity => {
86
- var _TelemetryManager$Int4;
92
+ var _TelemetryManager$Int5;
87
93
  if (!isValidMessage(activity)) return;
88
94
  const isHistoryMessageReceived = (0, _util.isHistoryMessage)(activity, startTime);
89
95
  const payload = (0, _util.buildMessagePayload)(activity, userId);
90
96
  payload.messageType = _Constants2.Constants.userMessageTag;
91
97
  if (isHistoryMessageReceived) {
92
- var _TelemetryManager$Int3;
93
- historyMessageStrategy((0, _util.polyfillMessagePayloadForEvent)(activity, payload, (_TelemetryManager$Int3 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int3 === void 0 ? void 0 : _TelemetryManager$Int3.conversationId));
98
+ var _TelemetryManager$Int4;
99
+ historyMessageStrategy((0, _util.polyfillMessagePayloadForEvent)(activity, payload, (_TelemetryManager$Int4 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int4 === void 0 ? void 0 : _TelemetryManager$Int4.conversationId));
94
100
  return;
95
101
  }
96
102
  firstResponseLatencyTracker.stopClock(payload);
97
103
  const newMessageReceivedEvent = {
98
104
  eventName: _TelemetryConstants.BroadcastEvent.NewMessageReceived,
99
- payload: (0, _util.polyfillMessagePayloadForEvent)(activity, payload, (_TelemetryManager$Int4 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int4 === void 0 ? void 0 : _TelemetryManager$Int4.conversationId)
105
+ payload: (0, _util.polyfillMessagePayloadForEvent)(activity, payload, (_TelemetryManager$Int5 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int5 === void 0 ? void 0 : _TelemetryManager$Int5.conversationId)
100
106
  };
101
107
  _omnichannelChatComponents.BroadcastService.postMessage(newMessageReceivedEvent);
102
108
  _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
@@ -16,6 +16,9 @@ _defineProperty(Constants, "channelMessageTag", "channel");
16
16
  _defineProperty(Constants, "historyMessageTag", "history");
17
17
  _defineProperty(Constants, "agentEndConversationMessageTag", "agentendconversation");
18
18
  _defineProperty(Constants, "supervisorForceCloseMessageTag", "supervisorforceclosedconversation");
19
+ _defineProperty(Constants, "endConversationalSurveyMessageTag", "endconversationalsurvey");
20
+ _defineProperty(Constants, "startConversationalSurveyMessageTag", "startconversationalsurvey");
21
+ _defineProperty(Constants, "c2ConversationalSurveyMessageTag", "c2conversationalsurvey");
19
22
  _defineProperty(Constants, "receivedMessageClassName", "ms_lcw_webchat_received_message");
20
23
  _defineProperty(Constants, "sentMessageClassName", "ms_lcw_webchat_sent_message");
21
24
  _defineProperty(Constants, "webchatChannelId", "webchat");
@@ -105,8 +108,7 @@ _defineProperty(Constants, "TargetRelationshipAttributes", "noopener noreferrer"
105
108
  // Markdown icons
106
109
  _defineProperty(Constants, "OpenLinkIconCssClass", "webchat__render-markdown__external-link-icon");
107
110
  // internet connection test
108
- _defineProperty(Constants, "internetConnectionTestUrl", "https://ocsdk-prod.azureedge.net/public/connecttest.txt");
109
- _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect Test");
111
+ _defineProperty(Constants, "internetConnectionTestPath", "/livechatwidget/version.txt");
110
112
  _defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
111
113
  _defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
112
114
  _defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
@@ -122,6 +124,7 @@ _defineProperty(Constants, "InitContextParamsResponse", "initContextParamsRespon
122
124
  _defineProperty(Constants, "OCOriginalMessageId", "OriginalMessageId");
123
125
  _defineProperty(Constants, "WebchatSequenceIdAttribute", "webchat:sequence-id");
124
126
  _defineProperty(Constants, "MessageSequenceIdOverride", "MessageSequenceIdOverride");
127
+ _defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
125
128
  export const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
126
129
  _classCallCheck(this, Regex);
127
130
  }), _defineProperty(_class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\])$"), _class);
@@ -220,6 +223,10 @@ export let ConversationMode;
220
223
  ConversationMode["Regular"] = "192350000";
221
224
  ConversationMode["Persistent"] = "192350001";
222
225
  })(ConversationMode || (ConversationMode = {}));
226
+ export let SurveyProvider;
227
+ (function (SurveyProvider) {
228
+ SurveyProvider["MicrosoftCopilotStudio"] = "600990001";
229
+ })(SurveyProvider || (SurveyProvider = {}));
223
230
  export let LiveWorkItemState;
224
231
  (function (LiveWorkItemState) {
225
232
  LiveWorkItemState["Active"] = "Active";
@@ -184,6 +184,7 @@ export let TelemetryEvent;
184
184
  TelemetryEvent["BotAuthActivityUndefinedSignInId"] = "BotAuthActivityUndefinedSignInId";
185
185
  TelemetryEvent["ThirdPartyCookiesBlocked"] = "ThirdPartyCookiesBlocked";
186
186
  TelemetryEvent["ParticipantsRemovedEvent"] = "ParticipantsRemovedEvent";
187
+ TelemetryEvent["QueueOverflowEvent"] = "QueueOverflowEvent";
187
188
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
188
189
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
189
190
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
@@ -453,4 +453,8 @@ export function getDeviceType() {
453
453
  } else {
454
454
  return "standard";
455
455
  }
456
+ }
457
+ export function isEndConversationDueToOverflowActivity(activity) {
458
+ var _activity$channelData, _activity$channelData2;
459
+ return (activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.tags) && Array.isArray(activity === null || activity === void 0 ? void 0 : (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.tags) && activity.channelData.tags.includes(Constants.EndConversationDueToOverflow);
456
460
  }
@@ -25,8 +25,11 @@ const DraggableChatWidget = props => {
25
25
  };
26
26
  const calculateOffsetsWithinViewport = useCallback((id, offset, delta) => {
27
27
  const draggableElement = document.getElementById(id);
28
+ if (isNullOrUndefined(draggableElement)) {
29
+ return;
30
+ }
28
31
  const positionRelativeToViewport = draggableElement.getBoundingClientRect();
29
- if (isNullOrUndefined(draggableElement) || isNullOrUndefined(positionRelativeToViewport) || isNullOrUndefined(offset.offsetLeft) || isNullOrUndefined(offset.offsetTop)) {
32
+ if (isNullOrUndefined(positionRelativeToViewport) || isNullOrUndefined(offset.offsetLeft) || isNullOrUndefined(offset.offsetTop)) {
30
33
  return;
31
34
  }
32
35
  let offsetLeft = offset.offsetLeft;
@@ -68,6 +71,9 @@ const DraggableChatWidget = props => {
68
71
  }
69
72
  const cacheInitialPosition = () => {
70
73
  const draggableElement = document.getElementById(props.elementId);
74
+ if (isNullOrUndefined(draggableElement)) {
75
+ return;
76
+ }
71
77
  const offsetLeft = draggableElement.offsetLeft;
72
78
  const offsetTop = draggableElement.offsetTop;
73
79
  setInitialPosition({
@@ -77,6 +83,9 @@ const DraggableChatWidget = props => {
77
83
  };
78
84
  const calculateOffsets = () => {
79
85
  const draggableElement = document.getElementById(props.elementId);
86
+ if (isNullOrUndefined(draggableElement)) {
87
+ return;
88
+ }
80
89
  const offsetLeft = draggableElement.offsetLeft;
81
90
  const offsetTop = draggableElement.offsetTop;
82
91
 
@@ -111,6 +120,9 @@ const DraggableChatWidget = props => {
111
120
  resetPosition(initialPosition);
112
121
  } else if (state.appStates.isMinimized) {
113
122
  const draggableElement = document.getElementById(props.elementId);
123
+ if (isNullOrUndefined(draggableElement)) {
124
+ return;
125
+ }
114
126
  const offsetLeft = draggableElement.offsetLeft;
115
127
  const offsetTop = draggableElement.offsetTop;
116
128
  if (!cachedPosition) {
@@ -135,6 +147,9 @@ const DraggableChatWidget = props => {
135
147
 
136
148
  // Update position via DOM manipulation to prevent <Stack/> continuously rendering on style change causing high CPU spike
137
149
  const draggableElement = document.getElementById(props.elementId);
150
+ if (isNullOrUndefined(draggableElement)) {
151
+ return;
152
+ }
138
153
  repositionElement(draggableElement, offsetLeft, offsetTop);
139
154
  setPosition({
140
155
  offsetLeft,
@@ -7,34 +7,47 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
7
7
  import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
8
8
  import { executeReducer } from "../../../contexts/createReducer";
9
9
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
10
- const isInternetConnected = async () => {
10
+ const getRegionBasedInternetTestUrl = widgetSnippet => {
11
+ var _widgetSnippet$match;
12
+ if (!widgetSnippet) {
13
+ return null;
14
+ }
15
+ const widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
16
+ const baseCdnUrl = (_widgetSnippet$match = widgetSnippet.match(widgetSnippetSourceRegex)) === null || _widgetSnippet$match === void 0 ? void 0 : _widgetSnippet$match[1];
17
+ return baseCdnUrl ? `${baseCdnUrl}${Constants.internetConnectionTestPath}` : null;
18
+ };
19
+ const isInternetConnected = async testUrl => {
11
20
  try {
12
- const response = await fetch(Constants.internetConnectionTestUrl);
13
- const text = await response.text();
14
- return text === Constants.internetConnectionTestUrlText;
21
+ const response = await fetch(testUrl, {
22
+ method: "GET",
23
+ cache: "no-cache"
24
+ });
25
+ return response.ok;
15
26
  } catch {
16
27
  return false;
17
28
  }
18
29
  };
19
30
  export const createInternetConnectionChangeHandler = async state => {
20
31
  const handler = async () => {
21
- const connected = await isInternetConnected();
32
+ var _inMemoryState$domain, _inMemoryState$domain2;
22
33
  const inMemoryState = executeReducer(state, {
23
34
  type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
24
35
  payload: null
25
36
  });
37
+ const testUrl = getRegionBasedInternetTestUrl((_inMemoryState$domain = inMemoryState.domainStates.liveChatConfig) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.LiveWSAndLiveChatEngJoin) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.msdyn_widgetsnippet);
38
+ const connected = testUrl ? await isInternetConnected(testUrl) : false;
26
39
  if (!connected) {
27
- var _inMemoryState$domain, _inMemoryState$domain2;
40
+ var _inMemoryState$domain3, _inMemoryState$domain4;
28
41
  TelemetryHelper.logActionEvent(LogLevel.WARN, {
29
42
  Event: TelemetryEvent.NetworkDisconnected
30
43
  });
31
- NotificationHandler.notifyError(NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.middlewareLocalizedTexts) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
44
+ NotificationHandler.notifyError(NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.middlewareLocalizedTexts) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
32
45
  } else {
33
- var _inMemoryState$domain3, _inMemoryState$domain4;
46
+ var _inMemoryState$domain5, _inMemoryState$domain6;
34
47
  TelemetryHelper.logActionEvent(LogLevel.WARN, {
35
48
  Event: TelemetryEvent.NetworkReconnected
36
49
  });
37
- NotificationHandler.notifySuccess(NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.middlewareLocalizedTexts) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
50
+ NotificationHandler.notifySuccess(NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain5 = inMemoryState.domainStates) === null || _inMemoryState$domain5 === void 0 ? void 0 : (_inMemoryState$domain6 = _inMemoryState$domain5.middlewareLocalizedTexts) === null || _inMemoryState$domain6 === void 0 ? void 0 : _inMemoryState$domain6.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
38
51
  BroadcastService.postMessage({
39
52
  eventName: BroadcastEvent.NetworkReconnected
40
53
  });
@@ -16,7 +16,7 @@ import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
16
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
17
  const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
18
18
  try {
19
- var _conversationDetails$, _state$domainStates, _state$appStates3;
19
+ var _conversationDetails$, _state$domainStates, _state$appStates5;
20
20
  const {
21
21
  chatConfig
22
22
  } = props;
@@ -27,7 +27,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
27
27
 
28
28
  // Use Case: When post chat is not configured
29
29
  if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : (_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === Constants.false) {
30
- var _state$appStates;
30
+ var _state$appStates, _state$appStates2, _state$appStates3;
31
31
  // If ended by customer, just close chat
32
32
  if ((state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.conversationEndedBy) === ConversationEndEntity.Customer) {
33
33
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
@@ -38,6 +38,13 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
38
38
  }
39
39
 
40
40
  // Use Case: If ended by Agent, stay chat in InActive state
41
+ let isConversationalSurveyEnabled = state.appStates.isConversationalSurveyEnabled;
42
+ if (isConversationalSurveyEnabled && ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates3 = state.appStates) === null || _state$appStates3 === void 0 ? void 0 : _state$appStates3.conversationEndedBy) === ConversationEndEntity.Bot)) {
43
+ dispatch({
44
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
45
+ payload: ConversationState.InActive
46
+ });
47
+ }
41
48
  return;
42
49
  }
43
50
 
@@ -53,7 +60,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
53
60
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
61
  const postchatContext = (await getPostChatContext(facadeChatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
55
62
  if (postchatContext === undefined) {
56
- var _state$appStates2;
63
+ var _state$appStates4;
57
64
  BroadcastService.postMessage({
58
65
  eventName: BroadcastEvent.OnWidgetError,
59
66
  payload: {
@@ -62,7 +69,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
62
69
  });
63
70
 
64
71
  // For Customer intiated conversations, just close chat widget
65
- if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Customer) {
72
+ if ((state === null || state === void 0 ? void 0 : (_state$appStates4 = state.appStates) === null || _state$appStates4 === void 0 ? void 0 : _state$appStates4.conversationEndedBy) === ConversationEndEntity.Customer) {
66
73
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
67
74
  Event: TelemetryEvent.PrepareEndChat,
68
75
  Description: PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat
@@ -80,11 +87,11 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
80
87
  }
81
88
 
82
89
  // Log PrepareEndChat if conversation ended by customer (bot and agent cases are handled in LiveChatWidgetStateful.tsx)
83
- if (state !== null && state !== void 0 && (_state$appStates3 = state.appStates) !== null && _state$appStates3 !== void 0 && _state$appStates3.conversationEndedBy) {
84
- var _state$appStates4;
90
+ if (state !== null && state !== void 0 && (_state$appStates5 = state.appStates) !== null && _state$appStates5 !== void 0 && _state$appStates5.conversationEndedBy) {
91
+ var _state$appStates6;
85
92
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
86
93
  Event: TelemetryEvent.PrepareEndChat,
87
- Description: `${PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat} ${state === null || state === void 0 ? void 0 : (_state$appStates4 = state.appStates) === null || _state$appStates4 === void 0 ? void 0 : _state$appStates4.conversationEndedBy}.`
94
+ Description: `${PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat} ${state === null || state === void 0 ? void 0 : (_state$appStates6 = state.appStates) === null || _state$appStates6 === void 0 ? void 0 : _state$appStates6.conversationEndedBy}.`
88
95
  });
89
96
  }
90
97
  const persistentEnabled = isPersistentEnabled(chatConfig);
@@ -256,6 +263,10 @@ export const closeChatStateCleanUp = dispatch => {
256
263
  payload: undefined
257
264
  });
258
265
  // dispatch({ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE, payload: ConversationState.Closed });
266
+ dispatch({
267
+ type: LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY,
268
+ payload: false
269
+ });
259
270
  dispatch({
260
271
  type: LiveChatWidgetActionType.SET_RECONNECT_ID,
261
272
  payload: undefined
@@ -32,6 +32,9 @@ import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller
32
32
  import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
33
33
  import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
34
34
  import { Constants } from "../../../common/Constants";
35
+ import { ConversationState } from "../../../contexts/common/ConversationState";
36
+ import { executeReducer } from "../../../contexts/createReducer";
37
+ import { createQueueOverflowMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware";
35
38
 
36
39
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
40
  export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
@@ -53,6 +56,20 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
53
56
  let webChatStore = WebChatStoreLoader.store;
54
57
  if (!webChatStore) {
55
58
  var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain7;
59
+ const addConversationalSurveyTagsCallback = action => {
60
+ var _inMemoryState$appSta;
61
+ const inMemoryState = executeReducer(state, {
62
+ type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
63
+ payload: null
64
+ });
65
+ const isConversationalSurvey = (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.isConversationalSurvey;
66
+ if (isConversationalSurvey) {
67
+ if (!action.payload.activity.channelData.tags.includes(Constants.c2ConversationalSurveyMessageTag)) {
68
+ action.payload.activity.channelData.tags.push(Constants.c2ConversationalSurveyMessageTag);
69
+ }
70
+ }
71
+ return action;
72
+ };
56
73
  const conversationEndCallback = async () => {
57
74
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
75
  const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
@@ -82,9 +99,21 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
82
99
  });
83
100
  }
84
101
  };
102
+ const startConversationalSurveyCallback = async () => {
103
+ dispatch({
104
+ type: LiveChatWidgetActionType.SET_CONVERSATIONAL_SURVEY_DISPLAY,
105
+ payload: true
106
+ });
107
+ };
108
+ const endConversationalSurveyCallback = async () => {
109
+ dispatch({
110
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
111
+ payload: ConversationState.InActive
112
+ });
113
+ };
85
114
  webChatStore = createStore({},
86
115
  //initial state
87
- preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), channelDataMiddleware, createConversationEndMiddleware(conversationEndCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, createMessageSequenceIdOverrideMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware(honorsTargetInHTMLLinks), createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware,
116
+ preProcessingMiddleware, attachmentProcessingMiddleware, createAttachmentUploadValidatorMiddleware((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), createQueueOverflowMiddleware(state, dispatch), channelDataMiddleware(addConversationalSurveyTagsCallback), createConversationEndMiddleware(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), createDataMaskingMiddleware((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), createMessageTimeStampMiddleware, createMessageSequenceIdOverrideMiddleware, gifUploadMiddleware, htmlPlayerMiddleware, htmlTextMiddleware(honorsTargetInHTMLLinks), createMaxMessageSizeValidator(localizedTexts), sanitizationMiddleware,
88
117
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
118
  ...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
90
119
  WebChatStoreLoader.store = webChatStore;
@@ -6,6 +6,22 @@ export const isPostChatSurveyEnabled = async facadeChatSDK => {
6
6
  const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
7
7
  return postChatEnabled === "true";
8
8
  };
9
+ export const getPostChatSurveyConfig = async facadeChatSDK => {
10
+ var _chatConfig$LiveWSAnd2, _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4, _chatConfig$LiveWSAnd5, _chatConfig$LiveWSAnd6, _chatConfig$LiveWSAnd7, _chatConfig$LiveWSAnd8, _chatConfig$LiveWSAnd9, _chatConfig$LiveWSAnd10;
11
+ const chatConfig = await facadeChatSDK.getLiveChatConfig();
12
+ const postChatEnabled = (_chatConfig$LiveWSAnd2 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd2 === void 0 ? void 0 : _chatConfig$LiveWSAnd2.msdyn_postconversationsurveyenable.toString().toLowerCase();
13
+ const agentSurveyMode = (_chatConfig$LiveWSAnd3 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd3 === void 0 ? void 0 : (_chatConfig$LiveWSAnd4 = _chatConfig$LiveWSAnd3.msdyn_postconversationsurveymode) === null || _chatConfig$LiveWSAnd4 === void 0 ? void 0 : _chatConfig$LiveWSAnd4.toString();
14
+ const botSurveyMode = (_chatConfig$LiveWSAnd5 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd5 === void 0 ? void 0 : (_chatConfig$LiveWSAnd6 = _chatConfig$LiveWSAnd5.msdyn_postconversationsurveybotsurveymode) === null || _chatConfig$LiveWSAnd6 === void 0 ? void 0 : _chatConfig$LiveWSAnd6.toString();
15
+ const surveyProvider = (_chatConfig$LiveWSAnd7 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd7 === void 0 ? void 0 : (_chatConfig$LiveWSAnd8 = _chatConfig$LiveWSAnd7.msdyn_surveyprovider) === null || _chatConfig$LiveWSAnd8 === void 0 ? void 0 : _chatConfig$LiveWSAnd8.toString();
16
+ const isConversationalSurveyEnabled = (_chatConfig$LiveWSAnd9 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd9 === void 0 ? void 0 : (_chatConfig$LiveWSAnd10 = _chatConfig$LiveWSAnd9.msdyn_isConversationalPostChatSurveyEnabled) === null || _chatConfig$LiveWSAnd10 === void 0 ? void 0 : _chatConfig$LiveWSAnd10.toString().toLowerCase();
17
+ return {
18
+ postChatEnabled: postChatEnabled === "true",
19
+ agentSurveyMode: agentSurveyMode,
20
+ botSurveyMode: botSurveyMode,
21
+ surveyProvider: surveyProvider,
22
+ isConversationalSurveyEnabled: isConversationalSurveyEnabled === "true"
23
+ };
24
+ };
9
25
  export const isPersistentChatEnabled = conversationMode => {
10
26
  if (isNullOrUndefined(conversationMode)) {
11
27
  return false;