Skip to content

Commit 42cb0a7

Browse files
committed
more tests
1 parent c16b325 commit 42cb0a7

File tree

6 files changed

+460
-27
lines changed

6 files changed

+460
-27
lines changed

packages/core/src/feedback.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
import type { Attachment, EventHint, FeedbackEvent } from '@sentry/types';
1+
import type { EventHint, FeedbackEvent, SendFeedbackParams } from '@sentry/types';
22
import { dropUndefinedKeys } from '@sentry/utils';
33
import { getClient, getCurrentScope } from './currentScopes';
44
import { createAttachmentEnvelope } from './envelope';
55

6-
interface FeedbackParams {
7-
message: string;
8-
name?: string;
9-
email?: string;
10-
attachments?: Attachment[];
11-
url?: string;
12-
source?: string;
13-
associatedEventId?: string;
14-
}
15-
166
/**
177
* Send user feedback to Sentry.
188
*/
199
export function captureFeedback(
20-
feedbackParams: FeedbackParams,
10+
feedbackParams: SendFeedbackParams,
2111
hint?: EventHint & { includeReplay?: boolean },
2212
): string {
2313
const { message, name, email, url, source, attachments, associatedEventId } = feedbackParams;
@@ -26,10 +16,6 @@ export function captureFeedback(
2616
const transport = client && client.getTransport();
2717
const dsn = client && client.getDsn();
2818

29-
if (!client || !transport || !dsn) {
30-
throw new Error('Invalid Sentry client');
31-
}
32-
3319
const feedbackEvent: FeedbackEvent = {
3420
contexts: {
3521
feedback: dropUndefinedKeys({
@@ -54,7 +40,7 @@ export function captureFeedback(
5440
// For now, we have to send attachments manually in a separate envelope
5541
// Because we do not support attachments in the feedback envelope
5642
// Once the Sentry API properly supports this, we can get rid of this and send it through the event envelope
57-
if (client && attachments && attachments.length) {
43+
if (client && transport && dsn && attachments && attachments.length) {
5844
// TODO: https://docs.sentry.io/platforms/javascript/enriching-events/attachments/
5945
// eslint-disable-next-line @typescript-eslint/no-floating-promises
6046
void transport.send(

0 commit comments

Comments
 (0)