Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: track delete domain
Marc Seitz3a1fd369dc79
diff --git a/lib/types.ts b/lib/types.tsindex 6edd4476..922b50e8 100644--- a/lib/types.ts+++ b/lib/types.ts@@ -122,7 +122,7 @@ export type AnalyticsEvents =documentId: string;customDomain: string | null | undefined;}- | { event: "User Upgraded"; email: string | null | undefined; }+ | { event: "User Upgraded"; email: string | null | undefined }| {event: "User Signed In";email: string | null | undefined;@@ -141,4 +141,8 @@ export type AnalyticsEvents =| {event: "Domain Verified";slug: string;+ }+ | {+ event: "Domain Deleted";+ slug: string;};\ No newline at end of filediff --git a/pages/api/domains/[domain]/index.ts b/pages/api/domains/[domain]/index.tsindex ead45758..c8d64328 100644--- a/pages/api/domains/[domain]/index.ts+++ b/pages/api/domains/[domain]/index.ts@@ -5,6 +5,7 @@ import { authOptions } from "@/pages/api//auth/[...nextauth]";import { log } from "@/lib/utils";import { getApexDomain, removeDomainFromVercel } from "@/lib/domains";import { CustomUser } from "@/lib/types";+import { identifyUser, trackAnalytics } from "@/lib/analytics";export default async function handle(req: NextApiRequest,@@ -66,6 +67,11 @@ export default async function handle(id: domainToBeDeleted.id,},}),+ identifyUser((session.user as CustomUser).id),+ trackAnalytics({+ event: "Domain Deleted",+ slug: domain,+ }),]);res.status(204).end(); // 204 No Content response for successful deletes