Remove custom analytics in favor of Vercel defaults

The changes remove custom analytics tracking in favor of using Vercel's
default page view tracking functionality.
This commit is contained in:
2025-08-27 13:25:21 +02:00
parent 9bac3cf33c
commit 30805b7bb9
3 changed files with 9 additions and 221 deletions
+1 -50
View File
@@ -1,6 +1,4 @@
import { NextRequest, NextResponse } from "next/server";
import { track } from "@vercel/analytics/server";
import { parseBibtex } from "~/lib/bibtex";
import { readFile } from "fs/promises";
import { join } from "path";
@@ -16,47 +14,7 @@ export async function GET(
}
try {
// Read the BibTeX file to get publication metadata
const bibtexPath = join(process.cwd(), "public", "publications.bib");
const bibtexContent = await readFile(bibtexPath, "utf-8");
const publications = parseBibtex(bibtexContent);
// Find the publication that matches this PDF
const publication = publications.find(
(pub) =>
pub.paperUrl?.includes(filename) ||
pub.posterUrl?.includes(filename) ||
pub.slidesUrl?.includes(filename),
);
// Track the PDF access
if (publication) {
const isPoster = publication.posterUrl?.includes(filename);
const isSlides = publication.slidesUrl?.includes(filename);
let fileType = "paper";
if (isPoster) fileType = "poster";
if (isSlides) fileType = "slides";
await track("Publication PDF Access", {
title: publication.title,
type: publication.type,
year: publication.year.toString(),
pdf_type: fileType,
citation_key: publication.citationKey || "",
venue: publication.venue || "",
access_method: "direct_url",
filename: filename,
});
} else {
// Track unknown PDF access
await track("Unknown PDF Access", {
filename: filename,
access_method: "direct_url",
});
}
// Serve the PDF file
// Serve the PDF file directly - Vercel Analytics will automatically track the route access
const pdfPath = join(process.cwd(), "public", "publications", filename);
const pdfBuffer = await readFile(pdfPath);
@@ -69,13 +27,6 @@ export async function GET(
});
} catch (error) {
console.error("Error serving PDF:", error);
// Track the error
await track("PDF Access Error", {
filename: filename,
error: error instanceof Error ? error.message : "Unknown error",
});
return new NextResponse("PDF not found", { status: 404 });
}
}