You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(flags): add fresh option to feature flag methods (#3119)
* feat(flags): add `fresh` option to feature flag methods
Add a `fresh` option to `getFeatureFlag()`, `getFeatureFlagResult()`, and
`isFeatureEnabled()` that only returns values loaded from the server, not
cached localStorage values.
By default, these methods may return cached values from localStorage if the
`/flags` endpoint hasn't responded yet. This reduces flicker but means you
might briefly see stale values (e.g., a flag that was disabled on the server).
With `{ fresh: true }`, the methods return `undefined` until the `/flags`
endpoint responds, ensuring you always get the current server state.
Usage:
```js
// Default behavior (may return cached values)
posthog.getFeatureFlag('my-flag')
// Only return fresh values from server
posthog.getFeatureFlag('my-flag', { fresh: true })
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor(flags): centralize FeatureFlagOptions type
Extract the inline `{ send_event?: boolean; fresh?: boolean }` options
type into a centralized `FeatureFlagOptions` type in @posthog/types.
This reduces duplication across 9 occurrences in 3 files and provides
a single source of truth for the feature flag lookup options.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* include changeset
---------
Co-authored-by: Claude <noreply@anthropic.com>
Adds a fresh option to getFeatureFlag(), getFeatureFlagResult(), and isFeatureEnabled() that only returns values loaded from the server, not cached localStorage values.
0 commit comments