mirror of
https://github.com/JonasunderscoreJones/K-Comebacks.git
synced 2025-10-22 17:39:19 +02:00
Compare commits
3 commits
441e3d5dec
...
610937910c
Author | SHA1 | Date | |
---|---|---|---|
610937910c | |||
4e94fa0566 | |||
af799015a7 |
3 changed files with 612 additions and 413 deletions
985
package-lock.json
generated
985
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -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
34
src/routes/analytics.js
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue