Skip to content

Commit 94b21c4

Browse files
authored
ref(feedback): Remove almost duplicate sendFeedback rejection message (#17297)
Noticed this by chance, this is a redundant message (we also use this as general fallback anyhow). The two messages have been: ``` Unable to send Feedback. This is because of network issues, or because you are using an ad-blocker. Unable to send Feedback. This could be because of network issues, or because you are using an ad-blocker ``` Which are virtually identical. We can safe some bytes there IMHO.
1 parent ffa8dd8 commit 94b21c4

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

packages/feedback/src/core/sendFeedback.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,18 @@ export const sendFeedback: SendFeedback = (
4646
cleanup();
4747

4848
// Require valid status codes, otherwise can assume feedback was not sent successfully
49-
if (
50-
response &&
51-
typeof response.statusCode === 'number' &&
52-
response.statusCode >= 200 &&
53-
response.statusCode < 300
54-
) {
49+
if (response?.statusCode && response.statusCode >= 200 && response.statusCode < 300) {
5550
return resolve(eventId);
5651
}
5752

58-
if (response && typeof response.statusCode === 'number' && response.statusCode === 0) {
53+
if (response?.statusCode === 403) {
5954
return reject(
60-
'Unable to send Feedback. This is because of network issues, or because you are using an ad-blocker.',
61-
);
62-
}
63-
64-
if (response && typeof response.statusCode === 'number' && response.statusCode === 403) {
65-
return reject(
66-
'Unable to send Feedback. This could be because this domain is not in your list of allowed domains.',
55+
'Unable to send feedback. This could be because this domain is not in your list of allowed domains.',
6756
);
6857
}
6958

7059
return reject(
71-
'Unable to send Feedback. This could be because of network issues, or because you are using an ad-blocker',
60+
'Unable to send feedback. This could be because of network issues, or because you are using an ad-blocker.',
7261
);
7362
});
7463
});

packages/feedback/test/core/sendFeedback.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ describe('sendFeedback', () => {
280280
message: 'mi',
281281
}),
282282
).rejects.toMatch(
283-
'Unable to send Feedback. This could be because of network issues, or because you are using an ad-blocker',
283+
'Unable to send feedback. This could be because of network issues, or because you are using an ad-blocker.',
284284
);
285285
});
286286

@@ -297,7 +297,24 @@ describe('sendFeedback', () => {
297297
message: 'mi',
298298
}),
299299
).rejects.toMatch(
300-
'Unable to send Feedback. This is because of network issues, or because you are using an ad-blocker.',
300+
'Unable to send feedback. This could be because of network issues, or because you are using an ad-blocker.',
301+
);
302+
});
303+
304+
it('handles 403 transport error', async () => {
305+
mockSdk();
306+
vi.spyOn(getClient()!.getTransport()!, 'send').mockImplementation(() => {
307+
return Promise.resolve({ statusCode: 403 });
308+
});
309+
310+
await expect(
311+
sendFeedback({
312+
name: 'doe',
313+
314+
message: 'mi',
315+
}),
316+
).rejects.toMatch(
317+
'Unable to send feedback. This could be because this domain is not in your list of allowed domains.',
301318
);
302319
});
303320

0 commit comments

Comments
 (0)