@microsoft/omnichannel-chat-widget 0.1.0-main.e170704 → 0.1.0-main.e312ecd

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 (154) hide show
  1. package/README.md +32 -0
  2. package/lib/cjs/common/Constants.js +18 -2
  3. package/lib/cjs/common/storage/default/defaultCacheManager.js +34 -0
  4. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
  5. package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
  6. package/lib/cjs/common/telemetry/TelemetryConstants.js +34 -3
  7. package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
  8. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +33 -21
  9. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
  10. package/lib/cjs/common/utils.js +76 -2
  11. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  12. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -3
  13. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  14. package/lib/cjs/components/footerstateful/FooterStateful.js +1 -8
  15. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
  16. package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -3
  17. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
  18. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
  19. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  20. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
  21. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
  22. package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
  23. package/lib/cjs/components/livechatwidget/common/authHelper.js +65 -0
  24. package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
  25. package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
  26. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
  27. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
  28. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +29 -17
  29. package/lib/cjs/components/livechatwidget/common/endChat.js +63 -16
  30. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +24 -3
  31. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
  32. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  33. package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
  34. package/lib/cjs/components/livechatwidget/common/startChat.js +179 -72
  35. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +273 -91
  36. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
  37. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  38. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +96 -2
  39. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
  40. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
  41. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  42. package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  43. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
  50. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
  51. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
  52. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  53. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +3 -0
  54. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +13 -5
  55. package/lib/cjs/contexts/createReducer.js +17 -0
  56. package/lib/cjs/controller/componentController.js +3 -3
  57. package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
  58. package/lib/esm/common/Constants.js +18 -2
  59. package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
  60. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
  61. package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
  62. package/lib/esm/common/telemetry/TelemetryConstants.js +34 -3
  63. package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
  64. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +30 -12
  65. package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
  66. package/lib/esm/common/utils.js +53 -0
  67. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  68. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +21 -6
  69. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
  70. package/lib/esm/components/footerstateful/FooterStateful.js +1 -8
  71. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
  72. package/lib/esm/components/headerstateful/HeaderStateful.js +4 -3
  73. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
  74. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
  75. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  76. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
  77. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
  78. package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
  79. package/lib/esm/components/livechatwidget/common/authHelper.js +50 -0
  80. package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
  81. package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
  82. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
  83. package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
  84. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +29 -17
  85. package/lib/esm/components/livechatwidget/common/endChat.js +61 -17
  86. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +23 -5
  87. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +56 -37
  88. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  89. package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
  90. package/lib/esm/components/livechatwidget/common/startChat.js +174 -75
  91. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +265 -94
  92. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
  93. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
  94. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +86 -2
  95. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
  96. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
  97. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  98. package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  99. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  100. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  101. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  102. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
  103. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  104. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
  105. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
  106. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
  107. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
  108. package/lib/esm/contexts/common/ConversationState.js +3 -2
  109. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +3 -0
  110. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +11 -5
  111. package/lib/esm/contexts/createReducer.js +17 -0
  112. package/lib/esm/controller/componentController.js +3 -3
  113. package/lib/esm/plugins/newMessageEventHandler.js +10 -12
  114. package/lib/types/common/Constants.d.ts +9 -1
  115. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  116. package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
  117. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
  118. package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
  119. package/lib/types/common/telemetry/TelemetryConstants.d.ts +27 -5
  120. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
  121. package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
  122. package/lib/types/common/utils.d.ts +7 -1
  123. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
  124. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  125. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  126. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  127. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  128. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  129. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  130. package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
  131. package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
  132. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
  133. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  134. package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
  135. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
  136. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
  137. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
  138. package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
  139. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  140. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
  141. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  142. package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
  143. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
  144. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  145. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
  146. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  147. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  148. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
  149. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  150. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  151. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
  152. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +4 -1
  153. package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
  154. package/package.json +4 -3
@@ -72,6 +72,7 @@ const createReducer = () => {
72
72
  case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT:
73
73
  return { ...state,
74
74
  domainStates: { ...state.domainStates,
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
76
  customContext: action.payload
76
77
  }
77
78
  };
@@ -234,6 +235,22 @@ const createReducer = () => {
234
235
  }
235
236
  };
236
237
 
