Skip to content

Add referral source question for new signups#266

Open
tizkovatereza wants to merge 2 commits intomainfrom
feat/referral-source-question
Open

Add referral source question for new signups#266
tizkovatereza wants to merge 2 commits intomainfrom
feat/referral-source-question

Conversation

@tizkovatereza
Copy link
Member

Summary

  • Shows a "How did you first hear about E2B?" dialog when a new user first lands on the dashboard
  • Users can type a freeform answer and submit, or skip
  • Response is saved to Supabase user_metadata (referral_source + referral_asked flag)
  • Submitting also posts the answer to Slack #user-signups via a new API route
  • Dialog never appears again once dismissed (submit or skip)

Files changed

  • src/features/dashboard/referral-source-dialog.tsx — new dialog component using existing Dialog, Input, Button primitives
  • src/features/dashboard/context.tsx — checks user_metadata.referral_asked and renders dialog
  • src/app/api/referral-source/route.ts — server-side API route to forward answer to Slack

Setup needed

  • SLACK_USER_SIGNUP_WEBHOOK_URL env variable must be available to the Next.js app (not just Supabase edge functions)

Test plan

  • Sign up with a new account → dialog should appear on dashboard
  • Type an answer and click Submit → check Supabase user_metadata and Slack
  • Click Skip → dialog closes, referral_asked: true is set, no Slack message
  • Refresh dashboard → dialog should NOT reappear
  • Existing users → dialog should NOT appear

🤖 Generated with Claude Code

Shows a dialog asking "How did you first hear about E2B?" when a new
user first lands on the dashboard. Users can type an answer and submit,
or skip. Response is saved to Supabase user_metadata and posted to
Slack #user-signups. The dialog never appears again once dismissed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 4, 2026

Deployment failed with the following error:

You don't have permission to create a Preview Deployment for this Vercel project: web.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 4, 2026

Deployment failed with the following error:

You don't have permission to create a Preview Deployment for this Vercel project: web-juliett.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b46c5f8ef0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +12 to +15
const { email, source } = await req.json()

if (!email) {
return NextResponse.json({ error: 'Missing email' }, { status: 400 })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Authenticate callers before forwarding to Slack

This route forwards any posted email/source payload to the Slack webhook without verifying the requester, so anyone who can reach /api/referral-source can spoof signup events or spam #user-signups. Add an auth check (for example via server Supabase session) and derive the user identity server-side instead of trusting client-provided email.

Useful? React with 👍 / 👎.

Comment on lines +30 to +36
async function updateUserMetadata(referralSource: string | null) {
await supabase.auth.updateUser({
data: {
referral_source: referralSource,
referral_asked: true,
},
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check updateUser errors before closing the dialog

supabase.auth.updateUser returns an { error } field on failure, but this helper ignores that result and the dialog closes as if the metadata write succeeded. If the update is rejected (e.g., expired auth state or backend error), referral_asked is never persisted and users can be prompted again after refresh while believing they already submitted/skipped.

Useful? React with 👍 / 👎.

Comment on lines +21 to +22
await fetch(webhookUrl, {
method: 'POST',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify Slack webhook response before returning success

The webhook call result is ignored, and this handler returns { ok: true } even when Slack responds with HTTP errors (fetch only throws on network failures). That silently drops referral telemetry while signaling success to the client, making delivery failures hard to detect and debug.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant