The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
update openapi and tests
Steven Tey50622099633a
diff --git a/apps/web/app/api/analytics/export/route.ts b/apps/web/app/api/analytics/export/route.tsindex 44d619259b..caf6fbf8eb 100644--- a/apps/web/app/api/analytics/export/route.ts+++ b/apps/web/app/api/analytics/export/route.ts@@ -1,7 +1,4 @@-import {- DEPRECATED_ANALYTICS_ENDPOINTS,- VALID_ANALYTICS_ENDPOINTS,-} from "@/lib/analytics/constants";+import { VALID_ANALYTICS_ENDPOINTS } from "@/lib/analytics/constants";import { getAnalytics } from "@/lib/analytics/get-analytics";import { validDateRangeForPlan } from "@/lib/analytics/utils";import { withWorkspace } from "@/lib/auth";@@ -125,8 +122,6 @@ export const GET = withWorkspace(if (endpoint === "top_urls" && !linkId) return;// skip clicks countif (endpoint === "count") return;- // skip deprecated endpoints- if (DEPRECATED_ANALYTICS_ENDPOINTS.includes(endpoint)) return;const response = await getAnalytics({...parsedParams,diff --git a/apps/web/lib/analytics/constants.ts b/apps/web/lib/analytics/constants.tsindex af96cde52b..ce8f672557 100644--- a/apps/web/lib/analytics/constants.ts+++ b/apps/web/lib/analytics/constants.ts@@ -85,29 +85,16 @@ export const INTERVAL_DATA: Record<export const VALID_ANALYTICS_ENDPOINTS = ["count","timeseries",- "country", // backwards compatibility"countries",- "city", // backwards compatibility"cities",- "device", // backwards compatibility"devices",- "browser", // backwards compatibility"browsers","os",- "referer", // backwards compatibility"referers","top_links","top_urls",] as const;-export const DEPRECATED_ANALYTICS_ENDPOINTS = [- "country",- "city",- "device",- "browser",- "referer",-];-export const VALID_ANALYTICS_FILTERS = ["country","city",diff --git a/apps/web/lib/analytics/utils.ts b/apps/web/lib/analytics/utils.tsindex 9d4ec6598c..6cc34d47a0 100644--- a/apps/web/lib/analytics/utils.ts+++ b/apps/web/lib/analytics/utils.ts@@ -14,33 +14,6 @@ export const editQueryString = (return searchParams.toString();};-export const formatAnalyticsEndpoint = (- endpoint: string,- type: "plural" | "singular",-) => {- const plural = {- country: "countries",- city: "cities",- device: "devices",- browser: "browsers",- referer: "referers",- };-- const singular = {- countries: "country",- cities: "city",- devices: "device",- browsers: "browser",- referers: "referer",- };-- if (type === "plural") {- return plural[endpoint] || endpoint;- } else if (type === "singular") {- return singular[endpoint] || endpoint;- }-};-export const validDateRangeForPlan = ({plan,interval,diff --git a/apps/web/lib/openapi/analytics/clicks/browsers.ts b/apps/web/lib/openapi/analytics/clicks/browsers.tsdeleted file mode 100644index 74ea40d76d..0000000000--- a/apps/web/lib/openapi/analytics/clicks/browsers.ts+++ /dev/null@@ -1,30 +0,0 @@-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";-import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";-import { ZodOpenApiOperationObject } from "zod-openapi";-import { workspaceParamsSchema } from "../../request";--export const getBrowsersByClicks: ZodOpenApiOperationObject = {- operationId: "getBrowsersByClicks",- "x-speakeasy-name-override": "browsers",- summary: "Retrieve top browsers by clicks",- description:- "Retrieve the top browsers by number of clicks for a link, a domain, or the authenticated workspace.",- requestParams: {- query: workspaceParamsSchema.merge(analyticsQuerySchema),- },- responses: {- "200": {- description: "The top browsers by number of clicks",- content: {- "application/json": {- schema: z.array(clickAnalyticsResponse["browsers"]),- },- },- },- ...openApiErrorResponses,- },- tags: ["analytics.clicks"],- security: [{ token: [] }],-};diff --git a/apps/web/lib/openapi/analytics/clicks/cities.ts b/apps/web/lib/openapi/analytics/clicks/cities.tsdeleted file mode 100644index 0fa0866970..0000000000--- a/apps/web/lib/openapi/analytics/clicks/cities.ts+++ /dev/null@@ -1,30 +0,0 @@-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";-import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";-import { ZodOpenApiOperationObject } from "zod-openapi";-import { workspaceParamsSchema } from "../../request";--export const getCitiesByClicks: ZodOpenApiOperationObject = {- operationId: "getCitiesByClicks",- "x-speakeasy-name-override": "cities",- summary: "Retrieve top cities by clicks",- description:- "Retrieve the top countries by number of clicks for a link, a domain, or the authenticated workspace.",- requestParams: {- query: workspaceParamsSchema.merge(analyticsQuerySchema),- },- responses: {- "200": {- description: "The top cities by number of clicks",- content: {- "application/json": {- schema: z.array(clickAnalyticsResponse["cities"]),- },- },- },- ...openApiErrorResponses,- },- tags: ["analytics.clicks"],- security: [{ token: [] }],-};diff --git a/apps/web/lib/openapi/analytics/clicks/count.ts b/apps/web/lib/openapi/analytics/clicks/count.tsdeleted file mode 100644index d49988f9fe..0000000000--- a/apps/web/lib/openapi/analytics/clicks/count.ts+++ /dev/null@@ -1,31 +0,0 @@-import { openApiErrorResponses } from "@/lib/openapi/responses";-import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";-import { ZodOpenApiOperationObject } from "zod-openapi";-import { workspaceParamsSchema } from "../../request";--export const getClicksCount: ZodOpenApiOperationObject = {- operationId: "getClicksCount",- "x-speakeasy-name-override": "count",- summary: "Retrieve the total clicks count",- description:- "Retrieve the total number of clicks for a link, a domain, or the authenticated workspace.",- requestParams: {- query: workspaceParamsSchema.merge(analyticsQuerySchema),- },- responses: {- "200": {- description: "The number of clicks",- content: {- "application/json": {- schema: {- type: "number",- description: "The number of clicks matching the specified queries.",- },- },- },- },- ...openApiErrorResponses,- },- tags: ["analytics.clicks"],- security: [{ token: [] }],-};diff --git a/apps/web/lib/openapi/analytics/clicks/countries.ts b/apps/web/lib/openapi/analytics/clicks/countries.tsdeleted file mode 100644index 1b9e632bc4..0000000000--- a/apps/web/lib/openapi/analytics/clicks/countries.ts+++ /dev/null@@ -1,30 +0,0 @@-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";-import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";-import { ZodOpenApiOperationObject } from "zod-openapi";-import { workspaceParamsSchema } from "../../request";--export const getCountriesByClicks: ZodOpenApiOperationObject = {- operationId: "getCountriesByClicks",- "x-speakeasy-name-override": "countries",- summary: "Retrieve top countries by clicks",- description:- "Retrieve the top countries by number of clicks for a link, a domain, or the authenticated workspace.",- requestParams: {- query: workspaceParamsSchema.merge(analyticsQuerySchema),- },- responses: {- "200": {- description: "The top countries by number of clicks",- content: {- "application/json": {- schema: z.array(clickAnalyticsResponse["countries"]),- },- },- },- ...openApiErrorResponses,- },- tags: ["analytics.clicks"],- security: [{ token: [] }],-};diff --git a/apps/web/lib/openapi/analytics/clicks/devices.ts b/apps/web/lib/openapi/analytics/clicks/devices.tsdeleted file mode 100644index dba753ecfa..0000000000--- a/apps/web/lib/openapi/analytics/clicks/devices.ts+++ /dev/null@@ -1,30 +0,0 @@-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";-import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";-import { ZodOpenApiOperationObject } from "zod-openapi";-import { workspaceParamsSchema } from "../../request";--export const getDevicesByClicks: ZodOpenApiOperationObject = {- operationId: "getDevicesByClicks",- "x-speakeasy-name-override": "devices",- summary: "Retrieve top devices by clicks",- description:- "Retrieve the top devices by number of clicks for a link, a domain, or the authenticated workspace.",- requestParams: {- query: workspaceParamsSchema.merge(analyticsQuerySchema),- },- responses: {- "200": {- description: "The top devices by number of clicks",- content: {- "application/json": {- schema: z.array(clickAnalyticsResponse["devices"]),- },- },- },- ...openApiErrorResponses,- },- tags: ["analytics.clicks"],- security: [{ token: [] }],-};diff --git a/apps/web/lib/openapi/analytics/clicks/index.ts b/apps/web/lib/openapi/analytics/clicks/index.tsdeleted file mode 100644index cd242b58a0..0000000000--- a/apps/web/lib/openapi/analytics/clicks/index.ts+++ /dev/null@@ -1,163 +0,0 @@-import { ZodOpenApiPathsObject } from "zod-openapi";-import { getBrowsersByClicks } from "./browsers";-import { getCitiesByClicks } from "./cities";-import { getClicksCount } from "./count";-import { getCountriesByClicks } from "./countries";-import { getDevicesByClicks } from "./devices";-import { getOSByClicks } from "./os";-import { getReferersByClicks } from "./referers";-import { getTimeseriesByClicks } from "./timeseries";-import { getTopLinksByClicks } from "./top-links";-import { getTopURLsByClicks } from "./top-urls";--export const clickAnalyticsPaths: ZodOpenApiPathsObject = {- "/analytics/clicks/count": {- get: getClicksCount,- },- "/analytics/clicks/timeseries": {- get: getTimeseriesByClicks,- },- "/analytics/clicks/countries": {- get: getCountriesByClicks,- },- "/analytics/clicks/cities": {- get: getCitiesByClicks,- },- "/analytics/clicks/devices": {- get: getDevicesByClicks,- },- "/analytics/clicks/browsers": {- get: getBrowsersByClicks,- },- "/analytics/clicks/os": {- get: getOSByClicks,- },- "/analytics/clicks/referers": {- get: getReferersByClicks,- },- "/analytics/clicks/top_links": {- get: getTopLinksByClicks,- },- "/analytics/clicks/top_urls": {- get: getTopURLsByClicks,- },- /**- * DEPRECATED ENDPOINTS- */- "/analytics/clicks": {- get: {- ...getClicksCount,- operationId: "getClicksCountDeprecated",- "x-speakeasy-name-override": undefined,- "x-speakeasy-deprecation-message":- "This method is deprecated. Use dub.analytics.clicks.count instead.",- "x-speakeasy-deprecation-replacement": "getClicksCount",- tags: ["analytics.clicks"],- deprecated: true,- },- },- "/analytics/timeseries": {- get: {- ...getTimeseriesByClicks,- operationId: "getTimeseriesByClicksDeprecated",- "x-speakeasy-deprecation-message":- "This method is deprecated. Use dub.analytics.clicks.timeseries instead.",- "x-speakeasy-deprecation-replacement": "getTimeseriesByClicks",- tags: ["analytics"],- deprecated: true,- },- },- "/analytics/country": {- get: {- ...getCountriesByClicks,- operationId: "getCountriesByClicksDeprecated",- "x-speakeasy-deprecation-message":- "This method is deprecated. Use dub.analytics.clicks.countries instead.",- "x-speakeasy-deprecation-replacement": "getCountriesByClicks",- "x-speakeasy-name-override": "country",- tags: ["analytics"],- deprecated: true,- },- },- "/analytics/city": {- get: {- ...getCitiesByClicks,- operationId: "getCitiesByClicksDeprecated",- "x-speakeasy-deprecation-message":- "This method is deprecated. Use dub.analytics.clicks.cities instead.",- "x-speakeasy-deprecation-replacement": "getCitiesByClicks",- "x-speakeasy-name-override": "city",- tags: ["analytics"],- deprecated: true,- },- },- "/analytics/device": {- get: {- ...getDevicesByClicks,- operationId: "getDevicesByClicksDeprecated",- "x-speakeasy-deprecation-message":- "This method is deprecated. Use dub.analytics.clicks.devices instead.",- "x-speakeasy-deprecation-replacement": "getDevicesByClicks",- "x-speakeasy-name-override": "device",- tags: ["analytics"],- deprecated: true,- },- },- "/analytics/browser": {- get: {- ...getBrowsersByClicks,- operationId: "getBrowsersByClicksDeprecated",- "x-speakeasy-deprecation-message":- "This method is deprecated. Use dub.analytics.clicks.browsers instead.",- "x-speakeasy-deprecation-replacement": "getBrowsersByClicks",- "x-speakeasy-name-override": "browser",- tags: ["analytics"],- deprecated: true,- },- },- "/analytics/os": {- get: {- ...getOSByClicks,- operationId: "getOSByClicksDeprecated",- "x-speakeasy-deprecation-message":- "This method is deprecated. Use dub.analytics.clicks.os instead.",- "x-speakeasy-deprecation-replacement": "getOSByClicks",- tags: ["analytics"],- deprecated: true,- },- },- "/analytics/referer": {- get: {- ...getReferersByClicks,- operationId: "getReferersByClicksDeprecated",- "x-speakeasy-deprecation-message":- "This method is deprecated. Use dub.analytics.clicks.referers instead.",- "x-speakeasy-deprecation-replacement": "getReferersByClicks",- "x-speakeasy-name-override": "referer",- tags: ["analytics"],- deprecated: true,- },- },- "/analytics/top_links": {- get: {- ...getTopLinksByClicks,- operationId: "getTopLinksByClicksDeprecated",- "x-speakeasy-deprecation-message":- "This method is deprecated. Use dub.analytics.clicks.topLinks instead.",- "x-speakeasy-deprecation-replacement": "getTopLinksByClicks",- tags: ["analytics"],- deprecated: true,- },- },- "/analytics/top_urls": {- get: {- ...getTopURLsByClicks,- operationId: "getTopURLsByClicksDeprecated",- "x-speakeasy-deprecation-message":- "This method is deprecated. Use dub.analytics.clicks.topUrls instead.",- "x-speakeasy-deprecation-replacement": "getTopURLsByClicks",- tags: ["analytics"],- deprecated: true,- },- },-};diff --git a/apps/web/lib/openapi/analytics/clicks/os.ts b/apps/web/lib/openapi/analytics/clicks/os.tsdeleted file mode 100644index 9c852fe979..0000000000--- a/apps/web/lib/openapi/analytics/clicks/os.ts+++ /dev/null@@ -1,30 +0,0 @@-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";-import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";-import { ZodOpenApiOperationObject } from "zod-openapi";-import { workspaceParamsSchema } from "../../request";--export const getOSByClicks: ZodOpenApiOperationObject = {- operationId: "getOSByClicks",- "x-speakeasy-name-override": "os",- summary: "Retrieve top OS by clicks",- description:- "Retrieve the top OS by number of clicks for a link, a domain, or the authenticated workspace.",- requestParams: {- query: workspaceParamsSchema.merge(analyticsQuerySchema),- },- responses: {- "200": {- description: "The top OS by number of clicks",- content: {- "application/json": {- schema: z.array(clickAnalyticsResponse["os"]),- },- },- },- ...openApiErrorResponses,- },- tags: ["analytics.clicks"],- security: [{ token: [] }],-};diff --git a/apps/web/lib/openapi/analytics/clicks/referers.ts b/apps/web/lib/openapi/analytics/clicks/referers.tsdeleted file mode 100644index 88011ff918..0000000000--- a/apps/web/lib/openapi/analytics/clicks/referers.ts+++ /dev/null@@ -1,30 +0,0 @@-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";-import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";-import { ZodOpenApiOperationObject } from "zod-openapi";-import { workspaceParamsSchema } from "../../request";--export const getReferersByClicks: ZodOpenApiOperationObject = {- operationId: "getReferersByClicks",- "x-speakeasy-name-override": "referers",- summary: "Retrieve top referers by clicks",- description:- "Retrieve the top referers by number of clicks for a link, a domain, or the authenticated workspace.",- requestParams: {- query: workspaceParamsSchema.merge(analyticsQuerySchema),- },- responses: {- "200": {- description: "The top referers by number of clicks",- content: {- "application/json": {- schema: z.array(clickAnalyticsResponse["referers"]),- },- },- },- ...openApiErrorResponses,- },- tags: ["analytics.clicks"],- security: [{ token: [] }],-};diff --git a/apps/web/lib/openapi/analytics/clicks/timeseries.ts b/apps/web/lib/openapi/analytics/clicks/timeseries.tsdeleted file mode 100644index e2cd2ce1ab..0000000000--- a/apps/web/lib/openapi/analytics/clicks/timeseries.ts+++ /dev/null@@ -1,30 +0,0 @@-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";-import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";-import { ZodOpenApiOperationObject } from "zod-openapi";-import { workspaceParamsSchema } from "../../request";--export const getTimeseriesByClicks: ZodOpenApiOperationObject = {- operationId: "getTimeseriesByClicks",- "x-speakeasy-name-override": "timeseries",- summary: "Retrieve timeseries click analytics",- description:- "Retrieve timeseries click analytics for a link, a domain, or the authenticated workspace over a period of time.",- requestParams: {- query: workspaceParamsSchema.merge(analyticsQuerySchema),- },- responses: {- "200": {- description: "The number of clicks over a period of time",- content: {- "application/json": {- schema: z.array(clickAnalyticsResponse["timeseries"]),- },- },- },- ...openApiErrorResponses,- },- 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.tsdeleted file mode 100644index 11588898f0..0000000000--- a/apps/web/lib/openapi/analytics/clicks/top-links.ts+++ /dev/null@@ -1,30 +0,0 @@-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";-import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";-import { ZodOpenApiOperationObject } from "zod-openapi";-import { workspaceParamsSchema } from "../../request";--export const getTopLinksByClicks: ZodOpenApiOperationObject = {- operationId: "getTopLinksByClicks",- "x-speakeasy-name-override": "topLinks",- summary: "Retrieve top links by clicks",- description:- "Retrieve the top links by number of clicks for a domain or the authenticated workspace.",- requestParams: {- query: workspaceParamsSchema.merge(analyticsQuerySchema),- },- responses: {- "200": {- description: "The top links by number of clicks",- content: {- "application/json": {- schema: z.array(clickAnalyticsResponse["top_links"]),- },- },- },- ...openApiErrorResponses,- },- 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.tsdeleted file mode 100644index 7f2a260cfe..0000000000--- a/apps/web/lib/openapi/analytics/clicks/top-urls.ts+++ /dev/null@@ -1,30 +0,0 @@-import { openApiErrorResponses } from "@/lib/openapi/responses";-import z from "@/lib/zod";-import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";-import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";-import { ZodOpenApiOperationObject } from "zod-openapi";-import { workspaceParamsSchema } from "../../request";--export const getTopURLsByClicks: ZodOpenApiOperationObject = {- operationId: "getTopURLsByClicks",- "x-speakeasy-name-override": "topUrls",- summary: "Retrieve top URLs by clicks",- description:- "Retrieve the top URLs by number of clicks for a given short link.",- requestParams: {- query: workspaceParamsSchema.merge(analyticsQuerySchema),- },- responses: {- "200": {- description: "The top URLs by number of clicks",- content: {- "application/json": {- schema: z.array(clickAnalyticsResponse["top_urls"]),- },- },- },- ...openApiErrorResponses,- },- tags: ["analytics.clicks"],- security: [{ token: [] }],-};diff --git a/apps/web/lib/openapi/analytics/index.ts b/apps/web/lib/openapi/analytics/index.tsnew file mode 100644index 0000000000..88b92f0256--- /dev/null+++ b/apps/web/lib/openapi/analytics/index.ts@@ -0,0 +1,70 @@+import { openApiErrorResponses } from "@/lib/openapi/responses";+import z from "@/lib/zod";+import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";+import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";+import { leadAnalyticsResponse } from "@/lib/zod/schemas/leads-analytics";+import { saleAnalyticsResponse } from "@/lib/zod/schemas/sales-analytics";+import { ZodOpenApiOperationObject, ZodOpenApiPathsObject } from "zod-openapi";+import { workspaceParamsSchema } from "../request";++const retrieveAnalytics: ZodOpenApiOperationObject = {+ operationId: "retrieveAnalytics",+ "x-speakeasy-name-override": "retrieve",+ summary:+ "Retrieve analytics for a link, a domain, or the authenticated workspace.",+ description:+ "Retrieve analytics for a link, a domain, or the authenticated workspace. The response type depends on the `event` and `type` query parameters.",+ requestParams: {+ query: workspaceParamsSchema.merge(analyticsQuerySchema),+ },+ responses: {+ "200": {+ description: "Analytics data",+ content: {+ "application/json": {+ schema: z.union([+ clickAnalyticsResponse.count,+ clickAnalyticsResponse.timeseries,+ clickAnalyticsResponse.countries,+ clickAnalyticsResponse.cities,+ clickAnalyticsResponse.devices,+ clickAnalyticsResponse.browsers,+ clickAnalyticsResponse.os,+ clickAnalyticsResponse.referers,+ clickAnalyticsResponse.top_links,+ clickAnalyticsResponse.top_urls,+ leadAnalyticsResponse.count,+ leadAnalyticsResponse.timeseries,+ leadAnalyticsResponse.countries,+ leadAnalyticsResponse.cities,+ leadAnalyticsResponse.devices,+ leadAnalyticsResponse.browsers,+ leadAnalyticsResponse.os,+ leadAnalyticsResponse.referers,+ leadAnalyticsResponse.top_links,+ leadAnalyticsResponse.top_urls,+ saleAnalyticsResponse.count,+ saleAnalyticsResponse.timeseries,+ saleAnalyticsResponse.countries,+ saleAnalyticsResponse.cities,+ saleAnalyticsResponse.devices,+ saleAnalyticsResponse.browsers,+ saleAnalyticsResponse.os,+ saleAnalyticsResponse.referers,+ saleAnalyticsResponse.top_links,+ saleAnalyticsResponse.top_urls,+ ]),+ },+ },+ },+ ...openApiErrorResponses,+ },+ tags: ["analytics"],+ security: [{ token: [] }],+};++export const analyticsPath: ZodOpenApiPathsObject = {+ "/analytics": {+ get: retrieveAnalytics,+ },+};diff --git a/apps/web/lib/openapi/index.ts b/apps/web/lib/openapi/index.tsindex 2a08ce6a7d..b678347e7a 100644--- a/apps/web/lib/openapi/index.ts+++ b/apps/web/lib/openapi/index.ts@@ -5,7 +5,7 @@ import { TagSchema } from "@/lib/zod/schemas/tags";import { WorkspaceSchema } from "@/lib/zod/schemas/workspaces";import { API_DOMAIN } from "@dub/utils";import { createDocument } from "zod-openapi";-import { clickAnalyticsPaths } from "./analytics/clicks";+import { analyticsPath } from "./analytics";import { domainsPaths } from "./domains";import { linksPaths } from "./links";import { metatagsPath } from "./metatags";@@ -40,7 +40,7 @@ export const document = createDocument({paths: {...linksPaths,...qrCodePaths,- ...clickAnalyticsPaths,+ ...analyticsPath,...workspacesPaths,...tagsPaths,...domainsPaths,diff --git a/apps/web/tests/analytics/clicks.test.ts b/apps/web/tests/analytics/clicks.test.tsindex ecfe5d96a5..b6d85200b7 100644--- a/apps/web/tests/analytics/clicks.test.ts+++ b/apps/web/tests/analytics/clicks.test.ts@@ -1,8 +1,4 @@-import {- DEPRECATED_ANALYTICS_ENDPOINTS,- VALID_ANALYTICS_ENDPOINTS,-} from "@/lib/analytics/constants";-import { formatAnalyticsEndpoint } from "@/lib/analytics/utils";+import { VALID_ANALYTICS_ENDPOINTS } from "@/lib/analytics/constants";import z from "@/lib/zod";import { clickAnalyticsResponse } from "@/lib/zod/schemas/clicks-analytics";import { describe, expect, test } from "vitest";@@ -15,9 +11,7 @@ describe.runIf(env.CI).sequential("GET /analytics/clicks", async () => {const { workspace, http } = await h.init();const { workspaceId } = workspace;- VALID_ANALYTICS_ENDPOINTS.filter(- (endpoint) => !DEPRECATED_ANALYTICS_ENDPOINTS.includes(endpoint),- ).map((endpoint) => {+ VALID_ANALYTICS_ENDPOINTS.map((endpoint) => {test(`by ${endpoint}`, async () => {const { status, data } = await http.get<any[]>({path: `/analytics/clicks/${endpoint}`,@@ -30,11 +24,7 @@ describe.runIf(env.CI).sequential("GET /analytics/clicks", async () => {expect(data).toBeGreaterThanOrEqual(0);} else {const parsed = z- .array(- clickAnalyticsResponse[- formatAnalyticsEndpoint(endpoint, "plural")- ].strict(),- )+ .array(clickAnalyticsResponse[endpoint].strict()).safeParse(data);expect(status).toEqual(200);@@ -55,26 +45,4 @@ describe.runIf(env.CI).sequential("GET /analytics/clicks", async () => {expect(clicks).toEqual(expect.any(Number));expect(clicks).toBeGreaterThanOrEqual(0);});-- // deprecated, backwards compatiblity- DEPRECATED_ANALYTICS_ENDPOINTS.map((endpoint) => {- test(`deprecated: by ${endpoint}`, async () => {- const { status, data } = await http.get<any[]>({- path: `/analytics/${endpoint}`,- query: { workspaceId, ...filter },- });-- const parsed = z- .array(- clickAnalyticsResponse[- formatAnalyticsEndpoint(endpoint, "plural")- ].strict(),- )- .safeParse(data);-- expect(status).toEqual(200);- expect(data.length).toBeGreaterThanOrEqual(0);- expect(parsed.success).toBeTruthy();- });- });});diff --git a/apps/web/tests/analytics/leads.test.ts b/apps/web/tests/analytics/leads.test.tsindex b2389dd120..e07e9c8f87 100644--- a/apps/web/tests/analytics/leads.test.ts+++ b/apps/web/tests/analytics/leads.test.ts@@ -1,8 +1,4 @@-import {- DEPRECATED_ANALYTICS_ENDPOINTS,- VALID_ANALYTICS_ENDPOINTS,-} from "@/lib/analytics/constants";-import { formatAnalyticsEndpoint } from "@/lib/analytics/utils";+import { VALID_ANALYTICS_ENDPOINTS } from "@/lib/analytics/constants";import z from "@/lib/zod";import { leadAnalyticsResponse } from "@/lib/zod/schemas/leads-analytics";import { describe, expect, test } from "vitest";@@ -14,9 +10,7 @@ describe.skip.sequential("GET /analytics/leads", async () => {const { workspace, http } = await h.init();const { workspaceId } = workspace;- VALID_ANALYTICS_ENDPOINTS.filter(- (endpoint) => !DEPRECATED_ANALYTICS_ENDPOINTS.includes(endpoint),- ).map((endpoint) => {+ VALID_ANALYTICS_ENDPOINTS.map((endpoint) => {test(`by ${endpoint}`, async () => {const { status, data } = await http.get<any[]>({path: `/analytics/leads/${endpoint}`,@@ -30,9 +24,8 @@ describe.skip.sequential("GET /analytics/leads", async () => {return;}- const schema = formatAnalyticsEndpoint(endpoint, "plural");const parsed = z- .array(leadAnalyticsResponse[schema].strict())+ .array(leadAnalyticsResponse[endpoint].strict()).safeParse(data);expect(status).toEqual(200);diff --git a/apps/web/tests/analytics/sales.test.ts b/apps/web/tests/analytics/sales.test.tsindex 641c68eab2..96d569cc38 100644--- a/apps/web/tests/analytics/sales.test.ts+++ b/apps/web/tests/analytics/sales.test.ts@@ -1,8 +1,4 @@-import {- DEPRECATED_ANALYTICS_ENDPOINTS,- VALID_ANALYTICS_ENDPOINTS,-} from "@/lib/analytics/constants";-import { formatAnalyticsEndpoint } from "@/lib/analytics/utils";+import { VALID_ANALYTICS_ENDPOINTS } from "@/lib/analytics/constants";import z from "@/lib/zod";import { saleAnalyticsResponse } from "@/lib/zod/schemas/sales-analytics";import { describe, expect, test } from "vitest";@@ -14,27 +10,23 @@ describe.skip.sequential("GET /analytics/sales", async () => {const { workspace, http } = await h.init();const { workspaceId } = workspace;- VALID_ANALYTICS_ENDPOINTS.filter(- (endpoint) => !DEPRECATED_ANALYTICS_ENDPOINTS.includes(endpoint),- ).map((endpoint) => {+ VALID_ANALYTICS_ENDPOINTS.map((endpoint) => {test(`by ${endpoint}`, async () => {const { status, data } = await http.get<any[]>({path: `/analytics/sales/${endpoint}`,query: { workspaceId, ...filter },});- const schema = formatAnalyticsEndpoint(endpoint, "plural");-expect(status).toEqual(200);if (endpoint === "count") {- const parsed = saleAnalyticsResponse[schema].strict().safeParse(data);+ const parsed = saleAnalyticsResponse[endpoint].strict().safeParse(data);expect(parsed.success).toBeTruthy();return;}const parsed = z- .array(saleAnalyticsResponse[schema].strict())+ .array(saleAnalyticsResponse[endpoint].strict()).safeParse(data);expect(data.length).toBeGreaterThanOrEqual(0);