238
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_SIZE:
239
+ return { ...state,
240
+ domainStates: { ...state.domainStates,
241
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
242
+ widgetSize: action.payload
243
+ }
244
+ };
245
+
246
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_INSTANCE_ID:
247
+ return { ...state,
248
+ domainStates: { ...state.domainStates,
249
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
250
+ widgetInstanceId: action.payload
251
+ }
252
+ };
253
+
237
254
  default:
238
255
  return state;
239
256
  }
@@ -8,7 +8,7 @@ exports.shouldShowWebChatContainer = exports.shouldShowReconnectChatPane = expor
8
8
  var _ConversationState = require("../contexts/common/ConversationState");
9
9
 
10
10
  const shouldShowChatButton = state => {
11
- return state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed;
11
+ return (state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed) && state.appStates.skipChatButtonRendering == false; // Do not show chat button in case of popout
12
12
  };
13
13
 
14
14
  exports.shouldShowChatButton = shouldShowChatButton;
@@ -44,7 +44,7 @@ const shouldShowWebChatContainer = state => {
44
44
  exports.shouldShowWebChatContainer = shouldShowWebChatContainer;
45
45
 
46
46
  const shouldShowLoadingPane = state => {
47
- return !state.appStates.isMinimized && !state.appStates.shouldShowPostChat && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
47
+ return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
48
48
  };
49
49
 
50
50
  exports.shouldShowLoadingPane = shouldShowLoadingPane;
@@ -56,7 +56,7 @@ const shouldShowReconnectChatPane = state => {
56
56
  exports.shouldShowReconnectChatPane = shouldShowReconnectChatPane;
57
57
 
58
58
  const shouldShowPostChatLoadingPane = state => {
59
- return !state.appStates.isMinimized && state.appStates.shouldShowPostChat && state.appStates.conversationState === _ConversationState.ConversationState.Loading;
59
+ return !state.appStates.isMinimized && state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading;
60
60
  };
61
61
 
62
62
  exports.shouldShowPostChatLoadingPane = shouldShowPostChatLoadingPane;
@@ -13,8 +13,6 @@ var _Constants = require("../common/Constants");
13
13
 
14
14
  var _TelemetryHelper = require("../common/telemetry/TelemetryHelper");
15
15
 
16
- var _TelemetryManager = require("../common/telemetry/TelemetryManager");
17
-
18
16
  const createOnNewAdapterActivityHandler = (chatId, userId) => {
19
17
  const onNewAdapterActivityHandler = activity => {
20
18
  var _activity$channelData, _activity$channelData2, _activity$channelData3;
@@ -29,18 +27,16 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
29
27
 
30
28
  const raiseMessageEvent = activity => {
31
29
  if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants.Constants.message) {
32
- var _TelemetryManager$Int, _activity$from;
30
+ var _text, _text2, _activity$channelData4, _activity$from;
33
31
 
34
32
  const payload = {
33
+ // To identify hidden contents vs empty content
35
34
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- text: activity === null || activity === void 0 ? void 0 : activity.text,
37
- id: activity === null || activity === void 0 ? void 0 : activity.id,
35
+ text: (activity === null || activity === void 0 ? void 0 : (_text = activity.text) === null || _text === void 0 ? void 0 : _text.length) >= 1 ? `*contents hidden (${activity === null || activity === void 0 ? void 0 : (_text2 = activity.text) === null || _text2 === void 0 ? void 0 : _text2.length} chars)*` : "",
38
36
  type: activity === null || activity === void 0 ? void 0 : activity.type,
39
37
  timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
40
- chatId: chatId,
41
38
  userId: userId,
42
- conversationId: ((_TelemetryManager$Int = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.conversationId) ?? "",
43
- channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
39
+ tags: activity === null || activity === void 0 ? void 0 : (_activity$channelData4 = activity.channelData) === null || _activity$channelData4 === void 0 ? void 0 : _activity$channelData4.tags,
44
40
  messageType: ""
45
41
  };
46
42
 
@@ -59,18 +55,18 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
59
55
  Description: "New message sent"
60
56
  });
61
57
  } else {
62
- var _activity$channelData4, _activity$channelData5;
58
+ var _activity$channelData5, _activity$channelData6;
63
59
 
64
- if (activity !== null && activity !== void 0 && (_activity$channelData4 = activity.channelData) !== null && _activity$channelData4 !== void 0 && (_activity$channelData5 = _activity$channelData4.tags) !== null && _activity$channelData5 !== void 0 && _activity$channelData5.includes(_Constants.Constants.systemMessageTag)) {
60
+ if (activity !== null && activity !== void 0 && (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(_Constants.Constants.systemMessageTag)) {
65
61
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
62
  payload.messageType = _Constants.Constants.systemMessageTag;
67
63
  } else {
68
- var _activity$channelData6, _activity$channelData7, _activity$channelData8;
64
+ var _activity$channelData7, _activity$channelData8, _activity$channelData9;
69
65
 
70
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
67
  const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text); // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
68
 
73
- const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData6 = activity.channelData) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : (_activity$channelData8 = _activity$channelData7.tags) === null || _activity$channelData8 === void 0 ? void 0 : _activity$channelData8.length) === 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData7 = activity.channelData) !== null && _activity$channelData7 !== void 0 && _activity$channelData7.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData8 = activity.channelData) === null || _activity$channelData8 === void 0 ? void 0 : (_activity$channelData9 = _activity$channelData8.tags) === null || _activity$channelData9 === void 0 ? void 0 : _activity$channelData9.length) === 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
70
 
75
71
  const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
76
72
 
@@ -90,7 +86,8 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
90
86
 
91
87
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
92
88
  Event: _TelemetryConstants.TelemetryEvent.MessageReceived,
93
- Description: "New message received"
89
+ Description: "New message received",
90
+ Data: payload
94
91
  });
