@microsoft/omnichannel-chat-widget 1.5.1-main.132e1c6 → 1.5.1-main.8614a75

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 (76) hide show
  1. package/lib/cjs/common/Constants.js +15 -8
  2. package/lib/cjs/common/telemetry/TelemetryConstants.js +1 -2
  3. package/lib/cjs/common/utils.js +2 -1
  4. package/lib/cjs/components/livechatwidget/common/chatDisconnectHelper.js +31 -16
  5. package/lib/cjs/components/livechatwidget/common/endChat.js +16 -4
  6. package/lib/cjs/components/livechatwidget/common/startChat.js +19 -80
  7. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +205 -0
  8. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.spec.js +282 -0
  9. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +13 -16
  10. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
  11. package/lib/cjs/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +68 -0
  12. package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.js +17 -0
  13. package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.js +17 -0
  14. package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.js +15 -0
  15. package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.js +17 -0
  16. package/lib/cjs/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.js +17 -0
  17. package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
  18. package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
  19. package/lib/cjs/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.js +1 -0
  20. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +0 -8
  21. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
  22. package/lib/cjs/contexts/common/ConversationState.js +1 -0
  23. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +1 -0
  24. package/lib/cjs/controller/componentController.js +5 -1
  25. package/lib/esm/common/Constants.js +11 -6
  26. package/lib/esm/common/telemetry/TelemetryConstants.js +1 -2
  27. package/lib/esm/common/utils.js +3 -2
  28. package/lib/esm/components/livechatwidget/common/chatDisconnectHelper.js +31 -16
  29. package/lib/esm/components/livechatwidget/common/endChat.js +14 -3
  30. package/lib/esm/components/livechatwidget/common/startChat.js +20 -81
  31. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +198 -0
  32. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.spec.js +280 -0
  33. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +15 -18
  34. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
  35. package/lib/esm/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +57 -0
  36. package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.js +10 -0
  37. package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.js +10 -0
  38. package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.js +8 -0
  39. package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.js +10 -0
  40. package/lib/esm/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.js +10 -0
  41. package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
  42. package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
  43. package/lib/esm/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.js +1 -0
  44. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +0 -8
  45. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
  46. package/lib/esm/contexts/common/ConversationState.js +1 -0
  47. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +1 -0
  48. package/lib/esm/controller/componentController.js +3 -0
  49. package/lib/types/common/Constants.d.ts +13 -4
  50. package/lib/types/common/telemetry/TelemetryConstants.d.ts +1 -1
  51. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
  52. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +5 -0
  53. package/lib/types/components/livechatwidget/common/startChatErrorHandler.spec.d.ts +1 -0
  54. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  55. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -1
  56. package/lib/types/components/startchaterrorpanestateful/StartChatErrorPaneStateful.d.ts +3 -0
  57. package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneGeneralStyleProps.d.ts +2 -0
  58. package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconImageProps.d.ts +2 -0
  59. package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneIconStyleProps.d.ts +2 -0
  60. package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneSubtitleStyleProps.d.ts +2 -0
  61. package/lib/types/components/startchaterrorpanestateful/common/defaultStartChatErrorPaneTitleStyleProps.d.ts +2 -0
  62. package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.d.ts +5 -0
  63. package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.d.ts +6 -0
  64. package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +10 -0
  65. package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +8 -0
  66. package/lib/types/components/startchaterrorpanestateful/interfaces/IStartChatErrorPaneStyleProps.d.ts +10 -0
  67. package/lib/types/contexts/common/ConversationState.d.ts +2 -1
  68. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  69. package/lib/types/controller/componentController.d.ts +1 -0
  70. package/package.json +3 -3
  71. package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +0 -4
  72. package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +0 -4
  73. /package/lib/cjs/components/{loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.js} +0 -0
  74. /package/lib/cjs/components/{loadingpanestateful/interfaces/IStartChatErrorPaneProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.js} +0 -0
  75. /package/lib/esm/components/{loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneClassNames.js} +0 -0
  76. /package/lib/esm/components/{loadingpanestateful/interfaces/IStartChatErrorPaneProps.js → startchaterrorpanestateful/interfaces/IStartChatErrorPaneComponentOverrides.js} +0 -0
