@microsoft/omnichannel-chat-widget 1.8.4-main.424a580 → 1.8.4-main.4f09da2

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 (60) hide show
  1. package/README.md +27 -0
  2. package/lib/cjs/common/Constants.js +2 -0
  3. package/lib/cjs/common/telemetry/AppInsightsEvents.js +11 -5
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
  6. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +7 -7
  7. package/lib/cjs/common/utils.js +14 -1
  8. package/lib/cjs/components/errorboundary/ErrorBoundary.js +2 -1
  9. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
  10. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +24 -21
  11. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
  12. package/lib/cjs/components/livechatwidget/common/endChat.js +26 -9
  13. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
  14. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  15. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +103 -26
  16. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +8 -6
  17. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +26 -33
  18. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +8 -2
  19. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
  20. package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  21. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
  22. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
  23. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -0
  24. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  25. package/lib/esm/common/Constants.js +2 -0
  26. package/lib/esm/common/telemetry/AppInsightsEvents.js +11 -5
  27. package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
  28. package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
  29. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +7 -7
  30. package/lib/esm/common/utils.js +11 -0
  31. package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -2
  32. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
  33. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +24 -21
  34. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
  35. package/lib/esm/components/livechatwidget/common/endChat.js +26 -9
  36. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
  37. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  38. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +103 -26
  39. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +8 -6
  40. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +27 -37
  41. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +8 -2
  42. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
  43. package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  44. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
  45. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
  46. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -0
  47. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -0
  48. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  49. package/lib/types/common/Constants.d.ts +2 -0
  50. package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -0
  51. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
  52. package/lib/types/common/utils.d.ts +9 -1
  53. package/lib/types/components/errorboundary/ErrorBoundary.d.ts +1 -1
  54. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +1 -1
  55. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
  56. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +0 -1
  57. package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
  58. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +1 -2
  59. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +1 -1
  60. package/package.json +2 -2
