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.

saleOccurrence → saleType

Steven Tey85e25c147c04
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx
index a7df83f705..f021bb7bf7 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx
@@ -10,7 +10,7 @@ import { ConversionBlock } from "@/ui/partners/overview/blocks/conversion-block"
import { CountriesBlock } from "@/ui/partners/overview/blocks/countries-block";
import { LinksBlock } from "@/ui/partners/overview/blocks/links-block";
import { PartnersBlock } from "@/ui/partners/overview/blocks/partners-block";
-import { SaleOccurrenceBlock } from "@/ui/partners/overview/blocks/sale-occurrence-block";
+import { SaleTypeBlock } from "@/ui/partners/overview/blocks/sale-type-block";
import { TrafficSourcesBlock } from "@/ui/partners/overview/blocks/traffic-sources-block";
import { ProgramOverviewCard } from "@/ui/partners/overview/program-overview-card";
import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
@@ -29,7 +29,7 @@ const BLOCKS = [
ConversionBlock,
CountriesBlock,
LinksBlock,
- SaleOccurrenceBlock,
+ SaleTypeBlock,
];
export default function ProgramOverviewPageClient() {
diff --git a/apps/web/lib/analytics/constants.ts b/apps/web/lib/analytics/constants.ts
index 5d59a0b09f..d1d925fc26 100644
--- a/apps/web/lib/analytics/constants.ts
+++ b/apps/web/lib/analytics/constants.ts
@@ -178,7 +178,7 @@ export const VALID_ANALYTICS_FILTERS = [
"customerId",
"qr", // deprecated, but keeping for now for backwards compatibility
"root",
- "saleOccurrence",
+ "saleType",
"utm_source",
"utm_medium",
"utm_campaign",
diff --git a/apps/web/lib/zod/schemas/analytics.ts b/apps/web/lib/zod/schemas/analytics.ts
index 72ed5f5f64..8cd70e5096 100644
--- a/apps/web/lib/zod/schemas/analytics.ts
+++ b/apps/web/lib/zod/schemas/analytics.ts
@@ -226,11 +226,11 @@ export const analyticsQuerySchema = z
.describe(
"Filter for root domains. If true, filter for domains only. If false, filter for links only. If undefined, return both.",
),
- saleOccurrence: z
+ saleType: z
.enum(["new", "recurring"])
.optional()
.describe(
- "The sale occurrence to retrieve analytics for (to differentiate between first and recurring sales). If undefined, return both.",
+ "Filter sales by type: 'new' for first-time purchases, 'recurring' for repeat purchases. If undefined, returns both.",
),
})
.merge(utmTagsSchema);
@@ -245,7 +245,7 @@ export const analyticsFilterTB = z
.transform((v) => (v ? prefixWorkspaceId(v) : undefined)),
customerId: z.string().optional(),
root: z.boolean().optional(),
- saleOccurrence: z.string().optional(),
+ saleType: z.string().optional(),
qr: z.boolean().optional(),
start: z.string(),
end: z.string(),
diff --git a/apps/web/ui/analytics/use-analytics-filters.tsx b/apps/web/ui/analytics/use-analytics-filters.tsx
index b844dfb676..f5dc25533e 100644
--- a/apps/web/ui/analytics/use-analytics-filters.tsx
+++ b/apps/web/ui/analytics/use-analytics-filters.tsx
@@ -465,9 +465,9 @@ export function useAnalyticsFilters({
})) ?? null,
},
{
- key: "saleOccurrence",
+ key: "saleType",
icon: Receipt2,
- label: "Sale occurrence",
+ label: "Sale type",
separatorAfter: true,
options: [
{
diff --git a/apps/web/ui/partners/overview/blocks/sale-occurrence-block.tsx b/apps/web/ui/partners/overview/blocks/sale-type-block.tsx
similarity index 97%
rename from apps/web/ui/partners/overview/blocks/sale-occurrence-block.tsx
rename to apps/web/ui/partners/overview/blocks/sale-type-block.tsx
index 91862edf21..39186b4b6f 100644
--- a/apps/web/ui/partners/overview/blocks/sale-occurrence-block.tsx
+++ b/apps/web/ui/partners/overview/blocks/sale-type-block.tsx
@@ -9,7 +9,7 @@ import { useContext, useMemo, useState } from "react";
import useSWR from "swr";
import { ProgramOverviewBlock } from "../program-overview-block";
-export function SaleOccurrenceBlock() {
+export function SaleTypeBlock() {
const { slug: workspaceSlug } = useWorkspace();
const { getQueryString } = useRouterStuff();
@@ -27,7 +27,7 @@ export function SaleOccurrenceBlock() {
`/api/analytics?${editQueryString(queryString, {
event: "sales",
groupBy: "count",
- saleOccurrence: "recurring",
+ saleType: "recurring",
})}`,
fetcher,
{
@@ -112,7 +112,7 @@ export function SaleOccurrenceBlock() {
<Link
key={item.key}
href={`/${workspaceSlug}/program/analytics${getQueryString(
- { tab: "sales", saleOccurrence: item.key },
+ { tab: "sales", saleType: item.key },
{
include: ["interval", "start", "end"],
},
diff --git a/packages/tinybird/pipes/v2_count.pipe b/packages/tinybird/pipes/v2_count.pipe
index 42341c89f5..dffc215272 100644
--- a/packages/tinybird/pipes/v2_count.pipe
+++ b/packages/tinybird/pipes/v2_count.pipe
@@ -178,7 +178,7 @@ SQL >
-NODE count_sales_with_occurrence
+NODE count_sales_with_type
SQL >
%
@@ -252,9 +252,9 @@ SQL >
INNER JOIN min_timestamps USING (customer_id, link_id)
WHERE
1 = 1
- {% if defined(saleOccurrence) %}
- {% if saleOccurrence == 'new' %} AND timestamp <= first_sale_ts
- {% elif saleOccurrence == 'recurring' %} AND timestamp > first_sale_ts
+ {% if defined(saleType) %}
+ {% if saleType == 'new' %} AND timestamp <= first_sale_ts
+ {% elif saleType == 'recurring' %} AND timestamp > first_sale_ts
{% end %}
{% end %}
) AS subquery
@@ -277,7 +277,7 @@ SQL >
{% if eventType == 'clicks' %} count_clicks
{% elif eventType == 'leads' %} count_leads
{% elif eventType == 'sales' %}
- {% if defined(saleType) %} count_sales_with_occurrence {% else %} count_sales {% end %}
+ {% if defined(saleType) %} count_sales {% else %} count_sales {% end %}
{% else %} count_composite
{% end %}
diff --git a/packages/tinybird/pipes/v2_events.pipe b/packages/tinybird/pipes/v2_events.pipe
index ea7bece15e..376b311a75 100644
--- a/packages/tinybird/pipes/v2_events.pipe
+++ b/packages/tinybird/pipes/v2_events.pipe
@@ -180,7 +180,7 @@ SQL >
-NODE sale_events_with_occurrence
+NODE sale_events_with_type
SQL >
%
@@ -243,14 +243,14 @@ SQL >
WHERE (customer_id, link_id) IN distinct_sales
GROUP BY customer_id, link_id
)
- SELECT *, CASE WHEN timestamp = first_sale_ts THEN 'new' ELSE 'recurring' END as sale_occurrence
+ SELECT *, CASE WHEN timestamp = first_sale_ts THEN 'new' ELSE 'recurring' END as sale_type
FROM sales
INNER JOIN min_timestamps USING (customer_id, link_id)
WHERE
1 = 1
- {% if defined(saleOccurrence) %}
- {% if saleOccurrence == 'new' %} AND timestamp = first_sale_ts
- {% elif saleOccurrence == 'recurring' %} AND timestamp > first_sale_ts
+ {% if defined(saleType) %}
+ {% if saleType == 'new' %} AND timestamp = first_sale_ts
+ {% elif saleType == 'recurring' %} AND timestamp > first_sale_ts
{% end %}
{% end %}
ORDER BY timestamp {% if order == 'asc' %} ASC {% else %} DESC {% end %}
@@ -267,7 +267,7 @@ SQL >
FROM
{% if eventType == 'leads' %} lead_events
{% elif eventType == 'sales' %}
- {% if defined(saleOccurrence) %} sale_events_with_occurrence {% else %} sale_events {% end %}
+ {% if defined(saleType) %} sale_events_with_type {% else %} sale_events {% end %}
{% else %} click_events
{% end %}