@@ -0,0 +1,280 @@
1
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
2
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
3
+ import { handleStartChatError } from "./startChatErrorHandler";
4
+ import { WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
5
+ import { ChatSDKError, ChatSDKErrorName } from "@microsoft/omnichannel-chat-sdk";
6
+ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
7
+ import { ConversationState } from "../../../contexts/common/ConversationState";
8
+ describe("startChatErrorHandler unit test", () => {
9
+ it("handleStartChatError should log failed event and return if exception is undefined", () => {
10
+ const dispatch = jest.fn();
11
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
12
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
13
+ handleStartChatError(dispatch, {}, {}, undefined, false);
14
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
15
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
16
+ ExceptionDetails: expect.objectContaining({
17
+ Exception: "Widget load complete with error: undefined"
18
+ })
19
+ }));
20
+ expect(dispatch).not.toHaveBeenCalled();
21
+ });
22
+ it("handleStartChatError should log failed with error event for AuthenticationFailedErrorString", () => {
23
+ const dispatch = jest.fn();
24
+ const mockEx = new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
25
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
26
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
27
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
28
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
29
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
30
+ ExceptionDetails: expect.objectContaining({
31
+ Exception: `Widget load complete with error: Error: ${WidgetLoadCustomErrorString.AuthenticationFailedErrorString}`
32
+ })
33
+ }));
34
+ expect(dispatch).toHaveBeenCalledTimes(2);
35
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
36
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
37
+ }));
38
+ });
39
+ it("handleStartChatError should log failed with error event for NetworkErrorString", () => {
40
+ const dispatch = jest.fn();
41
+ const mockEx = new Error(WidgetLoadCustomErrorString.NetworkErrorString);
42
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
43
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
44
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
45
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
46
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
47
+ ExceptionDetails: expect.objectContaining({
48
+ Exception: `Widget load complete with error: Error: ${WidgetLoadCustomErrorString.NetworkErrorString}`
49
+ })
50
+ }));
51
+ expect(dispatch).toHaveBeenCalledTimes(2);
52
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
53
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
54
+ }));
55
+ });
56
+ it("handleStartChatError should log complete event for WidgetUseOutsideOperatingHour", () => {
57
+ const dispatch = jest.fn();
58
+ const mockEx = new ChatSDKError(ChatSDKErrorName.WidgetUseOutsideOperatingHour);
59
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
60
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
61
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
62
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
63
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("INFO", expect.objectContaining({
64
+ Description: `Widget load complete. ${WidgetLoadTelemetryMessage.OOOHMessage}`
65
+ }));
66
+ expect(dispatch).toHaveBeenCalledTimes(2);
67
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
68
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
69
+ }));
70
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
71
+ type: LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS
72
+ }));
73
+ });
74
+ it("handleStartChatError should log failed with error event for PersistentChatConversationRetrievalFailure for non-400 status", () => {
75
+ const dispatch = jest.fn();
76
+ const mockEx = new ChatSDKError(ChatSDKErrorName.PersistentChatConversationRetrievalFailure, 429);
77
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
78
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
79
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
80
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
81
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
82
+ Description: "Widget load complete with error",
83
+ ExceptionDetails: expect.objectContaining({
84
+ Exception: `Widget load complete with error: ${ChatSDKErrorName.PersistentChatConversationRetrievalFailure}`,
85
+ HttpResponseStatusCode: 429
86
+ })
87
+ }));
88
+ expect(dispatch).toHaveBeenCalledTimes(2);
89
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
90
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
91
+ }));
92
+ });
93
+ it("handleStartChatError should log failed event for PersistentChatConversationRetrievalFailure for 400 status", () => {
94
+ const dispatch = jest.fn();
95
+ const mockEx = new ChatSDKError(ChatSDKErrorName.PersistentChatConversationRetrievalFailure, 400);
96
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
97
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
98
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
99
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
100
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
101
+ ExceptionDetails: expect.objectContaining({
102
+ Exception: `Widget load complete with error: ${ChatSDKErrorName.PersistentChatConversationRetrievalFailure}`,
103
+ HttpResponseStatusCode: 400
104
+ })
105
+ }));
106
+ expect(dispatch).toHaveBeenCalledTimes(2);
107
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
108
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
109
+ }));
110
+ });
111
+ it("handleStartChatError should log failed with error event for ConversationInitializationFailure for non-400 status", () => {
112
+ const dispatch = jest.fn();
113
+ const mockEx = new ChatSDKError(ChatSDKErrorName.ConversationInitializationFailure, 429);
114
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
115
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
116
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
117
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
118
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
119
+ Description: "Widget load complete with error",
120
+ ExceptionDetails: expect.objectContaining({
121
+ Exception: `Widget load complete with error: ${ChatSDKErrorName.ConversationInitializationFailure}`,
122
+ HttpResponseStatusCode: 429
123
+ })
124
+ }));
125
+ expect(dispatch).toHaveBeenCalledTimes(2);
126
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
127
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
128
+ }));
129
+ });
130
+ it("handleStartChatError should log failed event for ConversationInitializationFailure for 400 status", () => {
131
+ const dispatch = jest.fn();
132
+ const mockEx = new ChatSDKError(ChatSDKErrorName.ConversationInitializationFailure, 400);
133
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
134
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
135
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
136
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
137
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
138
+ ExceptionDetails: expect.objectContaining({
139
+ Exception: `Widget load complete with error: ${ChatSDKErrorName.ConversationInitializationFailure}`,
140
+ HttpResponseStatusCode: 400
141
+ })
142
+ }));
143
+ expect(dispatch).toHaveBeenCalledTimes(2);
144
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
145
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
146
+ }));
147
+ });
148
+ it("handleStartChatError should log failed with error event for ChatTokenRetrievalFailure for non-400 status", () => {
149
+ const dispatch = jest.fn();
150
+ const mockEx = new ChatSDKError(ChatSDKErrorName.ChatTokenRetrievalFailure, 429);
151
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
152
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
153
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
154
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
155
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
156
+ Description: "Widget load complete with error",
157
+ ExceptionDetails: expect.objectContaining({
158
+ Exception: `Widget load complete with error: ${ChatSDKErrorName.ChatTokenRetrievalFailure}`,
159
+ HttpResponseStatusCode: 429
160
+ })
161
+ }));
162
+ expect(dispatch).toHaveBeenCalledTimes(2);
163
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
164
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
165
+ }));
166
+ });
167
+ it("handleStartChatError should log failed event for ChatTokenRetrievalFailure for 400 status", () => {
168
+ const dispatch = jest.fn();
169
+ const mockEx = new ChatSDKError(ChatSDKErrorName.ChatTokenRetrievalFailure, 400);
170
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
171
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
172
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
173
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
174
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
175
+ ExceptionDetails: expect.objectContaining({
176
+ Exception: `Widget load complete with error: ${ChatSDKErrorName.ChatTokenRetrievalFailure}`,
177
+ HttpResponseStatusCode: 400
178
+ })
179
+ }));
180
+ expect(dispatch).toHaveBeenCalledTimes(2);
181
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
182
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
183
+ }));
184
+ });
185
+ it("handleStartChatError should log failed with error event for UninitializedChatSDK", () => {
186
+ const dispatch = jest.fn();
187
+ const mockEx = new ChatSDKError(ChatSDKErrorName.UninitializedChatSDK);
188
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
189
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
190
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
191
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
192
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
193
+ Description: "Widget load complete with error",
194
+ ExceptionDetails: expect.objectContaining({
195
+ Exception: `Widget load complete with error: ${ChatSDKErrorName.UninitializedChatSDK}`
196
+ })
197
+ }));
198
+ expect(dispatch).toHaveBeenCalledTimes(2);
199
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
200
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
201
+ }));
202
+ });
203
+ it("handleStartChatError should log failed with error event for InvalidConversation", () => {
204
+ const dispatch = jest.fn();
205
+ const mockEx = new ChatSDKError(ChatSDKErrorName.InvalidConversation);
206
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
207
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
208
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
209
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
210
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
211
+ Description: "Widget load complete with error",
212
+ ExceptionDetails: expect.objectContaining({
213
+ Exception: `Widget load complete with error: ${ChatSDKErrorName.InvalidConversation}`
214
+ })
215
+ }));
216
+ expect(dispatch).toHaveBeenCalledTimes(16);
217
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
218
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
219
+ payload: ConversationState.Closed
220
+ }));
221
+ });
222
+ it("handleStartChatError should log failed with error event for ClosedConversation", () => {
223
+ const dispatch = jest.fn();
224
+ const mockEx = new ChatSDKError(ChatSDKErrorName.ClosedConversation);
225
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
226
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
227
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
228
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
229
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
230
+ Description: "Widget load complete with error",
231
+ ExceptionDetails: expect.objectContaining({
232
+ Exception: `Widget load complete with error: ${ChatSDKErrorName.ClosedConversation}`
233
+ })
234
+ }));
235
+ expect(dispatch).toHaveBeenCalledTimes(16);
236
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
237
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
238
+ payload: ConversationState.Closed
239
+ }));
240
+ });
241
+ it("handleStartChatError should log failed event for any other errors", () => {
242
+ const dispatch = jest.fn();
243
+ const mockEx = new ChatSDKError(ChatSDKErrorName.ScriptLoadFailure, 405);
244
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
245
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
246
+ handleStartChatError(dispatch, {}, {}, mockEx, false);
247
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
248
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
249
+ ExceptionDetails: expect.objectContaining({
250
+ Exception: `Widget load complete with error: ${ChatSDKErrorName.ScriptLoadFailure}`,
251
+ HttpResponseStatusCode: 405
252
+ })
253
+ }));
254
+ expect(dispatch).toHaveBeenCalledTimes(2);
255
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
256
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
257
+ }));
258
+ });
259
+ it("handleStartChatError should force end chat if isStartChatSuccessful is true", () => {
260
+ const dispatch = jest.fn();
261
+ const mockEx = new ChatSDKError(ChatSDKErrorName.ScriptLoadFailure, 405);
262
+ const mockSDK = {
263
+ endChat: jest.fn()
264
+ };
265
+ spyOn(BroadcastService, "postMessage").and.callFake(() => false);
266
+ spyOn(TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
267
+ handleStartChatError(dispatch, mockSDK, {}, mockEx, true);
268
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(3);
269
+ expect(TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
270
+ ExceptionDetails: expect.objectContaining({
271
+ Exception: "SessionInit was successful, but widget load failed."
272
+ })
273
+ }));
274
+ expect(dispatch).toHaveBeenCalledTimes(2);
275
+ expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
276
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE
277
+ }));
278
+ expect(mockSDK.endChat).toHaveBeenCalled();
279
+ });
280
+ });
@@ -8,9 +8,9 @@ import React, { useEffect, useRef, useState } from "react";
8
8
  import { checkIfConversationStillValid, initStartChat, prepareStartChat, setPreChatAndInitiateChat } from "../common/startChat";
