1- import type { Attachment , EventHint , FeedbackEvent } from '@sentry/types' ;
1+ import type { EventHint , FeedbackEvent , SendFeedbackParams } from '@sentry/types' ;
22import { dropUndefinedKeys } from '@sentry/utils' ;
33import { getClient , getCurrentScope } from './currentScopes' ;
44import { 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 */
199export 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