-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
30 additions
and
11 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
export function logusage() { | ||
const params = new URLSearchParams(location.search) | ||
const ruletype = params.get("ruletype") ?? "nineball" | ||
const mode = params.get("state") ? "replay" : "play" | ||
const url = `https://scoreboard-tailuge.vercel.app/usage/${mode}/${ruletype}` | ||
|
||
fetch(url, { | ||
method: "GET", | ||
mode: "cors", | ||
headers: { "Content-Type": "application/json" }, | ||
}) | ||
} | ||
if (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1") { | ||
console.log("Skipping usage fetch for localhost.") | ||
return; | ||
} | ||
|
||
const url = `https://scoreboard-tailuge.vercel.app/api/usage/game` | ||
|
||
try { | ||
fetch(url, { | ||
method: "PUT", | ||
mode: "cors", | ||
}) | ||
.then(response => { | ||
if (!response.ok) { | ||
// Log HTTP errors (e.g., 4xx, 5xx) | ||
console.error("HTTP error:", response.status, response.statusText) | ||
} | ||
}) | ||
.catch(error => { | ||
// Log network errors or other fetch-related errors | ||
console.error("Fetch error:", error) | ||
}); | ||
} catch (error) { | ||
// Log any synchronous errors that occur in the try block | ||
console.error("Error in logusage:", error) | ||
} | ||
} |