: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(ingestion): add minimal_flag_called_events team configuration (#72466)
Phil Haackd87883bcba6a
diff --git a/nodejs/src/common/utils/team-manager.test.ts b/nodejs/src/common/utils/team-manager.test.tsindex 20baae78ae12..5f1bfe6c6106 100644--- a/nodejs/src/common/utils/team-manager.test.ts+++ b/nodejs/src/common/utils/team-manager.test.ts@@ -1,5 +1,11 @@import { forSnapshot } from '~/tests/helpers/snapshots'-import { createTeam, getFirstTeam, resetTestDatabase, updateOrganizationAvailableFeatures } from '~/tests/helpers/sql'+import {+ createTeam,+ getFirstTeam,+ insertRow,+ resetTestDatabase,+ updateOrganizationAvailableFeatures,+} from '~/tests/helpers/sql'import { Hub, Team } from '~/types'import { defaultConfig } from '../config/config'@@ -54,6 +60,7 @@ describe('TeamManager()', () => {"id": 2,"ingested_event": true,"logs_settings": null,+ "minimal_flag_called_events": false,"name": "TEST PROJECT","organization_id": "<REPLACED-UUID-1>","person_display_name_properties": [],@@ -198,6 +205,38 @@ describe('TeamManager()', () => {expect(newTeamByToken).not.toBeNull()expect(newTeamByToken!.drop_events_older_than_seconds).toBeNull()})++ it('defaults minimal_flag_called_events to false when no TeamFeatureFlagsConfig row exists', async () => {+ const newTeamId = await createTeam(postgres, organizationId)++ const newTeam = await teamManager.getTeam(newTeamId)+ expect(newTeam).not.toBeNull()+ expect(newTeam!.minimal_flag_called_events).toBe(false)+ })++ it('reflects minimal_flag_called_events when a TeamFeatureFlagsConfig row exists', async () => {+ const newTeamId = await createTeam(postgres, organizationId)+ await insertRow(postgres, 'feature_flags_teamfeatureflagsconfig', {+ team_id: newTeamId,+ minimal_flag_called_events: true,+ })++ const newTeam = await teamManager.getTeam(newTeamId)+ expect(newTeam).not.toBeNull()+ expect(newTeam!.minimal_flag_called_events).toBe(true)+ })++ it('does not leak minimal_flag_called_events across teams', async () => {+ const teamA = await createTeam(postgres, organizationId)+ const teamB = await createTeam(postgres, organizationId)+ await insertRow(postgres, 'feature_flags_teamfeatureflagsconfig', {+ team_id: teamA,+ minimal_flag_called_events: true,+ })++ expect((await teamManager.getTeam(teamA))!.minimal_flag_called_events).toBe(true)+ expect((await teamManager.getTeam(teamB))!.minimal_flag_called_events).toBe(false)+ })})describe('hasAvailableFeature()', () => {diff --git a/nodejs/src/common/utils/team-manager.ts b/nodejs/src/common/utils/team-manager.tsindex 5ede14af8d1b..160e45dd6bc6 100644--- a/nodejs/src/common/utils/team-manager.ts+++ b/nodejs/src/common/utils/team-manager.ts@@ -134,6 +134,10 @@ export class TeamManager {t.logs_settings,t.extra_settings,extract('epoch' from t.drop_events_older_than) as drop_events_older_than_seconds,+ COALESCE(+ (SELECT minimal_flag_called_events FROM feature_flags_teamfeatureflagsconfig WHERE team_id = t.id),+ false+ ) AS minimal_flag_called_events,o.available_product_featuresFROM posthog_team tJOIN posthog_organization o ON o.id = t.organization_iddiff --git a/nodejs/src/ingestion/common/steps/event-processing/prefetch-hog-functions-step.test.ts b/nodejs/src/ingestion/common/steps/event-processing/prefetch-hog-functions-step.test.tsindex c0429e0e75e7..eee45486b01d 100644--- a/nodejs/src/ingestion/common/steps/event-processing/prefetch-hog-functions-step.test.ts+++ b/nodejs/src/ingestion/common/steps/event-processing/prefetch-hog-functions-step.test.ts@@ -20,6 +20,7 @@ const createTestTeam = (overrides: Partial<Team> = {}): Team => ({heatmaps_opt_in: null,ingested_event: true,person_display_name_properties: null,+ minimal_flag_called_events: false,test_account_filters: null,cookieless_server_hash_mode: null,timezone: 'UTC',diff --git a/nodejs/src/ingestion/framework/ingestion-warning-handling-chunk-pipeline.test.ts b/nodejs/src/ingestion/framework/ingestion-warning-handling-chunk-pipeline.test.tsindex af501d98da33..a02ea85b3a40 100644--- a/nodejs/src/ingestion/framework/ingestion-warning-handling-chunk-pipeline.test.ts+++ b/nodejs/src/ingestion/framework/ingestion-warning-handling-chunk-pipeline.test.ts@@ -40,6 +40,7 @@ function createTestTeam(overrides: Partial<Team> = {}): Team {heatmaps_opt_in: null,ingested_event: true,person_display_name_properties: null,+ minimal_flag_called_events: false,test_account_filters: null,cookieless_server_hash_mode: null,timezone: 'UTC',diff --git a/nodejs/src/types.ts b/nodejs/src/types.tsindex a2d069b36aa6..937e3e3ca6dd 100644--- a/nodejs/src/types.ts+++ b/nodejs/src/types.ts@@ -281,6 +281,7 @@ export interface Team {heatmaps_opt_in: boolean | nullingested_event: booleanperson_display_name_properties: string[] | null+ minimal_flag_called_events: booleantest_account_filters:| (EventPropertyFilter | PersonPropertyFilter | ElementPropertyFilter | CohortPropertyFilter)[]| nulldiff --git a/nodejs/tests/helpers/ingestion-e2e.ts b/nodejs/tests/helpers/ingestion-e2e.tsindex 29c0075044ab..ee3b02340979 100644--- a/nodejs/tests/helpers/ingestion-e2e.ts+++ b/nodejs/tests/helpers/ingestion-e2e.ts@@ -67,6 +67,7 @@ export const DEFAULT_TEAM: Team = {heatmaps_opt_in: null,ingested_event: true,person_display_name_properties: null,+ minimal_flag_called_events: false,test_account_filters: null,cookieless_server_hash_mode: null,timezone: 'UTC',diff --git a/nodejs/tests/helpers/team.ts b/nodejs/tests/helpers/team.tsindex 6aee9e6083dc..1ff52c85286e 100644--- a/nodejs/tests/helpers/team.ts+++ b/nodejs/tests/helpers/team.ts@@ -20,6 +20,7 @@ export function createTestTeam(overrides: Partial<Team> = {}): Team {heatmaps_opt_in: null,ingested_event: true,person_display_name_properties: null,+ minimal_flag_called_events: false,test_account_filters: null,cookieless_server_hash_mode: null,timezone: 'UTC',diff --git a/nodejs/tests/ingestion/framework/pipelines.integration.test.ts b/nodejs/tests/ingestion/framework/pipelines.integration.test.tsindex ae342d4700e6..8f4614abdf44 100644--- a/nodejs/tests/ingestion/framework/pipelines.integration.test.ts+++ b/nodejs/tests/ingestion/framework/pipelines.integration.test.ts@@ -32,6 +32,7 @@ const createTestTeam = (overrides: Partial<Team> = {}): Team => ({heatmaps_opt_in: null,ingested_event: true,person_display_name_properties: null,+ minimal_flag_called_events: false,test_account_filters: null,cookieless_server_hash_mode: null,timezone: 'UTC',diff --git a/nodejs/tests/ingestion/person-properties-metadata.e2e.test.ts b/nodejs/tests/ingestion/person-properties-metadata.e2e.test.tsindex df35fe337251..f69d9b8a7b6b 100644--- a/nodejs/tests/ingestion/person-properties-metadata.e2e.test.ts+++ b/nodejs/tests/ingestion/person-properties-metadata.e2e.test.ts@@ -52,6 +52,7 @@ const DEFAULT_TEAM: Team = {heatmaps_opt_in: null,ingested_event: true,person_display_name_properties: null,+ minimal_flag_called_events: false,test_account_filters: null,cookieless_server_hash_mode: null,timezone: 'UTC',diff --git a/nodejs/tests/ingestion/person-updates-e2e.test.ts b/nodejs/tests/ingestion/person-updates-e2e.test.tsindex 821d6725d2f8..ef82c4787ade 100644--- a/nodejs/tests/ingestion/person-updates-e2e.test.ts+++ b/nodejs/tests/ingestion/person-updates-e2e.test.ts@@ -54,6 +54,7 @@ const DEFAULT_TEAM: Team = {heatmaps_opt_in: null,ingested_event: true,person_display_name_properties: [],+ minimal_flag_called_events: false,person_processing_opt_out: null,test_account_filters: [],timezone: 'UTC',