@microsoft/omnichannel-chat-widget 1.5.1-main.c3533cf → 1.5.1-main.e2be12d
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.
- package/lib/cjs/common/Constants.js +10 -8
- package/lib/cjs/common/telemetry/TelemetryConstants.js +0 -2
- package/lib/cjs/common/utils.js +2 -1
- package/lib/cjs/components/livechatwidget/common/endChat.js +16 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +8 -82
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +198 -0
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.spec.js +282 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +1 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +0 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
- package/lib/esm/common/Constants.js +7 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +0 -2
- package/lib/esm/common/utils.js +3 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +14 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +9 -83
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +191 -0
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.spec.js +280 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +2 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +0 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.spec.js +1 -1
- package/lib/types/common/Constants.d.ts +8 -4
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +0 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.spec.d.ts +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
4
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
5
|
+
var _startChatErrorHandler = require("./startChatErrorHandler");
|
|
6
|
+
var _Constants = require("../../../common/Constants");
|
|
7
|
+
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
|
+
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
9
|
+
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
10
|
+
describe("startChatErrorHandler unit test", () => {
|
|
11
|
+
it("handleStartChatError should log failed event and return if exception is undefined", () => {
|
|
12
|
+
const dispatch = jest.fn();
|
|
13
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
14
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
15
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, undefined, false);
|
|
16
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
17
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
18
|
+
ExceptionDetails: expect.objectContaining({
|
|
19
|
+
Exception: "Widget load complete with error: undefined"
|
|
20
|
+
})
|
|
21
|
+
}));
|
|
22
|
+
expect(dispatch).not.toHaveBeenCalled();
|
|
23
|
+
});
|
|
24
|
+
it("handleStartChatError should log failed with error event for AuthenticationFailedErrorString", () => {
|
|
25
|
+
const dispatch = jest.fn();
|
|
26
|
+
const mockEx = new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
27
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
28
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
29
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
30
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
31
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
32
|
+
ExceptionDetails: expect.objectContaining({
|
|
33
|
+
Exception: `Widget load complete with error: Error: ${_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString}`
|
|
34
|
+
})
|
|
35
|
+
}));
|
|
36
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
37
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
38
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
it("handleStartChatError should log failed with error event for NetworkErrorString", () => {
|
|
42
|
+
const dispatch = jest.fn();
|
|
43
|
+
const mockEx = new Error(_Constants.WidgetLoadCustomErrorString.NetworkErrorString);
|
|
44
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
45
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
46
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
47
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
48
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
49
|
+
ExceptionDetails: expect.objectContaining({
|
|
50
|
+
Exception: `Widget load complete with error: Error: ${_Constants.WidgetLoadCustomErrorString.NetworkErrorString}`
|
|
51
|
+
})
|
|
52
|
+
}));
|
|
53
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
54
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
55
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
56
|
+
}));
|
|
57
|
+
});
|
|
58
|
+
it("handleStartChatError should log complete event for WidgetUseOutsideOperatingHour", () => {
|
|
59
|
+
const dispatch = jest.fn();
|
|
60
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.WidgetUseOutsideOperatingHour);
|
|
61
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
62
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
63
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
64
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
65
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("INFO", expect.objectContaining({
|
|
66
|
+
Description: `Widget load complete. ${_Constants.WidgetLoadTelemetryMessage.OOOHMessage}`
|
|
67
|
+
}));
|
|
68
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
69
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
70
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
71
|
+
}));
|
|
72
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
73
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS
|
|
74
|
+
}));
|
|
75
|
+
});
|
|
76
|
+
it("handleStartChatError should log failed with error event for PersistentChatConversationRetrievalFailure for non-400 status", () => {
|
|
77
|
+
const dispatch = jest.fn();
|
|
78
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure, 429);
|
|
79
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
80
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
81
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
82
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
83
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
84
|
+
Description: "Widget load complete with error",
|
|
85
|
+
ExceptionDetails: expect.objectContaining({
|
|
86
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure}`,
|
|
87
|
+
HttpResponseStatusCode: 429
|
|
88
|
+
})
|
|
89
|
+
}));
|
|
90
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
91
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
92
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
93
|
+
}));
|
|
94
|
+
});
|
|
95
|
+
it("handleStartChatError should log failed event for PersistentChatConversationRetrievalFailure for 400 status", () => {
|
|
96
|
+
const dispatch = jest.fn();
|
|
97
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure, 400);
|
|
98
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
99
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
100
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
101
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
102
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
103
|
+
ExceptionDetails: expect.objectContaining({
|
|
104
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.PersistentChatConversationRetrievalFailure}`,
|
|
105
|
+
HttpResponseStatusCode: 400
|
|
106
|
+
})
|
|
107
|
+
}));
|
|
108
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
109
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
110
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
111
|
+
}));
|
|
112
|
+
});
|
|
113
|
+
it("handleStartChatError should log failed with error event for ConversationInitializationFailure for non-400 status", () => {
|
|
114
|
+
const dispatch = jest.fn();
|
|
115
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure, 429);
|
|
116
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
117
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
118
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
119
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
120
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
121
|
+
Description: "Widget load complete with error",
|
|
122
|
+
ExceptionDetails: expect.objectContaining({
|
|
123
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure}`,
|
|
124
|
+
HttpResponseStatusCode: 429
|
|
125
|
+
})
|
|
126
|
+
}));
|
|
127
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
128
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
129
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
130
|
+
}));
|
|
131
|
+
});
|
|
132
|
+
it("handleStartChatError should log failed event for ConversationInitializationFailure for 400 status", () => {
|
|
133
|
+
const dispatch = jest.fn();
|
|
134
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure, 400);
|
|
135
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
136
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
137
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
138
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
139
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
140
|
+
ExceptionDetails: expect.objectContaining({
|
|
141
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ConversationInitializationFailure}`,
|
|
142
|
+
HttpResponseStatusCode: 400
|
|
143
|
+
})
|
|
144
|
+
}));
|
|
145
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
146
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
147
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
148
|
+
}));
|
|
149
|
+
});
|
|
150
|
+
it("handleStartChatError should log failed with error event for ChatTokenRetrievalFailure for non-400 status", () => {
|
|
151
|
+
const dispatch = jest.fn();
|
|
152
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure, 429);
|
|
153
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
154
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
155
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
156
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
157
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
158
|
+
Description: "Widget load complete with error",
|
|
159
|
+
ExceptionDetails: expect.objectContaining({
|
|
160
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure}`,
|
|
161
|
+
HttpResponseStatusCode: 429
|
|
162
|
+
})
|
|
163
|
+
}));
|
|
164
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
165
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
166
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
167
|
+
}));
|
|
168
|
+
});
|
|
169
|
+
it("handleStartChatError should log failed event for ChatTokenRetrievalFailure for 400 status", () => {
|
|
170
|
+
const dispatch = jest.fn();
|
|
171
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure, 400);
|
|
172
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
173
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
174
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
175
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
176
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
177
|
+
ExceptionDetails: expect.objectContaining({
|
|
178
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ChatTokenRetrievalFailure}`,
|
|
179
|
+
HttpResponseStatusCode: 400
|
|
180
|
+
})
|
|
181
|
+
}));
|
|
182
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
183
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
184
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
185
|
+
}));
|
|
186
|
+
});
|
|
187
|
+
it("handleStartChatError should log failed with error event for UninitializedChatSDK", () => {
|
|
188
|
+
const dispatch = jest.fn();
|
|
189
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK);
|
|
190
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
191
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
192
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
193
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
194
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
195
|
+
Description: "Widget load complete with error",
|
|
196
|
+
ExceptionDetails: expect.objectContaining({
|
|
197
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK}`
|
|
198
|
+
})
|
|
199
|
+
}));
|
|
200
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
201
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
202
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
203
|
+
}));
|
|
204
|
+
});
|
|
205
|
+
it("handleStartChatError should log failed with error event for InvalidConversation", () => {
|
|
206
|
+
const dispatch = jest.fn();
|
|
207
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.InvalidConversation);
|
|
208
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
209
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
210
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
211
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
212
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
213
|
+
Description: "Widget load complete with error",
|
|
214
|
+
ExceptionDetails: expect.objectContaining({
|
|
215
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.InvalidConversation}`
|
|
216
|
+
})
|
|
217
|
+
}));
|
|
218
|
+
expect(dispatch).toHaveBeenCalledTimes(16);
|
|
219
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
220
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
221
|
+
payload: _ConversationState.ConversationState.Closed
|
|
222
|
+
}));
|
|
223
|
+
});
|
|
224
|
+
it("handleStartChatError should log failed with error event for ClosedConversation", () => {
|
|
225
|
+
const dispatch = jest.fn();
|
|
226
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ClosedConversation);
|
|
227
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
228
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
229
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
230
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(1);
|
|
231
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("WARN", expect.objectContaining({
|
|
232
|
+
Description: "Widget load complete with error",
|
|
233
|
+
ExceptionDetails: expect.objectContaining({
|
|
234
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ClosedConversation}`
|
|
235
|
+
})
|
|
236
|
+
}));
|
|
237
|
+
expect(dispatch).toHaveBeenCalledTimes(16);
|
|
238
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
239
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
240
|
+
payload: _ConversationState.ConversationState.Closed
|
|
241
|
+
}));
|
|
242
|
+
});
|
|
243
|
+
it("handleStartChatError should log failed event for any other errors", () => {
|
|
244
|
+
const dispatch = jest.fn();
|
|
245
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure, 405);
|
|
246
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
247
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
248
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, {}, {}, mockEx, false);
|
|
249
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(2);
|
|
250
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
251
|
+
ExceptionDetails: expect.objectContaining({
|
|
252
|
+
Exception: `Widget load complete with error: ${_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure}`,
|
|
253
|
+
HttpResponseStatusCode: 405
|
|
254
|
+
})
|
|
255
|
+
}));
|
|
256
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
257
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
258
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
259
|
+
}));
|
|
260
|
+
});
|
|
261
|
+
it("handleStartChatError should force end chat if isStartChatSuccessful is true", () => {
|
|
262
|
+
const dispatch = jest.fn();
|
|
263
|
+
const mockEx = new _omnichannelChatSdk.ChatSDKError(_omnichannelChatSdk.ChatSDKErrorName.ScriptLoadFailure, 405);
|
|
264
|
+
const mockSDK = {
|
|
265
|
+
endChat: jest.fn()
|
|
266
|
+
};
|
|
267
|
+
spyOn(_omnichannelChatComponents.BroadcastService, "postMessage").and.callFake(() => false);
|
|
268
|
+
spyOn(_TelemetryHelper.TelemetryHelper, "logLoadingEvent").and.callFake(() => false);
|
|
269
|
+
(0, _startChatErrorHandler.handleStartChatError)(dispatch, mockSDK, {}, mockEx, true);
|
|
270
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledTimes(3);
|
|
271
|
+
expect(_TelemetryHelper.TelemetryHelper.logLoadingEvent).toHaveBeenCalledWith("ERROR", expect.objectContaining({
|
|
272
|
+
ExceptionDetails: expect.objectContaining({
|
|
273
|
+
Exception: "SessionInit was successful, but widget load failed."
|
|
274
|
+
})
|
|
275
|
+
}));
|
|
276
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
277
|
+
expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({
|
|
278
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE
|
|
279
|
+
}));
|
|
280
|
+
expect(mockSDK.endChat).toHaveBeenCalled();
|
|
281
|
+
});
|
|
282
|
+
});
|
|
@@ -55,7 +55,6 @@ var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useCha
|
|
|
55
55
|
var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
|
|
56
56
|
var _useChatSDKStore = _interopRequireDefault(require("../../../hooks/useChatSDKStore"));
|
|
57
57
|
var _defaultAdaptiveCardStyles = require("../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles");
|
|
58
|
-
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
59
58
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
60
59
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
61
60
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -433,12 +432,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
433
432
|
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload9 = msg.payload) === null || _msg$payload9 === void 0 ? void 0 : _msg$payload9.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
434
433
|
(0, _endChat.endChat)(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, true, false, false);
|
|
435
434
|
(0, _endChat.endChatStateCleanUp)(dispatch);
|
|
436
|
-
|
|
437
|
-
chatSDK.requestId = (0, _omnichannelChatSdk.uuidv4)();
|
|
438
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
439
|
-
chatSDK.chatToken = {};
|
|
440
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
441
|
-
chatSDK.reconnectId = null;
|
|
435
|
+
(0, _endChat.chatSDKStateCleanUp)(chatSDK);
|
|
442
436
|
return;
|
|
443
437
|
}
|
|
444
438
|
});
|
|
@@ -8,7 +8,6 @@ var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryCons
|
|
|
8
8
|
var _Constants = require("../../../../../common/Constants");
|
|
9
9
|
var _DirectLineActivityType = require("../../enums/DirectLineActivityType");
|
|
10
10
|
var _DirectLineSenderRole = require("../../enums/DirectLineSenderRole");
|
|
11
|
-
var _MessageType = require("../../enums/MessageType");
|
|
12
11
|
var _react = _interopRequireDefault(require("react"));
|
|
13
12
|
var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
|
|
14
13
|
var _defaultSystemMessageStyles = require("./defaultStyles/defaultSystemMessageStyles");
|
|
@@ -81,13 +80,6 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
|
|
|
81
80
|
if (card.activity) {
|
|
82
81
|
var _card$activity$from;
|
|
83
82
|
if (((_card$activity$from = card.activity.from) === null || _card$activity$from === void 0 ? void 0 : _card$activity$from.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel) {
|
|
84
|
-
var _card$activity$channe3;
|
|
85
|
-
if (((_card$activity$channe3 = card.activity.channelData) === null || _card$activity$channe3 === void 0 ? void 0 : _card$activity$channe3.type) === _MessageType.MessageTypes.Thread) {
|
|
86
|
-
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
87
|
-
Event: _TelemetryConstants.TelemetryEvent.IC3ThreadUpdateEventReceived,
|
|
88
|
-
Description: "IC3 ThreadUpdateEvent Received"
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
83
|
return () => false;
|
|
92
84
|
}
|
|
93
85
|
if (isTagIncluded(card, _Constants.Constants.hiddenTag)) {
|
|
@@ -22,7 +22,7 @@ describe("activityMiddleware test", () => {
|
|
|
22
22
|
};
|
|
23
23
|
const results = (0, _activityMiddleware.createActivityMiddleware)()()(next)(args);
|
|
24
24
|
expect(results()).toEqual(false);
|
|
25
|
-
expect(_TelemetryHelper.TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(
|
|
25
|
+
expect(_TelemetryHelper.TelemetryHelper.logActionEvent).toHaveBeenCalledTimes(0);
|
|
26
26
|
});
|
|
27
27
|
it("createActivityMiddleware() with Hidden tag should return nothing", () => {
|
|
28
28
|
spyOn(_TelemetryHelper.TelemetryHelper, "logActionEvent").and.callFake(() => false);
|
|
@@ -174,11 +174,6 @@ export let ElementType;
|
|
|
174
174
|
(function (ElementType) {
|
|
175
175
|
ElementType["CallingContainerSDK"] = "CallingContainerSDK";
|
|
176
176
|
})(ElementType || (ElementType = {}));
|
|
177
|
-
export let ChatSDKError;
|
|
178
|
-
(function (ChatSDKError) {
|
|
179
|
-
ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
|
|
180
|
-
ChatSDKError["AuthContactIdNotFoundFailure"] = "AuthContactIdNotFoundFailure";
|
|
181
|
-
})(ChatSDKError || (ChatSDKError = {}));
|
|
182
177
|
export let EnvironmentVersion;
|
|
183
178
|
(function (EnvironmentVersion) {
|
|
184
179
|
EnvironmentVersion["prod"] = "prod";
|
|
@@ -265,4 +260,10 @@ _defineProperty(AriaTelemetryConstants, "MOONCAKE_ENDPOINT", "");
|
|
|
265
260
|
_defineProperty(AriaTelemetryConstants, "Public", "Public");
|
|
266
261
|
_defineProperty(AriaTelemetryConstants, "EU", "Europe");
|
|
267
262
|
// EUR: crm4; FRA: crm12; GER: crm16; CHE: crm17; NOR: crm19
|
|
268
|
-
_defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
|
|
263
|
+
_defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);
|
|
264
|
+
export class WidgetLoadTelemetryMessage {}
|
|
265
|
+
_defineProperty(WidgetLoadTelemetryMessage, "OOOHMessage", "Widget is OOOH");
|
|
266
|
+
_defineProperty(WidgetLoadTelemetryMessage, "PersistedStateRetrievedMessage", "Persisted state retrieved");
|
|
267
|
+
export class WidgetLoadCustomErrorString {}
|
|
268
|
+
_defineProperty(WidgetLoadCustomErrorString, "AuthenticationFailedErrorString", "Authentication was not successful");
|
|
269
|
+
_defineProperty(WidgetLoadCustomErrorString, "NetworkErrorString", "Network Error");
|
|
@@ -127,7 +127,6 @@ export let TelemetryEvent;
|
|
|
127
127
|
TelemetryEvent["ErrorUIPaneLoaded"] = "ErrorUIPaneLoaded";
|
|
128
128
|
TelemetryEvent["DownloadTranscriptFailed"] = "DownloadTranscriptFailed";
|
|
129
129
|
TelemetryEvent["StartChatFailed"] = "StartChatFailed";
|
|
130
|
-
TelemetryEvent["IC3ThreadUpdateEventReceived"] = "IC3ThreadUpdateEventReceived";
|
|
131
130
|
TelemetryEvent["ConfirmationCancelButtonClicked"] = "ConfirmationCancelButtonClicked";
|
|
132
131
|
TelemetryEvent["ConfirmationConfirmButtonClicked"] = "ConfirmationConfirmButtonClicked";
|
|
133
132
|
TelemetryEvent["LoadingPaneLoaded"] = "LoadingPaneLoaded";
|
|
@@ -244,7 +243,6 @@ export class TelemetryConstants {
|
|
|
244
243
|
case TelemetryEvent.EmailTranscriptSent:
|
|
245
244
|
case TelemetryEvent.EmailTranscriptFailed:
|
|
246
245
|
case TelemetryEvent.DownloadTranscriptFailed:
|
|
247
|
-
case TelemetryEvent.IC3ThreadUpdateEventReceived:
|
|
248
246
|
case TelemetryEvent.ConfirmationCancelButtonClicked:
|
|
249
247
|
case TelemetryEvent.ConfirmationConfirmButtonClicked:
|
|
250
248
|
case TelemetryEvent.PreChatSurveyStartChatMethodFailed:
|
package/lib/esm/common/utils.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
var _this = this;
|
|
2
|
-
import { AriaTelemetryConstants,
|
|
2
|
+
import { AriaTelemetryConstants, Constants, HtmlAttributeNames, LocaleConstants } from "./Constants";
|
|
3
3
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "./telemetry/TelemetryConstants";
|
|
4
4
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
5
5
|
import { DataStoreManager } from "./contextDataStore/DataStoreManager";
|
|
6
6
|
import { KeyCodes } from "./KeyCodes";
|
|
7
7
|
import { Md5 } from "md5-typescript";
|
|
8
8
|
import { TelemetryHelper } from "./telemetry/TelemetryHelper";
|
|
9
|
+
import { ChatSDKErrorName } from "@microsoft/omnichannel-chat-sdk";
|
|
9
10
|
const getElementBySelector = selector => {
|
|
10
11
|
let element;
|
|
11
12
|
if (typeof selector === "string") {
|
|
@@ -373,7 +374,7 @@ export const getConversationDetailsCall = async chatSDK => {
|
|
|
373
374
|
|
|
374
375
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
375
376
|
export const checkContactIdError = e => {
|
|
376
|
-
if ((e === null || e === void 0 ? void 0 : e.message) ===
|
|
377
|
+
if ((e === null || e === void 0 ? void 0 : e.message) === ChatSDKErrorName.AuthContactIdNotFoundFailure) {
|
|
377
378
|
const contactIdNotFoundErrorEvent = {
|
|
378
379
|
eventName: BroadcastEvent.ContactIdNotFound,
|
|
379
380
|
payload: {
|
|
@@ -10,6 +10,7 @@ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
|
10
10
|
import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
|
|
11
11
|
import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
|
|
12
12
|
import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
|
|
13
|
+
import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
|
|
13
14
|
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
16
|
const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
|
|
@@ -145,7 +146,7 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
|
|
|
145
146
|
});
|
|
146
147
|
}
|
|
147
148
|
};
|
|
148
|
-
export const callingStateCleanUp =
|
|
149
|
+
export const callingStateCleanUp = dispatch => {
|
|
149
150
|
dispatch({
|
|
150
151
|
type: LiveChatWidgetActionType.SHOW_CALLING_CONTAINER,
|
|
151
152
|
payload: false
|
|
@@ -167,7 +168,7 @@ export const callingStateCleanUp = async dispatch => {
|
|
|
167
168
|
payload: true
|
|
168
169
|
});
|
|
169
170
|
};
|
|
170
|
-
export const endChatStateCleanUp =
|
|
171
|
+
export const endChatStateCleanUp = dispatch => {
|
|
171
172
|
// Need to clear these states immediately when chat ended from OC.
|
|
172
173
|
dispatch({
|
|
173
174
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
@@ -182,7 +183,7 @@ export const endChatStateCleanUp = async dispatch => {
|
|
|
182
183
|
payload: false
|
|
183
184
|
});
|
|
184
185
|
};
|
|
185
|
-
export const closeChatStateCleanUp =
|
|
186
|
+
export const closeChatStateCleanUp = dispatch => {
|
|
186
187
|
dispatch({
|
|
187
188
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
188
189
|
payload: undefined
|
|
@@ -218,6 +219,16 @@ export const closeChatStateCleanUp = async dispatch => {
|
|
|
218
219
|
});
|
|
219
220
|
};
|
|
220
221
|
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
223
|
+
export const chatSDKStateCleanUp = chatSDK => {
|
|
224
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
225
|
+
chatSDK.requestId = uuidv4();
|
|
226
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
227
|
+
chatSDK.chatToken = {};
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
+
chatSDK.reconnectId = null;
|
|
230
|
+
};
|
|
231
|
+
|
|
221
232
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
222
233
|
export const endVoiceVideoCallIfOngoing = async (chatSDK, dispatch) => {
|
|
223
234
|
let callId = "";
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import {
|
|
2
|
+
import { Constants, LiveWorkItemState, WidgetLoadCustomErrorString, WidgetLoadTelemetryMessage } from "../../../common/Constants";
|
|
3
3
|
import { checkContactIdError, createTimer, getConversationDetailsCall, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
4
4
|
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
5
5
|
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
6
6
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
7
7
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
8
8
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
9
|
-
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
10
|
-
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
11
9
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
12
10
|
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
13
11
|
import { createAdapter } from "./createAdapter";
|
|
@@ -15,7 +13,8 @@ import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEv
|
|
|
15
13
|
import { handleChatReconnect, isPersistentEnabled, isReconnectEnabled } from "./reconnectChatHelper";
|
|
16
14
|
import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
|
|
17
15
|
import { updateSessionDataForTelemetry } from "./updateSessionDataForTelemetry";
|
|
18
|
-
import {
|
|
16
|
+
import { logWidgetLoadComplete, handleStartChatError } from "./startChatErrorHandler";
|
|
17
|
+
import { chatSDKStateCleanUp } from "./endChat";
|
|
19
18
|
|
|
20
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
20
|
let optionalParams = {};
|
|
@@ -108,19 +107,15 @@ const setPreChatAndInitiateChat = async (chatSDK, dispatch, setAdapter, isProact
|
|
|
108
107
|
|
|
109
108
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
109
|
const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params, persistedState) => {
|
|
111
|
-
var _props$controlProps2;
|
|
112
110
|
let isStartChatSuccessful = false;
|
|
113
111
|
const chatConfig = props === null || props === void 0 ? void 0 : props.chatConfig;
|
|
114
112
|
const getAuthToken = props === null || props === void 0 ? void 0 : props.getAuthToken;
|
|
115
|
-
const hideErrorUIPane = props === null || props === void 0 ? void 0 : (_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.hideErrorUIPane;
|
|
116
113
|
if ((state === null || state === void 0 ? void 0 : state.appStates.conversationState) === ConversationState.Closed) {
|
|
117
114
|
// Preventive reset to avoid starting chat with previous requestId which could potentially cause problems
|
|
118
|
-
chatSDK
|
|
119
|
-
chatSDK.chatToken = {};
|
|
120
|
-
chatSDK.reconnectId = null;
|
|
115
|
+
chatSDKStateCleanUp(chatSDK);
|
|
121
116
|
}
|
|
122
117
|
try {
|
|
123
|
-
var _state$appStates, _newAdapter$activity
|
|
118
|
+
var _state$appStates, _newAdapter$activity$;
|
|
124
119
|
// Clear disconnect state on start chat
|
|
125
120
|
(state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.chatDisconnectEventReceived) && dispatch({
|
|
126
121
|
type: LiveChatWidgetActionType.SET_CHAT_DISCONNECT_EVENT_RECEIVED,
|
|
@@ -138,8 +133,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
138
133
|
// set auth token to chat sdk before start chat
|
|
139
134
|
const authSuccess = await handleAuthentication(chatSDK, chatConfig, getAuthToken);
|
|
140
135
|
if (!authSuccess) {
|
|
141
|
-
|
|
142
|
-
throw new Error("Authentication was not successful");
|
|
136
|
+
throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
143
137
|
}
|
|
144
138
|
}
|
|
145
139
|
|
|
@@ -202,16 +196,11 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
202
196
|
});
|
|
203
197
|
}
|
|
204
198
|
if (persistedState) {
|
|
205
|
-
var _TelemetryTimers$Widg;
|
|
206
199
|
dispatch({
|
|
207
200
|
type: LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
208
201
|
payload: persistedState
|
|
209
202
|
});
|
|
210
|
-
|
|
211
|
-
Event: TelemetryEvent.WidgetLoadComplete,
|
|
212
|
-
Description: "Widget load complete. Persisted state retrieved",
|
|
213
|
-
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
214
|
-
});
|
|
203
|
+
logWidgetLoadComplete(WidgetLoadTelemetryMessage.PersistedStateRetrievedMessage);
|
|
215
204
|
await setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
216
205
|
return;
|
|
217
206
|
}
|
|
@@ -222,11 +211,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
222
211
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
223
212
|
payload: liveChatContext
|
|
224
213
|
});
|
|
225
|
-
|
|
226
|
-
Event: TelemetryEvent.WidgetLoadComplete,
|
|
227
|
-
Description: "Widget load complete",
|
|
228
|
-
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg2 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg2 === void 0 ? void 0 : _TelemetryTimers$Widg2.milliSecondsElapsed
|
|
229
|
-
});
|
|
214
|
+
logWidgetLoadComplete();
|
|
230
215
|
|
|
231
216
|
// Set post chat context in state
|
|
232
217
|
// Commenting this for now as post chat context is fetched during end chat
|
|
@@ -235,72 +220,13 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
235
220
|
// Updating chat session detail for telemetry
|
|
236
221
|
await updateSessionDataForTelemetry(chatSDK, dispatch);
|
|
237
222
|
} catch (ex) {
|
|
238
|
-
|
|
239
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
|
-
if (ex.message === ChatSDKError.WidgetUseOutsideOperatingHour) {
|
|
241
|
-
var _TelemetryTimers$Widg3;
|
|
242
|
-
dispatch({
|
|
243
|
-
type: LiveChatWidgetActionType.SET_OUTSIDE_OPERATING_HOURS,
|
|
244
|
-
payload: true
|
|
245
|
-
});
|
|
246
|
-
dispatch({
|
|
247
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
248
|
-
payload: ConversationState.OutOfOffice
|
|
249
|
-
});
|
|
250
|
-
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
251
|
-
Event: TelemetryEvent.WidgetLoadComplete,
|
|
252
|
-
Description: "Widget load complete. Widget is OOOH.",
|
|
253
|
-
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
254
|
-
});
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
258
|
-
Event: TelemetryEvent.WidgetLoadFailed,
|
|
259
|
-
ExceptionDetails: {
|
|
260
|
-
Exception: `Widget load Failed: ${ex}`
|
|
261
|
-
},
|
|
262
|
-
ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
|
|
263
|
-
});
|
|
264
|
-
NotificationHandler.notifyError(NotificationScenarios.Connection, "Start Chat Failed: " + ex);
|
|
265
|
-
dispatch({
|
|
266
|
-
type: LiveChatWidgetActionType.SET_START_CHAT_FAILING,
|
|
267
|
-
payload: true
|
|
268
|
-
});
|
|
269
|
-
if (!hideErrorUIPane) {
|
|
270
|
-
// Set app state to failing start chat if hideErrorUI is not turned on
|
|
271
|
-
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
272
|
-
Event: TelemetryEvent.ErrorUIPaneLoaded,
|
|
273
|
-
Description: "Error UI Pane Loaded"
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
// Show the loading pane in other cases for failure, this will help for both hideStartChatButton case
|
|
277
|
-
dispatch({
|
|
278
|
-
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
279
|
-
payload: ConversationState.Loading
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
// If sessionInit was successful but LCW startchat failed due to some reason e.g adapter didn't load
|
|
283
|
-
// we need to directly endChat to avoid leaving ghost chats in OC, not disturbing any other UI state
|
|
284
|
-
if (isStartChatSuccessful === true) {
|
|
285
|
-
await forceEndChat(chatSDK);
|
|
286
|
-
}
|
|
223
|
+
handleStartChatError(dispatch, chatSDK, props, ex, isStartChatSuccessful);
|
|
287
224
|
} finally {
|
|
288
225
|
optionalParams = {};
|
|
289
226
|
widgetInstanceId = "";
|
|
290
227
|
}
|
|
291
228
|
};
|
|
292
229
|
|
|
293
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
294
|
-
const forceEndChat = async chatSDK => {
|
|
295
|
-
TelemetryHelper.logLoadingEvent(LogLevel.ERROR, {
|
|
296
|
-
Event: TelemetryEvent.WidgetLoadFailed,
|
|
297
|
-
ExceptionDetails: {
|
|
298
|
-
Exception: "SessionInit was successful, but widget load failed."
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat();
|
|
302
|
-
};
|
|
303
|
-
|
|
304
230
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
305
231
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
306
232
|
var _state$appStates2, _persistedState$domai6, _persistedState$appSt;
|