@microsoft/omnichannel-chat-widget 1.8.3 → 1.8.4-main.4478bbf

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 (118) hide show
  1. package/lib/cjs/common/Constants.js +5 -0
  2. package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
  3. package/lib/cjs/common/telemetry/AppInsightsEvents.js +4 -5
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +43 -2
  5. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +26 -10
  6. package/lib/cjs/common/utils/SecureEventBus.js +307 -0
  7. package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
  8. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
  9. package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
  10. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
  11. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
  12. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +284 -0
  13. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  14. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +18 -0
  15. package/lib/cjs/components/livechatwidget/common/endChat.js +7 -1
  16. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +7 -5
  17. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  18. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  19. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
  20. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
  21. package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  22. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +12 -3
  23. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +29 -2
  24. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
  25. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +31 -5
  26. package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
  27. package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
  28. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +97 -0
  29. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  30. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
  31. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +59 -0
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +122 -0
  33. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +18 -0
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1038 -0
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +44 -0
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
  44. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  45. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  46. package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
  47. package/lib/esm/common/Constants.js +5 -0
  48. package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
  49. package/lib/esm/common/telemetry/AppInsightsEvents.js +4 -5
  50. package/lib/esm/common/telemetry/TelemetryConstants.js +41 -1
  51. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +27 -11
  52. package/lib/esm/common/utils/SecureEventBus.js +328 -0
  53. package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
  54. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
  55. package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
  56. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
  57. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
  58. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +277 -0
  59. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  60. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +11 -0
  61. package/lib/esm/components/livechatwidget/common/endChat.js +7 -1
  62. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +7 -5
  63. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  64. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  65. package/lib/esm/components/livechatwidget/common/startChat.js +7 -3
  66. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
  67. package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  68. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +13 -4
  69. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +31 -4
  70. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
  71. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +34 -5
  72. package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
  73. package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
  74. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +90 -0
  75. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  76. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  77. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +51 -0
  78. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +115 -0
  79. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
  80. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +10 -0
  81. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1060 -0
  82. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
  83. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +42 -0
  84. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
  85. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
  86. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
  87. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
  88. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
  89. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
  90. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  91. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  92. package/lib/esm/plugins/newMessageEventHandler.js +4 -1
  93. package/lib/types/common/Constants.d.ts +4 -0
  94. package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
  95. package/lib/types/common/telemetry/TelemetryConstants.d.ts +38 -2
  96. package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
  97. package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
  98. package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
  99. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
  100. package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
  101. package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
  102. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
  103. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
  104. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +7 -0
  105. package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
  106. package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
  107. package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
  108. package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
  109. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +7 -0
  110. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
  111. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
  112. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
  113. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
  114. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
  115. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
  116. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
  117. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +1 -0
  118. package/package.json +3 -3
