@microsoft/omnichannel-chat-widget 0.1.0-main.8b6c0d8 → 0.1.0-main.cf54410

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/lib/cjs/common/Constants.js +2 -0
  2. package/lib/cjs/common/contextDataStore/DataStoreManager.js +14 -0
  3. package/lib/cjs/common/interfaces/IContextDataStore.js +1 -0
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +1 -0
  5. package/lib/cjs/common/telemetry/TelemetryHelper.js +9 -4
  6. package/lib/cjs/common/telemetry/TelemetryManager.js +12 -4
  7. package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +3 -3
  8. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +14 -1
  9. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +3 -0
  10. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +8 -1
  11. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +13 -26
  12. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +27 -26
  13. package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +14 -0
  14. package/lib/cjs/components/livechatwidget/common/endChat.js +8 -0
  15. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -9
  16. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +18 -3
  17. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +23 -22
  18. package/lib/cjs/components/livechatwidget/common/startChat.js +64 -18
  19. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -13
  20. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +25 -8
  21. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +4 -0
  22. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +6 -3
  23. package/lib/cjs/contexts/createReducer.js +27 -0
  24. package/lib/esm/common/Constants.js +2 -0
  25. package/lib/esm/common/contextDataStore/DataStoreManager.js +5 -0
  26. package/lib/esm/common/interfaces/IContextDataStore.js +1 -0
  27. package/lib/esm/common/telemetry/TelemetryConstants.js +1 -0
  28. package/lib/esm/common/telemetry/TelemetryHelper.js +9 -4
  29. package/lib/esm/common/telemetry/TelemetryManager.js +8 -4
  30. package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +3 -3
  31. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +14 -1
  32. package/lib/esm/common/telemetry/loggers/consoleLogger.js +3 -0
  33. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +9 -1
  34. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +13 -26
  35. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +29 -28
  36. package/lib/esm/components/livechatwidget/common/disposeTelemetryLoggers.js +4 -0
  37. package/lib/esm/components/livechatwidget/common/endChat.js +8 -0
  38. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +8 -9
  39. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +18 -2
  40. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +22 -22
  41. package/lib/esm/components/livechatwidget/common/startChat.js +62 -17
  42. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +23 -12
  43. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +26 -10
  44. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +4 -0
  45. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +6 -3
  46. package/lib/esm/contexts/createReducer.js +27 -0
  47. package/lib/types/common/Constants.d.ts +1 -0
  48. package/lib/types/common/contextDataStore/DataStoreManager.d.ts +4 -0
  49. package/lib/types/common/interfaces/IContextDataStore.d.ts +14 -0
  50. package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -1
  51. package/lib/types/common/telemetry/TelemetryManager.d.ts +1 -0
  52. package/lib/types/common/telemetry/definitions/Contracts.d.ts +3 -0
  53. package/lib/types/common/telemetry/definitions/Payload.d.ts +3 -0
  54. package/lib/types/common/telemetry/interfaces/IChatSDKLogger.d.ts +1 -0
  55. package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +2 -0
  56. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +12 -0
  57. package/lib/types/components/livechatwidget/common/disposeTelemetryLoggers.d.ts +1 -0
  58. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
  59. package/lib/types/components/livechatwidget/common/startChat.d.ts +1 -1
  60. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
  61. package/lib/types/components/prechatsurveypanestateful/interfaces/IPreChatSurveyPaneStatefulParams.d.ts +1 -1
  62. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +3 -0
  63. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +5 -1
  64. package/package.json +3 -1
@@ -31,9 +31,15 @@ var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
31
31
 
32
32
  var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
33
33
 
34
+ var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
35
+
34
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
37
  const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
36
- // Getting PreChat Survey Context
38
+ if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
39
+ return;
40
+ } // Getting PreChat Survey Context
41
+
42
+
37
43
  const parseToJson = false;
38
44
  const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
39
45
  const showPrechat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
@@ -70,17 +76,18 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
70
76
 
71
77
  exports.prepareStartChat = prepareStartChat;
72
78
 
