@microsoft/omnichannel-chat-widget 1.2.2-main.f0135ab → 1.2.3-main.000f886

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";
@@ -8,12 +8,12 @@ var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
10
10
  var _Constants = require("../../common/Constants");
11
- var _utils = require("../../common/utils");
12
11
  var _ConversationState = require("../../contexts/common/ConversationState");
13
12
  var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
14
13
  var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
15
14
  var _TelemetryManager = require("../../common/telemetry/TelemetryManager");
16
15
  var _defaultOutOfOfficeChatButtonStyleProps = require("./common/styleProps/defaultOutOfOfficeChatButtonStyleProps");
16
+ var _utils = require("../../common/utils");
17
17
  var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -28,6 +28,22 @@ const ChatButtonStateful = props => {
28
28
  } = props;
29
29
  //Setting OutOfOperatingHours Flag
30
30
  const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(((_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");
31
+ const ref = (0, _react.useRef)(() => {
32
+ return;
33
+ });
34
+ ref.current = async () => {
35
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
36
+ Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked
37
+ });
38
+ if (state.appStates.isMinimized) {
39
+ dispatch({
40
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
41
+ payload: false
42
+ });
43
+ } else {
44
+ await startChat();
45
+ }
46
+ };
31
47
  const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeChatButtonStyleProps.defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
32
48
  const controlProps = {
33
49
  id: "oc-lcw-chat-button",
@@ -36,19 +52,7 @@ const ChatButtonStateful = props => {
36
52
  subtitleText: "We're online.",
37
53
  hideNotificationBubble: (buttonProps === null || buttonProps === void 0 ? void 0 : (_buttonProps$controlP = buttonProps.controlProps) === null || _buttonProps$controlP === void 0 ? void 0 : _buttonProps$controlP.hideNotificationBubble) === true || state.appStates.isMinimized === false,
38
54
  unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > _Constants.Constants.maximumUnreadMessageCount ? (_props$buttonProps = props.buttonProps) === null || _props$buttonProps === void 0 ? void 0 : (_props$buttonProps$co = _props$buttonProps.controlProps) === null || _props$buttonProps$co === void 0 ? void 0 : _props$buttonProps$co.largeUnreadMessageString : state.appStates.unreadMessageCount.toString() : "0",
39
- onClick: async () => {
40
- _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
41
- Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked
42
- });
43
- if (state.appStates.isMinimized) {
44
- dispatch({
45
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
46
- payload: false
47
- });
48
- } else {
49
- await startChat();
50
- }
51
- },
55
+ onClick: () => ref.current(),
52
56
  unreadMessageString: (_props$buttonProps2 = props.buttonProps) === null || _props$buttonProps2 === void 0 ? void 0 : (_props$buttonProps2$c = _props$buttonProps2.controlProps) === null || _props$buttonProps2$c === void 0 ? void 0 : _props$buttonProps2$c.unreadMessageString,
53
57
  ...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps)
54
58
  };
@@ -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
  };
@@ -88,12 +88,12 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
88
88
  const optionalParams = {
89
89
  isProactiveChat
90
90
  };
91
- await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
91
+ await initStartChat(chatSDK, dispatch, setAdapter, state, props, optionalParams);
92
92
  };
93
93
 
94
94
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
95
  exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
