diff --git a/docs/migration/feedback.md b/docs/migration/feedback.md index c6f328c9ff0f..84580ac69d0a 100644 --- a/docs/migration/feedback.md +++ b/docs/migration/feedback.md @@ -86,7 +86,7 @@ For example, `attachTo()` is a convenience wrapper over the lifecycle methods. Y function attachTo(button: HTMLElement) { const handleClick = () => { const widget = feedbackInstance.createWidget({ - onFormClose: () => { + onFormClose: ({ reason }) => { widget.close(); }, onFormSubmited: () => { diff --git a/packages/feedback/src/core/integration.ts b/packages/feedback/src/core/integration.ts index 8917644cebfe..2c40cd9e3408 100644 --- a/packages/feedback/src/core/integration.ts +++ b/packages/feedback/src/core/integration.ts @@ -231,9 +231,9 @@ export const buildFeedbackIntegration = ({ if (!dialog) { dialog = await _loadAndRenderDialog({ ...mergedOptions, - onFormClose: () => { + onFormClose: ({ reason }) => { dialog && dialog.close(); - mergedOptions.onFormClose && mergedOptions.onFormClose(); + mergedOptions.onFormClose && mergedOptions.onFormClose({ reason }); }, onFormSubmitted: () => { dialog && dialog.removeFromDom(); diff --git a/packages/feedback/src/modal/components/Dialog.tsx b/packages/feedback/src/modal/components/Dialog.tsx index b711335a96c3..bdfbe5ad1ff0 100644 --- a/packages/feedback/src/modal/components/Dialog.tsx +++ b/packages/feedback/src/modal/components/Dialog.tsx @@ -54,7 +54,11 @@ export function Dialog({ open, onFormSubmitted, ...props }: Props): VNode { ) : ( - + options.onFormClose && options.onFormClose({ reason: 'dialog-dismissed' })} + open={open} + >
void; + onFormClose: (args: { reason: 'dialog-dismissed' | 'form-cancelled' }) => void; onSubmit: SendFeedback; onSubmitSuccess: (data: FeedbackFormData) => void; onSubmitError: (error: Error) => void; @@ -217,7 +217,7 @@ export function Form({ -
diff --git a/packages/feedback/src/modal/integration.tsx b/packages/feedback/src/modal/integration.tsx index ab0b6418b8cd..defcc8f0a992 100644 --- a/packages/feedback/src/modal/integration.tsx +++ b/packages/feedback/src/modal/integration.tsx @@ -71,9 +71,9 @@ export const feedbackModalIntegration = ((): FeedbackModalIntegration => { showEmail={options.showEmail || options.isEmailRequired} defaultName={(userKey && user && user[userKey.name]) || ''} defaultEmail={(userKey && user && user[userKey.email]) || ''} - onFormClose={() => { + onFormClose={({ reason }) => { renderContent(false); - options.onFormClose && options.onFormClose(); + options.onFormClose && options.onFormClose({ reason }); }} onSubmit={sendFeedback} onSubmitSuccess={(data: FeedbackFormData) => { diff --git a/packages/feedback/src/util/mergeOptions.ts b/packages/feedback/src/util/mergeOptions.ts index 0a30a893c777..3051db9a475f 100644 --- a/packages/feedback/src/util/mergeOptions.ts +++ b/packages/feedback/src/util/mergeOptions.ts @@ -19,9 +19,9 @@ export function mergeOptions( optionOverrides.onFormOpen && optionOverrides.onFormOpen(); defaultOptions.onFormOpen && defaultOptions.onFormOpen(); }, - onFormClose: () => { - optionOverrides.onFormClose && optionOverrides.onFormClose(); - defaultOptions.onFormClose && defaultOptions.onFormClose(); + onFormClose: (...args) => { + optionOverrides.onFormClose && optionOverrides.onFormClose(...args); + defaultOptions.onFormClose && defaultOptions.onFormClose(...args); }, onSubmitSuccess: (data: FeedbackFormData) => { optionOverrides.onSubmitSuccess && optionOverrides.onSubmitSuccess(data); diff --git a/packages/integration-shims/src/Feedback.ts b/packages/integration-shims/src/Feedback.ts index 189dc074cd1e..ed31489161e2 100644 --- a/packages/integration-shims/src/Feedback.ts +++ b/packages/integration-shims/src/Feedback.ts @@ -2,7 +2,7 @@ import type { Integration } from '@sentry/types'; import { consoleSandbox } from '@sentry/utils'; import { FAKE_FUNCTION } from './common'; -const FEEDBACK_INTEGRATION_METHODS = ['attachTo', 'createWidget', 'remove'] as const; +const FEEDBACK_INTEGRATION_METHODS = ['attachTo', 'createForm', 'createWidget', 'remove'] as const; type FeedbackSpecificMethods = Record<(typeof FEEDBACK_INTEGRATION_METHODS)[number], () => void>; diff --git a/packages/types/src/feedback/config.ts b/packages/types/src/feedback/config.ts index 2350545941be..71f4a21750dc 100644 --- a/packages/types/src/feedback/config.ts +++ b/packages/types/src/feedback/config.ts @@ -175,7 +175,7 @@ export interface FeedbackCallbacks { /** * Callback when form is closed and not submitted */ - onFormClose?: () => void; + onFormClose?: (args: { reason: 'dialog-dismissed' | 'form-cancelled' }) => void; /** * Callback when feedback is successfully submitted