73
- const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
79
+ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
74
80
  try {
75
81
  var _TelemetryTimers$Widg;
76
82
 
77
83
  try {
84
+ _TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
85
+
78
86
  _TelemetryHelper.TelemetryHelper.logConfigDataEvent(_TelemetryConstants.LogLevel.INFO, {
79
87
  Event: _TelemetryConstants.TelemetryEvent.StartChatSDKCall
80
88
  });
81
89
 
82
90
  await chatSDK.startChat(params);
83
- _TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
84
91
  } catch (error) {
85
92
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.ERROR, {
86
93
  Event: _TelemetryConstants.TelemetryEvent.StartChatMethodException,
@@ -91,24 +98,39 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
91
98
  }
92
99
 
93
100
  const newAdapter = await (0, _createAdapter.createAdapter)(chatSDK);
94
- setAdapter(newAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
+ setAdapter(newAdapter);
95
102
 
96
- if (chatSDK !== null && chatSDK !== void 0 && chatSDK.getVoiceVideoCalling) {
103
+ if (!persistedState) {
97
104
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- const chatToken = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatToken());
105
+ if (chatSDK !== null && chatSDK !== void 0 && chatSDK.getVoiceVideoCalling) {
106
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
107
+ const chatToken = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatToken());
108
+ dispatch({
109
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
110
+ payload: chatToken
111
+ });
112
+ } // eslint-disable-next-line @typescript-eslint/no-explicit-any
113
+
114
+
115
+ const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
99
116
  dispatch({
100
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
101
- payload: chatToken
117
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
118
+ payload: liveChatContext
102
119
  });
103
- }
104
-
105
- await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, false);
106
- await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch); // Set app state to Active
120
+ await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
121
+ await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch); // Set app state to Active
107
122
 
108
- dispatch({
109
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
110
- payload: _ConversationState.ConversationState.Active
111
- });
123
+ dispatch({
124
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
125
+ payload: _ConversationState.ConversationState.Active
126
+ });
127
+ } else {
128
+ dispatch({
129
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
130
+ payload: persistedState
131
+ });
132
+ await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
133
+ }
112
134
 
113
135
  _TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
114
136
  Event: _TelemetryConstants.TelemetryEvent.WidgetLoadComplete,
@@ -137,6 +159,30 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params) => {
137
159
  });
138
160
  }
139
161
  }
140
- };
162
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
163
+
164
+
165
+ exports.initStartChat = initStartChat;
166
+
167
+ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
168
+ var _DataStoreManager$cli, _persistedState$domai;
169
+
170
+ const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(_Constants.Constants.widgetStateDataKey, "localStorage");
171
+ const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
141
172
 
142
- exports.initStartChat = initStartChat;
173
+ if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext) {
174
+ var _persistedState$domai2;
175
+
176
+ dispatch({
177
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
178
+ payload: _ConversationState.ConversationState.Loading
179
+ });
180
+ const optionalParams = {
181
+ liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai2 = persistedState.domainStates) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.liveChatContext
182
+ };
183
+ await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
184
+ return true;
185
+ } else {
186
+ return false;
187
+ }
188
+ };
@@ -81,6 +81,12 @@ var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useCha
81
81
 
82
82
  var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
83
83
 
84
+ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
85
+
86
+ var _disposeTelemetryLoggers = require("../common/disposeTelemetryLoggers");
87
+
88
+ var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
89
+
84
90
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
85
91
 
86
92
  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); }