9
9
  import { createTimer, getBroadcastChannelName, getConversationDetailsCall, getLocaleDirection, getStateFromCache, getWidgetCacheIdfromProps, getWidgetEndChatEventName, isNullOrEmptyString, isNullOrUndefined, isUndefinedOrEmpty } from "../../../common/utils";
10
10
  import { defaultClientDataStoreProvider, isCookieAllowed } from "../../../common/storage/default/defaultClientDataStoreProvider";
11
- import { endChat, endChatStateCleanUp, prepareEndChat } from "../common/endChat";
11
+ import { chatSDKStateCleanUp, endChat, endChatStateCleanUp, prepareEndChat } from "../common/endChat";
12
12
  import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "../common/reconnectChatHelper";
13
- import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
13
+ import { shouldShowCallingContainer, shouldShowChatButton, shouldShowConfirmationPane, shouldShowEmailTranscriptPane, shouldShowStartChatErrorPane, shouldShowHeader, shouldShowLoadingPane, shouldShowOutOfOfficeHoursPane, shouldShowPostChatLoadingPane, shouldShowPostChatSurveyPane, shouldShowPreChatSurveyPane, shouldShowProactiveChatPane, shouldShowReconnectChatPane, shouldShowWebChatContainer } from "../../../controller/componentController";
14
14
  import { ActivityStreamHandler } from "../common/ActivityStreamHandler";
