-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(feedback): Use debug
instead of logger
#17027
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Incorrect `debug` Usage Causes Errors
The debug
function from @sentry/core
was incorrectly used as an object with an error
method (e.g., debug.error(...)
), replacing previous logger.error(...)
calls. As debug
is a function, not an object, this causes a TypeScript compilation error and, in debug builds, a runtime TypeError: debug.error is not a function
. This issue breaks feedback-related flows in files like Form.tsx
and core/integration.ts
.
packages/feedback/src/modal/components/Form.tsx#L128-L135
sentry-javascript/packages/feedback/src/modal/components/Form.tsx
Lines 128 to 135 in b8a82ed
}, | |
{ attachments: data.attachments }, | |
); | |
onSubmitSuccess(data, eventId); | |
} catch (error) { | |
DEBUG_BUILD && debug.error(error); | |
setError(error as string); | |
onSubmitError(error as Error); |
packages/feedback/src/core/integration.ts#L193-L247
sentry-javascript/packages/feedback/src/core/integration.ts
Lines 193 to 247 in b8a82ed
modalIntegration = modalIntegrationFn() as FeedbackModalIntegration; | |
addIntegration(modalIntegration); | |
} catch { | |
DEBUG_BUILD && | |
debug.error( | |
'[Feedback] Error when trying to load feedback integrations. Try using `feedbackSyncIntegration` in your `Sentry.init`.', | |
); | |
throw new Error('[Feedback] Missing feedback modal integration!'); | |
} | |
try { | |
const screenshotIntegrationFn = screenshotRequired | |
? getScreenshotIntegration | |
? getScreenshotIntegration() | |
: await lazyLoadIntegration('feedbackScreenshotIntegration', scriptNonce) | |
: undefined; | |
if (screenshotIntegrationFn) { | |
screenshotIntegration = screenshotIntegrationFn() as FeedbackScreenshotIntegration; | |
addIntegration(screenshotIntegration); | |
} | |
} catch { | |
DEBUG_BUILD && | |
debug.error('[Feedback] Missing feedback screenshot integration. Proceeding without screenshots.'); | |
} | |
const dialog = modalIntegration.createDialog({ | |
options: { | |
...options, | |
onFormClose: () => { | |
dialog?.close(); | |
options.onFormClose?.(); | |
}, | |
onFormSubmitted: () => { | |
dialog?.close(); | |
options.onFormSubmitted?.(); | |
}, | |
}, | |
screenshotIntegration, | |
sendFeedback, | |
shadow: _createShadow(options), | |
}); | |
return dialog; | |
}; | |
const _attachTo = (el: Element | string, optionOverrides: OverrideFeedbackConfiguration = {}): Unsubscribe => { | |
const mergedOptions = mergeOptions(_options, optionOverrides); | |
const targetEl = | |
typeof el === 'string' ? DOCUMENT.querySelector(el) : typeof el.addEventListener === 'function' ? el : null; | |
if (!targetEl) { | |
DEBUG_BUILD && debug.error('[Feedback] Unable to attach to target element'); | |
throw new Error('Unable to attach to target element'); |
Was this report helpful? Give feedback by reacting with 👍 or 👎
resolves #16949