The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix A/B tests to use base_url endpoint
Steven Tey741404d513fb
diff --git a/apps/web/lib/api/links/complete-ab-tests.ts b/apps/web/lib/api/links/complete-ab-tests.tsindex ce225035ad..bf0325da61 100644--- a/apps/web/lib/api/links/complete-ab-tests.ts+++ b/apps/web/lib/api/links/complete-ab-tests.ts@@ -18,7 +18,7 @@ export async function completeABTests(link: Link) {const analytics: { url: string; leads: number }[] = await getAnalytics({event: "leads",- groupBy: "top_urls",+ groupBy: "top_base_urls",linkId: link.id,workspaceId: link.projectId,start: link.testStartedAt ? new Date(link.testStartedAt) : undefined,diff --git a/apps/web/lib/zod/schemas/analytics.ts b/apps/web/lib/zod/schemas/analytics.tsindex 45651e7fac..6fcb6136fb 100644--- a/apps/web/lib/zod/schemas/analytics.ts+++ b/apps/web/lib/zod/schemas/analytics.ts@@ -195,7 +195,7 @@ export const analyticsQuerySchema = zreferer: z.string().optional()- .describe("The referer to retrieve analytics for.")+ .describe("The referer hostname to retrieve analytics for.").openapi({ example: "google.com" }),refererUrl: z.string()diff --git a/apps/web/ui/analytics/partner-section.tsx b/apps/web/ui/analytics/partner-section.tsxindex 6fe06b252c..36c2860753 100644--- a/apps/web/ui/analytics/partner-section.tsx+++ b/apps/web/ui/analytics/partner-section.tsx@@ -49,7 +49,7 @@ const TAB_CONFIG: Record<},getGroupBy: (subtab): { groupBy: AnalyticsGroupByOptions } => {if (subtab === "short_links") return { groupBy: "top_links" };- return { groupBy: "top_urls" };+ return { groupBy: "top_base_urls" };},},};diff --git a/apps/web/ui/analytics/use-analytics-filters.tsx b/apps/web/ui/analytics/use-analytics-filters.tsxindex 17922c85e1..fae4b69d97 100644--- a/apps/web/ui/analytics/use-analytics-filters.tsx+++ b/apps/web/ui/analytics/use-analytics-filters.tsx@@ -271,7 +271,7 @@ export function useAnalyticsFilters({omitGroupByFilterKey: true,context,});- const { data: urls } = useAnalyticsFilterOption("top_urls", {+ const { data: baseUrls } = useAnalyticsFilterOption("top_base_urls", {disabled: !isRequested("url"),omitGroupByFilterKey: true,context,@@ -721,7 +721,7 @@ export function useAnalyticsFilters({/>),options:- urls?.map(({ url, ...rest }) => ({+ baseUrls?.map(({ url, ...rest }) => ({value: url,label: url.replace(/^https?:\/\//, "").replace(/\/$/, ""),right: getFilterOptionTotal(rest),@@ -813,7 +813,7 @@ export function useAnalyticsFilters({os,referers,refererUrls,- urls,+ baseUrls,utmData,searchParamsObj.tagIds,searchParamsObj.domain,diff --git a/apps/web/ui/links/link-tests.tsx b/apps/web/ui/links/link-tests.tsxindex 7cfae99ea6..c111b7a6d1 100644--- a/apps/web/ui/links/link-tests.tsx+++ b/apps/web/ui/links/link-tests.tsx@@ -41,7 +41,7 @@ export const LinkTests = memo(({ link }: { link: ResponseLink }) => {showTests &&`/api/analytics?${new URLSearchParams({event: "composite",- groupBy: "top_urls",+ groupBy: "top_base_urls",linkId: link.id,workspaceId: workspaceId!,...(link.testStartedAt && {diff --git a/packages/tinybird/pipes/v3_count.pipe b/packages/tinybird/pipes/v3_count.pipeindex 57073a379b..bb4ccf01ce 100644--- a/packages/tinybird/pipes/v3_count.pipe+++ b/packages/tinybird/pipes/v3_count.pipe@@ -93,7 +93,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}@@ -144,7 +144,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}{% if defined(filters) %}@@ -228,7 +228,7 @@ SQL >AND urlLIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}{% if defined(filters) %}diff --git a/packages/tinybird/pipes/v3_events.pipe b/packages/tinybird/pipes/v3_events.pipeindex 83593f0c86..00c2f0956c 100644--- a/packages/tinybird/pipes/v3_events.pipe+++ b/packages/tinybird/pipes/v3_events.pipe@@ -97,7 +97,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}ORDER BY timestamp {% if order == 'asc' %} ASC {% else %} DESC {% end %}@@ -155,7 +155,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}{% if defined(filters) %}@@ -237,7 +237,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}{% if defined(filters) %}diff --git a/packages/tinybird/pipes/v3_group_by.pipe b/packages/tinybird/pipes/v3_group_by.pipeindex 965bc01a8e..3cf9e755d9 100644--- a/packages/tinybird/pipes/v3_group_by.pipe+++ b/packages/tinybird/pipes/v3_group_by.pipe@@ -138,7 +138,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}GROUP BY@@ -241,7 +241,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}{% if defined(filters) %}@@ -368,7 +368,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime(end) }} {% end %}{% if defined(filters) %}diff --git a/packages/tinybird/pipes/v3_group_by_link_metadata.pipe b/packages/tinybird/pipes/v3_group_by_link_metadata.pipeindex 61f5787fe9..292e07fb72 100644--- a/packages/tinybird/pipes/v3_group_by_link_metadata.pipe+++ b/packages/tinybird/pipes/v3_group_by_link_metadata.pipe@@ -108,7 +108,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}GROUP BY wl.groupByField@@ -164,7 +164,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}GROUP BY wl.groupByField@@ -221,7 +221,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}GROUP BY wl.groupByFielddiff --git a/packages/tinybird/pipes/v3_timeseries.pipe b/packages/tinybird/pipes/v3_timeseries.pipeindex 7f59af78ca..511a3eb0f4 100644--- a/packages/tinybird/pipes/v3_timeseries.pipe+++ b/packages/tinybird/pipes/v3_timeseries.pipe@@ -176,7 +176,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}GROUP BY interval@@ -254,7 +254,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}GROUP BY interval@@ -337,7 +337,7 @@ SQL >{% if defined(utm_content) %}AND url LIKE concat('%utm_content=', encodeURLFormComponent({{ String(utm_content) }}), '%'){% end %}- {% if defined(url) %} AND url = {{ url }} {% end %}+ {% if defined(url) %} AND splitByString('?', url)[1] = {{ url }} {% end %}{% if defined(start) %} AND timestamp >= {{ DateTime64(start) }} {% end %}{% if defined(end) %} AND timestamp <= {{ DateTime64(end) }} {% end %}GROUP BY interval