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): accept a blank role on social signup (#105618)

posthog[bot]033b526b98fc
diff --git a/frontend/src/lib/components/SignupRoleSelect.tsx b/frontend/src/lib/components/SignupRoleSelect.tsx
index 718017c1e1fd..fcedd434aa62 100644
--- a/frontend/src/lib/components/SignupRoleSelect.tsx
+++ b/frontend/src/lib/components/SignupRoleSelect.tsx
@@ -28,9 +28,21 @@ const shuffle = <T,>(items: T[]): T[] => {
// Done at module scope so the list is stable for the page rather than reordering on every render.
const roleOptions = [...shuffle(ROLE_OPTIONS), OTHER_ROLE_OPTION]
-export default function SignupRoleSelect({ className }: { className?: string }): JSX.Element {
+export default function SignupRoleSelect({
+ className,
+ showOptional,
+}: {
+ className?: string
+ // Only the organization confirmation form lets people submit without a role
+ showOptional?: boolean
+}): JSX.Element {
return (
- <LemonField name="role_at_organization" label="What is your role?" className={className}>
+ <LemonField
+ name="role_at_organization"
+ label="What is your role?"
+ className={className}
+ showOptional={showOptional}
+ >
{({ value, onChange }) => (
<LemonSelect
fullWidth
diff --git a/frontend/src/scenes/organization/ConfirmOrganization/ConfirmOrganization.test.tsx b/frontend/src/scenes/organization/ConfirmOrganization/ConfirmOrganization.test.tsx
index 07cf7eb70dd2..768ebe6fb021 100644
--- a/frontend/src/scenes/organization/ConfirmOrganization/ConfirmOrganization.test.tsx
+++ b/frontend/src/scenes/organization/ConfirmOrganization/ConfirmOrganization.test.tsx
@@ -45,4 +45,8 @@ describe('ConfirmOrganization', () => {
// as a blank button
expect(screen.getByText('Select your role')).toBeInTheDocument()
})
+
+ it('marks the role as optional, because this form submits without one', () => {
+ expect(screen.getByText('What is your role?').closest('label')).toHaveTextContent('(optional)')
+ })
})
diff --git a/frontend/src/scenes/organization/ConfirmOrganization/ConfirmOrganization.tsx b/frontend/src/scenes/organization/ConfirmOrganization/ConfirmOrganization.tsx
index 8d45b8f3340c..1d5bc1620977 100644
--- a/frontend/src/scenes/organization/ConfirmOrganization/ConfirmOrganization.tsx
+++ b/frontend/src/scenes/organization/ConfirmOrganization/ConfirmOrganization.tsx
@@ -82,7 +82,7 @@ export function ConfirmOrganization(): JSX.Element {
<LemonInput className="ph-ignore-input" placeholder="Hogflix Movies" />
</LemonField>
- <SignupRoleSelect />
+ <SignupRoleSelect showOptional />
<SignupReferralSource disabled={isConfirmOrganizationSubmitting} />
<LemonButton
diff --git a/posthog/api/signup.py b/posthog/api/signup.py
index 58dbbecf3a7a..9d9ab5a4c28a 100644
--- a/posthog/api/signup.py
+++ b/posthog/api/signup.py
@@ -774,7 +774,9 @@ class SocialSignupSerializer(serializers.Serializer):
organization_name: serializers.Field = serializers.CharField(max_length=64)
first_name: serializers.Field = serializers.CharField(max_length=128)
- role_at_organization: serializers.Field = serializers.CharField(max_length=123, required=False, default="")
+ role_at_organization: serializers.Field = serializers.CharField(
+ max_length=123, required=False, allow_blank=True, default=""
+ )
referral_source: serializers.Field = serializers.CharField(
max_length=1000, required=False, allow_blank=True, default=""
)
diff --git a/posthog/api/test/test_signup.py b/posthog/api/test/test_signup.py
index 48bb0c1ee505..8072e643ac26 100644
--- a/posthog/api/test/test_signup.py
+++ b/posthog/api/test/test_signup.py
@@ -3033,6 +3033,23 @@ class TestInviteSignupAPI(APIBaseTest):
1,
)
+ def test_api_social_sign_up_accepts_a_blank_role(self):
+ Organization.objects.all().delete() # Can only create organizations in fresh instances
+ session = self.client.session
+ session.update({"backend": "google-oauth2", "email": "[email protected]"})
+ session.save()
+
+ response = self.client.post(
+ "/api/social_signup",
+ {
+ "organization_name": "Org blank role",
+ "first_name": "Max",
+ "role_at_organization": "",
+ },
+ )
+
+ self.assertEqual(response.status_code, status.HTTP_201_CREATED)
+
@patch("posthog.api.signup.is_email_available", return_value=True)
@patch("posthog.api.signup.email_verification_code_verifier.send_code")
def test_api_social_invite_sign_up_if_email_verification_on(self, email_mock, email_available_mock):