@microsoft/omnichannel-chat-widget 1.8.3 → 1.8.4-main.21aec08

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 (149) hide show
  1. package/README.md +27 -0
  2. package/lib/cjs/common/Constants.js +7 -0
  3. package/lib/cjs/common/facades/FacadeChatSDK.js +6 -0
  4. package/lib/cjs/common/telemetry/AppInsightsEvents.js +14 -9
  5. package/lib/cjs/common/telemetry/TelemetryConstants.js +46 -2
  6. package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
  7. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +29 -13
  8. package/lib/cjs/common/utils/SecureEventBus.js +307 -0
  9. package/lib/cjs/common/utils/dispatchCustomEvent.js +25 -0
  10. package/lib/cjs/common/utils.js +14 -1
  11. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
  12. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +20 -1
  13. package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
  14. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +127 -0
  15. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +15 -0
  16. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +290 -0
  17. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  18. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +17 -0
  19. package/lib/cjs/components/livechatwidget/common/endChat.js +33 -10
  20. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +16 -7
  21. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
  22. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  23. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  24. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  25. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
  26. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
  27. package/lib/cjs/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  28. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +123 -28
  29. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +37 -8
  30. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
  31. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +46 -22
  32. package/lib/cjs/components/webchatcontainerstateful/common/activities/botActivity.js +14 -0
  33. package/lib/cjs/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +17 -0
  34. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +103 -0
  35. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
  36. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +1 -1
  37. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +57 -0
  38. package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +121 -0
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +10 -0
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +47 -0
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1058 -0
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +34 -0
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +50 -1
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +16 -2
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +20 -0
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +2 -2
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +59 -0
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -3
  50. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -2
  51. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  52. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  53. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
  54. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
  55. package/lib/cjs/contexts/createReducer.js +15 -0
  56. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  57. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  58. package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
  59. package/lib/esm/common/Constants.js +7 -0
  60. package/lib/esm/common/facades/FacadeChatSDK.js +6 -0
  61. package/lib/esm/common/telemetry/AppInsightsEvents.js +14 -9
  62. package/lib/esm/common/telemetry/TelemetryConstants.js +44 -1
  63. package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
  64. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +30 -14
  65. package/lib/esm/common/utils/SecureEventBus.js +328 -0
  66. package/lib/esm/common/utils/dispatchCustomEvent.js +18 -0
  67. package/lib/esm/common/utils.js +11 -0
  68. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
  69. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +20 -1
  70. package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
  71. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.js +120 -0
  72. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +8 -0
  73. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +283 -0
  74. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  75. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +10 -0
  76. package/lib/esm/components/livechatwidget/common/endChat.js +33 -10
  77. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +16 -7
  78. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
  79. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  80. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  81. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  82. package/lib/esm/components/livechatwidget/common/startChat.js +7 -3
  83. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
  84. package/lib/esm/components/livechatwidget/interfaces/IPersistentChatHistoryProps.js +1 -0
  85. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -29
  86. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +39 -10
  87. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
  88. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +46 -22
  89. package/lib/esm/components/webchatcontainerstateful/common/activities/botActivity.js +7 -0
  90. package/lib/esm/components/webchatcontainerstateful/common/activities/conversationDividerActivity.js +9 -0
  91. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +96 -0
  92. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -1
  93. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  94. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +49 -0
  95. package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  96. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +114 -0
  97. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.js +3 -0
  98. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +39 -0
  99. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +1080 -0
  100. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +25 -0
  101. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +48 -1
  102. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +13 -0
  103. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.js +13 -0
  104. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +1 -1
  105. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +52 -0
  106. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -2
  107. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +1 -1
  108. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  109. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  110. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
  111. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
  112. package/lib/esm/contexts/createReducer.js +15 -0
  113. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  114. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  115. package/lib/esm/plugins/newMessageEventHandler.js +4 -1
  116. package/lib/types/common/Constants.d.ts +6 -0
  117. package/lib/types/common/facades/FacadeChatSDK.d.ts +3 -1
  118. package/lib/types/common/telemetry/TelemetryConstants.d.ts +41 -2
  119. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
  120. package/lib/types/common/utils/SecureEventBus.d.ts +159 -0
  121. package/lib/types/common/utils/dispatchCustomEvent.d.ts +2 -0
  122. package/lib/types/common/utils.d.ts +9 -1
  123. package/lib/types/components/livechatwidget/common/ActivitySubscriber/AddActivitySubscriber.d.ts +45 -0
  124. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +7 -0
  125. package/lib/types/components/livechatwidget/common/PersistentConversationHandler.d.ts +28 -0
  126. package/lib/types/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.d.ts +2 -0
  127. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
  128. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
  129. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
  130. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +11 -0
  131. package/lib/types/components/webchatcontainerstateful/common/activities/botActivity.d.ts +7 -0
  132. package/lib/types/components/webchatcontainerstateful/common/activities/conversationDividerActivity.d.ts +10 -0
  133. package/lib/types/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.d.ts +2 -0
  134. package/lib/types/components/webchatcontainerstateful/hooks/usePersistentChatHistory.d.ts +4 -0
  135. package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
  136. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +6 -0
  137. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/Constants.d.ts +3 -0
  138. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.d.ts +4 -0
  139. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +326 -0
  140. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.d.ts +8 -0
  141. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
  142. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -0
  143. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultInLineBannerStyle.d.ts +2 -0
  144. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.d.ts +2 -0
  145. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
  146. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  147. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +6 -0
  148. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
  149. package/package.json +3 -3
