@microsoft/omnichannel-chat-widget 0.1.0-main.0ec5410 → 0.1.0-main.106d830

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 (60) hide show
  1. package/README.md +3 -11
  2. package/lib/cjs/common/Constants.js +34 -4
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +13 -1
  4. package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +10 -5
  6. package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  7. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +21 -2
  8. package/lib/cjs/common/utils.js +15 -2
  9. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -39
  10. package/lib/cjs/components/footerstateful/FooterStateful.js +1 -2
  11. package/lib/cjs/components/headerstateful/HeaderStateful.js +1 -7
  12. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +5 -2
  13. package/lib/cjs/components/livechatwidget/common/endChat.js +37 -1
  14. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +1 -1
  15. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +3 -0
  16. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +105 -20
  17. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +7 -6
  18. package/lib/cjs/components/livechatwidget/common/startChat.js +38 -29
  19. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +55 -11
  20. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
  21. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  22. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +44 -0
  23. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +15 -16
  24. package/lib/cjs/contexts/createReducer.js +0 -10
  25. package/lib/esm/common/Constants.js +30 -3
  26. package/lib/esm/common/telemetry/TelemetryConstants.js +13 -1
  27. package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
  28. package/lib/esm/common/telemetry/TelemetryManager.js +9 -5
  29. package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  30. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +18 -1
  31. package/lib/esm/common/utils.js +11 -1
  32. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -37
  33. package/lib/esm/components/footerstateful/FooterStateful.js +1 -2
  34. package/lib/esm/components/headerstateful/HeaderStateful.js +1 -7
  35. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +5 -3
  36. package/lib/esm/components/livechatwidget/common/endChat.js +37 -3
  37. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +1 -1
  38. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +2 -0
  39. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +94 -20
  40. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +4 -3
  41. package/lib/esm/components/livechatwidget/common/startChat.js +39 -30
  42. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +53 -13
  43. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
  44. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -6
  45. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +31 -0
  46. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +15 -16
  47. package/lib/esm/contexts/createReducer.js +0 -9
  48. package/lib/types/common/Constants.d.ts +17 -1
  49. package/lib/types/common/telemetry/TelemetryConstants.d.ts +9 -2
  50. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
  51. package/lib/types/common/utils.d.ts +1 -0
  52. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +4 -4
  53. package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
  54. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  55. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -2
  56. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  57. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -0
  58. package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
  59. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +15 -16
  60. package/package.json +3 -1
@@ -12,6 +12,8 @@ _defineProperty(Constants, "historyMessageTag", "history");
12
12
 
13
13
  _defineProperty(Constants, "agentEndConversationMessageTag", "agentendconversation");
14
14
 
15
+ _defineProperty(Constants, "supervisorForceCloseMessageTag", "supervisorforceclosedconversation");
16
+
15
17
  _defineProperty(Constants, "receivedMessageClassName", "ms_lcw_webchat_received_message");
16
18
 
17
19
  _defineProperty(Constants, "sentMessageClassName", "ms_lcw_webchat_sent_message");
@@ -120,8 +122,6 @@ _defineProperty(Constants, "InputSubmit", "InputSubmit");
120
122
 
121
123
  _defineProperty(Constants, "ReconnectIdAttributeName", "oc.reconnectid");
122
124
 
123
- _defineProperty(Constants, "redirectPageRequest", "redirectPageRequest");
124
-
125
125
  _defineProperty(Constants, "LiveChatWidget", "LiveChatWidgetNew");
126
126
 
127
127
  _defineProperty(Constants, "GuidPattern", "xx-x-4m-ym-xxx");
@@ -255,6 +255,15 @@ export let ChatSDKError;
255
255
  ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
256
256
  })(ChatSDKError || (ChatSDKError = {}));
257
257
 
258
+ export let EnvironmentVersion;
259
+
260
+ (function (EnvironmentVersion) {
261
+ EnvironmentVersion["prod"] = "prod";
262
+ EnvironmentVersion["dogfood"] = "df";
263
+ EnvironmentVersion["int"] = "int";
264
+ EnvironmentVersion["test"] = "test";
265
+ })(EnvironmentVersion || (EnvironmentVersion = {}));
266
+
258
267
  export class TranscriptConstants {}
259
268
 
260
269
  _defineProperty(TranscriptConstants, "ChatTranscriptsBodyColor", "#F5F5F5");
@@ -275,4 +284,22 @@ _defineProperty(TranscriptConstants, "InternalMode", "internal");
275
284
 
276
285
  _defineProperty(TranscriptConstants, "AgentDialogColor", "#2266E3");
