Remove referrals feature, keep freebuff creator attribution#519
Remove referrals feature, keep freebuff creator attribution#519
Conversation
Strip the /refer-friends CLI command, web referral pages, affiliate
sponsee routes, and one-time referral redemption API. Simplify the
profile referrals section to a read-only list of who you referred.
Keep DB schema, legacy monthly bonus grants, and the GrantType enum
so historical referrals continue to pay out.
Restore creator attribution for freebuff only: /get-started already
accepts ?referrer=<name> and persists it; /onboard fires a
FREEBUFF_REFERRER_ATTRIBUTED PostHog event with \$set_once on first
visit post-login. /onboard now redirects logged-out visitors to
/get-started (or /login when an auth_code is present) and greets
logged-in users with an optional "{Name} invited you to try Freebuff!"
header. Fixes a pre-existing bug where auth_code was dropped when
/onboard redirected unauthenticated users.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Greptile SummaryThis PR removes the Codebuff referral program (CLI Key changes:
Confidence Score: 4/5Safe to merge; the referral cleanup is complete and the creator attribution flow is logically sound, with one P2 concern around ReferrerTracker firing on error pages. Large deletion PR (3800+ lines removed) with focused new additions for freebuff creator attribution. The deletion is clean with no dangling references. The new ReferrerTracker uses $set_once which makes premature firing on error pages a non-issue for PostHog data quality. The redirect logic fix for auth_code preservation is correct. One P2 issue (ReferrerTracker on error branches) and one style issue (duplicated normalizeReferrer) remain. freebuff/web/src/app/onboard/page.tsx — ReferrerTracker placement in all StatusCard branches; freebuff/web/src/app/get-started/get-started-client.tsx — paired normalizeReferrer duplication Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User Browser
participant GS as GetStarted Page
participant LS as localStorage
participant Login as Login Page
participant Onboard as Onboard Page
participant RT as ReferrerTracker
participant PH as PostHog
U->>GS: Visit /get-started with referrer param
GS->>LS: setItem freebuff_referrer
Note over GS: posthog FREEBUFF_GET_STARTED_VIEWED
U->>U: Install CLI, run freebuff
U->>Onboard: CLI opens onboard with auth code (not logged in)
Onboard-->>Login: redirect to login preserving auth code and referrer
U->>Login: Sign in via OAuth
Login-->>Onboard: OAuth callback back to onboard
Onboard->>Onboard: Validate auth code, create CLI session
Onboard->>RT: Render ReferrerTracker component
RT->>LS: getItem freebuff_referrer
RT->>PH: capture FREEBUFF_REFERRER_ATTRIBUTED with set_once
RT->>LS: removeItem freebuff_referrer
Onboard-->>U: Show Login successful
|
| if (!raw) return null | ||
| const trimmed = raw.trim().slice(0, 50) | ||
| return trimmed || null | ||
| } | ||
|
|
||
| interface PageProps { |
There was a problem hiding this comment.
normalizeReferrer duplicated across two files
The normalizeReferrer function is identical in both freebuff/web/src/app/onboard/page.tsx and freebuff/web/src/app/get-started/page.tsx. These should be extracted to a shared utility (e.g. freebuff/web/src/lib/referrer.ts) to avoid drift if the logic ever changes.
// freebuff/web/src/lib/referrer.ts
export function normalizeReferrer(raw: string | undefined): string | null {
if (!raw) return null
const trimmed = raw.trim().slice(0, 50)
return trimmed || null
}Brings back the codebuff referral landing routes (/[sponsee], /referrals/[code], /api/referrals/[code]) without free-credit mentions, and ensures freebuff persists ?referrer= through OAuth by saving to localStorage in all sign-in entrypoints and mounting ReferrerTracker in the root layout. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Saves the referrer display name to localStorage on /referrals/[code] and swaps
the /onboard welcome/success title to "{Name} invited you to Codebuff!" when
it's present, mirroring the freebuff attribution pattern.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds a ReferrerTracker to the codebuff root layout so any signed-in user who passed through /referrals/<code> gets attributed via PostHog (with \$set_once) on whatever page they eventually land on. Split the localStorage key so the tracker and the /onboard welcome card don't race to clear each other. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Consolidate to a single `codebuff_referrer` localStorage key. WelcomeCard now both fires the PostHog attribution event (post-auth) and renders the personalized title, removing the tracker/welcome-card race. - Delete ReferrerTracker and its mount in the root layout. - Replace HTTP self-fetch in /referrals/[code] with a direct DB query and delete the now-unused /api/referrals/[code] route. - Inline the trivial renderSuccessPage/renderErrorCard wrappers in the onboard page. - Hide the Referrals profile tab when the user has no referral history. - Strip leftover console.log debug statements from SignInButton. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Removes the referrals feature while preserving historical data, restores simplified creator/referrer landing pages, and wires freebuff creator attribution through OAuth.
Removed:
/refer-friendscommand, referral banner, and related UI/testsKept / Simplified:
/[sponsee]→/referrals/[code]landing pages restored but credit-free — just shows "{Name} invited you to Codebuff!" with install instructions/onboardpreserves?referrer=and shows "{Name} invited you to try Freebuff!" for logged-in users?referrer=now persists through OAuth vialocalStorage.freebuff_referrer, set inSignInButtonandLoginCardbefore signIn;ReferrerTrackermounted in the root layout fires theFREEBUFF_REFERRER_ATTRIBUTEDPostHog event on any post-OAuth landing pageTest plan
/get-started?referrer=Bob, sign in, confirm PostHog receivesfreebuff.referrer_attributedwithreferrer=Boband$set_once.freebuff_referrer=Bob/login?referrer=Bobdirectly (no get-started), sign in, confirm attribution still fires/somehandle, confirm redirect to/referrals/<code>?referrer=somehandleand landing page shows referrer name + install CTA🤖 Generated with Claude Code