1import{r as c,j as e}from"./playbook-DzR_ry6Q.js";import{h as u,R as y}from"./AppUpdateMonitor-Bn2pSfA6.js";function E(){throw new Error("Test React render error â intentional crash for error boundary test")}class T extends y{constructor(i){super(i),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?e.jsxs("div",{className:"text-critical p-2 border border-critical bg-background-critical rounded",children:["React render error caught by boundary."," ",e.jsx("button",{className:"rounded ml-2 p-1 bg-background-base text-base border",onClick:()=>{this.setState({hasError:!1}),this.props.onReset?.()},children:"Reset"})]}):this.props.children}}function N(n){return n.toTimeString().slice(0,8)}function g(){const[n,i]=c.useState([]),[d,l]=c.useState(!1);function t(r,s){i(f=>[{time:N(new Date),scenario:r,result:s},...f])}async function a(r){try{await u.get(`/api/TestApi/error/${r}`),t(`${r}`,"No error thrown (unexpected)")}catch(s){t(`${r}`,`Caught: ${s.message||s}`)}}async function h(){try{await u.get("/api/TestApi/throw"),t("Backend Throw","No error (unexpected)")}catch(r){t("Backend Throw",`Caught: ${r.message||r}`)}}function x(){fetch("https://0.0.0.0:1/").then(()=>t("Network Error","No error (unexpected)")).catch(r=>{console.error("Network error (console only, not reported):",r),t("Network Error",`console.error only: ${r.message}`)})}function m(){setTimeout(()=>{null.property},0),t("Null Reference","TypeError thrown in setTimeout â window.onerror â Datadog")}function b(){setTimeout(()=>{(void 0).method()},0),t("Undefined Method","TypeError thrown in setTimeout â window.onerror â Datadog")}function p(){setTimeout(()=>{undeclaredVariable.access},0),t("ReferenceError","ReferenceError thrown in setTimeout â window.onerror â Datadog")}function j(){setTimeout(()=>{throw new Error("Test explicit throw in setTimeout â intentional for window.onerror test")},0),t("Throw in setTimeout","Error thrown in setTimeout â window.onerror â Datadog")}function w(){Promise.reject(new Error("Test unhandled rejection â intentional for global handler test")),t("Unhandled Rejection","Promise.reject fired â check global handler â Datadog")}return e.jsxs("div",{className:"max-w-[800px] mx-auto my-6 px-4",children:[e.jsx("div",{className:"bg-background-warning border-2 border-warning-muted text-warning rounded py-3 px-4 mb-6 font-bold text-center text-body",children:"â Dev/Test Only â not available in production"}),e.jsx("h1",{className:"text-[20px] mb-2",children:"Datadog Error Reporting Test"}),e.jsx("p",{className:"text-body text-muted mb-5",children:"Click each button to trigger the corresponding error scenario and verify it appears in Datadog Logs / browser DevTools console."}),e.jsxs("div",{className:"mb-6",children:[e.jsx("strong",{className:"text-body",children:"Network Errors:"}),e.jsxs("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-2.5 mt-2",children:[e.jsx(o,{label:"400 Bad Request",note:"reportError â Datadog",onClick:()=>a(400)}),e.jsx(o,{label:"401 Unauthorized",note:"logInfo â Datadog + Triggers sign-out redirect",onClick:()=>a(401)}),e.jsx(o,{label:"403 Forbidden",note:"logWarning â Datadog + InvalidAccessModal",onClick:()=>a(403),variant:"warning"}),e.jsx(o,{label:"404 Not Found",note:"reportError â Datadog",onClick:()=>a(404)}),e.jsx(o,{label:"422 Validation",note:"Silently ignored â no Datadog report",onClick:()=>a(422),variant:"default"}),e.jsx(o,{label:"429 Too Many Requests",note:"reportError â Datadog + TooManyRequestsModal",onClick:()=>a(429),variant:"warning"}),e.jsx(o,{label:"500 Server Error",note:"reportError â Datadog",onClick:()=>a(500)}),e.jsx(o,{label:"Backend Throw (500)",note:"Server-side throw â WebApiExceptionLogger â App Insights",onClick:h}),e.jsx(o,{label:"Network Error",note:"console.error only â NOT in Datadog",onClick:x,variant:"default"})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("strong",{className:"text-body",children:"JS Runtime Errors (window.onerror â Datadog):"}),e.jsxs("p",{className:"text-body-sm text-muted mt-1 mb-2",children:["These are thrown inside ",e.jsx("code",{children:"setTimeout"})," to escape React's event wrapper and hit the global ",e.jsx("code",{children:"window.onerror"})," handler."]}),e.jsxs("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-2.5 mb-2",children:[e.jsx(o,{label:"Null Reference",note:"null.property â TypeError â window.onerror â Datadog",onClick:m}),e.jsx(o,{label:"Undefined Method",note:"undefined.method() â TypeError â window.onerror â Datadog",onClick:b}),e.jsx(o,{label:"ReferenceError",note:"undeclaredVar.x â ReferenceError â window.onerror â Datadog",onClick:p}),e.jsx(o,{label:"Throw in setTimeout",note:"throw new Error(...) in setTimeout â window.onerror â Datadog",onClick:j}
1),e.jsx(o,{label:"Unhandled Rejection",note:"Global unhandledrejection â Datadog",onClick:w})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("strong",{className:"text-body",children:"React Render Error Boundary:"}),e.jsxs("div",{className:"mt-2",children:[!d&&e.jsx(o,{label:"React Render Error",note:"ReportingErrorBoundary.componentDidCatch â Datadog",onClick:()=>{l(!0),t("React Render Error","Crash component rendered â check ReportingErrorBoundary.componentDidCatch â Datadog")}}),e.jsx(T,{onReset:()=>l(!1),children:d?e.jsx(E,{}):null})]})]}),e.jsxs("div",{children:[e.jsx("strong",{className:"text-body-sm",children:"Log:"}),n.length===0?e.jsx("p",{className:"text-body-sm text-muted mt-1",children:"No events yet."}):e.jsxs("table",{className:"w-full text-body-sm border-collapse mt-1",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-b-base text-left",children:[e.jsx("th",{className:"py-1 px-2 w-[70px]",children:"Time"}),e.jsx("th",{className:"py-1 px-2 w-[160px]",children:"Scenario"}),e.jsx("th",{className:"py-1 px-2",children:"Result"})]})}),e.jsx("tbody",{children:n.map((r,s)=>e.jsxs("tr",{className:"border-b border-b-muted",children:[e.jsx("td",{className:"py-1 px-2 text-muted",children:r.time}),e.jsx("td",{className:"py-1 px-2 font-[500]",children:r.scenario}),e.jsx("td",{className:"py-1 px-2 text-base",children:r.result})]},s))})]})]})]})}const R={critical:"border-0 bg-critical-base text-on-dark",warning:"border-0 bg-background-warning text-warning",default:"border border-muted bg-background-muted text-base"};function o({label:n,note:i,onClick:d,variant:l="critical"}){return e.jsxs("div",{className:"border border-base rounded-lg p-3 bg-foreground-base",children:[e.jsx("button",{onClick:d,className:`block w-full py-2 px-3 rounded font-bold text-body-sm cursor-pointer ${R[l]}`,children:n}),e.jsx("p",{className:"mt-1 text-body-sm text-[#666]",children:i})]})}const v=Object.freeze(Object.defineProperty({__proto__:null,default:g},Symbol.toStringTag,{value:"Module"})),C=Object.freeze(Object.defineProperty({__proto__:null,default:g},Symbol.toStringTag,{value:"Module"}));export{v as E,C as a}; 2//# sourceMappingURL=ErrorTest-Cd2T69o4.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.