95
92
  }
96
93
  }
@@ -4,6 +4,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
4
4
 
5
5
  export class Constants {}
6
6
 
7
+ _defineProperty(Constants, "magicCodeBroadcastChannel", "MagicCodeChannel");
8
+
9
+ _defineProperty(Constants, "magicCodeResponseBroadcastChannel", "MagicCodeResponseChannel");
10
+
7
11
  _defineProperty(Constants, "systemMessageTag", "system");
8
12
 
9
13
  _defineProperty(Constants, "userMessageTag", "user");
@@ -36,8 +40,6 @@ _defineProperty(Constants, "false", "false");
36
40
 
37
41
  _defineProperty(Constants, "maximumUnreadMessageCount", 99);
38
42
 
39
- _defineProperty(Constants, "widgetStateDataKey", "LcwChatWidgetState");
40
-
41
43
  _defineProperty(Constants, "channelIdKey", "ChannelId-");
42
44
 
43
45
  _defineProperty(Constants, "ChannelId", "lcw");
@@ -72,6 +74,14 @@ _defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
72
74
 
73
75
  _defineProperty(Constants, "message", "message");
74
76
 
77
+ _defineProperty(Constants, "hiddenTag", "Hidden");
78
+
79
+ _defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
80
+
81
+ _defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
82
+
83
+ _defineProperty(Constants, "publicMessageTag", "public");
84
+
75
85
  _defineProperty(Constants, "supportedAdaptiveCardContentTypes", ["application/vnd.microsoft.card.adaptive", "application/vnd.microsoft.card.audio", "application/vnd.microsoft.card.hero", "application/vnd.microsoft.card.receipt", "application/vnd.microsoft.card.thumbnail", "application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"]);
76
86
 
77
87
  _defineProperty(Constants, "maxUploadFileSize", "500000");
