Open CharCaius opened 2 weeks ago
对应的一个配置文件config.json
内容如下:
{"aegis_env":"prod"}
没错,就这么短
回顾发现写错咯。。。。。我服了
<script src="https://tam.cdn-go.cn/aegis-sdk/latest/aegis.f.min.js" crossorigin="anonymous"></script>
<script>let VisitorID=localStorage.getItem('VisitorID');if(!VisitorID){VisitorID=(function(){const array=new Uint32Array(3);window.crypto.getRandomValues(array);return array.join('').slice(0,10)})();localStorage.setItem('VisitorID',VisitorID);console.log("UIN:",VisitorID)}else{console.log("UIN:",VisitorID)}const AegisENVs=Object.freeze({prod:'production',dev:'development',gray:'gray',pre:'pre',daily:'daily',local:'local',test:'test',others:'others'});let env=AegisENVs.prod;fetch('/config.json').then(res=>res.json()).then(config=>{env=AegisENVs[config.aegis_env]||AegisENVs.prod}).catch(error=>{console.error('获取上报环境失败:',error);env=AegisENVs.dev});</script>
<!-- Aegis Init-->
<script>
if (typeof Aegis === 'function') {
var aegis = new Aegis({
// Env
id: 'mZxy9hL2PY1GozZLD9',
uin: VisitorID,
env: env,
hostUrl: 'https://rumt-zh.com',
// Speed Report
reportApiSpeed: true,
pagePerformance: true,
reportAssetSpeed: true,
speedSample: false,
// Error Report
onError: true,
// SPA Set
spa: true,
// API
api: {
// Report
apiDetail: true,
reportRequest: true,
websocketHack: true,
usePerformanceTiming: true,
// Trace Header
// injectTraceHeader: 'traceparent',
// Header Report
// reqHeaders: ['traceparent'],
resHeaders: ['content-type', 'server'],
// Ignore URL
// injectTraceIgnoreUrls: ['/gstatic.com/', '/bilibili.com/'],
// RC Report
// retCodeHandler(data, url, xhr) {
// }
}
});
}
</script>
此代码应插入在
<head>
标签的首部以获取相对准确的数据📦 feat: 新增性能跟踪功能
以下代码需插入主页面内