Back

Version 34

5/26/2024
/** @jsxImportSource https://esm.sh/react */
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo?v=27";
import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
import { renderToString } from "npm:react-dom/server";

const { name, httpEndpoint } = extractValInfo(import.meta.url);

// sqlite.batch([
// {
// sql: `CREATE TABLE IF NOT EXISTS ${name}_impression (
// id INTEGER PRIMARY KEY,
// timestamp TEXT NOT NULL DEFAULT (datetime('now')),
// val TEXT NOT NULL,
// event_name TEXT,
// meta TEXT
// );`,
// args: [],
// },
// ]);

export const initAnalytics = () => {
console.log((new Error()).stack.split("\n").at(-1).split(" ").at(-1).split(":").slice(0, 2).join(":"));
// console.log(info);
};

export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
if (req.method === "GET" && url.pathname === "/pixel.png") {
console.log(req);
// dprint-ignore
const pngBytes = Uint8Array.from([
0x89, 0x50, 0x4E, 0x47, // PNG signature
0x0D, 0x0A, 0x1A, 0x0A,
0x00, 0x00, 0x00, 0x0D, // IHDR chunk
0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, // Width: 1
maxm-valtownanalytics.web.val.run
Updated: May 30, 2024