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.

fix(experiments): explain that exposure filters remove events, not users (#127284)

Marcel Poelkerec3e0d1f250c
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 0dd52a7e5b76..3c5768f971b5 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3372,6 +3372,10 @@ snapshots:
hash: v1.k794b7964.030c95e50318c77d8010cb0a0fa7829cfba90270045068a0db974e232504f9ad.iP86lD1msdXZjVXPQ1hzjV9tizv3xhQfntQDguO8GLg
experiments-howtoreadtooltip--tooltip-frequentist--light:
hash: v1.k794b7964.06d76f5dd20d9afc251e95a391666454d01199bf6a587ed1443c19540bd92f57.qvlIJTJCzqS5DL7nVn55PYJujlSmxLxgPDYwA8a5wWo
+ experiments-negatedeventfilternote--before-launch--dark:
+ hash: v1.k794b7964.fa75fd3c2573b9685a1d716407b7fed1588a33798205a476a6f96e7ef830547b.yxhyFEFkBUl33wRcIxunZ2mPw4f5G3iF0OC85Draphg
+ experiments-negatedeventfilternote--before-launch--light:
+ hash: v1.k794b7964.3babd668b713488e463b7901a0e93ea0154bbfb2bab677463f3422ce5d4534ee.tchxUAkUhFs7VcmTctLKkqfvz8HF33_GRDS61AkZ3fI
experiments-replayvisionscannercard--off--dark:
hash: v1.k794b7964.c9fb173cda38d075177709adc2b01144d835ca606362b9c701a596199a755158.nWxgtqo2ZyNfFq0RRmHmy78q7Hu_ZRbjSM5Q70inZKs
experiments-replayvisionscannercard--off--light:
diff --git a/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx b/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx
index 1ee19c49f273..f5fa0db6b479 100644
--- a/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx
+++ b/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx
@@ -11,9 +11,11 @@ import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFil
import { teamLogic } from 'scenes/teamLogic'
import { ExperimentEventExposureConfig, ExperimentExposureCriteria, NodeKind } from '~/queries/schema/schema-general'
-import { ChartDisplayCategory, type Experiment } from '~/types'
+import { ChartDisplayCategory, type Experiment, type FeatureFlagBasicType } from '~/types'
+import { NegatedEventFilterNote } from 'products/experiments/frontend/components/NegatedEventFilterNote'
import { SelectableCard } from 'products/experiments/frontend/components/SelectableCard'
+import { isLaunched } from 'products/experiments/frontend/experimentStatus'
import {
EXPERIMENT_EXPOSURE_EVENT,
@@ -40,82 +42,106 @@ const DEFAULT_ACTIVATION_CONFIG: ExperimentEventExposureConfig = {
type ExposureCriteriaPanelProps = {
experiment: Experiment
+ /** The flag the experiment runs on. A wizard draft keeps a linked flag outside `experiment`. */
+ featureFlag: Pick<FeatureFlagBasicType, 'filters'> | null
onChange: (exposureCriteria: ExperimentExposureCriteria) => void
compact?: boolean
}
function InclusionActionFilter({
experiment,
+ groupTypeIndex,
onChange,
}: {
experiment: Experiment
+ groupTypeIndex: number | null | undefined
onChange: ExposureCriteriaPanelProps['onChange']
}): JSX.Element {
return (
- <SeriesActionFilter
- bordered
- series={exposureConfigToSeries(experiment.exposure_criteria?.exposure_config || DEFAULT_EXPOSURE_CONFIG)}
- trendsDisplayCategory={ChartDisplayCategory.TimeSeries}
- onChange={(series) => {
- const exposureConfig = seriesToExposureConfig(series)
- if (exposureConfig) {
- onChange({ exposure_config: exposureConfig })
- }
- }}
- typeKey="experiment-exposure-config"
- buttonCopy="Add exposure event"
- showSeriesIndicator={false}
- hideRename={true}
- entitiesLimit={1}
- mathAvailability={MathAvailability.None}
- showNumericalPropsOnly={false}
- {...commonActionFilterProps}
- actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
- />
+ <div>
+ <SeriesActionFilter
+ bordered
+ series={exposureConfigToSeries(
+ experiment.exposure_criteria?.exposure_config || DEFAULT_EXPOSURE_CONFIG
+ )}
+ trendsDisplayCategory={ChartDisplayCategory.TimeSeries}
+ onChange={(series) => {
+ const exposureConfig = seriesToExposureConfig(series)
+ if (exposureConfig) {
+ onChange({ exposure_config: exposureConfig })
+ }
+ }}
+ typeKey="experiment-exposure-config"
+ buttonCopy="Add exposure event"
+ showSeriesIndicator={false}
+ hideRename={true}
+ entitiesLimit={1}
+ mathAvailability={MathAvailability.None}
+ showNumericalPropsOnly={false}
+ {...commonActionFilterProps}
+ actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
+ />
+ <NegatedEventFilterNote
+ config={experiment.exposure_criteria?.exposure_config}
+ launched={isLaunched(experiment)}
+ groupTypeIndex={groupTypeIndex}
+ />
+ </div>
)
}
function ActivationActionFilter({
experiment,
+ groupTypeIndex,
onChange,
}: {
experiment: Experiment
+ groupTypeIndex: number | null | undefined
onChange: ExposureCriteriaPanelProps['onChange']
}): JSX.Element {
return (
- <SeriesActionFilter
- bordered
- series={exposureConfigToSeries(
- experiment.exposure_criteria?.activation_config || DEFAULT_ACTIVATION_CONFIG
- )}
- trendsDisplayCategory={ChartDisplayCategory.TimeSeries}
- onChange={(series) => {
- const activationConfig = seriesToExposureConfig(series)
- if (activationConfig) {
- onChange({ activation_config: activationConfig })
- }
- }}
- typeKey="experiment-activation-config"
- buttonCopy="Add activation event"
- showSeriesIndicator={false}
- hideRename={true}
- entitiesLimit={1}
- mathAvailability={MathAvailability.None}
- showNumericalPropsOnly={false}
- {...commonActionFilterProps}
- actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
- />
+ <div>
+ <SeriesActionFilter
+ bordered
+ series={exposureConfigToSeries(
+ experiment.exposure_criteria?.activation_config || DEFAULT_ACTIVATION_CONFIG
+ )}
+ trendsDisplayCategory={ChartDisplayCategory.TimeSeries}
+ onChange={(series) => {
+ const activationConfig = seriesToExposureConfig(series)
+ if (activationConfig) {
+ onChange({ activation_config: activationConfig })
+ }
+ }}
+ typeKey="experiment-activation-config"
+ buttonCopy="Add activation event"
+ showSeriesIndicator={false}
+ hideRename={true}
+ entitiesLimit={1}
+ mathAvailability={MathAvailability.None}
+ showNumericalPropsOnly={false}
+ {...commonActionFilterProps}
+ actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
+ />
+ <NegatedEventFilterNote
+ config={experiment.exposure_criteria?.activation_config}
+ launched={isLaunched(experiment)}
+ groupTypeIndex={groupTypeIndex}
+ />
+ </div>
)
}
function ExposureCriteriaFields({
experiment,
+ groupTypeIndex,
onChange,
hasFilters,
defaultExposureEvent,
showActivationOption,
}: {
experiment: Experiment
+ groupTypeIndex: number | null | undefined
onChange: ExposureCriteriaPanelProps['onChange']
hasFilters: boolean
defaultExposureEvent: string
@@ -169,7 +195,7 @@ function ExposureCriteriaFields({
description={
<>
Select a custom event to signal that users reached the part of your app where the experiment
- runs. You can also filter out users you would like to exclude.
+ runs. You can also filter which events count as exposure.
</>
}
selected={isCustom}
@@ -188,12 +214,20 @@ function ExposureCriteriaFields({
{isCustom && (
<div className="mb-4">
- <InclusionActionFilter experiment={experiment} onChange={onChange} />
+ <InclusionActionFilter
+ experiment={experiment}
+ groupTypeIndex={groupTypeIndex}
+ onChange={onChange}
+ />
</div>
)}
{isActivation && (
<div className="mb-4">
- <ActivationActionFilter experiment={experiment} onChange={onChange} />
+ <ActivationActionFilter
+ experiment={experiment}
+ groupTypeIndex={groupTypeIndex}
+ onChange={onChange}
+ />
</div>
)}
@@ -244,7 +278,13 @@ function ExposureCriteriaFields({
)
}
-export function ExposureCriteriaPanel({ experiment, onChange, compact }: ExposureCriteriaPanelProps): JSX.Element {
+export function ExposureCriteriaPanel({
+ experiment,
+ featureFlag,
+ onChange,
+ compact,
+}: ExposureCriteriaPanelProps): JSX.Element {
+ const groupTypeIndex = featureFlag?.filters?.aggregation_group_type_index
// getActivationConfig, not a raw field check: a stored default-sentinel exposure_config
// still composes with activation, and the editor must classify it the way the backend does
const isActivation = !!getActivationConfig(experiment.exposure_criteria)
@@ -348,8 +388,20 @@ export function ExposureCriteriaPanel({ experiment, onChange, compact }: Exposur
]}
/>
</div>
- {isCustom && <InclusionActionFilter experiment={experiment} onChange={onChange} />}
- {isActivation && <ActivationActionFilter experiment={experiment} onChange={onChange} />}
+ {isCustom && (
+ <InclusionActionFilter
+ experiment={experiment}
+ groupTypeIndex={groupTypeIndex}
+ onChange={onChange}
+ />
+ )}
+ {isActivation && (
+ <ActivationActionFilter
+ experiment={experiment}
+ groupTypeIndex={groupTypeIndex}
+ onChange={onChange}
+ />
+ )}
</div>
<div className="flex flex-wrap items-center justify-between gap-2">
@@ -446,6 +498,7 @@ export function ExposureCriteriaPanel({ experiment, onChange, compact }: Exposur
<div className="p-3">
<ExposureCriteriaFields
experiment={experiment}
+ groupTypeIndex={groupTypeIndex}
onChange={onChange}
hasFilters={hasFilters}
defaultExposureEvent={defaultExposureEvent}
diff --git a/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx b/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx
index d624ce777db2..f1d33e47ee51 100644
--- a/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx
+++ b/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx
@@ -13,7 +13,9 @@ import { teamLogic } from 'scenes/teamLogic'
import { ExperimentExposureCriteria, NodeKind } from '~/queries/schema/schema-general'
import { ChartDisplayCategory } from '~/types'
+import { NegatedEventFilterNote } from 'products/experiments/frontend/components/NegatedEventFilterNote'
import { SelectableCard } from 'products/experiments/frontend/components/SelectableCard'
+import { isLaunched } from 'products/experiments/frontend/experimentStatus'
import { experimentLogic } from '../experimentLogic'
import { EXPOSURE_DEFAULT_EVENT, getActivationConfig, resolveFilterTestAccounts } from '../exposureContract'
@@ -27,7 +29,9 @@ type ExposureCriteriaModalProps = {
export function ExposureCriteriaModal({ onSave }: ExposureCriteriaModalProps): JSX.Element | null {
const { isExposureCriteriaModalOpen, exposureCriteria } = useValues(exposureCriteriaModalLogic)
- const { resolvedExposureEvent } = useValues(experimentLogic)
+ const { experiment, resolvedExposureEvent } = useValues(experimentLogic)
+ const launched = isLaunched(experiment)
+ const groupTypeIndex = experiment.feature_flag?.filters?.aggregation_group_type_index
const { closeExposureCriteriaModal, setExposureCriteria } = useActions(exposureCriteriaModalLogic)
const { currentTeam } = useValues(teamLogic)
@@ -128,7 +132,7 @@ export function ExposureCriteriaModal({ onSave }: ExposureCriteriaModalProps): J
<>
If you can't rely on the <LemonTag>{resolvedExposureEvent}</LemonTag> event, you can select
a custom event to signal that users reached the part of your app where the experiment runs.
- You can also filter out users you would like to exclude from the analysis.
+ You can also filter which events count as exposure.
</>
}
selected={isCustom}
@@ -174,6 +178,11 @@ export function ExposureCriteriaModal({ onSave }: ExposureCriteriaModalProps): J
{...commonActionFilterProps}
actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
/>
+ <NegatedEventFilterNote
+ config={exposureCriteria.exposure_config}
+ launched={launched}
+ groupTypeIndex={groupTypeIndex}
+ />
</div>
)}
{isActivation && exposureCriteria?.activation_config && (
@@ -201,6 +210,11 @@ export function ExposureCriteriaModal({ onSave }: ExposureCriteriaModalProps): J
{...commonActionFilterProps}
actionsTaxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
/>
+ <NegatedEventFilterNote
+ config={exposureCriteria.activation_config}
+ launched={launched}
+ groupTypeIndex={groupTypeIndex}
+ />
</div>
)}
<div className="w-[405px]">
diff --git a/frontend/src/scenes/experiments/ExperimentWizard/steps/AnalyticsStep.tsx b/frontend/src/scenes/experiments/ExperimentWizard/steps/AnalyticsStep.tsx
index 9981bf70dc72..b6e997fe4e10 100644
--- a/frontend/src/scenes/experiments/ExperimentWizard/steps/AnalyticsStep.tsx
+++ b/frontend/src/scenes/experiments/ExperimentWizard/steps/AnalyticsStep.tsx
@@ -11,7 +11,7 @@ import { experimentWizardLogic } from '../experimentWizardLogic'
import { ReplayVisionScannerOption } from './ReplayVisionScannerOption'
export function AnalyticsStep(): JSX.Element {
- const { experiment, sharedMetrics } = useValues(experimentWizardLogic)
+ const { experiment, linkedFeatureFlag, sharedMetrics } = useValues(experimentWizardLogic)
const { setExperiment, setExposureCriteria, setSharedMetrics } = useActions(experimentWizardLogic)
const experimentScanners = useFeatureFlag('VISION_EXPERIMENT_SCANNER')
@@ -20,7 +20,12 @@ export function AnalyticsStep(): JSX.Element {
<div className="space-y-4">
<div>
<h3 className="text-lg font-semibold mb-1">Who is included in the analysis?</h3>
- <ExposureCriteriaPanel experiment={experiment} onChange={setExposureCriteria} compact />
+ <ExposureCriteriaPanel
+ experiment={experiment}
+ featureFlag={linkedFeatureFlag}
+ onChange={setExposureCriteria}
+ compact
+ />
</div>
<div className="mt-10">
diff --git a/frontend/src/scenes/experiments/exposureContract.test.ts b/frontend/src/scenes/experiments/exposureContract.test.ts
index 0a9508cdddac..fb8c0f570759 100644
--- a/frontend/src/scenes/experiments/exposureContract.test.ts
+++ b/frontend/src/scenes/experiments/exposureContract.test.ts
@@ -1,9 +1,17 @@
-import { ExperimentEventExposureConfig, ExperimentExposureCriteria, NodeKind } from '~/queries/schema/schema-general'
+import {
+ ExperimentEventExposureConfig,
+ ExperimentExposureConfig,
+ ExperimentExposureCriteria,
+ HogQLQueryModifiers,
+ NodeKind,
+} from '~/queries/schema/schema-general'
+import { AnyPropertyFilter, PropertyFilterType, PropertyOperator } from '~/types'
import {
exposureEventLabel,
getActivationConfig,
getExposureEventAndProperty,
+ hasNegatedEventFilter,
isDefaultExposureConfig,
resolvedExposureEvent,
} from './exposureContract'
@@ -178,4 +186,95 @@ describe('exposureContract', () => {
])('resolves the activation config for %s', (_name, exposureCriteria, expectActive) => {
expect(getActivationConfig(exposureCriteria)).toEqual(expectActive ? activationConfig : undefined)
})
+
+ const eventConfig = (...properties: AnyPropertyFilter[]): ExperimentEventExposureConfig => ({
+ kind: NodeKind.ExperimentEventExposureConfig,
+ event: '$pageview',
+ properties,
+ })
+ const eventFilter = (key: string, operator: PropertyOperator): AnyPropertyFilter => ({
+ type: PropertyFilterType.Event,
+ key,
+ operator,
+ value: 'x',
+ })
+ const negatedPersonFilter: AnyPropertyFilter = {
+ type: PropertyFilterType.Person,
+ key: 'email',
+ operator: PropertyOperator.NotIContains,
+ value: 'x',
+ }
+
+ it.each<
+ [
+ string,
+ ExperimentExposureConfig | undefined,
+ boolean,
+ (number | null)?,
+ HogQLQueryModifiers['personsOnEventsMode']?,
+ ]
+ >([
+ ['no config', undefined, false],
+ ['no filters', eventConfig(), false],
+ ['a negated event filter', eventConfig(eventFilter('$current_url', PropertyOperator.NotIContains)), true],
+ ['a negated filter without a value', eventConfig(eventFilter('step', PropertyOperator.IsNotSet)), true],
+ ['a filter that selects', eventConfig(eventFilter('$current_url', PropertyOperator.IContains)), false],
+ ['a negated filter on the flag key', eventConfig(eventFilter('$feature_flag', PropertyOperator.IsNot)), false],
+ [
+ 'a negated filter on the group a group experiment counts',
+ eventConfig(eventFilter('$group_2', PropertyOperator.IsNot)),
+ false,
+ 2,
+ ],
+ [
+ 'a negated filter on a group key in a person experiment',
+ eventConfig(eventFilter('$group_2', PropertyOperator.IsNot)),
+ true,
+ null,
+ ],
+ ['a negated person filter read from the persons table', eventConfig(negatedPersonFilter), false],
+ [
+ 'a negated person filter read from the events',
+ eventConfig(negatedPersonFilter),
+ true,
+ null,
+ 'person_id_override_properties_on_events',
+ ],
+ ['a negated person filter in a group experiment', eventConfig(negatedPersonFilter), true, 2],
+ [
+ 'a negated session filter',
+ eventConfig({
+ type: PropertyFilterType.Session,
+ key: '$entry_current_url',
+ operator: PropertyOperator.NotIContains,
+ value: 'x',
+ }),
+ true,
+ ],
+ [
+ 'an action with a negated event filter',
+ {
+ kind: NodeKind.ActionsNode,
+ id: 1,
+ properties: [eventFilter('$current_url', PropertyOperator.IsNot)],
+ },
+ true,
+ ],
+ [
+ 'a warehouse exposure',
+ { kind: NodeKind.ExperimentWarehouseNativeExposureConfig, connection_id: 'x', query: 'SELECT 1' },
+ false,
+ ],
+ ])(
+ 'reads whether the config leaves out events for %s',
+ (
+ _name,
+ config,
+ expected,
+ groupTypeIndex = null,
+ personsOnEventsMode = 'person_id_override_properties_joined'
+ ) => {
+ expect(hasNegatedEventFilter(config, groupTypeIndex, personsOnEventsMode)).toBe(expected)
+ }
+ )
})
diff --git a/frontend/src/scenes/experiments/exposureContract.ts b/frontend/src/scenes/experiments/exposureContract.ts
index 66ccb1bcba62..4cd929e4773e 100644
--- a/frontend/src/scenes/experiments/exposureContract.ts
+++ b/frontend/src/scenes/experiments/exposureContract.ts
@@ -2,9 +2,10 @@ import {
ExperimentEventExposureConfig,
ExperimentExposureConfig,
ExperimentExposureCriteria,
+ HogQLQueryModifiers,
NodeKind,
} from '~/queries/schema/schema-general'
-import { Experiment } from '~/types'
+import { Experiment, PropertyFilterType, PropertyOperator } from '~/types'
/**
* The flag exposure event contract for experiments. Mirrors the backend chokepoint
@@ -66,6 +67,69 @@ export function isDefaultExposureConfig(config: ExperimentExposureConfig): boole
return isEventConfig(config) && config.event === EXPOSURE_DEFAULT_EVENT
}
+/** Whether the operator matches the values its positive form does not. Keep in sync with
+ * `_NEGATIVE_OPERATOR_COMPLEMENTS` in `posthog/hogql/property.py`. */
+function isOperatorNegated(operator: PropertyOperator): boolean {
+ return [
+ PropertyOperator.IsNot,
+ PropertyOperator.NotIn,
+ PropertyOperator.IsNotSet,
+ PropertyOperator.NotIContains,
+ PropertyOperator.NotIContainsMulti,
+ PropertyOperator.NotRegex,
+ PropertyOperator.NotStartsWith,
+ PropertyOperator.NotEndsWith,
+ PropertyOperator.NotBetween,
+ PropertyOperator.IsCleanedPathNotExact,
+ PropertyOperator.SemverNeq,
+ ].includes(operator)
+}
+
+/**
+ * Whether a negated filter in the config leaves out single events while the experiment still counts
+ * the person or group that sent them. Event, session and element properties can change from one event
+ * to the next. Person properties can too when the team reads them from the events: an event sent before
+ * the person identified has no `email`, and a negated filter keeps an event without a value. A cohort
+ * filter, and a person filter read from the persons table, leave out the whole person. When the flag
+ * counts groups, the group still counts through its other persons. `$feature_flag` names the flag of a
+ * flag call event, not a trait of the user. A group-aggregated experiment counts each group by
+ * `$group_<index>`, so a filter on that key leaves out the whole group.
+ */
+export function hasNegatedEventFilter(
+ config: ExperimentExposureConfig | undefined,
+ groupTypeIndex: number | null | undefined,
+ personsOnEventsMode: HogQLQueryModifiers['personsOnEventsMode']
+): boolean {
+ if (!config || config.kind === NodeKind.ExperimentWarehouseNativeExposureConfig) {
+ return false
+ }
+ const groupKey = groupTypeIndex != null ? `$group_${groupTypeIndex}` : null
+ const aggregatesByGroup = groupKey !== null
+ const personFilterVaries =
+ aggregatesByGroup ||
+ personsOnEventsMode === 'person_id_override_properties_on_events' ||
+ personsOnEventsMode === 'person_id_no_override_properties_on_events'
+ return (config.properties ?? []).some((property) => {
+ switch (property.type) {
+ case PropertyFilterType.Event:
+ return (
+ property.key !== '$feature_flag' &&
+ property.key !== groupKey &&
+ isOperatorNegated(property.operator)
+ )
+ case PropertyFilterType.Session:
+ case PropertyFilterType.Element:
+ return isOperatorNegated(property.operator)
+ case PropertyFilterType.Person:
+ return personFilterVaries && isOperatorNegated(property.operator)
+ case PropertyFilterType.Cohort:
+ return aggregatesByGroup && isOperatorNegated(property.operator)
+ default:
+ return false
+ }
+ })
+}
+
/**
* The activation event config in effect for the criteria, or undefined when there is none.
* Activation only composes with the default exposure, so a custom `exposure_config` disables it
diff --git a/products/experiments/frontend/components/NegatedEventFilterNote.stories.tsx b/products/experiments/frontend/components/NegatedEventFilterNote.stories.tsx
new file mode 100644
index 000000000000..5e5f3a9d57a2
--- /dev/null
+++ b/products/experiments/frontend/components/NegatedEventFilterNote.stories.tsx
@@ -0,0 +1,30 @@
+import type { Meta, StoryObj } from '@storybook/react'
+
+import { NodeKind } from '~/queries/schema/schema-general'
+import { PropertyFilterType, PropertyOperator } from '~/types'
+
+import { NegatedEventFilterNote } from './NegatedEventFilterNote'
+
+const meta: Meta<typeof NegatedEventFilterNote> = {
+ title: 'Experiments/NegatedEventFilterNote',
+ component: NegatedEventFilterNote,
+ args: {
+ launched: false,
+ groupTypeIndex: null,
+ config: {
+ kind: NodeKind.ExperimentEventExposureConfig,
+ event: '$pageview',
+ properties: [
+ {
+ type: PropertyFilterType.Event,
+ key: '$current_url',
+ operator: PropertyOperator.NotIContains,
+ value: '/internal',
+ },
+ ],
+ },
+ },
+}
+export default meta
+
+export const BeforeLaunch: StoryObj<typeof NegatedEventFilterNote> = {}
diff --git a/products/experiments/frontend/components/NegatedEventFilterNote.tsx b/products/experiments/frontend/components/NegatedEventFilterNote.tsx
new file mode 100644
index 000000000000..e7ea5b17cc38
--- /dev/null
+++ b/products/experiments/frontend/components/NegatedEventFilterNote.tsx
@@ -0,0 +1,36 @@
+import { useValues } from 'kea'
+
+import { capitalizeFirstLetter } from 'lib/utils/strings'
+import { hasNegatedEventFilter } from 'scenes/experiments/exposureContract'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { groupsModel } from '~/models/groupsModel'
+import type { ExperimentExposureConfig } from '~/queries/schema/schema-general'
+
+export function NegatedEventFilterNote({
+ config,
+ launched,
+ groupTypeIndex,
+}: {
+ config: ExperimentExposureConfig | undefined
+ launched: boolean
+ /** The aggregation group of the experiment's flag, or null when the flag counts persons. */
+ groupTypeIndex: number | null | undefined
+}): JSX.Element | null {
+ const { aggregationLabel } = useValues(groupsModel)
+ const { currentTeam } = useValues(teamLogic)
+ const personsOnEventsMode =
+ currentTeam?.modifiers?.personsOnEventsMode ?? currentTeam?.default_modifiers?.personsOnEventsMode
+ if (!hasNegatedEventFilter(config, groupTypeIndex, personsOnEventsMode)) {
+ return null
+ }
+ const units = aggregationLabel(groupTypeIndex, true).plural
+ return (
+ <div className="text-xs text-muted mt-1">
+ These filters remove individual events, not {units}. {capitalizeFirstLetter(units)} still count as long as
+ one of their events of this type passes the filters.
+ {!launched &&
+ ` To keep ${units} out of the experiment, exclude them in the feature flag's release conditions.`}
+ </div>
+ )
+}
diff --git a/products/experiments/skills/configuring-experiment-analytics/SKILL.md b/products/experiments/skills/configuring-experiment-analytics/SKILL.md
index c9673a8ae258..1a28030637d8 100644
--- a/products/experiments/skills/configuring-experiment-analytics/SKILL.md
+++ b/products/experiments/skills/configuring-experiment-analytics/SKILL.md
@@ -18,6 +18,10 @@ Two options:
1. **Default exposure event** — users are included when the experiment's default exposure event fires for the experiment's flag: `$feature_flag_called`, or `$experiment_exposure` for newer experiments. Which one applies is resolved server-side — read `resolved_exposure_event` from `experiment-get` rather than assuming either name (both events carry the same properties). When it is `$feature_flag_called`, also read `$experiment_exposure` (`event IN ('$feature_flag_called', '$experiment_exposure')`), and count persons, not rows. This is the standard approach — it means a user is included only when they actually encounter the feature flag in your code.
2. **Custom exposure event** — users are included when a specific custom event fires. Use this when you want tighter control over who enters the analysis (e.g., only users who actually visit the page where the experiment runs).
+Filters on the exposure event remove individual events, not users.
+A user still counts as long as one of their exposure events passes the filters.
+To keep users out of the experiment, exclude them in the flag's release conditions before launch (see `configuring-experiment-rollout`).
+
### Multiple variant handling
When a user is exposed to multiple variants (e.g., due to flag changes or race conditions):
diff --git a/products/experiments/skills/diagnosing-experiment-health/references/numbers-vs-sql.md b/products/experiments/skills/diagnosing-experiment-health/references/numbers-vs-sql.md
index eb194fa9bcc6..8e43ae7f3a54 100644
--- a/products/experiments/skills/diagnosing-experiment-health/references/numbers-vs-sql.md
+++ b/products/experiments/skills/diagnosing-experiment-health/references/numbers-vs-sql.md
@@ -254,6 +254,12 @@ debug stats discrepancies via the Recordings tab.
An exposure that a server sends carries no session id, or one that matches no recording, so no recording can be tied to the exposure event itself.
The person's other sessions can still have recordings, when replay is on for the project and the session was sampled. Find them by person, or by the flag's value on the session's events.
+**A recording that an exposure filter should have left out** `[MEDIUM]`.
+Filters on the exposure event remove individual events, not people.
+A person still counts as long as one of their exposure events passes the filters, so their sessions can show the filtered page or value.
+To keep people out of the experiment, exclude them in the flag's release conditions before launch.
+On a running experiment that edit is a mid-run change: new exposures stop and nobody moves to another variant, but earlier exposures stay counted (A6 in `bias-and-skew.md`, E2 in `mid-run-changes.md`).
+
**Recommend:** use recordings to _qualitatively_ understand variant differences (what users actually
experienced), not to _audit_ the numbers.