The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Sync and ban-check Tapfiliate partners whose import fails after enrollment
Rafi9f24a81ec294
diff --git a/apps/web/lib/tapfiliate/import-partners.ts b/apps/web/lib/tapfiliate/import-partners.tsindex c2d3f7c5a9..3c394edb6a 100644--- a/apps/web/lib/tapfiliate/import-partners.ts+++ b/apps/web/lib/tapfiliate/import-partners.ts@@ -89,6 +89,10 @@ export async function importPartners(payload: TapfiliateImportPayload) {break;}+ // Filled as soon as each enrollment is saved, so a partner whose later step+ // throws still reaches the search sync and the ban check.+ const enrolledPartnerIds: string[] = [];+const partnersPromise = await Promise.allSettled(affiliates.map((affiliate) => {let group = defaultGroup;@@ -105,6 +109,7 @@ export async function importPartners(payload: TapfiliateImportPayload) {group,userId,importId,+ enrolledPartnerIds,});}),);@@ -116,13 +121,16 @@ export async function importPartners(payload: TapfiliateImportPayload) {).map((p) => p.value);- if (partnerIds.length > 0) {- // Queue an index update because the imported partners were enrolled.- // Queued per page rather than per partner.- await queuePartnerSearchSync({ partnerIds, programId });+ // Queue an index update because the imported partners were enrolled.+ // Queued per page rather than per partner.+ await queuePartnerSearchSync({ partnerIds: enrolledPartnerIds, programId });- await detectAndRecordNetworkLevelBans({ programId, partnerIds });+ await detectAndRecordNetworkLevelBans({+ programId,+ partnerIds: enrolledPartnerIds,+ });+ if (partnerIds.length > 0) {await tapfiliateImporter.trackImportedPartnerIds({programId,partnerIds,@@ -180,6 +188,7 @@ async function createPartnerAndLinks({group,userId,importId,+ enrolledPartnerIds,}: {workspace: Pick<WorkspaceProps, "id" | "plan">;program: Pick<@@ -199,6 +208,7 @@ async function createPartnerAndLinks({>;userId: string;importId: string;+ enrolledPartnerIds: string[];}) {if (!affiliate.email) {await logImportError({@@ -256,6 +266,8 @@ async function createPartnerAndLinks({},});+ enrolledPartnerIds.push(partner.id);+if (preservedBan) {return partner.id;}