Skip to content

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

feat: add analytics to upload-zone

Marc Seitz9add2251616e
diff --git a/components/upload-zone.tsx b/components/upload-zone.tsx
index 99ec9a62..27f20b8a 100644
--- a/components/upload-zone.tsx
+++ b/components/upload-zone.tsx
@@ -1,3 +1,5 @@
+import { useRouter } from "next/router";
+
import { useCallback, useRef, useState } from "react";
import { useTeam } from "@/context/team-context";
@@ -11,9 +13,10 @@ import {
Presentation as PresentationChartBarIcon,
} from "lucide-react";
import { useSession } from "next-auth/react";
-import { FileError, FileRejection, useDropzone } from "react-dropzone";
+import { FileRejection, useDropzone } from "react-dropzone";
import { mutate } from "swr";
+import { useAnalytics } from "@/lib/analytics";
import { createDocument } from "@/lib/documents/create-document";
import { resumableUpload } from "@/lib/files/tus-upload";
import { usePlan } from "@/lib/swr/use-billing";
@@ -86,7 +89,9 @@ export default function UploadZone({
>;
folderPathName?: string;
}) {
+ const analytics = useAnalytics();
const { plan, loading } = usePlan();
+ const router = useRouter();
const teamInfo = useTeam();
const { data: session } = useSession();
const maxSize = plan === "business" || plan === "datarooms" ? 100 : 30;
@@ -184,6 +189,16 @@ export default function UploadZone({
// update progress to 100%
onUploadProgress(index, 100, document.id);
+ analytics.capture("Document Added", {
+ documentId: document.id,
+ name: document.name,
+ numPages: document.numPages,
+ path: router.asPath,
+ type: document.type,
+ teamId: teamInfo?.currentTeam?.id,
+ bulkupload: true,
+ });
+
return document;
});