Skip to content

Commit 8aff1eb

Browse files
jahoomaclaude
andcommitted
Personalize codebuff /onboard welcome with referrer name
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>
1 parent 07fe1aa commit 8aff1eb

4 files changed

Lines changed: 72 additions & 15 deletions

File tree

web/src/app/onboard/page.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { isAuthCodeExpired, parseAuthCode, validateAuthCode } from './_helpers'
1515
import { authOptions } from '../api/auth/[...nextauth]/auth-options'
1616

1717
import CardWithBeams from '@/components/card-with-beams'
18+
import { WelcomeCard } from '@/components/onboard/welcome-card'
1819
import { logger } from '@/util/logger'
1920

2021

@@ -33,19 +34,17 @@ function renderErrorCard(title: string, description: string, message: string) {
3334
}
3435

3536
function renderSuccessPage(
36-
title: string,
37+
fallbackTitle: string,
3738
description: string,
3839
message: string,
3940
) {
40-
return CardWithBeams({
41-
title,
42-
description,
43-
content: (
44-
<div className="flex flex-col space-y-4 text-center">
45-
<p className="text-lg">{message}</p>
46-
</div>
47-
),
48-
})
41+
return (
42+
<WelcomeCard
43+
fallbackTitle={fallbackTitle}
44+
description={description}
45+
message={message}
46+
/>
47+
)
4948
}
5049

5150
const Onboard = async ({ searchParams }: PageProps) => {

web/src/app/referrals/[code]/page.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { ReferralCodeResponse } from '../../api/referrals/[code]/route'
66
import type { Metadata } from 'next'
77

88
import CardWithBeams from '@/components/card-with-beams'
9+
import { PersistReferrer } from '@/components/referral/persist-referrer'
910
import { Button } from '@/components/ui/button'
1011
import { InstallInstructions } from '@/components/ui/install-instructions'
1112

@@ -78,10 +79,13 @@ export default async function ReferralPage({
7879
const displayName = referrerName || referrerParam || 'Someone'
7980

8081
return (
81-
<CardWithBeams
82-
title={`${displayName} invited you to Codebuff!`}
83-
description="Install Codebuff and start building with AI in your terminal."
84-
content={<InstallInstructions />}
85-
/>
82+
<>
83+
<PersistReferrer referrer={displayName} />
84+
<CardWithBeams
85+
title={`${displayName} invited you to Codebuff!`}
86+
description="Install Codebuff and start building with AI in your terminal."
87+
content={<InstallInstructions />}
88+
/>
89+
</>
8690
)
8791
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use client'
2+
3+
import { useEffect, useState } from 'react'
4+
5+
import CardWithBeams from '@/components/card-with-beams'
6+
7+
export function WelcomeCard({
8+
fallbackTitle,
9+
description,
10+
message,
11+
}: {
12+
fallbackTitle: string
13+
description: string
14+
message: string
15+
}) {
16+
const [referrer, setReferrer] = useState<string | null>(null)
17+
18+
useEffect(() => {
19+
const stored = localStorage.getItem('codebuff_referrer')
20+
if (stored) {
21+
setReferrer(stored)
22+
localStorage.removeItem('codebuff_referrer')
23+
}
24+
}, [])
25+
26+
const title = referrer
27+
? `${referrer} invited you to Codebuff!`
28+
: fallbackTitle
29+
30+
return (
31+
<CardWithBeams
32+
title={title}
33+
description={description}
34+
content={
35+
<div className="flex flex-col space-y-4 text-center">
36+
<p className="text-lg">{message}</p>
37+
</div>
38+
}
39+
/>
40+
)
41+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use client'
2+
3+
import { useEffect } from 'react'
4+
5+
export function PersistReferrer({ referrer }: { referrer: string }) {
6+
useEffect(() => {
7+
if (referrer) {
8+
localStorage.setItem('codebuff_referrer', referrer)
9+
}
10+
}, [referrer])
11+
12+
return null
13+
}

0 commit comments

Comments
 (0)