15
15
  import CallingContainerStateful from "../../callingcontainerstateful/CallingContainerStateful";
16
16
  import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
@@ -51,9 +51,9 @@ import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
51
51
  import useChatContextStore from "../../../hooks/useChatContextStore";
52
52
  import useChatSDKStore from "../../../hooks/useChatSDKStore";
53
53
  import { defaultAdaptiveCardStyles } from "../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles";
54
- import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
54
+ import StartChatErrorPaneStateful from "../../startchaterrorpanestateful/StartChatErrorPaneStateful";
55
55
  export const LiveChatWidgetStateful = props => {
56
- var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$contro10, _livechatProps$compon8, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$compon11, _livechatProps$compon12;
56
+ var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
57
57
  const [state, dispatch] = useChatContextStore();
58
58
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
59
  const [adapter, setAdapter] = useChatAdapterStore();
@@ -186,6 +186,10 @@ export const LiveChatWidgetStateful = props => {
186
186
  };
187
187
  useEffect(() => {
188
188
  var _props$controlProps5, _props$controlProps6, _props$controlProps7, _props$chatConfig, _props$chatConfig$Liv, _props$controlProps9, _props$chatConfig2, _props$chatConfig2$Ch, _state$appStates5;
189
+ dispatch({
190
+ type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
191
+ payload: false
192
+ });
189
193
  state.domainStates.confirmationPaneConfirmedOptionClicked = false;
190
194
  state.domainStates.confirmationState = ConfirmationState.NotSet;
191
195
  setupClientDataStore();
@@ -425,12 +429,7 @@ export const LiveChatWidgetStateful = props => {
425
429
  if ((msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
426
430
  endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
427
431
  endChatStateCleanUp(dispatch);
428
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
429
- chatSDK.requestId = uuidv4();
430
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
431
- chatSDK.chatToken = {};
432
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
433
- chatSDK.reconnectId = null;
432
+ chatSDKStateCleanUp(chatSDK);
434
433
  return;
435
434
  }
436
435
  });
@@ -608,9 +607,7 @@ export const LiveChatWidgetStateful = props => {
608
607
 
609
608
  // Handle Chat disconnect cases
610
609
  useEffect(() => {
611
- if (state.appStates.chatDisconnectEventReceived) {
612
- handleChatDisconnect(props, state, setWebChatStyles);
613
- }
610
+ handleChatDisconnect(props, state, setWebChatStyles);
614
611
  }, [state.appStates.chatDisconnectEventReceived]);
615
612
  const initiateEndChatOnBrowserUnload = () => {
616
613
  var _DataStoreManager$cli;
@@ -707,17 +704,17 @@ export const LiveChatWidgetStateful = props => {
707
704
  }, headerDraggableConfig))), !((_livechatProps$contro5 = livechatProps.controlProps) !== null && _livechatProps$contro5 !== void 0 && _livechatProps$contro5.hideLoadingPane) && shouldShowLoadingPane(state) && (decodeComponentString((_livechatProps$compon4 = livechatProps.componentOverrides) === null || _livechatProps$compon4 === void 0 ? void 0 : _livechatProps$compon4.loadingPane) || /*#__PURE__*/React.createElement(LoadingPaneStateful, {
708
705
  loadingPaneProps: livechatProps.loadingPaneProps,
709
706
  startChatErrorPaneProps: livechatProps.startChatErrorPaneProps
710
- })), !((_livechatProps$contro6 = livechatProps.controlProps) !== null && _livechatProps$contro6 !== void 0 && _livechatProps$contro6.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_livechatProps$compon5 = livechatProps.componentOverrides) === null || _livechatProps$compon5 === void 0 ? void 0 : _livechatProps$compon5.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, livechatProps.outOfOfficeHoursPaneProps)), !((_livechatProps$contro7 = livechatProps.controlProps) !== null && _livechatProps$contro7 !== void 0 && _livechatProps$contro7.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_livechatProps$compon6 = livechatProps.componentOverrides) === null || _livechatProps$compon6 === void 0 ? void 0 : _livechatProps$compon6.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
707
+ })), !((_livechatProps$contro6 = livechatProps.controlProps) !== null && _livechatProps$contro6 !== void 0 && _livechatProps$contro6.hideErrorUIPane) && shouldShowStartChatErrorPane(state) && (decodeComponentString((_livechatProps$compon5 = livechatProps.componentOverrides) === null || _livechatProps$compon5 === void 0 ? void 0 : _livechatProps$compon5.startChatErrorPane) || /*#__PURE__*/React.createElement(StartChatErrorPaneStateful, livechatProps.startChatErrorPaneProps)), !((_livechatProps$contro7 = livechatProps.controlProps) !== null && _livechatProps$contro7 !== void 0 && _livechatProps$contro7.hideOutOfOfficeHoursPane) && shouldShowOutOfOfficeHoursPane(state) && (decodeComponentString((_livechatProps$compon6 = livechatProps.componentOverrides) === null || _livechatProps$compon6 === void 0 ? void 0 : _livechatProps$compon6.outOfOfficeHoursPane) || /*#__PURE__*/React.createElement(OutOfOfficeHoursPaneStateful, livechatProps.outOfOfficeHoursPaneProps)), !((_livechatProps$contro8 = livechatProps.controlProps) !== null && _livechatProps$contro8 !== void 0 && _livechatProps$contro8.hideReconnectChatPane) && shouldShowReconnectChatPane(state) && (decodeComponentString((_livechatProps$compon7 = livechatProps.componentOverrides) === null || _livechatProps$compon7 === void 0 ? void 0 : _livechatProps$compon7.reconnectChatPane) || /*#__PURE__*/React.createElement(ReconnectChatPaneStateful, {
711
708
  reconnectChatProps: livechatProps.reconnectChatPaneProps,
712
709
  initStartChat: initStartChatRelay
713
- })), !((_livechatProps$contro8 = livechatProps.controlProps) !== null && _livechatProps$contro8 !== void 0 && _livechatProps$contro8.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_livechatProps$compon7 = livechatProps.componentOverrides) === null || _livechatProps$compon7 === void 0 ? void 0 : _livechatProps$compon7.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
710
+ })), !((_livechatProps$contro9 = livechatProps.controlProps) !== null && _livechatProps$contro9 !== void 0 && _livechatProps$contro9.hidePreChatSurveyPane) && shouldShowPreChatSurveyPane(state) && (decodeComponentString((_livechatProps$compon8 = livechatProps.componentOverrides) === null || _livechatProps$compon8 === void 0 ? void 0 : _livechatProps$compon8.preChatSurveyPane) || /*#__PURE__*/React.createElement(PreChatSurveyPaneStateful, {
714
711
  surveyProps: livechatProps.preChatSurveyPaneProps,
715
712
  initStartChat: initStartChatRelay
716
- })), !((_livechatProps$contro9 = livechatProps.controlProps) !== null && _livechatProps$contro9 !== void 0 && _livechatProps$contro9.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
713
+ })), !((_livechatProps$contro10 = livechatProps.controlProps) !== null && _livechatProps$contro10 !== void 0 && _livechatProps$contro10.hideCallingContainer) && shouldShowCallingContainer(state) && /*#__PURE__*/React.createElement(CallingContainerStateful, _extends({
717
714
  voiceVideoCallingSdk: voiceVideoCallingSDK
718
- }, livechatProps.callingContainerProps)), !((_livechatProps$contro10 = livechatProps.controlProps) !== null && _livechatProps$contro10 !== void 0 && _livechatProps$contro10.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_livechatProps$compon8 = livechatProps.componentOverrides) === null || _livechatProps$compon8 === void 0 ? void 0 : _livechatProps$compon8.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, livechatProps)), !((_livechatProps$contro11 = livechatProps.controlProps) !== null && _livechatProps$contro11 !== void 0 && _livechatProps$contro11.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_livechatProps$compon9 = livechatProps.componentOverrides) === null || _livechatProps$compon9 === void 0 ? void 0 : _livechatProps$compon9.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
715
+ }, livechatProps.callingContainerProps)), !((_livechatProps$contro11 = livechatProps.controlProps) !== null && _livechatProps$contro11 !== void 0 && _livechatProps$contro11.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_livechatProps$compon9 = livechatProps.componentOverrides) === null || _livechatProps$compon9 === void 0 ? void 0 : _livechatProps$compon9.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, livechatProps)), !((_livechatProps$contro12 = livechatProps.controlProps) !== null && _livechatProps$contro12 !== void 0 && _livechatProps$contro12.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_livechatProps$compon10 = livechatProps.componentOverrides) === null || _livechatProps$compon10 === void 0 ? void 0 : _livechatProps$compon10.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
719
716
  setPostChatContext: setPostChatContextRelay,
