Skip to content

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

feat: improve the analytics window, ship the group tools, correct num_pages

Marc Seitz28f3c7aa2ad6
diff --git a/lib/tinybird/endpoints/get_total_average_page_duration.pipe b/lib/tinybird/endpoints/get_total_average_page_duration.pipe
index 42122bab..d8279465 100644
--- a/lib/tinybird/endpoints/get_total_average_page_duration.pipe
+++ b/lib/tinybird/endpoints/get_total_average_page_duration.pipe
@@ -10,6 +10,7 @@ SQL >
WHERE
documentId = {{ String(documentId, required=true) }}
AND time >= {{ Int64(since, required=true) }}
+ AND time <= {{ Int64(until, 9999999999999) }}
AND linkId NOT IN splitByChar(',', {{ String(excludedLinkIds, required=True) }})
AND viewId NOT IN splitByChar(',', {{ String(excludedViewIds, required=True) }})
GROUP BY versionNumber, pageNumber, viewId
diff --git a/lib/tinybird/endpoints/get_total_dataroom_duration.pipe b/lib/tinybird/endpoints/get_total_dataroom_duration.pipe
index fcc41ef2..f00f26e9 100644
--- a/lib/tinybird/endpoints/get_total_dataroom_duration.pipe
+++ b/lib/tinybird/endpoints/get_total_dataroom_duration.pipe
@@ -11,6 +11,7 @@ SQL >
WHERE
dataroomId = {{ String(dataroomId, required=true) }}
AND time >= {{ Int64(since, required=true) }}
+ AND time <= {{ Int64(until, 9999999999999) }}
AND linkId NOT IN {{ Array(excludedLinkIds, String) }}
AND viewId NOT IN {{ Array(excludedViewIds, String) }}
GROUP BY
diff --git a/lib/tinybird/pipes.ts b/lib/tinybird/pipes.ts
index e391fe16..b2bff446 100644
--- a/lib/tinybird/pipes.ts
+++ b/lib/tinybird/pipes.ts
@@ -10,6 +10,12 @@ const tb = new Tinybird({
baseUrl: process.env.TINYBIRD_BASE_URL,
});
+// A parameter declared here is only a client-side contract: Tinybird silently
+// ignores query params the deployed pipe's SQL doesn't reference. So adding
+// `until` below is a no-op until the matching endpoints/*.pipe is pushed
+// (`tb push --force`). Keep the two in lockstep — an `until` that exists here
+// but not in the SQL reads as a working time filter while returning all-time
+// numbers.
export const getTotalAvgPageDuration = tb.buildPipe({
pipe: "get_total_average_page_duration__v5",
parameters: z.object({
@@ -17,6 +23,7 @@ export const getTotalAvgPageDuration = tb.buildPipe({
excludedLinkIds: z.string().describe("Comma separated linkIds"),
excludedViewIds: z.string().describe("Comma separated viewIds"),
since: z.number(),
+ until: z.number().optional(),
}),
data: z.object({
versionNumber: z.number().int(),
@@ -131,6 +138,7 @@ export const getTotalDataroomDuration = tb.buildPipe({
excludedLinkIds: z.array(z.string()),
excludedViewIds: z.array(z.string()),
since: z.number(),
+ until: z.number().optional(),
}),
data: z.object({
viewId: z.string(),