Javascript 为什么从Firefox浏览器访问时,站点时间数据不能保存在DB中?
根据doc中的说明,我们在网站中加入了TimeSite库Javascript 为什么从Firefox浏览器访问时,站点时间数据不能保存在DB中?,javascript,firefox,mariadb,analytics,Javascript,Firefox,Mariadb,Analytics,根据doc中的说明,我们在网站中加入了TimeSite库 <script type="text/javascript"> var Tos; (function(d, s, id, file) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; j
<script type="text/javascript">
var Tos;
(function(d, s, id, file) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.onload = function() {
// save with XMLHttpRequest or sendBeacon
var config = {
trackBy: 'seconds',
developerMode: true,
callback: function(data) {
console.log('***');
console.log(data);
// give your endpoint URL/ server-side URL that is going to handle your TOS data which is of POST method. Eg. PHP, nodejs or python URL which saves this data to your DB
var endPointUrl = 'http://localhost:4500/tos'; // replace with your endpoint URL
if (data && data.trackingType) {
if (data.trackingType == 'tos') {
if (Tos.verifyData(data) != 'valid') {
console.log('Data abolished!');
return;
}
}
if (navigator && typeof navigator.sendBeacon === 'function') {
data.trasferredWith = 'sendBeacon';
var blob = new Blob([JSON.stringify(data)], {type : 'application/json'});
navigator.sendBeacon(endPointUrl, blob);
}
}
}};
if(TimeOnSiteTracker) {
Tos = new TimeOnSiteTracker(config);
}
};
js.src = file;fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'TimeOnSiteTracker', '//cdn.jsdelivr.net/gh/saleemkce/timeonsite@1.1.0/timeonsitetracker.min.js'));
</script>
但此会话数据不存储在MariaDB中。没有任何线索表明数据去了哪里。在刷新第二页时,我再次在Firefox web控制台中看到更新的数据对象,但在MariaDB中没有捕获数据。它在Chrome中工作,但似乎无法在DB中正确存储数据。你知道如何在Firefox中解决这个问题吗
我跟着火车走。非常感谢您的帮助。为什么不发布您的服务器端代码,以便我们可以查看它?我使用开发人员提供的免费后端代码库“visual”,用于PHP和NodeJ的完整后端代码可以在这个后端文件夹中看到。我使用PHP。我不认为问题可能出现在后端,因为它在Chrome中工作。
***
{
TOSId: 14650383319214848
TOSSessionKey: "8808159448467693499978"
TOSUserId: "anonymous"
URL: "https://localhost/index.html"
currentTime: "2021-03-30 16:25:17.908"
entryTime: "2021-03-30 16:24:36.911"
timeOnPage: 41
timeOnPageByDuration: "0d 00h 00m 41s"
timeOnPageTrackedBy: "second"
timeOnSite: 41
timeOnSiteByDuration: "0d 00h 00m 41s"
title: "home page - rental crown"
trackingType: "tos"
}