720
717
  prepareEndChat: prepareEndChatRelay
721
- }))), !((_livechatProps$contro12 = livechatProps.controlProps) !== null && _livechatProps$contro12 !== void 0 && _livechatProps$contro12.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_livechatProps$compon10 = livechatProps.componentOverrides) === null || _livechatProps$compon10 === void 0 ? void 0 : _livechatProps$compon10.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, livechatProps.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK))), createFooter(livechatProps, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, livechatProps.emailTranscriptPane))))));
718
+ }))), !((_livechatProps$contro13 = livechatProps.controlProps) !== null && _livechatProps$contro13 !== void 0 && _livechatProps$contro13.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, livechatProps.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK))), createFooter(livechatProps, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_livechatProps$compon13 = livechatProps.componentOverrides) === null || _livechatProps$compon13 === void 0 ? void 0 : _livechatProps$compon13.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, livechatProps.emailTranscriptPane))))));
722
719
  };
723
720
  export default LiveChatWidgetStateful;
@@ -3,10 +3,10 @@ import React, { useEffect } from "react";
3
3
  import { LoadingPane } from "@microsoft/omnichannel-chat-components";
4
4
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
5
5
  import { defaultGeneralLoadingPaneStyleProps } from "./common/defaultStyleProps/defaultgeneralLoadingPaneStyleProps";
