1
- import type { Attachment , EventHint , FeedbackEvent } from '@sentry/types' ;
1
+ import type { EventHint , FeedbackEvent , SendFeedbackParams } from '@sentry/types' ;
2
2
import { dropUndefinedKeys } from '@sentry/utils' ;
3
3
import { getClient , getCurrentScope } from './currentScopes' ;
4
4
import { createAttachmentEnvelope } from './envelope' ;
5
5
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
-
16
6
/**
17
7
* Send user feedback to Sentry.
18
8
*/
19
9
export function captureFeedback (
20
- feedbackParams : FeedbackParams ,
10
+ feedbackParams : SendFeedbackParams ,
21
11
hint ?: EventHint & { includeReplay ?: boolean } ,
22
12
) : string {
23
13
const { message, name, email, url, source, attachments, associatedEventId } = feedbackParams ;
@@ -26,10 +16,6 @@ export function captureFeedback(
26
16
const transport = client && client . getTransport ( ) ;
27
17
const dsn = client && client . getDsn ( ) ;
28
18
29
- if ( ! client || ! transport || ! dsn ) {
30
- throw new Error ( 'Invalid Sentry client' ) ;
31
- }
32
-
33
19
const feedbackEvent : FeedbackEvent = {
34
20
contexts : {
35
21
feedback : dropUndefinedKeys ( {
@@ -54,7 +40,7 @@ export function captureFeedback(
54
40
// For now, we have to send attachments manually in a separate envelope
55
41
// Because we do not support attachments in the feedback envelope
56
42
// 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 ) {
58
44
// TODO: https://docs.sentry.io/platforms/javascript/enriching-events/attachments/
59
45
// eslint-disable-next-line @typescript-eslint/no-floating-promises
60
46
void transport . send (
0 commit comments