Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(signup): keep a digits-only name a string on the confirm page (#121512)

Phill9a508164938c
diff --git a/frontend/src/scenes/organization/ConfirmOrganization/confirmOrganizationLogic.test.ts b/frontend/src/scenes/organization/ConfirmOrganization/confirmOrganizationLogic.test.ts
index b914e0b60fed..788a100b59c4 100644
--- a/frontend/src/scenes/organization/ConfirmOrganization/confirmOrganizationLogic.test.ts
+++ b/frontend/src/scenes/organization/ConfirmOrganization/confirmOrganizationLogic.test.ts
@@ -19,22 +19,28 @@ describe('confirmOrganizationLogic', () => {
})
describe('query params', () => {
- it('prefills the form from the URL', async () => {
- router.actions.push('/organization/confirm-creation', {
- email: '[email protected]',
- first_name: 'Spike',
- organization_name: 'Spikes Inc',
- })
+ it.each([
+ ['Spike', 'Spikes Inc'],
+ ['3130', '2600'],
+ ])('prefills the form from the URL with the name %p', async (firstName, organizationName) => {
+ // A raw URL, not a params object: kea-router passes object values through untouched, so
+ // only a real query string parses a name of only digits into a number, which used to crash
+ router.actions.push(
+ `/organization/[email protected]&first_name=${encodeURIComponent(firstName)}&organization_name=${encodeURIComponent(organizationName)}`
+ )
await expectLogic(logic)
.toDispatchActions(['setEmail', 'setConfirmOrganizationValues'])
.toMatchValues({
confirmOrganization: expect.objectContaining({
- first_name: 'Spike',
- organization_name: 'Spikes Inc',
+ first_name: firstName,
+ organization_name: organizationName,
}),
})
+
+ expect(logic.values.confirmOrganizationValidationErrors.first_name).toBeUndefined()
+ expect(logic.values.confirmOrganizationValidationErrors.organization_name).toBeUndefined()
})
it('keeps user input when a later location change re-fires the handler', async () => {
diff --git a/frontend/src/scenes/organization/ConfirmOrganization/confirmOrganizationLogic.ts b/frontend/src/scenes/organization/ConfirmOrganization/confirmOrganizationLogic.ts
index d92bb2df5a07..6141866648a2 100644
--- a/frontend/src/scenes/organization/ConfirmOrganization/confirmOrganizationLogic.ts
+++ b/frontend/src/scenes/organization/ConfirmOrganization/confirmOrganizationLogic.ts
@@ -211,7 +211,7 @@ export const confirmOrganizationLogic = kea<confirmOrganizationLogicType>([
})),
urlToAction(({ actions, values }) => ({
- '/organization/confirm-creation': (_, { email, organization_name, first_name }) => {
+ '/organization/confirm-creation': (_, __, ___, { search }) => {
// Prefill from the URL once. Later location changes on this same page (for example
// opening the docs side panel) re-fire this handler with empty params, which would
// otherwise wipe what the user has typed.
@@ -220,15 +220,22 @@ export const confirmOrganizationLogic = kea<confirmOrganizationLogicType>([
}
actions.setHasPrefilled()
+ // Read the raw query string, because kea-router parses a value that looks like a number
+ // into one. A name of only digits must stay text for the validators to trim it.
+ const params = new URLSearchParams(search)
+ const email = params.get('email')
+ const organizationName = params.get('organization_name')
+ const firstName = params.get('first_name')
+
if (email) {
actions.setEmail(email)
}
const prefill: DeepPartial<ConfirmOrganizationFormValues> = {}
- if (organization_name) {
- prefill.organization_name = organization_name
+ if (organizationName) {
+ prefill.organization_name = organizationName
}
- if (first_name) {
- prefill.first_name = first_name
+ if (firstName) {
+ prefill.first_name = firstName
}
if (Object.keys(prefill).length > 0) {
actions.setConfirmOrganizationValues(prefill)