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.

add program descriptions

Steven Tey615b921ad6ad
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/page.tsx
index 0a76201f30..582d4030ed 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/[programSlug]/page.tsx
@@ -94,8 +94,8 @@ export default async function MarketplaceProgramPage(props: {
isDarkImage && "text-content-inverted/90",
)}
>
- {program.name} is a program in the Dub Partner Network. Join the
- network to start partnering with them.
+ {program.description ||
+ `${program.name} is a program in the Dub Partner Network. Join the network to start partnering with them.`}
</div>
</div>
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/featured-program-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/featured-program-card.tsx
index c0b85a4908..be6251da20 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/featured-program-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/featured-program-card.tsx
@@ -44,7 +44,6 @@ export function FeaturedProgramCard({
</div>
<div className="mt-10 flex flex-col">
- {/* Name */}
<span
className={cn(
"text-3xl font-semibold",
@@ -60,8 +59,8 @@ export function FeaturedProgramCard({
darkImage && "text-content-inverted",
)}
>
- {/* Description */}
- {`${program.name} is a program in the Dub Partner Network. Join the network to start partnering with them.`}
+ {program.description ||
+ `${program.name} is a program in the Dub Partner Network. Join the network to start partnering with them.`}
</div>
<div className="mt-5 flex gap-8">
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/program-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/program-card.tsx
index 8fb568153b..1f56235ca7 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/program-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/marketplace/program-card.tsx
@@ -28,14 +28,13 @@ export function ProgramCard({ program }: { program: NetworkProgramProps }) {
</div>
<div className="mt-4 flex flex-col">
- {/* Name */}
<span className="text-content-emphasis text-base font-semibold">
{program.name}
</span>
<div className="text-content-subtle mt-1 line-clamp-2 text-sm">
- {/* Domain */}
- {`${program.name} is a program in the Dub Partner Network. Join the network to start partnering with them.`}
+ {program.description ||
+ `${program.name} is a program in the Dub Partner Network. Join the network to start partnering with them.`}
</div>
<div className="mt-4 flex gap-4">
diff --git a/apps/web/lib/zod/schemas/program-network.ts b/apps/web/lib/zod/schemas/program-network.ts
index dd2bb1ab2a..15463019ce 100644
--- a/apps/web/lib/zod/schemas/program-network.ts
+++ b/apps/web/lib/zod/schemas/program-network.ts
@@ -16,6 +16,7 @@ export const NetworkProgramSchema = ProgramSchema.pick({
rewards: true,
termsUrl: true,
}).extend({
+ description: z.string().nullish(),
discount: DiscountSchema.nullish(),
categories: z.array(z.nativeEnum(Category)),
featuredOnMarketplaceAt: z.date().nullable(),
diff --git a/apps/web/scripts/migrations/backfill-program-marketplace-descriptions.ts b/apps/web/scripts/migrations/backfill-program-marketplace-descriptions.ts
new file mode 100644
index 0000000000..ff0a67da53
--- /dev/null
+++ b/apps/web/scripts/migrations/backfill-program-marketplace-descriptions.ts
@@ -0,0 +1,118 @@
+import { prisma } from "@dub/prisma";
+import FireCrawlApp from "@mendable/firecrawl-js";
+import "dotenv-flow/config";
+
+if (!process.env.FIRECRAWL_API_KEY)
+ throw new Error("FIRECRAWL_API_KEY is not set");
+
+// Initialize FireCrawl
+const firecrawl = new FireCrawlApp({
+ apiKey: process.env.FIRECRAWL_API_KEY,
+});
+
+// Function to scrape website content
+async function scrapeWebsite(url: string) {
+ try {
+ const scrapeResult = await firecrawl.scrapeUrl(url, {
+ formats: ["markdown"],
+ onlyMainContent: true,
+ parsePDF: false,
+ maxAge: 14400000, // 4 hours cache
+ excludeTags: ["img"],
+ });
+
+ if (!scrapeResult.success) {
+ throw new Error(scrapeResult.error || "Failed to scrape");
+ }
+
+ return {
+ content: scrapeResult.markdown || "",
+ title: scrapeResult.metadata?.title || "",
+ description: scrapeResult.metadata?.description || "",
+ };
+ } catch (error) {
+ console.error(`Error scraping ${url}:`, error);
+ return null;
+ }
+}
+
+// Main processing function
+async function main() {
+ console.log("Starting program description backfill...");
+
+ const programs = await prisma.program.findMany({
+ select: {
+ id: true,
+ name: true,
+ url: true,
+ description: true,
+ },
+ where: {
+ addedToMarketplaceAt: {
+ not: null,
+ },
+ url: {
+ not: null,
+ },
+ description: null,
+ },
+ });
+
+ console.log(`Found ${programs.length} programs to backfill descriptions`);
+
+ let successCount = 0;
+ let errorCount = 0;
+
+ // Process each program
+ for (let i = 0; i < programs.length; i++) {
+ const program = programs[i];
+ console.log(`\n[${i + 1}/${programs.length}] Processing: ${program.name}`);
+
+ if (!program.url) {
+ console.log(` Skipping: No URL provided`);
+ errorCount++;
+ continue;
+ }
+
+ // Scrape website
+ console.log(` Scraping: ${program.url}`);
+ const scraped = await scrapeWebsite(program.url);
+
+ if (!scraped) {
+ console.log(` Error: Failed to scrape website`);
+ errorCount++;
+ continue;
+ }
+
+ if (!scraped.description) {
+ console.log(` Error: Failed to generate description`);
+ errorCount++;
+ continue;
+ }
+
+ // Update program description
+ await prisma.program.update({
+ where: { id: program.id },
+ data: { description: scraped.description },
+ });
+
+ console.log(
+ ` ✓ Updated description: ${scraped.description.substring(0, 100)}...`,
+ );
+ successCount++;
+
+ // Add delay to respect rate limits
+ await new Promise((resolve) => setTimeout(resolve, 1000));
+ }
+
+ console.log(`\nCompleted: ${successCount} successful, ${errorCount} errors`);
+}
+
+main()
+ .catch((error) => {
+ console.error("Script failed:", error);
+ process.exit(1);
+ })
+ .finally(async () => {
+ await prisma.$disconnect();
+ });
diff --git a/apps/web/ui/partners/program-network/program-category.tsx b/apps/web/ui/partners/program-network/program-category.tsx
index a82b53c0b4..8709648cb2 100644
--- a/apps/web/ui/partners/program-network/program-category.tsx
+++ b/apps/web/ui/partners/program-network/program-category.tsx
@@ -30,7 +30,9 @@ export const ProgramCategory = ({
)}
>
<Icon className="size-4" />
- <span className="min-w-0 truncate text-sm font-medium">{label}</span>
+ <span className="text-content-subtle min-w-0 truncate text-sm font-medium">
+ {label}
+ </span>
</As>
);
};
diff --git a/apps/web/ui/partners/program-network/program-rewards-display.tsx b/apps/web/ui/partners/program-network/program-rewards-display.tsx
index 393f3d5f44..9196facf61 100644
--- a/apps/web/ui/partners/program-network/program-rewards-display.tsx
+++ b/apps/web/ui/partners/program-network/program-rewards-display.tsx
@@ -99,7 +99,7 @@ export function ProgramRewardsDisplay({
</div>
<span
className={cn(
- "max-w-[160px] truncate text-sm font-medium",
+ "text-content-subtle max-w-[160px] truncate text-sm font-medium",
isDarkImage && "text-content-inverted",
descriptionClassName,
)}
diff --git a/packages/prisma/schema/program.prisma b/packages/prisma/schema/program.prisma
index 5cfa57145f..6eef038a26 100644
--- a/packages/prisma/schema/program.prisma
+++ b/packages/prisma/schema/program.prisma
@@ -33,7 +33,8 @@ model Program {
slug String @unique
domain String? @unique
url String?
- logo String? // TODO: remove after we refactor all program.logo fields to use group.logo instead
+ logo String?
+ description String? @db.Text
primaryRewardEvent EventType @default(sale)
minPayoutAmount Int @default(0) // Default minimum payout amount of $0
payoutMode ProgramPayoutMode @default(internal)