您可以通過發送一個得到你想要的數據使用相關的調試信息向您的服務器發送HTTP請求。這有點令人討厭,因爲它適用於您的生產站點上的所有用戶,並且如果您可以將Safari附加到調試中,您將擁有的功能遠不及您所需,但可能適用於此特定情況。
一些基本的JS提供瞭如何可能會圍繞發送頁面加載和/或用戶事件觸發的總體思路事件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<button>Click Me</button>
<script>
var sendDebug = function(simpleObject) {
var serializedObject = JSON.stringify(simpleObject);
var iPhone = navigator.userAgent.indexOf('iPhone') > 0;
var xhr = new XMLHttpRequest();
xhr.open('GET', `https://null.jsbin.com?iphone=${iPhone}&info=${serializedObject}`);
xhr.send(null);
}
document.querySelector('button').addEventListener('click', function() {
sendDebug('clicked the button');
})
sendDebug('page loaded');
</script>
</body>
</html>
我包括基於該navigator.userAgent
粗iPhone
布爾;你可以考慮只爲iPhone發送數據,這樣你就不會在非iPhone請求中混淆日誌(注意userAgent可以從應用程序中修改,所以你需要仔細檢查它們發送的內容)。儘管取決於您處理的流量,但這可能不夠節流。
這將創建HTTP請求並將調試數據附加到查詢字符串。這些應該是在你的訪問日誌中可見的服務器上:
https://null.jsbin.com/?iphone=false&info=%22clicked%20the%20button%22
http://jsbin.com/novowoduka/edit?html,output
除非Apple在最新版本的iOS中進行了更改,否則該功能僅適用於應用程序的調試版本,而不適用於通過應用商店獲取的應用程序。 – asgallant
鏈接到Apple文檔已損壞 – dsjoerg