@microsoft/omnichannel-chat-widget 0.1.0-main.07f52ee → 0.1.0-main.20562ae

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 (109) hide show
  1. package/README.md +3 -11
  2. package/lib/cjs/assets/Audios.js +8 -0
  3. package/lib/cjs/assets/Icons.js +28 -0
  4. package/lib/cjs/common/Constants.js +4 -0
  5. package/lib/cjs/common/telemetry/TelemetryConstants.js +32 -3
  6. package/lib/cjs/common/telemetry/TelemetryManager.js +7 -5
  7. package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  8. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -39
  9. package/lib/cjs/components/footerstateful/FooterStateful.js +3 -3
  10. package/lib/cjs/components/headerstateful/HeaderStateful.js +11 -8
  11. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -4
  12. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -7
  13. package/lib/cjs/components/livechatwidget/common/endChat.js +101 -57
  14. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +1 -1
  15. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +25 -7
  16. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +7 -6
  17. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -5
  18. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
  19. package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -3
  20. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +72 -21
  21. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
  22. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +9 -3
  23. package/lib/cjs/{assets/assets.d.js → components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js} +0 -0
  24. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
  25. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +51 -73
  26. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +9 -46
  27. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
  28. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  29. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  30. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +15 -16
  31. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +5 -1
  32. package/lib/cjs/contexts/createReducer.js +0 -10
  33. package/lib/cjs/controller/componentController.js +2 -2
  34. package/lib/cjs/plugins/newMessageEventHandler.js +102 -0
  35. package/lib/esm/assets/Audios.js +1 -0
  36. package/lib/esm/assets/Icons.js +11 -0
  37. package/lib/esm/common/Constants.js +4 -0
  38. package/lib/esm/common/telemetry/TelemetryConstants.js +28 -2
  39. package/lib/esm/common/telemetry/TelemetryManager.js +6 -5
  40. package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  41. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +6 -35
  42. package/lib/esm/components/footerstateful/FooterStateful.js +3 -3
  43. package/lib/esm/components/headerstateful/HeaderStateful.js +12 -9
  44. package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -3
  45. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -9
  46. package/lib/esm/components/livechatwidget/common/endChat.js +100 -55
  47. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +1 -1
  48. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +23 -8
  49. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +4 -3
  50. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -5
  51. package/lib/esm/components/livechatwidget/common/startChat.js +4 -1
  52. package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
  53. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +67 -19
  54. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
  55. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +8 -4
  56. package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  57. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
  58. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -12
  59. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -44
  60. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  61. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  62. package/lib/esm/contexts/common/ConversationState.js +3 -2
  63. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +15 -16
  64. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +5 -1
  65. package/lib/esm/contexts/createReducer.js +0 -9
  66. package/lib/esm/controller/componentController.js +2 -2
  67. package/lib/esm/plugins/newMessageEventHandler.js +84 -0
  68. package/lib/types/assets/Audios.d.ts +1 -0
  69. package/lib/types/assets/Icons.d.ts +11 -0
  70. package/lib/types/common/Constants.d.ts +2 -0
  71. package/lib/types/common/telemetry/TelemetryConstants.d.ts +19 -1
  72. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +5 -2
  73. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +4 -1
  74. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  75. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
  76. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  77. package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
  78. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  79. package/lib/types/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.d.ts +1 -1
  80. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
  81. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  82. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +15 -16
  83. package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
  84. package/package.json +5 -6
  85. package/lib/cjs/assets/audios/newMessageNotification.mp3 +0 -0
  86. package/lib/cjs/assets/icons/archiveIcon.svg +0 -3
  87. package/lib/cjs/assets/icons/audioIcon.svg +0 -6
  88. package/lib/cjs/assets/icons/blankIcon.svg +0 -6
  89. package/lib/cjs/assets/icons/excelIcon.svg +0 -6
  90. package/lib/cjs/assets/icons/imageIcon.svg +0 -6
  91. package/lib/cjs/assets/icons/oneNoteIcon.svg +0 -6
  92. package/lib/cjs/assets/icons/pdfIcon.svg +0 -6
  93. package/lib/cjs/assets/icons/powerpointIcon.svg +0 -6
  94. package/lib/cjs/assets/icons/videoIcon.svg +0 -6
  95. package/lib/cjs/assets/icons/visioIcon.svg +0 -6
  96. package/lib/cjs/assets/icons/wordIcon.svg +0 -6
  97. package/lib/esm/assets/assets.d.js +0 -0
  98. package/lib/esm/assets/audios/newMessageNotification.mp3 +0 -0
  99. package/lib/esm/assets/icons/archiveIcon.svg +0 -3
  100. package/lib/esm/assets/icons/audioIcon.svg +0 -6
  101. package/lib/esm/assets/icons/blankIcon.svg +0 -6
  102. package/lib/esm/assets/icons/excelIcon.svg +0 -6
  103. package/lib/esm/assets/icons/imageIcon.svg +0 -6
  104. package/lib/esm/assets/icons/oneNoteIcon.svg +0 -6
  105. package/lib/esm/assets/icons/pdfIcon.svg +0 -6
  106. package/lib/esm/assets/icons/powerpointIcon.svg +0 -6
  107. package/lib/esm/assets/icons/videoIcon.svg +0 -6
  108. package/lib/esm/assets/icons/visioIcon.svg +0 -6
  109. package/lib/esm/assets/icons/wordIcon.svg +0 -6
