Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(flags): add flag_evaluations_mode column to TeamFeatureFlagsConfig (#106185)

Phil Haack7563d6d2d2df
diff --git a/products/feature_flags/backend/migrations/0021_teamfeatureflagsconfig_flag_evaluations_mode.py b/products/feature_flags/backend/migrations/0021_teamfeatureflagsconfig_flag_evaluations_mode.py
new file mode 100644
index 000000000000..1b42e0d0cf7b
--- /dev/null
+++ b/products/feature_flags/backend/migrations/0021_teamfeatureflagsconfig_flag_evaluations_mode.py
@@ -0,0 +1,28 @@
+# Generated by Django 5.2.17 on 2026-09-23 18:18
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ (
+ "feature_flags",
+ "0020_alter_featureflag_created_by_alter_featureflag_team_and_more",
+ ),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="teamfeatureflagsconfig",
+ name="flag_evaluations_mode",
+ field=models.SmallIntegerField(
+ choices=[
+ (0, "Events"),
+ (1, "Read flag evaluations"),
+ (2, "Flag evaluations only"),
+ ],
+ db_default=0,
+ default=0,
+ ),
+ ),
+ ]
diff --git a/products/feature_flags/backend/migrations/max_migration.txt b/products/feature_flags/backend/migrations/max_migration.txt
index b38a02e326a8..543adb4d2a99 100644
--- a/products/feature_flags/backend/migrations/max_migration.txt
+++ b/products/feature_flags/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0020_alter_featureflag_created_by_alter_featureflag_team_and_more
+0021_teamfeatureflagsconfig_flag_evaluations_mode
diff --git a/products/feature_flags/backend/models/team_feature_flags_config.py b/products/feature_flags/backend/models/team_feature_flags_config.py
index a0fb4a665f0f..a909f8764ede 100644
--- a/products/feature_flags/backend/models/team_feature_flags_config.py
+++ b/products/feature_flags/backend/models/team_feature_flags_config.py
@@ -24,6 +24,24 @@ class PropertyMatchingVersion(models.IntegerChoices):
EXPLICIT = 2, "Explicit"
+class FlagEvaluationsMode(models.IntegerChoices):
+ """Which table the product reads a team's $feature_flag_called data from. This field does not
+ control ingestion. The INGESTION_FLAG_EVALUATIONS_TEAMS allowlist in FlagEvaluationsService
+ decides which teams ingestion also writes to flag_evaluations. FLAG_EVALUATIONS_ONLY is
+ reserved for the ingestion change that stops the events writes.
+ """
+
+ # The Usage tab reads the events table. The flag_evaluations HogQL table stays hidden unless
+ # the flag-evaluations-hogql-table flag is on for the organization.
+ EVENTS = 0, "Events"
+ # The Usage tab reads flag_evaluations, and the HogQL table is visible.
+ READ_FLAG_EVALUATIONS = 1, "Read flag evaluations"
+ # As READ_FLAG_EVALUATIONS, and ingestion stops writing $feature_flag_called to events. Ingestion
+ # ignores this mode until the change that implements it deploys. Until then the mode acts as
+ # READ_FLAG_EVALUATIONS. A team already on this mode stops the events writes when that change deploys.
+ FLAG_EVALUATIONS_ONLY = 2, "Flag evaluations only"
+
+
class TeamFeatureFlagsConfig(models.Model):
"""Internal-only team-level feature flags settings, written by staff and never by customers.
@@ -69,6 +87,14 @@ class TeamFeatureFlagsConfig(models.Model):
validators=[MinValueValidator(1), MaxValueValidator(MAX_FEATURE_FLAGS_OVERRIDE_CEILING)],
)
+ # The database default keeps older writers, and raw INSERTs that omit this column, valid during
+ # rolling deploys.
+ flag_evaluations_mode = models.SmallIntegerField(
+ choices=FlagEvaluationsMode,
+ default=FlagEvaluationsMode.EVENTS,
+ db_default=FlagEvaluationsMode.EVENTS,
+ )
+
class Meta:
constraints = [
models.CheckConstraint(