mirror of
https://github.com/vercel/flags.git
synced 2026-09-19 03:49:23 +08:00
cf9ccd0076
* Scaffold Geistdocs instance * Update biome.json * Replace content * Re-path docs * Update docs package name * Misc fixes * Update geistdocs.tsx * Move content to correct folder * Start migrating custom components * Finish migrating custom components * Migrate existing redirects * Remove #next suffixes from code blocks * Migrate homepage and flags * Remove duplicate lockfiles * Start fixing homepage * Replace Geist components * Fix colors * Improve layout * Fix code blocks * Fix hero * Fix illustrations * Fix redirect * Fix nav links * Patch in FrameworkSwitcher * Bump Next.js in docs * Delete turbo.json * Misc fixes * More logo fixes
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { siteId } from "@/geistdocs";
|
|
|
|
const PLATFORM_URL = "https://geistdocs.com/md-tracking";
|
|
|
|
type TrackMdRequestParams = {
|
|
path: string;
|
|
userAgent: string | null;
|
|
referer: string | null;
|
|
acceptHeader: string | null;
|
|
/** How the markdown was requested: 'md-url' for direct .md URLs, 'header-negotiated' for Accept header */
|
|
requestType?: "md-url" | "header-negotiated";
|
|
};
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
}
|