@@ -146,6 +156,12 @@ _defineProperty(Constants, "internetConnectionTestUrl", "https://ocsdk-prod.azur
146
156
 
147
157
  _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect Test");
148
158
 
159
+ _defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
160
+
161
+ _defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
162
+
163
+ _defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
164
+
149
165
  export const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[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]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
150
166
  export class HtmlIdNames {}
151
167
 
@@ -0,0 +1,19 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
+ import { getWidgetCacheId } from "../../utils";
5
+ import { defaultClientDataStoreProvider } from "./defaultClientDataStoreProvider";
6
+ export class defaultCacheManager {}
7
+
8
+ _defineProperty(defaultCacheManager, "InternalCache", {});
9
+
10
+ export const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId) => {
11
+ const widgetCacheId = getWidgetCacheId(orgid, widgetId, widgetInstanceId);
12
+ BroadcastService.getMessageByEventName(widgetCacheId).subscribe(msg => {
13
+ try {
14
+ defaultClientDataStoreProvider().setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
15
+ } catch (error) {
16
+ console.error("Error in setting data to localstorage", error);
17
+ }
18
+ });
19
+ };
@@ -0,0 +1,102 @@
1
+ import { inMemoryDataStore } from "./defaultInMemoryDataStore";
2
+ import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
3
+ import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
4
+ export const defaultClientDataStoreProvider = () => {
5
+ const isCookieAllowed = () => {
6
+ try {
7
+ localStorage;
8
+ sessionStorage;
9
+ return true;
10
+ } catch (error) {
11
+ console.error("Third party cookie blocked");
12
+ return false;
13
+ }
14
+ };
15
+
16
+ const TtlInMs = 15 * 60 * 1000; // 15 mins
17
+
18
+ const dataStoreProvider = {
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ setData: (key, data, type) => {
21
+ if (isCookieAllowed()) {
22
+ try {
23
+ if (key) {
24
+ const now = new Date();
25
+ const item = {
26
+ data: data,
27
+ expiry: now.getTime() + TtlInMs
28
+ };
29
+ const strItem = JSON.stringify(item);
30
+
31
+ if (type === "localStorage") {
32
+ localStorage.setItem(key, strItem);
33
+ } else {
34
+ sessionStorage.setItem(key, strItem);
35
+ }
36
+ }
37
+ } catch (error) {
38
+ TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
39
+ Event: TelemetryEvent.ClientDataStoreProviderFailed,
40
+ ExceptionDetails: error,
41
+ Description: "Unable to store data in localStorage."
42
+ });
43
+ }
44
+ } else {
45
+ const dataToCache = {
46
+ key: key,
47
+ data: data,
48
+ type: type
49
+ };
50
+ parent.postMessage(dataToCache, "*");
51
+ }
52
+ },
53
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
+ getData: (key, type) => {
55
+ if (isCookieAllowed()) {
56
+ let item;
57
+
58
+ if (type === "localStorage") {
59
+ item = localStorage.getItem(key);
60
+ } else {
61
+ item = sessionStorage.getItem(key);
62
+ } //Return item if not expired
63
+
64
+
65
+ let itemInJson = undefined;
66
+
67
+ if (item !== null) {
68
+ itemInJson = JSON.parse(item);
69
+ const now = new Date(); // compare the expiry time of the item with the current time
70
+
71
+ if (now.getTime() > itemInJson.expiry) {
72
+ // If the item is expired, delete the item from storage
73
+ // and return null
74
+ localStorage.removeItem(key);
75
+ return null;
76
+ }
77
+
78
+ return itemInJson.data;
79
+ }
80
+ } else {
81
+ // get data from in memory db when cookie is disabled
82
+ return inMemoryDataStore().getData(key);
83
+ }
84
+ },
85
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
+ removeData: (key, type) => {
87
+ if (isCookieAllowed()) {
88
+ if (key) {
89
+ if (type === "localStorage") {
90
+ return localStorage.removeItem(key);
91
+ } else {
92
+ return sessionStorage.removeItem(key);
93
+ }
94
+ }
95
+ } else {
96
+ // get data from in memory db when cookie is disabled
97
+ return inMemoryDataStore().removeData(key);
98
+ }
99
+ }
100
+ };
101
+ return dataStoreProvider;
102
+ };
@@ -0,0 +1,71 @@
1
+ import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
2
+ import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
3
+ import { defaultCacheManager } from "./defaultCacheManager";
4
+ export const defaultInitializeInMemoryDataStore = widgetId => {
5
+ try {
6
+ localStorage;
7
+ } catch (error) {
8
+ // Register below events when localStorage is not accessible
9
+ // Listening to event raised from client browser
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ window.addEventListener("message", function (e) {
12
+ try {
13
+ if (e.data.key) {
14
+ const browserData = e.data;
15
+
16
+ if (defaultCacheManager.InternalCache[browserData.key]) {
17
+ delete defaultCacheManager.InternalCache[browserData.key];
18
+ }
19
+
20
+ defaultCacheManager.InternalCache[browserData.key] = browserData.data;
21
+ }
22
+ } catch (error) {
23
+ TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
24
+ Event: TelemetryEvent.InMemoryDataStoreFailed,
25
+ ExceptionDetails: error,
26
+ Description: "Unable to register default in-memory cache."
27
+ });
28
+ }
29
+ }); // send cache initialize message to client
30
+
31
+ if (defaultCacheManager.InternalCache === undefined || {}) {
32
+ parent.postMessage({
33
+ data: "cacheinitialize",
34
+ widgetId: widgetId
35
+ }, "*");
36
+ }
37
+ }
38
+ };
39
+ export const inMemoryDataStore = () => {
40
+ const dataStoreProvider = {
41
+ getData: key => {
42
+ if (defaultCacheManager.InternalCache && defaultCacheManager.InternalCache[key]) {
43
+ return defaultCacheManager.InternalCache[key];
44
+ }
45
+ },
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ setData: (key, data) => {
48
+ try {
49
+ defaultCacheManager.InternalCache[key] = data;
50
+ } catch (error) {
51
+ TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
52
+ Event: TelemetryEvent.InMemoryDataStoreFailed,
53
+ ExceptionDetails: error,
54
+ Description: "Unable to set data in default in-memory cache."
55
+ });
56
+ }
57
+ },
58
+ removeData: key => {
59
+ try {
60
+ defaultCacheManager.InternalCache[key] = {};
61
+ } catch (error) {
62
+ TelemetryHelper.logConfigDataEvent(LogLevel.ERROR, {
63
+ Event: TelemetryEvent.InMemoryDataStoreFailed,
64
+ ExceptionDetails: error,
65
+ Description: "Unable to remove data from default in-memory cache."
66
+ });
67
+ }
68
+ }
69
+ };
70
+ return dataStoreProvider;
71
+ };
@@ -26,19 +26,29 @@ export let BroadcastEvent; // Events being logged
26
26
 
