Skip to content

feat(feedback): Return the eventId into the onSubmitSuccess callback #16835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/types-hoist/feedback/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export interface FeedbackCallbacks {
*
* After this you'll see a SuccessMessage on the screen for a moment.
*/
onSubmitSuccess?: (data: FeedbackFormData) => void;
onSubmitSuccess?: (data: FeedbackFormData, eventId: string) => void;

/**
* Callback when feedback is unsuccessfully submitted
Expand Down
4 changes: 2 additions & 2 deletions packages/feedback/src/modal/components/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export function Dialog({ open, onFormSubmitted, ...props }: Props): VNode {
}, [timeoutId]);

const onSubmitSuccess = useCallback(
(data: FeedbackFormData) => {
props.onSubmitSuccess(data);
(data: FeedbackFormData, eventId: string) => {
props.onSubmitSuccess(data, eventId);
setTimeoutId(
setTimeout(() => {
onFormSubmitted();
Expand Down
6 changes: 3 additions & 3 deletions packages/feedback/src/modal/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface Props extends Pick<FeedbackInternalOptions, 'showEmail' | 'show
defaultName: string;
onFormClose: () => void;
onSubmit: SendFeedback;
onSubmitSuccess: (data: FeedbackFormData) => void;
onSubmitSuccess: (data: FeedbackFormData, eventId: string) => void;
onSubmitError: (error: Error) => void;
screenshotInput: ReturnType<FeedbackScreenshotIntegration['createInput']> | undefined;
}
Expand Down Expand Up @@ -118,7 +118,7 @@ export function Form({
}

try {
await onSubmit(
const eventId = await onSubmit(
{
name: data.name,
email: data.email,
Expand All @@ -128,7 +128,7 @@ export function Form({
},
{ attachments: data.attachments },
);
onSubmitSuccess(data);
onSubmitSuccess(data, eventId);
} catch (error) {
DEBUG_BUILD && logger.error(error);
setError(error as string);
Expand Down
4 changes: 2 additions & 2 deletions packages/feedback/src/modal/integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ export const feedbackModalIntegration = ((): FeedbackModalIntegration => {
options.onFormClose?.();
}}
onSubmit={sendFeedback}
onSubmitSuccess={(data: FeedbackFormData) => {
onSubmitSuccess={(data: FeedbackFormData, eventId: string) => {
renderContent(false);
options.onSubmitSuccess?.(data);
options.onSubmitSuccess?.(data, eventId);
}}
onSubmitError={(error: Error) => {
options.onSubmitError?.(error);
Expand Down
6 changes: 3 additions & 3 deletions packages/feedback/src/util/mergeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export function mergeOptions(
optionOverrides.onFormClose?.();
defaultOptions.onFormClose?.();
},
onSubmitSuccess: (data: FeedbackFormData) => {
optionOverrides.onSubmitSuccess?.(data);
defaultOptions.onSubmitSuccess?.(data);
onSubmitSuccess: (data: FeedbackFormData, eventId: string) => {
optionOverrides.onSubmitSuccess?.(data, eventId);
defaultOptions.onSubmitSuccess?.(data, eventId);
},
onSubmitError: (error: Error) => {
optionOverrides.onSubmitError?.(error);
Expand Down
Loading