add splitbee analytics

This commit is contained in:
m5r 2022-06-27 14:37:25 +02:00
parent 740b59f389
commit c48bf58784
3 changed files with 18 additions and 0 deletions

View File

@ -136,6 +136,7 @@ const Document: FunctionComponent<PropsWithChildren<{}>> = ({ children }) => (
<body className="h-full"> <body className="h-full">
{children} {children}
<ScrollRestoration /> <ScrollRestoration />
<script async data-api="/_hive" src="/bee.js" />
<Scripts /> <Scripts />
<LiveReload /> <LiveReload />
</body> </body>

14
app/routes/_hive.$.ts Normal file
View File

@ -0,0 +1,14 @@
import type { ActionFunction } from "remix";
async function proxyHive(request: Request) {
const url = new URL(request.url);
const req = new Request("https://hive.splitbee.io" + url.pathname.replace("/_hive", ""), {
...request,
signal: null,
});
req.headers.set("x-country", request.headers.get("cf-ipcountry")!);
req.headers.set("x-real-ip", request.headers.get("x-real-ip")!);
return fetch(req);
}
export const action: ActionFunction = ({ request }) => proxyHive(request);

3
app/routes/bee[.]js.ts Normal file
View File

@ -0,0 +1,3 @@
import type { LoaderFunction } from "remix";
export const loader: LoaderFunction = () => fetch("https://cdn.splitbee.io/sb.js");