Compare commits

...

3 commits

Author SHA1 Message Date
610937910c fixed date range 2024-08-27 18:35:58 +02:00
4e94fa0566 updated deps 2024-08-27 18:35:42 +02:00
af799015a7 added analytics tracking 2024-08-18 05:29:33 +02:00
3 changed files with 612 additions and 413 deletions

985
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
<script>
import { onMount } from "svelte";
import { recordRequest } from "./analytics";
let releases = [];
let searchArtist = "";
@ -43,8 +44,8 @@
: release.types) === selectedRelease ||
release.types.includes(selectedRelease);
const dateMatch =
(!startDate || new Date(release.date) >= startDate) &&
(!endDate || new Date(release.date) <= endDate);
(!startDate || new Date(release.date) >= new Date(startDate)) &&
(!endDate || new Date(release.date) <= new Date(endDate));
return artistMatch && titleMatch && releaseTypeMatch && dateMatch;
});
@ -71,6 +72,7 @@
}
onMount(async () => {
recordRequest();
try {
const response = await fetch('https://cdn.jonasjones.dev/api/kcomebacks/rkpop_data.json');
//const response = await fetch('/rkpop_data.json')

34
src/routes/analytics.js Normal file
View file

@ -0,0 +1,34 @@
// Function to record the request with analytics
export async function recordRequest() {
const analyticsData = {
timestamp: Date.now(),
domain: window.location.hostname,
method: 'GET', // Assuming the request method is GET; adjust as necessary
path: window.location.pathname,
};
console.log('Recording request:', analyticsData);
const ANALYTICS_URL = 'https://analytics.jonasjones.dev/requests/record/ipunknown';
const ANALYTICS_API_KEY = import.meta.env.VITE_ANALYTICS_API_KEY;
try {
const response = await fetch(ANALYTICS_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': ANALYTICS_API_KEY,
},
body: JSON.stringify(analyticsData),
});
if (response.ok) {
console.log('Request recorded successfully');
} else {
console.error('Failed to record request:', response.status, await response.text());
}
} catch (error) {
console.error('Error recording request:', error);
}
}