@@ -1,6 +1,10 @@
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
2
  import { createStore } from "botframework-webchat";
3
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
+ import { ConversationState } from "../../../contexts/common/ConversationState";
2
5
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
6
  import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
7
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
8
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
5
9
  import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
6
10
  import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
@@ -21,9 +25,8 @@ import gifUploadMiddleware from "../../webchatcontainerstateful/webchatcontrolle
21
25
  import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware";
22
26
  import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
23
27
  import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
24
- import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
25
- import { BroadcastService } from "@microsoft/omnichannel-chat-components";
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+
27
30
  export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
28
31
  var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21;
29
32
 
@@ -44,6 +47,11 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
44
47
  const conversationEndCallback = async () => {
45
48
  var _props$webChatContain4, _props$webChatContain5;
46
49
 
50
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
51
+ Event: TelemetryEvent.ConversationEndedThreadEventReceived,
52
+ Description: "Conversation is ended by agent side or by timeout."
53
+ });
54
+
47
55
  if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
48
56
  setWebChatStyles(styles => {
49
57
  return { ...styles,
@@ -52,11 +60,18 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
52
60
  });
53
61
  }
54
62
 
55
- if (isPostChatEnabled === "true" && postChatSurveyMode === PostChatSurveyMode.Embed) {
56
- const loadPostChatEvent = {
57
- eventName: "LoadPostChatSurvey"
58
- };
59
- BroadcastService.postMessage(loadPostChatEvent);
63
+ if (isPostChatEnabled === "true") {
64
+ if (postChatSurveyMode === PostChatSurveyMode.Embed) {
65
+ const loadPostChatEvent = {
66
+ eventName: BroadcastEvent.LoadPostChatSurvey
67
+ };
68
+ BroadcastService.postMessage(loadPostChatEvent);
69
+ } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
70
+ dispatch({
71
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
72
+ payload: ConversationState.InActive
73
+ });
74
+ }
60
75
  } else {
61
76
  dispatch({
62
77
  type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
@@ -1,11 +1,11 @@
1
- import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
2
1
  import { RegisterLoggers, TelemetryManager } from "../../../common/telemetry/TelemetryManager";
2
+ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
3
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
+ import { version as chatComponentVersion } from "@microsoft/omnichannel-chat-components/package.json";
5
+ import { version as chatSdkVersion } from "@microsoft/omnichannel-chat-sdk/package.json";
4
6
  import { defaultAriaConfig } from "../../../common/telemetry/defaultConfigs/defaultAriaConfig";
5
7
  import { defaultInternalTelemetryData } from "../../../common/telemetry/defaultConfigs/defaultTelemetryInternalData";
6
8
  import { defaultTelemetryConfiguration } from "../../../common/telemetry/defaultConfigs/defaultTelemetryConfiguration";
7
- import { version as chatComponentVersion } from "@microsoft/omnichannel-chat-components/package.json";
8
- import { version as chatSdkVersion } from "@microsoft/omnichannel-chat-sdk/package.json";
9
9
  export const registerTelemetryLoggers = (props, dispatch) => {
10
10
  var _props$liveChatContex, _props$liveChatContex2;
11
11
 
@@ -44,6 +44,7 @@ export const registerTelemetryLoggers = (props, dispatch) => {
44
44
  telemetryData.orgId = (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId;
45
45
  telemetryData.widgetId = (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId;
46
46
  telemetryData.orgUrl = (_props$chatSDK3 = props.chatSDK) === null || _props$chatSDK3 === void 0 ? void 0 : (_props$chatSDK3$omnic = _props$chatSDK3.omnichannelConfig) === null || _props$chatSDK3$omnic === void 0 ? void 0 : _props$chatSDK3$omnic.orgUrl;
47
+ TelemetryManager.InternalTelemetryData = telemetryData;
47
48
  dispatch({
48
49
  type: LiveChatWidgetActionType.SET_TELEMETRY_DATA,
49
50
  payload: telemetryData
@@ -1,9 +1,9 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
- import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
- import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
- import { ConversationState } from "../../../contexts/common/ConversationState";
5
2
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
+ import { ConversationState } from "../../../contexts/common/ConversationState";
4
+ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+
7
7
  export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
8
8
  try {
9
9
  if (!persistedChat) {
@@ -25,7 +25,8 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persist
25
25
  exception: ex
26
26
  }
27
27
  });
28
- }
28
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
+
29
30
 
30
31
  BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
31
32
  dispatch({
@@ -8,6 +8,7 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
8
8
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
9
9
  import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
10
10
  import { createAdapter } from "./createAdapter";
11
+ import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
11
12
  import { createTimer } from "../../../common/utils";
12
13
  import { getReconnectIdForAuthenticatedChat } from "./reconnectChatHelper";
13
14
  import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
@@ -55,7 +56,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
55
56
 
56
57
  const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
57
58
  try {
58
- var _TelemetryTimers$Widg;
59
+ var _newAdapter$activity$, _TelemetryTimers$Widg;
59
60
 
60
61
  try {
61
62
  TelemetryTimers.WidgetLoadTimer = createTimer();
@@ -74,6 +75,8 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
74
75
 
75
76
  const newAdapter = await createAdapter(chatSDK);
76
77
  setAdapter(newAdapter);
78
+ const chatToken = await chatSDK.getChatToken();
79
+ newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe(createOnNewAdapterActivityHandler(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
77
80
 
78
81
  if (!persistedState) {
79
82
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -2,14 +2,14 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
2
2
  import { ConversationState } from "../../../contexts/common/ConversationState";
3
3
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
4
4
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
5
- import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager"; // Defines startProactiveChat callback
6
-
7
- export const startProactiveChat = (dispatch, bodyTitle, showPrechat, inNewWindow) => {
5
+ import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
6
+ // Defines startProactiveChat callback
7
+ export const startProactiveChat = (dispatch, notificationConfig, enablePreChat, inNewWindow) => {
8
8
  dispatch({
9
9
  type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
10
10
  payload: {
11
- proactiveChatBodyTitle: bodyTitle ?? "",
12
- proactiveChatEnablePrechat: showPrechat ?? false,
11
+ proactiveChatBodyTitle: notificationConfig && notificationConfig.message ? notificationConfig.message : "",
12
+ proactiveChatEnablePrechat: enablePreChat ?? false,
13
13
  proactiveChatInNewWindow: inNewWindow ?? false
14
14
  }
15
15
  });
@@ -1,5 +1,6 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
4
  import { BroadcastService, decodeComponentString } from "@microsoft/omnichannel-chat-components";
4
5
  import { Stack } from "@fluentui/react";
5
6
  import React, { useEffect, useRef, useState } from "react";
@@ -12,6 +13,7 @@ import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
12
13
  import { Components } from "botframework-webchat";
13
14
  import ConfirmationPaneStateful from "../../confirmationpanestateful/ConfirmationPaneStateful";
14
15
  import { ConversationState } from "../../../contexts/common/ConversationState";
16
+ import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
15
17
  import { ElementType } from "@microsoft/omnichannel-chat-components";
16
18
  import EmailTranscriptPaneStateful from "../../emailtranscriptpanestateful/EmailTranscriptPaneStateful";
17
19
  import HeaderStateful from "../../headerstateful/HeaderStateful";
@@ -23,12 +25,14 @@ import PostChatSurveyPaneStateful from "../../postchatsurveypanestateful/PostCha
23
25
  import PreChatSurveyPaneStateful from "../../prechatsurveypanestateful/PreChatSurveyPaneStateful";
24
26
  import ProactiveChatPaneStateful from "../../proactivechatpanestateful/ProactiveChatPaneStateful";
25
27
  import ReconnectChatPaneStateful from "../../reconnectchatpanestateful/ReconnectChatPaneStateful";
28
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
26
29
  import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
27
30
  import WebChatContainerStateful from "../../webchatcontainerstateful/WebChatContainerStateful";
28
31
  import { createFooter } from "../common/createFooter";
29
32
  import { createInternetConnectionChangeHandler } from "../common/createInternetConnectionChangeHandler";
30
33
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
31
- import { endChat } from "../common/endChat";
34
+ import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
35
+ import { endChat, prepareEndChat } from "../common/endChat";
32
36
  import { getGeneralStylesForButton } from "../common/getGeneralStylesForButton";
33
37
  import { initCallingSdk } from "../common/initCallingSdk";
34
38
  import { initConfirmationPropsComposer } from "../common/initConfirmationPropsComposer";
@@ -39,11 +43,8 @@ import { startProactiveChat } from "../common/startProactiveChat";
39
43
  import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
40
44
  import useChatContextStore from "../../../hooks/useChatContextStore";
41
45
  import useChatSDKStore from "../../../hooks/useChatSDKStore";
42
- import { TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
43
- import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
44
- import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
45
46
  export const LiveChatWidgetStateful = props => {
46
- var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$controlProps6, _props$componentOverr2, _props$controlProps7, _props$componentOverr3, _props$controlProps8, _props$componentOverr4, _props$controlProps9, _props$componentOverr5, _props$controlProps10, _props$componentOverr6, _props$controlProps11, _props$controlProps12, _props$controlProps13, _props$componentOverr7, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$componentOverr10, _props$componentOverr11;
47
+ var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$controlProps6, _props$componentOverr2, _props$controlProps7, _props$componentOverr3, _props$controlProps8, _props$componentOverr4, _props$controlProps9, _props$componentOverr5, _props$controlProps10, _props$componentOverr6, _props$controlProps11, _props$componentOverr7, _props$controlProps12, _props$controlProps13, _props$componentOverr8, _props$controlProps14, _props$componentOverr9, _props$controlProps15, _props$componentOverr10, _props$componentOverr11, _props$componentOverr12;
47
48
 
48
49
  const [state, dispatch] = useChatContextStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
50
 
@@ -57,7 +58,8 @@ export const LiveChatWidgetStateful = props => {
57
58
  const {
58
59
  Composer
59
60
  } = Components;
60
- const canStartProactiveChat = useRef(true); // Process general styles
61
+ const canStartProactiveChat = useRef(true);
62
+ const canEndChat = useRef(true); // Process general styles
61
63
 
62
64
  const generalStyles = {
63
65
  root: Object.assign({}, getGeneralStylesForButton(state), (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyles)
@@ -142,13 +144,54 @@ export const LiveChatWidgetStateful = props => {
142
144
  }, [state.appStates.skipChatButtonRendering]);
143
145
  useEffect(() => {
144
146
  BroadcastService.getMessageByEventName("StartProactiveChat").subscribe(msg => {
147
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
148
+ Event: TelemetryEvent.StartProactiveChatEventReceived,
149
+ Description: "Start proactive chat event received."
150
+ });
151
+
145
152
  if (canStartProactiveChat.current) {
146
153
  var _msg$payload, _msg$payload2, _msg$payload3;
147
154
 
148
- startProactiveChat(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.bodyTitle, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.showPrechat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
155
+ startProactiveChat(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.notificationConfig, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.enablePreChat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
156
+ } else {
157
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
158
+ Event: TelemetryEvent.ChatAlreadyTriggered,
159
+ Description: "Start proactive chat method called, when chat was already triggered."
160
+ });
161
+ }
162
+ }); // start chat from SDK Event
163
+
164
+ BroadcastService.getMessageByEventName("StartChat").subscribe(() => {
165
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
166
+ Event: TelemetryEvent.StartChatEventRecevied,
167
+ Description: "Start chat event received."
168
+ });
169
+
170
+ if (state.appStates.isMinimized) {
171
+ dispatch({
172
+ type: LiveChatWidgetActionType.SET_MINIMIZED,
173
+ payload: false
174
+ });
175
+ } else {
176
+ prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
177
+ }
178
+ }); // end chat from SDK Event
179
+
180
+ BroadcastService.getMessageByEventName("EndChat").subscribe(async () => {
181
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
182
+ Event: TelemetryEvent.EndChatEventReceived,
183
+ Description: "End chat event received."
184
+ });
185
+
186
+ if (canEndChat.current) {
187
+ prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
188
+ } else {
189
+ const skipEndChatSDK = true;
190
+ const skipCloseChat = false;
191
+ endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
149
192
  }
150
193
  });
151
- window.addEventListener("beforeunload", event => {
194
+ window.addEventListener("beforeunload", () => {
152
195
  disposeTelemetryLoggers();
153
196
  });
154
197
 
@@ -158,11 +201,12 @@ export const LiveChatWidgetStateful = props => {
158
201
  }, []);
159
202
  useEffect(() => {
160
203
  canStartProactiveChat.current = state.appStates.conversationState === ConversationState.Closed;
204
+ canEndChat.current = state.appStates.conversationState === ConversationState.Active;
161
205
 
162
206
  if (state.appStates.conversationState === ConversationState.Active) {
163
207
  chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
164
208
  BroadcastService.postMessage({
165
- eventName: "NewMessageNotification"
209
+ eventName: BroadcastEvent.NewMessageNotification
166
210
  });
167
211
  });
168
212
  } // Track the message count
@@ -187,7 +231,7 @@ export const LiveChatWidgetStateful = props => {
187
231
  });
188
232
  const customEvent = {
189
233
  elementType: ElementType.Custom,
190
- eventName: "UnreadMessageCount",
234
+ eventName: BroadcastEvent.UnreadMessageCount,
191
235
  payload: 0
192
236
  };
193
237
  BroadcastService.postMessage(customEvent);
@@ -197,7 +241,7 @@ export const LiveChatWidgetStateful = props => {
197
241
  if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
198
242
  const customEvent = {
199
243
  elementType: ElementType.Custom,
200
- eventName: "UnreadMessageCount",
244
+ eventName: BroadcastEvent.UnreadMessageCount,
201
245
  payload: `${state.appStates.unreadMessageCount}`
202
246
  };
203
247
  BroadcastService.postMessage(customEvent);
@@ -212,9 +256,13 @@ export const LiveChatWidgetStateful = props => {
212
256
  }, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]);
213
257
  const webChatProps = initWebChatComposer(props, chatSDK, state, dispatch, setWebChatStyles);
214
258
 
215
- const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch);
259
+ const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
260
+
216
261
 
217
- const endChatRelay = () => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
262
+ const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat) => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat); // eslint-disable-next-line @typescript-eslint/no-explicit-any
263
+
264
+
265
+ const prepareEndChatRelay = (adapter, state) => prepareEndChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
218
266
 
219
267
  const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
220
268
 
@@ -225,7 +273,7 @@ export const LiveChatWidgetStateful = props => {
225
273
 
226
274
  useEffect(() => {
227
275
  const chatWidgetStateChangeEvent = {
228
- eventName: TelemetryEvent.ChatWidgetStateChanged,
276
+ eventName: BroadcastEvent.ChatWidgetStateChanged,
229
277
  payload: { ...state
230
278
  }
231
279
  };
@@ -252,14 +300,14 @@ export const LiveChatWidgetStateful = props => {
252
300
  })), !((_props$controlProps8 = props.controlProps) !== null && _props$controlProps8 !== void 0 && _props$controlProps8.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_props$componentOverr4 = props.componentOverrides) === null || _props$componentOverr4 === void 0 ? void 0 : _props$componentOverr4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, props.loadingPaneProps)), !((_props$controlProps9 = props.controlProps) !== null && _props$controlProps9 !== void 0 && _props$controlProps9.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_props$componentOverr5 = props.componentOverrides) === null || _props$componentOverr5 === void 0 ? void 0 : _props$componentOverr5.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, props.outOfOfficeHoursPaneProps)), !((_props$controlProps10 = props.controlProps) !== null && _props$controlProps10 !== void 0 && _props$controlProps10.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_props$componentOverr6 = props.componentOverrides) === null || _props$componentOverr6 === void 0 ? void 0 : _props$componentOverr6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
253
301
  reconnectChatProps: props.reconnectChatPaneProps,
254
302
  initStartChat: initStartChatRelay
255
- })), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
303
+ })), !((_props$controlProps11 = props.controlProps) !== null && _props$controlProps11 !== void 0 && _props$controlProps11.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
256
304
  surveyProps: props.preChatSurveyPaneProps,
257
305
  initStartChat: initStartChatRelay
258
- }), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
306
+ })), !((_props$controlProps12 = props.controlProps) !== null && _props$controlProps12 !== void 0 && _props$controlProps12.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
259
307
  voiceVideoCallingSdk: voiceVideoCallingSDK
260
- }, props.callingContainerProps)), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr7 = props.componentOverrides) === null || _props$componentOverr7 === void 0 ? void 0 : _props$componentOverr7.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
308
+ }, props.callingContainerProps)), !((_props$controlProps13 = props.controlProps) !== null && _props$controlProps13 !== void 0 && _props$controlProps13.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_props$componentOverr8 = props.componentOverrides) === null || _props$componentOverr8 === void 0 ? void 0 : _props$componentOverr8.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, props.webChatContainerProps)), !((_props$controlProps14 = props.controlProps) !== null && _props$controlProps14 !== void 0 && _props$controlProps14.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
261
309
  setPostChatContext: setPostChatContextRelay,
262
- endChat: endChatRelay
263
- }))), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr9 = props.componentOverrides) === null || _props$componentOverr9 === void 0 ? void 0 : _props$componentOverr9.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane))));
310
+ prepareEndChat: prepareEndChatRelay
311
+ }))), !((_props$controlProps15 = props.controlProps) !== null && _props$controlProps15 !== void 0 && _props$controlProps15.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_props$componentOverr10 = props.componentOverrides) === null || _props$componentOverr10 === void 0 ? void 0 : _props$componentOverr10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, props.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_props$componentOverr11 = props.componentOverrides) === null || _props$componentOverr11 === void 0 ? void 0 : _props$componentOverr11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, props.postChatSurveyPaneProps, props.chatSDK))), createFooter(props, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_props$componentOverr12 = props.componentOverrides) === null || _props$componentOverr12 === void 0 ? void 0 : _props$componentOverr12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, props.emailTranscriptPane))));
264
312
  };
