diff --git a/packages/core/src/feedback.ts b/packages/core/src/feedback.ts index af7bfecf14f5..f1acda999d44 100644 --- a/packages/core/src/feedback.ts +++ b/packages/core/src/feedback.ts @@ -9,7 +9,7 @@ interface FeedbackParams { attachments?: Attachment[]; url?: string; source?: string; - relatedEventId?: string; + associatedEventId?: string; } /** @@ -19,7 +19,7 @@ export function captureFeedback( feedbackParams: FeedbackParams, hint?: EventHint & { includeReplay?: boolean }, ): string { - const { message, name, email, url, source, attachments } = feedbackParams; + const { message, name, email, url, source, attachments, associatedEventId } = feedbackParams; const client = getClient(); const transport = client && client.getTransport(); @@ -37,14 +37,13 @@ export function captureFeedback( message, url, source, + associated_event_id: associatedEventId, }, }, type: 'feedback', level: 'info', }; - // TODO: What to do with `relatedEventId` ? - if (client) { client.emit('beforeSendFeedback', feedbackEvent, hint); } @@ -55,22 +54,17 @@ export function captureFeedback( // 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) { - const transport = client.getTransport(); - const dsn = client.getDsn(); - - if (dsn && transport) { - // TODO: https://docs.sentry.io/platforms/javascript/enriching-events/attachments/ - // eslint-disable-next-line @typescript-eslint/no-floating-promises - void transport.send( - createAttachmentEnvelope( - feedbackEvent, - attachments, - dsn, - client.getOptions()._metadata, - client.getOptions().tunnel, - ), - ); - } + // TODO: https://docs.sentry.io/platforms/javascript/enriching-events/attachments/ + // eslint-disable-next-line @typescript-eslint/no-floating-promises + void transport.send( + createAttachmentEnvelope( + feedbackEvent, + attachments, + dsn, + client.getOptions()._metadata, + client.getOptions().tunnel, + ), + ); } return eventId; diff --git a/packages/feedback/src/core/sendFeedback.ts b/packages/feedback/src/core/sendFeedback.ts index 09ca15538f5e..7a0abe145b2a 100644 --- a/packages/feedback/src/core/sendFeedback.ts +++ b/packages/feedback/src/core/sendFeedback.ts @@ -1,8 +1,9 @@ -import { createAttachmentEnvelope, createEventEnvelope, getClient, withScope } from '@sentry/core'; -import type { FeedbackEvent, SendFeedback, SendFeedbackParams } from '@sentry/types'; +import { captureFeedback } from '@sentry/core'; +import { getClient } from '@sentry/core'; +import type { SendFeedback, SendFeedbackParams, TransportMakeRequestResponse } from '@sentry/types'; +import type { Event } from '@sentry/types'; import { getLocationHref } from '@sentry/utils'; -import { FEEDBACK_API_SOURCE, FEEDBACK_WIDGET_SOURCE } from '../constants'; -import { prepareFeedbackEvent } from '../util/prepareFeedbackEvent'; +import { FEEDBACK_API_SOURCE } from '../constants'; /** * Public API to send a Feedback item to Sentry @@ -10,7 +11,7 @@ import { prepareFeedbackEvent } from '../util/prepareFeedbackEvent'; export const sendFeedback: SendFeedback = ( { name, email, message, attachments, source = FEEDBACK_API_SOURCE, url = getLocationHref() }: SendFeedbackParams, { includeReplay = true } = {}, -): Promise { +): Promise => { if (!message) { throw new Error('Unable to submit feedback with empty message'); } @@ -22,7 +23,7 @@ export const sendFeedback: SendFeedback = ( throw new Error('No client setup, cannot send feedback.'); } - const eventId = captureFeedback({ name, email, message, attachments, source, url }, hint); + const eventId = captureFeedback({ name, email, message, attachments, source, url }, { includeReplay }); // We want to wait for the feedback to be sent (or not) return new Promise((resolve, reject) => { diff --git a/packages/types/src/feedback/sendFeedback.ts b/packages/types/src/feedback/sendFeedback.ts index 612e0cff001d..7ba6600662bd 100644 --- a/packages/types/src/feedback/sendFeedback.ts +++ b/packages/types/src/feedback/sendFeedback.ts @@ -1,6 +1,5 @@ import type { Attachment } from '../attachment'; import type { Event } from '../event'; -import type { TransportMakeRequestResponse } from '../transport'; import type { User } from '../user'; /** @@ -19,6 +18,7 @@ interface FeedbackContext extends Record { name?: string; replay_id?: string; url?: string; + associated_event_id?: string; } /** @@ -48,7 +48,4 @@ interface SendFeedbackOptions { includeReplay?: boolean; } -export type SendFeedback = ( - params: SendFeedbackParams, - options?: SendFeedbackOptions, -) => Promise; +export type SendFeedback = (params: SendFeedbackParams, options?: SendFeedbackOptions) => Promise;