Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Add trigger enums

Steven Tey5dcab1ce63c5
diff --git a/apps/web/app/(ee)/api/track/visit/route.ts b/apps/web/app/(ee)/api/track/visit/route.ts
index 1aa5ce07b9..5cd1e630b1 100644
--- a/apps/web/app/(ee)/api/track/visit/route.ts
+++ b/apps/web/app/(ee)/api/track/visit/route.ts
@@ -98,6 +98,7 @@ export const POST = withAxiom(async (req: AxiomRequest) => {
workspaceId: cachedLink.projectId,
skipRatelimit: true,
...(referrer && { referrer }),
+ trigger: "pageview",
shouldCacheClickId: true,
});
}
diff --git a/apps/web/lib/analytics/constants.ts b/apps/web/lib/analytics/constants.ts
index d1d925fc26..8d5aec0bbf 100644
--- a/apps/web/lib/analytics/constants.ts
+++ b/apps/web/lib/analytics/constants.ts
@@ -208,10 +208,12 @@ export const DIMENSIONAL_ANALYTICS_FILTERS = [
];
export const TRIGGER_DISPLAY = {
- qr: "QR Scan",
+ qr: "QR Code Scan",
link: "Link Click",
+ pageview: "Page View",
+ deeplink: "Deep Link",
};
-export const TRIGGER_TYPES = ["qr", "link"] as const;
+export const TRIGGER_TYPES = ["qr", "link", "pageview", "deeplink"] as const;
export const EVENT_TYPES = ["clicks", "leads", "sales"] as const;
diff --git a/apps/web/lib/tinybird/record-click.ts b/apps/web/lib/tinybird/record-click.ts
index 8e19078019..2f26cf38d8 100644
--- a/apps/web/lib/tinybird/record-click.ts
+++ b/apps/web/lib/tinybird/record-click.ts
@@ -38,6 +38,7 @@ export async function recordClick({
skipRatelimit,
timestamp,
referrer,
+ trigger = "link",
shouldCacheClickId,
}: {
req: Request;
@@ -51,6 +52,7 @@ export async function recordClick({
skipRatelimit?: boolean;
timestamp?: string;
referrer?: string;
+ trigger?: string;
shouldCacheClickId?: boolean;
}) {
if (!clickId) {
@@ -94,6 +96,9 @@ export async function recordClick({
}
const isQr = detectQr(req);
+ if (isQr) {
+ trigger = "qr";
+ }
// get continent, region & geolocation data
// interesting, geolocation().region is Vercel's edge region – NOT the actual region
@@ -149,6 +154,7 @@ export async function recordClick({
qr: isQr,
referer: referer ? getDomainWithoutWWW(referer) || "(direct)" : "(direct)",
referer_url: referer || "(direct)",
+ trigger,
};
if (shouldCacheClickId) {