@@ -10,7 +10,10 @@ var _utils = require("../../../common/utils");
10
10
  var _renderSurveyHelpers = require("./renderSurveyHelpers");
11
11
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
12
12
  var _ConversationState = require("../../../contexts/common/ConversationState");
13
+ var _LazyLoadActivity = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity");
13
14
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
15
+ var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
16
+ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
14
17
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
15
18
  var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
16
19
  var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
@@ -200,6 +203,18 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
200
203
  facadeChatSDK.destroy();
201
204
  }
202
205
  }
206
+
207
+ //moving logic below to before processing skipCloseChat logic to avoid race conditions of postMessage for endChatEvent for other tabs vs postMessage for CloseChat
208
+ //TODO: clarify if this postMessageToOtherTab actually works in production.
209
+ if (postMessageToOtherTab) {
210
+ const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
211
+ _omnichannelChatComponents.BroadcastService.postMessage({
212
+ eventName: endChatEventName,
213
+ payload: {
214
+ runtimeId: _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId
215
+ }
216
+ });
217
+ }
203
218
  if (!skipCloseChat) {
204
219
  try {
205
220
  var _props$webChatContain;
@@ -231,20 +246,25 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
231
246
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
232
247
  payload: undefined
233
248
  });
234
- // Always allow to close the chat for embedded mode irrespective of end chat errors
249
+
250
+ // Call direct reset to ensure LazyLoadHandler gets reset regardless of broadcast timing
251
+ _LazyLoadActivity.LazyLoadHandler.directReset();
252
+ _omnichannelChatComponents.BroadcastService.postMessage({
253
+ eventName: _TelemetryConstants.BroadcastEvent.PersistentConversationReset
254
+ });
235
255
  closeChatWidget(dispatch, setWebChatStyles, props);
236
256
  facadeChatSDK.destroy();
257
+
258
+ //always post the close chat event after chat closed and cleanup completed
259
+ _omnichannelChatComponents.BroadcastService.postMessage({
260
+ eventName: _TelemetryConstants.BroadcastEvent.CloseChat
261
+ });
262
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
263
+ Event: _TelemetryConstants.TelemetryEvent.CloseChatCall,
264
+ Description: "Broadcasted close chat event"
265
+ });
237
266
  }
238
267
  }
239
- if (postMessageToOtherTab) {
240
- const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
241
- _omnichannelChatComponents.BroadcastService.postMessage({
242
- eventName: endChatEventName,
243
- payload: {
244
- runtimeId: _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId
245
- }
246
- });
247
- }
248
268
  };
249
269
  exports.endChat = endChat;
250
270
  const callingStateCleanUp = dispatch => {
@@ -325,6 +345,9 @@ const closeChatStateCleanUp = dispatch => {
325
345
  payload: {}
326
346
  });
327
347
 
348
+ // Dismiss the chat disconnect notification banner if it was shown
349
+ _NotificationHandler.NotificationHandler.dismissNotification(_NotificationScenarios.NotificationScenarios.ChatDisconnect);
350
+
328
351
  // Clear live chat context only if chat widget is fully closed to support transcript calls after sessionclose is called
