feat(statsig): marketing integration and SSR hero experiment#2918
feat(statsig): marketing integration and SSR hero experiment#2918HarshMN2345 merged 6 commits intomainfrom
Conversation
- Add Statsig browser client, CTA forwarding, and stable user id (cookie + localStorage). - Evaluate hero description experiment on the server (statsig-node) to avoid client flash. - Document STATSIG_SERVER_SECRET in .env.example; extend CSP for Statsig. - Update mobile web app meta in app.html. Made-with: Cursor
Greptile SummaryThis PR integrates Statsig for marketing analytics: a browser client (with session replay and web analytics plugins), a server-side experiment evaluation for the hero subtitle to avoid client flash, a stable user ID via cookie + localStorage, and CTA event forwarding from the existing analytics layer. Infrastructure wiring (Kubernetes secret, CI steps, CSP) is also included.
Confidence Score: 4/5Safe to merge after fixing the iOS PWA meta tag regression; all Statsig wiring is correct. One P1 found: the removal of src/app.html — the iOS PWA meta tag regression is the only blocking issue. Important Files Changed
|
| * Evaluates `best_description` for SSR. Exposure is not logged here so the client can log the real view. | ||
| */ | ||
| export async function evaluateHeroDescriptionExperiment( | ||
| user: StatsigUser, | ||
| fallback: string | ||
| ): Promise<string> { | ||
| const ready = await ensureStatsigServer(); | ||
| if (!ready) return fallback; | ||
|
|
||
| try { | ||
| const experiment = Statsig.getExperimentWithExposureLoggingDisabledSync( | ||
| user, | ||
| STATSIG_EXPERIMENT_BEST_DESCRIPTION | ||
| ); | ||
| return experiment.get('description', fallback) as string; |
There was a problem hiding this comment.
Experiment exposure is never logged
getExperimentWithExposureLoggingDisabledSync intentionally suppresses the impression log so the client can record it "on real view." However, no client-side code calls getExperiment(STATSIG_EXPERIMENT_BEST_DESCRIPTION) — the hero subtitle is passed directly from data.heroSubtitle without the browser SDK ever reading the experiment. With zero exposure logs, Statsig's dashboard will show no experiment traffic, goal metrics won't be attributed to the correct variant, and any statistical analysis will be invalid.
To fix this, after whenStatsigSyncReady() resolves in the hero component (or wherever the experiment result is consumed), call client.getExperiment(STATSIG_EXPERIMENT_BEST_DESCRIPTION) to log the exposure:
// e.g. in hero.svelte onMount, after Statsig is ready
whenStatsigSyncReady().then((client) => {
if (client) client.getExperiment(STATSIG_EXPERIMENT_BEST_DESCRIPTION);
});
Made-with: Cursor
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.)