feat: Números measures the site and the Prumo (0.12)
The browser records page load, upload speed and bytes, Prumo's check and the loose-art montage; the quote keeps them and Números shows average and p95 per period. Print generation and the payment-to-card time come from the database. The upload bar already estimates its remaining time.
This commit is contained in:
@@ -146,13 +146,16 @@
|
||||
const k=chaveArquivo(file);
|
||||
let e=envios.get(k);
|
||||
if (!e) {
|
||||
const T=window.dtfTimings;
|
||||
if(T){ if(T.uploadStart==null)T.uploadStart=performance.now();
|
||||
if(!T.uploadSeen.has(k)){T.uploadSeen.add(k);T.uploadBytes+=file.size;} }
|
||||
e={file, sent:0, done:false, failed:null, stop:new AbortController()};
|
||||
e.promise=(async()=>{
|
||||
const session=await ready;
|
||||
return window.dtfUpload(file,{api,scope:session.cart_scope,progress:()=>{},signal:e.stop.signal,
|
||||
onBytes:n=>{e.sent=n;pintaEnvio();}});
|
||||
})();
|
||||
e.promise.then(()=>{e.done=true;falhas.delete(k);pintaEnvio();},
|
||||
e.promise.then(()=>{e.done=true;if(window.dtfTimings)T.uploadEnd=performance.now();falhas.delete(k);pintaEnvio();},
|
||||
error=>{envios.delete(k);if(error?.name!=='AbortError')falhas.set(k,{file,error});pintaEnvio();});
|
||||
envios.set(k,e);
|
||||
}
|
||||
@@ -370,13 +373,24 @@
|
||||
// "Quero aprovar uma prova antes de imprimir": the order waits for the customer.
|
||||
if ($('fProva')?.checked) content.proof = true;
|
||||
if (cartSnapshot()!==initialCart) throw new Error('O carrinho mudou durante o envio. Confira os itens e envie de novo.');
|
||||
const serialized = JSON.stringify(content);
|
||||
// Browser timings for Números (item 0.12); they never affect the price.
|
||||
const T=window.dtfTimings, timings={};
|
||||
const nav=performance.getEntriesByType?.('navigation')?.[0];
|
||||
const pageMs=nav?.domContentLoadedEventEnd || (T?.pageStart!=null?performance.now()-T.pageStart:0);
|
||||
if(pageMs>0)timings.page_ms=Math.round(pageMs);
|
||||
if(T?.uploadStart!=null&&T.uploadEnd!=null){
|
||||
timings.upload_ms=Math.round(T.uploadEnd-T.uploadStart);
|
||||
timings.upload_bytes=Math.round(T.uploadBytes||0);
|
||||
}
|
||||
if(T?.analysisStart!=null&&T.analysisEnd!=null)timings.analysis_ms=Math.round(T.analysisEnd-T.analysisStart);
|
||||
if(T?.montageStart!=null&&T.montageEnd!=null)timings.montage_ms=Math.round(T.montageEnd-T.montageStart);
|
||||
const serialized = JSON.stringify({...content,timings});
|
||||
if (!requestKey || serialized !== requestBody) {
|
||||
requestKey = crypto.randomUUID(); requestBody = serialized;
|
||||
localStorage.setItem('dtf-request-key',requestKey);
|
||||
localStorage.setItem('dtf-request-body',requestBody);
|
||||
}
|
||||
const quote = await api('/quotes',{request_key:requestKey,...content});
|
||||
const quote = await api('/quotes',{request_key:requestKey,...content,timings});
|
||||
quotedCart=initialCart;localStorage.setItem('dtf-quote-cart',quotedCart);
|
||||
draftId=quote.id; localStorage.setItem('dtf-quote',draftId);
|
||||
await refresh(true);
|
||||
|
||||
Reference in New Issue
Block a user