Files
Hayden Bleasel 0edc599927 Docs updates (#52)
* Update meta.json

* Create posting-messages.mdx

* Colocate Slack app info

* Improve feature matrix

* Create API Reference

* Update for Channels

* Draft first guide

* Update Geistdocs
2026-02-17 13:01:15 -08:00

52 lines
1.2 KiB
TypeScript

import { siteId } from "@/geistdocs";
const PLATFORM_URL = "https://geistdocs.com/md-tracking";
interface TrackMdRequestParams {
acceptHeader: string | null;
path: string;
referer: string | null;
/** How the markdown was requested: 'md-url' for direct .md URLs, 'header-negotiated' for Accept header */
requestType?: "md-url" | "header-negotiated";
userAgent: string | null;
}
/**
* Track a markdown page request via the geistdocs platform.
* Fire-and-forget: errors are logged but don't affect the response.
*/
export async function trackMdRequest({
path,
userAgent,
referer,
acceptHeader,
requestType,
}: TrackMdRequestParams): Promise<void> {
try {
const response = await fetch(PLATFORM_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
path,
siteId: siteId ?? "geistdocs-unknown",
userAgent,
referer,
acceptHeader,
requestType,
}),
});
if (!response.ok) {
console.error(
"MD tracking failed:",
response.status,
await response.text()
);
}
} catch (error) {
console.error("MD tracking error:", error);
}
}