Skip to content

Commit

Permalink
file upload tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
t3dotgg committed Jan 29, 2025
1 parent 3f56e9a commit 3ef9de1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app/f/[folderId]/drive-contents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Link from "next/link";
import { SignInButton, SignedIn, SignedOut, UserButton } from "@clerk/nextjs";
import { UploadButton } from "~/components/uploadthing";
import { useRouter } from "next/navigation";
import { usePostHog } from "posthog-js/react";

export default function DriveContents(props: {
files: (typeof files_table.$inferSelect)[];
Expand All @@ -17,6 +18,8 @@ export default function DriveContents(props: {
}) {
const navigate = useRouter();

const posthog = usePostHog();

return (
<div className="min-h-screen bg-gray-900 p-8 text-gray-100">
<div className="mx-auto max-w-6xl">
Expand Down Expand Up @@ -65,6 +68,13 @@ export default function DriveContents(props: {
</div>
<UploadButton
endpoint="driveUploader"
onBeforeUploadBegin={(files) => {
posthog.capture("files_uploading", {
fileCount: files.length,
});

return files;
}}
onClientUploadComplete={() => {
navigate.refresh();
}}
Expand Down

0 comments on commit 3ef9de1

Please sign in to comment.