You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running ad blockers or other network disruptions occur showReportDialog will silently fail, there is no api provided for catching this case and asking the user to potentially turn their adblocker (or similar off).
Solution Brainstorm
Make showReportDialog return a Promise that resolves when the dialog opens, rejects with error when it fails. (Bonus if you make showReportDialog resolve an object that lets you close the dialog or similar.
import*asSentryfrom'@sentry/browser';import{useCallback,useEffect,useState}from'react';constisReportDialogScript=(target: EventTarget|null): target is HTMLScriptElement=>{if(!(targetinstanceofHTMLScriptElement)){returnfalse;}consturl=newURL(target.src);returnurl.hostname.endsWith('sentry.io')&&url.pathname.endsWith('/api/embed/error-page/');};exportconstuseReportDialog=(errorId: string|undefined,): readonly[open: ()=>void,failed: boolean]=>{const[failed,setFailed]=useState(false);// showReportDialog exposes no failure callback. Script error events don't bubble, so catch// them on window during the capture phase.useEffect(()=>{constonError=(event: Event): void=>{if(isReportDialogScript(event.target)){setFailed(true);}};window.addEventListener('error',onError,{capture: true});return()=>{window.removeEventListener('error',onError,{capture: true});};},[]);constopen=useCallback(()=>{if(!errorId){return;}setFailed(false);Sentry.showReportDialog({eventId: errorId});},[errorId]);return[open,failed]asconst;};
Activity
linear-code commentedon Sep 25, 2026
JS-3824
SimonSchick commentedon Sep 25, 2026
Our interrim solution:
andreiborza commentedon Sep 28, 2026
Hi @SimonSchick, thanks for filing this.
I think we could expose the
onErroroption or something along those lines. Will take a look.feat(browser): Add `onError` callback to `showReportDialog` (getsentr…
github-actions commentedon Sep 28, 2026
A PR closing this issue has just been released 🚀
This issue was referenced by PR #24780, which was included in the 11.1.0 release.