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.

Merge branch 'main' into improve-shopify-integration

Kiran Kbd00ed4c92e5
diff --cc apps/web/lib/integrations/shopify/create-lead.ts
index b544aee015,10f5e3cdc4..84886ffd94
--- a/apps/web/lib/integrations/shopify/create-lead.ts
+++ b/apps/web/lib/integrations/shopify/create-lead.ts
@@@ -10,8 -10,10 +10,10 @@@ import { sendWorkspaceWebhook } from "@
import { transformLeadEventData } from "@/lib/webhook/transform";
import { leadEventSchemaTB } from "@/lib/zod/schemas/leads";
import { nanoid } from "@dub/utils";
+ import { EventType } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
+ import { queueGoogleAdsConversionUpload } from "../google-ads/upload-conversion";
-import { orderSchema } from "./schema";
+import { shopifyOrderSchema } from "./schema";
export async function createShopifyLead({
clickId,
diff --cc apps/web/lib/integrations/shopify/process-order.ts
index 9a95571447,5e65157ae9..7cea0eb838
--- a/apps/web/lib/integrations/shopify/process-order.ts
+++ b/apps/web/lib/integrations/shopify/process-order.ts
@@@ -13,11 -13,12 +13,12 @@@ import { WorkspaceProps } from "@/lib/t
import { sendWorkspaceWebhook } from "@/lib/webhook/publish";
import { transformLeadEventData } from "@/lib/webhook/transform";
import { COUNTRIES_TO_CONTINENTS, nanoid } from "@dub/utils";
- import { Link } from "@prisma/client";
+ import { EventType, Link } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
+ import { queueGoogleAdsConversionUpload } from "../google-ads/upload-conversion";
import { createShopifyLead } from "./create-lead";
import { createShopifySale } from "./create-sale";
-import { orderSchema } from "./schema";
+import { orderSchema, ShopifyOrder } from "./schema";
// Process the order from Shopify webhook
export async function processOrder({
diff --cc apps/web/lib/jobs/registry.ts
index 861a419b3e,078257b5c9..36f5abd252
--- a/apps/web/lib/jobs/registry.ts
+++ b/apps/web/lib/jobs/registry.ts
@@@ -30,10 -30,10 +30,15 @@@ const jobLoaders =
(m) => m.createTremendousCampaignJob,
),
+ "partner-search-sync-job": () =>
+ import("./handlers/partner-search-sync-job").then(
+ (m) => m.partnerSearchSyncJob,
+ ),
++
+ "process-shopify-order-job": () =>
+ import("./handlers/process-shopify-order-job").then(
+ (m) => m.processShopifyOrderJob,
+ ),
} as const satisfies Record<string, () => Promise<JobDefinition>>;
const jobCache = new Map<string, JobDefinition>();
diff --cc apps/web/playwright/api/setup-test-workspace.ts
index bc6b4288e4,da1495546c..d1bd2ad461
--- a/apps/web/playwright/api/setup-test-workspace.ts
+++ b/apps/web/playwright/api/setup-test-workspace.ts
@@@ -31,11 -32,69 +32,72 @@@ export const TEST_WORKSPACE =
domain: "playwright-api.dub-internal-test.com",
url: "https://example.com",
},
+ shopify: {
+ storeId: "playwright-api.myshopify.com",
+ },
} as const;
+ export const TEST_COMMISSION_REWARDS = {
+ lead: {
+ id: "rw_playwright_api_lead",
+ event: EventType.lead,
+ type: RewardStructure.flat,
+ amountInCents: 1000,
+ modifiers: [
+ {
+ operator: "AND",
+ type: RewardStructure.flat,
+ amountInCents: 5000,
+ conditions: [
+ {
+ entity: "lead",
+ attribute: "metadata",
+ metadataField: "plan",
+ operator: "equals_to",
+ value: "pro",
+ },
+ ],
+ },
+ ],
+ },
+ sale: {
+ id: "rw_playwright_api_sale",
+ event: EventType.sale,
+ type: RewardStructure.flat,
+ amountInCents: 2500,
+ maxDuration: 0,
+ modifiers: [
+ {
+ operator: "AND",
+ type: RewardStructure.flat,
+ amountInCents: 5000,
+ conditions: [
+ {
+ entity: "sale",
+ attribute: "productId",
+ operator: "equals_to",
+ value: "sku_pro",
+ },
+ ],
+ },
+ {
+ operator: "AND",
+ type: RewardStructure.flat,
+ amountInCents: 7500,
+ conditions: [
+ {
+ entity: "sale",
+ attribute: "metadata",
+ metadataField: "plan",
+ operator: "equals_to",
+ value: "pro",
+ },
+ ],
+ },
+ ],
+ },
+ } as const;
+
const authFile = path.join(__dirname, "../.auth/api.json");
// Upserts a dedicated Playwright API user, workspace, membership,