fix: one Sentry issue per kind of API error; the expected 410 of a resumed upload is silent (Sentry 12/11)

Every failed API call landed in one issue titled Object.apiError; each now
has its own fingerprint and title from status, path and message, with ids
and file names normalized. The 410 of a recovered cart's expired upload
was already handled (the file goes up again from the stored copy); the
probe no longer reports it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-12 10:09:20 -03:00
parent d3918e83dc
commit 6896e6a161
5 changed files with 79 additions and 8 deletions

View File

@@ -23,11 +23,12 @@ window.dtfUpload = async (file, {api, prefix='/uploads', startPath=prefix, progr
};
let id=resume?localStorage.getItem(key):null,state;
if(id){
try{state=await api(prefix+'/'+id);}
try{state=await api(prefix+'/'+id,undefined,{expected:[403,404,410]});}
catch(error){
// The id was started under another session (a sign-in changes the scope):
// the new session does not own it, so this file starts again as a new
// upload. A 403/404/410 must never keep the retry on the old id.
// The id is only a hint from the last visit. When the upload expired or
// was started under another session (a sign-in changes the scope), this
// file starts again as a new upload, silently, and its id is replaced.
// These refusals are expected here and never reach Sentry.
if(![403,404,410].includes(error.status))throw error;
id=null;
if(resume)localStorage.removeItem(key);