@@ -117,6 +123,7 @@ const LiveChatWidgetStateful = props => {
117
123
 
118
124
  (0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
119
125
  (0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)();
126
+ _DataStoreManager.DataStoreManager.clientDataStore = props.contextDataStore ?? undefined;
120
127
  dispatch({
121
128
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
122
129
  payload: widgetElementId
@@ -194,11 +201,17 @@ const LiveChatWidgetStateful = props => {
194
201
  (0, _startProactiveChat.startProactiveChat)(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.bodyTitle, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.showPrechat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
195
202
  }
196
203
  });
204
+
205
+ window.addEventListener("beforeunload", event => {
206
+ (0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
207
+ });
208
+
209
+ if (state.appStates.conversationEndedByAgent) {
210
+ (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
211
+ }
197
212
  }, []);
198
213
  (0, _react2.useEffect)(() => {
199
- if (state.appStates.conversationState !== _ConversationState.ConversationState.Closed) {
200
- canStartProactiveChat.current = false;
201
- }
214
+ canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed;
202
215
 
203
216
  if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
204
217
  chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
@@ -209,7 +222,7 @@ const LiveChatWidgetStateful = props => {
209
222
  } // Track the message count
210
223
 
211
224
 
212
- if (state.appStates.conversationState == _ConversationState.ConversationState.Active) {
225
+ if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
213
226
  chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
214
227
  currentMessageCountRef.current++;
215
228
  dispatch({
@@ -255,25 +268,26 @@ const LiveChatWidgetStateful = props => {
255
268
  }, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]);
256
269
  const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, state, dispatch, setWebChatStyles);
257
270
 
258
- const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
271
+ const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
259
272
 
260
273
  const endChatRelay = () => (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
261
274
 
262
275
  const prepareStartChatRelay = () => (0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
263
276
 
264
277
 
265
- const initStartChatRelay = optionalParams => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams);
278
+ const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
266
279
 
267
280
  const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props); // publish chat widget state
268
281
 
269
- const chatWidgetStateChangeEvent = {
270
- eventName: "ChatWidgetStateChanged",
271
- payload: { ...state
272
- }
273
- };
274
-
275
- _omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
282
+ (0, _react2.useEffect)(() => {
283
+ const chatWidgetStateChangeEvent = {
284
+ eventName: _TelemetryConstants.TelemetryEvent.ChatWidgetStateChanged,
285
+ payload: { ...state
286
+ }
287
+ };
276
288
 
289
+ _omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
290
+ }, [state]);
277
291
  return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
278
292
  styleOptions: webChatStyles,
279
293
  directLine: ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine
@@ -27,6 +27,8 @@ var _defaultPreChatSurveyLocalizedTexts = require("./common/defaultProps/default
27
27
 
28
28
  var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
29
29
 
30
+ var _DataStoreManager = require("../../common/contextDataStore/DataStoreManager");
31
+
30
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
33
 
32
34
  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); }
@@ -91,14 +93,29 @@ const PreChatSurveyPaneStateful = props => {
91
93
  });
92
94
 
93
95
  try {
94
- const prechatResponseValues = (0, _utils.extractPreChatSurveyResponseValues)(state.domainStates.preChatSurveyResponse, values);
95
- const optionalParams = {
96
- initContext: {
97
- preChatResponse: prechatResponseValues
98
- }
99
- };
100
- setPreChatResponseEmail(values);
101
- await initStartChat(optionalParams);
96
+ var _DataStoreManager$cli, _persistedState$domai;
97
+
98
+ const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(_Constants.Constants.widgetStateDataKey, "localStorage");
99
+ const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
100
+ let optionalParams = {};
101
+
102
+ if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai = persistedState.domainStates) !== null && _persistedState$domai !== void 0 && _persistedState$domai.liveChatContext) {
103
+ var _persistedState$domai2;
104
+
105
+ optionalParams = {
106
+ liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai2 = persistedState.domainStates) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.liveChatContext
107
+ };
108
+ await initStartChat(optionalParams, persistedState);
109
+ } else {
110
+ const prechatResponseValues = (0, _utils.extractPreChatSurveyResponseValues)(state.domainStates.preChatSurveyResponse, values);
111
+ optionalParams = {
112
+ initContext: {
113
+ preChatResponse: prechatResponseValues
114
+ }
115
+ };
116
+ setPreChatResponseEmail(values);
117
+ await initStartChat(optionalParams);
118
+ }
102
119
  } catch (ex) {
103
120
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
104
121
  Event: _TelemetryConstants.TelemetryEvent.PreChatSurveyStartChatMethodFailed,
@@ -35,4 +35,8 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
35
35
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_TELEMETRY_DATA"] = 24] = "SET_TELEMETRY_DATA";
36
36
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_RECONNECT_ID"] = 25] = "SET_RECONNECT_ID";
37
37
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_UNREAD_MESSAGE_COUNT"] = 26] = "SET_UNREAD_MESSAGE_COUNT";
38
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_FOCUS_CHAT_BUTTON"] = 27] = "SET_FOCUS_CHAT_BUTTON";
39
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT"] = 28] = "SET_CONVERSATION_ENDED_BY_AGENT";
40
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 29] = "SET_WIDGET_STATE";
41
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
38
42
  })(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
@@ -22,7 +22,8 @@ const getLiveChatWidgetContextInitialState = props => {
22
22
  chatToken: undefined,
23
23
  postChatContext: undefined,
24
24
  telemetryInternalData: {},
25
- globalDir: "ltr"
25
+ globalDir: "ltr",
26
+ liveChatContext: undefined
26
27
  },
27
28
  appStates: {
28
29
  conversationState: _ConversationState.ConversationState.Closed,
@@ -41,7 +42,8 @@ const getLiveChatWidgetContextInitialState = props => {
41
42
  proactiveChatInNewWindow: false
42
43
  },
43
44
  e2vvEnabled: false,
44
- unreadMessageCount: 0
45
+ unreadMessageCount: 0,
46
+ conversationEndedByAgent: false
45
47
  },
46
48
  uiStates: {
47
49
  showConfirmationPane: false,
@@ -50,7 +52,8 @@ const getLiveChatWidgetContextInitialState = props => {
50
52
  isIncomingCall: true,
51
53
  disableVideoCall: true,
52
54
  disableRemoteVideo: true,
53
- disableSelfVideo: true
55
+ disableSelfVideo: true,
56
+ focusChatButton: false
54
57
  }
55
58
  };
56
59
  return props.liveChatContextFromCache ?? LiveChatWidgetContextInitialState;
@@ -114,6 +114,13 @@ const createReducer = () => {
114
114
  }
115
115
  };
