Skip to content

Refactor marketing hero component for improved Statsig integration#2943

Merged
eldadfux merged 1 commit intomainfrom
feat/marketing-hero-statsig-layouts
Apr 29, 2026
Merged

Refactor marketing hero component for improved Statsig integration#2943
eldadfux merged 1 commit intomainfrom
feat/marketing-hero-statsig-layouts

Conversation

@eldadfux
Copy link
Copy Markdown
Member

  • Updated the custom-hero.svelte component to conditionally assign hero subtitle and layout based on Statsig client responses, preventing unnecessary UI flashes.
  • Adjusted the +page.ts file to set prerender = false, ensuring the marketing page loads per request with real cookies and avoids layout inconsistencies.
  • Enhanced documentation in README.md to clarify the implications of SSR and client-side rendering for the marketing homepage.

These changes aim to enhance user experience by ensuring a seamless integration of Statsig-driven features while maintaining layout stability.

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

- Updated the `custom-hero.svelte` component to conditionally assign hero subtitle and layout based on Statsig client responses, preventing unnecessary UI flashes.
- Adjusted the `+page.ts` file to set `prerender = false`, ensuring the marketing page loads per request with real cookies and avoids layout inconsistencies.
- Enhanced documentation in `README.md` to clarify the implications of SSR and client-side rendering for the marketing homepage.

These changes aim to enhance user experience by ensuring a seamless integration of Statsig-driven features while maintaining layout stability.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 29, 2026

Greptile Summary

This PR fixes a visible layout flash on the marketing homepage by switching the route from prerender = true to prerender = false, so +page.server.ts runs per request with real cookies and evaluates Statsig experiments server-side. Both hero components are also updated to skip state assignments when the client Statsig result matches the SSR props, avoiding unnecessary re-renders in the common bootstrap-matches case.

Confidence Score: 4/5

Safe to merge; the logic is sound and the only finding is a now-unreachable dead code block.

All findings are P2. The building guard in +page.server.ts is unreachable dead code with prerender = false, but it is harmless. The core flash-prevention logic and the prerender switch are correct.

src/routes/(marketing)/+page.server.ts — building guard block is now unreachable

Important Files Changed

Filename Overview
src/routes/(marketing)/+page.ts Changed prerender from true to false — intentional trade-off to enable per-request Statsig evaluation in +page.server.ts
src/routes/(marketing)/+page.server.ts Comment updates only; building guard is now unreachable dead code since the page is no longer prerendered
src/routes/(marketing)/(components)/hero.svelte Added conditional guards so clientHeroSubtitle/clientHeroLayout are only set when Statsig client returns a different value than SSR, eliminating the layout-change flash
src/lib/components/homepage-variations/custom-hero.svelte Same conditional-guard pattern as hero.svelte applied to the custom hero variant, keeping both paths consistent
src/lib/statsig/README.md Documentation updated to clarify that prerender = false is now the intended setup for the marketing homepage

Comments Outside Diff (1)

  1. src/routes/(marketing)/+page.server.ts, line 19-28 (link)

    P2 building guard is now unreachable dead code

    With prerender = false set in +page.ts, SvelteKit will never call this server load function during vite build, so building can never be true here. The guard and its fallback return are effectively dead code. The comment even acknowledges the ambiguity ("may still be analyzed"), but in practice SvelteKit skips non-prerendered server loads at build time. Consider removing this block to keep the load function clean and avoid misleading future readers.

Reviews (1): Last reviewed commit: "Refactor marketing hero component for im..." | Re-trigger Greptile

@eldadfux eldadfux merged commit bd2a66b into main Apr 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant