@microsoft/omnichannel-chat-widget 1.2.1 → 1.2.2-main.03f3121

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.Regex = exports.ParticipantType = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.ChatSDKError = exports.AriaTelemetryConstants = exports.AMSConstants = void 0;
6
+ exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.Regex = exports.ParticipantType = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.ChatSDKError = exports.AriaTelemetryConstants = exports.AMSConstants = void 0;
7
7
  var _class;
8
8
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
9
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
@@ -208,6 +208,12 @@ exports.E2VVOptions = E2VVOptions;
208
208
  E2VVOptions["VideoAndVoiceCalling"] = "192350001";
209
209
  E2VVOptions["VoiceOnly"] = "192350002";
210
210
  })(E2VVOptions || (exports.E2VVOptions = E2VVOptions = {}));
211
+ let ConversationMode;
212
+ exports.ConversationMode = ConversationMode;
213
+ (function (ConversationMode) {
214
+ ConversationMode["Regular"] = "192350000";
215
+ ConversationMode["Persistent"] = "192350001";
216
+ })(ConversationMode || (exports.ConversationMode = ConversationMode = {}));
211
217
  let LiveWorkItemState;
212
218
  exports.LiveWorkItemState = LiveWorkItemState;
213
219
  (function (LiveWorkItemState) {
@@ -195,7 +195,7 @@ exports.TelemetryEvent = TelemetryEvent;
195
195
  TelemetryEvent["MessageSent"] = "MessageSent";
196
196
  TelemetryEvent["MessageReceived"] = "MessageReceived";
197
197
  TelemetryEvent["SystemMessageReceived"] = "SystemMessageReceived";
198
- TelemetryEvent["HistoryMessageReceived"] = "HistoryMessageReceived";
198
+ TelemetryEvent["RehydrateMessageReceived"] = "RehydrateMessageReceived";
199
199
  TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
200
200
  TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
201
201
  TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
@@ -3,19 +3,20 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isReconnectEnabled = exports.handleChatReconnect = exports.getChatReconnectContext = void 0;
6
+ exports.isReconnectEnabled = exports.isPersistentEnabled = exports.handleChatReconnect = exports.getChatReconnectContext = void 0;
7
7
  require("regenerator-runtime/runtime");
8
8
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
9
  var _utils = require("../../../common/utils");
10
10
  var _authHelper = require("./authHelper");
11
11
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
12
+ var _Constants = require("../../../common/Constants");
12
13
  var _ConversationState = require("../../../contexts/common/ConversationState");
13
14
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
14
15
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
17
  const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
17
18
  var _props$chatConfig, _props$chatConfig$Liv;
18
- if (!isReconnectEnabled(props.chatConfig)) return;
19
+ if (!isReconnectEnabled(props.chatConfig) || isPersistentEnabled(props.chatConfig)) return;
19
20
 
20
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
22
  const isAuthenticatedChat = (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
@@ -128,6 +129,15 @@ const isReconnectEnabled = chatConfig => {
128
129
  return false;
129
130
  };
130
131
  exports.isReconnectEnabled = isReconnectEnabled;
132
+ const isPersistentEnabled = chatConfig => {
133
+ if (chatConfig) {
134
+ var _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4;
135
+ const persistentEnabled = ((_chatConfig$LiveWSAnd3 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd3 === void 0 ? void 0 : (_chatConfig$LiveWSAnd4 = _chatConfig$LiveWSAnd3.msdyn_conversationmode) === null || _chatConfig$LiveWSAnd4 === void 0 ? void 0 : _chatConfig$LiveWSAnd4.toLowerCase()) === _Constants.ConversationMode.Persistent;
136
+ return persistentEnabled;
137
+ }
138
+ return false;
139
+ };
140
+ exports.isPersistentEnabled = isPersistentEnabled;
131
141
  const hasReconnectId = reconnectAvailabilityResponse => {
132
142
  return reconnectAvailabilityResponse && !(0, _utils.isNullOrUndefined)(reconnectAvailabilityResponse.reconnectId);
133
143
  };
@@ -131,7 +131,7 @@ const LiveChatWidgetStateful = props => {
131
131
  isChatValid = await (0, _startChat.checkIfConversationStillValid)(chatSDK, dispatch, state);
132
132
  if (isChatValid === true) {
133
133
  //Check if reconnect enabled
134
- if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true) {
134
+ if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true && !(0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
135
135
  await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, _startChat.initStartChat, state);
136
136
  // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
137
137
  if (state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat) {
@@ -145,7 +145,7 @@ const LiveChatWidgetStateful = props => {
145
145
  if (isChatValid === false) {
146
146
  if (localState) {
147
147
  // adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
148
- if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true) {
148
+ if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true && !(0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
149
149
  await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, _startChat.initStartChat, state);
150
150
  // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
151
151
  if (state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat) {
@@ -529,14 +529,14 @@ const LiveChatWidgetStateful = props => {
529
529
  }
530
530
 
531
531
  // If start chat failed, and C2 is trying to close chat widget
532
- if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed) {
532
+ if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed || (state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === _ConversationState.ConversationState.Postchat) {
533
533
  (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
534
534
  return;
535
535
  }
536
536
 
537
537
  // Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
538
- if ((state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === _ConversationState.ConversationState.Postchat || (state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === _ConversationState.ConversationState.InActive) {
539
- (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
538
+ if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === _ConversationState.ConversationState.InActive) {
539
+ (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid.current);
540
540
  return;
541
541
  }
542
542
  if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === _Constants.ConversationEndEntity.Bot) {
@@ -8,7 +8,6 @@ var _react = require("@fluentui/react");
8
8
  var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
9
9
  var _react2 = _interopRequireWildcard(require("react"));
10
10
  var _BotMagicCodeStore = require("./webchatcontroller/BotMagicCodeStore");
11
- var _broadcastChannel = require("broadcast-channel");
12
11
  var _botframeworkWebchat = require("botframework-webchat");
13
12
  var _Constants = require("../../common/Constants");
14
13
  var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
@@ -61,8 +60,8 @@ const WebChatContainerStateful = props => {
61
60
  BasicWebChat
62
61
  } = _botframeworkWebchat.Components;
63
62
  const [state, dispatch] = (0, _.useChatContextStore)();
64
- const magicCodeBroadcastChannel = new _broadcastChannel.BroadcastChannel(_Constants.Constants.magicCodeBroadcastChannel);
65
- const magicCodeResponseBroadcastChannel = new _broadcastChannel.BroadcastChannel(_Constants.Constants.magicCodeResponseBroadcastChannel);
63
+ const magicCodeBroadcastChannel = new window.BroadcastChannel(_Constants.Constants.magicCodeBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
64
+ const magicCodeResponseBroadcastChannel = new window.BroadcastChannel(_Constants.Constants.magicCodeResponseBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
66
65
  const {
67
66
  webChatContainerProps,
68
67
  contextDataStore
@@ -8,6 +8,7 @@ var _TelemetryConstants = require("../common/telemetry/TelemetryConstants");
8
8
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
9
9
  var _Constants = require("../common/Constants");
10
10
  var _TelemetryHelper = require("../common/telemetry/TelemetryHelper");
11
+ var _TelemetryManager = require("../common/telemetry/TelemetryManager");
11
12
  const createOnNewAdapterActivityHandler = (chatId, userId) => {
12
13
  const onNewAdapterActivityHandler = activity => {
13
14
  var _activity$channelData, _activity$channelData2, _activity$channelData3;
@@ -17,6 +18,20 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
17
18
  };
18
19
  let isHistoryMessageReceivedEventRasied = false;
19
20
  const raiseMessageEvent = (activity, isHistoryMessage) => {
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ const polyfillMessagePayloadForEvent = payload => {
23
+ var _activity$conversatio, _TelemetryManager$Int;
24
+ return {
25
+ ...payload,
26
+ channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
27
+ chatId: activity === null || activity === void 0 ? void 0 : (_activity$conversatio = activity.conversation) === null || _activity$conversatio === void 0 ? void 0 : _activity$conversatio.id,
28
+ conversationId: (_TelemetryManager$Int = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.conversationId,
29
+ id: activity === null || activity === void 0 ? void 0 : activity.id,
30
+ isChatComplete: false,
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
+ text: activity === null || activity === void 0 ? void 0 : activity.text
33
+ };
34
+ };
20
35
  if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants.Constants.message) {
21
36
  var _text, _text2, _activity$channelData4, _activity$from;
22
37
  const payload = {
@@ -34,7 +49,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
34
49
  payload.messageType = _Constants.Constants.userMessageTag;
35
50
  const newMessageSentEvent = {
36
51
  eventName: _TelemetryConstants.BroadcastEvent.NewMessageSent,
37
- payload: payload
52
+ payload: polyfillMessagePayloadForEvent(payload)
38
53
  };
39
54
  _omnichannelChatComponents.BroadcastService.postMessage(newMessageSentEvent);
40
55
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
@@ -65,7 +80,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
65
80
  }
66
81
  const newMessageReceivedEvent = {
67
82
  eventName: isHistoryMessage ? _TelemetryConstants.BroadcastEvent.HistoryMessageReceived : _TelemetryConstants.BroadcastEvent.NewMessageReceived,
68
- payload: payload
83
+ payload: polyfillMessagePayloadForEvent(payload)
69
84
  };
70
85
  _omnichannelChatComponents.BroadcastService.postMessage(newMessageReceivedEvent);
71
86
  if (!isHistoryMessage) {
@@ -78,7 +93,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
78
93
  if (!isHistoryMessageReceivedEventRasied) {
79
94
  isHistoryMessageReceivedEventRasied = true;
80
95
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
81
- Event: _TelemetryConstants.TelemetryEvent.HistoryMessageReceived,
96
+ Event: _TelemetryConstants.TelemetryEvent.RehydrateMessageReceived,
82
97
  Description: "History message received",
83
98
  Data: payload
84
99
  });
@@ -188,6 +188,11 @@ export let E2VVOptions;
188
188
  E2VVOptions["VideoAndVoiceCalling"] = "192350001";
189
189
  E2VVOptions["VoiceOnly"] = "192350002";
190
190
  })(E2VVOptions || (E2VVOptions = {}));
191
+ export let ConversationMode;
192
+ (function (ConversationMode) {
193
+ ConversationMode["Regular"] = "192350000";
194
+ ConversationMode["Persistent"] = "192350001";
195
+ })(ConversationMode || (ConversationMode = {}));
191
196
  export let LiveWorkItemState;
192
197
  (function (LiveWorkItemState) {
193
198
  LiveWorkItemState["Active"] = "Active";
@@ -189,7 +189,7 @@ export let TelemetryEvent;
189
189
  TelemetryEvent["MessageSent"] = "MessageSent";
190
190
  TelemetryEvent["MessageReceived"] = "MessageReceived";
191
191
  TelemetryEvent["SystemMessageReceived"] = "SystemMessageReceived";
192
- TelemetryEvent["HistoryMessageReceived"] = "HistoryMessageReceived";
192
+ TelemetryEvent["RehydrateMessageReceived"] = "RehydrateMessageReceived";
193
193
  TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
194
194
  TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
195
195
  TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
@@ -3,6 +3,7 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/teleme
3
3
  import { checkContactIdError, isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
4
4
  import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
5
5
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
6
+ import { ConversationMode } from "../../../common/Constants";
6
7
  import { ConversationState } from "../../../contexts/common/ConversationState";
7
8
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
8
9
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
@@ -10,7 +11,7 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
10
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
12
  const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
12
13
  var _props$chatConfig, _props$chatConfig$Liv;
13
- if (!isReconnectEnabled(props.chatConfig)) return;
14
+ if (!isReconnectEnabled(props.chatConfig) || isPersistentEnabled(props.chatConfig)) return;
14
15
 
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
17
  const isAuthenticatedChat = (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
@@ -120,7 +121,15 @@ const isReconnectEnabled = chatConfig => {
120
121
  }
121
122
  return false;
122
123
  };
124
+ const isPersistentEnabled = chatConfig => {
125
+ if (chatConfig) {
126
+ var _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4;
127
+ const persistentEnabled = ((_chatConfig$LiveWSAnd3 = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd3 === void 0 ? void 0 : (_chatConfig$LiveWSAnd4 = _chatConfig$LiveWSAnd3.msdyn_conversationmode) === null || _chatConfig$LiveWSAnd4 === void 0 ? void 0 : _chatConfig$LiveWSAnd4.toLowerCase()) === ConversationMode.Persistent;
128
+ return persistentEnabled;
129
+ }
130
+ return false;
131
+ };
123
132
  const hasReconnectId = reconnectAvailabilityResponse => {
124
133
  return reconnectAvailabilityResponse && !isNullOrUndefined(reconnectAvailabilityResponse.reconnectId);
125
134
  };
126
- export { handleChatReconnect, isReconnectEnabled, getChatReconnectContext };
135
+ export { handleChatReconnect, isReconnectEnabled, isPersistentEnabled, getChatReconnectContext };
@@ -9,7 +9,7 @@ import { checkIfConversationStillValid, initStartChat, prepareStartChat, setPreC
9
9
  import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString, isUndefinedOrEmpty, newGuid } from "../../../common/utils";
10
10
  import { defaultClientDataStoreProvider, isCookieAllowed } from "../../../common/storage/default/defaultClientDataStoreProvider";
11
11
  import { endChat, prepareEndChat } from "../common/endChat";
12
- import { handleChatReconnect, isReconnectEnabled } from "../common/reconnectChatHelper";
12
+ import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "../common/reconnectChatHelper";
13
13
  import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
14
14
  import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
15
15
  import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
@@ -123,7 +123,7 @@ export const LiveChatWidgetStateful = props => {
123
123
  isChatValid = await checkIfConversationStillValid(chatSDK, dispatch, state);
124
124
  if (isChatValid === true) {
125
125
  //Check if reconnect enabled
126
- if (isReconnectEnabled(props.chatConfig) === true) {
126
+ if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
127
127
  await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
128
128
  // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
129
129
  if (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.ReconnectChat) {
@@ -137,7 +137,7 @@ export const LiveChatWidgetStateful = props => {
137
137
  if (isChatValid === false) {
138
138
  if (localState) {
139
139
  // adding the reconnect logic for the case when customer tries to reconnect from a new browser or InPrivate browser
140
- if (isReconnectEnabled(props.chatConfig) === true) {
140
+ if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
141
141
  await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
142
142
  // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
143
143
  if (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.ReconnectChat) {
@@ -521,14 +521,14 @@ export const LiveChatWidgetStateful = props => {
521
521
  }
522
522
 
523
523
  // If start chat failed, and C2 is trying to close chat widget
524
- if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed) {
524
+ if (state !== null && state !== void 0 && (_state$appStates9 = state.appStates) !== null && _state$appStates9 !== void 0 && _state$appStates9.startChatFailed || (state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === ConversationState.Postchat) {
525
525
  endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
526
526
  return;
527
527
  }
528
528
 
529
529
  // Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
530
- if ((state === null || state === void 0 ? void 0 : (_state$appStates10 = state.appStates) === null || _state$appStates10 === void 0 ? void 0 : _state$appStates10.conversationState) === ConversationState.Postchat || (state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === ConversationState.InActive) {
531
- endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, true, uwid.current);
530
+ if ((state === null || state === void 0 ? void 0 : (_state$appStates11 = state.appStates) === null || _state$appStates11 === void 0 ? void 0 : _state$appStates11.conversationState) === ConversationState.InActive) {
531
+ endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true, uwid.current);
532
532
  return;
533
533
  }
534
534
  if ((state === null || state === void 0 ? void 0 : (_state$appStates12 = state.appStates) === null || _state$appStates12 === void 0 ? void 0 : _state$appStates12.conversationEndedBy) === ConversationEndEntity.Agent || (state === null || state === void 0 ? void 0 : (_state$appStates13 = state.appStates) === null || _state$appStates13 === void 0 ? void 0 : _state$appStates13.conversationEndedBy) === ConversationEndEntity.Bot) {
@@ -4,7 +4,6 @@ import { Stack } from "@fluentui/react";
4
4
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
5
5
  import React, { useEffect } from "react";
6
6
  import { BotMagicCodeStore } from "./webchatcontroller/BotMagicCodeStore";
7
- import { BroadcastChannel } from "broadcast-channel";
8
7
  import { Components } from "botframework-webchat";
9
8
  import { Constants } from "../../common/Constants";
10
9
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
@@ -53,8 +52,8 @@ export const WebChatContainerStateful = props => {
53
52
  BasicWebChat
54
53
  } = Components;
55
54
  const [state, dispatch] = useChatContextStore();
56
- const magicCodeBroadcastChannel = new BroadcastChannel(Constants.magicCodeBroadcastChannel);
57
- const magicCodeResponseBroadcastChannel = new BroadcastChannel(Constants.magicCodeResponseBroadcastChannel);
55
+ const magicCodeBroadcastChannel = new window.BroadcastChannel(Constants.magicCodeBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
56
+ const magicCodeResponseBroadcastChannel = new window.BroadcastChannel(Constants.magicCodeResponseBroadcastChannel); // eslint-disable-line @typescript-eslint/no-explicit-any
58
57
  const {
59
58
  webChatContainerProps,
60
59
  contextDataStore
@@ -2,6 +2,7 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../common/telemetry/Te
2
2
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
3
3
  import { Constants } from "../common/Constants";
4
4
  import { TelemetryHelper } from "../common/telemetry/TelemetryHelper";
5
+ import { TelemetryManager } from "../common/telemetry/TelemetryManager";
5
6
  export const createOnNewAdapterActivityHandler = (chatId, userId) => {
6
7
  const onNewAdapterActivityHandler = activity => {
7
8
  var _activity$channelData, _activity$channelData2, _activity$channelData3;
@@ -11,6 +12,20 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
11
12
  };
12
13
  let isHistoryMessageReceivedEventRasied = false;
13
14
  const raiseMessageEvent = (activity, isHistoryMessage) => {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ const polyfillMessagePayloadForEvent = payload => {
17
+ var _activity$conversatio, _TelemetryManager$Int;
18
+ return {
19
+ ...payload,
20
+ channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
21
+ chatId: activity === null || activity === void 0 ? void 0 : (_activity$conversatio = activity.conversation) === null || _activity$conversatio === void 0 ? void 0 : _activity$conversatio.id,
22
+ conversationId: (_TelemetryManager$Int = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.conversationId,
23
+ id: activity === null || activity === void 0 ? void 0 : activity.id,
24
+ isChatComplete: false,
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ text: activity === null || activity === void 0 ? void 0 : activity.text
27
+ };
28
+ };
14
29
  if ((activity === null || activity === void 0 ? void 0 : activity.type) === Constants.message) {
15
30
  var _text, _text2, _activity$channelData4, _activity$from;
16
31
  const payload = {
@@ -28,7 +43,7 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
28
43
  payload.messageType = Constants.userMessageTag;
29
44
  const newMessageSentEvent = {
30
45
  eventName: BroadcastEvent.NewMessageSent,
31
- payload: payload
46
+ payload: polyfillMessagePayloadForEvent(payload)
32
47
  };
33
48
  BroadcastService.postMessage(newMessageSentEvent);
34
49
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
@@ -59,7 +74,7 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
59
74
  }
60
75
  const newMessageReceivedEvent = {
61
76
  eventName: isHistoryMessage ? BroadcastEvent.HistoryMessageReceived : BroadcastEvent.NewMessageReceived,
62
- payload: payload
77
+ payload: polyfillMessagePayloadForEvent(payload)
63
78
  };
64
79
  BroadcastService.postMessage(newMessageReceivedEvent);
65
80
  if (!isHistoryMessage) {
@@ -72,7 +87,7 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
72
87
  if (!isHistoryMessageReceivedEventRasied) {
73
88
  isHistoryMessageReceivedEventRasied = true;
74
89
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
75
- Event: TelemetryEvent.HistoryMessageReceived,
90
+ Event: TelemetryEvent.RehydrateMessageReceived,
76
91
  Description: "History message received",
77
92
  Data: payload
78
93
  });
@@ -171,6 +171,10 @@ export declare enum E2VVOptions {
171
171
  VideoAndVoiceCalling = "192350001",
172
172
  VoiceOnly = "192350002"
173
173
  }
174
+ export declare enum ConversationMode {
175
+ Regular = "192350000",
176
+ Persistent = "192350001"
177
+ }
174
178
  export declare enum LiveWorkItemState {
175
179
  Active = "Active",
176
180
  Closed = "Closed",
@@ -182,7 +182,7 @@ export declare enum TelemetryEvent {
182
182
  MessageSent = "MessageSent",
183
183
  MessageReceived = "MessageReceived",
184
184
  SystemMessageReceived = "SystemMessageReceived",
185
- HistoryMessageReceived = "HistoryMessageReceived",
185
+ RehydrateMessageReceived = "RehydrateMessageReceived",
186
186
  CustomContextReceived = "CustomContextReceived",
187
187
  NetworkDisconnected = "NetworkDisconnected",
188
188
  NetworkReconnected = "NetworkReconnected",
@@ -6,4 +6,5 @@ import { ILiveChatWidgetContext } from "../../../contexts/common/ILiveChatWidget
6
6
  declare const handleChatReconnect: (chatSDK: any, props: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, initStartChat: any, state: ILiveChatWidgetContext) => Promise<void>;
7
7
  declare const getChatReconnectContext: (chatSDK: any, chatConfig: ChatConfig, props: any, isAuthenticatedChat: boolean) => Promise<any>;
8
8
  declare const isReconnectEnabled: (chatConfig?: ChatConfig | undefined) => boolean;
9
- export { handleChatReconnect, isReconnectEnabled, getChatReconnectContext };
9
+ declare const isPersistentEnabled: (chatConfig?: ChatConfig | undefined) => boolean;
10
+ export { handleChatReconnect, isReconnectEnabled, isPersistentEnabled, getChatReconnectContext };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.2.1",
3
+ "version": "1.2.2-main.03f3121",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@microsoft/omnichannel-chat-components": "^1.0.5",
78
- "@microsoft/omnichannel-chat-sdk": "1.4.4",
78
+ "@microsoft/omnichannel-chat-sdk": "1.4.5",
79
79
  "abort-controller-es5": "^2.0.1",
80
80
  "dompurify": "^2.3.4",
81
81
  "markdown-it": "^12.3.2",