6
- import { errorUILoadingPaneStyleProps } from "./common/errorUIStyleProps/errorUILoadingPaneStyleProps";
7
6
  import { findAllFocusableElement } from "../../common/utils";
8
7
  import useChatContextStore from "../../hooks/useChatContextStore";
9
8
  import useWindowDimensions from "../../hooks/useWindowDimensions";
9
+ import { errorUILoadingPaneStyleProps } from "./common/errorUIStyleProps/errorUILoadingPaneStyleProps";
10
10
 
11
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
12
  export const LoadingPaneStateful = props => {
@@ -0,0 +1,57 @@
1
+ import React, { useEffect } from "react";
2
+ import { LoadingPane } from "@microsoft/omnichannel-chat-components";
3
+ import { findAllFocusableElement } from "../../common/utils";
4
+ import useChatContextStore from "../../hooks/useChatContextStore";
5
+ import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
6
+ import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
7
+ import { defaultStartChatErrorPaneGeneralStyleProps } from "./common/defaultStartChatErrorPaneGeneralStyleProps";
8
+ import { defaultStartChatErrorPaneTitleStyleProps } from "./common/defaultStartChatErrorPaneTitleStyleProps";
9
+ import { defaultStartChatErrorPaneSubtitleStyleProps } from "./common/defaultStartChatErrorPaneSubtitleStyleProps";
10
+ import { defaultStartChatErrorPaneIconStyleProps } from "./common/defaultStartChatErrorPaneIconStyleProps";
11
+ import { defaultStartChatErrorPaneIconImageStyleProps } from "./common/defaultStartChatErrorPaneIconImageProps";
12
+ import { StartChatErrorPaneConstants } from "../../common/Constants";
13
+ export const StartChatErrorPaneStateful = startChatErrorPaneProps => {
14
+ var _startChatErrorPanePr, _startChatErrorPanePr2, _startChatErrorPanePr3, _startChatErrorPanePr4, _startChatErrorPanePr5, _startChatErrorPanePr6, _startChatErrorPanePr7;
15
+ const [state] = useChatContextStore();
16
+ const generalStyleProps = Object.assign({}, defaultStartChatErrorPaneGeneralStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr === void 0 ? void 0 : _startChatErrorPanePr.generalStyleProps);
17
+ const titleStyleProps = Object.assign({}, defaultStartChatErrorPaneTitleStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr2 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr2 === void 0 ? void 0 : _startChatErrorPanePr2.titleStyleProps);
18
+ const subtitleStyleProps = Object.assign({}, defaultStartChatErrorPaneSubtitleStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr3 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr3 === void 0 ? void 0 : _startChatErrorPanePr3.subtitleStyleProps);
19
+ const iconStyleProps = Object.assign({}, defaultStartChatErrorPaneIconStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr4 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr4 === void 0 ? void 0 : _startChatErrorPanePr4.iconStyleProps);
20
+ const iconImageProps = Object.assign({}, defaultStartChatErrorPaneIconImageStyleProps, startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr5 = startChatErrorPaneProps.styleProps) === null || _startChatErrorPanePr5 === void 0 ? void 0 : _startChatErrorPanePr5.iconImageProps);
21
+ const errorUIStyleProps = {
22
+ generalStyleProps: generalStyleProps,
23
+ titleStyleProps: titleStyleProps,
24
+ subtitleStyleProps: subtitleStyleProps,
25
+ iconStyleProps: iconStyleProps,
26
+ iconImageProps: iconImageProps
27
+ };
28
+ const errorPaneTitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr6 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr6 === void 0 ? void 0 : _startChatErrorPanePr6.titleText) ?? StartChatErrorPaneConstants.DefaultStartChatErrorTitleText;
29
+ const errorPaneSubtitleText = (startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : (_startChatErrorPanePr7 = startChatErrorPaneProps.controlProps) === null || _startChatErrorPanePr7 === void 0 ? void 0 : _startChatErrorPanePr7.subtitleText) ?? StartChatErrorPaneConstants.DefaultStartChatErrorSubtitleText;
30
+ const errorUIControlProps = {
31
+ id: StartChatErrorPaneConstants.DefaultStartChatErrorPaneId,
32
+ dir: state.domainStates.globalDir,
33
+ titleText: errorPaneTitleText,
34
+ subtitleText: errorPaneSubtitleText,
35
+ hideSpinner: true,
36
+ hideSpinnerText: true,
37
+ ...(startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : startChatErrorPaneProps.controlProps)
38
+ };
39
+
40
+ // Move focus to the first button
41
+ useEffect(() => {
42
+ const firstElement = findAllFocusableElement(`#${state.domainStates.widgetElementId}`);
43
+ if (firstElement && firstElement[0]) {
44
+ firstElement[0].focus();
45
+ }
46
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
47
+ Event: TelemetryEvent.StartChatErrorPaneLoaded,
48
+ Description: "Start chat error pane loaded."
49
+ });
50
+ }, []);
51
+ return /*#__PURE__*/React.createElement(LoadingPane, {
52
+ componentOverrides: startChatErrorPaneProps === null || startChatErrorPaneProps === void 0 ? void 0 : startChatErrorPaneProps.componentOverrides,
53
+ controlProps: errorUIControlProps,
54
+ styleProps: errorUIStyleProps
55
+ });
56
+ };
57
+ export default StartChatErrorPaneStateful;
@@ -0,0 +1,10 @@
1
+ export const defaultStartChatErrorPaneGeneralStyleProps = {
2
+ position: "initial",
3
+ width: "100%",
4
+ height: "100%",
5
+ left: "0%",
6
+ top: "0%",
7
+ borderRadius: "0 0 4px 4px",
8
+ borderWidth: "0px",
9
+ backgroundColor: "#FFFFFF"
10
+ };
@@ -0,0 +1,10 @@
1
+ import { ImageFit } from "@fluentui/react";
2
+ import { AlertIcon } from "../../../assets/Icons";
3
+ export const defaultStartChatErrorPaneIconImageStyleProps = {
4
+ src: AlertIcon,
5
+ imageFit: ImageFit.centerContain,
6
+ width: "86px",
7
+ height: "86px",
8
+ shouldFadeIn: false,
9
+ shouldStartVisible: true
10
+ };
@@ -0,0 +1,8 @@
1
+ export const defaultStartChatErrorPaneIconStyleProps = {
2
+ display: "flex",
3
+ order: 1,
4
+ alignSelf: "auto",
5
+ backgroundColor: "#FFFFFF",
6
+ boxShadow: "#FFFFFF 0px 0px 0px 0px",
7
+ margin: "0px 0px 0px 0px"
8
+ };
@@ -0,0 +1,10 @@
1
+ export const defaultStartChatErrorPaneSubtitleStyleProps = {
2
+ fontFamily: "'Segoe UI',Arial,sans-serif",
3
+ fontWeight: "normal",
4
+ fontSize: "18px",
5
+ color: "#36454F",
6
+ textAlign: "center",
7
+ display: "flex",
8
+ order: 3,
9
+ alignSelf: "auto"
10
+ };
@@ -0,0 +1,10 @@
1
+ export const defaultStartChatErrorPaneTitleStyleProps = {
2
+ fontFamily: "'Segoe UI',Arial,sans-serif",
3
+ fontWeight: "normal",
4
+ fontSize: "18px",
5
+ color: "#36454F",
6
+ textAlign: "center",
7
+ display: "flex",
8
+ order: 2,
9
+ alignSelf: "auto"
10
+ };
@@ -11,7 +11,6 @@ import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/Teleme
11
11
  import { Constants } from "../../../../../common/Constants";
