Skip to content

Commit abf402e

Browse files
committed
fix PR
1 parent 955048f commit abf402e

File tree

3 files changed

+23
-31
lines changed

3 files changed

+23
-31
lines changed

packages/core/src/feedback.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface FeedbackParams {
99
attachments?: Attachment[];
1010
url?: string;
1111
source?: string;
12-
relatedEventId?: string;
12+
associatedEventId?: string;
1313
}
1414

1515
/**
@@ -19,7 +19,7 @@ export function captureFeedback(
1919
feedbackParams: FeedbackParams,
2020
hint?: EventHint & { includeReplay?: boolean },
2121
): string {
22-
const { message, name, email, url, source, attachments } = feedbackParams;
22+
const { message, name, email, url, source, attachments, associatedEventId } = feedbackParams;
2323

2424
const client = getClient();
2525
const transport = client && client.getTransport();
@@ -37,14 +37,13 @@ export function captureFeedback(
3737
message,
3838
url,
3939
source,
40+
associated_event_id: associatedEventId,
4041
},
4142
},
4243
type: 'feedback',
4344
level: 'info',
4445
};
4546

46-
// TODO: What to do with `relatedEventId` ?
47-
4847
if (client) {
4948
client.emit('beforeSendFeedback', feedbackEvent, hint);
5049
}
@@ -55,22 +54,17 @@ export function captureFeedback(
5554
// Because we do not support attachments in the feedback envelope
5655
// Once the Sentry API properly supports this, we can get rid of this and send it through the event envelope
5756
if (client && attachments && attachments.length) {
58-
const transport = client.getTransport();
59-
const dsn = client.getDsn();
60-
61-
if (dsn && transport) {
62-
// TODO: https://docs.sentry.io/platforms/javascript/enriching-events/attachments/
63-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
64-
void transport.send(
65-
createAttachmentEnvelope(
66-
feedbackEvent,
67-
attachments,
68-
dsn,
69-
client.getOptions()._metadata,
70-
client.getOptions().tunnel,
71-
),
72-
);
73-
}
57+
// TODO: https://docs.sentry.io/platforms/javascript/enriching-events/attachments/
58+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
59+
void transport.send(
60+
createAttachmentEnvelope(
61+
feedbackEvent,
62+
attachments,
63+
dsn,
64+
client.getOptions()._metadata,
65+
client.getOptions().tunnel,
66+
),
67+
);
7468
}
7569

7670
return eventId;

packages/feedback/src/core/sendFeedback.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { createAttachmentEnvelope, createEventEnvelope, getClient, withScope } from '@sentry/core';
2-
import type { FeedbackEvent, SendFeedback, SendFeedbackParams } from '@sentry/types';
1+
import { captureFeedback } from '@sentry/core';
2+
import { getClient } from '@sentry/core';
3+
import type { SendFeedback, SendFeedbackParams, TransportMakeRequestResponse } from '@sentry/types';
4+
import type { Event } from '@sentry/types';
35
import { getLocationHref } from '@sentry/utils';
4-
import { FEEDBACK_API_SOURCE, FEEDBACK_WIDGET_SOURCE } from '../constants';
5-
import { prepareFeedbackEvent } from '../util/prepareFeedbackEvent';
6+
import { FEEDBACK_API_SOURCE } from '../constants';
67

78
/**
89
* Public API to send a Feedback item to Sentry
910
*/
1011
export const sendFeedback: SendFeedback = (
1112
{ name, email, message, attachments, source = FEEDBACK_API_SOURCE, url = getLocationHref() }: SendFeedbackParams,
1213
{ includeReplay = true } = {},
13-
): Promise<void> {
14+
): Promise<void> => {
1415
if (!message) {
1516
throw new Error('Unable to submit feedback with empty message');
1617
}
@@ -22,7 +23,7 @@ export const sendFeedback: SendFeedback = (
2223
throw new Error('No client setup, cannot send feedback.');
2324
}
2425

25-
const eventId = captureFeedback({ name, email, message, attachments, source, url }, hint);
26+
const eventId = captureFeedback({ name, email, message, attachments, source, url }, { includeReplay });
2627

2728
// We want to wait for the feedback to be sent (or not)
2829
return new Promise<void>((resolve, reject) => {

packages/types/src/feedback/sendFeedback.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Attachment } from '../attachment';
22
import type { Event } from '../event';
3-
import type { TransportMakeRequestResponse } from '../transport';
43
import type { User } from '../user';
54

65
/**
@@ -19,6 +18,7 @@ interface FeedbackContext extends Record<string, unknown> {
1918
name?: string;
2019
replay_id?: string;
2120
url?: string;
21+
associated_event_id?: string;
2222
}
2323

2424
/**
@@ -48,7 +48,4 @@ interface SendFeedbackOptions {
4848
includeReplay?: boolean;
4949
}
5050

51-
export type SendFeedback = (
52-
params: SendFeedbackParams,
53-
options?: SendFeedbackOptions,
54-
) => Promise<TransportMakeRequestResponse>;
51+
export type SendFeedback = (params: SendFeedbackParams, options?: SendFeedbackOptions) => Promise<void>;

0 commit comments

Comments
 (0)