Add logging for client IP in postAnalytics and update Lanyard styles to use RGB format
Some checks failed
Code quality checks / biome (push) Failing after 8s
Some checks failed
Code quality checks / biome (push) Failing after 8s
This commit is contained in:
parent
dcd6bfc3d7
commit
bf32c3fd35
3 changed files with 27 additions and 21 deletions
1
config.yml
Normal file
1
config.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{}
|
|
@ -47,6 +47,13 @@ const postAnalytics = async (
|
||||||
req: Request | Bun.BunRequest,
|
req: Request | Bun.BunRequest,
|
||||||
server: Bun.Server,
|
server: Bun.Server,
|
||||||
) => {
|
) => {
|
||||||
|
console.log(String(
|
||||||
|
req.headers.get("CF-Connecting-IP") ||
|
||||||
|
req.headers.get("X-Real-IP") ||
|
||||||
|
req.headers.get("X-Forwarded-For")?.split(",")[0] ||
|
||||||
|
(typeof server.requestIP(req) === "string"
|
||||||
|
? server.requestIP(req)
|
||||||
|
: server.requestIP(req)?.address || "")));
|
||||||
return await fetch("https://plausible.creations.works/api/event", {
|
return await fetch("https://plausible.creations.works/api/event", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -3,17 +3,17 @@ import { createRef } from "tsx-dom";
|
||||||
import socket from "../../Socket";
|
import socket from "../../Socket";
|
||||||
|
|
||||||
const statusTypes = {
|
const statusTypes = {
|
||||||
online: "rgb(0, 150, 0)",
|
online: "0, 150, 0",
|
||||||
idle: "rgb(150, 150, 0)",
|
idle: "150, 150, 0",
|
||||||
dnd: "rgb(150, 0, 0)",
|
dnd: "150, 0, 0",
|
||||||
offline: "rgb(150, 150, 150)",
|
offline: "150, 150, 150",
|
||||||
};
|
};
|
||||||
|
|
||||||
const gradientTypes = {
|
const gradientTypes = {
|
||||||
online: "rgba(0, 150, 0, 0.1)",
|
online: "0, 150, 0",
|
||||||
idle: "rgba(150, 150, 0, 0.1)",
|
idle: "150, 150, 0",
|
||||||
dnd: "rgba(150, 0, 0, 0.1)",
|
dnd: "150, 0, 0",
|
||||||
offline: "rgba(150, 150, 150, 0.1)",
|
offline: "150, 150, 150",
|
||||||
};
|
};
|
||||||
|
|
||||||
const activityTypes: Record<number, string> = {
|
const activityTypes: Record<number, string> = {
|
||||||
|
@ -31,21 +31,19 @@ export default () => {
|
||||||
socket.addEventListener("lanyard", (event: Event) => {
|
socket.addEventListener("lanyard", (event: Event) => {
|
||||||
const lanyard = (event as CustomEvent<LanyardData>).detail;
|
const lanyard = (event as CustomEvent<LanyardData>).detail;
|
||||||
|
|
||||||
document.body.style = `--status-color: ${statusTypes[lanyard.discord_status]}; --gradient-color: ${gradientTypes[lanyard.discord_status]};`;
|
document.body.style = `--status-color: rgb(${statusTypes[lanyard.discord_status]}); --gradient-color: rgba(${gradientTypes[lanyard.discord_status]}, 0.1);`;
|
||||||
|
|
||||||
if (container.current) {
|
if (container.current) {
|
||||||
container.current.className = "shj-lang-json";
|
|
||||||
container.current.textContent = JSON.stringify(
|
container.current.textContent = JSON.stringify(
|
||||||
{
|
{
|
||||||
status: lanyard.discord_status,
|
status: lanyard.discord_status,
|
||||||
activities: lanyard.activities.map((act) => {
|
activities: [... new Set(lanyard.activities.map((act) => {
|
||||||
const type = activityTypes[act.type];
|
const type = activityTypes[act.type];
|
||||||
const parts = [type];
|
const parts = [`${type} ${act.name}`];
|
||||||
if (act.name !== type) parts.push(act.name);
|
if (act.details && act.details !== act.name) parts.push(act.details);
|
||||||
if (act.details) parts.push(act.details);
|
if (act.state && act.state !== act.name) parts.push(act.state);
|
||||||
if (act.state) parts.push(act.state);
|
|
||||||
return parts;
|
return parts;
|
||||||
}),
|
}))],
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
2,
|
2,
|
||||||
|
|
Loading…
Add table
Reference in a new issue