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.

chore(experiments): funnel exposure event contract through shared helper (#69944)

Anderscdab025bb4b6
diff --git a/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx b/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx
index 35415b4fd98d..a2a42b28ce98 100644
--- a/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx
+++ b/frontend/src/scenes/experiments/ExperimentForm/ExposureCriteriaPanel.tsx
@@ -12,12 +12,13 @@ import { ExperimentEventExposureConfig, ExperimentExposureCriteria, NodeKind } f
import type { Experiment, FilterType } from '~/types'
import { SelectableCard } from '../components/SelectableCard'
+import { EXPOSURE_DEFAULT_EVENT } from '../exposureContract'
import { commonActionFilterProps } from '../Metrics/Selectors'
import { exposureConfigToFilter, filterToExposureConfig } from '../utils'
const DEFAULT_EXPOSURE_CONFIG: ExperimentEventExposureConfig = {
kind: NodeKind.ExperimentEventExposureConfig,
- event: '$feature_flag_called',
+ event: EXPOSURE_DEFAULT_EVENT,
properties: [],
}
@@ -77,7 +78,7 @@ function ExposureCriteriaFields({
title="Default"
description={
<>
- When a <LemonTag>$feature_flag_called</LemonTag> event is recorded, a user is considered{' '}
+ When a <LemonTag>{EXPOSURE_DEFAULT_EVENT}</LemonTag> event is recorded, a user is considered{' '}
<strong>exposed</strong> to the experiment.
</>
}
@@ -189,7 +190,7 @@ export function ExposureCriteriaPanel({ experiment, onChange, compact }: Exposur
<div>
<div>Feature flag is called</div>
<div className="text-xs text-muted font-normal">
- When $feature_flag_called is recorded
+ When {EXPOSURE_DEFAULT_EVENT} is recorded
</div>
</div>
),
diff --git a/frontend/src/scenes/experiments/ExperimentMetricForm.tsx b/frontend/src/scenes/experiments/ExperimentMetricForm.tsx
index 6b5fa99558cd..14c719c6fad3 100644
--- a/frontend/src/scenes/experiments/ExperimentMetricForm.tsx
+++ b/frontend/src/scenes/experiments/ExperimentMetricForm.tsx
@@ -41,6 +41,7 @@ import {
ExperimentRatioMetricOutlierHandling,
} from './ExperimentMetricOutlierHandling'
import { ExperimentMetricThreshold, isThresholdAvailableForMath } from './ExperimentMetricThreshold'
+import { EXPOSURE_DEFAULT_EVENT } from './exposureContract'
import { filterToMetricConfig, filterToMetricSource } from './metricQueryUtils'
import { createFilterForSource, getFilter } from './metricQueryUtils'
import { commonActionFilterProps } from './Metrics/Selectors'
@@ -55,7 +56,7 @@ import {
export function getExposureCriteriaLabel(exposureCriteria: ExperimentExposureCriteria | undefined): string {
const exposureConfig = exposureCriteria?.exposure_config
if (!exposureConfig) {
- return '$feature_flag_called'
+ return EXPOSURE_DEFAULT_EVENT
}
return getExposureConfigDisplayName(exposureConfig)
@@ -306,7 +307,8 @@ export function ExperimentMetricForm({
</>
) : (
<>
- Counts only after exposure event (<LemonTag>$feature_flag_called</LemonTag> by default)
+ Counts only after exposure event (<LemonTag>{EXPOSURE_DEFAULT_EVENT}</LemonTag> by
+ default)
</>
)}
<Tooltip
diff --git a/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx b/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx
index 8199e631bb2f..8c34e4a7d00d 100644
--- a/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx
+++ b/frontend/src/scenes/experiments/ExperimentView/ExposureCriteria.tsx
@@ -13,6 +13,7 @@ import { ExperimentExposureCriteria, NodeKind } from '~/queries/schema/schema-ge
import { FilterType } from '~/types'
import { SelectableCard } from '../components/SelectableCard'
+import { EXPOSURE_DEFAULT_EVENT } from '../exposureContract'
import { commonActionFilterProps } from '../Metrics/Selectors'
import { exposureConfigToFilter, filterToExposureConfig } from '../utils'
import { exposureCriteriaModalLogic } from './exposureCriteriaModalLogic'
@@ -68,7 +69,7 @@ export function ExposureCriteriaModal({ onSave }: ExposureCriteriaModalProps): J
title="Default"
description={
<>
- When a <LemonTag>$feature_flag_called</LemonTag> event is recorded, a user is considered{' '}
+ When a <LemonTag>{EXPOSURE_DEFAULT_EVENT}</LemonTag> event is recorded, a user is considered{' '}
<strong>exposed</strong> to the experiment and included in the analysis.
</>
}
@@ -84,8 +85,8 @@ export function ExposureCriteriaModal({ onSave }: ExposureCriteriaModalProps): J
title="Custom"
description={
<>
- If you can't rely on the <LemonTag>$feature_flag_called</LemonTag> event, you can select a
- custom event to signal that users reached the part of your app where the experiment runs.
+ If you can't rely on the <LemonTag>{EXPOSURE_DEFAULT_EVENT}</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.
</>
}
@@ -95,7 +96,7 @@ export function ExposureCriteriaModal({ onSave }: ExposureCriteriaModalProps): J
...exposureCriteria,
exposure_config: {
kind: NodeKind.ExperimentEventExposureConfig,
- event: '$feature_flag_called',
+ event: EXPOSURE_DEFAULT_EVENT,
properties: [],
},
})
diff --git a/frontend/src/scenes/experiments/ExperimentView/Exposures.tsx b/frontend/src/scenes/experiments/ExperimentView/Exposures.tsx
index 442a3a5ee9c2..5d066682e201 100644
--- a/frontend/src/scenes/experiments/ExperimentView/Exposures.tsx
+++ b/frontend/src/scenes/experiments/ExperimentView/Exposures.tsx
@@ -18,6 +18,7 @@ import {
import { EXPERIMENT_VARIANT_MULTIPLE } from '../constants'
import { experimentLogic } from '../experimentLogic'
+import { EXPOSURE_DEFAULT_EVENT } from '../exposureContract'
import { useChartColors } from '../MetricsView/shared/colors'
import { filterLowMultipleVariant, getExposureConfigDisplayName, resolveMultipleVariantHandling } from '../utils'
import { exposureCriteriaModalLogic } from './exposureCriteriaModalLogic'
@@ -223,7 +224,7 @@ function ExposuresChart({ exposures, axisLineColor }: ExposuresChartProps): JSX.
function getExposureCriteriaLabel(exposureCriteria: ExperimentExposureCriteria | undefined): string {
const exposureConfig = exposureCriteria?.exposure_config
if (!exposureConfig) {
- return 'Default ($feature_flag_called)'
+ return `Default (${EXPOSURE_DEFAULT_EVENT})`
}
const displayName = getExposureConfigDisplayName(exposureConfig)
diff --git a/frontend/src/scenes/experiments/MetricsView/shared/ErrorChecklist.tsx b/frontend/src/scenes/experiments/MetricsView/shared/ErrorChecklist.tsx
index acbd7bb96ed2..625d863d2466 100644
--- a/frontend/src/scenes/experiments/MetricsView/shared/ErrorChecklist.tsx
+++ b/frontend/src/scenes/experiments/MetricsView/shared/ErrorChecklist.tsx
@@ -11,6 +11,11 @@ import { NodeKind } from '~/queries/schema/schema-general'
import { ActivityTab, Experiment, InsightType, MultivariateFlagVariant } from '~/types'
import { experimentLogic } from '../../experimentLogic'
+import {
+ EXPOSURE_DEFAULT_EVENT,
+ EXPOSURE_FEATURE_FLAG_PROPERTY,
+ featureFlagVariantProperty,
+} from '../../exposureContract'
export enum ResultErrorCode {
NO_CONTROL_VARIANT = 'no-control-variant',
@@ -58,7 +63,7 @@ function ChecklistItem({
const requiredEvent =
insightType === InsightType.TRENDS
? hasMissingExposure
- ? metric.exposure_query?.series[0]?.event || '$feature_flag_called'
+ ? metric.exposure_query?.series[0]?.event || EXPOSURE_DEFAULT_EVENT
: metric.count_query?.series[0]?.event
: metric.funnels_query?.series[0]?.event
@@ -67,13 +72,18 @@ function ChecklistItem({
full: true,
source: {
kind: NodeKind.EventsQuery,
- select: ['*', 'event', `properties."$feature/${experiment.feature_flag?.key}"`, 'timestamp'],
+ select: [
+ '*',
+ 'event',
+ `properties."${featureFlagVariantProperty(experiment.feature_flag?.key ?? '')}"`,
+ 'timestamp',
+ ],
orderBy: ['timestamp DESC'],
after: experiment.start_date,
event: requiredEvent,
properties: [
{
- key: `$feature/${experiment.feature_flag?.key}`,
+ key: featureFlagVariantProperty(experiment.feature_flag?.key ?? ''),
value: hasMissingExposure
? variants.map((variant) => variant.key)
: errorCode === ResultErrorCode.NO_CONTROL_VARIANT
@@ -85,7 +95,7 @@ function ChecklistItem({
...(hasMissingExposure
? [
{
- key: '$feature_flag',
+ key: EXPOSURE_FEATURE_FLAG_PROPERTY,
value: [experiment.feature_flag?.key],
operator: 'exact',
type: 'event',
diff --git a/frontend/src/scenes/experiments/MetricsView/shared/MetricHeader.tsx b/frontend/src/scenes/experiments/MetricsView/shared/MetricHeader.tsx
index 7f69fe31ff62..8541675c8202 100644
--- a/frontend/src/scenes/experiments/MetricsView/shared/MetricHeader.tsx
+++ b/frontend/src/scenes/experiments/MetricsView/shared/MetricHeader.tsx
@@ -10,10 +10,10 @@ import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { experimentMetricsLogic } from 'scenes/experiments/experimentMetricsLogic'
import { isMetricThresholdCueVisible } from 'scenes/experiments/ExperimentMetricThreshold'
+import { EXPOSURE_DEFAULT_EVENT, getExposureEventAndProperty } from 'scenes/experiments/exposureContract'
import { METRIC_CONTEXTS, experimentMetricModalLogic } from 'scenes/experiments/Metrics/experimentMetricModalLogic'
import { sharedMetricDetailsModalLogic } from 'scenes/experiments/Metrics/sharedMetricDetailsModalLogic'
import { modalsLogic } from 'scenes/experiments/modalsLogic'
-import { isEventExposureConfig } from 'scenes/experiments/utils'
import { urls } from 'scenes/urls'
import type { Breakdown, EventsNode, ExperimentMetric } from '~/queries/schema/schema-general'
@@ -26,17 +26,11 @@ import { getMetricTag } from './utils'
const MAX_BREAKDOWNS = 3
// Helper function to get the exposure event from experiment
-const getExposureEvent = (experiment: Experiment): string => {
- const exposureConfig = experiment.exposure_criteria?.exposure_config
- if (!exposureConfig) {
- return '$feature_flag_called'
- }
- if (isEventExposureConfig(exposureConfig)) {
- return exposureConfig.event
- }
- // Fall back
- return '$feature_flag_called'
-}
+const getExposureEvent = (experiment: Experiment): string =>
+ getExposureEventAndProperty({
+ featureFlagKey: experiment.feature_flag_key,
+ exposureCriteria: experiment.exposure_criteria,
+ }).event ?? EXPOSURE_DEFAULT_EVENT
const AddBreakdownMenuItem = ({
experiment,
diff --git a/frontend/src/scenes/experiments/charts/funnel/StepBar.tsx b/frontend/src/scenes/experiments/charts/funnel/StepBar.tsx
index 57fdf9bd293e..99b5c0e39d03 100644
--- a/frontend/src/scenes/experiments/charts/funnel/StepBar.tsx
+++ b/frontend/src/scenes/experiments/charts/funnel/StepBar.tsx
@@ -9,6 +9,7 @@ import {
isExperimentFunnelMetric,
NodeKind,
} from '~/queries/schema/schema-general'
+import { EXPOSURE_DEFAULT_EVENT } from '~/scenes/experiments/exposureContract'
import { getExperimentVariants, getVariantColor } from '~/scenes/experiments/utils'
import { funnelTitle } from '~/scenes/trends/persons-modal/persons-modal-utils'
import { openPersonsModal } from '~/scenes/trends/persons-modal/PersonsModal'
@@ -97,7 +98,7 @@ function openExperimentPersonsModalForSeries({
// Add exposure configuration from experiment
exposureConfig: experiment?.exposure_criteria?.exposure_config || {
kind: NodeKind.ExperimentEventExposureConfig,
- event: '$feature_flag_called',
+ event: EXPOSURE_DEFAULT_EVENT,
properties: [],
},
multipleVariantHandling: experiment?.exposure_criteria?.multiple_variant_handling || 'exclude',
diff --git a/frontend/src/scenes/experiments/components/ResultsBreakdown/resultsBreakdownLogic.ts b/frontend/src/scenes/experiments/components/ResultsBreakdown/resultsBreakdownLogic.ts
index 52c66bf94145..2974097a2f10 100644
--- a/frontend/src/scenes/experiments/components/ResultsBreakdown/resultsBreakdownLogic.ts
+++ b/frontend/src/scenes/experiments/components/ResultsBreakdown/resultsBreakdownLogic.ts
@@ -15,6 +15,7 @@ import type {
TrendsQuery,
} from '~/queries/schema/schema-general'
import { ExperimentMetricType, NodeKind, isExperimentFunnelMetric } from '~/queries/schema/schema-general'
+import { getExposureEventAndProperty } from '~/scenes/experiments/exposureContract'
import {
addExposureToMetric,
compose,
@@ -109,10 +110,10 @@ export const resultsBreakdownLogic = kea<resultsBreakdownLogicType>([
filterTestAccounts: !!experiment.exposure_criteria?.filterTestAccounts,
dateRange: getExperimentDateRange(experiment),
breakdownFilter: {
- breakdown:
- exposureEventNode.event === '$feature_flag_called'
- ? '$feature_flag_response'
- : `$feature/${experiment.feature_flag_key}`,
+ breakdown: getExposureEventAndProperty({
+ featureFlagKey: experiment.feature_flag_key,
+ exposureCriteria: experiment.exposure_criteria,
+ }).variantProperty,
breakdown_type: 'event',
},
funnelsFilter: {
diff --git a/frontend/src/scenes/experiments/experimentLogic.tsx b/frontend/src/scenes/experiments/experimentLogic.tsx
index 45eab268b051..6b1d32800c31 100644
--- a/frontend/src/scenes/experiments/experimentLogic.tsx
+++ b/frontend/src/scenes/experiments/experimentLogic.tsx
@@ -88,6 +88,7 @@ import {
isLaunched,
isSingleVariantShipped,
} from './experimentsLogic'
+import { featureFlagVariantProperty } from './exposureContract'
import { holdoutsLogic } from './holdoutsLogic'
import {
legacyExpectedRunningTime,
@@ -1919,7 +1920,7 @@ export const experimentLogic = kea<experimentLogicType>([
date_to: values.experiment.end_date,
properties: [],
breakdown_filter: {
- breakdown: '$feature/' + values.experiment.feature_flag_key,
+ breakdown: featureFlagVariantProperty(values.experiment.feature_flag_key),
breakdown_type: 'event' as BreakdownType,
},
},
diff --git a/frontend/src/scenes/experiments/exposureContract.test.ts b/frontend/src/scenes/experiments/exposureContract.test.ts
new file mode 100644
index 000000000000..74738b85f005
--- /dev/null
+++ b/frontend/src/scenes/experiments/exposureContract.test.ts
@@ -0,0 +1,41 @@
+import { ExperimentExposureCriteria, NodeKind } from '~/queries/schema/schema-general'
+
+import { getExposureEventAndProperty } from './exposureContract'
+
+describe('exposureContract', () => {
+ // Guards the three-way branch that mirrors the backend `get_exposure_event_and_property`:
+ // action configs must yield `event: null` (actions match multiple events) so callers never
+ // filter action-based exposures down to a single event name.
+ it.each<[string, ExperimentExposureCriteria | undefined, { event: string | null; variantProperty: string }]>([
+ ['no exposure config', undefined, { event: '$feature_flag_called', variantProperty: '$feature_flag_response' }],
+ [
+ 'default $feature_flag_called config',
+ {
+ exposure_config: {
+ kind: NodeKind.ExperimentEventExposureConfig,
+ event: '$feature_flag_called',
+ properties: [],
+ },
+ },
+ { event: '$feature_flag_called', variantProperty: '$feature_flag_response' },
+ ],
+ [
+ 'custom event config',
+ {
+ exposure_config: {
+ kind: NodeKind.ExperimentEventExposureConfig,
+ event: 'checkout_started',
+ properties: [],
+ },
+ },
+ { event: 'checkout_started', variantProperty: '$feature/my-flag' },
+ ],
+ [
+ 'action config',
+ { exposure_config: { kind: NodeKind.ActionsNode, id: 42 } },
+ { event: null, variantProperty: '$feature/my-flag' },
+ ],
+ ])('resolves the exposure event and variant property for %s', (_name, exposureCriteria, expected) => {
+ expect(getExposureEventAndProperty({ featureFlagKey: 'my-flag', exposureCriteria })).toEqual(expected)
+ })
+})
diff --git a/frontend/src/scenes/experiments/exposureContract.ts b/frontend/src/scenes/experiments/exposureContract.ts
new file mode 100644
index 000000000000..32a48440c725
--- /dev/null
+++ b/frontend/src/scenes/experiments/exposureContract.ts
@@ -0,0 +1,57 @@
+import {
+ ExperimentEventExposureConfig,
+ ExperimentExposureConfig,
+ ExperimentExposureCriteria,
+ NodeKind,
+} from '~/queries/schema/schema-general'
+
+/**
+ * The flag exposure event contract for experiments. Mirrors the backend chokepoint
+ * `get_exposure_event_and_property` in
+ * products/experiments/backend/hogql_queries/exposure_query_logic.py so the event and
+ * variant-property decision lives in a single place on the frontend too.
+ */
+export const EXPOSURE_DEFAULT_EVENT = '$feature_flag_called'
+export const EXPOSURE_FEATURE_FLAG_RESPONSE_PROPERTY = '$feature_flag_response'
+export const EXPOSURE_FEATURE_FLAG_PROPERTY = '$feature_flag'
+
+/** The `$feature/<flag_key>` event property that carries the variant for custom exposure events. */
+export function featureFlagVariantProperty(featureFlagKey: string): string {
+ return `$feature/${featureFlagKey}`
+}
+
+function isEventConfig(config: ExperimentExposureConfig): config is ExperimentEventExposureConfig {
+ return config.kind === NodeKind.ExperimentEventExposureConfig || 'event' in config
+}
+
+/**
+ * Determines which event and variant property carry the exposure for an experiment.
+ *
+ * - No exposure config, or a `$feature_flag_called` config: the default event, with the variant on
+ * `$feature_flag_response`.
+ * - A custom exposure event: that event, with the variant on `$feature/<flag_key>`.
+ * - An action exposure config: `event` is `null` because an action can match multiple events, so no
+ * single event name applies (mirrors the backend returning `None`). Variant is on `$feature/<flag_key>`.
+ */
+export function getExposureEventAndProperty({
+ featureFlagKey,
+ exposureCriteria,
+}: {
+ featureFlagKey: string
+ exposureCriteria: ExperimentExposureCriteria | undefined
+}): { event: string | null; variantProperty: string } {
+ const exposureConfig = exposureCriteria?.exposure_config
+
+ // No config, or the default `$feature_flag_called` event: variant lives on `$feature_flag_response`.
+ if (!exposureConfig || (isEventConfig(exposureConfig) && exposureConfig.event === EXPOSURE_DEFAULT_EVENT)) {
+ return { event: EXPOSURE_DEFAULT_EVENT, variantProperty: EXPOSURE_FEATURE_FLAG_RESPONSE_PROPERTY }
+ }
+
+ // Custom exposure event: that event carries the variant on `$feature/<flag_key>`.
+ if (isEventConfig(exposureConfig)) {
+ return { event: exposureConfig.event, variantProperty: featureFlagVariantProperty(featureFlagKey) }
+ }
+
+ // Action config: actions can match multiple events, so there is no single event to filter on.
+ return { event: null, variantProperty: featureFlagVariantProperty(featureFlagKey) }
+}
diff --git a/frontend/src/scenes/experiments/metricQueryUtils.ts b/frontend/src/scenes/experiments/metricQueryUtils.ts
index c9565fa03b89..aa31b48e1ab6 100644
--- a/frontend/src/scenes/experiments/metricQueryUtils.ts
+++ b/frontend/src/scenes/experiments/metricQueryUtils.ts
@@ -32,6 +32,8 @@ import { setLatestVersionsOnQuery } from '~/queries/utils'
import type { Experiment, FilterType, IntervalType, MultivariateFlagVariant } from '~/types'
import { ChartDisplayType, ExperimentMetricMathType, PropertyFilterType, PropertyOperator } from '~/types'
+import { EXPOSURE_DEFAULT_EVENT, EXPOSURE_FEATURE_FLAG_PROPERTY, featureFlagVariantProperty } from './exposureContract'
+
/**
* We extract all the math properties from the EntityNode type so we can use them as
* options when creating a query. Tools like the running time calculator have to set
@@ -498,7 +500,7 @@ export const getExposureConfigEventsNode = (
options: { featureFlagKey: string; featureFlagVariants: MultivariateFlagVariant[] }
): EventsNode => {
const exposure_step_name = 'Experiment exposure'
- if (exposureConfig && exposureConfig.event !== '$feature_flag_called') {
+ if (exposureConfig && exposureConfig.event !== EXPOSURE_DEFAULT_EVENT) {
const { featureFlagKey, featureFlagVariants } = options
return {
kind: NodeKind.EventsNode,
@@ -507,7 +509,7 @@ export const getExposureConfigEventsNode = (
properties: [
...(exposureConfig.properties || []),
{
- key: `$feature/${featureFlagKey}`,
+ key: featureFlagVariantProperty(featureFlagKey),
type: PropertyFilterType.Event,
value: featureFlagVariants.map(({ key }) => key),
operator: PropertyOperator.Exact,
@@ -519,10 +521,10 @@ export const getExposureConfigEventsNode = (
return {
kind: NodeKind.EventsNode,
custom_name: exposure_step_name,
- event: '$feature_flag_called',
+ event: EXPOSURE_DEFAULT_EVENT,
properties: [
{
- key: '$feature_flag',
+ key: EXPOSURE_FEATURE_FLAG_PROPERTY,
type: PropertyFilterType.Event,
value: options.featureFlagKey,
operator: PropertyOperator.Exact,
diff --git a/frontend/src/scenes/experiments/utils.ts b/frontend/src/scenes/experiments/utils.ts
index af0984747b11..5feaacdef6f5 100644
--- a/frontend/src/scenes/experiments/utils.ts
+++ b/frontend/src/scenes/experiments/utils.ts
@@ -52,6 +52,12 @@ import type {
} from 'products/experiments/frontend/generated/api.schemas'
import { EXPERIMENT_VARIANT_MULTIPLE } from './constants'
+import {
+ EXPOSURE_DEFAULT_EVENT,
+ EXPOSURE_FEATURE_FLAG_PROPERTY,
+ EXPOSURE_FEATURE_FLAG_RESPONSE_PROPERTY,
+ featureFlagVariantProperty,
+} from './exposureContract'
import { SharedMetric } from './SharedMetrics/sharedMetricLogic'
const MULTIPLE_VARIANT_WARNING_THRESHOLD = 0.5 // on the 0-100 scale (0.5 = 0.5%)
@@ -144,7 +150,7 @@ function seriesToFilterLegacy(
type: 'events',
properties: [
{
- key: `$feature/${featureFlagKey}`,
+ key: featureFlagVariantProperty(featureFlagKey),
type: PropertyFilterType.Event,
value: [variantKey],
operator: PropertyOperator.Exact,
@@ -203,7 +209,7 @@ function createExposureFilter(
properties: [
...(exposureConfig.properties || []),
{
- key: `$feature/${featureFlagKey}`,
+ key: featureFlagVariantProperty(featureFlagKey),
type: PropertyFilterType.Event,
value: [variantKey],
operator: PropertyOperator.Exact,
@@ -230,23 +236,23 @@ export function getViewRecordingFilters(
const exposureCriteria = experiment.exposure_criteria?.exposure_config
if (
exposureCriteria &&
- !(isEventExposureConfig(exposureCriteria) && exposureCriteria.event === '$feature_flag_called')
+ !(isEventExposureConfig(exposureCriteria) && exposureCriteria.event === EXPOSURE_DEFAULT_EVENT)
) {
filters.push(createExposureFilter(exposureCriteria, experiment.feature_flag_key, variantKey))
} else {
filters.push({
- id: '$feature_flag_called',
- name: '$feature_flag_called',
+ id: EXPOSURE_DEFAULT_EVENT,
+ name: EXPOSURE_DEFAULT_EVENT,
type: 'events',
properties: [
{
- key: '$feature_flag_response',
+ key: EXPOSURE_FEATURE_FLAG_RESPONSE_PROPERTY,
type: PropertyFilterType.Event,
value: [variantKey],
operator: PropertyOperator.Exact,
},
{
- key: '$feature_flag',
+ key: EXPOSURE_FEATURE_FLAG_PROPERTY,
type: PropertyFilterType.Event,
value: experiment.feature_flag_key,
operator: PropertyOperator.Exact,
@@ -314,7 +320,7 @@ export function getViewRecordingFiltersLegacy(
type: 'events',
properties: [
{
- key: `$feature/${featureFlagKey}`,
+ key: featureFlagVariantProperty(featureFlagKey),
type: PropertyFilterType.Event,
value: [variantKey],
operator: PropertyOperator.Exact,
@@ -337,18 +343,18 @@ export function getViewRecordingFiltersLegacy(
}
} else {
filters.push({
- id: '$feature_flag_called',
- name: '$feature_flag_called',
+ id: EXPOSURE_DEFAULT_EVENT,
+ name: EXPOSURE_DEFAULT_EVENT,
type: 'events',
properties: [
{
- key: `$feature_flag_response`,
+ key: EXPOSURE_FEATURE_FLAG_RESPONSE_PROPERTY,
type: PropertyFilterType.Event,
value: [variantKey],
operator: PropertyOperator.Exact,
},
{
- key: '$feature_flag',
+ key: EXPOSURE_FEATURE_FLAG_PROPERTY,
type: PropertyFilterType.Event,
value: featureFlagKey,
operator: PropertyOperator.Exact,