@microsoft/omnichannel-chat-widget 1.8.4-main.7bdb634 → 1.8.4-main.c687f88

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 (104) hide show
  1. package/README.md +27 -0
  2. package/lib/cjs/common/Constants.js +3 -0
  3. package/lib/cjs/common/telemetry/AppInsightsEvents.js +14 -9
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +15 -2
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
  6. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +29 -13
  7. package/lib/cjs/common/utils.js +14 -1
  8. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
  9. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +20 -1
  10. package/lib/cjs/components/errorboundary/ErrorBoundary.js +2 -1
  11. package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
  12. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
  13. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +26 -20
  14. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
  15. package/lib/cjs/components/livechatwidget/common/endChat.js +26 -9
  16. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +9 -2
  17. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
  18. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  19. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  20. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  21. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
  22. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
  23. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -28
  24. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +37 -8
  25. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
  26. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +28 -30
  27. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +12 -12
  28. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  29. package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
  30. package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  31. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +30 -1
  33. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -2
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -0
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  38. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
  39. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
  40. package/lib/cjs/contexts/createReducer.js +15 -0
  41. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  42. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  43. package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
  44. package/lib/esm/common/Constants.js +3 -0
  45. package/lib/esm/common/telemetry/AppInsightsEvents.js +14 -9
  46. package/lib/esm/common/telemetry/TelemetryConstants.js +13 -1
  47. package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
  48. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +30 -14
  49. package/lib/esm/common/utils.js +11 -0
  50. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
  51. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +20 -1
  52. package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -2
  53. package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
  54. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
  55. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +26 -20
  56. package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
  57. package/lib/esm/components/livechatwidget/common/endChat.js +26 -9
  58. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +9 -2
  59. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
  60. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
  61. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
  62. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
  63. package/lib/esm/components/livechatwidget/common/startChat.js +7 -3
  64. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
  65. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +125 -29
  66. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +39 -10
  67. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
  68. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +29 -34
  69. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +12 -12
  70. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
  71. package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
  72. package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
  73. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
  74. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +30 -1
  75. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
  76. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -2
  77. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -0
  78. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -0
  79. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
  80. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
  81. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
  82. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
  83. package/lib/esm/contexts/createReducer.js +15 -0
  84. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
  85. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
  86. package/lib/esm/plugins/newMessageEventHandler.js +4 -1
  87. package/lib/types/common/Constants.d.ts +3 -0
  88. package/lib/types/common/telemetry/TelemetryConstants.d.ts +12 -1
  89. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
  90. package/lib/types/common/utils.d.ts +9 -1
  91. package/lib/types/components/errorboundary/ErrorBoundary.d.ts +1 -1
  92. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +1 -1
  93. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
  94. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
  95. package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +5 -1
  96. package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
  97. package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +1 -2
  98. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +1 -1
  99. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
  100. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
  101. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  102. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +5 -0
  103. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
  104. package/package.json +3 -3
@@ -4,18 +4,26 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.localizedStringsBotInitialsMiddleware = exports.getOverriddenLocalizedStrings = void 0;
7
+ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
7
8
  var _Constants = require("../../../../../common/Constants");
8
- var _utils = require("../../../../../common/utils");
9
- var _defaultWebChatStyles = require("../../../common/defaultStyles/defaultWebChatStyles");
10
9
  var _WebChatActionType = require("../../enums/WebChatActionType");
10
+ var _defaultWebChatStyles = require("../../../common/defaultStyles/defaultWebChatStyles");
11
+ var _utils = require("../../../../../common/utils");
11
12
  /* eslint-disable @typescript-eslint/no-explicit-any */
12
13
 
13
14
  let currentAgentInitials = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
