The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add delay queue option
Pedro Ladeira65cff39d7fa6
diff --git a/apps/web/lib/firstpromoter/import-customers.ts b/apps/web/lib/firstpromoter/import-customers.tsindex 71a1e04087..2c3cac1978 100644--- a/apps/web/lib/firstpromoter/import-customers.ts+++ b/apps/web/lib/firstpromoter/import-customers.ts@@ -166,11 +166,14 @@ export async function importCustomers(payload: FirstPromoterImportPayload) {processedBatches++;}- await firstPromoterImporter.queue({- ...payload,- action: hasMore ? "import-customers" : "import-commissions",- page: hasMore ? currentPage : undefined,- });+ await firstPromoterImporter.queue(+ {+ ...payload,+ action: hasMore ? "import-customers" : "import-commissions",+ page: hasMore ? currentPage : undefined,+ },+ !hasMore ? { delay: 5 * 60 } : undefined,+ );}async function createCustomer({diff --git a/apps/web/lib/firstpromoter/importer.ts b/apps/web/lib/firstpromoter/importer.tsindex aa722fa63a..b6920bc8dd 100644--- a/apps/web/lib/firstpromoter/importer.ts+++ b/apps/web/lib/firstpromoter/importer.ts@@ -31,11 +31,15 @@ class FirstPromoterImporter {return await redis.del(`${CACHE_KEY_PREFIX}:${workspaceId}`);}- async queue(body: FirstPromoterImportPayload) {+ async queue(+ body: FirstPromoterImportPayload,+ options?: { delay?: number },+ ) {return await qstash.publishJSON({url: `${APP_DOMAIN_WITH_NGROK}/api/cron/import/firstpromoter`,body,contentBasedDeduplication: true,+ ...(options?.delay != null && { delay: options.delay }),});}}diff --git a/apps/web/lib/partnerstack/import-customers.ts b/apps/web/lib/partnerstack/import-customers.tsindex 8656aca594..bd9dd076ce 100644--- a/apps/web/lib/partnerstack/import-customers.ts+++ b/apps/web/lib/partnerstack/import-customers.ts@@ -175,11 +175,14 @@ export async function importCustomers(payload: PartnerStackImportPayload) {currentStartingAfter = customers[customers.length - 1].key;}- await partnerStackImporter.queue({- ...payload,- startingAfter: hasMore ? currentStartingAfter : undefined,- action: hasMore ? "import-customers" : "import-commissions",- });+ await partnerStackImporter.queue(+ {+ ...payload,+ startingAfter: hasMore ? currentStartingAfter : undefined,+ action: hasMore ? "import-customers" : "import-commissions",+ },+ !hasMore ? { delay: 5 * 60 } : undefined,+ );if (!hasMore) {await redis.del(`${PARTNER_IDS_KEY_PREFIX}:${programId}`);diff --git a/apps/web/lib/partnerstack/importer.ts b/apps/web/lib/partnerstack/importer.tsindex 02aa6d2eab..f05afb12a2 100644--- a/apps/web/lib/partnerstack/importer.ts+++ b/apps/web/lib/partnerstack/importer.ts@@ -36,11 +36,15 @@ class PartnerStackImporter {return await redis.del(`${CACHE_KEY_PREFIX}:${workspaceId}`);}- async queue(body: z.infer<typeof partnerStackImportPayloadSchema>) {+ async queue(+ body: z.infer<typeof partnerStackImportPayloadSchema>,+ options?: { delay?: number },+ ) {return await qstash.publishJSON({url: `${APP_DOMAIN_WITH_NGROK}/api/cron/import/partnerstack`,body,contentBasedDeduplication: true,+ ...(options?.delay != null && { delay: options.delay }),});}}diff --git a/apps/web/lib/rewardful/import-customers.ts b/apps/web/lib/rewardful/import-customers.tsindex 6e8e4b0f6e..e11fb66081 100644--- a/apps/web/lib/rewardful/import-customers.ts+++ b/apps/web/lib/rewardful/import-customers.ts@@ -82,11 +82,14 @@ export async function importCustomers(payload: RewardfulImportPayload) {processedBatches++;}- await rewardfulImporter.queue({- ...payload,- page: hasMore ? currentPage : undefined,- action: hasMore ? "import-customers" : "import-commissions",- });+ await rewardfulImporter.queue(+ {+ ...payload,+ page: hasMore ? currentPage : undefined,+ action: hasMore ? "import-customers" : "import-commissions",+ },+ !hasMore ? { delay: 5 * 60 } : undefined,+ );}// Create individual referral entriesdiff --git a/apps/web/lib/rewardful/importer.ts b/apps/web/lib/rewardful/importer.tsindex 34371de65d..0e776fe6fa 100644--- a/apps/web/lib/rewardful/importer.ts+++ b/apps/web/lib/rewardful/importer.ts@@ -34,11 +34,15 @@ class RewardfulImporter {return await redis.del(`${CACHE_KEY_PREFIX}:${workspaceId}`);}- async queue(body: RewardfulImportPayload) {+ async queue(+ body: RewardfulImportPayload,+ options?: { delay?: number },+ ) {return await qstash.publishJSON({url: `${APP_DOMAIN_WITH_NGROK}/api/cron/import/rewardful`,body,contentBasedDeduplication: true,+ ...(options?.delay != null && { delay: options.delay }),});}}diff --git a/apps/web/lib/tolt/import-customers.ts b/apps/web/lib/tolt/import-customers.tsindex a5829e50ba..ccafef0d38 100644--- a/apps/web/lib/tolt/import-customers.ts+++ b/apps/web/lib/tolt/import-customers.ts@@ -141,11 +141,14 @@ export async function importCustomers(payload: ToltImportPayload) {startingAfter = customers[customers.length - 1].id;}- await toltImporter.queue({- ...payload,- startingAfter: hasMore ? startingAfter : undefined,- action: hasMore ? "import-customers" : "import-commissions",- });+ await toltImporter.queue(+ {+ ...payload,+ startingAfter: hasMore ? startingAfter : undefined,+ action: hasMore ? "import-customers" : "import-commissions",+ },+ !hasMore ? { delay: 5 * 60 } : undefined,+ );}// Create individual customer entriesdiff --git a/apps/web/lib/tolt/importer.ts b/apps/web/lib/tolt/importer.tsindex bc1bab18b3..469390abd8 100644--- a/apps/web/lib/tolt/importer.ts+++ b/apps/web/lib/tolt/importer.ts@@ -33,11 +33,15 @@ class ToltImporter {return await redis.del(`${CACHE_KEY_PREFIX}:${workspaceId}`);}- async queue(body: z.infer<typeof toltImportPayloadSchema>) {+ async queue(+ body: z.infer<typeof toltImportPayloadSchema>,+ options?: { delay?: number },+ ) {return await qstash.publishJSON({url: `${APP_DOMAIN_WITH_NGROK}/api/cron/import/tolt`,body,contentBasedDeduplication: true,+ ...(options?.delay != null && { delay: options.delay }),});}