Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Apr 19, 2024
1 parent c16b325 commit 42cb0a7
Show file tree
Hide file tree
Showing 6 changed files with 460 additions and 27 deletions.
20 changes: 3 additions & 17 deletions packages/core/src/feedback.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
import type { Attachment, EventHint, FeedbackEvent } from '@sentry/types';
import type { EventHint, FeedbackEvent, SendFeedbackParams } from '@sentry/types';
import { dropUndefinedKeys } from '@sentry/utils';
import { getClient, getCurrentScope } from './currentScopes';
import { createAttachmentEnvelope } from './envelope';

interface FeedbackParams {
message: string;
name?: string;
email?: string;
attachments?: Attachment[];
url?: string;
source?: string;
associatedEventId?: string;
}

/**
* Send user feedback to Sentry.
*/
export function captureFeedback(
feedbackParams: FeedbackParams,
feedbackParams: SendFeedbackParams,
hint?: EventHint & { includeReplay?: boolean },
): string {
const { message, name, email, url, source, attachments, associatedEventId } = feedbackParams;
Expand All @@ -26,10 +16,6 @@ export function captureFeedback(
const transport = client && client.getTransport();
const dsn = client && client.getDsn();

if (!client || !transport || !dsn) {
throw new Error('Invalid Sentry client');
}

const feedbackEvent: FeedbackEvent = {
contexts: {
feedback: dropUndefinedKeys({
Expand All @@ -54,7 +40,7 @@ export function captureFeedback(
// For now, we have to send attachments manually in a separate envelope
// Because we do not support attachments in the feedback envelope
// Once the Sentry API properly supports this, we can get rid of this and send it through the event envelope
if (client && attachments && attachments.length) {
if (client && transport && dsn && attachments && attachments.length) {
// TODO: https://docs.sentry.io/platforms/javascript/enriching-events/attachments/
// eslint-disable-next-line @typescript-eslint/no-floating-promises
void transport.send(
Expand Down

0 comments on commit 42cb0a7

Please sign in to comment.