feat: add onboarding info fields to first user setup (#23989)

Add optional demographic and newsletter preference fields to the setup
page: business use (yes/no), industry type, organization size, and two
newsletter toggles (marketing, release/security updates).

The new data flows through telemetry via a FirstUserOnboarding struct in
the snapshot payload, sent once when the first user is created. The
telemetry-server and BigQuery schema changes are required separately to
persist this data.

---------

Co-authored-by: default <davidiii@fraley.us>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeremy Ruppel
2026-04-03 09:52:52 -04:00
committed by GitHub
co-authored by default Claude Sonnet 4.6
parent 53482adc2d
commit da3c46b557
9 changed files with 549 additions and 15 deletions
+19 -1
View File
@@ -281,8 +281,26 @@ func (api *API) postFirstUser(rw http.ResponseWriter, r *http.Request) {
telemetryUser := telemetry.ConvertUser(user)
// Send the initial users email address!
telemetryUser.Email = &user.Email
// Only populate onboarding data when the client actually sent it. A nil
// OnboardingInfo means the request came from an older client, the CLI, or
// the OIDC flow — not from a user who answered "no" to every question.
//
// Note: newsletter consent (NewsletterMarketing) is bundled here alongside
// product-analytics fields. These may have different legal bases under GDPR
// and should be separated in a follow-up once the legal posture is clarified.
var onboarding *telemetry.FirstUserOnboarding
if createUser.OnboardingInfo != nil {
onboarding = &telemetry.FirstUserOnboarding{
IsBusiness: createUser.OnboardingInfo.IsBusiness,
IndustryType: string(createUser.OnboardingInfo.IndustryType),
OrgSize: string(createUser.OnboardingInfo.OrgSize),
NewsletterMarketing: createUser.OnboardingInfo.NewsletterMarketing,
NewsletterReleases: createUser.OnboardingInfo.NewsletterReleases,
}
}
api.Telemetry.Report(&telemetry.Snapshot{
Users: []telemetry.User{telemetryUser},
Users: []telemetry.User{telemetryUser},
FirstUserOnboarding: onboarding,
})
httpapi.Write(ctx, rw, http.StatusCreated, codersdk.CreateFirstUserResponse{