Skip to content

feat(statsig): integrate @statsig/statsig-node-core and update depend…#2932

Merged
eldadfux merged 1 commit intomainfrom
feat/statsig-marketing-ssr
Apr 28, 2026
Merged

feat(statsig): integrate @statsig/statsig-node-core and update depend…#2932
eldadfux merged 1 commit intomainfrom
feat/statsig-marketing-ssr

Conversation

@eldadfux
Copy link
Copy Markdown
Member

…encies

  • Added @statsig/statsig-node-core as a dependency for improved server-side functionality.
  • Updated Statsig client initialization to utilize the new core library.
  • Refactored user handling to support custom user fields and ensure compatibility with the new SDK.
  • Updated package versions in bun.lock, package.json, and pnpm-lock.yaml for consistency.

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.)

…encies

- Added @statsig/statsig-node-core as a dependency for improved server-side functionality.
- Updated Statsig client initialization to utilize the new core library.
- Refactored user handling to support custom user fields and ensure compatibility with the new SDK.
- Updated package versions in bun.lock, package.json, and pnpm-lock.yaml for consistency.

Made-with: Cursor
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR migrates the server-side Statsig integration from the legacy statsig-node package to @statsig/statsig-node-core, switching from a static class API to an instance-based client with matching Vite SSR externalization. The refactoring also introduces StatsigServerUserInput for type-safe user construction and correctly removes the now-unnecessary JSON.stringify around the bootstrap payload (which the new SDK returns as a pre-serialized string).

Confidence Score: 4/5

Safe to merge after confirming disableExposureLogging is supported by the new SDK

The migration is clean and well-structured. The only open question is whether the new SDK's getExperiment honours the disableExposureLogging option the same way the old dedicated method did; all other changes are straightforward API shape adaptations.

src/lib/statsig/hero-statsig.server.ts — specifically the getExperiment call with disableExposureLogging

Important Files Changed

Filename Overview
src/lib/statsig/hero-statsig.server.ts Core migration from statsig-node static class to @statsig/statsig-node-core instance-based client; introduces StatsigServerUserInput type, instance-level init caching, and adjusted API calls for getExperiment/getClientInitializeResponse
vite.config.ts Correctly externalizes @statsig/statsig-node-core from Vite SSR bundling to support its native N-API binary
package.json Replaces statsig-node ^6.5.1 with @statsig/statsig-node-core ^0.19.3

Reviews (1): Last reviewed commit: "feat(statsig): integrate @statsig/statsi..." | Re-trigger Greptile

Comment on lines +63 to +65
const experiment = client.getExperiment(statsigUser, STATSIG_EXPERIMENT_BEST_DESCRIPTION, {
disableExposureLogging: true
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Verify disableExposureLogging option is honoured by new SDK

The old code used the explicitly named getExperimentWithExposureLoggingDisabledSync, which made the no-logging contract unambiguous. The new call relies on { disableExposureLogging: true } being a recognised option in @statsig/statsig-node-core. If the option is silently ignored, the server will log an exposure for every SSR request, double-counting assignments in the Statsig dashboard and skewing experiment data. Worth confirming against the Node Core changelog or type definitions before shipping to production traffic.

@eldadfux eldadfux merged commit 3895b19 into main Apr 28, 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