feat: every error shown in red reaches Sentry, also the ones the page handled itself
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Publish images (push) Has been cancelled
Build and deploy / Secret scan and release gate (push) Has been cancelled
Build and deploy / Integration suite on a real stack (push) Has been cancelled
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Publish images (push) Has been cancelled
Build and deploy / Secret scan and release gate (push) Has been cancelled
Build and deploy / Integration suite on a real stack (push) Has been cancelled
Until now only failed API calls and uncaught exceptions reached Sentry. An error the page caught and showed, like the folders' "A última tentativa falhou" Marcus photographed on 16/11, or an upload that failed on the Site, never did. Now every red message in the Kanban, the Site's checkout, the customer's account page and every failed upload is sent, one issue per kind of message; the same text an API error already sent, or a 401 / restart 503 it skips on purpose, is not sent twice. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -114,7 +114,11 @@
|
||||
const normalizedMessage = value => clean(String(value == null ? '' : value)
|
||||
.replace(UUID, ':id').replace(FILE_NAME, ':arquivo').replace(NUMBER, ':id'));
|
||||
|
||||
// What apiError already sent, so the same text shown in red is not sent twice.
|
||||
const recent = new Map();
|
||||
function apiError(path, status, message, detail) {
|
||||
// Recorded first: a skipped 401 or restart 503 stays out of uiError too.
|
||||
recent.set(String(message), Date.now());
|
||||
if (!started || status === 401 || typeof Sentry === 'undefined') return;
|
||||
// A restart's few seconds without the database (app/app.py): not a bug.
|
||||
if (status === 503 && /reiniciando/.test(String(message))) return;
|
||||
@@ -134,5 +138,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
window.dtfObservability = {start, apiError, scrub};
|
||||
// Every error the page shows the user in red, also the ones it caught and
|
||||
// handled itself (a folder it could not write, an upload that failed): the
|
||||
// team sees them in Sentry before anyone sends a screenshot.
|
||||
function uiError(text, where) {
|
||||
if (!started || !text || typeof Sentry === 'undefined') return;
|
||||
const said = recent.get(String(text));
|
||||
if (said && Date.now() - said < 15000) return;
|
||||
try {
|
||||
const kind = normalizedMessage(text);
|
||||
Sentry.captureMessage('Aviso ' + (where || app) + ': ' + kind,
|
||||
{level: 'error', tags: {app, aviso: where || app}, extra: {page: location.pathname},
|
||||
fingerprint: ['ui-error', where || app, kind]});
|
||||
} catch (error) {
|
||||
// Reporting an error must never break the page.
|
||||
}
|
||||
}
|
||||
|
||||
window.dtfObservability = {start, apiError, uiError, scrub};
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user