blob: 9968ed5b78178f3299cd34d11442d5de2a75a315 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
async function getIpAndCountry() {
try {
const response = await fetch("https://freeipapi.com/api/json")
const data = await response.json()
return {
ip: data.ipAddress,
country: data.countryName
}
} catch (error) {
return { ip: "Unknown", country: "Unknown" }
}
}
const url = "https://analytics.miraikumiko.com/api/send"
const referrer = document.referrer
const userAgent = navigator.userAgent
const pageUrl = window.location.href
const clientData = await getIpAndCountry()
const data = {
referrer: referrer,
user_agent: userAgent,
page_url: pageUrl,
ip: clientData.ip,
country: clientData.country
}
fetch(url, {
method: "POST",
headers: {
"Token": "AAAA1234"
},
body: JSON.stringify(data)
})
|