277
286
 
278
- _defineProperty(TranscriptConstants, "AgentFontColor", "white");
287
+ _defineProperty(TranscriptConstants, "AgentFontColor", "white");
288
+
289
+ export class AriaTelemetryConstants {}
290
+
291
+ _defineProperty(AriaTelemetryConstants, "GERMANY_ENDPOINT", "https://de.pipe.aria.microsoft.com/Collector/3.0/");
292
+
293
+ _defineProperty(AriaTelemetryConstants, "GCCH_ENDPOINT", "https://tb.pipe.aria.microsoft.com/Collector/3.0/");
294
+
295
+ _defineProperty(AriaTelemetryConstants, "DOD_ENDPOINT", "https://pf.pipe.aria.microsoft.com/Collector/3.0");
296
+
297
+ _defineProperty(AriaTelemetryConstants, "EUROPE_ENDPOINT", "https://eu-mobile.events.data.microsoft.com/Collector/3.0/");
298
+
299
+ _defineProperty(AriaTelemetryConstants, "MOONCAKE_ENDPOINT", "");
300
+
301
+ _defineProperty(AriaTelemetryConstants, "Public", "Public");
302
+
303
+ _defineProperty(AriaTelemetryConstants, "EU", "Europe");
304
+
305
+ _defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
@@ -26,7 +26,7 @@ export let BroadcastEvent; // Events being logged
26
26
 
27
27
  (function (BroadcastEvent) {
28
28
  BroadcastEvent["LoadPostChatSurvey"] = "LoadPostChatSurvey";
29
- BroadcastEvent["EndChat"] = "EndChat";
29
+ BroadcastEvent["EndChat"] = "ChatEnded";
30
30
  BroadcastEvent["NewMessageNotification"] = "NewMessageNotification";
31
31
  BroadcastEvent["UnreadMessageCount"] = "UnreadMessageCount";
32
32
  BroadcastEvent["ChatWidgetStateChanged"] = "ChatWidgetStateChanged";
@@ -35,6 +35,9 @@ export let BroadcastEvent; // Events being logged
35
35
  BroadcastEvent["InvalidAdaptiveCardFormat"] = "InvalidAdaptiveCardFormat";
36
36
  BroadcastEvent["NewMessageSent"] = "NewMessageSent";
37
37
  BroadcastEvent["NewMessageReceived"] = "NewMessageReceived";
38
+ BroadcastEvent["RedirectPageRequest"] = "RedirectPageRequest";
39
+ BroadcastEvent["StartChatSkippingChatButtonRendering"] = "StartChatSkippingChatButtonRendering";
40
+ BroadcastEvent["StartUnauthenticatedReconnectChat"] = "StartUnauthenticatedReconnectChat";
38
41
  })(BroadcastEvent || (BroadcastEvent = {}));
39
42
 
40
43
  export let TelemetryEvent;
@@ -85,7 +88,9 @@ export let TelemetryEvent;
85
88
  TelemetryEvent["PrechatSurveyLoaded"] = "PrechatSurveyLoaded";
86
89
  TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
87
90
  TelemetryEvent["StartChatSDKCall"] = "StartChatCall";
91
+ TelemetryEvent["StartChatEventRecevied"] = "StartChatEventReceived";
88
92
  TelemetryEvent["EndChatSDKCall"] = "EndChatCall";
93
+ TelemetryEvent["EndChatEventReceived"] = "EndChatEventReceived";
89
94
  TelemetryEvent["OnNewMessageFailed"] = "OnNewMessageFailed";
90
95
  TelemetryEvent["OnNewMessageAudioNotificationFailed"] = "OnNewMessageAudioNotificationFailed";
91
96
  TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
@@ -99,6 +104,7 @@ export let TelemetryEvent;
99
104
  TelemetryEvent["LoadingPaneLoaded"] = "LoadingPaneLoaded";
100
105
  TelemetryEvent["EmailTranscriptLoaded"] = "EmailTranscriptLoaded";
101
106
  TelemetryEvent["OutOfOfficePaneLoaded"] = "OutOfOfficePaneLoaded";
107
+ TelemetryEvent["PostChatSurveyLoadingPaneLoaded"] = "PostChatSurveyLoadingPaneLoaded";
102
108
  TelemetryEvent["PostChatSurveyLoaded"] = "PostChatSurveyLoaded";
103
109
  TelemetryEvent["ConfirmationPaneLoaded"] = "ConfirmationPaneLoaded";
104
110
  TelemetryEvent["ProactiveChatPaneLoaded"] = "ProactiveChatPaneLoaded";
