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.

update tests and SDK docs

Steven Teyc781daf3ec39
diff --git a/apps/docs/sdks/typescript/analytics/clicks/browsers.mdx b/apps/docs/sdks/typescript/analytics/clicks/browsers.mdx
index 53d747a25c..b9eec3f8c2 100644
--- a/apps/docs/sdks/typescript/analytics/clicks/browsers.mdx
+++ b/apps/docs/sdks/typescript/analytics/clicks/browsers.mdx
@@ -1,6 +1,6 @@
---
title: "Browsers"
-"og:title": "dub.analytics.browsers - Retrieve browser analytics - TypeScript SDK"
+"og:title": "dub.analytics.clicks.browsers - Retrieve browser analytics - TypeScript SDK"
description: "Retrieve the top browsers by number of clicks for a link, a domain, or the authenticated workspace."
---
@@ -26,7 +26,7 @@ import AnalyticsArguments from "/snippets/analytics-arguments.mdx";
<RequestExample>
```typescript
-await dub.analytics.browsers({
+await dub.analytics.clicks.browsers({
key: "dummy",
domain: "dub.sh",
interval: "30d",
diff --git a/apps/docs/sdks/typescript/analytics/clicks/cities.mdx b/apps/docs/sdks/typescript/analytics/clicks/cities.mdx
index 6155b69479..ab6b2c0ded 100644
--- a/apps/docs/sdks/typescript/analytics/clicks/cities.mdx
+++ b/apps/docs/sdks/typescript/analytics/clicks/cities.mdx
@@ -1,6 +1,6 @@
---
title: "Cities"
-"og:title": "dub.analytics.cities - Retrieve city analytics - TypeScript SDK"
+"og:title": "dub.analytics.clicks.cities - Retrieve city analytics - TypeScript SDK"
description: "Retrieve the top countries by number of clicks for a link, a domain, or the authenticated workspace."
---
@@ -30,7 +30,7 @@ import AnalyticsArguments from "/snippets/analytics-arguments.mdx";
<RequestExample>
```typescript
-await dub.analytics.cities({
+await dub.analytics.clicks.cities({
key: "dummy",
domain: "dub.sh",
interval: "30d",
diff --git a/apps/docs/sdks/typescript/analytics/clicks/countries.mdx b/apps/docs/sdks/typescript/analytics/clicks/countries.mdx
index d54a7903a5..028ed5711f 100644
--- a/apps/docs/sdks/typescript/analytics/clicks/countries.mdx
+++ b/apps/docs/sdks/typescript/analytics/clicks/countries.mdx
@@ -1,6 +1,6 @@
---
title: "Countries"
-"og:title": "dub.analytics.countries - Retrieve country analytics - TypeScript SDK"
+"og:title": "dub.analytics.clicks.countries - Retrieve country analytics - TypeScript SDK"
description: "Retrieve the top countries by number of clicks for a link, a domain, or the authenticated workspace."
---
@@ -26,7 +26,7 @@ import AnalyticsArguments from "/snippets/analytics-arguments.mdx";
<RequestExample>
```typescript
-await dub.analytics.countries({
+await dub.analytics.clicks.countries({
key: "dummy",
domain: "dub.sh",
interval: "30d",
diff --git a/apps/docs/sdks/typescript/analytics/clicks/devices.mdx b/apps/docs/sdks/typescript/analytics/clicks/devices.mdx
index 1bb9524346..7c9b33be94 100644
--- a/apps/docs/sdks/typescript/analytics/clicks/devices.mdx
+++ b/apps/docs/sdks/typescript/analytics/clicks/devices.mdx
@@ -1,6 +1,6 @@
---
title: "Devices"
-"og:title": "dub.analytics.devices - Retrieve device analytics - TypeScript SDK"
+"og:title": "dub.analytics.clicks.devices - Retrieve device analytics - TypeScript SDK"
description: "Retrieve the top devices by number of clicks for a link, a domain, or the authenticated workspace."
---
@@ -26,7 +26,7 @@ import AnalyticsArguments from "/snippets/analytics-arguments.mdx";
<RequestExample>
```typescript
-await dub.analytics.devices({
+await dub.analytics.clicks.devices({
key: "dummy",
domain: "dub.sh",
interval: "30d",
diff --git a/apps/docs/sdks/typescript/analytics/clicks/os.mdx b/apps/docs/sdks/typescript/analytics/clicks/os.mdx
index d1a00acf29..c68ba4c39f 100644
--- a/apps/docs/sdks/typescript/analytics/clicks/os.mdx
+++ b/apps/docs/sdks/typescript/analytics/clicks/os.mdx
@@ -1,6 +1,6 @@
---
title: "OS"
-"og:title": "dub.analytics.os - Retrieve OS analytics - TypeScript SDK"
+"og:title": "dub.analytics.clicks.os - Retrieve OS analytics - TypeScript SDK"
description: "Retrieve the top OS by number of clicks for a link, a domain, or the authenticated workspace."
---
@@ -26,7 +26,7 @@ import AnalyticsArguments from "/snippets/analytics-arguments.mdx";
<RequestExample>
```typescript
-await dub.analytics.os({
+await dub.analytics.clicks.os({
key: "dummy",
domain: "dub.sh",
interval: "30d",
diff --git a/apps/docs/sdks/typescript/analytics/clicks/referers.mdx b/apps/docs/sdks/typescript/analytics/clicks/referers.mdx
index 07b1221008..f860e086ad 100644
--- a/apps/docs/sdks/typescript/analytics/clicks/referers.mdx
+++ b/apps/docs/sdks/typescript/analytics/clicks/referers.mdx
@@ -1,6 +1,6 @@
---
title: "Referers"
-"og:title": "dub.analytics.referers - Retrieve referer analytics - TypeScript SDK"
+"og:title": "dub.analytics.clicks.referers - Retrieve referer analytics - TypeScript SDK"
description: "Retrieve the top referers by number of clicks for a link, a domain, or the authenticated workspace."
---
@@ -26,7 +26,7 @@ import AnalyticsArguments from "/snippets/analytics-arguments.mdx";
<RequestExample>
```typescript
-await dub.analytics.referers({
+await dub.analytics.clicks.referers({
key: "dummy",
domain: "dub.sh",
interval: "30d",
diff --git a/apps/docs/sdks/typescript/analytics/clicks/timeseries.mdx b/apps/docs/sdks/typescript/analytics/clicks/timeseries.mdx
index 985464d5bc..842eeaf975 100644
--- a/apps/docs/sdks/typescript/analytics/clicks/timeseries.mdx
+++ b/apps/docs/sdks/typescript/analytics/clicks/timeseries.mdx
@@ -1,6 +1,6 @@
---
title: "Timeseries"
-"og:title": "dub.analytics.timeseries - Retrieve timeseries analytics - TypeScript SDK"
+"og:title": "dub.analytics.clicks.timeseries - Retrieve timeseries analytics - TypeScript SDK"
description: "Retrieve the number of clicks for a link, a domain, or the authenticated workspace over a period of time."
---
@@ -26,7 +26,7 @@ import AnalyticsArguments from "/snippets/analytics-arguments.mdx";
<RequestExample>
```typescript
-await dub.analytics.timeseries({
+await dub.analytics.clicks.timeseries({
key: "dummy",
domain: "dub.sh",
interval: "30d",
diff --git a/apps/docs/sdks/typescript/analytics/clicks/top-links.mdx b/apps/docs/sdks/typescript/analytics/clicks/top-links.mdx
index 9869b40fb3..fd968a4294 100644
--- a/apps/docs/sdks/typescript/analytics/clicks/top-links.mdx
+++ b/apps/docs/sdks/typescript/analytics/clicks/top-links.mdx
@@ -1,6 +1,6 @@
---
title: "Top Links"
-"og:title": "dub.analytics.topLinks - Retrieve top links - TypeScript SDK"
+"og:title": "dub.analytics.clicks.topLinks - Retrieve top links - TypeScript SDK"
description: "Retrieve the top links by number of clicks for a domain or the authenticated workspace."
---
@@ -26,7 +26,7 @@ import AnalyticsArguments from "/snippets/analytics-arguments.mdx";
<RequestExample>
```typescript
-await dub.analytics.topLinks({
+await dub.analytics.clicks.topLinks({
key: "dummy",
domain: "dub.sh",
interval: "30d",
diff --git a/apps/docs/sdks/typescript/analytics/clicks/top-urls.mdx b/apps/docs/sdks/typescript/analytics/clicks/top-urls.mdx
index d6be2ac1e1..d7af206a81 100644
--- a/apps/docs/sdks/typescript/analytics/clicks/top-urls.mdx
+++ b/apps/docs/sdks/typescript/analytics/clicks/top-urls.mdx
@@ -1,6 +1,6 @@
---
title: "Top Urls"
-"og:title": "dub.analytics.topUrls - Retrieve top urls - TypeScript SDK"
+"og:title": "dub.analytics.clicks.topUrls - Retrieve top urls - TypeScript SDK"
description: "Retrieve the top URLs by number of clicks for a given short link."
---
@@ -26,7 +26,7 @@ import AnalyticsArguments from "/snippets/analytics-arguments.mdx";
<RequestExample>
```typescript
-await dub.analytics.topUrls({
+await dub.analytics.clicks.topUrls({
key: "dummy",
domain: "dub.sh",
interval: "30d",
diff --git a/apps/web/lib/openapi/analytics/clicks/browser.ts b/apps/web/lib/openapi/analytics/clicks/browser.ts
index 752f415b0a..a663fffc71 100644
--- a/apps/web/lib/openapi/analytics/clicks/browser.ts
+++ b/apps/web/lib/openapi/analytics/clicks/browser.ts
@@ -27,6 +27,6 @@ export const getBrowserByClicks: ZodOpenApiOperationObject = {
},
...openApiErrorResponses,
},
- tags: ["Analytics"],
+ tags: ["analytics.clicks"],
security: [{ token: [] }],
};
diff --git a/apps/web/lib/openapi/analytics/clicks/city.ts b/apps/web/lib/openapi/analytics/clicks/city.ts
index 114a37b600..4d8342bb27 100644
--- a/apps/web/lib/openapi/analytics/clicks/city.ts
+++ b/apps/web/lib/openapi/analytics/clicks/city.ts
@@ -27,6 +27,6 @@ export const getCityByClicks: ZodOpenApiOperationObject = {
},
...openApiErrorResponses,
},
- tags: ["Analytics"],
+ tags: ["analytics.clicks"],
security: [{ token: [] }],
};
diff --git a/apps/web/lib/openapi/analytics/clicks/clicks.ts b/apps/web/lib/openapi/analytics/clicks/clicks.ts
index 50e529e4c8..69540f4561 100644
--- a/apps/web/lib/openapi/analytics/clicks/clicks.ts
+++ b/apps/web/lib/openapi/analytics/clicks/clicks.ts
@@ -26,6 +26,6 @@ export const getClicksAnalytics: ZodOpenApiOperationObject = {
},
...openApiErrorResponses,
},
- tags: ["Analytics"],
+ tags: ["analytics"],
security: [{ token: [] }],
};
diff --git a/apps/web/lib/openapi/analytics/clicks/country.ts b/apps/web/lib/openapi/analytics/clicks/country.ts
index 1d3efb237f..6f935bd426 100644
--- a/apps/web/lib/openapi/analytics/clicks/country.ts
+++ b/apps/web/lib/openapi/analytics/clicks/country.ts
@@ -27,6 +27,6 @@ export const getCountryByClicks: ZodOpenApiOperationObject = {
},
...openApiErrorResponses,
},
- tags: ["Analytics"],
+ tags: ["analytics.clicks"],
security: [{ token: [] }],
};
diff --git a/apps/web/lib/openapi/analytics/clicks/device.ts b/apps/web/lib/openapi/analytics/clicks/device.ts
index e75d6e5033..600a7948f3 100644
--- a/apps/web/lib/openapi/analytics/clicks/device.ts
+++ b/apps/web/lib/openapi/analytics/clicks/device.ts
@@ -27,6 +27,6 @@ export const getDeviceByClicks: ZodOpenApiOperationObject = {
},
...openApiErrorResponses,
},
- tags: ["Analytics"],
+ tags: ["analytics.clicks"],
security: [{ token: [] }],
};
diff --git a/apps/web/lib/openapi/analytics/clicks/os.ts b/apps/web/lib/openapi/analytics/clicks/os.ts
index 1bf06b6e24..69a5510a86 100644
--- a/apps/web/lib/openapi/analytics/clicks/os.ts
+++ b/apps/web/lib/openapi/analytics/clicks/os.ts
@@ -27,6 +27,6 @@ export const getOSByClicks: ZodOpenApiOperationObject = {
},
...openApiErrorResponses,
},
- tags: ["Analytics"],
+ tags: ["analytics.clicks"],
security: [{ token: [] }],
};
diff --git a/apps/web/lib/openapi/analytics/clicks/referer.ts b/apps/web/lib/openapi/analytics/clicks/referer.ts
index 25f44b9ed8..cf13da4bdc 100644
--- a/apps/web/lib/openapi/analytics/clicks/referer.ts
+++ b/apps/web/lib/openapi/analytics/clicks/referer.ts
@@ -27,6 +27,6 @@ export const getRefererByClicks: ZodOpenApiOperationObject = {
},
...openApiErrorResponses,
},
- tags: ["Analytics"],
+ tags: ["analytics.clicks"],
security: [{ token: [] }],
};
diff --git a/apps/web/lib/openapi/analytics/clicks/timeseries.ts b/apps/web/lib/openapi/analytics/clicks/timeseries.ts
index b0332ac609..6364177bf9 100644
--- a/apps/web/lib/openapi/analytics/clicks/timeseries.ts
+++ b/apps/web/lib/openapi/analytics/clicks/timeseries.ts
@@ -27,6 +27,6 @@ export const getTimeseriesByClicks: ZodOpenApiOperationObject = {
},
...openApiErrorResponses,
},
- tags: ["Analytics"],
+ tags: ["analytics.clicks"],
security: [{ token: [] }],
};
diff --git a/apps/web/lib/openapi/analytics/clicks/top-links.ts b/apps/web/lib/openapi/analytics/clicks/top-links.ts
index 899de801e2..7c5c6c8803 100644
--- a/apps/web/lib/openapi/analytics/clicks/top-links.ts
+++ b/apps/web/lib/openapi/analytics/clicks/top-links.ts
@@ -27,6 +27,6 @@ export const getTopLinksByClicks: ZodOpenApiOperationObject = {
},
...openApiErrorResponses,
},
- tags: ["Analytics"],
+ tags: ["analytics.clicks"],
security: [{ token: [] }],
};
diff --git a/apps/web/lib/openapi/analytics/clicks/top-urls.ts b/apps/web/lib/openapi/analytics/clicks/top-urls.ts
index 8147a62438..57538031ae 100644
--- a/apps/web/lib/openapi/analytics/clicks/top-urls.ts
+++ b/apps/web/lib/openapi/analytics/clicks/top-urls.ts
@@ -27,6 +27,6 @@ export const getTopURLsByClicks: ZodOpenApiOperationObject = {
},
...openApiErrorResponses,
},
- tags: ["Analytics"],
+ tags: ["analytics.clicks"],
security: [{ token: [] }],
};
diff --git a/apps/web/tests/analytics/clicks.test.ts b/apps/web/tests/analytics/clicks.test.ts
index 0beaa189f2..31b4cb50e9 100644
--- a/apps/web/tests/analytics/clicks.test.ts
+++ b/apps/web/tests/analytics/clicks.test.ts
@@ -1,3 +1,4 @@
+import { VALID_TINYBIRD_ENDPOINTS } from "@/lib/analytics";
import z from "@/lib/zod";
import { getClickAnalyticsResponse } from "@/lib/zod/schemas";
import { describe, expect, test } from "vitest";
@@ -21,138 +22,20 @@ describe.runIf(env.CI).sequential("GET /analytics/clicks", async () => {
expect(clicks).toBeGreaterThanOrEqual(0);
});
- test("by timeseries", async () => {
- const { status, data } = await http.get<any[]>({
- path: "/analytics/clicks",
- query: { workspaceId, groupBy: "timeseries", ...filter },
- });
-
- const parsed = z
- .array(getClickAnalyticsResponse["timeseries"].strict())
- .safeParse(data);
-
- expect(status).toEqual(200);
- expect(data.length).toBeGreaterThanOrEqual(0);
- expect(parsed.success).toBeTruthy();
- });
-
- test("by country", async () => {
- const { status, data } = await http.get<any[]>({
- path: "/analytics/clicks",
- query: { workspaceId, groupBy: "country", ...filter },
- });
-
- const parsed = z
- .array(getClickAnalyticsResponse["country"].strict())
- .safeParse(data);
-
- expect(status).toEqual(200);
- expect(data.length).toBeGreaterThanOrEqual(0);
- expect(parsed.success).toBeTruthy();
- });
-
- test("by city", async () => {
- const { status, data } = await http.get<any[]>({
- path: "/analytics/clicks",
- query: { workspaceId, groupBy: "city", ...filter },
- });
-
- const parsed = z
- .array(getClickAnalyticsResponse["city"].strict())
- .safeParse(data);
-
- expect(status).toEqual(200);
- expect(data.length).toBeGreaterThanOrEqual(0);
- expect(parsed.success).toBeTruthy();
- });
-
- test("by device", async () => {
- const { status, data } = await http.get<any[]>({
- path: "/analytics/clicks",
- query: { workspaceId, groupBy: "device", ...filter },
- });
-
- const parsed = z
- .array(getClickAnalyticsResponse["device"].strict())
- .safeParse(data);
-
- expect(status).toEqual(200);
- expect(data.length).toBeGreaterThanOrEqual(0);
- expect(parsed.success).toBeTruthy();
- });
-
- test("by browser", async () => {
- const { status, data } = await http.get<any[]>({
- path: "/analytics/clicks",
- query: { workspaceId, groupBy: "browser", ...filter },
- });
-
- const parsed = z
- .array(getClickAnalyticsResponse["browser"].strict())
- .safeParse(data);
+ VALID_TINYBIRD_ENDPOINTS.map((endpoint) => {
+ test(`by ${endpoint}`, async () => {
+ const { status, data } = await http.get<any[]>({
+ path: `/analytics/clicks/${endpoint}`,
+ query: { workspaceId, ...filter },
+ });
- expect(status).toEqual(200);
- expect(data.length).toBeGreaterThanOrEqual(0);
- expect(parsed.success).toBeTruthy();
- });
+ const parsed = z
+ .array(getClickAnalyticsResponse[endpoint].strict())
+ .safeParse(data);
- test("by os", async () => {
- const { status, data } = await http.get<any[]>({
- path: "/analytics/clicks",
- query: { workspaceId, groupBy: "os", ...filter },
+ expect(status).toEqual(200);
+ expect(data.length).toBeGreaterThanOrEqual(0);
+ expect(parsed.success).toBeTruthy();
});
-
- const parsed = z
- .array(getClickAnalyticsResponse["os"].strict())
- .safeParse(data);
-
- expect(status).toEqual(200);
- expect(data.length).toBeGreaterThanOrEqual(0);
- expect(parsed.success).toBeTruthy();
- });
-
- test("by referer", async () => {
- const { status, data } = await http.get<any[]>({
- path: "/analytics/clicks",
- query: { workspaceId, groupBy: "referer", ...filter },
- });
-
- const parsed = z
- .array(getClickAnalyticsResponse["referer"].strict())
- .safeParse(data);
-
- expect(status).toEqual(200);
- expect(data.length).toBeGreaterThanOrEqual(0);
- expect(parsed.success).toBeTruthy();
- });
-
- test("by top_links", async () => {
- const { status, data } = await http.get<any[]>({
- path: "/analytics/clicks",
- query: { workspaceId, groupBy: "top_links", ...filter },
- });
-
- const parsed = z
- .array(getClickAnalyticsResponse["top_links"].strict())
- .safeParse(data);
-
- expect(status).toEqual(200);
- expect(data.length).toBeGreaterThanOrEqual(0);
- expect(parsed.success).toBeTruthy();
- });
-
- test("by top_urls", async () => {
- const { status, data } = await http.get<any[]>({
- path: "/analytics/clicks",
- query: { workspaceId, groupBy: "top_urls", ...filter },
- });
-
- const parsed = z
- .array(getClickAnalyticsResponse["top_urls"].strict())
- .safeParse(data);
-
- expect(status).toEqual(200);
- expect(data.length).toBeGreaterThanOrEqual(0);
- expect(parsed.success).toBeTruthy();
});
});