11import { createEventEnvelope , getClient , withScope , createAttachmentEnvelope } from '@sentry/core' ;
2- import type { FeedbackEvent , TransportMakeRequestResponse } from '@sentry/types' ;
2+ import type { Attachment , FeedbackEvent , TransportMakeRequestResponse } from '@sentry/types' ;
33
44import { FEEDBACK_API_SOURCE , FEEDBACK_WIDGET_SOURCE } from '../constants' ;
5- import type { Screenshot , SendFeedbackData , SendFeedbackOptions } from '../types' ;
5+ import type { SendFeedbackData , SendFeedbackOptions } from '../types' ;
66import { prepareFeedbackEvent } from './prepareFeedbackEvent' ;
77
88/**
@@ -11,7 +11,7 @@ import { prepareFeedbackEvent } from './prepareFeedbackEvent';
1111export async function sendFeedbackRequest (
1212 { feedback : { message, email, name, source, url } } : SendFeedbackData ,
1313 { includeReplay = true } : SendFeedbackOptions = { } ,
14- screenshots : Screenshot [ ] ,
14+ screenshots : Attachment [ ] ,
1515) : Promise < void | TransportMakeRequestResponse > {
1616 const client = getClient ( ) ;
1717 const transport = client && client . getTransport ( ) ;
@@ -56,19 +56,6 @@ export async function sendFeedbackRequest(
5656
5757 const envelope = createEventEnvelope ( feedbackEvent , dsn , client . getOptions ( ) . _metadata , client . getOptions ( ) . tunnel ) ;
5858
59- let attachment_envelope ;
60- for ( const attachment of screenshots || [ ] ) {
61- attachment_envelope = createAttachmentEnvelope (
62- feedbackEvent ,
63- attachment ,
64- dsn ,
65- client . getOptions ( ) . _metadata ,
66- client . getOptions ( ) . tunnel ,
67- // eslint-disable-next-line @sentry-internal/sdk/no-optional-chaining
68- client . getOptions ( ) . transportOptions && client . getOptions ( ) . transportOptions ?. textEncoder ,
69- ) ;
70- }
71-
7259 let response : void | TransportMakeRequestResponse ;
7360
7461 try {
@@ -96,7 +83,15 @@ export async function sendFeedbackRequest(
9683 throw new Error ( 'Unable to send Feedback' ) ;
9784 }
9885
99- if ( attachment_envelope ) {
86+ if ( screenshots ) {
87+ const attachment_envelope = createAttachmentEnvelope (
88+ feedbackEvent ,
89+ screenshots ,
90+ dsn ,
91+ client . getOptions ( ) . _metadata ,
92+ client . getOptions ( ) . tunnel ,
93+ ) ;
94+
10095 try {
10196 response = await transport . send ( attachment_envelope ) ;
10297 } catch ( err ) {
0 commit comments