@@ -0,0 +1,277 @@
1
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
8
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
9
+ import ChatWidgetEvents from "./ChatWidgetEvents";
10
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
11
+ import conversationDividerActivity from "../../webchatcontainerstateful/common/activities/conversationDividerActivity";
12
+ import convertPersistentChatHistoryMessageToActivity from "../../webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity";
13
+ import { createTimer } from "../../../common/utils";
14
+ import { defaultPersistentChatHistoryProps } from "./defaultProps/defaultPersistentChatHistoryProps";
15
+ import dispatchCustomEvent from "../../../common/utils/dispatchCustomEvent";
16
+
17
+ /**
18
+ * Class responsible for handling persistent conversation history
19
+ */
20
+ let PersistentConversationHandler = /*#__PURE__*/function () {
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+
23
+ function PersistentConversationHandler(facadeChatSDK, props) {
24
+ _classCallCheck(this, PersistentConversationHandler);
25
+ _defineProperty(this, "appliedProps", {
26
+ ...defaultPersistentChatHistoryProps
27
+ });
28
+ _defineProperty(this, "isLastPull", false);
29
+ _defineProperty(this, "pageToken", null);
30
+ _defineProperty(this, "facadeChatSDK", void 0);
31
+ _defineProperty(this, "lastMessage", null);
32
+ _defineProperty(this, "count", 0);
33
+ _defineProperty(this, "pageSize", 4);
34
+ _defineProperty(this, "isCurrentlyPulling", false);
35
+ _defineProperty(this, "pageTokenInTransitSet", new Set());
36
+ _defineProperty(this, "resetEventListener", BroadcastService.getMessageByEventName(BroadcastEvent.PersistentConversationReset).subscribe(() => {
37
+ this.reset();
38
+ }));
39
+ this.facadeChatSDK = facadeChatSDK;
40
+ this.appliedPropsHandler(props);
41
+ TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
42
+ Event: TelemetryEvent.LCWPersistentConversationHandlerInitialized,
43
+ Description: "PersistentConversationHandler initialized",
44
+ CustomProperties: {
45
+ pageSize: this.pageSize
46
+ }
47
+ });
48
+ }
49
+ _createClass(PersistentConversationHandler, [{
50
+ key: "appliedPropsHandler",
51
+ value: function appliedPropsHandler(props) {
52
+ this.appliedProps = {
53
+ ...defaultPersistentChatHistoryProps,
54
+ ...props
55
+ };
56
+ this.pageSize = this.appliedProps.pageSize || 4;
57
+ }
58
+ }, {
59
+ key: "reset",
60
+ value: function reset() {
61
+ this.isLastPull = false;
62
+ this.pageToken = null;
63
+ this.lastMessage = null;
64
+ this.count = 0;
65
+ this.isCurrentlyPulling = false;
66
+ this.pageTokenInTransitSet.clear();
67
+ }
68
+ }, {
69
+ key: "destroy",
70
+ value: function destroy() {
71
+ // Only unsubscribe when the handler is being destroyed completely
72
+ this.resetEventListener.unsubscribe();
73
+ }
74
+ }, {
75
+ key: "pullHistory",
76
+ value: async function pullHistory() {
77
+ const pullTimer = createTimer();
78
+
79
+ // Prevent concurrent pulls regardless of pageToken
80
+ if (this.isCurrentlyPulling) {
81
+ TelemetryHelper.logActionEvent(LogLevel.WARN, {
82
+ Event: TelemetryEvent.LCWPersistentHistoryPullBlocked,
83
+ Description: "History pull blocked - already in progress"
84
+ });
85
+ return;
86
+ }
87
+
88
+ // Additional check for specific pageToken duplicates
89
+ if (this.pageToken && this.pageTokenInTransitSet.has(this.pageToken)) {
90
+ return;
91
+ }
92
+
93
+ // Mark as currently pulling
94
+ this.isCurrentlyPulling = true;
95
+ if (this.pageToken) {
96
+ this.pageTokenInTransitSet.add(this.pageToken);
97
+ }
98
+ try {
99
+ var _ref;
100
+ const messages = await this.fetchHistoryMessages();
101
+ if (messages === null || (messages === null || messages === void 0 ? void 0 : messages.length) === 0) {
102
+ this.isLastPull = true;
103
+ // Dispatch event to notify UI that no more history is available
104
+ dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
105
+ // Also hide the loading banner
106
+ dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
107
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
108
+ Event: TelemetryEvent.LCWPersistentHistoryPullCompleted,
109
+ Description: "History pull completed - no more messages",
110
+ ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed
111
+ });
112
+ return;
113
+ }
114
+ const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
115
+ this.processHistoryMessages(messagesDescOrder);
116
+
117
+ // Dispatch event to hide the loading banner after messages are processed
118
+ dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
119
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
120
+ Event: TelemetryEvent.LCWPersistentHistoryPullCompleted,
121
+ Description: "History pull completed successfully",
122
+ ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed,
123
+ CustomProperties: {
124
+ messageCount: messages.length,
125
+ totalProcessed: this.count
126
+ }
127
+ });
128
+ } finally {
129
+ // Always clear the pulling flag when done
130
+ this.isCurrentlyPulling = false;
131
+
132
+ // Remove pageToken from transit set if it was added
133
+ if (this.pageToken) {
134
+ this.pageTokenInTransitSet.delete(this.pageToken);
135
+ }
136
+ }
137
+ }
138
+
139
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
140
+ }, {
141
+ key: "processHistoryMessages",
142
+ value: function processHistoryMessages(messagesDescOrder) {
143
+ for (const message of messagesDescOrder) {
144
+ try {
145
+ const activity = this.processMessageToActivity(message);
146
+ if (activity) {
147
+ dispatchCustomEvent(ChatWidgetEvents.ADD_ACTIVITY, {
148
+ activity
149
+ });
150
+ const dividerActivity = this.createDividerActivity(activity);
151
+ if (dividerActivity) {
152
+ dispatchCustomEvent(ChatWidgetEvents.ADD_ACTIVITY, {
153
+ activity: dividerActivity
154
+ });
155
+ }
156
+ this.lastMessage = activity;
157
+ }
158
+ } catch (error) {
159
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
160
+ Event: TelemetryEvent.ConvertPersistentChatHistoryMessageToActivityFailed,
161
+ ExceptionDetails: error
162
+ });
163
+ }
164
+ }
165
+ }
166
+
167
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
+ }, {
169
+ key: "fetchHistoryMessages",
170
+ value: async function fetchHistoryMessages() {
171
+ if (!this.shouldPull()) {
172
+ // Dispatch event to ensure banner is hidden when no more pulls are needed
173
+ dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
174
+ dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
175
+ return [];
176
+ }
177
+ const options = {
178
+ pageSize: this.pageSize,
179
+ pageToken: this.pageToken || undefined
180
+ };
181
+ try {
182
+ var _this$facadeChatSDK;
183
+ const response = await ((_this$facadeChatSDK = this.facadeChatSDK) === null || _this$facadeChatSDK === void 0 ? void 0 : _this$facadeChatSDK.fetchPersistentConversationHistory(options));
184
+ const {
185
+ chatMessages: messages,
186
+ nextPageToken: pageToken
187
+ } = response;
188
+ this.pageToken = pageToken || null;
189
+ if (pageToken === null) {
190
+ this.isLastPull = true;
191
+ // Dispatch event when we reach the end of available history
192
+ dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
193
+ }
194
+
195
+ // if chatMessages is null, return empty array
196
+ if (!messages) {
197
+ this.isLastPull = true;
198
+ // Dispatch event when we reach the end of available history
199
+ dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
200
+ // Also hide the loading banner
201
+ dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
202
+ return [];
203
+ }
204
+ dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
205
+ return messages;
206
+ } catch (error) {
207
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
208
+ Event: TelemetryEvent.FetchPersistentChatHistoryFailed,
209
+ ExceptionDetails: error
210
+ });
211
+ this.isLastPull = true;
212
+ this.pageToken = null;
213
+ // Dispatch event when there's an error to stop loading banner
214
+ dispatchCustomEvent(ChatWidgetEvents.NO_MORE_HISTORY_AVAILABLE);
215
+ // Also hide the loading banner
216
+ dispatchCustomEvent(ChatWidgetEvents.HIDE_LOADING_BANNER);
217
+ return [];
218
+ }
219
+ }
220
+ }, {
221
+ key: "shouldPull",
222
+ value: function shouldPull() {
223
+ return !this.isLastPull;
224
+ }
225
+
226
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
227
+ }, {
228
+ key: "processMessageToActivity",
229
+ value: function processMessageToActivity(message) {
230
+ try {
231
+ const activity = convertPersistentChatHistoryMessageToActivity(message);
232
+ activity.id = activity.id || `activity-${this.count}`;
233
+ activity.channelData = {
234
+ ...activity.channelData,
235
+ metadata: {
236
+ count: this.count
237
+ }
238
+ };
239
+
240
+ // Increment the count after assigning it to the activity
241
+ this.count += 1;
242
+ return activity;
243
+ } catch (error) {
244
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
245
+ Event: TelemetryEvent.ConvertPersistentChatHistoryMessageToActivityFailed,
246
+ ExceptionDetails: error
247
+ });
248
+ throw error;
249
+ }
250
+ }
251
+
252
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
253
+ }, {
254
+ key: "createDividerActivity",
255
+ value: function createDividerActivity(activity) {
256
+ var _this$lastMessage, _this$lastMessage$cha;
257
+ if (((_this$lastMessage = this.lastMessage) === null || _this$lastMessage === void 0 ? void 0 : (_this$lastMessage$cha = _this$lastMessage.channelData) === null || _this$lastMessage$cha === void 0 ? void 0 : _this$lastMessage$cha.conversationId) !== activity.channelData.conversationId) {
258
+ const rawSequenceId = activity.channelData["webchat:sequence-id"];
259
+ const sequenceId = typeof rawSequenceId === "number" && !isNaN(rawSequenceId) ? rawSequenceId + 1 : 1;
260
+ const timestamp = new Date(activity.timestamp).getTime() + 1;
261
+ return {
262
+ ...conversationDividerActivity,
263
+ channelData: {
264
+ ...conversationDividerActivity.channelData,
265
+ conversationId: activity.channelData.conversationId,
266
+ "webchat:sequence-id": sequenceId
267
+ },
268
+ timestamp: new Date(timestamp).toISOString(),
269
+ identifier: `divider-${activity.channelData.conversationId}`
270
+ };
271
+ }
272
+ return null;
273
+ }
274
+ }]);
275
+ return PersistentConversationHandler;
276
+ }();
277
+ export default PersistentConversationHandler;
@@ -1,3 +1,4 @@
1
+ import { AddActivitySubscriber } from "./ActivitySubscriber/AddActivitySubscriber";
1
2
  import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
