@sdc-monitor/demo
Version:
<div align="center"> <a href="#" target="_blank"> <img src="https://i.loli.net/2021/07/28/EvPwd4NjVH3tBfO.jpg" alt="mito-logo" height="90"> </a> <p>A Lightweight SDK For Monitor Web</p>
100 lines (97 loc) • 3.15 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>demo</title>
<script src="/browserDist/browser.min.js"></script>
</head>
<body>
<script src="./initMito.js"></script>
<h1>错误调试</h1>
<button id="codeErr" onclick="codeError()">代码错误</button>
<!-- <button id="normalReq" onclick="onClickXhrNormal()">xhr正常请求</button> -->
<button id="exceptionReq" onclick="onClickXhrError()">xhr异常请求</button>
<!-- <button id="normalFetch" onclick="onClickNativeFetch()">Fetch正常请求</button> -->
<button id="exceptionFetch" onclick="onClickNativeErrorFetch()">Fetch异常请求</button>
<button id="logUpload" onclick="mitoLog()">log上报</button>
<button id="promiseError" onclick="promiseError()">promiseError</button>
<!-- <script src="https://test-contentcenter.woa.com/content-center/lib/contentCenter.js"></script> -->
<script src="/aa.js"></script>
<img src="图片" alt="">
<link rel="stylesheet" href="css">
<!--<a href="/Vue/index.html">跳到Vue页面</a>
<a href="/Vue3/index.html">跳到Vue3页面</a>
<a href="/WebPerformance/index.html">跳到WebPerformance页面</a> -->
<script>
function codeError() {
let a = {}
a.split('/')
}
function promiseError() {
const promiseWrap = () =>
new Promise((resolve, reject) => {
reject('promise reject')
})
promiseWrap().then((res) => {
console.log('res', res)
})
}
function mitoLog() {
window._MITO_.log({ message: { one: 111 }, tag: '测试' })
}
function onClickNativeFetch() {
fetch('/normal/post', {
method: 'POST',
body: JSON.stringify({ test: '测试请求体' }),
mode: 'cors',
headers: {
'Content-Type': 'application/json'
}
}).then((res) => {
res.text().then((res) => console.log('res', res))
})
}
function onClickNativeErrorFetch() {
fetch('/exception/post', {
method: 'POST',
body: JSON.stringify({ test: '测试请求体' }),
mode: 'cors',
headers: {
'Content-Type': 'application/json'
}
}).then(
(res) => {
res.text().then((res) => console.log('res', res))
},
(err) => {
console.log('err', err)
}
)
}
function onClickXhrNormal() {
console.log('12312')
const xhr = new XMLHttpRequest()
xhr.open('get', '/normal')
xhr.setRequestHeader('content-type', 'application/json')
xhr.send()
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log(xhr.responseText)
}
}
}
function onClickXhrError() {
const xhr = new XMLHttpRequest()
xhr.open('get', '/exception')
xhr.setRequestHeader('content-type', 'application/json')
xhr.send()
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log(xhr.responseText)
}
}
}
</script>
</body>
</html>