265
313
  export default LiveChatWidgetStateful;
@@ -3,6 +3,8 @@ import { LoadingPane } from "@microsoft/omnichannel-chat-components";
3
3
  import { defaultGeneralPostChatLoadingPaneStyleProps } from "./common/defaultgeneralPostChatLoadingPaneStyleProps";
4
4
  import { findAllFocusableElement } from "../../common/utils";
5
5
  import useChatContextStore from "../../hooks/useChatContextStore";
6
+ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
7
+ import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
6
8
  export const PostChatLoadingPaneStateful = props => {
7
9
  var _props$styleProps;
8
10
 
@@ -28,6 +30,10 @@ export const PostChatLoadingPaneStateful = props => {
28
30
  if (firstElement && firstElement[0]) {
29
31
  firstElement[0].focus();
30
32
  }
33
+
34
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
35
+ Event: TelemetryEvent.PostChatSurveyLoadingPaneLoaded
36
+ });
31
37
  }, []);
32
38
  return /*#__PURE__*/React.createElement(LoadingPane, {
33
39
  componentOverrides: props.componentOverrides,
@@ -1,4 +1,4 @@
1
- import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
2
  import React, { useEffect, useState } from "react";
3
3
  import { createTimer, setFocusOnElement } from "../../common/utils";
4
4
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
@@ -51,12 +51,12 @@ export const ProactiveChatPaneStateful = props => {
51
51
  if (state.appStates.proactiveChatStates.proactiveChatInNewWindow) {
52
52
  // TODO: BroadcastService: replace with the sdk broadcast service, when in place
53
53
  const startPopoutChatEvent = {
54
- eventName: "StartPopoutChat"
54
+ eventName: BroadcastEvent.ProactiveChatStartPopoutChat
55
55
  };
56
56
  BroadcastService.postMessage(startPopoutChatEvent);
57
57
  dispatch({
58
- type: LiveChatWidgetActionType.SET_SKIP_CHAT_BUTTON_RENDERING,
59
- payload: true
58
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
59
+ payload: ConversationState.Closed
60
60
  });
61
61
  } else if (((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True") {
62
62
  dispatch({
@@ -68,6 +68,10 @@ export const ProactiveChatPaneStateful = props => {
68
68
  payload: ConversationState.OutOfOffice
69
69
  });
70
70
  } else {
71
+ const proactiveChatStarted = {
72
+ eventName: BroadcastEvent.ProactiveChatStartChat
73
+ };
74
+ BroadcastService.postMessage(proactiveChatStarted);
71
75
  await startChat();
72
76
  }
73
77
  },
@@ -14,6 +14,10 @@ export class MockChatSDK {
14
14
  return null;
15
15
  }
16
16
 
17
+ getChatToken() {
18
+ return null;
19
+ }
20
+
17
21
  createChatAdapter() {
18
22
  return new MockAdapter();
19
23
  } // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1,16 +1,6 @@
1
- import { BrowserVendor } from "../../webchatcontroller/enums/BrowserVendor";
1
+ import { ArchiveIcon, AudioIcon, BlankIcon, ExcelIcon, ImageIcon, OneNoteIcon, PDFIcon, PowerpointIcon, VideoIcon, VisioIcon, WordIcon } from "../../../../assets/Icons";
2
2
  import { getBrowserName, isChromiumEdge } from "./BrowserInfo";
3
- import ArchiveIcon from "../../../../assets/icons/archiveIcon.svg";
4
- import AudioIcon from "../../../../assets/icons/audioIcon.svg";
5
- import BlankIcon from "../../../../assets/icons/blankIcon.svg";
6
- import VideoIcon from "../../../../assets/icons/videoIcon.svg";
7
- import ImageIcon from "../../../../assets/icons/imageIcon.svg";
8
- import WordIcon from "../../../../assets/icons/wordIcon.svg";
9
- import OneNoteIcon from "../../../../assets/icons/oneNoteIcon.svg";
10
- import PowerpointIcon from "../../../../assets/icons/powerpointIcon.svg";
11
- import VisioIcon from "../../../../assets/icons/visioIcon.svg";
12
- import PDFIcon from "../../../../assets/icons/pdfIcon.svg";
13
- import ExcelIcon from "../../../../assets/icons/excelIcon.svg";
3
+ import { BrowserVendor } from "../../webchatcontroller/enums/BrowserVendor";
14
4
  import { Constants } from "../../../../common/Constants";
15
5
  const FileAttachmentIconMap = {
16
6
  "aac": AudioIcon,
@@ -5,59 +5,19 @@
5
5
  * 1. Renders system messages differently, according to Microsoft LiveChatWidget styles
6
6
  * 2. Changes the font size of user messages
7
7
  * 3. Decodes certain html characters that came through from chat services
8
- * 4. Triggers end conversation sequence when the chat thread is deleted
9
8
  ******/
10
- import React from "react";
9
+ import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
11
10
  import { Constants } from "../../../../../common/Constants";
12
11
  import { DirectLineActivityType } from "../../enums/DirectLineActivityType";
13
12
  import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
14
13
  import { MessageTypes } from "../../enums/MessageType";
14
+ import React from "react";
15
+ import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
15
16
  import { defaultSystemMessageStyles } from "./defaultStyles/defaultSystemMessageStyles";
16
17
  import { defaultUserMessageStyles } from "./defaultStyles/defaultUserMessageStyles";
17
18
  import { escapeHtml } from "../../../../../common/utils";
18
- import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
19
- import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
20
19
  const loggedSystemMessages = new Array(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
20
 
22
- const handleThreadUpdate = channelData => {
23
- var _channelData$properti, _channelData$properti2;
24
-
25
- TelemetryHelper.logActionEvent(LogLevel.INFO, {
26
- Event: TelemetryEvent.IC3ThreadUpdateEventReceived,
27
- Description: "IC3 ThreadUpdateEvent Received"
28
- });
29
-
30
- const postConversationEndedAction = () => {
31
- TelemetryHelper.logActionEvent(LogLevel.INFO, {
32
- Event: TelemetryEvent.ConversationEndedThreadEventReceived,
33
- Description: "Conversation is ended by agent side or by timeout."
34
- });
35
- }; // If the Thread is deleted, then display post conversation survey if enabled.
36
-
37
-
38
- const isThreadDeleted = (channelData === null || channelData === void 0 ? void 0 : (_channelData$properti = channelData.properties) === null || _channelData$properti === void 0 ? void 0 : (_channelData$properti2 = _channelData$properti.isdeleted) === null || _channelData$properti2 === void 0 ? void 0 : _channelData$properti2.toLowerCase()) === Constants.true;
39
-
40
- if (isThreadDeleted) {
41
- postConversationEndedAction();
42
- return;
43
- } //check if customer is still in the thread
44
-
45
-
46
- if (channelData.members && channelData.members.length > 0) {
47
- for (let i = 0; i < channelData.members.length; i++) {
48
- const id = channelData.members[i].id;
49
- const tag = channelData.members[i].tag; // In case of ACS customer is not removed from thread and has "left" tag
50
-
51
- if (id.startsWith(Constants.visitorIdPrefix) && tag !== Constants.left) {
52
- return;
53
- }
54
- }
55
- }
56
-
57
- postConversationEndedAction();
58
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
-
60
-
61
21
  const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
62
22
  var _card$activity, _card$activity$channe, _card$activity$channe2, _card$activity2, _card$activity2$chann, _card$activity3, _card$activity3$chann, _card$activity3$chann2, _card$activity4, _card$activity4$chann, _card$activity5, _card$activity5$chann, _card$nextVisibleActi, _card$nextVisibleActi2, _card$activity6, _card$activity6$chann, _card$activity7, _card$nextVisibleActi3, _card$activity8;
63
23
 
@@ -108,7 +68,10 @@ export const createActivityMiddleware = (systemMessageStyleProps, userMessageSty
108
68
  var _card$activity$channe3;
109
69
 
110
70
  if (((_card$activity$channe3 = card.activity.channelData) === null || _card$activity$channe3 === void 0 ? void 0 : _card$activity$channe3.type) === MessageTypes.Thread) {
111
- handleThreadUpdate(card.activity.channelData);
71
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
72
+ Event: TelemetryEvent.IC3ThreadUpdateEventReceived,
73
+ Description: "IC3 ThreadUpdateEvent Received"
74
+ });
112
75
  }
113
76
 
114
77
  return () => false;
@@ -8,6 +8,7 @@
8
8
  import { Constants, MimeTypes, WebChatMiddlewareConstants } from "../../../../../common/Constants";
9
9
  import React from "react";
10
10
  import { getFileAttachmentIconData, isInlineMediaSupported } from "../../../common/utils/FileAttachmentIconManager";
11
+ import { BroadcastEvent } from "../../../../../common/telemetry/TelemetryConstants";
11
12
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
12
13
  import { WebChatActionType } from "../../enums/WebChatActionType";
13
14
  import { defaultAttachmentAdaptiveCardStyles } from "./defaultStyles/defaultAtttachmentAdaptiveCardStyles";
@@ -187,7 +188,7 @@ const createAttachmentMiddleware = enableInlinePlaying => {
187
188
  } catch (e) {
188
189
  const errorData = "Unable to parse the adaptive card format";
189
190
  BroadcastService.postMessage({
190
- eventName: "InvalidAdaptiveCardFormat",
191
+ eventName: BroadcastEvent.InvalidAdaptiveCardFormat,
191
192
  payload: {
192
193
  Message: errorData,
193
194
  ExceptionDetails: e
@@ -17,22 +17,22 @@ const createConversationEndMiddleware = conversationEndCallback => _ref => {
17
17
  var _action$payload;
18
18
 
19
19
  if ((action === null || action === void 0 ? void 0 : action.type) == WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
20
- var _activity$from, _activity$from2, _activity$channelData5, _activity$channelData6;
20
+ var _activity$from, _activity$from2, _activity$channelData7, _activity$channelData8;
21
21
 
22
22
  const activity = action.payload.activity;
23
23
 
24
24
  if (((_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) === DirectLineSenderRole.Bot && activity.channelId === "ACS_CHANNEL") {
25
- var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4;
25
+ var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6;
26
26
 
27
27
  // ACS
28
- if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(Constants.systemMessageTag) && (_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && (_activity$channelData4 = _activity$channelData3.tags) !== null && _activity$channelData4 !== void 0 && _activity$channelData4.includes(Constants.agentEndConversationMessageTag)) {
28
+ if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(Constants.systemMessageTag) && ((_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && (_activity$channelData4 = _activity$channelData3.tags) !== null && _activity$channelData4 !== void 0 && _activity$channelData4.includes(Constants.agentEndConversationMessageTag) || (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(Constants.supervisorForceCloseMessageTag))) {
29
29
  conversationEndCallback();
30
30
  }
31
- } else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === DirectLineSenderRole.Channel && ((_activity$channelData5 = activity.channelData) === null || _activity$channelData5 === void 0 ? void 0 : _activity$channelData5.type) === MessageTypes.Thread && (_activity$channelData6 = activity.channelData) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.properties) {
32
- var _activity$channelData7, _activity$channelData8, _activity$channelData9, _activity$channelData10;
31
+ } else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === DirectLineSenderRole.Channel && ((_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : _activity$channelData7.type) === MessageTypes.Thread && (_activity$channelData8 = activity.channelData) !== null && _activity$channelData8 !== void 0 && _activity$channelData8.properties) {
32
+ var _activity$channelData9, _activity$channelData10, _activity$channelData11, _activity$channelData12;
33
33
 
34
34
  // IC3
35
- if (((_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : (_activity$channelData8 = _activity$channelData7.properties) === null || _activity$channelData8 === void 0 ? void 0 : _activity$channelData8.isdeleted) === Constants.truePascal || !((_activity$channelData9 = activity.channelData) !== null && _activity$channelData9 !== void 0 && (_activity$channelData10 = _activity$channelData9.properties) !== null && _activity$channelData10 !== void 0 && _activity$channelData10.containsExternalEntitiesListeningAll)) {
35
+ if (((_activity$channelData9 = activity.channelData) === null || _activity$channelData9 === void 0 ? void 0 : (_activity$channelData10 = _activity$channelData9.properties) === null || _activity$channelData10 === void 0 ? void 0 : _activity$channelData10.isdeleted) === Constants.truePascal || !((_activity$channelData11 = activity.channelData) !== null && _activity$channelData11 !== void 0 && (_activity$channelData12 = _activity$channelData11.properties) !== null && _activity$channelData12 !== void 0 && _activity$channelData12.containsExternalEntitiesListeningAll)) {
36
36
  conversationEndCallback();
37
37
  }
38
38
  }
@@ -7,6 +7,7 @@ export let ConversationState;
7
7
  ConversationState[ConversationState["OutOfOffice"] = 3] = "OutOfOffice";
8
8
  ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
9
9
  ConversationState[ConversationState["Active"] = 5] = "Active";
10
- ConversationState[ConversationState["Postchat"] = 6] = "Postchat";
11
- ConversationState[ConversationState["Closed"] = 7] = "Closed";
10
+ ConversationState[ConversationState["InActive"] = 6] = "InActive";
11
+ ConversationState[ConversationState["Postchat"] = 7] = "Postchat";
12
+ ConversationState[ConversationState["Closed"] = 8] = "Closed";
12
13
  })(ConversationState || (ConversationState = {}));