2
3
  import { ChatAdapterShim } from "./ChatAdapterShim";
3
4
  import { HiddenAdaptiveCardActivitySubscriber } from "./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber";
@@ -44,6 +45,7 @@ export const createAdapter = async (facadeChatSDK, props) => {
44
45
  fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval
45
46
  };
46
47
  adapter = new ChatAdapterShim(adapter);
48
+ adapter.addSubscriber(new AddActivitySubscriber());
47
49
  adapter.addSubscriber(new PauseActivitySubscriber());
48
50
  adapter.addSubscriber(new BotAuthActivitySubscriber(botAuthActivitySubscriberOptionalParams));
49
51
  // Remove this code after ICM ID:544623085 is fixed
@@ -0,0 +1,11 @@
1
+ export const defaultPersistentChatHistoryProps = {
2
+ persistentChatHistoryEnabled: true,
3
+ pageSize: 4,
4
+ dividerActivityStyle: {
5
+ border: "1px solid rgb(96, 94, 92, 0.5)",
6
+ margin: "10px 20%"
7
+ },
8
+ bannerStyle: {
9
+ margin: "10px auto"
10
+ }
11
+ };
@@ -4,6 +4,7 @@ import { getConversationDetailsCall, getWidgetEndChatEventName } from "../../../
4
4
  import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
