Skip to content

ref(feedback): Remove almost duplicate sendFeedback rejection message #17297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions packages/feedback/src/core/sendFeedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,18 @@ export const sendFeedback: SendFeedback = (
cleanup();

// Require valid status codes, otherwise can assume feedback was not sent successfully
if (
response &&
typeof response.statusCode === 'number' &&
response.statusCode >= 200 &&
response.statusCode < 300
) {
if (response?.statusCode && response.statusCode >= 200 && response.statusCode < 300) {
return resolve(eventId);
}

if (response && typeof response.statusCode === 'number' && response.statusCode === 0) {
if (response?.statusCode === 403) {
return reject(
'Unable to send Feedback. This is because of network issues, or because you are using an ad-blocker.',
);
}

if (response && typeof response.statusCode === 'number' && response.statusCode === 403) {
return reject(
'Unable to send Feedback. This could be because this domain is not in your list of allowed domains.',
'Unable to send feedback. This could be because this domain is not in your list of allowed domains.',
);
}

return reject(
'Unable to send Feedback. This could be 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.',
);
});
});
Expand Down
21 changes: 19 additions & 2 deletions packages/feedback/test/core/sendFeedback.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ describe('sendFeedback', () => {
message: 'mi',
}),
).rejects.toMatch(
'Unable to send Feedback. This could be 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.',
);
});

Expand All @@ -297,7 +297,24 @@ describe('sendFeedback', () => {
message: 'mi',
}),
).rejects.toMatch(
'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.',
);
});

it('handles 403 transport error', async () => {
mockSdk();
vi.spyOn(getClient()!.getTransport()!, 'send').mockImplementation(() => {
return Promise.resolve({ statusCode: 403 });
});

await expect(
sendFeedback({
name: 'doe',
email: '[email protected]',
message: 'mi',
}),
).rejects.toMatch(
'Unable to send feedback. This could be because this domain is not in your list of allowed domains.',
);
});

Expand Down
Loading