Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

refactor(analytics): domain added

Marc Seitz02f13bfc8cc0
diff --git a/components/domains/add-domain-modal.tsx b/components/domains/add-domain-modal.tsx
index f1ecec2e..0ac217c2 100644
--- a/components/domains/add-domain-modal.tsx
+++ b/components/domains/add-domain-modal.tsx
@@ -15,6 +15,7 @@ import { useState } from "react";
import { toast } from "sonner";
import { UpgradePlanModal } from "../billing/upgrade-plan-modal";
import { usePlan } from "@/lib/swr/use-billing";
+import { useAnalytics } from "@/lib/analytics";
export function AddDomainModal({
open,
@@ -32,6 +33,7 @@ export function AddDomainModal({
const teamInfo = useTeam();
const { plan } = usePlan();
+ const analytics = useAnalytics();
const handleSubmit = async (event: any) => {
event.preventDefault();
@@ -63,6 +65,7 @@ export function AddDomainModal({
const newDomain = await response.json();
+ analytics.capture("Domain Added", { slug: domain });
toast.success("Domain added successfully! 🎉");
// Update local data with the new link
diff --git a/pages/api/teams/[teamId]/domains/index.ts b/pages/api/teams/[teamId]/domains/index.ts
index 13ab9da9..19a251ca 100644
--- a/pages/api/teams/[teamId]/domains/index.ts
+++ b/pages/api/teams/[teamId]/domains/index.ts
@@ -82,15 +82,13 @@ export default async function handle(
});
await addDomainToVercel(domain);
- await identifyUser(userId);
- await trackAnalytics({
- event: "Domain Added",
- slug: domain,
- });
-
return res.status(201).json(response);
} catch (error) {
- log({message: `Failed to add domain. \n\n ${error} \n\n*Metadata*: \`{teamId: ${teamId}, userId: ${userId}}\``, type: "error", mention: true});
+ log({
+ message: `Failed to add domain. \n\n ${error} \n\n*Metadata*: \`{teamId: ${teamId}, userId: ${userId}}\``,
+ type: "error",
+ mention: true,
+ });
errorhandler(error, res);
}
} else {