14
- const localizedStringsBotInitialsMiddleware = () => _ref => {
15
+
16
+ // Optional external updater (React context dispatch wrapper) set at runtime
17
+ let externalInitialsUpdater;
18
+ const localizedStringsBotInitialsMiddleware = onInitialsChange => _ref => {
15
19
  let {
16
20
  dispatch
17
21
  } = _ref;
18
22
  return next => action => {
23
+ if (onInitialsChange && !externalInitialsUpdater) {
24
+ externalInitialsUpdater = onInitialsChange; // capture once
25
+ }
26
+
19
27
  if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
20
28
  var _action$payload, _activity$from;
21
29
  const activity = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
@@ -23,10 +31,25 @@ const localizedStringsBotInitialsMiddleware = () => _ref => {
23
31
  var _activity$channelData, _activity$channelData2, _activity$tags;
24
32
  const agentName = activity.from.name.trim();
25
33
  const isSystemMessage = agentName === "__agent__" || agentName.startsWith("__") || ((_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : (_activity$channelData2 = _activity$channelData.tags) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.includes(_Constants.Constants.systemMessageTag)) || ((_activity$tags = activity.tags) === null || _activity$tags === void 0 ? void 0 : _activity$tags.includes(_Constants.Constants.systemMessageTag));
26
- if (!isSystemMessage && agentName !== "") {
27
- // Update initials for valid agent/bot names
34
+ if (!isSystemMessage && agentName) {
28
35
  const newInitials = (0, _utils.getIconText)(agentName) || currentAgentInitials;
29
- currentAgentInitials = newInitials;
36
+ if (newInitials !== currentAgentInitials) {
37
+ var _externalInitialsUpda;
38
+ currentAgentInitials = newInitials;
39
+ // Notify external React context if provided
40
+ (_externalInitialsUpda = externalInitialsUpdater) === null || _externalInitialsUpda === void 0 ? void 0 : _externalInitialsUpda(currentAgentInitials || "");
41
+ // Broadcast (optional) for multi-tab sync without forcing consumers
42
+ _omnichannelChatComponents.BroadcastService.postMessage({
43
+ eventName: "BotAvatarInitialsUpdated",
44
+ payload: {
45
+ initials: currentAgentInitials
46
+ }
47
+ });
48
+ // Also dispatch a no-op action into WebChat store to encourage re-render (cheap)
49
+ dispatch({
50
+ type: "__BOT_INITIALS_UPDATED__"
51
+ });
52
+ }
30
53
  }
31
54
  }
32
55
  }
@@ -40,7 +63,6 @@ const getOverriddenLocalizedStrings = existingOverrides => {
40
63
  ...strings,
41
64
  ...existingOverrides
42
65
  };
43
-
44
66
  // Apply dynamic bot initials to alt text if not already overridden through props
45
67
  if (!(existingOverrides !== null && existingOverrides !== void 0 && existingOverrides.ACTIVITY_BOT_SAID_ALT)) {
46
68
  result.ACTIVITY_BOT_SAID_ALT = `${currentAgentInitials} said:`;
@@ -56,4 +56,5 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
56
56
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_ENABLED"] = 46] = "SET_CONVERSATIONAL_SURVEY_ENABLED";
57
57
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATIONAL_SURVEY_DISPLAY"] = 47] = "SET_CONVERSATIONAL_SURVEY_DISPLAY";
58
58
  LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 48] = "GET_IN_MEMORY_STATE";
59
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_AVATAR_INITIALS"] = 49] = "SET_BOT_AVATAR_INITIALS";
59
60
  })(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
@@ -10,6 +10,7 @@ var _ConversationState = require("./ConversationState");
10
10
  var _StartChatFailureType = require("./StartChatFailureType");
11
11
  var _defaultClientDataStoreProvider = require("../../common/storage/default/defaultClientDataStoreProvider");
12
12
  var _defaultMiddlewareLocalizedTexts = require("../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
13
+ var _defaultWebChatStyles = require("../../components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles");
13
14
  const getLiveChatWidgetContextInitialState = props => {
14
15
  var _props$controlProps, _props$webChatContain;
15
16
  const isOutsideOperatingHours = () => {
@@ -39,6 +40,10 @@ const getLiveChatWidgetContextInitialState = props => {
39
40
  initialStateFromCache.domainStates.liveChatConfig = props.chatConfig;
40
41
  // Cache the result of isOutsideOperatingHours() to ensure consistency
41
42
  initialStateFromCache.appStates.outsideOperatingHours = outsideOperatingHours;
43
+ // Backward compatibility: if botAvatarInitials not cached (older sessions), seed with default
44
+ if (!initialStateFromCache.domainStates.botAvatarInitials) {
45
+ initialStateFromCache.domainStates.botAvatarInitials = _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials;
46
+ }
42
47
  return initialStateFromCache;
43
48
  }
44
49
  const LiveChatWidgetContextInitialState = {
@@ -62,7 +67,8 @@ const getLiveChatWidgetContextInitialState = props => {
62
67
  transcriptRequestId: "",
63
68
  confirmationPaneConfirmedOptionClicked: false,
64
69
  confirmationState: _Constants.ConfirmationState.NotSet,
65
- startChatFailureType: _StartChatFailureType.StartChatFailureType.Generic
70
+ startChatFailureType: _StartChatFailureType.StartChatFailureType.Generic,
71
+ botAvatarInitials: _defaultWebChatStyles.defaultWebChatStyles.botAvatarInitials
66
72
  },
67
73
  appStates: {
68
74
  conversationState: _ConversationState.ConversationState.Closed,
@@ -562,6 +562,21 @@ const reducer = (state, action) => {
562
562
  widgetSize: action.payload
563
563
  }
564
564
  };
565
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_BOT_AVATAR_INITIALS:
566
+ inMemory = {
567
+ ...inMemory,
568
+ domainStates: {
569
+ ...inMemory.domainStates,
570
+ botAvatarInitials: action.payload
571
+ }
572
+ };
573
+ return {
574
+ ...state,
575
+ domainStates: {
576
+ ...state.domainStates,
577
+ botAvatarInitials: action.payload
578
+ }
579
+ };
565
580
  case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID:
566
581
  inMemory = {
567
582
  ...inMemory,
@@ -36,7 +36,7 @@ const createTrackingForFirstMessage = () => {
36
36
  * Starts tracking the time for the first bot message after widget loads.
37
37
  * Sets a 5-second timeout to auto-reset if no bot message is received.
38
38
  */
39
- const widgetLoadListener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.TelemetryEvent.WidgetLoadComplete).subscribe(() => {
39
+ const widgetLoadListener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.TelemetryEvent.StartChatComplete).subscribe(() => {
40
40
  if (isTracking) return;
41
41
  isTracking = true;
42
42
  startTime = new Date().getTime();
@@ -91,7 +91,8 @@ const createTrackingForFirstMessage = () => {
91
91
  CustomProperties: {
92
92
  elapsedTime,
93
93
  widgetLoadedAt: startTime,
94
- botMessage: stopTrackingMessage
94
+ botMessage: stopTrackingMessage,
95
+ type: payload === null || payload === void 0 ? void 0 : payload.type
95
96
  }
96
97
  });
97
98
  disconnectListener();
@@ -7,6 +7,7 @@ exports.FirstResponseLatencyTracker = void 0;
7
7
  var _TelemetryConstants = require("../common/telemetry/TelemetryConstants");
8
8
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
9
9
  var _TelemetryHelper = require("../common/telemetry/TelemetryHelper");
10
+ var _Constants = require("../common/Constants");
10
11
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
12
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
12
13
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -133,7 +134,8 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
133
134
  CustomProperties: {
134
135
  elapsedTime,
135
136
  userMessage: this.startTrackingMessage,
136
- botMessage: this.stopTrackingMessage
137
+ botMessage: this.stopTrackingMessage,
138
+ type: payload === null || payload === void 0 ? void 0 : payload.type
137
139
  }
138
140
  });
139
141
  }
@@ -174,7 +176,9 @@ let FirstResponseLatencyTracker = /*#__PURE__*/function () {
174
176
  value: function stopClock(payload) {
175
177
  try {
176
178
  if (!payload || !payload.Id) {
177
- throw new Error("Invalid payload");
179
+ if ((payload === null || payload === void 0 ? void 0 : payload.type) !== _Constants.Constants.typing) {
180
+ throw new Error("Invalid payload");
181
+ }
178
182
  }
179
183
 
180
184
  // Only allow stopTracking if sender is valid and tracking is active
@@ -84,6 +84,9 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
84
84
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
85
  const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
86
86
  if (messageHasNoTags && messageHasNoText && messageHasNoAttachments) {
87
+ if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants2.Constants.typing) {
88
+ return true;
89
+ }
87
90
  return false;
88
91
  }
89
92
  return true;
@@ -112,7 +115,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
112
115
  });
113
116
  };
114
117
  const raiseMessageEvent = activity => {
115
- if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants2.Constants.message) {
118
+ if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants2.Constants.message || (activity === null || activity === void 0 ? void 0 : activity.type) === _Constants2.Constants.typing) {
116
119
  const scenarioType = (0, _util.getScenarioType)(activity);
117
120
  switch (scenarioType) {
118
121
  case _Constants.ScenarioType.UserSendMessageStrategy:
@@ -61,6 +61,7 @@ _defineProperty(Constants, "queuePositionMessageTag", "queueposition");
61
61
  _defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
62
62
  _defineProperty(Constants, "message", "message");
63
63
  _defineProperty(Constants, "hiddenTag", "Hidden");
64
+ _defineProperty(Constants, "typing", "typing");
64
65
  // messageTimestampMiddleware
65
66
  _defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
66
67
  _defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
@@ -135,6 +136,7 @@ _defineProperty(Constants, "customEventName", "customEventName");
135
136
  _defineProperty(Constants, "customEventValue", "customEventValue");
136
137
  _defineProperty(Constants, "Hidden", "Hidden");
137
138
  _defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
139
+ _defineProperty(Constants, "SkipSessionCloseForPersistentChatFlag", "skipSessionCloseForPersistentChat");
138
140
  export const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
139
141
  _classCallCheck(this, Regex);
140
142
  }), _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);
@@ -344,6 +346,7 @@ _defineProperty(PrepareEndChatDescriptionConstants, "ConversationEndedBy", "Conv
344
346
  _defineProperty(PrepareEndChatDescriptionConstants, "PrepareEndChatError", "There's an error while preparing to end chat. Closing chat widget.");
345
347
  _defineProperty(PrepareEndChatDescriptionConstants, "WidgetLoadFailedAfterSessionInit", "SessionInit was successful, but widget load failed. Ending chat to avoid ghost chats in OC.");
346
348
  _defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceived", "Received InitiateEndChat BroadcastEvent while conversation state is not Active. Ending chat.");
349
+ _defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceivedActiveChat", "Received InitiateEndChat BroadcastEvent while conversation state is Active. Updating conversation states.");
347
350
  _defineProperty(PrepareEndChatDescriptionConstants, "EndChatReceivedFromOtherTabs", "Received EndChat BroadcastEvent from other tabs. Closing this chat.");
348
351
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseChatOnFailureOrPostChat", "Customer is trying to close chat widget on start chat failure or post chat pane.");
349
352
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseInactiveChat", "Chat was Inactive and customer is trying to close chat widget or refreshing the page.");
@@ -1,10 +1,10 @@
1
1
  export const AppInsightsEventMapping = {
2
2
  "LCWChatButtonClicked": "LCWChatButtonActionStarted",
3
- "WidgetLoadStarted": "WidgetStartChatStarted",
4
- "WidgetLoadComplete": "WidgetStartChatCompleted",
5
- "WidgetLoadFailed": "WidgetStartChatFailed",
6
- "PrechatSubmitted": "PrechatSubmitCompleted",
7
- "StartChatEventRecevied": "StartChatEventReceivedCompleted",
3
+ "UXLCWChatButtonLoadingStart": "LiveChatWidgetChatButtonLoadingStarted",
4
+ "UXLCWChatButtonLoadingCompleted": "LiveChatWidgetChatButtonLoadingCompleted",
5
+ "UXPrechatPaneStart": "PrechatSurveyStarted",
6
+ "UXPrechatPaneCompleted": "PrechatSurveyCompleted",
7
+ "PrechatSubmitted": "PrechatSurveySubmitCompleted",
8
8
  "EndChatEventReceived": "EndChatEventReceivedCompleted",
9
9
  "EmailTranscriptSent": "EmailTranscriptActionCompleted",
10
10
  "EmailTranscriptFailed": "EmailTranscriptActionFailed",
@@ -12,13 +12,18 @@ export const AppInsightsEventMapping = {
12
12
  "HeaderMinimizeButtonClicked": "MinimizeChatActionStarted",
13
13
  "DownloadTranscriptButtonClicked": "DownloadTranscriptActionStarted",
14
14
  "EmailTranscriptButtonClicked": "EmailTranscriptButtonActionStarted",
15
- "CustomerVoiceFormResponseSubmitted": "CustomerVoiceFormResponseSubmitCompleted",
16
- "StartProactiveChatEventReceived": "StartProactiveChatEventReceivedCompleted",
17
15
  "ProactiveChatRejected": "ProactiveChatTimeOutCompleted",
18
16
  "MessageSent": "MessageSentCompleted",
19
17
  "MessageReceived": "MessageReceivedCompleted",
20
18
  "SystemMessageReceived": "SystemMessageReceivedCompleted",
21
- "RehydrateMessageReceived": "RehydrateMessageReceivedCompleted",
19
+ "RehydrateMessageReceived": "ChatHistoryMessageReceivedCompleted",
22
20
  "CustomContextReceived": "CustomContextReceivedCompleted",
23
- "PostChatContextCallSucceed": "PostChatContextCallCompleted"
21
+ "NewTokenValidationStarted": "AuthTokenValidationStarted",
22
+ "NewTokenValidationCompleted": "AuthTokenValidationCompleted",
23
+ "NewTokenValidationFailed": "AuthTokenValidationFailed",
24
+ "UXPostChatPaneStarted": "PostChatSurveyStarted",
25
+ "UXPostChatPaneCompleted": "PostChatSurveyCompleted",
26
+ "WidgetLoadStarted": "ChatSessionInitializationStarted",
27
+ "WidgetLoadComplete": "ChatSessionInitializationCompleted",
28
+ "WidgetLoadFailed": "ChatSessionInitializationFailed"
24
29
  };
@@ -118,6 +118,7 @@ export let TelemetryEvent;
118
118
  TelemetryEvent["EndChatFailed"] = "EndChatFailed";
119
119
  TelemetryEvent["SettingCustomContext"] = "SettingCustomContext";
120
120
  TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
121
+ TelemetryEvent["PersistentChatHistoryEnabled"] = "PersistentChatHistoryEnabled";
121
122
  TelemetryEvent["LCWChatButtonActionCompleted"] = "LCWChatButtonActionCompleted";
122
123
  TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
123
124
  TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
@@ -282,6 +283,8 @@ export let TelemetryEvent;
282
283
  TelemetryEvent["UXCitationPaneCompleted"] = "UXCitationPaneCompleted";
283
284
  TelemetryEvent["UXLiveChatWidgetStart"] = "UXLiveChatWidgetStart";
284
285
  TelemetryEvent["UXLiveChatWidgetCompleted"] = "UXLiveChatWidgetCompleted";
286
+ TelemetryEvent["UXPostChatPaneStarted"] = "UXPostChatPaneStarted";
287
+ TelemetryEvent["UXPostChatPaneCompleted"] = "UXPostChatPaneCompleted";
285
288
  TelemetryEvent["AppInsightsInitialized"] = "AppInsightsInitialized";
286
289
  TelemetryEvent["AppInsightsInitFailed"] = "AppInsightsInitFailed";
287
290
  TelemetryEvent["ConvertPersistentChatHistoryMessageToActivityFailed"] = "ConvertPersistentChatHistoryMessageToActivityFailed";
@@ -297,6 +300,7 @@ export let TelemetryEvent;
297
300
  TelemetryEvent["LCWPersistentConversationHandlerInitialized"] = "LCWPersistentConversationHandlerInitialized";
298
301
  TelemetryEvent["LCWPersistentHistoryPullBlocked"] = "LCWPersistentHistoryPullBlocked";
299
302
  TelemetryEvent["LCWPersistentHistoryPullCompleted"] = "LCWPersistentHistoryPullCompleted";
303
+ TelemetryEvent["LCWPersistentHistoryReturnedNull"] = "LCWPersistentHistoryReturnedNull";
300
304
  TelemetryEvent["LCWLazyLoadInitializationStarted"] = "LCWLazyLoadInitializationStarted";
301
305
  TelemetryEvent["LCWLazyLoadContainerNotFound"] = "LCWLazyLoadContainerNotFound";
302
306
  TelemetryEvent["LCWLazyLoadInitializationCompleted"] = "LCWLazyLoadInitializationCompleted";
@@ -306,10 +310,12 @@ export let TelemetryEvent;
306
310
  TelemetryEvent["LCWLazyLoadActivityMounted"] = "LCWLazyLoadActivityMounted";
307
311
  TelemetryEvent["LCWLazyLoadReset"] = "LCWLazyLoadReset";
308
312
  TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
313
+ TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
309
314
  TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
310
315
  TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
311
316
  TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
312
317
  TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
318
+ TelemetryEvent["StartChatComplete"] = "StartChatComplete";
313
319
  })(TelemetryEvent || (TelemetryEvent = {}));
314
320
  export let TelemetryConstants = /*#__PURE__*/function () {
315
321
  function TelemetryConstants() {
@@ -439,4 +445,10 @@ export let TelemetryConstants = /*#__PURE__*/function () {
439
445
  }
440
446
  }]);
441
447
  return TelemetryConstants;
442
- }();
448
+ }();
449
+ export let ConversationStage;
450
+ (function (ConversationStage) {
451
+ ConversationStage["Initialization"] = "Initialization";
452
+ ConversationStage["CSREngagement"] = "CSR Engagement";
453
+ ConversationStage["ConversationEnd"] = "Conversation End";
454
+ })(ConversationStage || (ConversationStage = {}));
@@ -41,7 +41,7 @@ export const RegisterLoggers = () => {
41
41
  loggers.push(consoleLogger());
42
42
  }
43
43
  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) {
44
- var _TelemetryManager$Int11, _TelemetryManager$Int20, _TelemetryManager$Int21, _TelemetryManager$Int22, _TelemetryManager$Int23;
44
+ var _TelemetryManager$Int11, _TelemetryManager$Int20, _TelemetryManager$Int21, _TelemetryManager$Int22, _TelemetryManager$Int23, _TelemetryManager$Int24, _TelemetryManager$Int25, _TelemetryManager$Int26;
45
45
  if ((_TelemetryManager$Int11 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int11 !== void 0 && _TelemetryManager$Int11.ariaConfig) {
46
46
  var _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14, _TelemetryManager$Int15, _TelemetryManager$Int16, _TelemetryManager$Int17, _TelemetryManager$Int18, _TelemetryManager$Int19;
47
47
  loggers.push(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.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.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.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.ariaTelemetryApplicationName));
@@ -52,12 +52,15 @@ export const RegisterLoggers = () => {
52
52
  loggers.push(logger);
53
53
  });
54
54
  }
55
- 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) {
56
- var _TelemetryManager$Int24;
57
- if ((_TelemetryManager$Int24 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int24 !== void 0 && _TelemetryManager$Int24.appInsightsConfig.appInsightsKey) {
58
- var _TelemetryManager$Int25;
59
- loggers.push(appInsightsLogger((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : _TelemetryManager$Int25.appInsightsConfig.appInsightsKey));
60
- }
55
+ const chatConfigAppInsightsKey = (_TelemetryManager$Int22 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int22 === void 0 ? void 0 : _TelemetryManager$Int22.chatConfigAppInsightsKey;
56
+ 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;
57
+ // when chatConfig has AppInsightsInstrumentationKey
58
+ if (chatConfigAppInsightsKey) {
59
+ loggers.push(appInsightsLogger(chatConfigAppInsightsKey));
60
+ }
61
+ // when key set through appInsightsConfig
62
+ 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) {
63
+ loggers.push(appInsightsLogger(appInsightsKeyFromUser));
61
64
  }
62
65
  }
63
66
  };
@@ -1,19 +1,16 @@
1
- import { LogLevel, TelemetryEvent } from "../TelemetryConstants";
1
+ import { ConversationStage, LogLevel, TelemetryEvent } from "../TelemetryConstants";
2
2
  import ScenarioMarker from "../ScenarioMarker";
3
3
  import { TelemetryHelper } from "../TelemetryHelper";
4
4
  import { AppInsightsTelemetryMessage } from "../../Constants";
5
5
  import { AppInsightsEventMapping } from "../AppInsightsEvents";
6
6
  var AllowedKeys;
7
7
  (function (AllowedKeys) {
8
- AllowedKeys["LogLevel"] = "LogLevel";
9
- AllowedKeys["Description"] = "Description";
10
- AllowedKeys["ExceptionDetails"] = "ExceptionDetails";
11
- AllowedKeys["ChannelId"] = "ChannelId";
8
+ AllowedKeys["OrganizationId"] = "powerplatform.analytics.resource.organization.id";
9
+ AllowedKeys["ConversationId"] = "powerplatform.analytics.resource.id";
10
+ AllowedKeys["ElapsedTimeInMilliseconds"] = "Duration";
11
+ AllowedKeys["Description"] = "omnichannel.description";
12
+ AllowedKeys["ChannelId"] = "omnichannel.channel.type";
12
13
  AllowedKeys["LCWRuntimeId"] = "ClientSessionId";
13
- AllowedKeys["ConversationId"] = "LiveWorkItemId";
14
- AllowedKeys["ChatId"] = "ChatThreadId";
15
- AllowedKeys["OrganizationId"] = "OrganizationId";
16
- AllowedKeys["ElapsedTimeInMilliseconds"] = "DurationInMilliseconds";
17
14
  })(AllowedKeys || (AllowedKeys = {}));
18
15
  let initializationPromise = null;
19
16
  export const appInsightsLogger = appInsightsKey => {
@@ -86,11 +83,11 @@ export const appInsightsLogger = appInsightsKey => {
86
83
  if (!_logger) return;
87
84
  const eventName = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$paylo = telemetryInput.payload) === null || _telemetryInput$paylo === void 0 ? void 0 : _telemetryInput$paylo.Event;
88
85
  const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$telem = telemetryInput.telemetryInfo) === null || _telemetryInput$telem === void 0 ? void 0 : _telemetryInput$telem.telemetryInfo;
89
- const eventProperties = setEventProperties(telemetryInfo);
90
86
  if (eventName) {
91
87
  const trackingEventName = getTrackingEventName(logLevel, eventName);
92
- _logger.trackEvent({
93
- name: trackingEventName,
88
+ const eventProperties = setEventProperties(trackingEventName, telemetryInfo);
89
+ _logger.trackTrace({
90
+ message: trackingEventName,
94
91
  properties: eventProperties
95
92
  });
96
93
  }
@@ -107,17 +104,36 @@ export const appInsightsLogger = appInsightsKey => {
107
104
  };
108
105
 
109
106
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
- function setEventProperties(telemetryInfo) {
107
+ function setEventProperties(eventName, telemetryInfo) {
111
108
  const eventProperties = {};
112
109
  if (telemetryInfo) {
113
110
  for (const key in AllowedKeys) {
114
- const finalKey = AllowedKeys[key]; // get renamed keys for LCWRuntimeId, ConversationId, ChatId
111
+ const finalKey = AllowedKeys[key]; // get renamed keys for LCWRuntimeId, ConversationId
115
112
  const value = telemetryInfo[key];
116
113
  if (value !== undefined && value !== null && value !== "") {
117
114
  eventProperties[finalKey] = value;
118
115
  }
119
116
  }
120
117
  }
118
+ // Include exception details in description for error events
119
+ if (telemetryInfo !== null && telemetryInfo !== void 0 && telemetryInfo.ExceptionDetails) {
120
+ eventProperties[AllowedKeys.Description] = JSON.stringify(telemetryInfo.ExceptionDetails);
121
+ }
122
+ const customProperties = (() => {
123
+ if (!(telemetryInfo !== null && telemetryInfo !== void 0 && telemetryInfo.CustomProperties)) {
124
+ return {};
125
+ }
126
+ try {
127
+ return typeof telemetryInfo.CustomProperties === "string" ? JSON.parse(telemetryInfo.CustomProperties) : telemetryInfo.CustomProperties;
128
+ } catch (error) {
129
+ console.warn("Failed to parse CustomProperties:", error);
130
+ return {};
131
+ }
132
+ })();
133
+ // Additional properties
134
+ eventProperties["ConversationStage"] = customProperties.ConversationStage ?? ConversationStage.CSREngagement;
135
+ eventProperties["Scenario"] = "Conversation Diagnostics";
136
+ eventProperties["powerplatform.analytics.subscenario"] = eventName.includes(": ") ? eventName.split(": ")[1] : eventName;
121
137
  return eventProperties;
122
138
  }
123
139
  function getTrackingEventName(logLevel, eventName) {
@@ -474,4 +474,15 @@ export const getCustomEventValue = customEventPayload => {
474
474
  export function isEndConversationDueToOverflowActivity(activity) {
475
475
  var _activity$channelData, _activity$channelData2;
476
476
  return (activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : _activity$channelData.tags) && Array.isArray(activity === null || activity === void 0 ? void 0 : (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.tags) && activity.channelData.tags.includes(Constants.EndConversationDueToOverflow);
477
+ }
478
+
479
+ /**
480
+ * Parses a value that can be boolean or string ("true"/"false") into a boolean.
481
+ * Handles null/undefined by returning false.
482
+ *
483
+ * @param value - The value to parse (can be boolean, string, null, or undefined)
484
+ * @returns true if value is true or "true" (case-insensitive), false otherwise
485
+ */
486
+ export function parseBooleanFromConfig(value) {
487
+ return value === true || (value === null || value === void 0 ? void 0 : value.toString().toLowerCase()) === "true";
477
488
  }
@@ -1,4 +1,4 @@
1
- import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
1
+ import { ConversationStage, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
2
  import React, { useEffect, useRef, useState } from "react";
3
3
  import { createTimer, setFocusOnElement } from "../../common/utils";
4
4
  import { ChatButton } from "@microsoft/omnichannel-chat-components";
@@ -17,7 +17,10 @@ export const ChatButtonStateful = props => {
17
17
  uiTimer = createTimer();
18
18
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
19
19
  Event: TelemetryEvent.UXLCWChatButtonLoadingStart,
20
- Description: "Chat button loading started"
20
+ Description: "Chat button loading started",
21
+ CustomProperties: {
22
+ ConversationStage: ConversationStage.Initialization
23
+ }
21
24
  });
22
25
  }, []);
23
26
 
@@ -40,7 +43,10 @@ export const ChatButtonStateful = props => {
40
43
  ref.current = async () => {
41
44
  TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
42
45
  Event: TelemetryEvent.LCWChatButtonClicked,
43
- Description: "Chat button click action started"
46
+ Description: "Chat button click action started",
47
+ CustomProperties: {
48
+ ConversationStage: ConversationStage.Initialization
49
+ }
44
50
  });
45
51
  if (state.appStates.isMinimized) {
46
52
  dispatch({
@@ -60,7 +66,10 @@ export const ChatButtonStateful = props => {
60
66
  }
61
67
  TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
62
68
  Event: TelemetryEvent.LCWChatButtonActionCompleted,
63
- Description: "Chat button action completed"
69
+ Description: "Chat button action completed",
70
+ CustomProperties: {
71
+ ConversationStage: ConversationStage.Initialization
72
+ }
64
73
  });
65
74
  };
66
75
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
@@ -114,7 +123,10 @@ export const ChatButtonStateful = props => {
114
123
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
115
124
  Event: TelemetryEvent.UXLCWChatButtonLoadingCompleted,
116
125
  Description: "Chat button loading completed",
117
- ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
126
+ ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed,
127
+ CustomProperties: {
128
+ ConversationStage: ConversationStage.Initialization
129
+ }
118
130
  });
119
131
  }, []);
120
132
  useEffect(() => {
@@ -33,7 +33,7 @@ export const CitationPaneStateful = props => {
33
33
  const [paneStyle, setPaneStyle] = useState(null);
34
34
  const [isReady, setIsReady] = useState(false);
35
35
 
36
- // Move focus to the container
36
+ // Initial focus pattern (mirrors ConfirmationPaneStateful): focus first focusable element (will re-attempt after visibility becomes true)
37
37
  useEffect(() => {
38
38
  preventFocusToMoveOutOfElement(controlId);
39
39
  const focusableElements = findAllFocusableElement(`#${controlId}`);
@@ -55,6 +55,25 @@ export const CitationPaneStateful = props => {
55
55
  });
56
56
  }, []);
57
57
 
58
+ // Retry focus once pane is actually visible (isReady) in case initial attempt occurred while wrapper was visibility:hidden
59
+ useEffect(() => {
60
+ if (!isReady) return;
61
+ const focusableElements = findAllFocusableElement(`#${controlId}`);
62
+ if (focusableElements && focusableElements.length > 0) {
63
+ const first = focusableElements[0];
64
+ // If focused element is not already inside the pane, move focus
65
+ if (!first.contains(document.activeElement) && !(document.activeElement && document.activeElement.id.startsWith(controlId))) {
66
+ requestAnimationFrame(() => {
67
+ if (first.isConnected) {
68
+ first.focus({
69
+ preventScroll: true
70
+ });
71
+ }
72
+ });
73
+ }
74
+ }
75
+ }, [isReady, controlId]);
76
+
58
77
  // Compute the widget bounds and set pane style accordingly (95% of widget size
59
78
  // and centered inside the widget). If the widget container can't be found,
60
79
  // fall back to the default pane styles from defaultCitationPaneProps.
@@ -10,12 +10,14 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
10
10
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
11
  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; } }
12
12
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13
- import React, { Component } from 'react';
13
+ import React, { Component } from "react";
14
+
15
+ // eslint-disable-next-line @typescript-eslint/ban-types
14
16
  const RenderChildrenFunction = _ref => {
15
17
  let {
16
18
  children
17
19
  } = _ref;
18
- return typeof children === 'function' ? children() : children;
20
+ return typeof children === "function" ? children() : children;
19
21
  };
20
22
  let ErrorBoundary = /*#__PURE__*/function (_Component) {
21
23
  _inherits(ErrorBoundary, _Component);
@@ -1,4 +1,4 @@
1
- import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
1
+ import { ConversationStage, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
2
  import React, { useEffect, useRef, useState } from "react";
3
3
  import { ConfirmationState } from "../../common/Constants";
4
4
  import { ConversationState } from "../../contexts/common/ConversationState";
@@ -61,7 +61,10 @@ export const HeaderStateful = props => {
61
61
  var _props$headerProps, _props$headerProps$co, _props$headerProps$co2;
62
62
  TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
63
63
  Event: TelemetryEvent.HeaderCloseButtonClicked,
64
- Description: "Header Close action started."
64
+ Description: "Header Close action started.",
65
+ CustomProperties: {
66
+ ConversationStage: ConversationStage.ConversationEnd
67
+ }
65
68
  });
66
69
  if (localConfirmationPaneState.current !== ConfirmationState.Ok) {
67
70
  dispatch({
@@ -76,7 +79,10 @@ export const HeaderStateful = props => {
76
79
  }
77
80
  TelemetryHelper.logActionEventToAllTelemetry(LogLevel.INFO, {
78
81
  Event: TelemetryEvent.CloseChatActionCompleted,
79
- Description: "Header Close action completed."
82
+ Description: "Header Close action completed.",
83
+ CustomProperties: {
84
+ ConversationStage: ConversationStage.ConversationEnd
85
+ }
80
86
  });
81
87
  const closeButtonId = ((_props$headerProps = props.headerProps) === null || _props$headerProps === void 0 ? void 0 : (_props$headerProps$co = _props$headerProps.controlProps) === null || _props$headerProps$co === void 0 ? void 0 : (_props$headerProps$co2 = _props$headerProps$co.closeButtonProps) === null || _props$headerProps$co2 === void 0 ? void 0 : _props$headerProps$co2.id) ?? `${controlProps.id}-close-button`;
82
88
  if (closeButtonId) {
@@ -3,6 +3,6 @@ var ChatWidgetEvents;
3
3
  ChatWidgetEvents["ADD_ACTIVITY"] = "CHAT_WIDGET/ADD_ACTIVITY";
4
4
  ChatWidgetEvents["FETCH_PERSISTENT_CHAT_HISTORY"] = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY";
5
5
  ChatWidgetEvents["NO_MORE_HISTORY_AVAILABLE"] = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE";
6
- ChatWidgetEvents["HIDE_LOADING_BANNER"] = "CHAT_WIDGET/HIDE_LOADING_BANNER";
6
+ ChatWidgetEvents["HISTORY_LOAD_ERROR"] = "CHAT_WIDGET/HISTORY_LOAD_ERROR";
7
7
  })(ChatWidgetEvents || (ChatWidgetEvents = {}));
8
8
  export default ChatWidgetEvents;