Merge main into bugs-uploads
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> # Conflicts: # web/checkout.js
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
const error=new Error(text);error.status=response.status;
|
||||
const retry=response.headers.get('Retry-After');
|
||||
if(retry!=null)error.retryAfter=retry;
|
||||
window.dtfObservability?.apiError?.(path,response.status,error.message,data.detail);
|
||||
throw error;
|
||||
}
|
||||
return data;
|
||||
@@ -70,6 +71,9 @@
|
||||
}
|
||||
const ready = api('/session');
|
||||
ready.then(session=>{
|
||||
window.dtfEnvironment=session.sentry_environment||session.environment;
|
||||
window.dtfRelease=session.sentry_release||undefined;
|
||||
window.dtfObservability?.start?.(session.sentry_dsn_web,'site');
|
||||
window.dtfUploadMaxBytes=session.max_upload_bytes;
|
||||
const limit=document.getElementById('zLimite');
|
||||
if(limit)limit.textContent='Até '+(session.max_upload_bytes/1073741824).toFixed(0)+' GB por arquivo.';
|
||||
|
||||
@@ -641,6 +641,8 @@ h2 em{font-style:normal;color:var(--laranja)}
|
||||
@media(prefers-reduced-motion:reduce){*{transition:none!important;scroll-behavior:auto}}
|
||||
</style>
|
||||
<link rel="stylesheet" href="/site-v2.css">
|
||||
<script src="/vendor/sentry.min.js"></script>
|
||||
<script src="/observability.js"></script>
|
||||
<script src="/site-pages.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -297,4 +297,4 @@
|
||||
<div class="scrim" id="scrim"></div>
|
||||
<aside class="drawer" id="panel" aria-label="Pedido"></aside>
|
||||
</div>
|
||||
<script src="/upload.js"></script><script src="/kanban-viewer.js"></script><script src="/kanban.js"></script><script src="/kanban-label.js"></script><script src="/kanban-numbers.js"></script><script src="/kanban-site.js"></script><script src="/packing.js"></script><script src="/kanban-montador.js"></script></body></html>
|
||||
<script src="/vendor/sentry.min.js"></script><script src="/observability.js"></script><script src="/upload.js"></script><script src="/kanban-viewer.js"></script><script src="/kanban.js"></script><script src="/kanban-label.js"></script><script src="/kanban-numbers.js"></script><script src="/kanban-site.js"></script><script src="/packing.js"></script><script src="/kanban-montador.js"></script></body></html>
|
||||
|
||||
@@ -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)));
|
||||
|
||||
120
web/observability.js
Normal file
120
web/observability.js
Normal file
@@ -0,0 +1,120 @@
|
||||
/* Sentry for the Site and the Kanban, used only when the DSN arrives from the
|
||||
API. It loads after web/vendor/sentry.min.js and never fetches anything
|
||||
itself; DSNs are public by design, so an empty one leaves everything off.
|
||||
|
||||
beforeSend follows the server (app/observability.py): no cookies, credential
|
||||
headers, request bodies or signed/token query strings, and CPF/CNPJ and
|
||||
e-mails replaced by [removido]. */
|
||||
(function () {
|
||||
const EMAIL = /[^\s@]+@[^\s@]+\.[A-Za-z]{2,}/g;
|
||||
const DOCUMENT = /(?<!\d)(?:\d{2}\.?\d{3}\.?\d{3}\/?\d{4}-?\d{2}|\d{3}\.?\d{3}\.?\d{3}-?\d{2})(?!\d)/g;
|
||||
const SENSITIVE_PARAM = /token|signature|x-amz/i;
|
||||
const SENSITIVE_HEADER = /^(cookie|authorization|x-.*token.*)$/i;
|
||||
const REDACTED = '[removido]';
|
||||
let started = false;
|
||||
let app = '';
|
||||
|
||||
const clean = value => String(value == null ? '' : value)
|
||||
.replace(EMAIL, REDACTED).replace(DOCUMENT, REDACTED);
|
||||
|
||||
function scrubQuery(query) {
|
||||
if (!query) return query;
|
||||
return String(query).split('&').filter(part => {
|
||||
let key = part.split('=')[0] || '';
|
||||
try { key = decodeURIComponent(key.replace(/\+/g, ' ')); } catch (error) { /* keep the raw key */ }
|
||||
return !SENSITIVE_PARAM.test(key);
|
||||
}).join('&');
|
||||
}
|
||||
|
||||
function scrubText(value) {
|
||||
if (typeof value !== 'string') return value;
|
||||
value = clean(value);
|
||||
const at = value.indexOf('?');
|
||||
return at < 0 ? value : value.slice(0, at + 1) + scrubQuery(value.slice(at + 1));
|
||||
}
|
||||
|
||||
function scrubUrl(url) {
|
||||
if (typeof url !== 'string') return url;
|
||||
const at = url.indexOf('?');
|
||||
return at < 0 ? url : url.slice(0, at + 1) + scrubQuery(url.slice(at + 1));
|
||||
}
|
||||
|
||||
function scrubValue(value) {
|
||||
if (typeof value === 'string') return scrubText(value);
|
||||
if (Array.isArray(value)) return value.map(scrubValue);
|
||||
if (value && typeof value === 'object') {
|
||||
const out = {};
|
||||
for (const [key, item] of Object.entries(value)) out[key] = scrubValue(item);
|
||||
return out;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function scrubRequest(request) {
|
||||
if (!request || typeof request !== 'object') return;
|
||||
delete request.cookies;
|
||||
delete request.data;
|
||||
delete request.body;
|
||||
if (request.headers && typeof request.headers === 'object') {
|
||||
for (const key of Object.keys(request.headers)) {
|
||||
if (SENSITIVE_HEADER.test(key)) delete request.headers[key];
|
||||
}
|
||||
}
|
||||
if (request.query_string) request.query_string = scrubQuery(request.query_string);
|
||||
if (request.url) request.url = scrubUrl(request.url);
|
||||
}
|
||||
|
||||
function scrub(event) {
|
||||
if (!event || typeof event !== 'object') return event;
|
||||
scrubRequest(event.request);
|
||||
if (typeof event.message === 'string') event.message = scrubText(event.message);
|
||||
if (event.logentry && typeof event.logentry.message === 'string')
|
||||
event.logentry.message = scrubText(event.logentry.message);
|
||||
if (event.exception && Array.isArray(event.exception.values)) {
|
||||
for (const value of event.exception.values) {
|
||||
if (value && typeof value.value === 'string') value.value = scrubText(value.value);
|
||||
}
|
||||
}
|
||||
let breadcrumbs = event.breadcrumbs;
|
||||
if (breadcrumbs && !Array.isArray(breadcrumbs)) breadcrumbs = breadcrumbs.values;
|
||||
if (Array.isArray(breadcrumbs)) {
|
||||
for (const crumb of breadcrumbs) {
|
||||
if (!crumb || typeof crumb !== 'object') continue;
|
||||
if (typeof crumb.message === 'string') crumb.message = scrubText(crumb.message);
|
||||
if (crumb.data) crumb.data = scrubValue(crumb.data);
|
||||
}
|
||||
}
|
||||
if (event.extra) event.extra = scrubValue(event.extra);
|
||||
if (event.user) event.user = scrubValue(event.user);
|
||||
return event;
|
||||
}
|
||||
|
||||
function start(dsn, component) {
|
||||
if (started || !dsn || typeof Sentry === 'undefined') return;
|
||||
started = true;
|
||||
app = component || '';
|
||||
const options = {dsn, sendDefaultPii: false, beforeSend: scrub};
|
||||
if (window.dtfEnvironment) options.environment = window.dtfEnvironment;
|
||||
if (window.dtfRelease) options.release = window.dtfRelease;
|
||||
try {
|
||||
Sentry.init(options);
|
||||
Sentry.setTag('app', app);
|
||||
} catch (error) {
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
|
||||
function apiError(path, status, message, detail) {
|
||||
if (!started || status === 401 || typeof Sentry === 'undefined') return;
|
||||
try {
|
||||
const extra = {path, status, page: location.pathname};
|
||||
if (status === 422 && detail) extra.detail = detail;
|
||||
Sentry.captureMessage(clean('API ' + status + ' ' + path + ': ' + (message || '')),
|
||||
{level: 'error', tags: {app}, extra});
|
||||
} catch (error) {
|
||||
// Reporting an error must never break the page.
|
||||
}
|
||||
}
|
||||
|
||||
window.dtfObservability = {start, apiError, scrub};
|
||||
})();
|
||||
21
web/vendor/LICENSE-sentry.txt
vendored
Normal file
21
web/vendor/LICENSE-sentry.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Functional Software, Inc. dba Sentry
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
7
web/vendor/README.md
vendored
7
web/vendor/README.md
vendored
@@ -31,3 +31,10 @@ curl -s "https://api.cdnjs.com/libraries/pdf.js/<version>?fields=sri"
|
||||
documented workaround is `isEvalSupported: false`; `web/index.html` already passes
|
||||
that, so the known path is closed. Upgrading is worthwhile but is an API change,
|
||||
not a file swap, and belongs with its own browser testing — see `ROADMAP.md` 2.7.
|
||||
|
||||
## Sentry browser SDK 11.12.0
|
||||
|
||||
One line per vendored file: source, version, date and SHA-256.
|
||||
|
||||
- `sentry.min.js` — https://browser.sentry-cdn.com/11.12.0/bundle.min.js — @sentry/browser 11.12.0 — 2026-11-11 — sha256 `388cdc69ba60b5a883097874ee8e5e010543990d60b5846d9dd1a4e736a49902`
|
||||
- `LICENSE-sentry.txt` — https://registry.npmjs.org/@sentry/browser/-/browser-11.12.0.tgz (`package/LICENSE`) — @sentry/browser 11.12.0 — 2026-11-11 — sha256 `f3df0b92efcd9d8cc0de5a36c151569a12a647d65b851abbb696ef7b13dee10b`
|
||||
|
||||
3
web/vendor/sentry.min.js
vendored
Normal file
3
web/vendor/sentry.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user