salmon-plastic-31303
11/30/2022, 10:10 AMsalmon-plastic-31303
12/02/2022, 1:10 PMgentle-petabyte-80785
12/03/2022, 3:57 PMsalmon-plastic-31303
12/03/2022, 10:24 PMshy-kite-21035
12/06/2022, 12:28 PMexport const location = {};
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(getPosition);
} else {
return "Geolocation is not supported by this browser.";
}
}
getLocation();
function getPosition(position) {
location.latitude = position.coords.latitude;
location.longitude = position.coords.longitude;
}
You can then pass the lat/long details to the event.salmon-plastic-31303
12/08/2022, 8:25 AMexport async function transformEvent(event, metadata) {
if (event.request_ip) {
const res = await fetch("https://ip2.app/info.php?ip=" + event.request_ip);
event.context.geolocation = res;
}
return event;
}salmon-plastic-31303
12/08/2022, 8:27 AMsalmon-plastic-31303
12/08/2022, 8:27 AMsalmon-plastic-31303
12/08/2022, 8:37 AMsalmon-plastic-31303
12/08/2022, 8:59 AMsalmon-plastic-31303
12/08/2022, 12:10 PM