package/README.md CHANGED
@@ -268,6 +268,33 @@ const customizedFooterProp: IFooterProps = {
268
268
  setOnCustomEvent((event) => console.log(event));
269
269
  ```
270
270
 
271
+ #### Trigger initiateEndChat event
272
+ Customer can trigger the initiateEndChat event via BroadcastService to end a chat session.
273
+ When needed, the payload below could be triggered:
274
+ ```js
275
+ const endChatEvent = {
276
+ eventName: "InitiateEndChat",
277
+ payload: {
278
+ skipSessionCloseForPersistentChat: true
279
+ } //optional payload
280
+ };
281
+ BroadcastService.postMessage(endChatEvent);
282
+ ```
283
+
284
+ The payload of the event is optional, only needed when force closing of a persistent chat session is not required.
285
+ When chat widget receives the event without any payload, it will:
286
+ 1. set the widget to closed state, the widget panel will be minimized. Post chat survey will not be displayed.
287
+ 2. trigger a sessionclose service network request to OmniChannel services.
288
+
289
+ If skipSessionCloseForPersistentChat is set to true. The session close network request will not be triggered, instead, if postChat survey is available, post chat survey will be displayed.
290
+
291
+ After successfully processed initiateEndChat event. The CloseChat event is broadcasted.
292
+ ```js
293
+ BroadcastService.getMessageByEventName("CloseChat").subscribe(async (msg) => {
294
+ console.log("close chat received: ", msg);
295
+ //more actions to unmount component and resources
296
+ })
297
+ ```
271
298
  ## See Also
272
299
 
273
300
  [Customizations Dev Guide](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/customizations/getstarted.md)\
@@ -143,6 +143,7 @@ _defineProperty(Constants, "customEventName", "customEventName");
143
143
  _defineProperty(Constants, "customEventValue", "customEventValue");
144
144
  _defineProperty(Constants, "Hidden", "Hidden");
145
145
  _defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
146
+ _defineProperty(Constants, "SkipSessionCloseForPersistentChatFlag", "skipSessionCloseForPersistentChat");
146
147
  const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
147
148
  _classCallCheck(this, Regex);
148
149
  }), _defineProperty(_class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\])$"), _class);
@@ -378,6 +379,7 @@ _defineProperty(PrepareEndChatDescriptionConstants, "ConversationEndedBy", "Conv
378
379
  _defineProperty(PrepareEndChatDescriptionConstants, "PrepareEndChatError", "There's an error while preparing to end chat. Closing chat widget.");
379
380
  _defineProperty(PrepareEndChatDescriptionConstants, "WidgetLoadFailedAfterSessionInit", "SessionInit was successful, but widget load failed. Ending chat to avoid ghost chats in OC.");
380
381
  _defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceived", "Received InitiateEndChat BroadcastEvent while conversation state is not Active. Ending chat.");
382
+ _defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceivedActiveChat", "Received InitiateEndChat BroadcastEvent while conversation state is Active. Updating conversation states.");
381
383
  _defineProperty(PrepareEndChatDescriptionConstants, "EndChatReceivedFromOtherTabs", "Received EndChat BroadcastEvent from other tabs. Closing this chat.");
382
384
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseChatOnFailureOrPostChat", "Customer is trying to close chat widget on start chat failure or post chat pane.");
383
385
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseInactiveChat", "Chat was Inactive and customer is trying to close chat widget or refreshing the page.");
@@ -6,8 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.AppInsightsEventMapping = void 0;
7
7
  const AppInsightsEventMapping = {
8
8
  "LCWChatButtonClicked": "LCWChatButtonActionStarted",
9
- "PrechatSubmitted": "PrechatSubmitCompleted",
10
- "StartChatEventRecevied": "StartChatEventReceivedCompleted",
9
+ "UXLCWChatButtonLoadingStart": "LiveChatWidgetChatButtonLoadingStarted",
10
+ "UXLCWChatButtonLoadingCompleted": "LiveChatWidgetChatButtonLoadingCompleted",
11
+ "UXPrechatPaneStart": "PrechatSurveyStarted",
12
+ "UXPrechatPaneCompleted": "PrechatSurveyCompleted",
13
+ "PrechatSubmitted": "PrechatSurveySubmitCompleted",
11
14
  "EndChatEventReceived": "EndChatEventReceivedCompleted",
12
15
  "EmailTranscriptSent": "EmailTranscriptActionCompleted",
13
16
  "EmailTranscriptFailed": "EmailTranscriptActionFailed",
@@ -15,8 +18,6 @@ const AppInsightsEventMapping = {
15
18
  "HeaderMinimizeButtonClicked": "MinimizeChatActionStarted",
16
19
  "DownloadTranscriptButtonClicked": "DownloadTranscriptActionStarted",
17
20
  "EmailTranscriptButtonClicked": "EmailTranscriptButtonActionStarted",
18
- "CustomerVoiceFormResponseSubmitted": "CustomerVoiceFormResponseSubmitCompleted",
19
- "StartProactiveChatEventReceived": "StartProactiveChatEventReceivedCompleted",
20
21
  "ProactiveChatRejected": "ProactiveChatTimeOutCompleted",
21
22
  "MessageSent": "MessageSentCompleted",
22
23
  "MessageReceived": "MessageReceivedCompleted",
@@ -25,6 +26,11 @@ const AppInsightsEventMapping = {
25
26
  "CustomContextReceived": "CustomContextReceivedCompleted",
26
27
  "NewTokenValidationStarted": "AuthTokenValidationStarted",
27
28
  "NewTokenValidationCompleted": "AuthTokenValidationCompleted",
28
- "NewTokenValidationFailed": "AuthTokenValidationFailed"
29
+ "NewTokenValidationFailed": "AuthTokenValidationFailed",
30
+ "UXPostChatPaneStarted": "PostChatSurveyStarted",
31
+ "UXPostChatPaneCompleted": "PostChatSurveyCompleted",
32
+ "WidgetLoadStarted": "ChatSessionInitializationStarted",
33
+ "WidgetLoadComplete": "ChatSessionInitializationCompleted",
34
+ "WidgetLoadFailed": "ChatSessionInitializationFailed"
29
35
  };
30
36
  exports.AppInsightsEventMapping = AppInsightsEventMapping;
@@ -306,6 +306,7 @@ exports.TelemetryEvent = TelemetryEvent;
306
306
  TelemetryEvent["LCWPersistentConversationHandlerInitialized"] = "LCWPersistentConversationHandlerInitialized";
307
307
  TelemetryEvent["LCWPersistentHistoryPullBlocked"] = "LCWPersistentHistoryPullBlocked";
308
308
  TelemetryEvent["LCWPersistentHistoryPullCompleted"] = "LCWPersistentHistoryPullCompleted";
309
+ TelemetryEvent["LCWPersistentHistoryReturnedNull"] = "LCWPersistentHistoryReturnedNull";
309
310
  TelemetryEvent["LCWLazyLoadInitializationStarted"] = "LCWLazyLoadInitializationStarted";
310
311
  TelemetryEvent["LCWLazyLoadContainerNotFound"] = "LCWLazyLoadContainerNotFound";
311
312
  TelemetryEvent["LCWLazyLoadInitializationCompleted"] = "LCWLazyLoadInitializationCompleted";
@@ -315,6 +316,7 @@ exports.TelemetryEvent = TelemetryEvent;
315
316
  TelemetryEvent["LCWLazyLoadActivityMounted"] = "LCWLazyLoadActivityMounted";
316
317
  TelemetryEvent["LCWLazyLoadReset"] = "LCWLazyLoadReset";
317
318
  TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
319
+ TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
318
320
  TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
319
321
  TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
320
322
  TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
@@ -50,7 +50,7 @@ const RegisterLoggers = () => {
50
50
  loggers.push((0, _consoleLogger.consoleLogger)());
51
51
  }
52
52
  if (((_TelemetryManager$Int9 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int9 === void 0 ? void 0 : (_TelemetryManager$Int10 = _TelemetryManager$Int9.telemetryConfig) === null || _TelemetryManager$Int10 === void 0 ? void 0 : _TelemetryManager$Int10.telemetryDisabled) === false) {
53
- var _TelemetryManager$Int11, _TelemetryManager$Int20, _TelemetryManager$Int21, _TelemetryManager$Int22, _TelemetryManager$Int23;
53
+ var _TelemetryManager$Int11, _TelemetryManager$Int20, _TelemetryManager$Int21, _TelemetryManager$Int22, _TelemetryManager$Int23, _TelemetryManager$Int24, _TelemetryManager$Int25, _TelemetryManager$Int26;
54
54
  if ((_TelemetryManager$Int11 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int11 !== void 0 && _TelemetryManager$Int11.ariaConfig) {
55
55
  var _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14, _TelemetryManager$Int15, _TelemetryManager$Int16, _TelemetryManager$Int17, _TelemetryManager$Int18, _TelemetryManager$Int19;
56
56
  loggers.push((0, _ariaTelemetryLogger.ariaTelemetryLogger)(((_TelemetryManager$Int12 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : (_TelemetryManager$Int13 = _TelemetryManager$Int12.ariaConfig) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.ariaTelemetryKey) ?? _defaultAriaConfig.defaultAriaConfig.ariaTelemetryKey, ((_TelemetryManager$Int14 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : (_TelemetryManager$Int15 = _TelemetryManager$Int14.ariaConfig) === null || _TelemetryManager$Int15 === void 0 ? void 0 : _TelemetryManager$Int15.disableCookieUsage) ?? _defaultAriaConfig.defaultAriaConfig.disableCookieUsage, ((_TelemetryManager$Int16 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int16 === void 0 ? void 0 : (_TelemetryManager$Int17 = _TelemetryManager$Int16.ariaConfig) === null || _TelemetryManager$Int17 === void 0 ? void 0 : _TelemetryManager$Int17.collectorUriForTelemetry) ?? _defaultAriaConfig.defaultAriaConfig.collectorUriForTelemetry, ((_TelemetryManager$Int18 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int18 === void 0 ? void 0 : (_TelemetryManager$Int19 = _TelemetryManager$Int18.ariaConfig) === null || _TelemetryManager$Int19 === void 0 ? void 0 : _TelemetryManager$Int19.ariaTelemetryApplicationName) ?? _defaultAriaConfig.defaultAriaConfig.ariaTelemetryApplicationName));
@@ -61,12 +61,15 @@ const RegisterLoggers = () => {
61
61
  loggers.push(logger);
62
62
  });
63
63
  }
64
- if (((_TelemetryManager$Int22 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int22 === void 0 ? void 0 : (_TelemetryManager$Int23 = _TelemetryManager$Int22.appInsightsConfig) === null || _TelemetryManager$Int23 === void 0 ? void 0 : _TelemetryManager$Int23.appInsightsDisabled) === false) {
65
- var _TelemetryManager$Int24;
66
- if ((_TelemetryManager$Int24 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int24 !== void 0 && _TelemetryManager$Int24.appInsightsConfig.appInsightsKey) {
67
- var _TelemetryManager$Int25;
68
- loggers.push((0, _appInsightsLogger.appInsightsLogger)((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : _TelemetryManager$Int25.appInsightsConfig.appInsightsKey));
69
- }
64
+ const chatConfigAppInsightsKey = (_TelemetryManager$Int22 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int22 === void 0 ? void 0 : _TelemetryManager$Int22.chatConfigAppInsightsKey;
65
+ const appInsightsKeyFromUser = (_TelemetryManager$Int23 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int23 === void 0 ? void 0 : (_TelemetryManager$Int24 = _TelemetryManager$Int23.appInsightsConfig) === null || _TelemetryManager$Int24 === void 0 ? void 0 : _TelemetryManager$Int24.appInsightsKey;
66
+ // when chatConfig has AppInsightsInstrumentationKey
67
+ if (chatConfigAppInsightsKey) {
68
+ loggers.push((0, _appInsightsLogger.appInsightsLogger)(chatConfigAppInsightsKey));
69
+ }
70
+ // when key set through appInsightsConfig
71
+ else if (appInsightsKeyFromUser && ((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : (_TelemetryManager$Int26 = _TelemetryManager$Int25.appInsightsConfig) === null || _TelemetryManager$Int26 === void 0 ? void 0 : _TelemetryManager$Int26.appInsightsDisabled) === false) {
72
+ loggers.push((0, _appInsightsLogger.appInsightsLogger)(appInsightsKeyFromUser));
70
73
  }
71
74
  }
72
75
  };
@@ -14,11 +14,11 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
14
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
15
  var AllowedKeys;
16
16
  (function (AllowedKeys) {
17
- AllowedKeys["OrganizationId"] = "OrganizationId";
18
- AllowedKeys["ConversationId"] = "LiveWorkItemId";
17
+ AllowedKeys["OrganizationId"] = "powerplatform.analytics.resource.organization.id";
18
+ AllowedKeys["ConversationId"] = "powerplatform.analytics.resource.id";
19
19
  AllowedKeys["ElapsedTimeInMilliseconds"] = "Duration";
20
- AllowedKeys["Description"] = "Description";
21
- AllowedKeys["ChannelId"] = "ChannelType";
20
+ AllowedKeys["Description"] = "omnichannel.description";
21
+ AllowedKeys["ChannelId"] = "omnichannel.channel.type";
22
22
  AllowedKeys["LCWRuntimeId"] = "ClientSessionId";
23
23
  })(AllowedKeys || (AllowedKeys = {}));
24
24
  let initializationPromise = null;
@@ -95,8 +95,8 @@ const appInsightsLogger = appInsightsKey => {
95
95
  if (eventName) {
96
96
  const trackingEventName = getTrackingEventName(logLevel, eventName);
97
97
  const eventProperties = setEventProperties(trackingEventName, telemetryInfo);
98
- _logger.trackEvent({
99
- name: trackingEventName,
98
+ _logger.trackTrace({
99
+ message: trackingEventName,
100
100
  properties: eventProperties
101
101
  });
102
102
  }
@@ -142,7 +142,7 @@ const appInsightsLogger = appInsightsKey => {
142
142
  // Additional properties
143
143
  eventProperties["ConversationStage"] = customProperties.ConversationStage ?? _TelemetryConstants.ConversationStage.CSREngagement;
144
144
  eventProperties["Scenario"] = "Conversation Diagnostics";
145
- eventProperties["OperationName"] = eventName.includes(": ") ? eventName.split(": ")[1] : eventName;
145
+ eventProperties["powerplatform.analytics.subscenario"] = eventName.includes(": ") ? eventName.split(": ")[1] : eventName;
146
146
  return eventProperties;
147
147
  }
148
148
  function getTrackingEventName(logLevel, eventName) {
@@ -7,7 +7,9 @@ exports.getCustomEventValue = exports.getConversationDetailsCall = exports.getBr
7
7
  exports.getDeviceType = getDeviceType;
8
8
  exports.getWidgetEndChatEventName = exports.getWidgetCacheIdfromProps = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = void 0;
9
9
  exports.isEndConversationDueToOverflowActivity = isEndConversationDueToOverflowActivity;
10
- exports.setTabIndices = exports.setOcUserAgent = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isValidCustomEvent = exports.isUndefinedOrEmpty = exports.isThisSessionPopout = exports.isNullOrUndefined = exports.isNullOrEmptyString = void 0;
10
+ exports.parseAdaptiveCardPayload = exports.newGuid = exports.isValidCustomEvent = exports.isUndefinedOrEmpty = exports.isThisSessionPopout = exports.isNullOrUndefined = exports.isNullOrEmptyString = void 0;
11
+ exports.parseBooleanFromConfig = parseBooleanFromConfig;
12
+ exports.setTabIndices = exports.setOcUserAgent = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseLowerCaseString = void 0;
11
13
  var _Constants = require("./Constants");
12
14
  var _TelemetryConstants = require("./telemetry/TelemetryConstants");
13
15
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
@@ -519,4 +521,15 @@ exports.getCustomEventValue = getCustomEventValue;
519
521
  function isEndConversationDueToOverflowActivity(activity) {
520
522
  var _activity$channelData, _activity$channelData2;
521
523
  return (activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.tags) && Array.isArray(activity === null || activity === void 0 ? void 0 : (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.tags) && activity.channelData.tags.includes(_Constants.Constants.EndConversationDueToOverflow);
524
+ }
525
+
526
+ /**
527
+ * Parses a value that can be boolean or string ("true"/"false") into a boolean.
528
+ * Handles null/undefined by returning false.
529
+ *
530
+ * @param value - The value to parse (can be boolean, string, null, or undefined)
531
+ * @returns true if value is true or "true" (case-insensitive), false otherwise
532
+ */
533
+ function parseBooleanFromConfig(value) {
534
+ return value === true || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "true";
522
535
  }
@@ -19,11 +19,12 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
19
19
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
20
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
21
21
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
+ // eslint-disable-next-line @typescript-eslint/ban-types
22
23
  const RenderChildrenFunction = _ref => {
23
24
  let {
24
25
  children
25
26
  } = _ref;
26
- return typeof children === 'function' ? children() : children;
27
+ return typeof children === "function" ? children() : children;
27
28
  };
28
29
  let ErrorBoundary = /*#__PURE__*/function (_Component) {
29
30
  _inherits(ErrorBoundary, _Component);
@@ -9,7 +9,7 @@ var ChatWidgetEvents;
9
9
  ChatWidgetEvents["ADD_ACTIVITY"] = "CHAT_WIDGET/ADD_ACTIVITY";
10
10
  ChatWidgetEvents["FETCH_PERSISTENT_CHAT_HISTORY"] = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY";
11
11
  ChatWidgetEvents["NO_MORE_HISTORY_AVAILABLE"] = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE";
12
- ChatWidgetEvents["HIDE_LOADING_BANNER"] = "CHAT_WIDGET/HIDE_LOADING_BANNER";
12
+ ChatWidgetEvents["HISTORY_LOAD_ERROR"] = "CHAT_WIDGET/HISTORY_LOAD_ERROR";
13
13
  })(ChatWidgetEvents || (ChatWidgetEvents = {}));
14
14
  var _default = ChatWidgetEvents;
15
15
  exports.default = _default;
@@ -36,7 +36,7 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
36
36
  _defineProperty(this, "facadeChatSDK", void 0);
37
37
  _defineProperty(this, "lastMessage", null);
38
38
  _defineProperty(this, "count", 0);
39
- _defineProperty(this, "pageSize", 4);
39
+ _defineProperty(this, "pageSize", _defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps.pageSize);
40
40
  _defineProperty(this, "isCurrentlyPulling", false);
41
41
  _defineProperty(this, "pageTokenInTransitSet", new Set());
42
42
  _defineProperty(this, "resetEventListener", _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.PersistentConversationReset).subscribe(() => {
@@ -48,7 +48,7 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
48
48
  Event: _TelemetryConstants.TelemetryEvent.LCWPersistentConversationHandlerInitialized,
49
49
  Description: "PersistentConversationHandler initialized",
50
50
  CustomProperties: {
51
- pageSize: this.pageSize
51
+ pageSize: _defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps.pageSize
52
52
  }
53
53
  });
54
54
  }
@@ -61,8 +61,8 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
61
61
  ...props
62
62
  };
63
63
 
64
- // if the props is not existent or is not anumber then default to 4
65
- this.pageSize = ((_this$appliedProps = this.appliedProps) === null || _this$appliedProps === void 0 ? void 0 : _this$appliedProps.pageSize) !== undefined && !isNaN(this.appliedProps.pageSize) ? this.appliedProps.pageSize : 4;
64
+ // if the props is not existent or is not a number then default to defaultPersistentChatHistoryProps.pageSize
65
+ this.pageSize = ((_this$appliedProps = this.appliedProps) === null || _this$appliedProps === void 0 ? void 0 : _this$appliedProps.pageSize) !== undefined && !isNaN(this.appliedProps.pageSize) ? this.appliedProps.pageSize : _defaultPersistentChatHistoryProps.defaultPersistentChatHistoryProps.pageSize;
66
66
  }
67
67
  }, {
68
68
  key: "reset",
@@ -107,12 +107,23 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
107
107
  try {
108
108
  var _ref;
109
109
  const messages = await this.fetchHistoryMessages();
110
- if (messages === null || (messages === null || messages === void 0 ? void 0 : messages.length) === 0) {
110
+
111
+ // Handle error case - null indicates an error occurred
112
+ // Don't mark as last pull to allow retry on next attempt
113
+ if (messages == null) {
114
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
115
+ Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryReturnedNull,
116
+ Description: "History pull returned null - Possible error occurred, will retry on next scroll",
117
+ ElapsedTimeInMilliseconds: pullTimer.milliSecondsElapsed
118
+ });
119
+ return;
120
+ }
121
+
122
+ // Handle legitimate end of history - empty array
123
+ if (messages.length === 0) {
111
124
  this.isLastPull = true;
112
125
  // Dispatch event to notify UI that no more history is available
113
126
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
114
- // Also hide the loading banner
115
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
116
127
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
117
128
  Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
118
129
  Description: "History pull completed - no more messages",
@@ -122,9 +133,6 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
122
133
  }
123
134
  const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
124
135
  this.processHistoryMessages(messagesDescOrder);
125
-
126
- // Dispatch event to hide the loading banner after messages are processed
127
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
128
136
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
129
137
  Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
130
138
  Description: "History pull completed successfully",
@@ -180,7 +188,6 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
180
188
  if (!this.shouldPull()) {
181
189
  // Dispatch event to ensure banner is hidden when no more pulls are needed
182
190
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
183
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
184
191
  return [];
185
192
  }
186
193
  const options = {
@@ -206,24 +213,20 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
206
213
  this.isLastPull = true;
207
214
  // Dispatch event when we reach the end of available history
208
215
  (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
209
- // Also hide the loading banner
210
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
211
216
  return [];
212
217
  }
213
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
214
218
  return messages;
215
219
  } catch (error) {
216
220
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
217
221
  Event: _TelemetryConstants.TelemetryEvent.FetchPersistentChatHistoryFailed,
218
222
  ExceptionDetails: error
219
223
  });
220
- this.isLastPull = true;
221
- this.pageToken = null;
222
- // Dispatch event when there's an error to stop loading banner
223
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.NO_MORE_HISTORY_AVAILABLE);
224
- // Also hide the loading banner
225
- (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HIDE_LOADING_BANNER);
226
- return [];
224
+
225
+ // On error, dispatch HISTORY_LOAD_ERROR to hide loading banner without marking conversation as ended
226
+ // This allows recovery on the next attempt (e.g., transient network errors)
227
+ // Return null to distinguish error from legitimate empty history
228
+ (0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HISTORY_LOAD_ERROR);
229
+ return null;
227
230
  }
228
231
  }
229
232
  }, {
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.defaultPersistentChatHistoryProps = void 0;
7
7
  const defaultPersistentChatHistoryProps = {
8
- persistentChatHistoryEnabled: true,
9
- pageSize: 4,
8
+ pageSize: 10,
10
9
  dividerActivityStyle: {
11
10
  border: "1px solid rgb(96, 94, 92, 0.5)",
12
11
  margin: "10px 20%"
@@ -12,6 +12,8 @@ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components
12
12
  var _ConversationState = require("../../../contexts/common/ConversationState");
13
13
  var _LazyLoadActivity = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity");
14
14
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
15
+ var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
16
+ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
15
17
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
16
18
  var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
17
19
  var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
@@ -201,6 +203,18 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
201
203
  facadeChatSDK.destroy();
202
204
  }
203
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
+ }
204
218
  if (!skipCloseChat) {
205
219
  try {
206
220
  var _props$webChatContain;
@@ -240,17 +254,17 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
240
254
  });
241
255
  closeChatWidget(dispatch, setWebChatStyles, props);
242
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
+ });
243
266
  }
244
267
  }
245
- if (postMessageToOtherTab) {
246
- const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
247
- _omnichannelChatComponents.BroadcastService.postMessage({
248
- eventName: endChatEventName,
249
- payload: {
250
- runtimeId: _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId
251
- }
252
- });
253
- }
254
268
  };
255
269
  exports.endChat = endChat;
256
270
  const callingStateCleanUp = dispatch => {
@@ -331,6 +345,9 @@ const closeChatStateCleanUp = dispatch => {
331
345
  payload: {}
332
346
  });
333
347
 
348
+ // Dismiss the chat disconnect notification banner if it was shown
349
+ _NotificationHandler.NotificationHandler.dismissNotification(_NotificationScenarios.NotificationScenarios.ChatDisconnect);
350
+
334
351
  // Clear live chat context only if chat widget is fully closed to support transcript calls after sessionclose is called
335
352
  dispatch({
336
353
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
@@ -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");