Add referral source question for new signups#266
Conversation
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>
|
Deployment failed with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Deployment failed with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
There was a problem hiding this comment.
💡 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".
| const { email, source } = await req.json() | ||
|
|
||
| if (!email) { | ||
| return NextResponse.json({ error: 'Missing email' }, { status: 400 }) |
There was a problem hiding this comment.
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 👍 / 👎.
| async function updateUserMetadata(referralSource: string | null) { | ||
| await supabase.auth.updateUser({ | ||
| data: { | ||
| referral_source: referralSource, | ||
| referral_asked: true, | ||
| }, | ||
| }) |
There was a problem hiding this comment.
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 👍 / 👎.
| await fetch(webhookUrl, { | ||
| method: 'POST', |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
user_metadata(referral_source+referral_askedflag)#user-signupsvia a new API routeFiles changed
src/features/dashboard/referral-source-dialog.tsx— new dialog component using existingDialog,Input,Buttonprimitivessrc/features/dashboard/context.tsx— checksuser_metadata.referral_askedand renders dialogsrc/app/api/referral-source/route.ts— server-side API route to forward answer to SlackSetup needed
SLACK_USER_SIGNUP_WEBHOOK_URLenv variable must be available to the Next.js app (not just Supabase edge functions)Test plan
referral_asked: trueis set, no Slack message🤖 Generated with Claude Code