Skip to content

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

add plausible events

Marc Seitz5325b830cc62
diff --git a/pages/documents/[id]/chat.tsx b/pages/documents/[id]/chat.tsx
index 101d7d2c..8f7bb1be 100644
--- a/pages/documents/[id]/chat.tsx
+++ b/pages/documents/[id]/chat.tsx
@@ -8,6 +8,8 @@ import Sparkle from "@/components/shared/icons/sparkle";
import { usePlan } from "@/lib/swr/use-billing";
import { Button } from "@/components/ui/button";
import Link from "next/link";
+import { usePlausible } from "next-plausible";
+import { useEffect } from "react";
export const getServerSideProps = async (context: any) => {
const { id } = context.params;
@@ -107,6 +109,14 @@ export default function ChatPage({
documentId: string;
}) {
const { plan } = usePlan();
+ const plausible = usePlausible();
+
+ useEffect(() => {
+ plausible("assistantViewedFromDocument", {
+ props: { documentId: documentId },
+ });
+ }, []);
+
return (
<>
<Nav documentId={documentId} />
diff --git a/pages/documents/[id]/index.tsx b/pages/documents/[id]/index.tsx
index 6375601a..678059e3 100644
--- a/pages/documents/[id]/index.tsx
+++ b/pages/documents/[id]/index.tsx
@@ -28,6 +28,7 @@ import ProcessStatusBar from "@/components/documents/process-status-bar";
import NotionIcon from "@/components/shared/icons/notion";
import PapermarkSparkle from "@/components/shared/icons/papermark-sparkle";
import { Document } from "@prisma/client";
+import { usePlausible } from "next-plausible";
export default function DocumentPage() {
const { document: prismaDocument, primaryVersion, error } = useDocument();
@@ -43,6 +44,7 @@ export default function DocumentPage() {
const dropdownRef = useRef<HTMLDivElement | null>(null);
const teamInfo = useTeam();
+ const plausible = usePlausible();
const handleNameSubmit = async () => {
if (enterPressedRef.current) {
@@ -176,6 +178,7 @@ export default function DocumentPage() {
}),
}).then(() => {
// Once the assistant is activated, redirect to the chat
+ plausible("assistantEnabled", { props: { documentId: document.id } }); // track the event
router.push(`/documents/${document.id}/chat`);
}),
{
diff --git a/pages/view/[linkId]/chat.tsx b/pages/view/[linkId]/chat.tsx
index c599b3f4..0d2a1c75 100644
--- a/pages/view/[linkId]/chat.tsx
+++ b/pages/view/[linkId]/chat.tsx
@@ -8,6 +8,8 @@ import Sparkle from "@/components/shared/icons/sparkle";
import { usePlan } from "@/lib/swr/use-billing";
import Link from "next/link";
import { Button } from "@/components/ui/button";
+import { usePlausible } from "next-plausible";
+import { useEffect } from "react";
export const getServerSideProps = async (context: any) => {
const { linkId } = context.params;
@@ -107,6 +109,11 @@ export default function ChatPage({
linkId: string;
}) {
const { plan } = usePlan();
+ const plausible = usePlausible();
+
+ useEffect(() => {
+ plausible("assistantViewedFromLink", { props: { linkId: linkId } });
+ }, []);
return (
<>