diff --git a/bun.lock b/bun.lock index 55232941..d2f16721 100644 --- a/bun.lock +++ b/bun.lock @@ -9,6 +9,7 @@ "@profullstack/affiliates": "^0.3.0", "@profullstack/ai-providers": "0.1.2", "@profullstack/autoblog": "0.5.0", + "@profullstack/cross-promo": "^0.1.0", "@profullstack/footer": "latest", "@profullstack/profile": "0.1.8", "@profullstack/redeem-credits": "^0.2.0", @@ -336,6 +337,8 @@ "@profullstack/autoblog": ["@profullstack/autoblog@0.5.0", "", { "dependencies": { "@profullstack/ai-providers": "0.1.0" } }, "sha512-KewpX0rM55o+7TMYeU35gqZceQFNF6zmo8zDoZRP5zoPU+XqTRcBlv6bZvl9oQHUXKXAsePJVNZKtDNhTrNEfw=="], + "@profullstack/cross-promo": ["@profullstack/cross-promo@0.1.0", "", { "bin": { "cross-promo": "bin/cross-promo.js" } }, "sha512-LQMxZSvApH1T+8WmMu/Nj1LqojXeTw6wAtpLfhuKFwx9eR36hQG/7vVIDkKpmU5zKw7UwARe20MOfFCak2+ejA=="], + "@profullstack/emailer": ["@profullstack/emailer@1.0.3", "", {}, "sha512-VyAtCcfnSI6LOwJvWogCr3ZNmEsaZw+iuWrqnosLsdcKsbRyCrCmXigMNZJZEjlgYlR+lK//PwNPG+xtCFvWAw=="], "@profullstack/footer": ["@profullstack/footer@0.4.0", "", { "peerDependencies": { "react": ">=18" }, "optionalPeers": ["react"], "bin": { "profullstack-footer": "bin/profullstack-footer.js" } }, "sha512-EJZnMUQmWDi9Gzx6BAjogloeaPFFSSCHtHJuC9dsXiOz8M87hfn6Z+Zx9AMYWk8s6xemPrPlkXKGB3PZugkcEA=="], diff --git a/package.json b/package.json index 5592dabc..092b7bec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ugig.net", - "version": "1.5.2", + "version": "1.6.0", "private": true, "description": "A marketplace for AI-assisted engineers and skilled workers.", "scripts": { @@ -42,6 +42,7 @@ "@profullstack/affiliates": "^0.3.0", "@profullstack/ai-providers": "0.1.2", "@profullstack/autoblog": "0.5.0", + "@profullstack/cross-promo": "^0.1.0", "@profullstack/footer": "latest", "@profullstack/profile": "0.1.8", "@profullstack/redeem-credits": "^0.2.0", diff --git a/src/app/api/auth/confirmed/route.ts b/src/app/api/auth/confirmed/route.ts index 2584607a..cb00bc39 100644 --- a/src/app/api/auth/confirmed/route.ts +++ b/src/app/api/auth/confirmed/route.ts @@ -145,7 +145,7 @@ export async function POST(request: NextRequest) { } // Send the welcome/onboarding email - const welcome = welcomeEmail({ name, accountType }); + const welcome = await welcomeEmail({ name, accountType, email }); const result = await sendEmail({ to: email, subject: welcome.subject, diff --git a/src/lib/email.test.ts b/src/lib/email.test.ts index 4693c243..6d057a74 100644 --- a/src/lib/email.test.ts +++ b/src/lib/email.test.ts @@ -5,6 +5,7 @@ import { referralInviteEmail, signupConfirmationEmail, videoCallInviteEmail, + welcomeEmail, } from "./email"; describe("videoCallInviteEmail", () => { @@ -206,3 +207,25 @@ describe("gigExpiredEmail", () => { expect(r.html).toContain("<script>"); }); }); + +describe("welcomeEmail cross-promo", () => { + beforeEach(() => { + // The bundled catalog: no network in tests. + vi.stubEnv("CROSS_PROMO", "bundled"); + }); + + it("appends the network block after the message, never promoting ugig.net", async () => { + const { html, text } = await welcomeEmail({ name: "Ada", email: "ada@example.com" }); + expect(html).toContain("profullstack.com"); + expect(html).toContain("utm_campaign=cross-promo"); + expect(html).toContain("utm_source=ugig.net"); + // The block sits after the tip and before the footer. + expect(html.indexOf("utm_campaign=cross-promo")).toBeGreaterThan(html.indexOf("5x more views")); + expect(html.indexOf("utm_campaign=cross-promo")).toBeLessThan(html.indexOf("AI-Powered Gig Marketplace

")); + expect(text).toContain("utm_campaign=cross-promo"); + // No promoted link points back at the sender. + const links = [...html.matchAll(/href="(https?:\/\/[^"]*utm_campaign=cross-promo[^"]*)"/g)].map((m) => m[1]); + expect(links.length).toBeGreaterThan(0); + for (const l of links) expect(new URL(l.replace(/&/g, "&")).hostname).not.toMatch(/(^|\.)ugig\.net$/); + }); +}); diff --git a/src/lib/email.ts b/src/lib/email.ts index 73f2c972..f1ab7e75 100644 --- a/src/lib/email.ts +++ b/src/lib/email.ts @@ -1,4 +1,5 @@ import { createEmailer, escapeHtml, type Emailer } from "@profullstack/stack/email"; +import { promoBlock } from "@profullstack/cross-promo"; import type { NotificationSettingKey } from "@/lib/notification-settings"; import { UNSUBSCRIBABLE_SETTINGS, unsubscribeUrl } from "@/lib/email-unsubscribe"; @@ -1163,9 +1164,27 @@ ugig.net - AI-Powered Gig Marketplace }; } -export function welcomeEmail(params: { name: string; accountType?: string }) { - const { name, accountType } = params; +/** ugig's palette for the shared "more from the network" block. */ +const PROMO_THEME = { + accent: "#667eea", + text: "#374151", + muted: "#6b7280", + bg: "#ffffff", + border: "#e5e7eb", + heading: "#1f2937", +}; + +export async function welcomeEmail(params: { name: string; accountType?: string; email?: string }) { + const { name, accountType, email } = params; const baseUrl = getBaseUrl(); + // Sister properties for freelancers, never ugig itself. Never throws; falls + // back to the bundled catalog if the CDN is slow or down. + const promo = await promoBlock({ + site: "ugig.net", + audience: "freelancers", + seed: email, + theme: PROMO_THEME, + }); const displayName = name || "there"; const isAgent = accountType === "agent"; @@ -1262,6 +1281,8 @@ export function welcomeEmail(params: { name: string; accountType?: string }) { 💡 Tip: Profiles with an avatar, banner, and at least 3 skills get 5x more views from clients.

+ + ${promo.html}
@@ -1313,7 +1334,7 @@ ${cliText} Tip: Profiles with an avatar, banner, and at least 3 skills get 5x more views. Complete your profile: ${baseUrl}/profile/edit - +${promo.text ? `\n${promo.text}\n` : ""} --- ugig.net - AI-Powered Gig Marketplace `;