Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
chore: cleanup
Marc Seitz53704b206d44
diff --git a/pages/api/documents/[id]/stats.ts b/pages/api/documents/[id]/stats.tsindex 896f7c5d..aa6d97af 100644--- a/pages/api/documents/[id]/stats.ts+++ b/pages/api/documents/[id]/stats.ts@@ -9,7 +9,7 @@ export default async function handle(res: NextApiResponse) {if (req.method === "GET") {- // GET /api/documents/:id+ // GET /api/documents/:id/statsconst session = await getServerSession(req, res, authOptions);if (!session) {return res.status(401).end("Unauthorized");diff --git a/pages/api/documents/[id]/views/index.ts b/pages/api/documents/[id]/views/index.tsindex d5b1364d..fde0bb22 100644--- a/pages/api/documents/[id]/views/index.ts+++ b/pages/api/documents/[id]/views/index.ts@@ -10,13 +10,13 @@ export default async function handle(res: NextApiResponse) {if (req.method === "GET") {- // GET /api/documents/:id/visits+ // GET /api/documents/:id/viewsconst session = await getServerSession(req, res, authOptions);if (!session) {return res.status(401).end("Unauthorized");}- // get link id from query params+ // get document id from query paramsconst { id } = req.query as { id: string };try {diff --git a/pages/api/documents/index.ts b/pages/api/documents/index.tsindex 0aadd56e..44f02a3c 100644--- a/pages/api/documents/index.ts+++ b/pages/api/documents/index.ts@@ -51,13 +51,6 @@ export default async function handle(return;}- const referer = req.headers.referer;- let pathWithQuery = null;- if (referer) {- const url = new URL(referer);- pathWithQuery = url.pathname + url.search;- }-// Assuming data is an object with `name` and `description` propertiesconst { name, url, numPages } = req.body;@@ -94,6 +87,14 @@ export default async function handle(},});+ // calculate the path of the page where the document was added+ const referer = req.headers.referer;+ let pathWithQuery = null;+ if (referer) {+ const url = new URL(referer);+ pathWithQuery = url.pathname + url.search;+ }+await identifyUser((session.user as CustomUser).id);await trackAnalytics({event: "Document Added",