@microsoft/omnichannel-chat-widget 1.6.2-main.c7d45e8 → 1.6.3-main.18ee949

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.
@@ -36,7 +36,7 @@ class TelemetryHelper {
36
36
  static populateBasicProperties(level,
37
37
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
38
  telemetryData) {
39
- var _TelemetryManager$Int, _TelemetryManager$Int2, _TelemetryManager$Int3, _TelemetryManager$Int4, _TelemetryManager$Int5, _TelemetryManager$Int6, _TelemetryManager$Int7, _TelemetryManager$Int8;
39
+ var _TelemetryManager$Int, _TelemetryManager$Int2, _TelemetryManager$Int3, _TelemetryManager$Int4, _TelemetryManager$Int5, _TelemetryManager$Int6, _TelemetryManager$Int7, _TelemetryManager$Int8, _TelemetryManager$Int9, _TelemetryManager$Int10, _TelemetryManager$Int11;
40
40
  return {
41
41
  WidgetId: ((_TelemetryManager$Int = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.widgetId) ?? "",
42
42
  ChatId: ((_TelemetryManager$Int2 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int2 === void 0 ? void 0 : _TelemetryManager$Int2.chatId) ?? "",
@@ -46,7 +46,10 @@ class TelemetryHelper {
46
46
  OrganizationUrl: ((_TelemetryManager$Int6 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int6 === void 0 ? void 0 : _TelemetryManager$Int6.orgUrl) ?? "",
47
47
  LCWRuntimeId: ((_TelemetryManager$Int7 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int7 === void 0 ? void 0 : _TelemetryManager$Int7.lcwRuntimeId) ?? "",
48
48
  CurrentRequestId: ((_TelemetryManager$Int8 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int8 === void 0 ? void 0 : _TelemetryManager$Int8.currentRequestId) ?? "",
49
- LogLevel: level
49
+ LogLevel: level,
50
+ OCChatSDKVersion: ((_TelemetryManager$Int9 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int9 === void 0 ? void 0 : _TelemetryManager$Int9.OCChatSDKVersion) ?? "",
51
+ OCChatWidgetVersion: ((_TelemetryManager$Int10 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int10 === void 0 ? void 0 : _TelemetryManager$Int10.chatWidgetVersion) ?? "",
52
+ OCChatComponentsVersion: ((_TelemetryManager$Int11 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int11 === void 0 ? void 0 : _TelemetryManager$Int11.chatComponentVersion) ?? ""
50
53
  };
51
54
  }
52
55
  static populate(level, telemetryData, configure) {
@@ -80,22 +83,21 @@ class TelemetryHelper {
80
83
  static conformToConfigValidationContract(level, input) {
81
84
  const payload = input.payload;
82
85
  return TelemetryHelper.populate(level, payload, event => {
83
- var _TelemetryManager$Int9, _TelemetryManager$Int10, _TelemetryManager$Int11;
86
+ var _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14;
84
87
  event.Event = payload.Event;
85
88
  event.RequestId = payload.RequestId;
86
- event.LCWVersion = (_TelemetryManager$Int9 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int9 === void 0 ? void 0 : _TelemetryManager$Int9.environmentVersion;
89
+ event.LCWVersion = (_TelemetryManager$Int12 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : _TelemetryManager$Int12.environmentVersion;
87
90
  event.CloudType = payload.CloudType;
88
- event.Domain = (_TelemetryManager$Int10 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int10 === void 0 ? void 0 : _TelemetryManager$Int10.hostName;
91
+ event.Domain = (_TelemetryManager$Int13 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.hostName;
89
92
  event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
90
93
  event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
91
- event.Language = ((_TelemetryManager$Int11 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int11 === void 0 ? void 0 : _TelemetryManager$Int11.chatWidgetLocaleLCID) || "";
94
+ event.Language = ((_TelemetryManager$Int14 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : _TelemetryManager$Int14.chatWidgetLocaleLCID) || "";
92
95
  event.Description = payload.Data;
93
96
  });
94
97
  }
95
98
  static conformToLoadContract(level, input) {
96
99
  const payload = input.payload;
97
100
  return TelemetryHelper.populate(level, payload, event => {
98
- var _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14;
99
101
  event.Event = payload.Event;
100
102
  event.Description = payload.Description;
101
103
  event.ResourcePath = payload.ResourcePath;
@@ -104,9 +106,6 @@ class TelemetryHelper {
104
106
  event.ChatType = payload.ChatType;
105
107
  event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
106
108
  event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
107
- event.OCChatSDKVersion = ((_TelemetryManager$Int12 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : _TelemetryManager$Int12.OCChatSDKVersion) ?? "";
108
- event.OCChatWidgetVersion = ((_TelemetryManager$Int13 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.chatWidgetVersion) ?? "";
109
- event.OCChatComponentsVersion = ((_TelemetryManager$Int14 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : _TelemetryManager$Int14.chatComponentVersion) ?? "";
110
109
  });
111
110
  }
112
111
  static conformToIC3ClientContract(level, input) {
@@ -30,9 +30,9 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
30
30
  return false;
31
31
  }
32
32
  if (hasReconnectId(reconnectChatContext)) {
33
- var _props$reconnectChatP2, _props$reconnectChatP3;
34
- //if reconnect id is provided in props, don't show reconnect pane
35
- if ((_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.reconnectId && !(0, _utils.isNullOrEmptyString)((_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId)) {
33
+ var _props$reconnectChatP2, _props$reconnectChatP3, _props$controlProps;
34
+ //if reconnect id is provided in props, or hideReconnectChatPane is true, don't show reconnect pane
35
+ if ((_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.reconnectId && !(0, _utils.isNullOrEmptyString)((_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId) || (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideReconnectChatPane) {
36
36
  await setReconnectIdAndStartChat(isAuthenticatedChat, chatSDK, state, props, dispatch, setAdapter, reconnectChatContext.reconnectId ?? "", initStartChat);
37
37
  return false;
38
38
  }
@@ -57,6 +57,7 @@ var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDK
57
57
  var _defaultAdaptiveCardStyles = require("../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles");
58
58
  var _StartChatErrorPaneStateful = _interopRequireDefault(require("../../startchaterrorpanestateful/StartChatErrorPaneStateful"));
59
59
  var _StartChatFailureType = require("../../../contexts/common/StartChatFailureType");
60
+ var _createReducer = require("../../../contexts/createReducer");
60
61
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61
62
  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); }
62
63
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -125,8 +126,12 @@ const LiveChatWidgetStateful = props => {
125
126
  const isReconnectTriggered = async () => {
126
127
  if ((0, _reconnectChatHelper.isReconnectEnabled)(props.chatConfig) === true && !(0, _reconnectChatHelper.isPersistentEnabled)(props.chatConfig)) {
127
128
  const noValidReconnectId = await (0, _reconnectChatHelper.handleChatReconnect)(chatSDK, props, dispatch, setAdapter, _startChat.initStartChat, state);
129
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
130
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
131
+ payload: null
132
+ });
128
133
  // If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
129
- if (!noValidReconnectId && (state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat)) {
134
+ if (!noValidReconnectId && (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Active || inMemoryState.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat)) {
130
135
  return true;
131
136
  }
132
137
  }
@@ -340,7 +345,7 @@ const LiveChatWidgetStateful = props => {
340
345
 
341
346
  // Start chat from SDK Event
342
347
  _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(msg => {
343
- var _msg$payload4, _msg$payload5, _msg$payload6;
348
+ var _msg$payload4, _msg$payload5, _msg$payload6, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
344
349
  // If the startChat event is not initiated by the same tab. Ignore the call
345
350
  if (!(0, _utils.isNullOrUndefined)(msg === null || msg === void 0 ? void 0 : (_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
346
351
  return;
@@ -368,12 +373,13 @@ const LiveChatWidgetStateful = props => {
368
373
  Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
369
374
  Description: "Start chat event received."
370
375
  });
376
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
377
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
378
+ payload: null
379
+ });
371
380
 
372
- // DataStoreManager.clientDataStore?.swtichToSessionStorage(true);
373
- const persistedState = (0, _utils.getStateFromCache)((0, _utils.getWidgetCacheIdfromProps)(props));
374
-
375
- // Chat not found in cache - scenario: explicitly clearing cache and calling startChat SDK method
376
- if (persistedState === undefined) {
381
+ // Only initiate new chat if widget runtime state is one of the followings
382
+ if (((_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) === _ConversationState.ConversationState.Closed || ((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === _ConversationState.ConversationState.InActive || ((_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.conversationState) === _ConversationState.ConversationState.Postchat) {
377
383
  _omnichannelChatComponents.BroadcastService.postMessage({
378
384
  eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
379
385
  });
@@ -381,33 +387,21 @@ const LiveChatWidgetStateful = props => {
381
387
  return;
382
388
  }
383
389
 
384
- // Chat exist in cache
385
- if (persistedState) {
386
- var _persistedState$appSt, _persistedState$appSt2, _persistedState$appSt3, _persistedState$appSt4;
387
- // Only initiate new chat if widget state in cache in one of the followings
388
- if (((_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === _ConversationState.ConversationState.Closed || ((_persistedState$appSt2 = persistedState.appStates) === null || _persistedState$appSt2 === void 0 ? void 0 : _persistedState$appSt2.conversationState) === _ConversationState.ConversationState.InActive || ((_persistedState$appSt3 = persistedState.appStates) === null || _persistedState$appSt3 === void 0 ? void 0 : _persistedState$appSt3.conversationState) === _ConversationState.ConversationState.Postchat) {
389
- _omnichannelChatComponents.BroadcastService.postMessage({
390
- eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
391
- });
392
- (0, _startChat.prepareStartChat)(props, chatSDK, stateWithUpdatedContext, dispatch, setAdapter);
393
- return;
394
- }
395
-
396
- // If minimized, maximize the chat
397
- if ((persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt4 = persistedState.appStates) === null || _persistedState$appSt4 === void 0 ? void 0 : _persistedState$appSt4.isMinimized) === true) {
398
- var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
399
- dispatch({
400
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
401
- payload: false
402
- });
403
- _omnichannelChatComponents.BroadcastService.postMessage({
404
- eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
405
- payload: {
406
- height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
407
- width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
408
- }
409
- });
410
- }
390
+ // If minimized, maximize the chat
391
+ if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.isMinimized) === true) {
392
+ var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
393
+ dispatch({
394
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
395
+ payload: false
396
+ });
397
+ _omnichannelChatComponents.BroadcastService.postMessage({
398
+ eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
399
+ payload: {
400
+ height: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.widgetSize) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.height,
401
+ width: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.widgetSize) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.width
402
+ }
403
+ });
404
+ return;
411
405
  }
412
406
  });
413
407
 
@@ -52,4 +52,5 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
52
52
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 42] = "SET_SURVEY_MODE";
53
53
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 43] = "SET_CONFIRMATION_STATE";
54
54
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 44] = "SET_POST_CHAT_PARTICIPANT_TYPE";
55
+ LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 45] = "GET_IN_MEMORY_STATE";
55
56
  })(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));