Skip to content

Commit

Permalink
Revert "add plausible server side analytics" (#2366)
Browse files Browse the repository at this point in the history
Revert "add plausible server side analytics (#2308)"

This reverts commit 3180988.
  • Loading branch information
recursiveforte authored Sep 18, 2024
1 parent a702059 commit 57d146a
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
import metrics from "../metrics";
import {APIContext} from "astro";

export async function onRequest({ request, clientAddress }: APIContext, next: () => any) {
export async function onRequest({ request }: any, next: () => any) {
const path = new URL(request.url).pathname.slice(1);

await fetch("https://plausible.io/api/event", {
method: "POST",
headers: {
"Content-Type": "application/json",
"User-Agent": request.headers.get("User-Agent")!,
"X-Forwarded-For": clientAddress,
},
body: JSON.stringify({
domain: "sprig.hackclub.com",
url: request.url,
name: "pageview"
})
})


if (!path.includes("api")) return next();

const metricName = path.split("/").join("_");
Expand Down

0 comments on commit 57d146a

Please sign in to comment.