40 lines
835 B
TypeScript
Raw Normal View History

2019-11-18 02:04:13 +00:00
export function uploadAnalytics() {
const analytics = {
general: {
timezoneOffset: new Date().getTimezoneOffset()
},
screen: {
availableHeight: screen.availHeight,
availableWidth: screen.availWidth,
height: screen.height,
pixelRatio: window.devicePixelRatio,
width: screen.width
},
system: {
cpuCount: navigator.hardwareConcurrency,
platform: navigator.platform
},
connection: {
downLink: 0,
effectiveType: "",
roundTripTime: 0
2017-11-17 13:17:40 +00:00
}
2019-11-18 02:04:13 +00:00
}
2017-11-17 13:17:40 +00:00
2019-11-18 02:04:13 +00:00
if("connection" in navigator) {
const connection = navigator["connection"] as any
2019-11-18 02:04:13 +00:00
analytics.connection = {
downLink: connection.downlink,
roundTripTime: connection.rtt,
effectiveType: connection.effectiveType
2017-10-01 05:50:53 +00:00
}
}
2019-11-18 02:04:13 +00:00
fetch("/dark-flame-master", {
method: "POST",
credentials: "same-origin",
body: JSON.stringify(analytics)
})
2019-11-17 09:44:30 +00:00
}