Code Duplication Analysis v1 — Leadmetrics v3
Date: 2026-04-05
Reviewer: Claude Code
Resolved: 2026-04-07
Scope: All modified files across dashboard/dm/manage apps, queue package, and new server-auth modules
Status: 15/16 complete — 1 pending (low priority)
D-15 · Profile Data Normalization
Files:
apps/dashboard/src/app/(dashboard)/settings/profile/actions.tsapps/dm/src/app/(dm)/profile/actions.ts
Both files normalize the same profile shape (trim strings, coerce empty strings to null). The backends differ (BetterAuth DB vs external API) but the input normalization is identical.
Status: ⏭ Skipped — low priority; dashboard (BetterAuth DB) vs DM (REST API) differ too much for a clean shared abstraction right now.
Proposed Fix:
// packages/common/src/profile.ts
export interface ProfileInput {
name: string;
phone: string;
country: string;
about: string;
whatsapp: string;
}
export function normalizeProfile(data: ProfileInput) {
return {
name: data.name.trim(),
phone: data.phone.trim() || null,
country: data.country.trim() || null,
about: data.about.trim() || null,
whatsapp: data.whatsapp.trim() || null,
};
}Where to live: packages/common/src/profile.ts