@@ -120,6 +126,7 @@ export let TelemetryEvent;
120
126
  TelemetryEvent["InvalidConfiguration"] = "InvalidConfiguration";
121
127
  TelemetryEvent["SendTypingIndicatorSucceeded"] = "SendTypingIndicatorSucceeded";
122
128
  TelemetryEvent["SendTypingIndicatorFailed"] = "SendTypingIndicatorFailed";
129
+ TelemetryEvent["WebChatEvent"] = "WebChatEvent";
123
130
  TelemetryEvent["PreChatSurveyStartChatMethodFailed"] = "PreChatSurveyStartChatMethodFailed";
124
131
  TelemetryEvent["ChatAlreadyTriggered"] = "ChatAlreadyTriggered";
125
132
  TelemetryEvent["StartProactiveChatEventReceived"] = "StartProactiveChatEventReceived";
@@ -148,6 +155,7 @@ export class TelemetryConstants {
148
155
  case TelemetryEvent.LCWChatButtonShow:
149
156
  case TelemetryEvent.PrechatSurveyLoaded:
150
157
  case TelemetryEvent.LoadingPaneLoaded:
158
+ case TelemetryEvent.PostChatSurveyLoadingPaneLoaded:
151
159
  case TelemetryEvent.PostChatSurveyLoaded:
152
160
  case TelemetryEvent.EmailTranscriptLoaded:
153
161
  case TelemetryEvent.OutOfOfficePaneLoaded:
@@ -177,12 +185,16 @@ export class TelemetryConstants {
177
185
  return ScenarioType.ACTIONS;
178
186
 
179
187
  case TelemetryEvent.StartChatSDKCall:
188
+ case TelemetryEvent.StartChatEventRecevied:
180
189
  case TelemetryEvent.StartChatMethodException:
181
190
  case TelemetryEvent.CloseChatMethodException:
191
+ case TelemetryEvent.StartProactiveChatEventReceived:
182
192
  case TelemetryEvent.StartProactiveChatMethodFailed:
183
193
  case TelemetryEvent.OnNewMessageFailed:
184
194
  case TelemetryEvent.OnNewMessageAudioNotificationFailed:
185
195
  case TelemetryEvent.GetConversationDetailsCallFailed:
196
+ case TelemetryEvent.EndChatSDKCall:
197
+ case TelemetryEvent.EndChatEventReceived:
186
198
  case TelemetryEvent.EndChatSDKCallFailed:
187
199
  case TelemetryEvent.PostChatContextCallFailed:
188
200
  case TelemetryEvent.PostChatContextCallSucceed:
@@ -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 { ScenarioType } from "./TelemetryConstants";
3
+ import { ScenarioType, TelemetryEvent } from "./TelemetryConstants";
4
4
  import { newGuid } from "../utils";
5
5
  import { TelemetryManager } from "./TelemetryManager";
6
6
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
@@ -259,4 +259,16 @@ _defineProperty(TelemetryHelper, "logConfigDataEvent", (logLevel, payload) => {
259
259
  }
260
260
  };
261
261
  BroadcastService.postMessage(telemetryEvent);
262
+ });
263
+
264
+ _defineProperty(TelemetryHelper, "logWebChatEvent", (logLevel, payload) => {
265
+ const telemetryEvent = {
266
+ eventName: TelemetryEvent.WebChatEvent,
267
+ logLevel: logLevel,
268
+ payload: { ...payload,
269
+ type: TelemetryEvent.WebChatEvent,
270
+ scenarioType: ScenarioType.WEBCHAT
271
+ }
272
+ };
273
+ BroadcastService.postMessage(telemetryEvent);
262
274
  });
@@ -4,6 +4,7 @@ import { LogLevel, ScenarioType, TelemetryConstants, TelemetryEvent } from "./Te
4
4
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
5
5
  import { ariaTelemetryLogger } from "./loggers/ariaTelemetryLogger";
6
6
  import { consoleLogger } from "./loggers/consoleLogger";
7
+ import { defaultAriaConfig } from "./defaultConfigs/defaultAriaConfig";
7
8
  export class TelemetryTimers {}
8
9
 
9
10
  _defineProperty(TelemetryTimers, "LcwLoadToChatButtonTimer", void 0);
