Download frontend/src/diagnostics.mjs from Wizzas/DefectRAG: direct link, hf CLI and curl.
- Browser
- Download file 2.06 kB
-
https://huggingface.co/Wizzas/DefectRAG/resolve/main/frontend/src/diagnostics.mjs
- Command line
-
hf download hf://Wizzas/DefectRAG/frontend/src/diagnostics.mjs
-
curl -L -o diagnostics.mjs https://huggingface.co/Wizzas/DefectRAG/resolve/main/frontend/src/diagnostics.mjs
2.06 kB
| // A small, private record of recent problems for the Help page's "Copy details" | |
| // button. It never stores emails, tokens, file names, notes or photos. | |
| const MAX=15; | |
| const issues=[]; | |
| /* global __APP_BUILD__ */ | |
| export const build=typeof __APP_BUILD__==='object'&&__APP_BUILD__?__APP_BUILD__:{version:'dev',commit:'local',built:''}; | |
| const scrub=value=>String(value||'') | |
| .replace(/[\w.+-]+@[\w-]+\.[\w.-]+/g,'[email]') | |
| .replace(/eyJ[\w-]+\.[\w-]+\.[\w-]+/g,'[token]') | |
| .replace(/(bearer|apikey|key|token)=?\s*[\w-]{16,}/gi,'$1 [hidden]') | |
| .slice(0,300); | |
| export function recordIssue(kind,message,extra={}){ | |
| const path=String(extra.path||'').split('?')[0].replace(/[0-9a-f]{8,}/gi,':id'); | |
| issues.push({at:new Date().toISOString(),kind,message:scrub(message),status:extra.status??null,path}); | |
| if(issues.length>MAX)issues.splice(0,issues.length-MAX); | |
| } | |
| export function recentIssues(){return issues.slice()} | |
| export function clearIssues(){issues.length=0} | |
| export function diagnosticReport(context={},env=globalThis){ | |
| const nav=env.navigator||{},screen=env.innerWidth?env.innerWidth+'脳'+env.innerHeight:'unknown'; | |
| const lines=[ | |
| 'DefectRAG diagnostic details', | |
| 'Version: '+build.version+' 路 build '+build.commit+(build.built?' 路 '+build.built:''), | |
| 'Page: '+(context.page||'unknown')+' 路 mode: '+(context.mode||'unknown')+' 路 sync: '+(context.sync||'unknown'), | |
| 'Signed in: '+(context.signedIn?'yes':'no')+' 路 workspace: '+(context.workspace||'unknown'), | |
| 'Screen: '+screen+' 路 theme: '+(context.theme||'unknown')+' 路 text size: '+(context.textSize?Math.round(context.textSize*100)+'%':'unknown'), | |
| 'Browser: '+scrub(nav.userAgent||'unknown'), | |
| 'Online: '+(nav.onLine===false?'no':'yes'), | |
| 'Time: '+new Date().toISOString(), | |
| '', | |
| 'Recent problems ('+issues.length+'):' | |
| ]; | |
| if(!issues.length)lines.push('none recorded in this tab'); | |
| for(const item of issues.slice().reverse())lines.push('- '+item.at+' 路 '+item.kind+(item.status?' '+item.status:'')+(item.path?' 路 '+item.path:'')+' 路 '+item.message); | |
| return lines.join('\n'); | |
| } | |