27
27
  (function (BroadcastEvent) {
28
28
  BroadcastEvent["LoadPostChatSurvey"] = "LoadPostChatSurvey";
29
- BroadcastEvent["EndChat"] = "ChatEnded";
29
+ BroadcastEvent["ChatEnded"] = "ChatEnded";
30
30
  BroadcastEvent["NewMessageNotification"] = "NewMessageNotification";
31
31
  BroadcastEvent["UnreadMessageCount"] = "UnreadMessageCount";
32
- BroadcastEvent["ChatWidgetStateChanged"] = "ChatWidgetStateChanged";
32
+ BroadcastEvent["StartProactiveChat"] = "StartProactiveChat";
33
33
  BroadcastEvent["ProactiveChatStartChat"] = "ProactiveChatStartChat";
34
34
  BroadcastEvent["ProactiveChatStartPopoutChat"] = "ProactiveChatStartPopoutChat";
35
+ BroadcastEvent["ProactiveChatIsInPopoutMode"] = "ProactiveChatIsInPopoutMode";
36
+ BroadcastEvent["ResetProactiveChatParams"] = "ResetProactiveChatParams";
35
37
  BroadcastEvent["InvalidAdaptiveCardFormat"] = "InvalidAdaptiveCardFormat";
36
38
  BroadcastEvent["NewMessageSent"] = "NewMessageSent";
37
39
  BroadcastEvent["NewMessageReceived"] = "NewMessageReceived";
38
40
  BroadcastEvent["RedirectPageRequest"] = "RedirectPageRequest";
41
+ BroadcastEvent["StartChat"] = "StartChat";
39
42
  BroadcastEvent["StartChatSkippingChatButtonRendering"] = "StartChatSkippingChatButtonRendering";
40
43
  BroadcastEvent["StartUnauthenticatedReconnectChat"] = "StartUnauthenticatedReconnectChat";
44
+ BroadcastEvent["InitiateEndChat"] = "InitiateEndChat";
41
45
  BroadcastEvent["SetCustomContext"] = "SetCustomContext";
46
+ BroadcastEvent["ChatRetrievedFromCache"] = "ChatRetrievedFromCache";
47
+ BroadcastEvent["MaximizeChat"] = "MaximizeChat";
48
+ BroadcastEvent["ChatInitiated"] = "ChatInitiated";
49
+ BroadcastEvent["CloseChat"] = "CloseChat";
50
+ BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
51
+ BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
42
52
  })(BroadcastEvent || (BroadcastEvent = {}));
43
53
 
44
54
  export let TelemetryEvent;
@@ -79,6 +89,8 @@ export let TelemetryEvent;
79
89
  TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
80
90
  TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
81
91
  TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
92
+ TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
93
+ TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
82
94
  TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
83
95
  TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
84
96
  TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
@@ -90,8 +102,9 @@ export let TelemetryEvent;
90
102
  TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
91
103
  TelemetryEvent["StartChatSDKCall"] = "StartChatCall";