116
116
 
117
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_FOCUS_CHAT_BUTTON:
118
+ return { ...state,
119
+ uiStates: { ...state.uiStates,
120
+ focusChatButton: action.payload
121
+ }
122
+ };
123
+
117
124
  case _LiveChatWidgetActionType.LiveChatWidgetActionType.DISABLE_VIDEO_CALL:
118
125
  return { ...state,
119
126
  uiStates: { ...state.uiStates,
@@ -138,6 +145,7 @@ const createReducer = () => {
138
145
  case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN:
139
146
  return { ...state,
140
147
  domainStates: { ...state.domainStates,
148
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
141
149
  chatToken: action.payload
142
150
  }
143
151
  };
@@ -210,6 +218,25 @@ const createReducer = () => {
210
218
  }
211
219
  };
212
220
 
221
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT:
222
+ return { ...state,
223
+ domainStates: { ...state.domainStates,
224
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
225
+ liveChatContext: action.payload
226
+ }
227
+ };
228
+
229
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE:
230
+ return { ...action.payload
231
+ };
232
+
233
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT:
234
+ return { ...state,
235
+ appStates: { ...state.appStates,
236
+ conversationEndedByAgent: action.payload
237
+ }
238
+ };
239
+
213
240
  default:
214
241
  return state;
215
242
  }
@@ -32,6 +32,8 @@ _defineProperty(Constants, "false", "false");
32
32
 
33
33
  _defineProperty(Constants, "maximumUnreadMessageCount", 99);
34
34
 
35
+ _defineProperty(Constants, "widgetStateDataKey", "LcwChatWidgetState");
36
+
35
37
  _defineProperty(Constants, "channelIdKey", "ChannelId-");
36
38
 
37
39
  _defineProperty(Constants, "ChannelId", "lcw");
@@ -0,0 +1,5 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ export class DataStoreManager {}
4
+
5
+ _defineProperty(DataStoreManager, "clientDataStore", void 0);
@@ -0,0 +1 @@
1
+ export {};
@@ -114,6 +114,7 @@ export let TelemetryEvent;
114
114
  TelemetryEvent["ReconnectChatContinueConversation"] = "ReconnectChatContinueConversation";
115
115
  TelemetryEvent["ReconnectChatStartNewConversation"] = "ReconnectChatStartNewConversation";
116
116
  TelemetryEvent["ReconnectChatMinimize"] = "ReconnectChatMinimize";
117
+ TelemetryEvent["ChatWidgetStateChanged"] = "ChatWidgetStateChanged";
117
118
  })(TelemetryEvent || (TelemetryEvent = {}));