329
352
  dispatch({
330
353
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
@@ -7,6 +7,7 @@ exports.initWebChatComposer = void 0;
7
7
  var _Constants = require("../../../common/Constants");
8
8
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
9
  var _utils = require("../../../common/utils");
10
+ var _localizedStringsBotInitialsMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware");
10
11
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
11
12
  var _ConversationState = require("../../../contexts/common/ConversationState");
12
13
  var _dompurify = _interopRequireDefault(require("dompurify"));
@@ -17,6 +18,7 @@ var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontrol
17
18
  var _attachmentProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware"));
18
19
  var _channelDataMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware"));
19
20
  var _activityMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware");
21
+ var _activityStatusMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware");
20
22
  var _attachmentMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware");
21
23
  var _attachmentUploadValidatorMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware"));
22
24
  var _avatarMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware");
@@ -44,11 +46,10 @@ var _htmlPlayerMiddleware = _interopRequireDefault(require("../../webchatcontain
44
46
  var _htmlTextMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware"));
45
47
  var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware"));
46
48
  var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
47
- var _localizedStringsBotInitialsMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware");
48
49
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
49
50
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
51
  const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
51
- 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;
52
+ 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;
52
53
  // Add a hook to make all links open a new window
53
54
  postDomPurifyActivities();
54
55
  const localizedTexts = {
@@ -66,6 +67,7 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
66
67
  let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
67
68
  if (!webChatStore) {
68
69
  var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain7;
70
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
71
  const addConversationalSurveyTagsCallback = action => {
70
72
  var _inMemoryState$appSta;
71
73
  const inMemoryState = (0, _createReducer.executeReducer)(state, {
@@ -123,7 +125,14 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
123
125
  };
124
126
  webChatStore = (0, _botframeworkWebchat.createStore)({},
125
127
  //initial state
126
- _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_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), (0, _customEventMiddleware.default)(_omnichannelChatComponents.BroadcastService), (0, _queueOverflowHandlerMiddleware.createQueueOverflowMiddleware)(state, dispatch), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, (0, _citationsMiddleware.createCitationsMiddleware)(state, dispatch), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, (0, _callActionMiddleware.default)(), (0, _localizedStringsBotInitialsMiddleware.localizedStringsBotInitialsMiddleware)(),
128
+ _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_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), (0, _customEventMiddleware.default)(_omnichannelChatComponents.BroadcastService), (0, _queueOverflowHandlerMiddleware.createQueueOverflowMiddleware)(state, dispatch), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, (0, _citationsMiddleware.createCitationsMiddleware)(state, dispatch), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, (0, _callActionMiddleware.default)(),
129
+ // Pass a callback so middleware can push initials into React context for reactivity
130
+ (0, _localizedStringsBotInitialsMiddleware.localizedStringsBotInitialsMiddleware)(initials => {
131
+ dispatch({
132
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_BOT_AVATAR_INITIALS,
133
+ payload: initials
134
+ });
135
+ }),
127
136
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
137
  ...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
129
138
  _WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
@@ -166,14 +175,14 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
166
175
  dir: state.domainStates.globalDir,
167
176
  locale: (0, _utils.changeLanguageCodeFormatForWebChat)((0, _omnichannelChatSdk.getLocaleStringFromId)((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
168
177
  store: webChatStore,
169
- activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : (0, _activityMiddleware.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),
178
+ activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : (0, _activityMiddleware.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, localizedTexts),
170
179
  attachmentMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableAttachmentMiddleware ? undefined : (0, _attachmentMiddleware.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.defaultAttachmentProps.enableInlinePlaying),
171
- 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.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.activityStatusMiddleware,
180
+ activityStatusMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableActivityStatusMiddleware ? undefined : (0, _activityStatusMiddleware.createActivityStatusMiddleware)((0, _omnichannelChatSdk.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)),
172
181
  toastMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableToastMiddleware ? undefined : (0, _toastMiddleware.createToastMiddleware)(props.notificationPaneProps, endChat),
173
182
  renderMarkdown,
174
183
  avatarMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableAvatarMiddleware ? undefined : (0, _avatarMiddleware.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),
175
- 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.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
176
- 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.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
184
+ 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.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai === void 0 ? void 0 : _defaultWebChatContai.groupActivitiesMiddleware,
185
+ 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.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.typingIndicatorMiddleware,
177
186
  onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
178
187
  cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain25 = props.webChatContainerProps) === null || _props$webChatContain25 === void 0 ? void 0 : _props$webChatContain25.botMagicCode) || undefined),
179
188
  sendTypingIndicator: true,
@@ -3,15 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = exports.getPostChatSurveyConfig = void 0;
7
- var _Constants = require("../../../common/Constants");
6
+ exports.shouldLoadPersistentChatHistory = exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = exports.getPostChatSurveyConfig = void 0;
8
7
  var _utils = require("../../../common/utils");
8
+ var _Constants = require("../../../common/Constants");
9
9
  const isPostChatSurveyEnabled = async facadeChatSDK => {
10
10
  var _chatConfig$LiveWSAnd;
11
11
  const chatConfig = await facadeChatSDK.getLiveChatConfig();
12
12
  const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
13
13
  return postChatEnabled === "true";
14
14
  };
15
+
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
17
  exports.isPostChatSurveyEnabled = isPostChatSurveyEnabled;
16
18
  const getPostChatSurveyConfig = async facadeChatSDK => {
17
19
  var _chatConfig$LiveWSAnd2, _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4, _chatConfig$LiveWSAnd5, _chatConfig$LiveWSAnd6, _chatConfig$LiveWSAnd7, _chatConfig$LiveWSAnd8, _chatConfig$LiveWSAnd9, _chatConfig$LiveWSAnd10;
@@ -34,6 +36,36 @@ const isPersistentChatEnabled = conversationMode => {
34
36
  if ((0, _utils.isNullOrUndefined)(conversationMode)) {
35
37
  return false;
36
38
  }
37
- return (conversationMode === null || conversationMode === void 0 ? void 0 : conversationMode.toString().toLowerCase()) === _Constants.ConversationMode.Persistent;
39
+ return (conversationMode === null || conversationMode === void 0 ? void 0 : conversationMode.toString()) === _Constants.ConversationMode.Persistent;
40
+ };
41
+
42
+ /**
43
+ * Determines if persistent chat history should be loaded based on all required conditions.
44
+ *
45
+ * @param extendedChatConfig - The extended chat configuration object
46
+ * @returns true if ALL conditions are met:
47
+ * 1. Conversation mode must be Persistent ("192350001")
48
+ * 2. History is enabled in admin config (msdyn_enablepersistentchatpreviousconversations)
49
+ * 3. History is enabled via feature flag (lcwPersistentChatHistoryEnabled)
50
+ */
51
+ exports.isPersistentChatEnabled = isPersistentChatEnabled;
52
+ const shouldLoadPersistentChatHistory = extendedChatConfig => {
53
+ var _extendedChatConfig$L, _extendedChatConfig$L2, _extendedChatConfig$L3;
54
+ // CRITICAL: First check if conversation mode is persistent
55
+ // Only persistent mode ("192350001") should allow history loading
56
+ const isPersistentChatEnabledForWidget = isPersistentChatEnabled(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L === void 0 ? void 0 : _extendedChatConfig$L.msdyn_conversationmode);
57
+ if (!isPersistentChatEnabledForWidget) {
58
+ return false;
59
+ }
60
+
61
+ // Check if history is enabled in admin config (handles both boolean and string "true"/"false")
62
+ const isHistoryEnabledInConfig = (0, _utils.parseBooleanFromConfig)(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L2 = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L2 === void 0 ? void 0 : _extendedChatConfig$L2.msdyn_enablepersistentchatpreviousconversations);
63
+ if (!isHistoryEnabledInConfig) {
64
+ return false;
65
+ }
66
+
67
+ // Check if history is enabled via feature flag (handles both boolean and string "true"/"false")
68
+ const isHistoryEnabledViaFCB = (0, _utils.parseBooleanFromConfig)(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L3 = extendedChatConfig.LcwFcbConfiguration) === null || _extendedChatConfig$L3 === void 0 ? void 0 : _extendedChatConfig$L3.lcwPersistentChatHistoryEnabled);
69
+ return isHistoryEnabledViaFCB;
38
70
  };
39
- exports.isPersistentChatEnabled = isPersistentChatEnabled;
71
+ exports.shouldLoadPersistentChatHistory = shouldLoadPersistentChatHistory;
@@ -30,7 +30,10 @@ const registerTelemetryLoggers = (props, dispatch) => {
30
30
  appInsightsConfig: Object.assign({}, _defaultAppInsightsConfig.defaultAppInsightsConfig, props.appInsightsConfig)
31
31
  };
32
32
  if (props.chatConfig) {
33
+ var _props$chatConfig$Liv;
33
34
  telemetryData = _TelemetryHelper.TelemetryHelper.addChatConfigDataToTelemetry(props === null || props === void 0 ? void 0 : props.chatConfig, telemetryData);
35
+ //store AppInsights instrumentation key from chatConfig if present
36
+ telemetryData.chatConfigAppInsightsKey = (_props$chatConfig$Liv = props.chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.AppInsightsInstrumentationKey;
34
37
  }
35
38
  if (!((_props$chatSDK = props.chatSDK) !== null && _props$chatSDK !== void 0 && (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) !== null && _props$chatSDK$omnich !== void 0 && _props$chatSDK$omnich.orgId) || ((_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.orgId.trim().length) === 0) {
36
39
  throw new Error("orgId is undefined in ChatSDK");
@@ -156,7 +156,7 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
156
156
  if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
157
157
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
158
158
  const context = await facadeChatSDK.getPostChatSurveyContext();
159
- _TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
159
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
160
160
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
161
161
  Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
162
162
  });
@@ -174,7 +174,7 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
174
174
  }
175
175
  }
176
176
  } catch (error) {
177
- _TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
177
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
178
178
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallFailed,
179
179
  Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallFailed,
180
180
  ExceptionDetails: {
@@ -24,13 +24,13 @@ const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persiste
24
24
  const postChatEnabled = postChatConfig.postChatEnabled;
25
25
  if (postChatEnabled) {
26
26
  if (!persistedChat) {
27
- _TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
27
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
28
28
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallStarted,
29
29
  Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallStarted
30
30
  });
31
31
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
32
  const context = await facadeChatSDK.getPostChatSurveyContext();
33
- _TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
33
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
34
34
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
35
35
  Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
36
36
  });
@@ -47,7 +47,7 @@ const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persiste
47
47
  }
48
48
  }
49
49
  } catch (ex) {
50
- _TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
50
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
51
51
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallFailed,
52
52
  Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallFailed,
53
53
  ExceptionDetails: {
@@ -181,7 +181,10 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
181
181
  _TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
182
182
  _TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
183
183
  Event: _TelemetryConstants.TelemetryEvent.WidgetLoadStarted,
184
- Description: "Widget start chat started."
184
+ Description: "Widget start chat started.",
185
+ CustomProperties: {
186
+ ConversationStage: _TelemetryConstants.ConversationStage.Initialization
187
+ }
185
188
  });
186
189
 
187
190
  //Check if chat retrieved from cache
@@ -209,6 +212,7 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
209
212
  const startTime = new Date().getTime();
210
213
  (0, _FirstMessageTrackerFromBot.createTrackingForFirstMessage)();
211
214
  await facadeChatSDK.startChat(startChatOptionalParams);
215
+ (0, _startChatErrorHandler.logStartChatComplete)();
212
216
  isStartChatSuccessful = true;
213
217
  await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, startTime, props);
214
218
  } catch (error) {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.logWidgetLoadWithUnexpectedError = exports.logWidgetLoadComplete = exports.handleStartChatError = void 0;
6
+ exports.logWidgetLoadWithUnexpectedError = exports.logWidgetLoadComplete = exports.logStartChatComplete = exports.handleStartChatError = void 0;
7
7
  var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
8
8
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
9
  var _Constants = require("../../../common/Constants");
@@ -124,7 +124,10 @@ const logWidgetLoadFailed = ex => {
124
124
  Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
125
125
  Description: "Widget load complete with error",
126
126
  ExceptionDetails: exDetails,
127
- ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
127
+ ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed,
128
+ CustomProperties: {
129
+ ConversationStage: _TelemetryConstants.ConversationStage.Initialization
130
+ }
128
131
  });