5
5
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
6
6
  import { ConversationState } from "../../../contexts/common/ConversationState";
7
+ import { LazyLoadHandler } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity";
7
8
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
8
9
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
9
10
  import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
@@ -225,7 +226,12 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
225
226
  type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
226
227
  payload: undefined
227
228
  });
228
- // Always allow to close the chat for embedded mode irrespective of end chat errors
229
+
230
+ // Call direct reset to ensure LazyLoadHandler gets reset regardless of broadcast timing
231
+ LazyLoadHandler.directReset();
232
+ BroadcastService.postMessage({
233
+ eventName: BroadcastEvent.PersistentConversationReset
234
+ });
229
235
  closeChatWidget(dispatch, setWebChatStyles, props);
230
236
  facadeChatSDK.destroy();
231
237
  }
@@ -1,6 +1,7 @@
1
1
  import { ConversationEndEntity, ParticipantType } from "../../../common/Constants";
2
2
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { changeLanguageCodeFormatForWebChat, getConversationDetailsCall } from "../../../common/utils";
4
+ import { getOverriddenLocalizedStrings, localizedStringsBotInitialsMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware";
4
5
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
5
6
  import { Constants } from "../../../common/Constants";
6
7
  import { ConversationState } from "../../../contexts/common/ConversationState";
@@ -12,6 +13,7 @@ import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontro
12
13
  import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
13
14
  import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
14
15
  import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
16
+ import { createActivityStatusMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware";
15
17
  import { createAttachmentMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
16
18
  import createAttachmentUploadValidatorMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware";
17
19
  import { createAvatarMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware";
@@ -39,11 +41,10 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
39
41
  import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
40
42
  import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
41
43
  import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
42
- import { localizedStringsBotInitialsMiddleware, getOverriddenLocalizedStrings } from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware";
43
44
 
44
45
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
46
  export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
46
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain13, _props$webChatContain14, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain15, _props$webChatContain16, _defaultWebChatContai, _props$webChatContain17, _props$webChatContain18, _props$webChatContain19, _props$webChatContain20, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai2, _props$webChatContain23, _props$webChatContain24, _defaultWebChatContai3, _props$webChatContain25, _props$webChatContain26, _props$webChatContain27, _props$webChatContain28;
47
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain13, _props$webChatContain14, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain15, _props$webChatContain16, _state$domainStates$l6, _state$domainStates$l7, _props$webChatContain17, _props$webChatContain18, _props$webChatContain19, _props$webChatContain20, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai, _props$webChatContain23, _props$webChatContain24, _defaultWebChatContai2, _props$webChatContain25, _props$webChatContain26, _props$webChatContain27, _props$webChatContain28;
47
48
  // Add a hook to make all links open a new window
48
49
  postDomPurifyActivities();
49
50
  const localizedTexts = {
@@ -61,6 +62,7 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
61
62
  let webChatStore = WebChatStoreLoader.store;
62
63
  if (!webChatStore) {
63
64
  var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain7;
65
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
66
  const addConversationalSurveyTagsCallback = action => {
65
67
  var _inMemoryState$appSta;
66
68
  const inMemoryState = executeReducer(state, {
@@ -163,12 +165,12 @@ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endCh
163
165
  store: webChatStore,
164
166
  activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : createActivityMiddleware(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
165
167
  attachmentMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableAttachmentMiddleware ? undefined : createAttachmentMiddleware(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? defaultAttachmentProps.enableInlinePlaying),
166
- activityStatusMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableActivityStatusMiddleware ? undefined : (_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.activityStatusMiddleware,
168
+ activityStatusMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableActivityStatusMiddleware ? undefined : createActivityStatusMiddleware(getLocaleStringFromId((_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : (_state$domainStates$l7 = _state$domainStates$l6.ChatWidgetLanguage) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.msdyn_localeid)),
167
169
  toastMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableToastMiddleware ? undefined : createToastMiddleware(props.notificationPaneProps, endChat),
168
170
  renderMarkdown,
169
171
  avatarMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableAvatarMiddleware ? undefined : createAvatarMiddleware((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
170
- groupActivitiesMiddleware: (_props$webChatContain21 = props.webChatContainerProps) !== null && _props$webChatContain21 !== void 0 && (_props$webChatContain22 = _props$webChatContain21.renderingMiddlewareProps) !== null && _props$webChatContain22 !== void 0 && _props$webChatContain22.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
171
- typingIndicatorMiddleware: (_props$webChatContain23 = props.webChatContainerProps) !== null && _props$webChatContain23 !== void 0 && (_props$webChatContain24 = _props$webChatContain23.renderingMiddlewareProps) !== null && _props$webChatContain24 !== void 0 && _props$webChatContain24.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
172
+ groupActivitiesMiddleware: (_props$webChatContain21 = props.webChatContainerProps) !== null && _props$webChatContain21 !== void 0 && (_props$webChatContain22 = _props$webChatContain21.renderingMiddlewareProps) !== null && _props$webChatContain22 !== void 0 && _props$webChatContain22.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.groupActivitiesMiddleware,
173
+ typingIndicatorMiddleware: (_props$webChatContain23 = props.webChatContainerProps) !== null && _props$webChatContain23 !== void 0 && (_props$webChatContain24 = _props$webChatContain23.renderingMiddlewareProps) !== null && _props$webChatContain24 !== void 0 && _props$webChatContain24.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.typingIndicatorMiddleware,
172
174
  onTelemetry: createWebChatTelemetry(),
173
175
  cardActionMiddleware: createCardActionMiddleware(((_props$webChatContain25 = props.webChatContainerProps) === null || _props$webChatContain25 === void 0 ? void 0 : _props$webChatContain25.botMagicCode) || undefined),
174
176
  sendTypingIndicator: true,
@@ -149,7 +149,7 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
149
149
  if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
150
150
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
151
151
  const context = await facadeChatSDK.getPostChatSurveyContext();
152
- TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
152
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
153
153
  Event: TelemetryEvent.PostChatContextCallSucceed,
154
154
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
155
155
  });
@@ -167,7 +167,7 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
167
167
  }
168
168
  }
169
169
  } catch (error) {
170
- TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.ERROR, {
170
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
171
171
  Event: TelemetryEvent.PostChatContextCallFailed,
172
172
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallFailed,
173
173
  ExceptionDetails: {
@@ -19,13 +19,13 @@ export const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, p
19
19
  const postChatEnabled = postChatConfig.postChatEnabled;
20
20
  if (postChatEnabled) {
21
21
  if (!persistedChat) {
22
- TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
22
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
23
23
  Event: TelemetryEvent.PostChatContextCallStarted,
24
24
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallStarted
25
25
  });
26
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
27
  const context = await facadeChatSDK.getPostChatSurveyContext();
28
- TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
28
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
29
29
  Event: TelemetryEvent.PostChatContextCallSucceed,
30
30
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
31
31
  });
@@ -42,7 +42,7 @@ export const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, p
42
42
  }
43
43
  }
44
44
  } catch (ex) {
45
- TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.ERROR, {
45
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
46
46
  Event: TelemetryEvent.PostChatContextCallFailed,
47
47
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallFailed,
48
48
  ExceptionDetails: {
@@ -1,9 +1,9 @@
1
- import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
+ import { BroadcastEvent, ConversationStage, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
2
  import { Constants, LiveWorkItemState, WidgetLoadTelemetryMessage } from "../../../common/Constants";
3
3
  import { TelemetryManager, TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
4
4
  import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty } from "../../../common/utils";
5
5
  import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
6
- import { handleStartChatError, logWidgetLoadComplete } from "./startChatErrorHandler";
6
+ import { handleStartChatError, logStartChatComplete, logWidgetLoadComplete } from "./startChatErrorHandler";
7
7
  import { ActivityStreamHandler } from "./ActivityStreamHandler";
8
8
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
9
9
  import { ConversationState } from "../../../contexts/common/ConversationState";
@@ -174,7 +174,10 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
174
174
  TelemetryTimers.WidgetLoadTimer = createTimer();
175
175
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
176
176
  Event: TelemetryEvent.WidgetLoadStarted,
177
- Description: "Widget start chat started."
177
+ Description: "Widget start chat started.",
178
+ CustomProperties: {
179
+ ConversationStage: ConversationStage.Initialization
180
+ }
178
181
  });
179
182
 
180
183
  //Check if chat retrieved from cache
@@ -202,6 +205,7 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
202
205
  const startTime = new Date().getTime();
203
206
  createTrackingForFirstMessage();
204
207
  await facadeChatSDK.startChat(startChatOptionalParams);
208
+ logStartChatComplete();
205
209
  isStartChatSuccessful = true;
206
210
  await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, startTime, props);
207
211
  } catch (error) {
@@ -1,5 +1,5 @@
1
1
  import { ChatSDKError, ChatSDKErrorName } from "@microsoft/omnichannel-chat-sdk";
2
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
+ import { ConversationStage, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { PrepareEndChatDescriptionConstants, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
4
4
  import { callingStateCleanUp, chatSDKStateCleanUp, closeChatStateCleanUp, endChatStateCleanUp } from "./endChat";
5
5
  import { ConversationState } from "../../../contexts/common/ConversationState";
@@ -118,7 +118,10 @@ const logWidgetLoadFailed = ex => {
118
118
  Event: TelemetryEvent.WidgetLoadFailed,
119
119
  Description: "Widget load complete with error",
120
120
  ExceptionDetails: exDetails,
121
- ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
121
+ ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed,
122
+ CustomProperties: {
123
+ ConversationStage: ConversationStage.Initialization
124
+ }
122
125
  });
123
126
  };
124
127
  export const logWidgetLoadComplete = additionalMessage => {
@@ -133,6 +136,16 @@ export const logWidgetLoadComplete = additionalMessage => {
133
136
  ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
134
137
  });
135
138
  };
139
+ export const logStartChatComplete = additionalMessage => {
140
+ let descriptionString = "Start chat complete";
141
+ if (additionalMessage) {
142
+ descriptionString += `. ${additionalMessage}`;
143
+ }
144
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
145
+ Event: TelemetryEvent.StartChatComplete,
146
+ Description: descriptionString
147
+ });
148
+ };
136
149
  const logWidgetLoadCompleteWithError = ex => {
137
150
  var _TelemetryTimers$Widg3;
138
151
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -149,7 +162,10 @@ const logWidgetLoadCompleteWithError = ex => {
149
162
  Event: TelemetryEvent.WidgetLoadFailed,
150
163
  Description: "Widget load complete with error",
151
164
  ExceptionDetails: exDetails,
152
- ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
165
+ ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed,
166
+ CustomProperties: {
167
+ ConversationStage: ConversationStage.Initialization
168
+ }
153
169
  });
154
170
  };
155
171
  export const logWidgetLoadWithUnexpectedError = ex => {
@@ -177,7 +193,10 @@ export const logWidgetLoadWithUnexpectedError = ex => {
177
193
  Event: TelemetryEvent.WidgetLoadFailed,
178
194
  Description: "Widget load with unexpected error",
179
195
  ExceptionDetails: exDetails,
180
- ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
196
+ ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed,
197
+ CustomProperties: {
198
+ ConversationStage: ConversationStage.Initialization
199
+ }
181
200
  });
182
201
  };
183
202
 
@@ -1,5 +1,5 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
+ import { BroadcastEvent, ConversationStage, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { BroadcastService, BroadcastServiceInitialize, decodeComponentString } from "@microsoft/omnichannel-chat-components";
4
4
  import { Components } from "botframework-webchat";
5
5
  import { ConfirmationState, Constants, ConversationEndEntity, E2VVOptions, LiveWorkItemState, PrepareEndChatDescriptionConstants, StorageType, WidgetLoadCustomErrorString } from "../../../common/Constants";
@@ -61,7 +61,10 @@ export const LiveChatWidgetStateful = props => {
61
61
  uiTimer = createTimer();
62
62
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
63
63
  Event: TelemetryEvent.UXLiveChatWidgetStart,
64
- Description: "Live chat widget loading started."
64
+ Description: "Live chat widget loading started.",
65
+ CustomProperties: {
66
+ ConversationStage: ConversationStage.Initialization
67
+ }
65
68
  });
66
69
  }, []);
67
70
  const [state, dispatch] = useChatContextStore();
@@ -492,7 +495,10 @@ export const LiveChatWidgetStateful = props => {
492
495
  BroadcastService.getMessageByEventName(BroadcastEvent.InitiateEndChat).subscribe(async () => {
493
496
  TelemetryHelper.logSDKEventToAllTelemetry(LogLevel.INFO, {
494
497
  Event: TelemetryEvent.EndChatEventReceived,
495
- Description: "Received InitiateEndChat BroadcastEvent."
498
+ Description: "Received InitiateEndChat BroadcastEvent.",
499
+ CustomProperties: {
500
+ ConversationStage: ConversationStage.ConversationEnd
501
+ }
496
502
  });
497
503
 
498
504
  // This is to ensure to get latest state from cache in multitab
@@ -797,7 +803,10 @@ export const LiveChatWidgetStateful = props => {
797
803
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
798
804
  Event: TelemetryEvent.UXLiveChatWidgetCompleted,
799
805
  Description: "Live chat widget loading completed.",
800
- ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
806
+ ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed,
807
+ CustomProperties: {
808
+ ConversationStage: ConversationStage.Initialization
809
+ }
801
810
  });
802
811
  }, []);
803
812
  const initiateEndChatOnBrowserUnload = () => {