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.

fix isDeprecatedClicksEndpoint

Steven Tey06de8a70c867
diff --git a/apps/web/app/api/analytics/route.ts b/apps/web/app/api/analytics/route.ts
index 9212ec04ea..02d8b428a8 100644
--- a/apps/web/app/api/analytics/route.ts
+++ b/apps/web/app/api/analytics/route.ts
@@ -16,7 +16,7 @@ export const GET = withWorkspace(
analyticsPathParamsSchema.parse(params);
// for backwards compatibility (we used to support /analytics/[endpoint] as well)
- if (oldEvent && VALID_ANALYTICS_ENDPOINTS.includes(oldEvent)) {
+ if (!oldType && oldEvent && VALID_ANALYTICS_ENDPOINTS.includes(oldEvent)) {
oldType = oldEvent;
oldEvent = undefined;
}
@@ -48,7 +48,7 @@ export const GET = withWorkspace(
// (/api/analytics/clicks/clicks)
// (/api/analytics/clicks/count)
const isDeprecatedClicksEndpoint =
- oldEvent && oldEvent === "clicks" && (!oldType || oldType === "count");
+ oldEvent === "clicks" || oldType === "count";
const response = await getAnalytics({
...parsedParams,
diff --git a/apps/web/tests/analytics/clicks.test.ts b/apps/web/tests/analytics/clicks.test.ts
index 6a0355ab28..6d3fb2692a 100644
--- a/apps/web/tests/analytics/clicks.test.ts
+++ b/apps/web/tests/analytics/clicks.test.ts
@@ -84,7 +84,7 @@ describe.runIf(env.CI).sequential("GET /analytics/{endpoint}", async () => {
expect(status).toEqual(200);
- if (endpoint === "clicks") {
+ if (endpoint === "clicks" || endpoint === "count") {
expect(data).toEqual(expect.any(Number));
expect(data).toBeGreaterThanOrEqual(0);
} else {