129
132
  };
130
133
  const logWidgetLoadComplete = additionalMessage => {
@@ -140,6 +143,17 @@ const logWidgetLoadComplete = additionalMessage => {
140
143
  });
141
144
  };
142
145
  exports.logWidgetLoadComplete = logWidgetLoadComplete;
146
+ const logStartChatComplete = additionalMessage => {
147
+ let descriptionString = "Start chat complete";
148
+ if (additionalMessage) {
149
+ descriptionString += `. ${additionalMessage}`;
150
+ }
151
+ _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
152
+ Event: _TelemetryConstants.TelemetryEvent.StartChatComplete,
153
+ Description: descriptionString
154
+ });
155
+ };
156
+ exports.logStartChatComplete = logStartChatComplete;
143
157
  const logWidgetLoadCompleteWithError = ex => {
144
158
  var _TelemetryTimers$Widg3;
145
159
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -156,7 +170,10 @@ const logWidgetLoadCompleteWithError = ex => {
156
170
  Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
157
171
  Description: "Widget load complete with error",
158
172
  ExceptionDetails: exDetails,
159
- ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
173
+ ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed,
174
+ CustomProperties: {
175
+ ConversationStage: _TelemetryConstants.ConversationStage.Initialization
176
+ }
160
177
  });
161
178
  };
162
179
  const logWidgetLoadWithUnexpectedError = ex => {
@@ -184,7 +201,10 @@ const logWidgetLoadWithUnexpectedError = ex => {
184
201
  Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
185
202
  Description: "Widget load with unexpected error",
186
203
  ExceptionDetails: exDetails,
187
- ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
204
+ ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed,
205
+ CustomProperties: {
206
+ ConversationStage: _TelemetryConstants.ConversationStage.Initialization
207
+ }
188
208
  });
189
209
  };
190
210