Skip to content

Commit

Permalink
Remove plausible 😢
Browse files Browse the repository at this point in the history
  • Loading branch information
danreeves authored Dec 4, 2023
1 parent cd70cc2 commit 5daee47
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 52 deletions.
6 changes: 0 additions & 6 deletions app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function PageLayout() {
<footer className="mx-auto max-w-7xl px-4 pb-4 pt-6 sm:px-8 lg:px-10">
<div className="flex items-center justify-center gap-4 p-4 rounded-lg border bg-card text-card-foreground shadow-sm">
<a href="https://github.com/danreeves/darkti.de">Source Code</a>
<a href="https://plausible.io/darkti.de">Site Analytics</a>
{/* <a href="#TODO">Site Analytics</a> */}
</div>
</footer>
</div>
Expand Down
40 changes: 5 additions & 35 deletions app/routes/api.event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5daee47

Please sign in to comment.