Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/auth/confirmed/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions src/lib/email.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
referralInviteEmail,
signupConfirmationEmail,
videoCallInviteEmail,
welcomeEmail,
} from "./email";

describe("videoCallInviteEmail", () => {
Expand Down Expand Up @@ -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</p>"));
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(/&amp;/g, "&")).hostname).not.toMatch(/(^|\.)ugig\.net$/);
});
});
27 changes: 24 additions & 3 deletions src/lib/email.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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";

Expand Down Expand Up @@ -1262,6 +1281,8 @@ export function welcomeEmail(params: { name: string; accountType?: string }) {
<strong>💡 Tip:</strong> Profiles with an avatar, banner, and at least 3 skills get <strong>5x more views</strong> from clients.
</p>
</div>

${promo.html}
</div>

<div style="text-align: center; padding: 20px; color: #9ca3af; font-size: 12px;">
Expand Down Expand Up @@ -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
`;
Expand Down
Loading