feat: Sentry in the API, the worker, the Site and the Kanban (off until the DSNs are set)
app/observability.py starts sentry-sdk for the API and the worker when SENTRY_DSN_API is set, with send_default_pii off and a scrub that strips cookies, tokens, bodies, CPF/CNPJ and e-mails. The browser loads the official Sentry bundle from our own origin (web/vendor, provenance in its README) and starts with SENTRY_DSN_WEB from /api/session or /api/operator/me; every failed API answer the customer or the team gets is reported with its path, status and message, never the request body. The CSP allows Blyzer's Sentry ingest host. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -230,7 +230,14 @@ function freightWeight(fr){
|
||||
function downloadButton(text,fn,className){const b=button(text,fn,className);b.prepend(svgIcon(IC.download,'i m'));return b;}
|
||||
async function api(path,body){
|
||||
const r=await fetch('/api/operator'+path,{headers:{'Content-Type':'application/json'},...(body===undefined?{}:{method:'POST',body:JSON.stringify(body)})});
|
||||
const d=await r.json();if(!r.ok){const error=new Error(typeof d.detail==='string'?d.detail:'Confira os campos ('+r.status+').');error.status=r.status;throw error;}return d;
|
||||
const d=await r.json();
|
||||
if(!r.ok){
|
||||
const error=new Error(typeof d.detail==='string'?d.detail:'Confira os campos ('+r.status+').');
|
||||
error.status=r.status;
|
||||
window.dtfObservability?.apiError?.(path,r.status,error.message,d.detail);
|
||||
throw error;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
function download(uid,orderId){return async()=>{
|
||||
const result=await api('/uploads/'+uid+'/download'+(orderId?'?order_id='+encodeURIComponent(orderId):''));
|
||||
@@ -636,7 +643,11 @@ let seenOrders=null, seenPending=null, unseen=0;
|
||||
async function load(quiet=false){
|
||||
try{
|
||||
const [loaded,me]=await Promise.all([api('/board'),api('/me')]);
|
||||
board=absorb(loaded);ME=me;applyRole();paintMyMachine();
|
||||
board=absorb(loaded);ME=me;
|
||||
window.dtfEnvironment=me.sentry_environment||me.environment;
|
||||
window.dtfRelease=me.sentry_release||undefined;
|
||||
window.dtfObservability?.start?.(me.sentry_dsn_web,'kanban');
|
||||
applyRole();paintMyMachine();
|
||||
noticeNew(quiet);
|
||||
const known=new Set(board.orders.map(o=>o.id));
|
||||
board.orders.push(...olderFinished.filter(o=>!known.has(o.id)));
|
||||
|
||||
Reference in New Issue
Block a user