118
119
 
119
120
  export class TelemetryConstants {
@@ -98,6 +98,8 @@ export class TelemetryHelper {
98
98
  static conformToLoadContract(level, input) {
99
99
  const payload = input.payload;
100
100
  return TelemetryHelper.populate(level, payload, event => {
101
+ var _TelemetryManager$Int11, _TelemetryManager$Int12, _TelemetryManager$Int13;
102
+
101
103
  event.Event = payload.Event;
102
104
  event.ResourcePath = payload.ResourcePath;
103
105
  event.WidgetState = payload.WidgetState;
@@ -105,16 +107,19 @@ export class TelemetryHelper {
105
107
  event.ChatType = payload.ChatType;
106
108
  event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
107
109
  event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
110
+ event.OCChatSDKVersion = ((_TelemetryManager$Int11 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int11 === void 0 ? void 0 : _TelemetryManager$Int11.OCChatSDKVersion) ?? "";
111
+ event.OCChatWidgetVersion = ((_TelemetryManager$Int12 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : _TelemetryManager$Int12.chatWidgetVersion) ?? "";
112
+ event.OCChatComponentsVersion = ((_TelemetryManager$Int13 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.chatComponentVersion) ?? "";
108
113
  });
109
114
  }
110
115
 
111
116
  static conformToIC3ClientContract(level, input) {
112
117
  const payload = input.payload;
113
118
  return TelemetryHelper.populate(level, payload, event => {
114
- var _TelemetryManager$Int11;
119
+ var _TelemetryManager$Int14;
115
120
 
116
121
  event.Event = payload.Event;
117
- event.IC3ClientVersion = (_TelemetryManager$Int11 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int11 === void 0 ? void 0 : _TelemetryManager$Int11.IC3ClientVersion;
122
+ event.IC3ClientVersion = (_TelemetryManager$Int14 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : _TelemetryManager$Int14.IC3ClientVersion;
118
123
  event.SubscriptionId = payload.SubscriptionId;
119
124
  event.EndpointUrl = payload.EndpointUrl;
120
125
  event.EndpointId = payload.EndpointId;
@@ -233,14 +238,14 @@ _defineProperty(TelemetryHelper, "logActionEvent", (logLevel, payload) => {
233
238
  });
234
239
 
235
240
  _defineProperty(TelemetryHelper, "logSDKEvent", (logLevel, payload) => {
236
- var _TelemetryManager$Int12;
241
+ var _TelemetryManager$Int15;
237
242
 
238
243
  const telemetryEvent = {
239
244
  eventName: (payload === null || payload === void 0 ? void 0 : payload.Event) ?? "",
240
245
  logLevel: logLevel,
241
246
  payload: { ...payload,
242
247
  TransactionId: newGuid(),
243
- RequestId: (_TelemetryManager$Int12 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : _TelemetryManager$Int12.currentRequestId
248
+ RequestId: (_TelemetryManager$Int15 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int15 === void 0 ? void 0 : _TelemetryManager$Int15.currentRequestId
244
249
  }
245
250
  };
246
251
  BroadcastService.postMessage(telemetryEvent);
@@ -1,6 +1,6 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
2
 
3
- import { LogLevel, ScenarioType, TelemetryConstants } from "./TelemetryConstants";
3
+ import { LogLevel, ScenarioType, TelemetryConstants, TelemetryEvent } from "./TelemetryConstants";
4
4
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
5
5
  import { ariaTelemetryLogger } from "./loggers/ariaTelemetryLogger";
6
6
  import { consoleLogger } from "./loggers/consoleLogger";
@@ -16,15 +16,19 @@ export class TelemetryManager {}
16
16
 
17
17
  _defineProperty(TelemetryManager, "InternalTelemetryData", void 0);
18
18
 
19
+ const loggers = [];
20
+ export const disposeLoggers = () => {
21
+ loggers.map(logger => {
22
+ logger.dispose();
23
+ });
24
+ };
19
25
  export const RegisterLoggers = () => {
20
- const loggers = [];
21
-
22
26
  const registerLoggers = () => {
23
27
  var _TelemetryManager$Int, _TelemetryManager$Int2, _TelemetryManager$Int3, _TelemetryManager$Int4, _TelemetryManager$Int5, _TelemetryManager$Int6, _TelemetryManager$Int7, _TelemetryManager$Int8;
24
28
 
25
29
  if (!((_TelemetryManager$Int = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int !== void 0 && (_TelemetryManager$Int2 = _TelemetryManager$Int.telemetryConfig) !== null && _TelemetryManager$Int2 !== void 0 && _TelemetryManager$Int2.disableConsoleLog) || !((_TelemetryManager$Int3 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int3 !== void 0 && (_TelemetryManager$Int4 = _TelemetryManager$Int3.telemetryConfig) !== null && _TelemetryManager$Int4 !== void 0 && _TelemetryManager$Int4.telemetryDisabled)) {
26
30
  BroadcastService.getAnyMessage().subscribe(event => {
27
- if (event.payload) {
31
+ if (event.payload && event.eventName !== TelemetryEvent.ChatWidgetStateChanged) {
28
32
  logTelemetry(event);
29
33
  }
30
34
  });
@@ -1,6 +1,6 @@
1
1
  export const defaultAriaConfig = {
2
- collectorUriForTelemetry: "https://browser.pipe.aria.microsoft.com/Collector/3.0/",
3
- ariaTelemetryKey: "1574efd98545488983328fac0c9bcb59-45c2ff50-ebcc-473d-949d-e3134ef2189e-6906",
4
- ariaTelemetryApplicationName: "D365_Omnichannel_Client_Sandbox",
2
+ collectorUriForTelemetry: "",
3
+ ariaTelemetryKey: "c7655518acf1403f93ff6b9f77942f0a-d01a02fd-6b50-4de3-a566-62eda11f93bc-7083",
4
+ ariaTelemetryApplicationName: "",
5
5
  disableCookieUsage: true
6
6
  };
@@ -17,7 +17,15 @@ export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, colle
17
17
  configuration.collectorUri = collectiorUriForTelemetry;
18
18
  }
19
19
 
20
- _logger = AWTLogManager.initialize(ariaTelemetryKey, configuration);
20
+ try {
21
+ _logger = AWTLogManager.initialize(ariaTelemetryKey, configuration);
22
+
23
+ if (_logger === undefined) {
24
+ _logger = AWTLogManager.getLogger(ariaTelemetryKey);
25
+ }
26
+ } catch (error) {
27
+ console.log(error);
28
+ }
21
29
  }
22
30
 
23
31
  return _logger;
@@ -37,6 +45,11 @@ export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, colle
37
45
 
38
46
  eventProperties.setPropertyWithPii(ariaTelemetryApplicationName, Constants.LiveChatWidget, AWTPiiKind.GenericData);
39
47
  logger() ? logger().logEvent(eventProperties) : console.log("Unable to initialize aria logger");
48
+ },
49
+ dispose: () => {
50
+ AWTLogManager.flush(function () {
51
+ console.log("Aria logger disposed");
52
+ });
40
53
  }
41
54
  };
42
55
  return ariaLogger;
@@ -30,6 +30,9 @@ export const consoleLogger = () => {
30
30
  } catch (ex) {
31
31
  console.error("An unexpected error occurred in the Telemetry client: " + ex);
32
32
  }
33
+ },
34
+ dispose: () => {
35
+ console.log("disposing loggers");
33
36
  }
34
37
  };
35
38
  return consoleLogger;
@@ -73,7 +73,15 @@ export const ChatButtonStateful = props => {
73
73
  Event: TelemetryEvent.LCWChatButtonShow,
74
74
  ElapsedTimeInMilliseconds: TelemetryTimers.LcwLoadToChatButtonTimer.milliSecondsElapsed
75
75
  });
76
- setFocusOnElement(document.getElementById((controlProps === null || controlProps === void 0 ? void 0 : controlProps.id) ?? "oc-lcw-chat-button"));
76
+
77
+ if (state.uiStates.focusChatButton) {
78
+ setFocusOnElement(document.getElementById((controlProps === null || controlProps === void 0 ? void 0 : controlProps.id) ?? "oc-lcw-chat-button"));
79
+ } else {
80
+ dispatch({
81
+ type: LiveChatWidgetActionType.SET_FOCUS_CHAT_BUTTON,
82
+ payload: true
83
+ });
84
+ }
77
85
  }, []);
78
86
  return /*#__PURE__*/React.createElement(ChatButton, {
79
87
  componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
@@ -1,9 +1,7 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
2
  import React, { useEffect } from "react";
3
3
  import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
4
- import { ConfirmationPane } from "@microsoft/omnichannel-chat-components";
5
- import { Constants } from "../../common/Constants";
6
- import { ConversationState } from "../../contexts/common/ConversationState";
4
+ import { BroadcastService, ConfirmationPane } from "@microsoft/omnichannel-chat-components";
7
5
  import { DimLayer } from "../dimlayer/DimLayer";
8
6
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
9
7
  import { NotificationHandler } from "../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
@@ -12,20 +10,21 @@ import { PostChatSurveyMode } from "../postchatsurveypanestateful/enums/PostChat
12
10
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
13
11
  import useChatAdapterStore from "../../hooks/useChatAdapterStore";
14
12
  import useChatContextStore from "../../hooks/useChatContextStore";
15
- import useChatSDKStore from "../../hooks/useChatSDKStore"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ import useChatSDKStore from "../../hooks/useChatSDKStore";
14
+ import { Constants } from "../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
15
 
17
16
  export const ConfirmationPaneStateful = props => {
18
17
  var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
19
18
 
20
19
  const initialTabIndexMap = new Map();
21
- let elements = [];
20
+ let elements = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+
22
+ const chatSDK = useChatSDKStore();
22
23
  const [state, dispatch] = useChatContextStore();
23
24
  const {
24
- setPostChatContext,
25
25
  endChat
26
26
  } = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
-
28
- const chatSDK = useChatSDKStore(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
28
 
30
29
  const [adapter] = useChatAdapterStore();
31
30
  const isPostChatEnabled = (_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.msdyn_postconversationsurveyenable;
@@ -44,26 +43,14 @@ export const ConfirmationPaneStateful = props => {
44
43
  });
45
44
 
46
45
  try {
47
- //ToDo: End Chat before PostChat Context and conversation Details is set once the getPostChatContext request ID fetch issue is fixed
48
- const conversationDetails = await chatSDK.getConversationDetails(); // ToDo: Replace with CanRenderPostChat once available in conversationDetails API response
46
+ // check agent has joined conversation
47
+ const conversationDetails = await chatSDK.getConversationDetails();
49
48
 
50
49
  if (isPostChatEnabled === "true" && postChatSurveyMode === PostChatSurveyMode.Embed && conversationDetails.canRenderPostChat === Constants.truePascal) {
51
- dispatch({
52
- type: LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT,
53
- payload: true
54
- });
55
- dispatch({
56
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
57
- payload: ConversationState.Loading
58
- });
59
- await setPostChatContext();
60
-
61
- if (state.domainStates.postChatContext) {
62
- dispatch({
63
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
64
- payload: ConversationState.Postchat
65
- });
66
- }
50
+ const loadPostChatEvent = {
51
+ eventName: "LoadPostChatSurvey"
52
+ };
53
+ BroadcastService.postMessage(loadPostChatEvent);
67
54
  } else {
68
55
  setTabIndices(elements, initialTabIndexMap, true);
69
56