Skip to content

Commit d00ee76

Browse files
committed
fix(onboarding): Commit the auto-detected platform to the host
The platform-features core only derived the displayed platform from detection, committing to the host via onPlatformChange on explicit picks. The onboarding step papers over this with a fallback commit in its Continue handler, but the single-view project-creation flow has no Continue boundary: accepting the detected platform left the wizard's selectedPlatform unset, so the project name never defaulted and the Create CTA stayed disabled with no way to proceed short of re-picking the platform manually. Commit the detected platform in the same once-per-repo effect that fires the platform-selected analytics. The onboarding step's fallback commit becomes a no-op and stays as belt and braces.
1 parent 8f214e1 commit d00ee76

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

static/app/views/onboarding/components/scmPlatformFeaturesCore.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,12 @@ export function ScmPlatformFeaturesCore({
161161

162162
const currentPlatformName = getPlatformName(currentPlatformKey);
163163

164-
// Fire scm_platform_selected once per repo when detection auto-resolves a
165-
// platform and the user hasn't explicitly chosen one. Otherwise a user who
166-
// accepts the recommendation and clicks Continue never emits the event,
167-
// leaving the funnel without a platform-selected step. The ref is re-armed
168-
// on repo change above so a switch to a new repo fires the event again.
164+
// Adopt the first detected platform once per repo when the user hasn't
165+
// explicitly chosen one: commit it to the host so flows without a Continue
166+
// boundary (single-view project creation) get a platform without an explicit
167+
// pick, and fire scm_platform_selected so a user who just accepts the
168+
// recommendation still emits a platform-selected funnel step. The ref is
169+
// re-armed on repo change above so a switch to a new repo adopts again.
169170
useEffect(() => {
170171
if (
171172
autoDetectionTrackedRef.current ||
@@ -175,12 +176,19 @@ export function ScmPlatformFeaturesCore({
175176
return;
176177
}
177178
autoDetectionTrackedRef.current = true;
179+
setPlatform(detectedPlatformKey);
178180
trackAnalytics(PLATFORM_SELECTED_EVENT[analyticsFlow], {
179181
organization,
180182
platform: detectedPlatformKey,
181183
source: 'detected',
182184
});
183-
}, [detectedPlatformKey, selectedPlatform?.key, organization, analyticsFlow]);
185+
}, [
186+
detectedPlatformKey,
187+
selectedPlatform?.key,
188+
organization,
189+
analyticsFlow,
190+
setPlatform,
191+
]);
184192

185193
// Wizard-driven platforms render an informational variant since the wizard CLI
186194
// owns product configuration and toggles aren't actionable.

static/app/views/onboarding/scmPlatformFeatures.spec.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('ScmPlatformFeatures', () => {
120120
expect(within(radioGroup).getByText('Django')).toBeInTheDocument();
121121
});
122122

123-
it('auto-selects first detected platform', async () => {
123+
it('auto-selects and commits first detected platform', async () => {
124124
MockApiClient.addMockResponse({
125125
url: `/organizations/${organization.slug}/repos/42/platforms/`,
126126
body: {
@@ -135,14 +135,15 @@ describe('ScmPlatformFeatures', () => {
135135
},
136136
});
137137

138-
render(
139-
<ScmPlatformFeatures {...defaultProps({selectedRepository: mockRepository})} />,
140-
{organization}
141-
);
138+
const props = defaultProps({selectedRepository: mockRepository});
139+
render(<ScmPlatformFeatures {...props} />, {organization});
142140

143141
expect(
144142
await screen.findByRole('heading', {level: 3, name: 'Available with Next.js'})
145143
).toBeInTheDocument();
144+
expect(props.onPlatformChange).toHaveBeenCalledWith(
145+
expect.objectContaining({key: 'javascript-nextjs'})
146+
);
146147
});
147148

148149
describe('feature card variants', () => {

0 commit comments

Comments
 (0)