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.

Generate fake click IDs inside recordFakeClick instead of callers.

Kiran K5ee7688e8499
diff --git a/apps/web/lib/integrations/shopify/attribute-via-discount-code.ts b/apps/web/lib/integrations/shopify/attribute-via-discount-code.ts
index fe07a4f1f4..920f5ac129 100644
--- a/apps/web/lib/integrations/shopify/attribute-via-discount-code.ts
+++ b/apps/web/lib/integrations/shopify/attribute-via-discount-code.ts
@@ -28,8 +28,20 @@ export async function attributeViaDiscountCode({
const billingAddressCountry = billingAddress?.country_code?.toUpperCase();
+ // Record a fake click for this event
+ const clickEvent = await recordFakeClick({
+ link,
+ customer: {
+ continent: billingAddressCountry
+ ? COUNTRIES_TO_CONTINENTS[billingAddressCountry] ?? "Unknown"
+ : "Unknown",
+ country: billingAddressCountry ?? "Unknown",
+ region: billingAddress?.province ?? "Unknown",
+ },
+ });
+
const customerId = createId({ prefix: "cus_" });
- const clickId = nanoid(16);
+ const clickId = clickEvent.click_id;
// Create the customer before recording the fake click so a P2002 on
// projectId_externalId never leaves an orphaned Tinybird click behind.
@@ -51,19 +63,6 @@ export async function attributeViaDiscountCode({
},
});
- // Record a fake click for this event
- const clickEvent = await recordFakeClick({
- link,
- clickId,
- customer: {
- continent: billingAddressCountry
- ? COUNTRIES_TO_CONTINENTS[billingAddressCountry] ?? "Unknown"
- : "Unknown",
- country: billingAddressCountry ?? "Unknown",
- region: billingAddress?.province ?? "Unknown",
- },
- });
-
// Prepare the payload for the lead event
const { timestamp, ...rest } = clickEvent;
diff --git a/apps/web/lib/integrations/shopify/error.ts b/apps/web/lib/integrations/shopify/error.ts
index 8db81b1f4d..0531925c2e 100644
--- a/apps/web/lib/integrations/shopify/error.ts
+++ b/apps/web/lib/integrations/shopify/error.ts
@@ -8,7 +8,3 @@ export class ShopifyError extends Error {
Object.setPrototypeOf(this, new.target.prototype);
}
}
-
-export function isShopifyError(error: unknown): error is ShopifyError {
- return error instanceof ShopifyError;
-}
diff --git a/apps/web/lib/tinybird/record-fake-click.ts b/apps/web/lib/tinybird/record-fake-click.ts
index 30994d55e3..76464382dd 100644
--- a/apps/web/lib/tinybird/record-fake-click.ts
+++ b/apps/web/lib/tinybird/record-fake-click.ts
@@ -25,7 +25,6 @@ export async function recordFakeClick({
link,
customer,
timestamp,
- clickId,
}: {
link: Pick<Link, "id" | "url" | "domain" | "key" | "projectId">;
customer?: {
@@ -34,7 +33,6 @@ export async function recordFakeClick({
continent?: string | null;
};
timestamp?: string | number;
- clickId?: string;
}) {
const dummyRequest = new Request(link.url, {
headers: new Headers({
@@ -48,7 +46,7 @@ export async function recordFakeClick({
const clickData = await recordClick({
req: dummyRequest,
- clickId: clickId ?? nanoid(16),
+ clickId: nanoid(16),
workspaceId: link.projectId!,
linkId: link.id,
domain: link.domain,