Skip to content

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

chore: small additions

Marc Seitz0d8ade90d9f4
diff --git a/components/documents/stats-card.tsx b/components/documents/stats-card.tsx
index f56df1e4..17bc88a4 100644
--- a/components/documents/stats-card.tsx
+++ b/components/documents/stats-card.tsx
@@ -12,17 +12,17 @@ export default function StatsCard() {
const statistics = [
{
- name: "Number of views",
+ name: "Number of visits",
value: stats?.views.length.toString() ?? "0",
active: true,
},
{
- name: "Number of unique viewers",
+ name: "Number of unique visitors",
value: stats?.groupedViews.length.toString() ?? "0",
active: true,
},
{
- name: "Total view duration",
+ name: "Total avgerage view duration",
value:
stats?.total_duration == null
? "46"
diff --git a/components/links/links-visitors.tsx b/components/links/links-visitors.tsx
index cb5504df..31327f69 100644
--- a/components/links/links-visitors.tsx
+++ b/components/links/links-visitors.tsx
@@ -27,11 +27,11 @@ export default function LinksVisitors({linkId, linkName}: {linkId: string, linkN
<div className="min-w-0 flex-1">
<div className="focus:outline-none">
<p className="text-sm font-medium text-gray-200 overflow-visible">
- {view.viewerEmail}
+ {view.viewerEmail ? view.viewerEmail : "Anonymous"}
</p>
- <p className="text-sm text-gray-500">
+ {/* <p className="text-sm text-gray-500">
<span>{linkName}</span>
- </p>
+ </p> */}
</div>
</div>
</div>
diff --git a/components/visitors/visitors-table.tsx b/components/visitors/visitors-table.tsx
index 90ae2778..e8c068d6 100644
--- a/components/visitors/visitors-table.tsx
+++ b/components/visitors/visitors-table.tsx
@@ -32,9 +32,7 @@ export default function VisitorsTable({numPages}: {numPages: number}) {
<Table>
<TableHeader>
<TableRow className="hover:bg-transparent">
- <TableHead className="font-medium">
- Name
- </TableHead>
+ <TableHead className="font-medium">Name</TableHead>
<TableHead className="font-medium">Visit Duration</TableHead>
<TableHead className="font-medium">Visit Completion</TableHead>
<TableHead className="font-medium">Last Viewed</TableHead>
@@ -58,10 +56,10 @@ export default function VisitorsTable({numPages}: {numPages: number}) {
<div className="min-w-0 flex-1">
<div className="focus:outline-none">
<p className="text-sm font-medium text-gray-200 overflow-visible">
- {view.viewerEmail}
+ {view.viewerEmail? view.viewerEmail : "Anonymous"}
</p>
<p className="text-sm text-gray-500">
- <span>Link Name</span>
+ {view.link.name ? view.link.name : view.linkId}
</p>
</div>
</div>
diff --git a/lib/swr/use-document.ts b/lib/swr/use-document.ts
index 1355b9d0..0592dc4d 100644
--- a/lib/swr/use-document.ts
+++ b/lib/swr/use-document.ts
@@ -54,6 +54,9 @@ interface ViewWithDuration extends View {
};
totalDuration: number;
completionRate: number;
+ link: {
+ name: string | null;
+ }
}
export function useDocumentVisits() {
diff --git a/pages/api/documents/[id]/views/index.ts b/pages/api/documents/[id]/views/index.ts
index 789ca79f..4ade3bf3 100644
--- a/pages/api/documents/[id]/views/index.ts
+++ b/pages/api/documents/[id]/views/index.ts
@@ -38,6 +38,13 @@ export default async function handle(
orderBy: {
viewedAt: "desc",
},
+ include: {
+ link: {
+ select: {
+ name: true,
+ }
+ }
+ }
});
const durationsPromises = views.map((view) => {