92
104
  TelemetryEvent["StartChatEventRecevied"] = "StartChatEventReceived";
93
- TelemetryEvent["EndChatSDKCall"] = "EndChatCall";
105
+ TelemetryEvent["EndChatSDKCall"] = "EndChatSDKCall";
94
106
  TelemetryEvent["EndChatEventReceived"] = "EndChatEventReceived";
107
+ TelemetryEvent["WindowClosed"] = "WindowClosed";
95
108
  TelemetryEvent["OnNewMessageFailed"] = "OnNewMessageFailed";
96
109
  TelemetryEvent["OnNewMessageAudioNotificationFailed"] = "OnNewMessageAudioNotificationFailed";
97
110
  TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
@@ -116,6 +129,12 @@ export let TelemetryEvent;
116
129
  TelemetryEvent["EmailTranscriptButtonClicked"] = "EmailTranscriptButtonClicked";
117
130
  TelemetryEvent["EmailTranscriptCancelButtonClicked"] = "EmailTranscriptCancelButtonClicked";
118
131
  TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
132
+ TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
133
+ TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
134
+ TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
135
+ TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
136
+ TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
137
+ TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
119
138
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
120
139
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
121
140
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
@@ -142,12 +161,18 @@ export let TelemetryEvent;
142
161
  TelemetryEvent["MessageSent"] = "MessageSent";
143
162
  TelemetryEvent["MessageReceived"] = "MessageReceived";
144
163
  TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
164
+ TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
165
+ TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
145
166
  })(TelemetryEvent || (TelemetryEvent = {}));
146
167
 
