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.

some changes

Kiran K464745b9cf06
diff --git a/apps/web/lib/tolt/import-affiliates.ts b/apps/web/lib/tolt/import-affiliates.ts
index 1c283422d3..e088f3b64c 100644
--- a/apps/web/lib/tolt/import-affiliates.ts
+++ b/apps/web/lib/tolt/import-affiliates.ts
@@ -18,7 +18,11 @@ export async function importAffiliates({
id: programId,
},
include: {
- rewards: true,
+ rewards: {
+ where: {
+ default: true,
+ },
+ },
},
});
@@ -34,7 +38,7 @@ export async function importAffiliates({
const saleReward = program.rewards.find((r) => r.event === "sale");
const leadReward = program.rewards.find((r) => r.event === "lead");
const clickReward = program.rewards.find((r) => r.event === "click");
- const reward = saleReward || leadReward || clickReward;
+ const defaultReward = saleReward || leadReward || clickReward;
while (hasMore && processedBatches < MAX_BATCHES) {
const affiliates = await toltApi.listAffiliates({
@@ -57,7 +61,7 @@ export async function importAffiliates({
createPartner({
program,
affiliate,
- reward,
+ reward: defaultReward,
}),
),
);
diff --git a/apps/web/lib/tolt/import-links.ts b/apps/web/lib/tolt/import-links.ts
index 1aac8cf367..a6dc2b67fd 100644
--- a/apps/web/lib/tolt/import-links.ts
+++ b/apps/web/lib/tolt/import-links.ts
@@ -51,29 +51,26 @@ export async function importLinks({
const partnerMap = new Map(partners.map(({ email, id }) => [email, id]));
- const activeLinks = links.filter((link) =>
+ const partnerLinks = links.filter((link) =>
partnerMap.has(link.partner.email),
);
- if (activeLinks.length === 0) {
- console.log("No active links to import.");
- break;
+ if (partnerLinks.length > 0) {
+ await bulkCreateLinks({
+ links: partnerLinks.map((link) => ({
+ userId,
+ programId,
+ projectId: program.workspaceId,
+ partnerId: partnerMap.get(link.partner.email),
+ folderId: program.defaultFolderId,
+ domain: program.domain!,
+ key: link.value || nanoid(),
+ url: program.url!,
+ trackConversion: true,
+ })),
+ });
}
- await bulkCreateLinks({
- links: activeLinks.map((link) => ({
- userId,
- programId,
- projectId: program.workspaceId,
- partnerId: partnerMap.get(link.partner.email),
- folderId: program.defaultFolderId,
- domain: program.domain!,
- key: link.value || nanoid(),
- url: program.url!,
- trackConversion: true,
- })),
- });
-
await new Promise((resolve) => setTimeout(resolve, 2000));
processedBatches++;
diff --git a/apps/web/lib/tolt/import-referrals.ts b/apps/web/lib/tolt/import-referrals.ts
index a12996eb45..06965df2c1 100644
--- a/apps/web/lib/tolt/import-referrals.ts
+++ b/apps/web/lib/tolt/import-referrals.ts
@@ -94,11 +94,11 @@ export async function importReferrals({
}
await Promise.all(
- customers.map((customer) =>
+ customers.map(({ partner, ...customer }) =>
createReferral({
workspace,
- links: partnerEmailToLinks.get(customer.partner.email) ?? [],
customer,
+ links: partnerEmailToLinks.get(partner.email) ?? [],
}),
),
);
@@ -122,7 +122,7 @@ async function createReferral({
workspace,
links,
}: {
- customer: ToltCustomer;
+ customer: Omit<ToltCustomer, "partner">;
workspace: Pick<Project, "id" | "stripeConnectId">;
links: Pick<Link, "id" | "key" | "domain" | "url">[];
}) {
@@ -141,7 +141,9 @@ async function createReferral({
});
if (customerFound) {
- console.log(`A customer already exists with email ${customer.email}`);
+ console.log(
+ `A customer already exists with customer_id ${customer.customer_id}`,
+ );
return;
}
diff --git a/apps/web/ui/modals/import-tolt-modal.tsx b/apps/web/ui/modals/import-tolt-modal.tsx
index 4108411508..47ecba3eff 100644
--- a/apps/web/ui/modals/import-tolt-modal.tsx
+++ b/apps/web/ui/modals/import-tolt-modal.tsx
@@ -178,7 +178,7 @@ function TokenForm({
htmlFor="programId"
className="block text-sm font-medium text-neutral-700"
>
- Program ID
+ Tolt Program ID
</label>
<input
type="text"