12
12
  import { DirectLineActivityType } from "../../enums/DirectLineActivityType";
13
13
  import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
14
- import { MessageTypes } from "../../enums/MessageType";
15
14
  import React from "react";
16
15
  import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
17
16
  import { defaultSystemMessageStyles } from "./defaultStyles/defaultSystemMessageStyles";
@@ -74,13 +73,6 @@ export const createActivityMiddleware = (systemMessageStyleProps, userMessageSty
74
73
  if (card.activity) {
75
74
  var _card$activity$from;
76
75
  if (((_card$activity$from = card.activity.from) === null || _card$activity$from === void 0 ? void 0 : _card$activity$from.role) === DirectLineSenderRole.Channel) {
77
- var _card$activity$channe3;
78
- if (((_card$activity$channe3 = card.activity.channelData) === null || _card$activity$channe3 === void 0 ? void 0 : _card$activity$channe3.type) === MessageTypes.Thread) {
79
- TelemetryHelper.logActionEvent(LogLevel.INFO, {
80
- Event: TelemetryEvent.IC3ThreadUpdateEventReceived,
81
- Description: "IC3 ThreadUpdateEvent Received"
82
- });
83
- }
84
76
  return () => false;
85
77
  }
86
78
  if (isTagIncluded(card, Constants.hiddenTag)) {
@@ -20,7 +20,7 @@ describe("activityMiddleware test", () => {
20
20
  };
21
21
  const results = createActivityMiddleware()()(next)(args);
22
22
  expect(results()).toEqual(false);
23
- expect(TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(1);
23
+ expect(TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(0);
24
24
  });
25
25
  it("createActivityMiddleware() with Hidden tag should return nothing", () => {
26
26
  spyOn(TelemetryHelper, "logActionEvent").and.callFake(() => false);
@@ -10,4 +10,5 @@ export let ConversationState;
10
10
  ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
11
11
  ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
12
12
  ConversationState[ConversationState["Closed"] = 9] = "Closed";
13
+ ConversationState[ConversationState["Error"] = 10] = "Error";
13
14
  })(ConversationState || (ConversationState = {}));
@@ -58,6 +58,7 @@ export const getLiveChatWidgetContextInitialState = props => {
58
58
  },
59
59
  uiStates: {
60
60
  showConfirmationPane: false,
61
+ showStartChatErrorPane: false,
61
62
  showEmailTranscriptPane: false,
62
63
  showCallingPopup: false,
63
64
  isIncomingCall: true,
@@ -22,6 +22,9 @@ export const shouldShowWebChatContainer = state => {
22
22
  export const shouldShowLoadingPane = state => {
23
23
  return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Loading;
24
24
  };
25
+ export const shouldShowStartChatErrorPane = state => {
26
+ return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Error;
27
+ };
25
28
  export const shouldShowReconnectChatPane = state => {
26
29
  return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.ReconnectChat;
27
30
  };
@@ -160,10 +160,6 @@ export declare class LocaleConstants {
160
160
  export declare enum ElementType {
161
161
  CallingContainerSDK = "CallingContainerSDK"
162
162
  }
163
- export declare enum ChatSDKError {
164
- WidgetUseOutsideOperatingHour = "WidgetUseOutsideOperatingHour",
165
- AuthContactIdNotFoundFailure = "AuthContactIdNotFoundFailure"
166
- }
167
163
  export declare enum EnvironmentVersion {
168
164
  prod = "prod",
169
165
  dogfood = "df",
@@ -231,6 +227,11 @@ export declare class NotificationPaneConstants {
231
227
  static readonly ChatDisconnectSubtitleText = "For additional assistance, please close the chat and try again.";
232
228
  static readonly ChromeCloseIconName = "ChromeClose";
233
229
  }
230
+ export declare class StartChatErrorPaneConstants {
231
+ static readonly DefaultStartChatErrorPaneId = "oc-lcw-start-chat-error-pane";
232
+ static readonly DefaultStartChatErrorTitleText = "We are unable to load chat at this time.";
233
+ static readonly DefaultStartChatErrorSubtitleText = "Please try again later.";
234
+ }
234
235
  export declare class AriaTelemetryConstants {
235
236
  static readonly GERMANY_ENDPOINT: string;
236
237
  static readonly GCCH_ENDPOINT: string;
@@ -241,3 +242,11 @@ export declare class AriaTelemetryConstants {
241
242
  static readonly EU: string;
242
243
  static readonly lcwEUDomainNames: Array<string>;
243
244
  }
245
+ export declare class WidgetLoadTelemetryMessage {
246
+ static readonly OOOHMessage = "Widget is OOOH";
247
+ static readonly PersistedStateRetrievedMessage = "Persisted state retrieved";
248
+ }
249
+ export declare class WidgetLoadCustomErrorString {
250
+ static readonly AuthenticationFailedErrorString = "Authentication was not successful";
251
+ static readonly NetworkErrorString = "Network Error";
252
+ }
@@ -120,10 +120,10 @@ export declare enum TelemetryEvent {
120
120
  ErrorUIPaneLoaded = "ErrorUIPaneLoaded",
121
121
  DownloadTranscriptFailed = "DownloadTranscriptFailed",
122
122
  StartChatFailed = "StartChatFailed",
123
- IC3ThreadUpdateEventReceived = "IC3ThreadUpdateEventReceived",
124
123
  ConfirmationCancelButtonClicked = "ConfirmationCancelButtonClicked",
125
124
  ConfirmationConfirmButtonClicked = "ConfirmationConfirmButtonClicked",
126
125
  LoadingPaneLoaded = "LoadingPaneLoaded",
126
+ StartChatErrorPaneLoaded = "StartChatErrorPaneLoaded",
127
127
  EmailTranscriptLoaded = "EmailTranscriptLoaded",
128
128
  OutOfOfficePaneLoaded = "OutOfOfficePaneLoaded",
129
129
  ConfirmationPaneLoaded = "ConfirmationPaneLoaded",