147
168
  export class TelemetryConstants {
148
169
  static map(eventTypeOrScenarioType) {
149
170
  switch (eventTypeOrScenarioType) {
150
171
  case TelemetryEvent.ParseAdaptiveCardFailed:
172
+ case TelemetryEvent.ReceivedNullOrEmptyToken:
173
+ case TelemetryEvent.GetAuthTokenCalled:
174
+ case TelemetryEvent.SuppressBotMagicCodeSucceeded:
175
+ case TelemetryEvent.SuppressBotMagicCodeFailed:
151
176
  return ScenarioType.CONFIG_VALIDATION;
152
177
 
153
178
  case TelemetryEvent.WebChatLoaded:
@@ -187,6 +212,11 @@ export class TelemetryConstants {
187
212
  case TelemetryEvent.MessageSent:
188
213
  case TelemetryEvent.MessageReceived:
189
214
  case TelemetryEvent.CustomContextReceived:
215
+ case TelemetryEvent.BrowserUnloadEventStarted:
216
+ case TelemetryEvent.NetworkDisconnected:
217
+ case TelemetryEvent.NetworkReconnected:
218
+ case TelemetryEvent.AudioToggleButtonClicked:
219
+ case TelemetryEvent.EmailTranscriptCancelButtonClicked:
190
220
  return ScenarioType.ACTIONS;
191
221
 
192
222
  case TelemetryEvent.StartChatSDKCall:
@@ -203,6 +233,7 @@ export class TelemetryConstants {
203
233
  case TelemetryEvent.EndChatSDKCallFailed:
204
234
  case TelemetryEvent.PostChatContextCallFailed:
205
235
  case TelemetryEvent.PostChatContextCallSucceed:
236
+ case TelemetryEvent.GetConversationDetailsException:
206
237
  return ScenarioType.SDK;
207
238
 
208
239
  case TelemetryEvent.VideoCallAcceptButtonClick:
@@ -5,6 +5,7 @@ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
5
5
  import { ariaTelemetryLogger } from "./loggers/ariaTelemetryLogger";
6
6
  import { consoleLogger } from "./loggers/consoleLogger";
7
7
  import { defaultAriaConfig } from "./defaultConfigs/defaultAriaConfig";
8
+ import { TelemetryHelper } from "./TelemetryHelper";
8
9
  export class TelemetryTimers {}
9
10
 
10
11
  _defineProperty(TelemetryTimers, "LcwLoadToChatButtonTimer", void 0);
@@ -72,7 +73,11 @@ export const RegisterLoggers = () => {
72
73
 
73
74
  const logLevel = telemetryEvent.logLevel ?? LogLevel.INFO;
74
75
  const scenarioType = ((_payload = telemetryEvent.payload) === null || _payload === void 0 ? void 0 : _payload.scenarioType) ?? ScenarioType.UNDEFINED;
75
- logger.log(logLevel, parseInput(telemetryEvent === null || telemetryEvent === void 0 ? void 0 : telemetryEvent.payload, scenarioType));
76
+ const telemetryInput = parseInput(telemetryEvent === null || telemetryEvent === void 0 ? void 0 : telemetryEvent.payload, scenarioType);
77
+ telemetryInput.telemetryInfo = {
78
+ telemetryInfo: TelemetryHelper.buildTelemetryEvent(logLevel, telemetryInput)
79
+ };
80
+ logger.log(logLevel, telemetryInput);
76
81
  });
77
82
  };
78
83
 
@@ -1,9 +1,7 @@
1
1
  import { getDomain, isNullOrEmptyString, isNullOrUndefined } from "../../utils";
2
- import AWTEventProperties from "@microsoft/omnichannel-chat-sdk/lib/external/aria/webjs/AWTEventProperties";
3
- import AWTLogManager from "@microsoft/omnichannel-chat-sdk/lib/external/aria/webjs/AWTLogManager";
4
- import { AWTPiiKind } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
2
+ import { AWTLogManager } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/webjs/AriaSDK";
3
+ import { AWTCustomerContentKind, AWTPiiKind, AWTPropertyType } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
5
4
  import { Constants, AriaTelemetryConstants, EnvironmentVersion } from "../../Constants";
6
- import { TelemetryHelper } from "../TelemetryHelper";
7
5
  import { TelemetryManager } from "../TelemetryManager";
8
6
  export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, collectiorUriForTelemetry, ariaTelemetryApplicationName) => {
9
7
  let _logger;
@@ -50,17 +48,37 @@ export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, colle
50
48
  const ariaLogger = {
51
49
  log: (logLevel, telemetryInput) => {
52
50
  try {
53
- let property;
54
- const eventProperties = new AWTEventProperties();
55
- const event = TelemetryHelper.buildTelemetryEvent(logLevel, telemetryInput);
56
- eventProperties.setName(telemetryInput.scenarioType);
51
+ var _telemetryInput$telem;
57
52
 
58
- for (const key of Object.keys(event)) {
59
- property = typeof event[key] === "object" ? JSON.stringify(event[key]) : event[key];
60
- eventProperties.setProperty(key, property);
53
+ const telemetryInfo = telemetryInput === null || telemetryInput === void 0 ? void 0 : (_telemetryInput$telem = telemetryInput.telemetryInfo) === null || _telemetryInput$telem === void 0 ? void 0 : _telemetryInput$telem.telemetryInfo; // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
+
55
+ const eventProperties = {
56
+ name: telemetryInput.scenarioType,
57
+ properties: {}
58
+ };
59
+
60
+ if (telemetryInfo) {
61
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
62
+ Object.keys(telemetryInfo).forEach((key, index) => {
63
+ if (!isNullOrUndefined(telemetryInfo[key]) && !isNullOrEmptyString(telemetryInfo[key])) {
64
+ const property = {
65
+ value: typeof telemetryInfo[key] === "object" ? JSON.stringify(telemetryInfo[key]) : telemetryInfo[key],
66
+ type: typeof telemetryInfo[key] === "number" ? AWTPropertyType.Double : AWTPropertyType.String,
67
+ pii: AWTPiiKind.NotSet,
68
+ cc: AWTCustomerContentKind.NotSet
69
+ };
70
+ eventProperties.properties[key] = property;
71
+ }
72
+ });
73
+ const nameProperty = {
74
+ value: Constants.LiveChatWidget,
75
+ type: AWTPropertyType.String,
76
+ pii: AWTPiiKind.GenericData,
77
+ cc: AWTCustomerContentKind.NotSet
78
+ };
79
+ eventProperties.properties[ariaTelemetryApplicationName] = nameProperty;
61
80
  }
62
81
 
63
- eventProperties.setPropertyWithPii(ariaTelemetryApplicationName, Constants.LiveChatWidget, AWTPiiKind.GenericData);
64
82
  logger() ? logger().logEvent(eventProperties) : console.log("Unable to initialize aria logger");
65
83
  } catch (error) {
66
84
  console.error("Error in logging telemetry to Aria logger:" + error);
@@ -4,27 +4,28 @@ export const consoleLogger = () => {
4
4
  const consoleLogger = {
5
5
  log: (logLevel, telemetryInput) => {
6
6
  const payload = telemetryInput !== null && telemetryInput !== void 0 && telemetryInput.payload && Object.keys(telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.payload).length > 0 ? telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.payload : "";
7
+ const telemetryInfo = telemetryInput !== null && telemetryInput !== void 0 && telemetryInput.telemetryInfo && Object.keys(telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.telemetryInfo).length > 0 ? telemetryInput === null || telemetryInput === void 0 ? void 0 : telemetryInput.telemetryInfo : "";
7
8
 
8
9
  try {
9
10
  switch (logLevel) {
10
11
  case LogLevel.INFO:
11
- console.info(Constants.LiveChatWidget, payload);
12
+ console.info(Constants.LiveChatWidget, payload, telemetryInfo);
12
13
  break;
13
14
 
14
15
  case LogLevel.DEBUG:
15
- console.debug(Constants.LiveChatWidget, payload);
16
+ console.debug(Constants.LiveChatWidget, payload, telemetryInfo);
16
17
  break;
17
18
 
18
19
  case LogLevel.WARN:
19
- console.warn(Constants.LiveChatWidget, payload);
20
+ console.warn(Constants.LiveChatWidget, payload, telemetryInfo);
20
21
  break;
21
22
 
22
23
  case LogLevel.ERROR:
23
- console.error(Constants.LiveChatWidget, payload);
24
+ console.error(Constants.LiveChatWidget, payload, telemetryInfo);
24
25
  break;
25
26
 
26
27
  default:
27
- console.debug(Constants.LiveChatWidget, payload);
28
+ console.debug(Constants.LiveChatWidget, payload, telemetryInfo);
28
29
  break;
29
30
  }
30
31
  } catch (ex) {
@@ -1,5 +1,8 @@
1
1
  import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
2
+ import { DataStoreManager } from "./contextDataStore/DataStoreManager";
2
3
  import { KeyCodes } from "./KeyCodes";
4
+ import { BroadcastEvent } from "./telemetry/TelemetryConstants";
5
+ import { Md5 } from "md5-typescript";
3
6
 
4
7
  const getElementBySelector = selector => {
5
8
  let element;
@@ -277,6 +280,7 @@ export const createTimer = () => {
277
280
 
278
281
  };
279
282
  }; // Returns the domain of the org
283
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
280
284
 
281
285
  export const getDomain = hostValue => {
282
286
  for (let i = 0; i < AriaTelemetryConstants.lcwEUDomainNames.length; i++) {
@@ -286,4 +290,53 @@ export const getDomain = hostValue => {
286
290
  }
287
291
 
288
292
  return AriaTelemetryConstants.Public;
293
+ };
294
+ export const getWidgetCacheId = (orgId, widgetId, widgetInstanceId) => {
295
+ const widgetCacheId = `${widgetInstanceId}_${orgId}_${widgetId}`;
296
+ return Md5.init(widgetCacheId);
297
+ };
298
+ export const getWidgetEndChatEventName = (orgId, widgetId, widgetInstanceId) => {
299
+ if (!isNullOrEmptyString(widgetInstanceId)) {
300
+ return `${BroadcastEvent.ChatEnded}_${widgetInstanceId}_${orgId}_${widgetId}`;
301
+ }
302
+
303
+ return `${BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
304
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
305
+
306
+ export const getStateFromCache = (orgId, widgetId, widgetInstanceId) => {
307
+ // Getting updated state from cache
308
+ try {
309
+ if (DataStoreManager.clientDataStore) {
310
+ var _DataStoreManager$cli;
311
+
312
+ const widgetStateEventName = getWidgetCacheId(orgId, widgetId, widgetInstanceId);
313
+ const widgetStateFromCache = (_DataStoreManager$cli = DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
314
+ const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
315
+ return persistedState;
316
+ } else {
317
+ return null;
318
+ }
319
+ } catch (error) {
320
+ console.log(error);
321
+ return null;
322
+ }
323
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
324
+
325
+ export const isUndefinedOrEmpty = object => {
326
+ if (object) {
327
+ if (Object.keys(object).length === 0) {
328
+ return true;
329
+ }
330
+
331
+ return false;
332
+ } else {
333
+ return true;
334
+ }
335
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
336
+
337
+ export const addDelayInMs = ms => {
338
+ return new Promise(resolve => setTimeout(resolve, ms));
339
+ };
340
+ export const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
341
+ return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
289
342
  };