From 5daee47cb5b7b88e4469b0c25b5b04a1a2cc4cae Mon Sep 17 00:00:00 2001 From: Dan Reeves Date: Mon, 4 Dec 2023 13:13:49 +0000 Subject: [PATCH] Remove plausible :cry: --- app/entry.client.tsx | 6 ------ app/routes/_pages.tsx | 2 +- app/routes/api.event.ts | 40 +++++----------------------------------- package-lock.json | 9 --------- package.json | 1 - 5 files changed, 6 insertions(+), 52 deletions(-) diff --git a/app/entry.client.tsx b/app/entry.client.tsx index d023a7b..fbe4f0a 100644 --- a/app/entry.client.tsx +++ b/app/entry.client.tsx @@ -1,12 +1,6 @@ import { RemixBrowser } from "@remix-run/react" import { startTransition, StrictMode } from "react" import { hydrateRoot } from "react-dom/client" -import Plausible from "plausible-tracker" - -Plausible({ - domain: "darkti.de", - apiHost: "https://darkti.de", -}).enableAutoPageviews() const hydrate = () => startTransition(() => { diff --git a/app/routes/_pages.tsx b/app/routes/_pages.tsx index 5a2029b..dbedfa8 100644 --- a/app/routes/_pages.tsx +++ b/app/routes/_pages.tsx @@ -37,7 +37,7 @@ export default function PageLayout() { diff --git a/app/routes/api.event.ts b/app/routes/api.event.ts index 39bb4bb..17f1659 100644 --- a/app/routes/api.event.ts +++ b/app/routes/api.event.ts @@ -3,41 +3,11 @@ import { json } from "@remix-run/node" import { getClientIPAddress } from "remix-utils/get-client-ip-address" export async function action({ request }: ActionFunctionArgs) { - try { - const { origin } = new URL(request.url) - const analyticsHost = "https://plausible.io" - const forwardPath = request.url.replace(origin, analyticsHost) - - const clientIp = getClientIPAddress(request) - const clientUserAgent = request.headers.get("user-agent") - - if (!clientIp || !clientUserAgent) { - return null - } - - const headers = { - "content-type": "application/json", - "x-forwarded-for": clientIp, - "user-agent": clientUserAgent, - } - - let body = await request.text() - - body = body.replaceAll( - /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/g, - ":id", - ) - - return await fetch(forwardPath, { - method: request.method, - headers, - body: body, - }) - } catch (e) { - console.log("event error") - console.log(e) - return json({ e }) - } + throw new Response(null, { + status: 404, + statusText: "Not Found", + }) +} } export async function loader() { diff --git a/package-lock.json b/package-lock.json index 3ca5c1f..ed9f673 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,7 +51,6 @@ "nanoid-dictionary": "^4.3.0", "next-themes": "^0.2.1", "node-fetch-cache": "^3.1.3", - "plausible-tracker": "^0.3.8", "prettier": "^3.0.3", "prisma": "^5.5.2", "react": "^18.2.0", @@ -12480,14 +12479,6 @@ "pathe": "^1.1.0" } }, - "node_modules/plausible-tracker": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/plausible-tracker/-/plausible-tracker-0.3.8.tgz", - "integrity": "sha512-lmOWYQ7s9KOUJ1R+YTOR3HrjdbxIS2Z4de0P/Jx2dQPteznJl2eX3tXxKClpvbfyGP59B5bbhW8ftN59HbbFSg==", - "engines": { - "node": ">=10" - } - }, "node_modules/postcss": { "version": "8.4.31", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", diff --git a/package.json b/package.json index 2654844..d05b9ac 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "nanoid-dictionary": "^4.3.0", "next-themes": "^0.2.1", "node-fetch-cache": "^3.1.3", - "plausible-tracker": "^0.3.8", "prettier": "^3.0.3", "prisma": "^5.5.2", "react": "^18.2.0",