Add visitor tracking and combat selection features
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
export async function trackVisitor({ onUpdate, onError } = {}) {
|
||||
try {
|
||||
const response = await fetch("/api/visitors/check", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: "{}",
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Visitor check failed: ${response.status}`);
|
||||
}
|
||||
|
||||
const visitorStats = await response.json();
|
||||
onUpdate?.(visitorStats);
|
||||
return visitorStats;
|
||||
} catch (error) {
|
||||
onError?.(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user