41 lines
874 B
TypeScript
Raw Normal View History

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