@@ -26,7 +27,7 @@ export const RegisterLoggers = () => {
26
27
  const registerLoggers = () => {
27
28
  var _TelemetryManager$Int, _TelemetryManager$Int2, _TelemetryManager$Int3, _TelemetryManager$Int4, _TelemetryManager$Int5, _TelemetryManager$Int6, _TelemetryManager$Int7, _TelemetryManager$Int8;
28
29
 
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)) {
30
+ if (((_TelemetryManager$Int = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : (_TelemetryManager$Int2 = _TelemetryManager$Int.telemetryConfig) === null || _TelemetryManager$Int2 === void 0 ? void 0 : _TelemetryManager$Int2.disableConsoleLog) === false || ((_TelemetryManager$Int3 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int3 === void 0 ? void 0 : (_TelemetryManager$Int4 = _TelemetryManager$Int3.telemetryConfig) === null || _TelemetryManager$Int4 === void 0 ? void 0 : _TelemetryManager$Int4.telemetryDisabled) === false) {
30
31
  BroadcastService.getAnyMessage().subscribe(event => {
31
32
  if (event.payload && event.eventName in TelemetryEvent) {
32
33
  logTelemetry(event);
@@ -34,17 +35,17 @@ export const RegisterLoggers = () => {
34
35
  });
35
36
  }
36
37
 
37
- if (!((_TelemetryManager$Int5 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int5 !== void 0 && (_TelemetryManager$Int6 = _TelemetryManager$Int5.telemetryConfig) !== null && _TelemetryManager$Int6 !== void 0 && _TelemetryManager$Int6.disableConsoleLog)) {
38
+ if (((_TelemetryManager$Int5 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int5 === void 0 ? void 0 : (_TelemetryManager$Int6 = _TelemetryManager$Int5.telemetryConfig) === null || _TelemetryManager$Int6 === void 0 ? void 0 : _TelemetryManager$Int6.disableConsoleLog) === false) {
38
39
  loggers.push(consoleLogger());
39
40
  }
40
41
 
41
- if (!((_TelemetryManager$Int7 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int7 !== void 0 && (_TelemetryManager$Int8 = _TelemetryManager$Int7.telemetryConfig) !== null && _TelemetryManager$Int8 !== void 0 && _TelemetryManager$Int8.telemetryDisabled)) {
42
+ if (((_TelemetryManager$Int7 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int7 === void 0 ? void 0 : (_TelemetryManager$Int8 = _TelemetryManager$Int7.telemetryConfig) === null || _TelemetryManager$Int8 === void 0 ? void 0 : _TelemetryManager$Int8.telemetryDisabled) === false) {
42
43
  var _TelemetryManager$Int9, _TelemetryManager$Int18, _TelemetryManager$Int19;
43
44
 
44
45
  if ((_TelemetryManager$Int9 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int9 !== void 0 && _TelemetryManager$Int9.ariaConfig) {
45
46
  var _TelemetryManager$Int10, _TelemetryManager$Int11, _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14, _TelemetryManager$Int15, _TelemetryManager$Int16, _TelemetryManager$Int17;
46
47
 
47
- loggers.push(ariaTelemetryLogger(((_TelemetryManager$Int10 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int10 === void 0 ? void 0 : (_TelemetryManager$Int11 = _TelemetryManager$Int10.ariaConfig) === null || _TelemetryManager$Int11 === void 0 ? void 0 : _TelemetryManager$Int11.ariaTelemetryKey) ?? "", ((_TelemetryManager$Int12 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : (_TelemetryManager$Int13 = _TelemetryManager$Int12.ariaConfig) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.disableCookieUsage) ?? false, ((_TelemetryManager$Int14 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : (_TelemetryManager$Int15 = _TelemetryManager$Int14.ariaConfig) === null || _TelemetryManager$Int15 === void 0 ? void 0 : _TelemetryManager$Int15.collectorUriForTelemetry) ?? "", ((_TelemetryManager$Int16 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int16 === void 0 ? void 0 : (_TelemetryManager$Int17 = _TelemetryManager$Int16.ariaConfig) === null || _TelemetryManager$Int17 === void 0 ? void 0 : _TelemetryManager$Int17.ariaTelemetryApplicationName) ?? "OmniChannelProd_Web"));
48
+ loggers.push(ariaTelemetryLogger(((_TelemetryManager$Int10 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int10 === void 0 ? void 0 : (_TelemetryManager$Int11 = _TelemetryManager$Int10.ariaConfig) === null || _TelemetryManager$Int11 === void 0 ? void 0 : _TelemetryManager$Int11.ariaTelemetryKey) ?? defaultAriaConfig.ariaTelemetryKey, ((_TelemetryManager$Int12 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : (_TelemetryManager$Int13 = _TelemetryManager$Int12.ariaConfig) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.disableCookieUsage) ?? defaultAriaConfig.disableCookieUsage, ((_TelemetryManager$Int14 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : (_TelemetryManager$Int15 = _TelemetryManager$Int14.ariaConfig) === null || _TelemetryManager$Int15 === void 0 ? void 0 : _TelemetryManager$Int15.collectorUriForTelemetry) ?? defaultAriaConfig.collectorUriForTelemetry, ((_TelemetryManager$Int16 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int16 === void 0 ? void 0 : (_TelemetryManager$Int17 = _TelemetryManager$Int16.ariaConfig) === null || _TelemetryManager$Int17 === void 0 ? void 0 : _TelemetryManager$Int17.ariaTelemetryApplicationName) ?? defaultAriaConfig.ariaTelemetryApplicationName));
48
49
  }
49
50
 
50
51
  const customLoggers = (_TelemetryManager$Int18 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int18 === void 0 ? void 0 : (_TelemetryManager$Int19 = _TelemetryManager$Int18.telemetryConfig) === null || _TelemetryManager$Int19 === void 0 ? void 0 : _TelemetryManager$Int19.telemetryLoggers;
@@ -67,8 +68,11 @@ export const RegisterLoggers = () => {
67
68
 
68
69
  const logTelemetry = telemetryEvent => {
69
70
  loggers.map(logger => {
71
+ var _payload;
72
+
70
73
  const logLevel = telemetryEvent.logLevel ?? LogLevel.INFO;
71
- logger.log(logLevel, parseInput(telemetryEvent === null || telemetryEvent === void 0 ? void 0 : telemetryEvent.payload));
74
+ const scenarioType = ((_payload = telemetryEvent.payload) === null || _payload === void 0 ? void 0 : _payload.scenarioType) ?? ScenarioType.UNDEFINED;
75
+ logger.log(logLevel, parseInput(telemetryEvent === null || telemetryEvent === void 0 ? void 0 : telemetryEvent.payload, scenarioType));
72
76
  });
73
77
  };
74
78
 
@@ -1,6 +1,6 @@
1
1
  export const defaultAriaConfig = {
2
2
  collectorUriForTelemetry: "",
3
3
  ariaTelemetryKey: "c7655518acf1403f93ff6b9f77942f0a-d01a02fd-6b50-4de3-a566-62eda11f93bc-7083",
4
- ariaTelemetryApplicationName: "",
4
+ ariaTelemetryApplicationName: "D365_Omnichannel_Client_Public_Prod",
5
5
  disableCookieUsage: true
6
6
  };
@@ -1,9 +1,11 @@
1
- import { isNullOrEmptyString, isNullOrUndefined } from "../../utils";
1
+ import { AriaTelemetryConstants, EnvironmentVersion } from "../../../../src/common/Constants";
2
+ import { getDomain, isNullOrEmptyString, isNullOrUndefined } from "../../utils";
2
3
  import AWTEventProperties from "@microsoft/omnichannel-chat-sdk/lib/external/aria/webjs/AWTEventProperties";
3
4
  import AWTLogManager from "@microsoft/omnichannel-chat-sdk/lib/external/aria/webjs/AWTLogManager";
4
5
  import { AWTPiiKind } from "@microsoft/omnichannel-chat-sdk/lib/external/aria/common/Enums";
5
6
  import { Constants } from "../../Constants";
6
7
  import { TelemetryHelper } from "../TelemetryHelper";
8
+ import { TelemetryManager } from "../TelemetryManager";
7
9
  export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, collectiorUriForTelemetry, ariaTelemetryApplicationName) => {
8
10
  let _logger;
9
11
 
@@ -15,6 +17,21 @@ export const ariaTelemetryLogger = (ariaTelemetryKey, disabledCookieUsage, colle
15
17
 
16
18
  if (!isNullOrEmptyString(collectiorUriForTelemetry)) {
17
19
  configuration.collectorUri = collectiorUriForTelemetry;
20
+ } else {
21
+ if (TelemetryManager.InternalTelemetryData.environmentVersion == EnvironmentVersion.prod) {
22
+ var _TelemetryManager$Int;
23
+
24
+ const orgUrl = (_TelemetryManager$Int = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.orgUrl;
25
+
26
+ if (!isNullOrUndefined(orgUrl)) {
27
+ // If the given org is a Production EU org, modify the Aria collector uri
28
+ const region = getDomain(orgUrl);
29
+
30
+ if (region === AriaTelemetryConstants.EU) {
31
+ configuration.collectorUri = AriaTelemetryConstants.EUROPE_ENDPOINT;
32
+ }
33
+ }
34
+ }
18
35
  }
19
36
 
20
37
  try {
@@ -1,4 +1,4 @@
1
- import { Constants, LocaleConstants } from "./Constants";
1
+ import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
2
2
  import { KeyCodes } from "./KeyCodes";
3
3
 
4
4
  const getElementBySelector = selector => {
@@ -276,4 +276,14 @@ export const createTimer = () => {
276
276
  }
277
277
 
278
278
  };
279
+ }; // Returns the domain of the org
280
+
281
+ export const getDomain = hostValue => {
282
+ for (let i = 0; i < AriaTelemetryConstants.lcwEUDomainNames.length; i++) {
283
+ if (hostValue.endsWith(AriaTelemetryConstants.lcwEUDomainNames[i])) {
284
+ return AriaTelemetryConstants.EU;
285
+ }
286
+ }
287
+
288
+ return AriaTelemetryConstants.Public;
279
289
  };
@@ -1,35 +1,25 @@
1
- import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
- import { BroadcastService, ConfirmationPane } from "@microsoft/omnichannel-chat-components";
1
+ import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
+ import { ConfirmationPane } from "@microsoft/omnichannel-chat-components";
3
3
  import React, { useEffect } from "react";
4
4
  import { findAllFocusableElement, findParentFocusableElementsWithoutChildContainer, preventFocusToMoveOutOfElement, setFocusOnElement, setFocusOnSendBox, setTabIndices } from "../../common/utils";
5
- import { Constants } from "../../common/Constants";
6
- import { ConversationState } from "../../contexts/common/ConversationState";
7
5
  import { DimLayer } from "../dimlayer/DimLayer";
8
6
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
9
7
  import { NotificationHandler } from "../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
10
8
  import { NotificationScenarios } from "../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
11
- import { PostChatSurveyMode } from "../postchatsurveypanestateful/enums/PostChatSurveyMode";
12
9
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
13
10
  import useChatAdapterStore from "../../hooks/useChatAdapterStore";
14
- import useChatContextStore from "../../hooks/useChatContextStore";
15
- import useChatSDKStore from "../../hooks/useChatSDKStore"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ import useChatContextStore from "../../hooks/useChatContextStore"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
12
 
17
13
  export const ConfirmationPaneStateful = props => {
18
- var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
19
-
20
14
  const initialTabIndexMap = new Map();
21
- let elements = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
-
23
- const chatSDK = useChatSDKStore();
15
+ let elements = [];
24
16
  const [state, dispatch] = useChatContextStore();
25
17
  const {
26
- endChat
18
+ prepareEndChat
27
19
  } = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
20
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
21
 
30
22
  const [adapter] = useChatAdapterStore();
31
- 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;
32
- const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
33
23
  const controlProps = {
34
24
  id: "oc-lcw-confirmation-pane",
35
25
  dir: state.domainStates.globalDir,
@@ -44,28 +34,8 @@ export const ConfirmationPaneStateful = props => {
44
34
  });
45
35
 
46
36
  try {
47
- // check agent has joined conversation
48
- const conversationDetails = await chatSDK.getConversationDetails();
49
-
50
- if (isPostChatEnabled === "true" && (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === Constants.truePascal) {
51
- if (postChatSurveyMode === PostChatSurveyMode.Embed) {
52
- const loadPostChatEvent = {
53
- eventName: BroadcastEvent.LoadPostChatSurvey
54
- };
55
- BroadcastService.postMessage(loadPostChatEvent);
56
- } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
57
- const skipEndChatSDK = false;
58
- const skipCloseChat = true;
59
- await endChat(adapter, skipEndChatSDK, skipCloseChat);
60
- dispatch({
61
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
62
- payload: ConversationState.InActive
63
- });
64
- }
65
- } else {
66
- setTabIndices(elements, initialTabIndexMap, true);
67
- await endChat(adapter);
68
- }
37
+ setTabIndices(elements, initialTabIndexMap, true);
38
+ await prepareEndChat(adapter, state);
69
39
  } catch (ex) {
70
40
  TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
71
41
  Event: TelemetryEvent.GetConversationDetailsCallFailed,
@@ -97,8 +97,7 @@ export const FooterStateful = props => {
97
97
  styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
98
98
  }), /*#__PURE__*/React.createElement(AudioNotificationStateful, {
99
99
  audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? NewMessageNotificationSoundBase64,
100
- hideAudioNotificationButton: (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : _footerProps$controlP4.hideAudioNotificationButton) ?? false,
101
- isAudioMuted: state.appStates.isAudioMuted ?? false
100
+ isAudioMuted: state.appStates.isAudioMuted === null ? (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : _footerProps$controlP4.hideAudioNotificationButton) ?? false : state.appStates.isAudioMuted ?? false
102
101
  }));
103
102
  };
104
103
  export default FooterStateful;
@@ -46,13 +46,7 @@ export const HeaderStateful = props => {
46
46
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
47
47
  payload: true
48
48
  });
49
- } else if (conversationState.current === ConversationState.Postchat) {
50
- dispatch({
51
- type: LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT,
52
- payload: false
53
- });
54
- await endChat(adapter);
55
- } else if (conversationState.current === ConversationState.InActive) {
49
+ } else {
56
50
  const skipEndChatSDK = true;
57
51
  const skipCloseChat = false;
58
52
  await endChat(adapter, skipEndChatSDK, skipCloseChat);
@@ -9,7 +9,8 @@ import createAttachmentMiddleware from "../../../webchatcontainerstateful/webcha
9
9
  import { createAvatarMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware";
10
10
  import { createMarkdown } from "../createMarkdown";
11
11
  import { groupActivitiesMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware";
12
- import { typingIndicatorMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware"; // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ import { typingIndicatorMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware";
13
+ import { createWebChatTelemetry } from "../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger"; // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
14
 
14
15
  export const dummyDefaultProps = {
15
16
  audioNotificationProps: {
@@ -1424,7 +1425,8 @@ export const dummyDefaultProps = {
1424
1425
  },
1425
1426
  authClientFunction: undefined,
1426
1427
  isReconnectEnabled: undefined,
1427
- reconnectId: undefined
1428
+ reconnectId: undefined,
1429
+ redirectInSameWindow: undefined
1428
1430
  },
1429
1431
  styleProps: {
1430
1432
  generalStyles: {
@@ -1496,7 +1498,7 @@ export const dummyDefaultProps = {
1496
1498
  internalErrorBoxClass: undefined,
1497
1499
  internalRenderErrorBox: undefined,
1498
1500
  locale: "en-US",
1499
- onTelemetry: undefined,
1501
+ onTelemetry: createWebChatTelemetry(),
1500
1502
  overrideLocalizedStrings: undefined,
1501
1503
  renderMarkdown: createMarkdown(false, false),
1502
1504
  scrollToEndButtonMiddleware: undefined,
@@ -4,9 +4,41 @@ import { ConversationState } from "../../../contexts/common/ConversationState";
4
4
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
5
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
6
6
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
7
- import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
8
+ import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
9
+ import { Constants } from "../../../common/Constants";
8
10
 
9
- export const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat) => {
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
13
+ var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
14
+
15
+ 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;
16
+ const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
17
+ const conversationDetails = await chatSDK.getConversationDetails();
18
+
19
+ if (isPostChatEnabled === "true" && (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === Constants.truePascal) {
20
+ const skipEndChatSDK = false;
21
+ const skipCloseChat = true;
22
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
23
+
24
+ if (postChatSurveyMode === PostChatSurveyMode.Embed) {
25
+ const loadPostChatEvent = {
26
+ eventName: BroadcastEvent.LoadPostChatSurvey
27
+ };
28
+ BroadcastService.postMessage(loadPostChatEvent);
29
+ } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
30
+ dispatch({
31
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
32
+ payload: ConversationState.InActive
33
+ });
34
+ }
35
+ } else {
36
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
37
+ }
38
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+
40
+
41
+ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat) => {
10
42
  if (!skipEndChatSDK) {
11
43
  try {
12
44
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
@@ -69,4 +101,6 @@ export const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
69
101
  });
70
102
  }
71
103
  }
72
- };
104
+ };
105
+
106
+ export { prepareEndChat, endChat };
@@ -8,7 +8,7 @@ export const initCallingSdk = async (chatSDK, setVoiceVideoCallingSDK) => {
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
9
  const callingSDK = await chatSDK.getVoiceVideoCalling();
10
10
  setVoiceVideoCallingSDK(callingSDK);
11
- TelemetryHelper.logCallingEvent(LogLevel.ERROR, {
11
+ TelemetryHelper.logCallingEvent(LogLevel.INFO, {
12
12
  Event: TelemetryEvent.CallingSDKLoadSuccess
13
13
  });
14
14
  return true;
@@ -17,6 +17,7 @@ import createConversationEndMiddleware from "../../webchatcontainerstateful/webc
17
17
  import createDataMaskingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware";
18
18
  import { createMarkdown } from "./createMarkdown";
19
19
  import createMaxMessageSizeValidator from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator";
20
+ import { createWebChatTelemetry } from "../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
20
21
  import { defaultAttachmentProps } from "../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps";
21
22
  import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
22
23
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
@@ -103,6 +104,7 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
103
104
  avatarMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableAvatarMiddleware ? undefined : createAvatarMiddleware((_state$domainStates$r5 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r5 === void 0 ? void 0 : _state$domainStates$r5.avatarStyleProps, (_state$domainStates$r6 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r6 === void 0 ? void 0 : _state$domainStates$r6.avatarTextStyleProps),
104
105
  groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
105
106
  typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
107
+ onTelemetry: createWebChatTelemetry(),
106
108
  ...((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.webChatProps)
107
109
  };
108
110
  return webChatProps;
@@ -1,6 +1,6 @@
1
1
  import "regenerator-runtime/runtime";
2
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
- import { Constants } from "../../../common/Constants";
2
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
4
  import { ConversationState } from "../../../contexts/common/ConversationState";
5
5
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
6
6
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -46,33 +46,107 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
46
46
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
47
 
48
48
 
49
- const handleUnauthenticatedReconnectChat = async (dispatch, reconnectId, initStartChat) => {
50
- const reconnectAvailabilityResponse = await getChatReconnectContext(reconnectId);
49
+ const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
50
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
51
51
 
52
- if (reconnectAvailabilityResponse && reconnectAvailabilityResponse.redirectURL) {
53
- redirectPage(reconnectAvailabilityResponse.redirectURL);
52
+ if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
53
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
54
54
  } else {
55
- const optionalParams = {
56
- reconnectId: reconnectId
57
- };
55
+ await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
56
+ }
57
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+
59
+
60
+ const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
61
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
62
+
63
+ if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
64
+ await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
65
+ }
66
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
+
68
+
69
+ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
70
+ const startUnauthenticatedReconnectChat = {
71
+ eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
72
+ };
73
+ BroadcastService.postMessage(startUnauthenticatedReconnectChat);
74
+ const optionalParams = {
75
+ reconnectId: reconnectId
76
+ };
77
+ dispatch({
78
+ type: LiveChatWidgetActionType.SET_RECONNECT_ID,
79
+ payload: reconnectId
80
+ });
81
+ dispatch({
82
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
83
+ payload: ConversationState.Loading
84
+ });
85
+ await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
86
+ };
87
+
88
+ const redirectPage = (redirectURL, redirectInSameWindow) => {
89
+ const redirectPageRequest = {
90
+ eventName: BroadcastEvent.RedirectPageRequest,
91
+ payload: {
92
+ redirectURL: redirectURL
93
+ }
94
+ };
95
+ BroadcastService.postMessage(redirectPageRequest);
96
+
97
+ if (redirectInSameWindow) {
98
+ window.location.href = redirectURL;
99
+ }
100
+ };
101
+
102
+ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
103
+ return reconnectAvailabilityResponse && !reconnectAvailabilityResponse.reconnectId;
104
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
+
106
+
107
+ const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
108
+ const startUnauthenticatedReconnectChat = {
109
+ eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
110
+ };
111
+ BroadcastService.postMessage(startUnauthenticatedReconnectChat); // Getting PreChat Survey Context
112
+
113
+ const parseToJson = false;
114
+ const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
115
+
116
+ if (preChatSurveyResponse) {
58
117
  dispatch({
59
- type: LiveChatWidgetActionType.SET_RECONNECT_ID,
60
- payload: reconnectId
118
+ type: LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
119
+ payload: preChatSurveyResponse
61
120
  });
121
+ dispatch({
122
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
123
+ payload: ConversationState.Prechat
124
+ });
125
+ } else {
62
126
  dispatch({
63
127
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
64
128
  payload: ConversationState.Loading
65
129
  });
66
- await initStartChat(optionalParams);
130
+ await initStartChat(chatSDK, dispatch, setAdapter);
67
131
  }
68
- };
132
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
133
 
70
- const redirectPage = newUrl => {
71
- const data = {
72
- messageName: Constants.redirectPageRequest,
73
- newUrl: newUrl
74
- };
75
- window.parent.postMessage(data, "*");
134
+
135
+ const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
136
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
137
+
138
+ if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
139
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
140
+ }
141
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
+
143
+
144
+ const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
145
+ if (reconnectAvailabilityResponse.redirectURL) {
146
+ redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
147
+ } else {
148
+ await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
149
+ }
76
150
  };
77
151
 
78
- export { getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat };
152
+ export { getChatReconnectContext, getReconnectIdForAuthenticatedChat, handleUnauthenticatedReconnectChat, startUnauthenticatedReconnectChat, handleRedirectUnauthenticatedReconnectChat };