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.

wip leads analytics

Kiran K0e0a1deece73
diff --git a/apps/web/app/api/analytics/admin/clicks/[endpoint]/route.ts b/apps/web/app/api/analytics/admin/clicks/[endpoint]/route.ts
index 95061e5223..380379c7cf 100644
--- a/apps/web/app/api/analytics/admin/clicks/[endpoint]/route.ts
+++ b/apps/web/app/api/analytics/admin/clicks/[endpoint]/route.ts
@@ -3,7 +3,7 @@ import { withAdmin } from "@/lib/auth";
import {
analyticsEndpointSchema,
clickAnalyticsQuerySchema,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { NextResponse } from "next/server";
// GET /api/admin/analytics/clicks – get click analytics for admin
diff --git a/apps/web/app/api/analytics/clicks/[endpoint]/route.ts b/apps/web/app/api/analytics/clicks/[endpoint]/route.ts
index 9312a88d64..fb35ef21d6 100644
--- a/apps/web/app/api/analytics/clicks/[endpoint]/route.ts
+++ b/apps/web/app/api/analytics/clicks/[endpoint]/route.ts
@@ -5,7 +5,7 @@ import { getDomainViaEdge } from "@/lib/planetscale";
import {
analyticsEndpointSchema,
clickAnalyticsQuerySchema,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { NextResponse } from "next/server";
// GET /api/analytics/clicks/[endpoint] – get click analytics
diff --git a/apps/web/app/api/analytics/edge/clicks/[endpoint]/route.ts b/apps/web/app/api/analytics/edge/clicks/[endpoint]/route.ts
index 35d9111d7f..3dc93848c1 100644
--- a/apps/web/app/api/analytics/edge/clicks/[endpoint]/route.ts
+++ b/apps/web/app/api/analytics/edge/clicks/[endpoint]/route.ts
@@ -10,7 +10,7 @@ import { ratelimit } from "@/lib/upstash";
import {
analyticsEndpointSchema,
clickAnalyticsQuerySchema,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { DUB_DEMO_LINKS, DUB_WORKSPACE_ID, getSearchParams } from "@dub/utils";
import { ipAddress } from "@vercel/edge";
import { NextResponse, type NextRequest } from "next/server";
diff --git a/apps/web/app/api/analytics/export/route.ts b/apps/web/app/api/analytics/export/route.ts
index ea1f05b587..6db391eab1 100644
--- a/apps/web/app/api/analytics/export/route.ts
+++ b/apps/web/app/api/analytics/export/route.ts
@@ -8,7 +8,7 @@ import { DubApiError } from "@/lib/api/errors";
import { withWorkspace } from "@/lib/auth";
import { getDomainViaEdge } from "@/lib/planetscale";
import { prisma } from "@/lib/prisma";
-import { clickAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";
+import { clickAnalyticsQuerySchema } from "@/lib/zod/schemas/click-analytics";
import { linkConstructor } from "@dub/utils";
import { json2csv } from "json-2-csv";
import JSZip from "jszip";
diff --git a/apps/web/app/api/analytics/leads/[endpoint]/route.ts b/apps/web/app/api/analytics/leads/[endpoint]/route.ts
new file mode 100644
index 0000000000..72370e09a2
--- /dev/null
+++ b/apps/web/app/api/analytics/leads/[endpoint]/route.ts
@@ -0,0 +1,45 @@
+import { getLeads } from "@/lib/analytics/leads";
+import { validDateRangeForPlan } from "@/lib/analytics/utils";
+import { withWorkspace } from "@/lib/auth";
+import { getDomainViaEdge } from "@/lib/planetscale";
+import {
+ analyticsEndpointSchema,
+ clickAnalyticsQuerySchema,
+} from "@/lib/zod/schemas/click-analytics";
+import { NextResponse } from "next/server";
+
+// GET /api/analytics/leads/[endpoint] – get leads analytics
+export const GET = withWorkspace(
+ async ({ params, searchParams, workspace, link }) => {
+ const { endpoint } = analyticsEndpointSchema.parse(params);
+ const parsedParams = clickAnalyticsQuerySchema.parse(searchParams);
+
+ const { domain, key, interval, start, end } = parsedParams;
+
+ validDateRangeForPlan({
+ plan: workspace.plan,
+ interval,
+ start,
+ end,
+ throwError: true,
+ });
+
+ const linkId = link
+ ? link.id
+ : domain && key === "_root"
+ ? await getDomainViaEdge(domain).then((d) => d?.id)
+ : null;
+
+ const response = await getLeads({
+ ...parsedParams,
+ endpoint,
+ ...(linkId && { linkId }),
+ workspaceId: workspace.id,
+ });
+
+ return NextResponse.json(response);
+ },
+ {
+ needNotExceededClicks: true,
+ },
+);
diff --git a/apps/web/lib/analytics/clicks.ts b/apps/web/lib/analytics/clicks.ts
index 0937d7d013..ebe7f5e057 100644
--- a/apps/web/lib/analytics/clicks.ts
+++ b/apps/web/lib/analytics/clicks.ts
@@ -7,7 +7,7 @@ import {
clickAnalyticsQuerySchema,
getClickAnalytics,
getClickAnalyticsResponse,
-} from "../zod/schemas/analytics";
+} from "../zod/schemas/click-analytics";
import { INTERVAL_DATA } from "./constants";
import { AnalyticsEndpoints } from "./types";
diff --git a/apps/web/lib/analytics/leads.ts b/apps/web/lib/analytics/leads.ts
new file mode 100644
index 0000000000..269f300df8
--- /dev/null
+++ b/apps/web/lib/analytics/leads.ts
@@ -0,0 +1,90 @@
+import { tb } from "@/lib/tinybird";
+import z from "@/lib/zod";
+import { getDaysDifference } from "@dub/utils";
+import {
+ clickAnalyticsQuerySchema,
+ getClickAnalytics,
+} from "../zod/schemas/click-analytics";
+import { leadAnalyticsResponse } from "../zod/schemas/lead-analytics";
+import { INTERVAL_DATA } from "./constants";
+import { AnalyticsEndpoints } from "./types";
+
+export const getLeads = async (
+ props: z.infer<typeof clickAnalyticsQuerySchema> & {
+ workspaceId?: string;
+ endpoint: AnalyticsEndpoints;
+ },
+) => {
+ let { workspaceId, endpoint, interval, start, end } = props;
+
+ // get all-time clicks count if:
+ // 1. linkId is defined
+ // 2. endpoint is not defined
+ // 3. interval is all time
+ // 4. call is made from dashboard
+ // if (
+ // linkId &&
+ // endpoint === "count" &&
+ // interval === "all" &&
+ // headers()?.get("Request-Source") === "app.dub.co"
+ // ) {
+ // let response = await conn.execute(
+ // "SELECT clicks FROM Link WHERE `id` = ?",
+ // [linkId],
+ // );
+
+ // if (response.rows.length === 0) {
+ // response = await conn.execute(
+ // "SELECT clicks FROM Domain WHERE `id` = ?",
+ // [linkId],
+ // );
+ // if (response.rows.length === 0) {
+ // return 0;
+ // }
+ // }
+ // return response.rows[0]["clicks"];
+ // }
+
+ const pipe = tb.buildPipe({
+ pipe: `leads_${endpoint}`,
+ parameters: getClickAnalytics,
+ data: leadAnalyticsResponse[endpoint],
+ });
+
+ let granularity: "minute" | "hour" | "day" | "month" = "day";
+
+ if (interval) {
+ start = INTERVAL_DATA[interval].startDate;
+ end = new Date(Date.now());
+ granularity = INTERVAL_DATA[interval].granularity;
+ } else {
+ start = new Date(start!);
+ end = end ? new Date(end) : new Date(Date.now());
+ if (getDaysDifference(start, end) > 180) {
+ granularity = "month";
+ }
+
+ // swap start and end if start is greater than end
+ if (start > end) {
+ [start, end] = [end, start];
+ }
+ }
+
+ console.log("props", { ...props, start, end, workspaceId, granularity });
+
+ const response = await pipe(
+ getClickAnalytics.parse({
+ ...props,
+ workspaceId,
+ // start: start.toISOString().replace("T", " ").replace("Z", ""),
+ // end: end.toISOString().replace("T", " ").replace("Z", ""),
+ start: start.toISOString(),
+ end: end.toISOString(),
+ granularity,
+ }),
+ );
+
+ // for total leads, we return just the value;
+ // everything else we return an array of values
+ return endpoint === "count" ? response.data[0].leads : response.data;
+};
diff --git a/apps/web/lib/api/errors.ts b/apps/web/lib/api/errors.ts
index 1ea7f133ea..9b37dc4677 100644
--- a/apps/web/lib/api/errors.ts
+++ b/apps/web/lib/api/errors.ts
@@ -118,7 +118,8 @@ export function fromZodError(error: ZodError): ErrorResponse {
}
export function handleApiError(error: any): ErrorResponse & { status: number } {
- console.error("API error occurred", JSON.stringify(error, null, 2));
+ console.error("API error occurred", error);
+ // console.error("API error occurred", JSON.stringify(error, null, 2));
// Zod errors
if (error instanceof ZodError) {
diff --git a/apps/web/lib/edge-config/is-beta-tester.ts b/apps/web/lib/edge-config/is-beta-tester.ts
index 6b07e6c4c4..cccb745653 100644
--- a/apps/web/lib/edge-config/is-beta-tester.ts
+++ b/apps/web/lib/edge-config/is-beta-tester.ts
@@ -1,6 +1,7 @@
import { get } from "@vercel/edge-config";
export const isBetaTester = async (workspaceId: string) => {
+ return true;
workspaceId = workspaceId.startsWith("ws_")
? workspaceId
: `ws_${workspaceId}`;
diff --git a/apps/web/lib/openapi/analytics/clicks/browsers.ts b/apps/web/lib/openapi/analytics/clicks/browsers.ts
index c2a3c69e6e..d3aff1c6b8 100644
--- a/apps/web/lib/openapi/analytics/clicks/browsers.ts
+++ b/apps/web/lib/openapi/analytics/clicks/browsers.ts
@@ -3,7 +3,7 @@ import z from "@/lib/zod";
import {
clickAnalyticsQuerySchema,
getClickAnalyticsResponse,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { ZodOpenApiOperationObject } from "zod-openapi";
import { workspaceParamsSchema } from "../../request";
diff --git a/apps/web/lib/openapi/analytics/clicks/cities.ts b/apps/web/lib/openapi/analytics/clicks/cities.ts
index 02f1936bc3..a6a9ba1df3 100644
--- a/apps/web/lib/openapi/analytics/clicks/cities.ts
+++ b/apps/web/lib/openapi/analytics/clicks/cities.ts
@@ -3,7 +3,7 @@ import z from "@/lib/zod";
import {
clickAnalyticsQuerySchema,
getClickAnalyticsResponse,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { ZodOpenApiOperationObject } from "zod-openapi";
import { workspaceParamsSchema } from "../../request";
diff --git a/apps/web/lib/openapi/analytics/clicks/count.ts b/apps/web/lib/openapi/analytics/clicks/count.ts
index 3450d5369a..9ffaae57ca 100644
--- a/apps/web/lib/openapi/analytics/clicks/count.ts
+++ b/apps/web/lib/openapi/analytics/clicks/count.ts
@@ -1,5 +1,5 @@
import { openApiErrorResponses } from "@/lib/openapi/responses";
-import { clickAnalyticsQuerySchema } from "@/lib/zod/schemas/analytics";
+import { clickAnalyticsQuerySchema } from "@/lib/zod/schemas/click-analytics";
import { ZodOpenApiOperationObject } from "zod-openapi";
import { workspaceParamsSchema } from "../../request";
diff --git a/apps/web/lib/openapi/analytics/clicks/countries.ts b/apps/web/lib/openapi/analytics/clicks/countries.ts
index 5381070028..0f4d672f30 100644
--- a/apps/web/lib/openapi/analytics/clicks/countries.ts
+++ b/apps/web/lib/openapi/analytics/clicks/countries.ts
@@ -3,7 +3,7 @@ import z from "@/lib/zod";
import {
clickAnalyticsQuerySchema,
getClickAnalyticsResponse,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { ZodOpenApiOperationObject } from "zod-openapi";
import { workspaceParamsSchema } from "../../request";
diff --git a/apps/web/lib/openapi/analytics/clicks/devices.ts b/apps/web/lib/openapi/analytics/clicks/devices.ts
index 060e9f9caf..e72ede7e43 100644
--- a/apps/web/lib/openapi/analytics/clicks/devices.ts
+++ b/apps/web/lib/openapi/analytics/clicks/devices.ts
@@ -3,7 +3,7 @@ import z from "@/lib/zod";
import {
clickAnalyticsQuerySchema,
getClickAnalyticsResponse,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { ZodOpenApiOperationObject } from "zod-openapi";
import { workspaceParamsSchema } from "../../request";
diff --git a/apps/web/lib/openapi/analytics/clicks/os.ts b/apps/web/lib/openapi/analytics/clicks/os.ts
index 294755d4c1..d10b047985 100644
--- a/apps/web/lib/openapi/analytics/clicks/os.ts
+++ b/apps/web/lib/openapi/analytics/clicks/os.ts
@@ -3,7 +3,7 @@ import z from "@/lib/zod";
import {
clickAnalyticsQuerySchema,
getClickAnalyticsResponse,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { ZodOpenApiOperationObject } from "zod-openapi";
import { workspaceParamsSchema } from "../../request";
diff --git a/apps/web/lib/openapi/analytics/clicks/referers.ts b/apps/web/lib/openapi/analytics/clicks/referers.ts
index a79ba8df65..27fe88df5c 100644
--- a/apps/web/lib/openapi/analytics/clicks/referers.ts
+++ b/apps/web/lib/openapi/analytics/clicks/referers.ts
@@ -3,7 +3,7 @@ import z from "@/lib/zod";
import {
clickAnalyticsQuerySchema,
getClickAnalyticsResponse,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { ZodOpenApiOperationObject } from "zod-openapi";
import { workspaceParamsSchema } from "../../request";
diff --git a/apps/web/lib/openapi/analytics/clicks/timeseries.ts b/apps/web/lib/openapi/analytics/clicks/timeseries.ts
index 7ada37b848..8a2cf3cbcc 100644
--- a/apps/web/lib/openapi/analytics/clicks/timeseries.ts
+++ b/apps/web/lib/openapi/analytics/clicks/timeseries.ts
@@ -3,7 +3,7 @@ import z from "@/lib/zod";
import {
clickAnalyticsQuerySchema,
getClickAnalyticsResponse,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { ZodOpenApiOperationObject } from "zod-openapi";
import { workspaceParamsSchema } from "../../request";
diff --git a/apps/web/lib/openapi/analytics/clicks/top-links.ts b/apps/web/lib/openapi/analytics/clicks/top-links.ts
index c73f7dd570..0214e933a0 100644
--- a/apps/web/lib/openapi/analytics/clicks/top-links.ts
+++ b/apps/web/lib/openapi/analytics/clicks/top-links.ts
@@ -3,7 +3,7 @@ import z from "@/lib/zod";
import {
clickAnalyticsQuerySchema,
getClickAnalyticsResponse,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { ZodOpenApiOperationObject } from "zod-openapi";
import { workspaceParamsSchema } from "../../request";
diff --git a/apps/web/lib/openapi/analytics/clicks/top-urls.ts b/apps/web/lib/openapi/analytics/clicks/top-urls.ts
index d3a8c2fc30..dda96f42d1 100644
--- a/apps/web/lib/openapi/analytics/clicks/top-urls.ts
+++ b/apps/web/lib/openapi/analytics/clicks/top-urls.ts
@@ -3,7 +3,7 @@ import z from "@/lib/zod";
import {
clickAnalyticsQuerySchema,
getClickAnalyticsResponse,
-} from "@/lib/zod/schemas/analytics";
+} from "@/lib/zod/schemas/click-analytics";
import { ZodOpenApiOperationObject } from "zod-openapi";
import { workspaceParamsSchema } from "../../request";
diff --git a/apps/web/lib/zod/schemas/analytics.ts b/apps/web/lib/zod/schemas/click-analytics.ts
similarity index 100%
rename from apps/web/lib/zod/schemas/analytics.ts
rename to apps/web/lib/zod/schemas/click-analytics.ts
diff --git a/apps/web/lib/zod/schemas/lead-analytics.ts b/apps/web/lib/zod/schemas/lead-analytics.ts
new file mode 100644
index 0000000000..4eb66cb97b
--- /dev/null
+++ b/apps/web/lib/zod/schemas/lead-analytics.ts
@@ -0,0 +1,64 @@
+import z from "@/lib/zod";
+import { COUNTRY_CODES } from "@dub/utils";
+
+export const leadAnalyticsResponse = {
+ count: z.object({
+ leads: z.number().describe("The total number of leads"),
+ }),
+
+ timeseries: z.object({
+ start: z.string().describe("The starting timestamp of the interval"),
+ leads: z.number().describe("The number of leads in the interval"),
+ }),
+
+ countries: z
+ .object({
+ country: z
+ .enum(COUNTRY_CODES)
+ .describe("The 2-letter country code: https://d.to/geo"),
+ leads: z.number().describe("The number of leads from this country"),
+ })
+ .openapi({ ref: "leadsByCountry" }),
+
+ cities: z
+ .object({
+ city: z.string().describe("The name of the city"),
+ country: z
+ .enum(COUNTRY_CODES)
+ .describe("The 2-letter country code of the city: https://d.to/geo"),
+ leads: z.number().describe("The number of leads from this city"),
+ })
+ .openapi({ ref: "leadsByCities" }),
+
+ devices: z.object({
+ device: z.string().describe("The name of the device"),
+ leads: z.number().describe("The number of leads from this device"),
+ }),
+
+ browsers: z.object({
+ browser: z.string().describe("The name of the browser"),
+ leads: z.number().describe("The number of leads from this browser"),
+ }),
+
+ os: z.object({
+ os: z.string().describe("The name of the OS"),
+ leads: z.number().describe("The number of leads from this OS"),
+ }),
+
+ referers: z.object({
+ referer: z
+ .string()
+ .describe("The name of the referer. If unknown, this will be `(direct)`"),
+ leads: z.number().describe("The number of leads from this referer"),
+ }),
+
+ top_links: z.object({
+ link: z.string().describe("The unique ID of the short link"),
+ leads: z.number().describe("The number of leads from this link"),
+ }),
+
+ top_urls: z.object({
+ url: z.string().describe("The destination URL"),
+ leads: z.number().describe("The number of leads from this URL"),
+ }),
+} as const;
diff --git a/apps/web/scripts/seed-data.ts b/apps/web/scripts/seed-data.ts
index c240b744b1..7e82ed779a 100644
--- a/apps/web/scripts/seed-data.ts
+++ b/apps/web/scripts/seed-data.ts
@@ -1,39 +1,91 @@
-import { getLeadEvent, recordSale } from "@/lib/tinybird";
-import { clickEventSchemaTB } from "@/lib/zod/schemas/clicks";
-import { nanoid } from "@dub/utils";
import "dotenv-flow/config";
-const customerId = "xxx";
-
async function main() {
- const leadEvent = await getLeadEvent({ customerId });
-
- const clickData = clickEventSchemaTB
- .omit({ timestamp: true })
- .parse(leadEvent.data[0]);
-
- await recordSale(
- Array.from({ length: 420 }, () => ({
- ...clickData,
- // random timestamp between now and 30 days ago
- timestamp: new Date(
- Date.now() - Math.floor(Math.random() * 30 * 24 * 60 * 60 * 1000),
- ).toISOString(),
- customer_id: customerId,
- event_id: nanoid(16),
- payment_processor: "Stripe",
- product_id: "xxx",
- invoice_id: "xxx",
- // random amount between 2400 and 9900, in increments of 100
- amount: Math.floor(Math.random() * 75 + 24) * 100,
- currency: "usd",
- recurring: 1,
- recurring_interval: "monthly",
- recurring_interval_count: 1,
- refunded: 0,
- metadata: "",
- })),
- );
+ const fakeEventName = [
+ "Sign Up",
+ "Created Account",
+ "Added Payment Method",
+ "Subscribed",
+ "Started Trial",
+ ];
+
+ for (let i = 1; i <= 10; i++) {
+ const response = await fetch(
+ "http://localhost:8888/api/track/lead?workspaceId=ws_clv6iazq2003k8lh32eclix8l",
+ {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer iGjIsxS2OsMuQFaRdH5jZKNn`,
+ },
+ body: JSON.stringify({
+ clickId: "efosj1dQU0NHZLQa",
+ eventName:
+ fakeEventName[Math.floor(Math.random() * fakeEventName.length)],
+ customerId: `david-${i}`,
+ customerName: `David ${i}`,
+ customerEmail: `david-${i}@dub.co`,
+ }),
+ },
+ );
+
+ const data = await response.json();
+ console.log(data);
+ }
+
+ // console.log("Token", process.env.TINYBIRD_API_KEY)
+ // const clickEvent = await getClickEvent({ clickId });
+ // console.log(clickEvent);
+
+ // const clickData = clickEventSchemaTB
+ // .omit({ timestamp: true })
+ // .parse(clickEvent.data[0]);
+
+ // const fakeEventName = [
+ // "Sign Up",
+ // "Created Account",
+ // "Added Payment Method",
+ // "Subscribed",
+ // "Started Trial",
+ // ];
+
+ // // Record leads
+ // recordLead({
+ // ...clickData,
+ // event_id: nanoid(16),
+ // event_name: fakeEventName[Math.floor(Math.random() * fakeEventName.length)],
+ // customer_id: customerId,
+ // metadata: "",
+ // });
+
+ // const leadEvent = await getLeadEvent({ customerId });
+
+ // const clickData = clickEventSchemaTB
+ // .omit({ timestamp: true })
+ // .parse(leadEvent.data[0]);
+
+ // await recordSale(
+ // Array.from({ length: 420 }, () => ({
+ // ...clickData,
+ // // random timestamp between now and 30 days ago
+ // timestamp: new Date(
+ // Date.now() - Math.floor(Math.random() * 30 * 24 * 60 * 60 * 1000),
+ // ).toISOString(),
+ // customer_id: customerId,
+ // event_id: nanoid(16),
+ // payment_processor: "Stripe",
+ // product_id: "xxx",
+ // invoice_id: "xxx",
+ // // random amount between 2400 and 9900, in increments of 100
+ // amount: Math.floor(Math.random() * 75 + 24) * 100,
+ // currency: "usd",
+ // recurring: 1,
+ // recurring_interval: "monthly",
+ // recurring_interval_count: 1,
+ // refunded: 0,
+ // metadata: "",
+ // })),
+ // );
}
main();
diff --git a/apps/web/tests/analytics/clicks.test.ts b/apps/web/tests/analytics/clicks.test.ts
index 955908865d..0f5e6f27eb 100644
--- a/apps/web/tests/analytics/clicks.test.ts
+++ b/apps/web/tests/analytics/clicks.test.ts
@@ -4,7 +4,7 @@ import {
} from "@/lib/analytics/constants";
import { formatAnalyticsEndpoint } from "@/lib/analytics/utils";
import z from "@/lib/zod";
-import { getClickAnalyticsResponse } from "@/lib/zod/schemas/analytics";
+import { getClickAnalyticsResponse } from "@/lib/zod/schemas/click-analytics";
import { describe, expect, test } from "vitest";
import { env } from "../utils/env";
import { IntegrationHarness } from "../utils/integration";
diff --git a/packages/tinybird/datasources/dub_click_events_mv.datasource b/packages/tinybird/datasources/dub_click_events_mv.datasource
index c7acf68c88..2da156a792 100644
--- a/packages/tinybird/datasources/dub_click_events_mv.datasource
+++ b/packages/tinybird/datasources/dub_click_events_mv.datasource
@@ -16,4 +16,4 @@ SCHEMA >
ENGINE "MergeTree"
ENGINE_PARTITION_KEY "toYYYYMM(timestamp)"
-ENGINE_SORTING_KEY "link_id, timestamp"
+ENGINE_SORTING_KEY "link_id, timestamp"
\ No newline at end of file
diff --git a/packages/tinybird/datasources/dub_lead_events_mv.datasource b/packages/tinybird/datasources/dub_lead_events_mv.datasource
new file mode 100644
index 0000000000..e69de29bb2