96
- const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persistedState) => {
96
+ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
97
97
  var _props$controlProps2;
98
98
  let isStartChatSuccessful = false;
99
99
  const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
@@ -131,7 +131,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
131
131
  try {
132
132
  var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
133
133
  // Set custom context params
134
- await setCustomContextParams(props);
134
+ await setCustomContextParams(state, props);
135
135
  const defaultOptionalParams = {
136
136
  sendDefaultInitContext: true,
137
137
  isProactiveChat: !!(params !== null && params !== void 0 && params.isProactiveChat),
@@ -295,14 +295,14 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
295
295
  const optionalParams = {
296
296
  liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
297
297
  };
298
- await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
298
+ await initStartChat(chatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
299
299
  return true;
300
300
  }
301
301
  return false;
302
302
  };
303
303
 
304
304
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
305
- const setCustomContextParams = async props => {
305
+ const setCustomContextParams = async (state, props) => {
306
306
  var _props$chatConfig, _props$chatConfig$Liv, _persistedState$domai8;
307
307
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
308
308
  const isAuthenticatedChat = props !== null && props !== void 0 && (_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;
@@ -310,6 +310,12 @@ const setCustomContextParams = async props => {
310
310
  if (isAuthenticatedChat) {
311
311
  return;
312
312
  }
313
+ if (state !== null && state !== void 0 && state.domainStates.customContext) {
314
+ optionalParams = Object.assign({}, optionalParams, {
315
+ customContext: JSON.parse(JSON.stringify(state === null || state === void 0 ? void 0 : state.domainStates.customContext))
316
+ });
317
+ return;
318
+ }
313
319
  if ((0, _utils.isNullOrEmptyString)(widgetInstanceId)) {
314
320
  widgetInstanceId = (0, _utils.getWidgetCacheIdfromProps)(props);
315
321
  }
@@ -322,13 +328,13 @@ const setCustomContextParams = async props => {
322
328
  Description: "Setting custom context for unauthenticated chat"
323
329
  });
324
330
  optionalParams = Object.assign({}, optionalParams, {
325
- customContext: customContextLocal
331
+ customContext: JSON.parse(JSON.stringify(customContextLocal))
326
332
  });
327
333
  } else {
328
334
  const customContextFromParent = await getInitContextParamsForPopout();
329
335
  if (!(0, _utils.isUndefinedOrEmpty)(customContextFromParent === null || customContextFromParent === void 0 ? void 0 : customContextFromParent.contextVariables)) {
330
336
  optionalParams = Object.assign({}, optionalParams, {
331
- customContext: customContextFromParent.contextVariables
337
+ customContext: JSON.parse(JSON.stringify(customContextFromParent.contextVariables))
332
338
  });
333
339
  }
334
340
  }
@@ -131,21 +131,21 @@ 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) {
138
138
  return;
139
139
  }
140
140
  }
141
- await (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, props, optionalParams);
141
+ await (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, state, props, optionalParams);
142
142
  return;
143
143
  }
144
144
  }
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) {
@@ -609,7 +609,7 @@ const LiveChatWidgetStateful = props => {
609
609
  const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => (0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab, uwid.current);
610
610
  const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
611
611
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
612
- const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
612
+ const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
613
613
  const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
614
614
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
615
615
  const prepareEndChatRelay = () => (0, _endChat.prepareEndChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
@@ -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";
@@ -1,13 +1,13 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
- import React, { useEffect, useState } from "react";
2
+ import React, { useEffect, useRef, useState } from "react";
3
3
  import { ChatButton } from "@microsoft/omnichannel-chat-components";
4
4
  import { Constants } from "../../common/Constants";
5
- import { setFocusOnElement } from "../../common/utils";
6
5
  import { ConversationState } from "../../contexts/common/ConversationState";
7
6
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
8
7
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
9
8
  import { TelemetryTimers } from "../../common/telemetry/TelemetryManager";
10
9
  import { defaultOutOfOfficeChatButtonStyleProps } from "./common/styleProps/defaultOutOfOfficeChatButtonStyleProps";
10
+ import { setFocusOnElement } from "../../common/utils";
11
11
  import useChatContextStore from "../../hooks/useChatContextStore";
12
12
  export const ChatButtonStateful = props => {
13
13
  var _state$domainStates$l, _state$domainStates$l2, _buttonProps$controlP, _props$buttonProps, _props$buttonProps$co, _props$buttonProps2, _props$buttonProps2$c, _props$buttonProps3, _props$buttonProps3$c;
@@ -19,6 +19,22 @@ export const ChatButtonStateful = props => {
19
19
  } = props;
20
20
  //Setting OutOfOperatingHours Flag
21
21
  const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_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");
22
+ const ref = useRef(() => {
23
+ return;
24
+ });
25
+ ref.current = async () => {
26
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
27
+ Event: TelemetryEvent.LCWChatButtonClicked
28
+ });
29
+ if (state.appStates.isMinimized) {
30
+ dispatch({
31
+ type: LiveChatWidgetActionType.SET_MINIMIZED,
32
+ payload: false
33
+ });
34
+ } else {
35
+ await startChat();
36
+ }
37
+ };
22
38
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
23
39
  const controlProps = {
24
40
  id: "oc-lcw-chat-button",
@@ -27,19 +43,7 @@ export const ChatButtonStateful = props => {
27
43
  subtitleText: "We're online.",
28
44
  hideNotificationBubble: (buttonProps === null || buttonProps === void 0 ? void 0 : (_buttonProps$controlP = buttonProps.controlProps) === null || _buttonProps$controlP === void 0 ? void 0 : _buttonProps$controlP.hideNotificationBubble) === true || state.appStates.isMinimized === false,
29
45
  unreadMessageCount: state.appStates.unreadMessageCount ? state.appStates.unreadMessageCount > Constants.maximumUnreadMessageCount ? (_props$buttonProps = props.buttonProps) === null || _props$buttonProps === void 0 ? void 0 : (_props$buttonProps$co = _props$buttonProps.controlProps) === null || _props$buttonProps$co === void 0 ? void 0 : _props$buttonProps$co.largeUnreadMessageString : state.appStates.unreadMessageCount.toString() : "0",
30
- onClick: async () => {
31
- TelemetryHelper.logActionEvent(LogLevel.INFO, {
32
- Event: TelemetryEvent.LCWChatButtonClicked
33
- });
34
- if (state.appStates.isMinimized) {
35
- dispatch({
36
- type: LiveChatWidgetActionType.SET_MINIMIZED,
37
- payload: false
38
- });
39
- } else {
40
- await startChat();
41
- }
42
- },
46
+ onClick: () => ref.current(),
43
47
  unreadMessageString: (_props$buttonProps2 = props.buttonProps) === null || _props$buttonProps2 === void 0 ? void 0 : (_props$buttonProps2$c = _props$buttonProps2.controlProps) === null || _props$buttonProps2$c === void 0 ? void 0 : _props$buttonProps2$c.unreadMessageString,
44
48
  ...(buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.controlProps)
45
49
  };
@@ -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 };
@@ -82,11 +82,11 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
82
82
  const optionalParams = {
83
83
  isProactiveChat
84
84
  };
85
- await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
85
+ await initStartChat(chatSDK, dispatch, setAdapter, state, props, optionalParams);
86
86
  };
87
87
 
88
88
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
- const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persistedState) => {
89
+ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
90
90
  var _props$controlProps2;
91
91
  let isStartChatSuccessful = false;
92
92
  const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
@@ -124,7 +124,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
124
124
  try {
125
125
  var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
126
126
  // Set custom context params
127
- await setCustomContextParams(props);
127
+ await setCustomContextParams(state, props);
128
128
  const defaultOptionalParams = {
129
129
  sendDefaultInitContext: true,
130
130
  isProactiveChat: !!(params !== null && params !== void 0 && params.isProactiveChat),
@@ -287,14 +287,14 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
287
287
  const optionalParams = {
288
288
  liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
289
289
  };
290
- await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
290
+ await initStartChat(chatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
291
291
  return true;
292
292
  }
293
293
  return false;
294
294
  };
295
295
 
296
296
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
297
- const setCustomContextParams = async props => {
297
+ const setCustomContextParams = async (state, props) => {
298
298
  var _props$chatConfig, _props$chatConfig$Liv, _persistedState$domai8;
299
299
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
300
300
  const isAuthenticatedChat = props !== null && props !== void 0 && (_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;
@@ -302,6 +302,12 @@ const setCustomContextParams = async props => {
302
302
  if (isAuthenticatedChat) {
303
303
  return;
304
304
  }
305
+ if (state !== null && state !== void 0 && state.domainStates.customContext) {
306
+ optionalParams = Object.assign({}, optionalParams, {
307
+ customContext: JSON.parse(JSON.stringify(state === null || state === void 0 ? void 0 : state.domainStates.customContext))
308
+ });
309
+ return;
310
+ }
305
311
  if (isNullOrEmptyString(widgetInstanceId)) {
306
312
  widgetInstanceId = getWidgetCacheIdfromProps(props);
307
313
  }
@@ -314,13 +320,13 @@ const setCustomContextParams = async props => {
314
320
  Description: "Setting custom context for unauthenticated chat"
315
321
  });
316
322
  optionalParams = Object.assign({}, optionalParams, {
317
- customContext: customContextLocal
323
+ customContext: JSON.parse(JSON.stringify(customContextLocal))
318
324
  });
319
325
  } else {
320
326
  const customContextFromParent = await getInitContextParamsForPopout();
321
327
  if (!isUndefinedOrEmpty(customContextFromParent === null || customContextFromParent === void 0 ? void 0 : customContextFromParent.contextVariables)) {
322
328
  optionalParams = Object.assign({}, optionalParams, {
323
- customContext: customContextFromParent.contextVariables
329
+ customContext: JSON.parse(JSON.stringify(customContextFromParent.contextVariables))
324
330
  });
325
331
  }
326
332
  }
@@ -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,21 +123,21 @@ 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) {
130
130
  return;
131
131
  }
132
132
  }
133
- await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
133
+ await initStartChat(chatSDK, dispatch, setAdapter, state, props, optionalParams);
134
134
  return;
135
135
  }
136
136
  }
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) {
@@ -601,7 +601,7 @@ export const LiveChatWidgetStateful = props => {
601
601
  const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab, uwid.current);
602
602
  const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter);
