The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added more backwards compatibility
Steven Tey040477df5afb
diff --git a/apps/web/app/api/analytics/route.ts b/apps/web/app/api/analytics/route.tsindex 1725d3071b..9212ec04ea 100644--- a/apps/web/app/api/analytics/route.ts+++ b/apps/web/app/api/analytics/route.ts@@ -42,10 +42,12 @@ export const GET = withWorkspace(? await getDomainViaEdge(domain).then((d) => d?.id): null;- // Identify the request is from deprecated endpoint+ // Identify the request is from deprecated clicks endpoint// (/api/analytics/clicks)+ // (/api/analytics/count)+ // (/api/analytics/clicks/clicks)// (/api/analytics/clicks/count)- const isDeprecatedEndpoint =+ const isDeprecatedClicksEndpoint =oldEvent && oldEvent === "clicks" && (!oldType || oldType === "count");const response = await getAnalytics({@@ -54,7 +56,7 @@ export const GET = withWorkspace(groupBy,...(linkId && { linkId }),workspaceId: workspace.id,- isDeprecatedEndpoint,+ isDeprecatedClicksEndpoint,});return NextResponse.json(response);diff --git a/apps/web/lib/analytics/get-analytics.ts b/apps/web/lib/analytics/get-analytics.tsindex 5411f86543..492412edf4 100644--- a/apps/web/lib/analytics/get-analytics.ts+++ b/apps/web/lib/analytics/get-analytics.ts@@ -31,7 +31,7 @@ export const getAnalytics = async (params: AnalyticsFilters) => {end,timezone = "UTC",isDemo,- isDeprecatedEndpoint = false,+ isDeprecatedClicksEndpoint = false,} = params;// get all-time clicks count if:@@ -100,7 +100,7 @@ export const getAnalytics = async (params: AnalyticsFilters) => {if (groupBy === "count") {// Return the count value for deprecated endpoints- if (isDeprecatedEndpoint) {+ if (isDeprecatedClicksEndpoint) {return response.data[0][event];// Return the object for count endpoints} else {diff --git a/apps/web/lib/analytics/types.ts b/apps/web/lib/analytics/types.tsindex 2dfd708f1b..e1fcf5c367 100644--- a/apps/web/lib/analytics/types.ts+++ b/apps/web/lib/analytics/types.ts@@ -20,5 +20,5 @@ export type DeviceTabs = "devices" | "browsers" | "os";export type AnalyticsFilters = z.infer<typeof analyticsQuerySchema> & {workspaceId?: string;isDemo?: boolean;- isDeprecatedEndpoint?: boolean;+ isDeprecatedClicksEndpoint?: boolean;};diff --git a/apps/web/tests/analytics/clicks.test.ts b/apps/web/tests/analytics/clicks.test.tsindex 6d3fb2692a..35376c41fd 100644--- a/apps/web/tests/analytics/clicks.test.ts+++ b/apps/web/tests/analytics/clicks.test.ts@@ -48,7 +48,7 @@ describe.runIf(env.CI).sequential("GET /analytics/clicks", async () => {query: { workspaceId, ...filter },});- if (endpoint === "clicks" || endpoint === "count") {+ if (endpoint === "clicks") {expect(status).toEqual(200);expect(data).toEqual(expect.any(Number));expect(data).toBeGreaterThanOrEqual(0);@@ -84,7 +84,7 @@ describe.runIf(env.CI).sequential("GET /analytics/{endpoint}", async () => {expect(status).toEqual(200);- if (endpoint === "clicks" || endpoint === "count") {+ if (endpoint === "clicks") {expect(data).toEqual(expect.any(Number));expect(data).toBeGreaterThanOrEqual(0);} else {