feat: add advanced_feature_flags_dedup_per_session config option#3241
Merged
dustinbyrne merged 2 commits intomainfrom Mar 16, 2026
Merged
feat: add advanced_feature_flags_dedup_per_session config option#3241dustinbyrne merged 2 commits intomainfrom
dustinbyrne merged 2 commits intomainfrom
Conversation
When enabled, event deduplication is scoped to the current session ID. Each new session re-emits the event for every flag that is checked, fixing the case where experiments miss flag events that were cached before the experiment went live.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Last reviewed commit: 789721a |
Contributor
Contributor
|
Size Change: +3.54 kB (+0.05%) Total Size: 6.68 MB
ℹ️ View Unchanged
|
marandaneto
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Experiments measure usage of feature flags via the
$feature_flag_calledevent. The SDK deduplicates this event globally—once emitted and cached for a given flag+value, it is never re-emitted unlessidentify(with a new distinct ID) orresetis called. This means that if the event fires before an experiment goes live, the experiment will never see it for that user, skewing results.This deviates from how the mobile SDKs track
$feature_flag_calledevents, which is in-memory.Changes
Adds a new config option
advanced_feature_flags_dedup_per_session(defaultfalse) that scopes$feature_flag_calleddeduplication to the current session ID. When enabled, the persisted$flag_call_reportedcache is cleared whenever the session rotates, so each new session re-emits the event for every flag that is checked.Files changed:
packages/types/src/posthog-config.ts— Newadvanced_feature_flags_dedup_per_session: booleanconfig property with JSDoc.packages/browser/src/constants.ts— NewFLAG_CALL_REPORTED_SESSION_IDpersistence key, added to reserved properties.packages/browser/src/posthog-core.ts— Default value (false).packages/browser/src/posthog-featureflags.ts— Session-scoped dedup logic: compares current session ID to the stored one, clears the reported-flags map on mismatch.packages/browser/src/__tests__/featureflags.test.ts— 5 new tests covering session rotation, default-off behavior, within-session value tracking, multi-flag reset, and empty session ID safety.In a future revision, we'll create a new defaults in which this is on by default.
Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file