603
603
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
604
- const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams, persistedState);
604
+ const initStartChatRelay = (optionalParams, persistedState) => initStartChat(chatSDK, dispatch, setAdapter, state, props, optionalParams, persistedState);
605
605
  const confirmationPaneProps = initConfirmationPropsComposer(props);
606
606
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
607
607
  const prepareEndChatRelay = () => prepareEndChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, uwid.current);
@@ -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 };
@@ -5,6 +5,6 @@ import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
5
5
  import StartChatOptionalParams from "@microsoft/omnichannel-chat-sdk/lib/core/StartChatOptionalParams";
6
6
  declare const prepareStartChat: (props: ILiveChatWidgetProps, chatSDK: any, state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any) => Promise<void>;
7
7
  declare const setPreChatAndInitiateChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, isProactiveChat?: boolean | undefined, proactiveChatEnablePrechatState?: boolean | undefined, state?: ILiveChatWidgetContext | undefined, props?: ILiveChatWidgetProps | undefined) => Promise<void>;
8
- declare const initStartChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, props?: ILiveChatWidgetProps | undefined, params?: StartChatOptionalParams | undefined, persistedState?: any) => Promise<void>;
8
+ declare const initStartChat: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, setAdapter: any, state: ILiveChatWidgetContext | undefined, props?: ILiveChatWidgetProps | undefined, params?: StartChatOptionalParams | undefined, persistedState?: any) => Promise<void>;
9
9
  declare const checkIfConversationStillValid: (chatSDK: any, dispatch: Dispatch<ILiveChatWidgetAction>, state: ILiveChatWidgetContext) => Promise<boolean>;
10
10
  export { prepareStartChat, initStartChat, setPreChatAndInitiateChat, checkIfConversationStillValid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.2.2-main.f0135ab",
3
+ "version": "1.2.3-main.000f886",
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.6",
79
79
  "abort-controller-es5": "^2.0.1",
80
80
  "dompurify": "^2.3.4",
81
81
  "markdown-it": "^12.3.2",