: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(experiments): Add a warehouse-native source node and exposure config (#114634)
Juraj Majerikd25aeca29d4f
diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.tsindex 787a9367d7be..a64ceeeddd6a 100644--- a/frontend/src/lib/utils/eventUsageLogic.ts+++ b/frontend/src/lib/utils/eventUsageLogic.ts@@ -444,6 +444,15 @@ function getSourceProperties(source: ExperimentMetricSource | ExperimentExposurehas_math_hogql: false,}}+ if (source.kind === NodeKind.ExperimentWarehouseNativeNode) {+ return {+ source_kind: source.kind,+ is_data_warehouse: false,+ property_filter_count: 0,+ math_type: source.math,+ has_math_hogql: false,+ }+ }return {source_kind: source.kind,is_data_warehouse: source.kind === NodeKind.ExperimentDataWarehouseNode,diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 4e41446d58c4..a1d786bb6d8a 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -25936,6 +25936,9 @@},{"$ref": "#/definitions/ActionsNode"+ },+ {+ "$ref": "#/definitions/ExperimentWarehouseNativeExposureConfig"}]},@@ -25943,8 +25946,15 @@"additionalProperties": false,"properties": {"activation_config": {- "$ref": "#/definitions/ExperimentExposureConfig",- "description": "Additional event (or action) an entity must emit at/after their first default exposure event before they count as exposed; exposure time becomes this event's timestamp. Only valid with the default exposure event, not a custom `exposure_config`."+ "anyOf": [+ {+ "$ref": "#/definitions/ExperimentEventExposureConfig"+ },+ {+ "$ref": "#/definitions/ActionsNode"+ }+ ],+ "description": "Additional event (or action) an entity must emit at/after their first default exposure event before they count as exposed; exposure time becomes this event's timestamp. Only valid with the default exposure event, not a custom `exposure_config`. Warehouse-native activation has no defined semantics yet, so only events and actions apply here."},"exposure_config": {"$ref": "#/definitions/ExperimentExposureConfig"@@ -26613,6 +26623,9 @@},{"$ref": "#/definitions/ExperimentDataWarehouseNode"+ },+ {+ "$ref": "#/definitions/ExperimentWarehouseNativeNode"}],"required": ["kind"],@@ -26918,6 +26931,27 @@"required": ["metric_type", "numerator", "denominator"],"type": "object"},+ "ExperimentRetentionCompletion": {+ "$ref": "#/definitions/ExperimentRetentionCompletionUnion"+ },+ "ExperimentRetentionCompletionUnion": {+ "discriminator": {+ "propertyName": "kind"+ },+ "oneOf": [+ {+ "$ref": "#/definitions/EventsNode"+ },+ {+ "$ref": "#/definitions/ActionsNode"+ },+ {+ "$ref": "#/definitions/ExperimentDataWarehouseNode"+ }+ ],+ "required": ["kind"],+ "type": "object"+ },"ExperimentRetentionMetric": {"additionalProperties": false,"properties": {@@ -26925,7 +26959,7 @@"$ref": "#/definitions/BreakdownFilter"},"completion_event": {- "$ref": "#/definitions/ExperimentMetricSource"+ "$ref": "#/definitions/ExperimentRetentionCompletion"},"conversion_window": {"$ref": "#/definitions/integer"@@ -26999,7 +27033,7 @@"additionalProperties": false,"properties": {"completion_event": {- "$ref": "#/definitions/ExperimentMetricSource"+ "$ref": "#/definitions/ExperimentRetentionCompletion"},"metric_type": {"const": "retention",@@ -27387,6 +27421,76 @@"required": ["key", "method", "number_of_samples", "sum", "sum_squares"],"type": "object"},+ "ExperimentWarehouseNativeExposureConfig": {+ "additionalProperties": false,+ "description": "Exposures that live in the customer's warehouse, read through a direct connection. An experiment with this exposure runs entirely in the warehouse, so every metric source must be an `ExperimentWarehouseNativeNode` on the same connection.",+ "properties": {+ "connection_id": {+ "description": "The direct-query source (an ExternalDataSource id) the SQL is written for.",+ "type": "string"+ },+ "kind": {+ "const": "ExperimentWarehouseNativeExposureConfig",+ "type": "string"+ },+ "query": {+ "description": "Read-only SQL in the warehouse's dialect, returning one row per exposure with `entity_id`, `variant` and `timestamp` columns. PostHog keeps the first exposure per entity and applies the experiment's date range and multiple-variant handling.",+ "type": "string"+ },+ "response": {+ "type": "object"+ },+ "version": {+ "description": "version of the node, used for schema migrations",+ "type": "number"+ }+ },+ "required": ["connection_id", "kind", "query"],+ "type": "object"+ },+ "ExperimentWarehouseNativeMathType": {+ "description": "The subset of `ExperimentMetricMathType` a warehouse-native source supports, with the same values.",+ "enum": ["total", "sum"],+ "type": "string"+ },+ "ExperimentWarehouseNativeNode": {+ "additionalProperties": false,+ "description": "Outcome rows that live in the customer's warehouse, read through a direct connection. PostHog joins them to the experiment's exposures and aggregates them inside the warehouse, so the SQL never mentions variants or exposures and only per-variant aggregates leave the warehouse. Distinct from `ExperimentDataWarehouseNode`, which reads tables synced into PostHog. It does not extend `EntityNode`: property filters and the other event settings cannot apply to SQL PostHog does not parse, so the shape lists every supported field. Only mean and ratio metrics accept it.",+ "properties": {+ "connection_id": {+ "description": "The direct-query source (an ExternalDataSource id) the SQL is written for.",+ "type": "string"+ },+ "custom_name": {+ "type": "string"+ },+ "kind": {+ "const": "ExperimentWarehouseNativeNode",+ "type": "string"+ },+ "math": {+ "$ref": "#/definitions/ExperimentWarehouseNativeMathType",+ "description": "How to aggregate the rows per entity. Defaults to `total` (row count)."+ },+ "math_property": {+ "description": "The numeric column `math` reads. Required when `math` is `sum`. One SQL relation can serve several metrics, each reading a different column.",+ "type": "string"+ },+ "query": {+ "description": "Read-only SQL in the warehouse's dialect, returning one row per outcome with `entity_id` and `timestamp` columns plus any numeric columns a metric can measure.",+ "type": "string"+ },+ "response": {+ "type": "object"+ },+ "version": {+ "description": "version of the node, used for schema migrations",+ "type": "number"+ }+ },+ "required": ["connection_id", "kind", "query"],+ "type": "object"+ },"ExternalQueryError": {"additionalProperties": false,"properties": {@@ -40026,10 +40130,12 @@"ExperimentQuery","ExperimentExposureQuery","ExperimentEventExposureConfig",+ "ExperimentWarehouseNativeExposureConfig","ExperimentActorsQuery","ExperimentTrendsQuery","ExperimentFunnelsQuery","ExperimentDataWarehouseNode",+ "ExperimentWarehouseNativeNode","ExperimentExposureNode","DatabaseSchemaQuery","SuggestedQuestionsQuery",diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 47f9e9fc2dec..bee4689948a4 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -169,10 +169,12 @@ export enum NodeKind {ExperimentQuery = 'ExperimentQuery',ExperimentExposureQuery = 'ExperimentExposureQuery',ExperimentEventExposureConfig = 'ExperimentEventExposureConfig',+ ExperimentWarehouseNativeExposureConfig = 'ExperimentWarehouseNativeExposureConfig',ExperimentActorsQuery = 'ExperimentActorsQuery',ExperimentTrendsQuery = 'ExperimentTrendsQuery',ExperimentFunnelsQuery = 'ExperimentFunnelsQuery',ExperimentDataWarehouseNode = 'ExperimentDataWarehouseNode',+ ExperimentWarehouseNativeNode = 'ExperimentWarehouseNativeNode',ExperimentExposureNode = 'ExperimentExposureNode',// Database metadata@@ -5862,15 +5864,19 @@ export interface ExperimentTrendsQuery {fingerprint?: string}-export type ExperimentExposureConfig = ExperimentEventExposureConfig | ActionsNode+export type ExperimentExposureConfig =+ | ExperimentEventExposureConfig+ | ActionsNode+ | ExperimentWarehouseNativeExposureConfigexport interface ExperimentExposureCriteria {filterTestAccounts?: booleanexposure_config?: ExperimentExposureConfig/** Additional event (or action) an entity must emit at/after their first default exposure* event before they count as exposed; exposure time becomes this event's timestamp.- * Only valid with the default exposure event, not a custom `exposure_config`. */- activation_config?: ExperimentExposureConfig+ * Only valid with the default exposure event, not a custom `exposure_config`. Warehouse-native+ * activation has no defined semantics yet, so only events and actions apply here. */+ activation_config?: ExperimentEventExposureConfig | ActionsNodemultiple_variant_handling?: 'exclude' | 'first_seen'}@@ -5880,6 +5886,19 @@ export interface ExperimentEventExposureConfig extends Node {properties: AnyPropertyFilter[]}+/** Exposures that live in the customer's warehouse, read through a direct connection. An experiment+ * with this exposure runs entirely in the warehouse, so every metric source must be an+ * `ExperimentWarehouseNativeNode` on the same connection. */+export interface ExperimentWarehouseNativeExposureConfig extends Node {+ kind: NodeKind.ExperimentWarehouseNativeExposureConfig+ /** The direct-query source (an ExternalDataSource id) the SQL is written for. */+ connection_id: string+ /** Read-only SQL in the warehouse's dialect, returning one row per exposure with `entity_id`,+ * `variant` and `timestamp` columns. PostHog keeps the first exposure per entity and applies+ * the experiment's date range and multiple-variant handling. */+ query: string+}+// ── Slim API types for experiment create/update ──────────────────────// Simplified versions of the full query types: they drop the nested// metric/node machinery (EventsNode, ExperimentMeanMetric, …) the@@ -6134,6 +6153,33 @@ export interface ExperimentDataWarehouseNode extends EntityNode {data_warehouse_join_key: string}+/** The subset of `ExperimentMetricMathType` a warehouse-native source supports, with the same values. */+export enum ExperimentWarehouseNativeMathType {+ TotalCount = 'total',+ Sum = 'sum',+}++/** Outcome rows that live in the customer's warehouse, read through a direct connection. PostHog joins+ * them to the experiment's exposures and aggregates them inside the warehouse, so the SQL never+ * mentions variants or exposures and only per-variant aggregates leave the warehouse. Distinct from+ * `ExperimentDataWarehouseNode`, which reads tables synced into PostHog. It does not extend+ * `EntityNode`: property filters and the other event settings cannot apply to SQL PostHog does not+ * parse, so the shape lists every supported field. Only mean and ratio metrics accept it. */+export interface ExperimentWarehouseNativeNode extends Node {+ kind: NodeKind.ExperimentWarehouseNativeNode+ /** The direct-query source (an ExternalDataSource id) the SQL is written for. */+ connection_id: string+ /** Read-only SQL in the warehouse's dialect, returning one row per outcome with `entity_id` and+ * `timestamp` columns plus any numeric columns a metric can measure. */+ query: string+ /** How to aggregate the rows per entity. Defaults to `total` (row count). */+ math?: ExperimentWarehouseNativeMathType+ /** The numeric column `math` reads. Required when `math` is `sum`. One SQL relation can serve+ * several metrics, each reading a different column. */+ math_property?: string+ custom_name?: string+}+// Named separately from `ExperimentMetricSource` so the JSDoc `@discriminator` tag// can attach without tripping ts-json-schema-generator's dedup (same workaround// pattern as `ExperimentMetricUnion = ExperimentMetric`). The alias is the public@@ -6141,7 +6187,11 @@ export interface ExperimentDataWarehouseNode extends EntityNode {/*** @discriminator kind*/-export type ExperimentMetricSourceUnion = EventsNode | ActionsNode | ExperimentDataWarehouseNode+export type ExperimentMetricSourceUnion =+ | EventsNode+ | ActionsNode+ | ExperimentDataWarehouseNode+ | ExperimentWarehouseNativeNodeexport type ExperimentMetricSource = ExperimentMetricSourceUnion@@ -6173,6 +6223,13 @@ export type ExperimentRetentionStartUnion =export type ExperimentRetentionStart = ExperimentRetentionStartUnion+/**+ * @discriminator kind+ */+export type ExperimentRetentionCompletionUnion = EventsNode | ActionsNode | ExperimentDataWarehouseNode++export type ExperimentRetentionCompletion = ExperimentRetentionCompletionUnion+export type ExperimentMeanMetric = ExperimentMetricBaseProperties &ExperimentMetricOutlierHandling & {metric_type: ExperimentMetricType.MEAN@@ -6218,7 +6275,7 @@ export type ExperimentRetentionMetric = ExperimentMetricBaseProperties & {// start resolves to the experiment's own exposure event at query time.start_event: ExperimentRetentionStart// Event that defines the completion of the retention window- completion_event: ExperimentMetricSource+ completion_event: ExperimentRetentionCompletion// Start of the retention windowretention_window_start: integerdiff --git a/frontend/src/queries/validators.js b/frontend/src/queries/validators.jsindex bf9cc96c0ae8..ebe3502f50cc 100644--- a/frontend/src/queries/validators.js+++ b/frontend/src/queries/validators.js@@ -8652,6 +8652,7 @@ const schema89 = {{ $ref: '#/definitions/EventsNode' },{ $ref: '#/definitions/ActionsNode' },{ $ref: '#/definitions/ExperimentDataWarehouseNode' },+ { $ref: '#/definitions/ExperimentWarehouseNativeNode' },],required: ['kind'],type: 'object',@@ -11330,6 +11331,296 @@ function validate113(data, { instancePath = '', parentData, parentDataProperty,validate113.errors = vErrorsreturn errors === 0}+const schema106 = {+ additionalProperties: false,+ description:+ "Outcome rows that live in the customer's warehouse, read through a direct connection. PostHog joins them to the experiment's exposures and aggregates them inside the warehouse, so the SQL never mentions variants or exposures and only per-variant aggregates leave the warehouse. Distinct from `ExperimentDataWarehouseNode`, which reads tables synced into PostHog. It does not extend `EntityNode`: property filters and the other event settings cannot apply to SQL PostHog does not parse, so the shape lists every supported field. Only mean and ratio metrics accept it.",+ properties: {+ connection_id: {+ description: 'The direct-query source (an ExternalDataSource id) the SQL is written for.',+ type: 'string',+ },+ custom_name: { type: 'string' },+ kind: { const: 'ExperimentWarehouseNativeNode', type: 'string' },+ math: {+ $ref: '#/definitions/ExperimentWarehouseNativeMathType',+ description: 'How to aggregate the rows per entity. Defaults to `total` (row count).',+ },+ math_property: {+ description:+ 'The numeric column `math` reads. Required when `math` is `sum`. One SQL relation can serve several metrics, each reading a different column.',+ type: 'string',+ },+ query: {+ description:+ "Read-only SQL in the warehouse's dialect, returning one row per outcome with `entity_id` and `timestamp` columns plus any numeric columns a metric can measure.",+ type: 'string',+ },+ response: { type: 'object' },+ version: { description: 'version of the node, used for schema migrations', type: 'number' },+ },+ required: ['connection_id', 'kind', 'query'],+ type: 'object',+}+const schema107 = {+ description: 'The subset of `ExperimentMetricMathType` a warehouse-native source supports, with the same values.',+ enum: ['total', 'sum'],+ type: 'string',+}+function validate119(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {+ let vErrors = null+ let errors = 0+ if (errors === 0) {+ if (data && typeof data == 'object' && !Array.isArray(data)) {+ let missing0+ if (+ (data.connection_id === undefined && (missing0 = 'connection_id')) ||+ (data.kind === undefined && (missing0 = 'kind')) ||+ (data.query === undefined && (missing0 = 'query'))+ ) {+ validate119.errors = [+ {+ instancePath,+ schemaPath: '#/required',+ keyword: 'required',+ params: { missingProperty: missing0 },+ message: "must have required property '" + missing0 + "'",+ },+ ]+ return false+ } else {+ const _errs1 = errors+ for (const key0 in data) {+ if (+ !(+ key0 === 'connection_id' ||+ key0 === 'custom_name' ||+ key0 === 'kind' ||+ key0 === 'math' ||+ key0 === 'math_property' ||+ key0 === 'query' ||+ key0 === 'response' ||+ key0 === 'version'+ )+ ) {+ validate119.errors = [+ {+ instancePath,+ schemaPath: '#/additionalProperties',+ keyword: 'additionalProperties',+ params: { additionalProperty: key0 },+ message: 'must NOT have additional properties',+ },+ ]+ return false+ break+ }+ }+ if (_errs1 === errors) {+ if (data.connection_id !== undefined) {+ const _errs2 = errors+ if (typeof data.connection_id !== 'string') {+ validate119.errors = [+ {+ instancePath: instancePath + '/connection_id',+ schemaPath: '#/properties/connection_id/type',+ keyword: 'type',+ params: { type: 'string' },+ message: 'must be string',+ },+ ]+ return false+ }+ var valid0 = _errs2 === errors+ } else {+ var valid0 = true+ }+ if (valid0) {+ if (data.custom_name !== undefined) {+ const _errs4 = errors+ if (typeof data.custom_name !== 'string') {+ validate119.errors = [+ {+ instancePath: instancePath + '/custom_name',+ schemaPath: '#/properties/custom_name/type',+ keyword: 'type',+ params: { type: 'string' },+ message: 'must be string',+ },+ ]+ return false+ }+ var valid0 = _errs4 === errors+ } else {+ var valid0 = true+ }+ if (valid0) {+ if (data.kind !== undefined) {+ let data2 = data.kind+ const _errs6 = errors+ if (typeof data2 !== 'string') {+ validate119.errors = [+ {+ instancePath: instancePath + '/kind',+ schemaPath: '#/properties/kind/type',+ keyword: 'type',+ params: { type: 'string' },+ message: 'must be string',+ },+ ]+ return false+ }+ if ('ExperimentWarehouseNativeNode' !== data2) {+ validate119.errors = [+ {+ instancePath: instancePath + '/kind',+ schemaPath: '#/properties/kind/const',+ keyword: 'const',+ params: { allowedValue: 'ExperimentWarehouseNativeNode' },+ message: 'must be equal to constant',+ },+ ]+ return false+ }+ var valid0 = _errs6 === errors+ } else {+ var valid0 = true+ }+ if (valid0) {+ if (data.math !== undefined) {+ let data3 = data.math+ const _errs8 = errors+ if (typeof data3 !== 'string') {+ validate119.errors = [+ {+ instancePath: instancePath + '/math',+ schemaPath: '#/definitions/ExperimentWarehouseNativeMathType/type',+ keyword: 'type',+ params: { type: 'string' },+ message: 'must be string',+ },+ ]+ return false+ }+ if (!(data3 === 'total' || data3 === 'sum')) {+ validate119.errors = [+ {+ instancePath: instancePath + '/math',+ schemaPath: '#/definitions/ExperimentWarehouseNativeMathType/enum',+ keyword: 'enum',+ params: { allowedValues: schema107.enum },+ message: 'must be equal to one of the allowed values',+ },+ ]+ return false+ }+ var valid0 = _errs8 === errors+ } else {+ var valid0 = true+ }+ if (valid0) {+ if (data.math_property !== undefined) {+ const _errs11 = errors+ if (typeof data.math_property !== 'string') {+ validate119.errors = [+ {+ instancePath: instancePath + '/math_property',+ schemaPath: '#/properties/math_property/type',+ keyword: 'type',+ params: { type: 'string' },+ message: 'must be string',+ },+ ]+ return false+ }+ var valid0 = _errs11 === errors+ } else {+ var valid0 = true+ }+ if (valid0) {+ if (data.query !== undefined) {+ const _errs13 = errors+ if (typeof data.query !== 'string') {+ validate119.errors = [+ {+ instancePath: instancePath + '/query',+ schemaPath: '#/properties/query/type',+ keyword: 'type',+ params: { type: 'string' },+ message: 'must be string',+ },+ ]+ return false+ }+ var valid0 = _errs13 === errors+ } else {+ var valid0 = true+ }+ if (valid0) {+ if (data.response !== undefined) {+ let data6 = data.response+ const _errs15 = errors+ if (!(data6 && typeof data6 == 'object' && !Array.isArray(data6))) {+ validate119.errors = [+ {+ instancePath: instancePath + '/response',+ schemaPath: '#/properties/response/type',+ keyword: 'type',+ params: { type: 'object' },+ message: 'must be object',+ },+ ]+ return false+ }+ var valid0 = _errs15 === errors+ } else {+ var valid0 = true+ }+ if (valid0) {+ if (data.version !== undefined) {+ let data7 = data.version+ const _errs17 = errors+ if (!(typeof data7 == 'number' && isFinite(data7))) {+ validate119.errors = [+ {+ instancePath: instancePath + '/version',+ schemaPath: '#/properties/version/type',+ keyword: 'type',+ params: { type: 'number' },+ message: 'must be number',+ },+ ]+ return false+ }+ var valid0 = _errs17 === errors+ } else {+ var valid0 = true+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ } else {+ validate119.errors = [+ {+ instancePath,+ schemaPath: '#/type',+ keyword: 'type',+ params: { type: 'object' },+ message: 'must be object',+ },+ ]+ return false+ }+ }+ validate119.errors = vErrors+ return errors === 0+}function validate98(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {let vErrors = nulllet errors = 0@@ -11374,6 +11665,21 @@ function validate98(data, { instancePath = '', parentData, parentDataProperty, rvalid0 = truepassing0 = 2}+ const _errs5 = errors+ if (!validate119(data, { instancePath, parentData, parentDataProperty, rootData })) {+ vErrors = vErrors === null ? validate119.errors : vErrors.concat(validate119.errors)+ errors = vErrors.length+ }+ var _valid0 = _errs5 === errors+ if (_valid0 && valid0) {+ valid0 = false+ passing0 = [passing0, 3]+ } else {+ if (_valid0) {+ valid0 = true+ passing0 = 3+ }+ }}}if (!valid0) {@@ -12070,7 +12376,7 @@ function validate93(data, { instancePath = '', parentData, parentDataProperty, rvalidate93.errors = vErrorsreturn errors === 0}-const schema106 = {+const schema108 = {additionalProperties: false,properties: {breakdownAttributionType: {@@ -12101,9 +12407,9 @@ const schema106 = {required: ['kind', 'metric_type', 'series'],type: 'object',}-const schema107 = { enum: ['first_touch', 'last_touch', 'all_events', 'step'], type: 'string' }-const schema110 = { enum: ['strict', 'unordered', 'ordered'], type: 'string' }-const schema112 = {+const schema109 = { enum: ['first_touch', 'last_touch', 'all_events', 'step'], type: 'string' }+const schema112 = { enum: ['strict', 'unordered', 'ordered'], type: 'string' }+const schema114 = {discriminator: { propertyName: 'kind' },oneOf: [{ $ref: '#/definitions/EventsNode' },@@ -12113,7 +12419,7 @@ const schema112 = {required: ['kind'],type: 'object',}-function validate123(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {+function validate125(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {let vErrors = nulllet errors = 0const _errs1 = errors@@ -12173,7 +12479,7 @@ function validate123(data, { instancePath = '', parentData, parentDataProperty,vErrors.push(err0)}errors++- validate123.errors = vErrors+ validate125.errors = vErrorsreturn false} else {errors = _errs1@@ -12189,7 +12495,7 @@ function validate123(data, { instancePath = '', parentData, parentDataProperty,if (data && typeof data == 'object' && !Array.isArray(data)) {let missing0if (data.kind === undefined && (missing0 = 'kind')) {- validate123.errors = [+ validate125.errors = [{instancePath,schemaPath: '#/required',@@ -12201,7 +12507,7 @@ function validate123(data, { instancePath = '', parentData, parentDataProperty,return false}} else {- validate123.errors = [+ validate125.errors = [{instancePath,schemaPath: '#/type',@@ -12213,10 +12519,10 @@ function validate123(data, { instancePath = '', parentData, parentDataProperty,return false}}- validate123.errors = vErrors+ validate125.errors = vErrorsreturn errors === 0}-function validate121(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {+function validate123(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {let vErrors = nulllet errors = 0if (errors === 0) {@@ -12227,7 +12533,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,(data.metric_type === undefined && (missing0 = 'metric_type')) ||(data.series === undefined && (missing0 = 'series'))) {- validate121.errors = [+ validate123.errors = [{instancePath,schemaPath: '#/required',@@ -12240,8 +12546,8 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,} else {const _errs1 = errorsfor (const key0 in data) {- if (!func2.call(schema106.properties, key0)) {- validate121.errors = [+ if (!func2.call(schema108.properties, key0)) {+ validate123.errors = [{instancePath,schemaPath: '#/additionalProperties',@@ -12259,7 +12565,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,let data0 = data.breakdownAttributionTypeconst _errs2 = errorsif (typeof data0 !== 'string') {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/breakdownAttributionType',schemaPath: '#/definitions/BreakdownAttributionType/type',@@ -12278,12 +12584,12 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,data0 === 'step')) {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/breakdownAttributionType',schemaPath: '#/definitions/BreakdownAttributionType/enum',keyword: 'enum',- params: { allowedValues: schema107.enum },+ params: { allowedValues: schema109.enum },message: 'must be equal to one of the allowed values',},]@@ -12298,7 +12604,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,let data1 = data.breakdownAttributionValueconst _errs5 = errorsif (!(typeof data1 == 'number' && !(data1 % 1) && !isNaN(data1) && isFinite(data1))) {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/breakdownAttributionValue',schemaPath: '#/properties/breakdownAttributionValue/type',@@ -12338,7 +12644,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,if (!(typeof data3 == 'number' && !(data3 % 1) && !isNaN(data3) && isFinite(data3))) {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/conversion_window',schemaPath: '#/definitions/integer/type',@@ -12358,7 +12664,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,let data4 = data.conversion_window_unitconst _errs11 = errorsif (typeof data4 !== 'string') {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/conversion_window_unit',schemaPath: '#/definitions/FunnelConversionWindowTimeUnit/type',@@ -12379,7 +12685,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,data4 === 'month')) {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/conversion_window_unit',schemaPath: '#/definitions/FunnelConversionWindowTimeUnit/enum',@@ -12398,7 +12704,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,if (data.fingerprint !== undefined) {const _errs14 = errorsif (typeof data.fingerprint !== 'string') {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/fingerprint',schemaPath: '#/properties/fingerprint/type',@@ -12418,7 +12724,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,let data6 = data.funnel_order_typeconst _errs16 = errorsif (typeof data6 !== 'string') {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/funnel_order_type',schemaPath: '#/definitions/StepOrderValue/type',@@ -12436,12 +12742,12 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,data6 === 'ordered')) {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/funnel_order_type',schemaPath: '#/definitions/StepOrderValue/enum',keyword: 'enum',- params: { allowedValues: schema110.enum },+ params: { allowedValues: schema112.enum },message: 'must be equal to one of the allowed values',},]@@ -12456,7 +12762,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,let data7 = data.goalconst _errs19 = errorsif (typeof data7 !== 'string') {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/goal',schemaPath: '#/definitions/ExperimentMetricGoal/type',@@ -12468,7 +12774,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,return false}if (!(data7 === 'increase' || data7 === 'decrease')) {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/goal',schemaPath: '#/definitions/ExperimentMetricGoal/enum',@@ -12487,7 +12793,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,if (data.isSharedMetric !== undefined) {const _errs22 = errorsif (typeof data.isSharedMetric !== 'boolean') {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/isSharedMetric',schemaPath: '#/properties/isSharedMetric/type',@@ -12507,7 +12813,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,let data9 = data.kindconst _errs24 = errorsif (typeof data9 !== 'string') {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/kind',schemaPath: '#/properties/kind/type',@@ -12519,7 +12825,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,return false}if ('ExperimentMetric' !== data9) {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/kind',schemaPath: '#/properties/kind/const',@@ -12539,7 +12845,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,let data10 = data.metric_typeconst _errs26 = errorsif (typeof data10 !== 'string') {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/metric_type',schemaPath: '#/properties/metric_type/type',@@ -12551,7 +12857,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,return false}if ('funnel' !== data10) {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/metric_type',schemaPath:@@ -12571,7 +12877,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,if (data.name !== undefined) {const _errs28 = errorsif (typeof data.name !== 'string') {- validate121.errors = [+ validate123.errors = [{instancePath: instancePath + '/name',schemaPath: '#/properties/name/type',@@ -12597,7 +12903,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,!Array.isArray(data12))) {- validate121.errors = [+ validate123.errors = [{instancePath:instancePath + '/response',@@ -12625,7 +12931,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,for (let i0 = 0; i0 < len0; i0++) {const _errs34 = errorsif (- !validate123(data13[i0], {+ !validate125(data13[i0], {instancePath:instancePath +'/series/' +@@ -12637,9 +12943,9 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,) {vErrors =vErrors === null- ? validate123.errors+ ? validate125.errors: vErrors.concat(- validate123.errors+ validate125.errors)errors = vErrors.length}@@ -12649,7 +12955,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,}}} else {- validate121.errors = [+ validate123.errors = [{instancePath:instancePath +@@ -12678,7 +12984,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,isFinite(data15))) {- validate121.errors = [+ validate123.errors = [{instancePath:instancePath +@@ -12700,7 +13006,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,if (data.uuid !== undefined) {const _errs37 = errorsif (typeof data.uuid !== 'string') {- validate121.errors = [+ validate123.errors = [{instancePath:instancePath +@@ -12732,7 +13038,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,isFinite(data17))) {- validate121.errors = [+ validate123.errors = [{instancePath:instancePath +@@ -12772,7 +13078,7 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,}}} else {- validate121.errors = [+ validate123.errors = [{instancePath,schemaPath: '#/type',@@ -12784,10 +13090,10 @@ function validate121(data, { instancePath = '', parentData, parentDataProperty,return false}}- validate121.errors = vErrors+ validate123.errors = vErrorsreturn errors === 0}-const schema113 = {+const schema115 = {additionalProperties: false,properties: {breakdownFilter: { $ref: '#/definitions/BreakdownFilter' },@@ -12811,7 +13117,7 @@ const schema113 = {required: ['denominator', 'kind', 'metric_type', 'numerator'],type: 'object',}-const schema116 = {+const schema118 = {additionalProperties: false,properties: {ignore_zeros: { type: 'boolean' },@@ -12832,7 +13138,7 @@ const schema116 = {},type: 'object',}-function validate129(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {+function validate131(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {let vErrors = nulllet errors = 0if (errors === 0) {@@ -12844,7 +13150,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,(data.metric_type === undefined && (missing0 = 'metric_type')) ||(data.numerator === undefined && (missing0 = 'numerator'))) {- validate129.errors = [+ validate131.errors = [{instancePath,schemaPath: '#/required',@@ -12857,8 +13163,8 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,} else {const _errs1 = errorsfor (const key0 in data) {- if (!func2.call(schema113.properties, key0)) {- validate129.errors = [+ if (!func2.call(schema115.properties, key0)) {+ validate131.errors = [{instancePath,schemaPath: '#/additionalProperties',@@ -12894,7 +13200,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,let data1 = data.conversion_windowconst _errs3 = errorsif (!(typeof data1 == 'number' && !(data1 % 1) && !isNaN(data1) && isFinite(data1))) {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/conversion_window',schemaPath: '#/definitions/integer/type',@@ -12914,7 +13220,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,let data2 = data.conversion_window_unitconst _errs6 = errorsif (typeof data2 !== 'string') {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/conversion_window_unit',schemaPath: '#/definitions/FunnelConversionWindowTimeUnit/type',@@ -12935,7 +13241,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,data2 === 'month')) {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/conversion_window_unit',schemaPath: '#/definitions/FunnelConversionWindowTimeUnit/enum',@@ -12985,7 +13291,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,key1 === 'upper_bound_percentile')) {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath + '/denominator_outlier_handling',@@ -13004,7 +13310,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,if (data4.ignore_zeros !== undefined) {const _errs14 = errorsif (typeof data4.ignore_zeros !== 'boolean') {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13029,7 +13335,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,if (errors === _errs16) {if (typeof data6 == 'number' && isFinite(data6)) {if (data6 > 1 || isNaN(data6)) {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13044,7 +13350,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,return false} else {if (data6 < 0 || isNaN(data6)) {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13063,7 +13369,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,}}} else {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13089,7 +13395,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,if (errors === _errs18) {if (typeof data7 == 'number' && isFinite(data7)) {if (data7 > 1 || isNaN(data7)) {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13107,7 +13413,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,return false} else {if (data7 < 0 || isNaN(data7)) {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13126,7 +13432,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,}}} else {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13149,7 +13455,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,}}} else {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/denominator_outlier_handling',schemaPath:@@ -13170,7 +13476,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,if (data.fingerprint !== undefined) {const _errs20 = errorsif (typeof data.fingerprint !== 'string') {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/fingerprint',schemaPath: '#/properties/fingerprint/type',@@ -13190,7 +13496,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,let data9 = data.goalconst _errs22 = errorsif (typeof data9 !== 'string') {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/goal',schemaPath: '#/definitions/ExperimentMetricGoal/type',@@ -13202,7 +13508,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,return false}if (!(data9 === 'increase' || data9 === 'decrease')) {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/goal',schemaPath: '#/definitions/ExperimentMetricGoal/enum',@@ -13221,7 +13527,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,if (data.isSharedMetric !== undefined) {const _errs25 = errorsif (typeof data.isSharedMetric !== 'boolean') {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/isSharedMetric',schemaPath: '#/properties/isSharedMetric/type',@@ -13241,7 +13547,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,let data11 = data.kindconst _errs27 = errorsif (typeof data11 !== 'string') {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/kind',schemaPath: '#/properties/kind/type',@@ -13253,7 +13559,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,return false}if ('ExperimentMetric' !== data11) {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/kind',schemaPath: '#/properties/kind/const',@@ -13273,7 +13579,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,let data12 = data.metric_typeconst _errs29 = errorsif (typeof data12 !== 'string') {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/metric_type',schemaPath: '#/properties/metric_type/type',@@ -13285,7 +13591,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,return false}if ('ratio' !== data12) {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/metric_type',schemaPath: '#/properties/metric_type/const',@@ -13304,7 +13610,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,if (data.name !== undefined) {const _errs31 = errorsif (typeof data.name !== 'string') {- validate129.errors = [+ validate131.errors = [{instancePath: instancePath + '/name',schemaPath: '#/properties/name/type',@@ -13362,7 +13668,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,'upper_bound_percentile')) {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13393,7 +13699,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,typeof data15.ignore_zeros !=='boolean') {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13432,7 +13738,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,data17 > 1 ||isNaN(data17)) {- validate129.errors =+ validate131.errors =[{instancePath:@@ -13460,7 +13766,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,data17)) {- validate129.errors =+ validate131.errors =[{instancePath:@@ -13483,7 +13789,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,}}} else {- validate129.errors =+ validate131.errors =[{instancePath:@@ -13531,7 +13837,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,data18)) {- validate129.errors =+ validate131.errors =[{instancePath:@@ -13559,7 +13865,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,data18)) {- validate129.errors =+ validate131.errors =[{instancePath:@@ -13582,7 +13888,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,}}} else {- validate129.errors =+ validate131.errors =[{instancePath:@@ -13611,7 +13917,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,}}} else {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13641,7 +13947,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,!Array.isArray(data19))) {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath + '/response',@@ -13668,7 +13974,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,isFinite(data20))) {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13690,7 +13996,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,if (data.uuid !== undefined) {const _errs48 = errorsif (typeof data.uuid !== 'string') {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13722,7 +14028,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,isFinite(data22))) {- validate129.errors = [+ validate131.errors = [{instancePath:instancePath +@@ -13762,7 +14068,7 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,}}} else {- validate129.errors = [+ validate131.errors = [{instancePath,schemaPath: '#/type',@@ -13774,14 +14080,14 @@ function validate129(data, { instancePath = '', parentData, parentDataProperty,return false}}- validate129.errors = vErrors+ validate131.errors = vErrorsreturn errors === 0}-const schema119 = {+const schema121 = {additionalProperties: false,properties: {breakdownFilter: { $ref: '#/definitions/BreakdownFilter' },- completion_event: { $ref: '#/definitions/ExperimentMetricSource' },+ completion_event: { $ref: '#/definitions/ExperimentRetentionCompletion' },conversion_window: { $ref: '#/definitions/integer' },conversion_window_unit: { $ref: '#/definitions/FunnelConversionWindowTimeUnit' },fingerprint: { type: 'string' },@@ -13812,7 +14118,120 @@ const schema119 = {],type: 'object',}-const schema126 = {+const schema122 = {+ discriminator: { propertyName: 'kind' },+ oneOf: [+ { $ref: '#/definitions/EventsNode' },+ { $ref: '#/definitions/ActionsNode' },+ { $ref: '#/definitions/ExperimentDataWarehouseNode' },+ ],+ required: ['kind'],+ type: 'object',+}+function validate138(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {+ let vErrors = null+ let errors = 0+ const _errs1 = errors+ let valid0 = false+ let passing0 = null+ const _errs2 = errors+ if (!validate99(data, { instancePath, parentData, parentDataProperty, rootData })) {+ vErrors = vErrors === null ? validate99.errors : vErrors.concat(validate99.errors)+ errors = vErrors.length+ }+ var _valid0 = _errs2 === errors+ if (_valid0) {+ valid0 = true+ passing0 = 0+ }+ const _errs3 = errors+ if (!validate107(data, { instancePath, parentData, parentDataProperty, rootData })) {+ vErrors = vErrors === null ? validate107.errors : vErrors.concat(validate107.errors)+ errors = vErrors.length+ }+ var _valid0 = _errs3 === errors+ if (_valid0 && valid0) {+ valid0 = false+ passing0 = [passing0, 1]+ } else {+ if (_valid0) {+ valid0 = true+ passing0 = 1+ }+ const _errs4 = errors+ if (!validate113(data, { instancePath, parentData, parentDataProperty, rootData })) {+ vErrors = vErrors === null ? validate113.errors : vErrors.concat(validate113.errors)+ errors = vErrors.length+ }+ var _valid0 = _errs4 === errors+ if (_valid0 && valid0) {+ valid0 = false+ passing0 = [passing0, 2]+ } else {+ if (_valid0) {+ valid0 = true+ passing0 = 2+ }+ }+ }+ if (!valid0) {+ const err0 = {+ instancePath,+ schemaPath: '#/oneOf',+ keyword: 'oneOf',+ params: { passingSchemas: passing0 },+ message: 'must match exactly one schema in oneOf',+ }+ if (vErrors === null) {+ vErrors = [err0]+ } else {+ vErrors.push(err0)+ }+ errors+++ validate138.errors = vErrors+ return false+ } else {+ errors = _errs1+ if (vErrors !== null) {+ if (_errs1) {+ vErrors.length = _errs1+ } else {+ vErrors = null+ }+ }+ }+ if (errors === 0) {+ if (data && typeof data == 'object' && !Array.isArray(data)) {+ let missing0+ if (data.kind === undefined && (missing0 = 'kind')) {+ validate138.errors = [+ {+ instancePath,+ schemaPath: '#/required',+ keyword: 'required',+ params: { missingProperty: missing0 },+ message: "must have required property '" + missing0 + "'",+ },+ ]+ return false+ }+ } else {+ validate138.errors = [+ {+ instancePath,+ schemaPath: '#/type',+ keyword: 'type',+ params: { type: 'object' },+ message: 'must be object',+ },+ ]+ return false+ }+ }+ validate138.errors = vErrors+ return errors === 0+}+const schema129 = {discriminator: { propertyName: 'kind' },oneOf: [{ $ref: '#/definitions/EventsNode' },@@ -13823,7 +14242,7 @@ const schema126 = {required: ['kind'],type: 'object',}-const schema127 = {+const schema130 = {additionalProperties: false,description:"Sentinel start source for retention metrics. It carries no event of its own: at query time it resolves to the experiment's exposure, so one shared metric anchors correctly on any experiment regardless of that experiment's exposure event.",@@ -13835,7 +14254,7 @@ const schema127 = {required: ['kind'],type: 'object',}-function validate137(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {+function validate143(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {let vErrors = nulllet errors = 0const _errs1 = errors@@ -14049,7 +14468,7 @@ function validate137(data, { instancePath = '', parentData, parentDataProperty,vErrors.push(err7)}errors++- validate137.errors = vErrors+ validate143.errors = vErrorsreturn false} else {errors = _errs1@@ -14065,7 +14484,7 @@ function validate137(data, { instancePath = '', parentData, parentDataProperty,if (data && typeof data == 'object' && !Array.isArray(data)) {let missing1if (data.kind === undefined && (missing1 = 'kind')) {- validate137.errors = [+ validate143.errors = [{instancePath,schemaPath: '#/required',@@ -14077,7 +14496,7 @@ function validate137(data, { instancePath = '', parentData, parentDataProperty,return false}} else {- validate137.errors = [+ validate143.errors = [{instancePath,schemaPath: '#/type',@@ -14089,10 +14508,10 @@ function validate137(data, { instancePath = '', parentData, parentDataProperty,return false}}- validate137.errors = vErrors+ validate143.errors = vErrorsreturn errors === 0}-function validate134(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {+function validate136(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {let vErrors = nulllet errors = 0if (errors === 0) {@@ -14108,7 +14527,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,(data.start_event === undefined && (missing0 = 'start_event')) ||(data.start_handling === undefined && (missing0 = 'start_handling'))) {- validate134.errors = [+ validate136.errors = [{instancePath,schemaPath: '#/required',@@ -14121,8 +14540,8 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,} else {const _errs1 = errorsfor (const key0 in data) {- if (!func2.call(schema119.properties, key0)) {- validate134.errors = [+ if (!func2.call(schema121.properties, key0)) {+ validate136.errors = [{instancePath,schemaPath: '#/additionalProperties',@@ -14157,14 +14576,14 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,if (data.completion_event !== undefined) {const _errs3 = errorsif (- !validate98(data.completion_event, {+ !validate138(data.completion_event, {instancePath: instancePath + '/completion_event',parentData: data,parentDataProperty: 'completion_event',rootData,})) {- vErrors = vErrors === null ? validate98.errors : vErrors.concat(validate98.errors)+ vErrors = vErrors === null ? validate138.errors : vErrors.concat(validate138.errors)errors = vErrors.length}var valid0 = _errs3 === errors@@ -14176,7 +14595,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,let data2 = data.conversion_windowconst _errs4 = errorsif (!(typeof data2 == 'number' && !(data2 % 1) && !isNaN(data2) && isFinite(data2))) {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/conversion_window',schemaPath: '#/definitions/integer/type',@@ -14196,7 +14615,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,let data3 = data.conversion_window_unitconst _errs7 = errorsif (typeof data3 !== 'string') {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/conversion_window_unit',schemaPath: '#/definitions/FunnelConversionWindowTimeUnit/type',@@ -14217,7 +14636,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,data3 === 'month')) {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/conversion_window_unit',schemaPath: '#/definitions/FunnelConversionWindowTimeUnit/enum',@@ -14236,7 +14655,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,if (data.fingerprint !== undefined) {const _errs10 = errorsif (typeof data.fingerprint !== 'string') {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/fingerprint',schemaPath: '#/properties/fingerprint/type',@@ -14256,7 +14675,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,let data5 = data.goalconst _errs12 = errorsif (typeof data5 !== 'string') {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/goal',schemaPath: '#/definitions/ExperimentMetricGoal/type',@@ -14268,7 +14687,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,return false}if (!(data5 === 'increase' || data5 === 'decrease')) {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/goal',schemaPath: '#/definitions/ExperimentMetricGoal/enum',@@ -14287,7 +14706,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,if (data.isSharedMetric !== undefined) {const _errs15 = errorsif (typeof data.isSharedMetric !== 'boolean') {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/isSharedMetric',schemaPath: '#/properties/isSharedMetric/type',@@ -14307,7 +14726,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,let data7 = data.kindconst _errs17 = errorsif (typeof data7 !== 'string') {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/kind',schemaPath: '#/properties/kind/type',@@ -14319,7 +14738,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,return false}if ('ExperimentMetric' !== data7) {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/kind',schemaPath: '#/properties/kind/const',@@ -14339,7 +14758,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,let data8 = data.metric_typeconst _errs19 = errorsif (typeof data8 !== 'string') {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/metric_type',schemaPath: '#/properties/metric_type/type',@@ -14351,7 +14770,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,return false}if ('retention' !== data8) {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/metric_type',schemaPath: '#/properties/metric_type/const',@@ -14370,7 +14789,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,if (data.name !== undefined) {const _errs21 = errorsif (typeof data.name !== 'string') {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/name',schemaPath: '#/properties/name/type',@@ -14396,7 +14815,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,!Array.isArray(data10))) {- validate134.errors = [+ validate136.errors = [{instancePath: instancePath + '/response',schemaPath: '#/properties/response/type',@@ -14423,7 +14842,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,isFinite(data11))) {- validate134.errors = [+ validate136.errors = [{instancePath:instancePath +@@ -14453,7 +14872,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,isFinite(data12))) {- validate134.errors = [+ validate136.errors = [{instancePath:instancePath +@@ -14476,7 +14895,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,let data13 = data.retention_window_unitconst _errs31 = errorsif (typeof data13 !== 'string') {- validate134.errors = [+ validate136.errors = [{instancePath:instancePath +@@ -14500,7 +14919,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,data13 === 'month')) {- validate134.errors = [+ validate136.errors = [{instancePath:instancePath +@@ -14532,7 +14951,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,isFinite(data14))) {- validate134.errors = [+ validate136.errors = [{instancePath:instancePath +@@ -14554,7 +14973,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,if (data.start_event !== undefined) {const _errs36 = errorsif (- !validate137(data.start_event, {+ !validate143(data.start_event, {instancePath:instancePath +'/start_event',@@ -14566,9 +14985,9 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,) {vErrors =vErrors === null- ? validate137.errors+ ? validate143.errors: vErrors.concat(- validate137.errors+ validate143.errors)errors = vErrors.length}@@ -14586,7 +15005,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,if (typeof data16 !== 'string') {- validate134.errors = [+ validate136.errors = [{instancePath:instancePath +@@ -14610,7 +15029,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,data16 === 'last_seen')) {- validate134.errors = [+ validate136.errors = [{instancePath:instancePath +@@ -14620,7 +15039,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,keyword: 'enum',params: {allowedValues:- schema119+ schema121.properties.start_handling.enum,@@ -14642,7 +15061,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,typeof data.uuid !=='string') {- validate134.errors = [+ validate136.errors = [{instancePath:instancePath +@@ -14679,7 +15098,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,isFinite(data18))) {- validate134.errors =+ validate136.errors =[{instancePath:@@ -14724,7 +15143,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,}}} else {- validate134.errors = [+ validate136.errors = [{instancePath,schemaPath: '#/type',@@ -14736,7 +15155,7 @@ function validate134(data, { instancePath = '', parentData, parentDataProperty,return false}}- validate134.errors = vErrors+ validate136.errors = vErrorsreturn errors === 0}function validate92(data, { instancePath = '', parentData, parentDataProperty, rootData = data } = {}) {@@ -14756,8 +15175,8 @@ function validate92(data, { instancePath = '', parentData, parentDataProperty, rpassing0 = 0}const _errs3 = errors- if (!validate121(data, { instancePath, parentData, parentDataProperty, rootData })) {- vErrors = vErrors === null ? validate121.errors : vErrors.concat(validate121.errors)+ if (!validate123(data, { instancePath, parentData, parentDataProperty, rootData })) {+ vErrors = vErrors === null ? validate123.errors : vErrors.concat(validate123.errors)errors = vErrors.length}var _valid0 = _errs3 === errors@@ -14770,8 +15189,8 @@ function validate92(data, { instancePath = '', parentData, parentDataProperty, rpassing0 = 1}const _errs4 = errors- if (!validate129(data, { instancePath, parentData, parentDataProperty, rootData })) {- vErrors = vErrors === null ? validate129.errors : vErrors.concat(validate129.errors)+ if (!validate131(data, { instancePath, parentData, parentDataProperty, rootData })) {+ vErrors = vErrors === null ? validate131.errors : vErrors.concat(validate131.errors)errors = vErrors.length}var _valid0 = _errs4 === errors@@ -14784,8 +15203,8 @@ function validate92(data, { instancePath = '', parentData, parentDataProperty, rpassing0 = 2}const _errs5 = errors- if (!validate134(data, { instancePath, parentData, parentDataProperty, rootData })) {- vErrors = vErrors === null ? validate134.errors : vErrors.concat(validate134.errors)+ if (!validate136(data, { instancePath, parentData, parentDataProperty, rootData })) {+ vErrors = vErrors === null ? validate136.errors : vErrors.concat(validate136.errors)errors = vErrors.length}var _valid0 = _errs5 === errorsdiff --git a/frontend/src/scenes/experiments/ExperimentMetricForm.tsx b/frontend/src/scenes/experiments/ExperimentMetricForm.tsxindex 7602d63ef433..b501a56e9cf1 100644--- a/frontend/src/scenes/experiments/ExperimentMetricForm.tsx+++ b/frontend/src/scenes/experiments/ExperimentMetricForm.tsx@@ -27,6 +27,7 @@ import {ExperimentMetric,ExperimentMetricSource,ExperimentMetricType,+ ExperimentRetentionStart,NodeKind,isExperimentExposureNode,isExperimentFunnelMetric,@@ -49,7 +50,7 @@ import {} from './ExperimentMetricOutlierHandling'import { ExperimentMetricThreshold, isThresholdAvailableForMath } from './ExperimentMetricThreshold'import { EXPOSURE_DEFAULT_EVENT, getActivationConfig, isDefaultExposureConfig } from './exposureContract'-import { seriesToMetricConfig, seriesToMetricSource } from './metricQueryUtils'+import { metricSourcesToSeries, seriesToMetricConfig, seriesToMetricSource } from './metricQueryUtils'import { commonActionFilterProps } from './Metrics/Selectors'import {getAllowedMathTypes,@@ -128,6 +129,13 @@ const dataWarehousePopoverFields: DataWarehousePopoverField[] = [},]+/** The sources every metric type accepts: those the series picker can produce. */+const isPickerSource = (source: ExperimentMetricSource | undefined): source is ExperimentFunnelMetricStep =>+ !!source &&+ (source.kind === NodeKind.EventsNode ||+ source.kind === NodeKind.ActionsNode ||+ source.kind === NodeKind.ExperimentDataWarehouseNode)+export function ExperimentMetricForm({metric,isSharedMetric = false,@@ -155,7 +163,7 @@ export function ExperimentMetricForm({const [isLoading, setIsLoading] = useState(false)// holds the custom start configuration while the exposure sentinel is selected, so switching back restores itconst previousRetentionStart = useRef<{- start_event: ExperimentMetricSource+ start_event: ExperimentRetentionStartstart_handling: 'first_seen' | 'last_seen'conversion_window?: numberconversion_window_unit?: FunnelConversionWindowTimeUnit@@ -219,18 +227,14 @@ export function ExperimentMetricForm({if (newMetricType === ExperimentMetricType.MEAN && isExperimentMeanMetric(newMetric)) {newMetric.source = sources[0]} else if (newMetricType === ExperimentMetricType.FUNNEL && isExperimentFunnelMetric(newMetric)) {- newMetric.series = sources.filter(- (s): s is ExperimentFunnelMetricStep =>- s &&- (s.kind === NodeKind.EventsNode ||- s.kind === NodeKind.ActionsNode ||- s.kind === NodeKind.ExperimentDataWarehouseNode)- )+ newMetric.series = sources.filter(isPickerSource)} else if (newMetricType === ExperimentMetricType.RATIO && isExperimentRatioMetric(newMetric)) {newMetric.numerator = sources[0]} else if (newMetricType === ExperimentMetricType.RETENTION && isExperimentRetentionMetric(newMetric)) {- newMetric.start_event = sources[0]- if (sources[1]) {+ if (isPickerSource(sources[0])) {+ newMetric.start_event = sources[0]+ }+ if (isPickerSource(sources[1])) {newMetric.completion_event = sources[1]}}@@ -367,7 +371,7 @@ export function ExperimentMetricForm({<><SeriesActionFilterbordered- series={[metric.source]}+ series={metricSourcesToSeries([metric.source])}trendsDisplayCategory={ChartDisplayCategory.TimeSeries}dataWarehouseNodeKind={NodeKind.ExperimentDataWarehouseNode}onChange={handleSetSeries}@@ -416,7 +420,7 @@ export function ExperimentMetricForm({{isExperimentFunnelMetric(metric) && (<SeriesActionFilterbordered- series={metric.series}+ series={metricSourcesToSeries(metric.series)}trendsDisplayCategory={ChartDisplayCategory.TimeSeries}dataWarehouseNodeKind={NodeKind.ExperimentDataWarehouseNode}onChange={handleSetSeries}@@ -441,7 +445,7 @@ export function ExperimentMetricForm({<LemonLabel className="mb-1">Numerator (what you're measuring)</LemonLabel><SeriesActionFilterbordered- series={[metric.numerator]}+ series={metricSourcesToSeries([metric.numerator])}trendsDisplayCategory={ChartDisplayCategory.TimeSeries}dataWarehouseNodeKind={NodeKind.ExperimentDataWarehouseNode}onChange={(series) => {@@ -469,7 +473,7 @@ export function ExperimentMetricForm({<LemonLabel className="mb-1">Denominator (what you're dividing by)</LemonLabel><SeriesActionFilterbordered- series={[metric.denominator]}+ series={metricSourcesToSeries([metric.denominator])}trendsDisplayCategory={ChartDisplayCategory.TimeSeries}dataWarehouseNodeKind={NodeKind.ExperimentDataWarehouseNode}onChange={(series) => {@@ -557,7 +561,7 @@ export function ExperimentMetricForm({) : (<SeriesActionFilterbordered- series={[metric.start_event]}+ series={metricSourcesToSeries([metric.start_event])}trendsDisplayCategory={ChartDisplayCategory.TimeSeries}dataWarehouseNodeKind={NodeKind.ExperimentDataWarehouseNode}onChange={(series) => {@@ -589,7 +593,7 @@ export function ExperimentMetricForm({</LemonLabel><SeriesActionFilterbordered- series={[metric.completion_event]}+ series={metricSourcesToSeries([metric.completion_event])}trendsDisplayCategory={ChartDisplayCategory.TimeSeries}dataWarehouseNodeKind={NodeKind.ExperimentDataWarehouseNode}onChange={(series) => {diff --git a/frontend/src/scenes/experiments/ExperimentMetricThreshold.tsx b/frontend/src/scenes/experiments/ExperimentMetricThreshold.tsxindex 6e67aa9aa51b..f1c75c2cd29e 100644--- a/frontend/src/scenes/experiments/ExperimentMetricThreshold.tsx+++ b/frontend/src/scenes/experiments/ExperimentMetricThreshold.tsx@@ -6,6 +6,7 @@ import { Tooltip } from 'lib/lemon-ui/Tooltip'import {ExperimentMeanMetric,ExperimentMetric,+ ExperimentWarehouseNativeMathType,MathType,isExperimentMeanMetric,} from '~/queries/schema/schema-general'@@ -15,12 +16,12 @@ import { ExperimentMetricMathType } from '~/types'* Threshold turns a per-user accumulated value into a binary outcome ("did this user reach N"),* so it only makes sense for math types that sum/count per user.*/-const THRESHOLD_ENABLED_MATH_TYPES = new Set<MathType>([+const THRESHOLD_ENABLED_MATH_TYPES = new Set<MathType | ExperimentWarehouseNativeMathType>([ExperimentMetricMathType.Sum,ExperimentMetricMathType.TotalCount,])-export function isThresholdAvailableForMath(math: MathType | undefined): boolean {+export function isThresholdAvailableForMath(math: MathType | ExperimentWarehouseNativeMathType | undefined): boolean {return math !== undefined && THRESHOLD_ENABLED_MATH_TYPES.has(math)}@@ -33,7 +34,7 @@ export const isMetricThresholdCueVisible = (metric: ExperimentMetric): metric isisExperimentMeanMetric(metric) && !!metric.threshold && isThresholdAvailableForMath(metric.source.math)export interface ExperimentMetricThresholdProps {- math: MathType | undefined+ math: MathType | ExperimentWarehouseNativeMathType | undefinedvalue: number | undefinedonChange: (value: number | undefined) => void}diff --git a/frontend/src/scenes/experiments/MetricsView/shared/utils.ts b/frontend/src/scenes/experiments/MetricsView/shared/utils.tsindex 3313ef7abf97..aaa3d9a5bdfc 100644--- a/frontend/src/scenes/experiments/MetricsView/shared/utils.ts+++ b/frontend/src/scenes/experiments/MetricsView/shared/utils.ts@@ -13,6 +13,7 @@ import type {import {ExperimentDataWarehouseNode,ExperimentExposureNode,+ ExperimentWarehouseNativeNode,ExperimentMetricType,ExperimentStatsValidationFailure,NodeKind,@@ -34,7 +35,12 @@ export const getMetricTag = (metric: ExperimentMetric | ExperimentTrendsQuery |return 'Trend'}-type MetricSource = EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentExposureNode+type MetricSource =+ | EventsNode+ | ActionsNode+ | ExperimentDataWarehouseNode+ | ExperimentWarehouseNativeNode+ | ExperimentExposureNodeconst getDefaultName = (source: MetricSource): string | null | undefined => {switch (source.kind) {@@ -44,6 +50,8 @@ const getDefaultName = (source: MetricSource): string | null | undefined => {return source.name || `Action ${source.id}`case NodeKind.ExperimentDataWarehouseNode:return source.table_name+ case NodeKind.ExperimentWarehouseNativeNode:+ return source.custom_name || 'Warehouse-native query'case NodeKind.ExperimentExposureNode:return 'Exposure'}diff --git a/frontend/src/scenes/experiments/metricQueryUtils.test.ts b/frontend/src/scenes/experiments/metricQueryUtils.test.tsindex 9f29103190d2..1eaf34809c32 100644--- a/frontend/src/scenes/experiments/metricQueryUtils.test.ts+++ b/frontend/src/scenes/experiments/metricQueryUtils.test.ts@@ -23,7 +23,13 @@ import {PropertyOperator,} from '~/types'-import { getMathProperties, getQuery, seriesToMetricConfig, seriesToMetricSource } from './metricQueryUtils'+import {+ getMathProperties,+ getQuery,+ metricSourcesToSeries,+ seriesToMetricConfig,+ seriesToMetricSource,+} from './metricQueryUtils'// getQuery builds date_from/date_to from dayjs() at call time, formatted to the minute.// The expected values below recompute dayjs() independently, so a minute rollover between@@ -175,7 +181,7 @@ describe('seriesToMetricConfig', () => {])('stores the funnel steps the picker emits after %s', (_label, edit, expectedSteps) => {const onChange = jest.fn()const logic = entityFilterLogic({- series: funnelSteps,+ series: metricSourcesToSeries(funnelSteps),onChange,typeKey: 'experiment-metric',dataWarehouseNodeKind: NodeKind.ExperimentDataWarehouseNode,diff --git a/frontend/src/scenes/experiments/metricQueryUtils.ts b/frontend/src/scenes/experiments/metricQueryUtils.tsindex a3ac6369e240..07833f2030f6 100644--- a/frontend/src/scenes/experiments/metricQueryUtils.ts+++ b/frontend/src/scenes/experiments/metricQueryUtils.ts@@ -25,6 +25,7 @@ import type {ExperimentMetric,ExperimentMetricSource,ExperimentMetricTypeProps,+ ExperimentWarehouseNativeNode,FunnelsDataWarehouseNode,FunnelsFilter,FunnelsQuery,@@ -33,7 +34,7 @@ import type {TrendsFilter,TrendsQuery,} from '~/queries/schema/schema-general'-import { ExperimentMetricType, NodeKind } from '~/queries/schema/schema-general'+import { ExperimentMetricType, ExperimentWarehouseNativeMathType, NodeKind } from '~/queries/schema/schema-general'import { setLatestVersionsOnQuery } from '~/queries/utils'import type { IntervalType } from '~/types'import { ChartDisplayType, ExperimentMetricMathType } from '~/types'@@ -97,6 +98,9 @@ const convertSourceToQueryNode = (source: ExperimentMetricSource): EventsNode |id_field: dataWarehouse.data_warehouse_join_key,}))+ .with({ kind: NodeKind.ExperimentWarehouseNativeNode }, () => {+ throw new Error('Warehouse-native sources cannot be shown as an insight yet')+ }).exhaustive()}@@ -121,6 +125,11 @@ const getDefaultDateRange = (): DateRange => ({* returns the math properties for the source*/export const getMathProperties = (source: ExperimentMetricSource): MathProperties => {+ if (source.kind === NodeKind.ExperimentWarehouseNativeNode) {+ return source.math === ExperimentWarehouseNativeMathType.Sum+ ? { math: ExperimentMetricMathType.Sum, math_property: source.math_property }+ : { math: ExperimentMetricMathType.TotalCount, math_property: undefined }+ }if (!source.math || source.math === ExperimentMetricMathType.TotalCount) {return { math: ExperimentMetricMathType.TotalCount, math_property: undefined }}@@ -252,17 +261,33 @@ const getFunnelSeries = (.exhaustive())+/**+ * The series editor has rows for events, actions and synced warehouse tables only. A+ * warehouse-native source has no row yet, so the form refuses it like the insight converters do.+ */+export function metricSourcesToSeries(sources: ExperimentMetricSource[]): SeriesNode[] {+ return sources.map((source) => {+ if (source.kind === NodeKind.ExperimentWarehouseNativeNode) {+ throw new Error('Warehouse-native sources cannot be edited in the metric form yet')+ }+ return source+ })+}+/*** The picker mirrors a warehouse table's name onto `id`, which `ExperimentDataWarehouseNode` does* not accept, so a table keeps only `table_name`. A group has no experiment equivalent and gives null.*/-const toExperimentSourceNode = (node: SeriesNode): ExperimentMetricSource | null => {+/** The sources the series picker can produce. A warehouse-native source has no picker row. */+type PickedMetricSource = Exclude<ExperimentMetricSource, ExperimentWarehouseNativeNode>++const toExperimentSourceNode = (node: SeriesNode): PickedMetricSource | null => {if (isEventsSeriesNode(node) || isActionsSeriesNode(node)) {return node}if (isWarehouseSeriesNode(node)) {const { id: _id, ...warehouseNode } = node as SeriesNode & { id?: string }- return { ...warehouseNode, kind: NodeKind.ExperimentDataWarehouseNode } as ExperimentMetricSource+ return { ...warehouseNode, kind: NodeKind.ExperimentDataWarehouseNode } as PickedMetricSource}return null}@@ -271,7 +296,7 @@ const toExperimentSourceNode = (node: SeriesNode): ExperimentMetricSource | null* Turns the series a single-source picker emits into a metric source, with total count as the* default math. Returns null when the picker holds no event, action or table.*/-export function seriesToMetricSource(series: SeriesNode[]): ExperimentMetricSource | null {+export function seriesToMetricSource(series: SeriesNode[]): PickedMetricSource | null {const [node] = cleanSeriesNodes(series.slice(0, 1), MathAvailability.All)const source = node ? toExperimentSourceNode(node) : nullif (source?.kind === NodeKind.EventsNode) {diff --git a/frontend/src/scenes/experiments/utils.ts b/frontend/src/scenes/experiments/utils.tsindex 3fe16439ad39..d4c75245771a 100644--- a/frontend/src/scenes/experiments/utils.ts+++ b/frontend/src/scenes/experiments/utils.ts@@ -7,6 +7,7 @@ import { MathAvailability } from 'scenes/insights/filters/ActionFilter/ActionFilimport { SeriesNode, isActionsSeriesNode, isEventsSeriesNode } from 'scenes/insights/filters/ActionFilter/seriesNode'import {+ ActionsNode,AnyEntityNode,Breakdown,CachedNewExperimentQueryResponse,@@ -77,7 +78,13 @@ export function isEventExposureConfig(config: ExperimentExposureConfig): config}export function getExposureConfigDisplayName(config: ExperimentExposureConfig): string {- return isEventExposureConfig(config) ? config.event || 'Unknown Event' : config.name || `Action ${config.id}`+ if (isEventExposureConfig(config)) {+ return config.event || 'Unknown Event'+ }+ if (config.kind === NodeKind.ExperimentWarehouseNativeExposureConfig) {+ return 'Warehouse exposures'+ }+ return config.name || `Action ${config.id}`}export function getVariantColor(variantKey: string, featureFlagVariants: MultivariateFlagVariant[]): string {@@ -546,7 +553,7 @@ export function exposureConfigToSeries(exposureConfig: ExperimentExposureConfig)/*** Only an event or an action can mark exposure, so any other series gives no config.*/-export function seriesToExposureConfig(series: SeriesNode[]): ExperimentExposureConfig | undefined {+export function seriesToExposureConfig(series: SeriesNode[]): ExperimentEventExposureConfig | ActionsNode | undefined {const [node] = seriesif (isEventsSeriesNode(node)) {return {@@ -735,6 +742,9 @@ const getEventCountSeries = (metric: ExperimentMetric): AnyEntityNode[] => {dataWarehouseNode.properties.length > 0 && { properties: dataWarehouseNode.properties }),},])+ .with({ kind: NodeKind.ExperimentWarehouseNativeNode }, () => {+ throw new Error('Warehouse-native sources cannot be shown as an insight yet')+ }).exhaustive()return seriesdiff --git a/frontend/src/scenes/saved-insights/insightTypesMetadata.tsx b/frontend/src/scenes/saved-insights/insightTypesMetadata.tsxindex e08a7dce58e6..2f0be1c85946 100644--- a/frontend/src/scenes/saved-insights/insightTypesMetadata.tsx+++ b/frontend/src/scenes/saved-insights/insightTypesMetadata.tsx@@ -447,6 +447,18 @@ export const QUERY_TYPES_METADATA: Record<NodeKind, InsightTypeMetadata> = {icon: IconFlask,inMenu: false,},+ [NodeKind.ExperimentWarehouseNativeNode]: {+ name: 'Experiment Warehouse-native Node',+ description: 'Experiment metric source run in the customer warehouse.',+ icon: IconFlask,+ inMenu: false,+ },+ [NodeKind.ExperimentWarehouseNativeExposureConfig]: {+ name: 'Experiment Warehouse-native Exposure Config',+ description: 'Experiment exposures run in the customer warehouse.',+ icon: IconFlask,+ inMenu: false,+ },[NodeKind.TeamTaxonomyQuery]: {name: 'Team Taxonomy',icon: IconHogQL,diff --git a/posthog/clickhouse/query_tagging.py b/posthog/clickhouse/query_tagging.pyindex 95ba2ce3e619..791ec6fedede 100644--- a/posthog/clickhouse/query_tagging.py+++ b/posthog/clickhouse/query_tagging.py@@ -339,6 +339,8 @@ def kind_fallback_tags(kind: NodeKind) -> FallbackTags | None:| NodeKind.ACTIONS_NODE| NodeKind.PERSONS_NODE| NodeKind.DATA_WAREHOUSE_NODE+ | NodeKind.EXPERIMENT_WAREHOUSE_NATIVE_NODE+ | NodeKind.EXPERIMENT_WAREHOUSE_NATIVE_EXPOSURE_CONFIG| NodeKind.FUNNELS_DATA_WAREHOUSE_NODE| NodeKind.LIFECYCLE_DATA_WAREHOUSE_NODE| NodeKind.DATA_TABLE_NODEdiff --git a/posthog/schema.py b/posthog/schema.pyindex 8cb81e0bd0d3..45ddb0105df1 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -136,6 +136,7 @@ from posthog.schema_enums import (ExperimentMetricType as ExperimentMetricType,ExperimentStatsMethod as ExperimentStatsMethod,ExperimentStatsValidationFailure as ExperimentStatsValidationFailure,+ ExperimentWarehouseNativeMathType as ExperimentWarehouseNativeMathType,ExternalQueryErrorCode as ExternalQueryErrorCode,ExternalQueryStatus as ExternalQueryStatus,FileSystemIconType as FileSystemIconType,@@ -1689,6 +1690,61 @@ class ExperimentRunningTimeCalculation(BaseModel):)+class ExperimentWarehouseNativeExposureConfig(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ connection_id: str = Field(+ ...,+ description=("The direct-query source (an ExternalDataSource id) the SQL is written for."),+ )+ kind: Literal["ExperimentWarehouseNativeExposureConfig"] = "ExperimentWarehouseNativeExposureConfig"+ query: str = Field(+ ...,+ description=(+ "Read-only SQL in the warehouse's dialect, returning one row per exposure"+ " with `entity_id`, `variant` and `timestamp` columns. PostHog keeps the"+ " first exposure per entity and applies the experiment's date range and"+ " multiple-variant handling."+ ),+ )+ response: dict[str, Any] | None = None+ version: float | None = Field(default=None, description="version of the node, used for schema migrations")+++class ExperimentWarehouseNativeNode(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ connection_id: str = Field(+ ...,+ description=("The direct-query source (an ExternalDataSource id) the SQL is written for."),+ )+ custom_name: str | None = None+ kind: Literal["ExperimentWarehouseNativeNode"] = "ExperimentWarehouseNativeNode"+ math: ExperimentWarehouseNativeMathType | None = Field(+ default=None,+ description=("How to aggregate the rows per entity. Defaults to `total` (row count)."),+ )+ math_property: str | None = Field(+ default=None,+ description=(+ "The numeric column `math` reads. Required when `math` is `sum`. One SQL"+ " relation can serve several metrics, each reading a different column."+ ),+ )+ query: str = Field(+ ...,+ description=(+ "Read-only SQL in the warehouse's dialect, returning one row per outcome"+ " with `entity_id` and `timestamp` columns plus any numeric columns a"+ " metric can measure."+ ),+ )+ response: dict[str, Any] | None = None+ version: float | None = Field(default=None, description="version of the node, used for schema migrations")++class FailureMessage(BaseModel):model_config = ConfigDict(extra="forbid",@@ -31331,10 +31387,11 @@ class ExperimentExposureCriteria(BaseModel):"Additional event (or action) an entity must emit at/after their first"" default exposure event before they count as exposed; exposure time"" becomes this event's timestamp. Only valid with the default exposure"- " event, not a custom `exposure_config`."+ " event, not a custom `exposure_config`. Warehouse-native activation has no"+ " defined semantics yet, so only events and actions apply here."),)- exposure_config: ExperimentEventExposureConfig | ActionsNode | None = None+ exposure_config: ExperimentEventExposureConfig | ActionsNode | ExperimentWarehouseNativeExposureConfig | None = NonefilterTestAccounts: bool | None = Nonemultiple_variant_handling: MultipleVariantHandling | None = None@@ -32019,7 +32076,9 @@ class ExperimentRatioMetric(BaseModel):breakdownFilter: BreakdownFilter | None = Noneconversion_window: int | None = Noneconversion_window_unit: FunnelConversionWindowTimeUnit | None = None- denominator: EventsNode | ActionsNode | ExperimentDataWarehouseNode = Field(..., discriminator="kind")+ denominator: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode = Field(+ ..., discriminator="kind"+ )denominator_outlier_handling: ExperimentMetricOutlierHandling | None = Nonefingerprint: str | None = Nonegoal: ExperimentMetricGoal | None = None@@ -32027,7 +32086,9 @@ class ExperimentRatioMetric(BaseModel):kind: Literal["ExperimentMetric"] = "ExperimentMetric"metric_type: Literal["ratio"] = "ratio"name: str | None = None- numerator: EventsNode | ActionsNode | ExperimentDataWarehouseNode = Field(..., discriminator="kind")+ numerator: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode = Field(+ ..., discriminator="kind"+ )numerator_outlier_handling: ExperimentMetricOutlierHandling | None = Noneresponse: dict[str, Any] | None = NonesharedMetricId: float | None = None@@ -32039,10 +32100,14 @@ class ExperimentRatioMetricTypeProps(BaseModel):model_config = ConfigDict(extra="forbid",)- denominator: EventsNode | ActionsNode | ExperimentDataWarehouseNode = Field(..., discriminator="kind")+ denominator: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode = Field(+ ..., discriminator="kind"+ )denominator_outlier_handling: ExperimentMetricOutlierHandling | None = Nonemetric_type: Literal["ratio"] = "ratio"- numerator: EventsNode | ActionsNode | ExperimentDataWarehouseNode = Field(..., discriminator="kind")+ numerator: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode = Field(+ ..., discriminator="kind"+ )numerator_outlier_handling: ExperimentMetricOutlierHandling | None = None@@ -32490,7 +32555,9 @@ class ExperimentMeanMetric(BaseModel):name: str | None = Noneresponse: dict[str, Any] | None = NonesharedMetricId: float | None = None- source: EventsNode | ActionsNode | ExperimentDataWarehouseNode = Field(..., discriminator="kind")+ source: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode = Field(+ ..., discriminator="kind"+ )threshold: float | None = Field(default=None,description=(@@ -32521,7 +32588,9 @@ class ExperimentMeanMetricTypeProps(BaseModel):),)metric_type: Literal["mean"] = "mean"- source: EventsNode | ActionsNode | ExperimentDataWarehouseNode = Field(..., discriminator="kind")+ source: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode = Field(+ ..., discriminator="kind"+ )threshold: float | None = Field(default=None,description=(@@ -33189,11 +33258,13 @@ class ExperimentActorsQuery(BaseModel):model_config = ConfigDict(extra="forbid",)- exposureConfig: ExperimentEventExposureConfig | ActionsNode | None = Field(- default=None,- description=(- "Exposure configuration for filtering events. Defines when users were first exposed to the experiment."- ),+ exposureConfig: ExperimentEventExposureConfig | ActionsNode | ExperimentWarehouseNativeExposureConfig | None = (+ Field(+ default=None,+ description=(+ "Exposure configuration for filtering events. Defines when users were first exposed to the experiment."+ ),+ ))featureFlagKey: str | None = Field(default=None, description="Feature flag key for breakdown filtering.")funnelStep: int | None = Field(diff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex 73761220cf99..47adbe78968b 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -1525,6 +1525,11 @@ class ExperimentStatsValidationFailure(StrEnum):NOT_ENOUGH_METRIC_DATA = "not-enough-metric-data"+class ExperimentWarehouseNativeMathType(StrEnum):+ TOTAL = "total"+ SUM = "sum"++class ExternalQueryErrorCode(StrEnum):PLATFORM_ACCESS_REQUIRED = "platform_access_required"QUERY_EXECUTION_FAILED = "query_execution_failed"@@ -2423,10 +2428,12 @@ class NodeKind(StrEnum):EXPERIMENT_QUERY = "ExperimentQuery"EXPERIMENT_EXPOSURE_QUERY = "ExperimentExposureQuery"EXPERIMENT_EVENT_EXPOSURE_CONFIG = "ExperimentEventExposureConfig"+ EXPERIMENT_WAREHOUSE_NATIVE_EXPOSURE_CONFIG = "ExperimentWarehouseNativeExposureConfig"EXPERIMENT_ACTORS_QUERY = "ExperimentActorsQuery"EXPERIMENT_TRENDS_QUERY = "ExperimentTrendsQuery"EXPERIMENT_FUNNELS_QUERY = "ExperimentFunnelsQuery"EXPERIMENT_DATA_WAREHOUSE_NODE = "ExperimentDataWarehouseNode"+ EXPERIMENT_WAREHOUSE_NATIVE_NODE = "ExperimentWarehouseNativeNode"EXPERIMENT_EXPOSURE_NODE = "ExperimentExposureNode"DATABASE_SCHEMA_QUERY = "DatabaseSchemaQuery"SUGGESTED_QUESTIONS_QUERY = "SuggestedQuestionsQuery"diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex d22513adeedc..c1c5017cdbb9 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -6460,6 +6460,19 @@ export interface ExperimentEventExposureConfigApi {version?: number | null}+export type ExperimentWarehouseNativeExposureConfigApiResponse = { [key: string]: unknown } | null++export interface ExperimentWarehouseNativeExposureConfigApi {+ /** The direct-query source (an ExternalDataSource id) the SQL is written for. */+ connection_id: string+ kind?: 'ExperimentWarehouseNativeExposureConfig'+ /** Read-only SQL in the warehouse's dialect, returning one row per exposure with `entity_id`, `variant` and `timestamp` columns. PostHog keeps the first exposure per entity and applies the experiment's date range and multiple-variant handling. */+ query: string+ response?: ExperimentWarehouseNativeExposureConfigApiResponse+ /** version of the node, used for schema migrations */+ version?: number | null+}+export type MultipleVariantHandlingApi = (typeof MultipleVariantHandlingApi)[keyof typeof MultipleVariantHandlingApi]export const MultipleVariantHandlingApi = {@@ -6564,6 +6577,32 @@ export interface ExperimentDataWarehouseNodeApi {version?: number | null}+export type ExperimentWarehouseNativeMathTypeApi =+ (typeof ExperimentWarehouseNativeMathTypeApi)[keyof typeof ExperimentWarehouseNativeMathTypeApi]++export const ExperimentWarehouseNativeMathTypeApi = {+ Total: 'total',+ Sum: 'sum',+} as const++export type ExperimentWarehouseNativeNodeApiResponse = { [key: string]: unknown } | null++export interface ExperimentWarehouseNativeNodeApi {+ /** The direct-query source (an ExternalDataSource id) the SQL is written for. */+ connection_id: string+ custom_name?: string | null+ kind?: 'ExperimentWarehouseNativeNode'+ /** How to aggregate the rows per entity. Defaults to `total` (row count). */+ math?: ExperimentWarehouseNativeMathTypeApi | null+ /** The numeric column `math` reads. Required when `math` is `sum`. One SQL relation can serve several metrics, each reading a different column. */+ math_property?: string | null+ /** Read-only SQL in the warehouse's dialect, returning one row per outcome with `entity_id` and `timestamp` columns plus any numeric columns a metric can measure. */+ query: string+ response?: ExperimentWarehouseNativeNodeApiResponse+ /** version of the node, used for schema migrations */+ version?: number | null+}+export type ExperimentMeanMetricApiResponse = { [key: string]: unknown } | nullexport interface ExperimentMeanMetricApi {@@ -6581,7 +6620,7 @@ export interface ExperimentMeanMetricApi {name?: string | nullresponse?: ExperimentMeanMetricApiResponsesharedMetricId?: number | null- source: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi+ source: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi | ExperimentWarehouseNativeNodeApi/** When set, reports the percentage of users whose per-user summed/counted value reaches or exceeds this threshold. Only meaningful for sum/count math types. */threshold?: number | null/** Winsorization upper percentile bound, as a fraction in [0, 1] (e.g. 0.99 for the 99th percentile). */@@ -6630,7 +6669,7 @@ export interface ExperimentRatioMetricApi {breakdownFilter?: BreakdownFilterApi | nullconversion_window?: number | nullconversion_window_unit?: FunnelConversionWindowTimeUnitApi | null- denominator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi+ denominator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi | ExperimentWarehouseNativeNodeApidenominator_outlier_handling?: ExperimentMetricOutlierHandlingApi | nullfingerprint?: string | nullgoal?: ExperimentMetricGoalApi | null@@ -6638,7 +6677,7 @@ export interface ExperimentRatioMetricApi {kind?: 'ExperimentMetric'metric_type?: 'ratio'name?: string | null- numerator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi+ numerator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi | ExperimentWarehouseNativeNodeApinumerator_outlier_handling?: ExperimentMetricOutlierHandlingApi | nullresponse?: ExperimentRatioMetricApiResponsesharedMetricId?: number | null@@ -6810,7 +6849,11 @@ export interface ExperimentQueryApi {export interface ExperimentActorsQueryApi {/** Exposure configuration for filtering events. Defines when users were first exposed to the experiment. */- exposureConfig?: ExperimentEventExposureConfigApi | ActionsNodeApi | null+ exposureConfig?:+ | ExperimentEventExposureConfigApi+ | ActionsNodeApi+ | ExperimentWarehouseNativeExposureConfigApi+ | null/** Feature flag key for breakdown filtering. */featureFlagKey?: string | null/** Index of the step for which we want to get actors for, per experiment variant. Positive for converted persons, negative for dropped off persons. */diff --git a/products/desktop/packages/api-client/src/generated.ts b/products/desktop/packages/api-client/src/generated.tsindex 6c0eed204f31..fba47a3354a8 100644--- a/products/desktop/packages/api-client/src/generated.ts+++ b/products/desktop/packages/api-client/src/generated.ts@@ -3743,6 +3743,19 @@ export namespace Schemas {response?: (Record<string, unknown> | null) | undefined;version?: (number | null) | undefined;};+ export type ExperimentWarehouseNativeExposureConfig = {+ /**+ * The direct-query source (an ExternalDataSource id) the SQL is written for.+ */+ connection_id: string;+ kind?: string | undefined;+ /**+ * Read-only SQL in the warehouse's dialect, returning one row per exposure with `entity_id`, `variant` and `timestamp` columns. PostHog keeps the first exposure per entity and applies the experiment's date range and multiple-variant handling.+ */+ query: string;+ response?: (Record<string, unknown> | null) | undefined;+ version?: (number | null) | undefined;+ };export type MultipleVariantHandling = "exclude" | "first_seen";export type ExperimentMetricGoal = "increase" | "decrease";export type ExperimentDataWarehouseNode = {@@ -3834,6 +3847,23 @@ export namespace Schemas {timestamp_field: string;version?: (number | null) | undefined;};+ export type ExperimentWarehouseNativeMathType = "total" | "sum";+ export type ExperimentWarehouseNativeNode = {+ /**+ * The direct-query source (an ExternalDataSource id) the SQL is written for.+ */+ connection_id: string;+ custom_name?: (string | null) | undefined;+ kind?: string | undefined;+ math?: (ExperimentWarehouseNativeMathType | null) | undefined;+ math_property?: (string | null) | undefined;+ /**+ * Read-only SQL in the warehouse's dialect, returning one row per outcome with `entity_id` and `timestamp` columns plus any numeric columns a metric can measure.+ */+ query: string;+ response?: (Record<string, unknown> | null) | undefined;+ version?: (number | null) | undefined;+ };export type ExperimentMeanMetric = {breakdownFilter?: (BreakdownFilter | null) | undefined;conversion_window?: (number | null) | undefined;@@ -3850,7 +3880,11 @@ export namespace Schemas {name?: (string | null) | undefined;response?: (Record<string, unknown> | null) | undefined;sharedMetricId?: (number | null) | undefined;- source: EventsNode | ActionsNode | ExperimentDataWarehouseNode;+ source:+ | EventsNode+ | ActionsNode+ | ExperimentDataWarehouseNode+ | ExperimentWarehouseNativeNode;threshold?: (number | null) | undefined;upper_bound_percentile?: (number | null) | undefined;uuid?: (string | null) | undefined;@@ -3890,7 +3924,11 @@ export namespace Schemas {conversion_window_unit?:| (FunnelConversionWindowTimeUnit | null)| undefined;- denominator: EventsNode | ActionsNode | ExperimentDataWarehouseNode;+ denominator:+ | EventsNode+ | ActionsNode+ | ExperimentDataWarehouseNode+ | ExperimentWarehouseNativeNode;denominator_outlier_handling?:| (ExperimentMetricOutlierHandling | null)| undefined;@@ -3900,7 +3938,11 @@ export namespace Schemas {kind?: string | undefined;metric_type?: string | undefined;name?: (string | null) | undefined;- numerator: EventsNode | ActionsNode | ExperimentDataWarehouseNode;+ numerator:+ | EventsNode+ | ActionsNode+ | ExperimentDataWarehouseNode+ | ExperimentWarehouseNativeNode;numerator_outlier_handling?:| (ExperimentMetricOutlierHandling | null)| undefined;@@ -4061,7 +4103,12 @@ export namespace Schemas {};export type ExperimentActorsQuery = {exposureConfig?:- | (ExperimentEventExposureConfig | ActionsNode | null)+ | (+ | ExperimentEventExposureConfig+ | ActionsNode+ | ExperimentWarehouseNativeExposureConfig+ | null+ )| undefined;featureFlagKey?: (string | null) | undefined;funnelStep?: (number | null) | undefined;diff --git a/products/experiments/backend/experiment_service.py b/products/experiments/backend/experiment_service.pyindex 91709e8e8327..d47d7a4c7aa7 100644--- a/products/experiments/backend/experiment_service.py+++ b/products/experiments/backend/experiment_service.py@@ -22,7 +22,12 @@ import structlogfrom rest_framework import statusfrom rest_framework.exceptions import APIException, PermissionDenied, ValidationError-from posthog.schema import ActionsNode, ExperimentEventExposureConfig, ExperimentExposureCriteria+from posthog.schema import (+ ActionsNode,+ ExperimentEventExposureConfig,+ ExperimentExposureCriteria,+ ExperimentWarehouseNativeExposureConfig,+)from posthog.hogql import astfrom posthog.hogql.constants import HogQLGlobalSettings, LimitContext@@ -770,7 +775,7 @@ class ExperimentService:# nullable), so only validate shape when a value is present.if exposure_criteria.get("exposure_config") is not None:cls._validate_exposure_config_shape(- exposure_criteria["exposure_config"], "exposure_criteria.exposure_config"+ exposure_criteria["exposure_config"], "exposure_criteria.exposure_config", warehouse_native_allowed=True)if exposure_criteria.get("activation_config") is not None:@@ -795,7 +800,9 @@ class ExperimentService:)@classmethod- def _validate_exposure_config_shape(cls, exposure_config: object, field_path: str) -> None:+ def _validate_exposure_config_shape(+ cls, exposure_config: object, field_path: str, *, warehouse_native_allowed: bool = False+ ) -> None:if not isinstance(exposure_config, dict):raise ValidationError(f"{field_path} must be an object, got {type(exposure_config).__name__}. {cls.EXPOSURE_CONFIG_HINT}"@@ -804,6 +811,12 @@ class ExperimentService:# `kind` is optional; missing kind defaults to ExperimentEventExposureConfig# to mirror the pydantic Literal default on that model.kind = exposure_config.get("kind", "ExperimentEventExposureConfig")+ if kind == "ExperimentWarehouseNativeExposureConfig" and warehouse_native_allowed:+ # The kind exists so the rest of the product can be built against it; nothing can run it yet.+ cls._validate_exposure_config_model(+ ExperimentWarehouseNativeExposureConfig, exposure_config, field_path, kind+ )+ raise ValidationError(f"{field_path}: warehouse-native exposures are not supported yet.")if kind not in cls.EXPOSURE_CONFIG_KINDS:raise ValidationError(f"{field_path}.kind must be one of "@@ -812,6 +825,12 @@ class ExperimentService:)model_cls = ActionsNode if kind == "ActionsNode" else ExperimentEventExposureConfig+ cls._validate_exposure_config_model(model_cls, exposure_config, field_path, kind)++ @classmethod+ def _validate_exposure_config_model(+ cls, model_cls: type[pydantic.BaseModel], exposure_config: dict, field_path: str, kind: object+ ) -> None:try:model_cls.model_validate(exposure_config)except pydantic.ValidationError as e:diff --git a/products/experiments/backend/facade/api.py b/products/experiments/backend/facade/api.pyindex a048a9ab2a55..4fa956d4ce6b 100644--- a/products/experiments/backend/facade/api.py+++ b/products/experiments/backend/facade/api.py@@ -12,6 +12,8 @@ from uuid import UUIDimport pydanticimport structlog+from posthog.schema import ExperimentEventExposureConfig+from posthog.models.team import Teamfrom posthog.models.user import User@@ -229,7 +231,9 @@ def _exposes_on_flag_calls(experiment_id: int, exposure_criteria: dict | None) -return criteria is None or (criteria.activation_config is Noneand is_default_exposure_config(criteria.exposure_config)- and not (criteria.exposure_config and criteria.exposure_config.properties)+ and not (+ isinstance(criteria.exposure_config, ExperimentEventExposureConfig) and criteria.exposure_config.properties+ ))diff --git a/products/experiments/backend/health/exposure_gate.py b/products/experiments/backend/health/exposure_gate.pyindex c2d7251cbd3e..94cbfab84657 100644--- a/products/experiments/backend/health/exposure_gate.py+++ b/products/experiments/backend/health/exposure_gate.py@@ -30,7 +30,7 @@ from django.utils import timezoneimport pydantic-from posthog.schema import ActionsNode+from posthog.schema import ActionsNode, ExperimentEventExposureConfigfrom posthog.hogql import astfrom posthog.hogql.constants import HogQLGlobalSettings@@ -583,7 +583,7 @@ def _not_checked_reason(config = criteria.exposure_config if criteria else Noneif isinstance(config, ActionsNode):return FlagHistoryNotCheckedReason.EXPOSURE_ACTION- if config is not None and config.properties:+ if isinstance(config, ExperimentEventExposureConfig) and config.properties:return FlagHistoryNotCheckedReason.EXPOSURE_FILTERSif not reader_access.can_query_events:return FlagHistoryNotCheckedReason.NO_QUERY_ACCESSdiff --git a/products/experiments/backend/hogql_queries/base_query_utils.py b/products/experiments/backend/hogql_queries/base_query_utils.pyindex e68f7fa7deef..ed3935b127f4 100644--- a/products/experiments/backend/hogql_queries/base_query_utils.py+++ b/products/experiments/backend/hogql_queries/base_query_utils.py@@ -15,6 +15,7 @@ from posthog.schema import (ExperimentEventExposureConfig,ExperimentFunnelMetric,ExperimentMetricMathType,+ ExperimentWarehouseNativeNode,FunnelConversionWindowTimeUnit,FunnelMathType,GroupMathType,@@ -22,6 +23,7 @@ from posthog.schema import ()from posthog.hogql import ast+from posthog.hogql.errors import ExposedHogQLErrorfrom posthog.hogql.parser import parse_exprfrom posthog.hogql.property import action_to_expr, property_to_expr@@ -108,10 +110,14 @@ def is_threshold_supported_math(math_type: ExperimentMetricMathType | None) -> breturn math_type in [ExperimentMetricMathType.SUM, ExperimentMetricMathType.TOTAL]-def get_source_value_expr(source: Union[EventsNode, ActionsNode, ExperimentDataWarehouseNode]) -> ast.Expr:+def get_source_value_expr(+ source: Union[EventsNode, ActionsNode, ExperimentDataWarehouseNode, ExperimentWarehouseNativeNode],+) -> ast.Expr:"""Return the per-row value that the metric aggregates."""+ if isinstance(source, ExperimentWarehouseNativeNode):+ raise ExposedHogQLError("Warehouse-native sources cannot be calculated yet.")if isinstance(source, EventsNode) or isinstance(source, ActionsNode):if hasattr(source, "math") and is_continuous(source.math):diff --git a/products/experiments/backend/hogql_queries/experiment_actors_query.py b/products/experiments/backend/hogql_queries/experiment_actors_query.pyindex 995a8eb8d6b2..52f8c88b5b7d 100644--- a/products/experiments/backend/hogql_queries/experiment_actors_query.py+++ b/products/experiments/backend/hogql_queries/experiment_actors_query.py@@ -7,9 +7,15 @@ from typing import TYPE_CHECKINGfrom rest_framework.exceptions import ValidationError-from posthog.schema import ActionsNode, ExperimentEventExposureConfig, ExperimentFunnelMetric+from posthog.schema import (+ ActionsNode,+ ExperimentEventExposureConfig,+ ExperimentFunnelMetric,+ ExperimentWarehouseNativeExposureConfig,+)from posthog.hogql import ast+from posthog.hogql.errors import ExposedHogQLErrorfrom posthog.clickhouse.query_tagging import Product, tag_queries@@ -66,11 +72,12 @@ def build_experiment_actors_query(runner: "ExperimentQueryRunner") -> ast.Selectexposure_config: ExperimentEventExposureConfig | ActionsNodeactivation_config: ExperimentEventExposureConfig | ActionsNode | None = Noneif runner.actors_query.exposureConfig is not None:+ override = runner.actors_query.exposureConfig+ if isinstance(override, ExperimentWarehouseNativeExposureConfig):+ raise ExposedHogQLError("Warehouse-native sources cannot be calculated yet.")# An explicit override replaces the whole exposure definition, including any# stored activation event.- exposure_config = resolve_exposure_config_for_builder(- runner.actors_query.exposureConfig, runner.team, runner.experiment.start_date- )+ exposure_config = resolve_exposure_config_for_builder(override, runner.team, runner.experiment.start_date)else:# Same resolution as the main experiment query, so the actor list matches the counts.exposure_params = get_exposure_config_params_for_builder(diff --git a/products/experiments/backend/hogql_queries/experiment_query_builder.py b/products/experiments/backend/hogql_queries/experiment_query_builder.pyindex b25dbcde9942..f342d4e65d61 100644--- a/products/experiments/backend/hogql_queries/experiment_query_builder.py+++ b/products/experiments/backend/hogql_queries/experiment_query_builder.py@@ -15,11 +15,13 @@ from posthog.schema import (ExperimentMeanMetric,ExperimentRatioMetric,ExperimentRetentionMetric,+ ExperimentWarehouseNativeExposureConfig,MultipleVariantHandling,)from posthog.hogql import astfrom posthog.hogql.constants import MAX_SELECT_RETURNED_ROWS+from posthog.hogql.errors import ExposedHogQLErrorfrom posthog.hogql_queries.utils.query_date_range import QueryDateRangefrom posthog.models.team.team import Team@@ -88,30 +90,33 @@ def get_exposure_config_params_for_builder(filter_test_accounts = resolve_filter_test_accounts(criteria)exposure_config: ExperimentEventExposureConfig | ActionsNodeactivation_config: ExperimentEventExposureConfig | ActionsNode | None = None+ stored_exposure = criteria.exposure_config if criteria else None+ if isinstance(stored_exposure, ExperimentWarehouseNativeExposureConfig):+ raise ExposedHogQLError("Warehouse-native sources cannot be calculated yet.")if criteria is None:exposure_config = ExperimentEventExposureConfig(event=resolve_default_exposure_event(team, start_date), properties=[])multiple_variant_handling = MultipleVariantHandling.EXCLUDEelse:- if criteria.exposure_config is None:+ if stored_exposure is None:exposure_config = ExperimentEventExposureConfig(event=resolve_default_exposure_event(team, start_date), properties=[])elif (- isinstance(criteria.exposure_config, ExperimentEventExposureConfig)- and criteria.exposure_config.event == DEFAULT_EXPOSURE_EVENT+ isinstance(stored_exposure, ExperimentEventExposureConfig)+ and stored_exposure.event == DEFAULT_EXPOSURE_EVENT):# A config naming $feature_flag_called explicitly is the default exposure, not a# custom one (same convention as get_exposure_event_and_property), so it follows# the same event resolution while keeping its property filters.- exposure_config = resolve_exposure_config_for_builder(criteria.exposure_config, team, start_date)+ exposure_config = resolve_exposure_config_for_builder(stored_exposure, team, start_date)else:- exposure_config = criteria.exposure_config+ exposure_config = stored_exposure# Activation only composes with the default exposure; a custom exposure_config# disables it (validation rejects the combination, but stored data predating it# must not silently change semantics).- if is_default_exposure_config(criteria.exposure_config):+ if is_default_exposure_config(stored_exposure):activation_config = criteria.activation_configmultiple_variant_handling = criteria.multiple_variant_handling or MultipleVariantHandling.EXCLUDEdiff --git a/products/experiments/backend/hogql_queries/experiment_query_runner.py b/products/experiments/backend/hogql_queries/experiment_query_runner.pyindex 298d097c98bf..9575609d61d8 100644--- a/products/experiments/backend/hogql_queries/experiment_query_runner.py+++ b/products/experiments/backend/hogql_queries/experiment_query_runner.py@@ -74,7 +74,10 @@ from products.experiments.backend.hogql_queries.utils import (get_variant_results,split_baseline_and_test_variants,)-from products.experiments.backend.metric_resolution import metric_reads_data_warehouse+from products.experiments.backend.metric_resolution import (+ metric_reads_data_warehouse,+ metric_uses_warehouse_native_source,+)from products.experiments.backend.metric_utils import get_default_metric_titlefrom products.experiments.backend.models.experiment import Experimentfrom products.experiments.backend.models.team_experiments_config import TeamExperimentsConfig@@ -573,8 +576,17 @@ class ExperimentQueryRunner(ExperimentResultsCacheMixin, QueryRunner):return sorted_results, response.columns or []+ def _refuse_warehouse_sources(self) -> None:+ exposure_config = (self.experiment.exposure_criteria or {}).get("exposure_config") or {}+ if (+ metric_uses_warehouse_native_source(self.metric)+ or exposure_config.get("kind") == "ExperimentWarehouseNativeExposureConfig"+ ):+ raise ExposedHogQLError("Warehouse-native sources cannot be calculated yet.")+@experiment_error_handlerdef _calculate(self) -> ExperimentQueryResponse:+ self._refuse_warehouse_sources()variant_results = self._prepare_variant_results()if self._has_breakdown(variant_results):diff --git a/products/experiments/backend/hogql_queries/experiment_ratio_query_builder.py b/products/experiments/backend/hogql_queries/experiment_ratio_query_builder.pyindex 3525873d32ad..9fe9454640e6 100644--- a/products/experiments/backend/hogql_queries/experiment_ratio_query_builder.py+++ b/products/experiments/backend/hogql_queries/experiment_ratio_query_builder.py@@ -6,6 +6,7 @@ from posthog.schema import (ExperimentDataWarehouseNode,ExperimentMetricOutlierHandling,ExperimentRatioMetric,+ ExperimentWarehouseNativeNode,)from posthog.hogql import ast@@ -72,7 +73,7 @@ class RatioQueryBuilder:)def _metric_events_query_for_precomputation(- self, source: EventsNode | ActionsNode | ExperimentDataWarehouseNode+ self, source: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode) -> tuple[str, dict[str, ast.Expr]]:assert isinstance(source, (ActionsNode, EventsNode))return build_metric_events_precompute_query(diff --git a/products/experiments/backend/hogql_queries/exposure_query_logic.py b/products/experiments/backend/hogql_queries/exposure_query_logic.pyindex 4cad82a94678..f66c8aef7f7a 100644--- a/products/experiments/backend/hogql_queries/exposure_query_logic.py+++ b/products/experiments/backend/hogql_queries/exposure_query_logic.py@@ -11,10 +11,12 @@ from posthog.schema import (ActionsNode,ExperimentEventExposureConfig,ExperimentExposureCriteria,+ ExperimentWarehouseNativeExposureConfig,MultipleVariantHandling,)from posthog.hogql import ast+from posthog.hogql.errors import ExposedHogQLErrorfrom posthog.hogql.property import action_to_expr, property_to_exprfrom posthog.models.team.team import Team@@ -174,13 +176,17 @@ def normalize_to_exposure_criteria(if config and isinstance(config, dict):if _is_actions_node_dict(config):criteria_copy[config_key] = ActionsNode.model_validate(config)+ elif config.get("kind") == "ExperimentWarehouseNativeExposureConfig":+ criteria_copy[config_key] = ExperimentWarehouseNativeExposureConfig.model_validate(config)else:criteria_copy[config_key] = ExperimentEventExposureConfig.model_validate(config)return ExperimentExposureCriteria.model_validate(criteria_copy)-def is_default_exposure_config(config: Union[ActionsNode, ExperimentEventExposureConfig, None]) -> bool:+def is_default_exposure_config(+ config: Union[ActionsNode, ExperimentEventExposureConfig, ExperimentWarehouseNativeExposureConfig, None],+) -> bool:"""A missing config or one naming a default exposure event is the default exposure, not acustom one (same convention as get_exposure_event_and_property)."""if config is None:@@ -257,13 +263,14 @@ def get_exposure_event_and_property(exposure_config = criteria.exposure_config if criteria else None+ if isinstance(exposure_config, ExperimentWarehouseNativeExposureConfig):+ raise ExposedHogQLError("Warehouse-native sources cannot be calculated yet.")if isinstance(exposure_config, ActionsNode):# build_exposure_event_conditions applies the action filter.feature_flag_variant_property = f"$feature/{feature_flag_key}"event = Noneelif (- exposure_config- and hasattr(exposure_config, "event")+ isinstance(exposure_config, ExperimentEventExposureConfig)and exposure_config.eventand exposure_config.event not in (DEFAULT_EXPOSURE_EVENT, EXPERIMENT_EXPOSURE_EVENT)):@@ -285,7 +292,9 @@ def get_exposure_event_and_property(def _get_event_name_from_config(- exposure_config: Optional[Union[ActionsNode, ExperimentEventExposureConfig]],+ exposure_config: Optional[+ Union[ActionsNode, ExperimentEventExposureConfig, ExperimentWarehouseNativeExposureConfig]+ ],default_exposure_event: str,) -> str:if not exposure_config or not hasattr(exposure_config, "event"):@@ -310,13 +319,17 @@ def _build_action_filter(action_id: int, team: Team) -> ast.Expr:def _build_event_filters(- exposure_config: Optional[Union[ActionsNode, ExperimentEventExposureConfig]],+ exposure_config: Optional[+ Union[ActionsNode, ExperimentEventExposureConfig, ExperimentWarehouseNativeExposureConfig]+ ],team: Team,feature_flag_key: Optional[str],default_exposure_event: str,) -> list[ast.Expr]:if isinstance(exposure_config, ActionsNode):return [_build_action_filter(int(exposure_config.id), team)]+ if isinstance(exposure_config, ExperimentWarehouseNativeExposureConfig):+ raise ExposedHogQLError("Warehouse-native sources cannot be calculated yet.")event = _get_event_name_from_config(exposure_config, default_exposure_event)filters: list[ast.Expr] = [exposure_event_name_filter(event)]@@ -336,7 +349,10 @@ def _build_event_filters(def _build_property_filters(- exposure_config: Optional[Union[ActionsNode, ExperimentEventExposureConfig]], team: Team+ exposure_config: Optional[+ Union[ActionsNode, ExperimentEventExposureConfig, ExperimentWarehouseNativeExposureConfig]+ ],+ team: Team,) -> list[ast.Expr]:if not exposure_config or exposure_config.kind != "ExperimentEventExposureConfig" or not exposure_config.properties:return []diff --git a/products/experiments/backend/hogql_queries/metric_events_precompute.py b/products/experiments/backend/hogql_queries/metric_events_precompute.pyindex e4b5cef00123..1b84ab1c5bdd 100644--- a/products/experiments/backend/hogql_queries/metric_events_precompute.py+++ b/products/experiments/backend/hogql_queries/metric_events_precompute.py@@ -21,6 +21,7 @@ from posthog.schema import (ExperimentMetricMathType,ExperimentRatioMetric,ExperimentRetentionMetric,+ ExperimentWarehouseNativeNode,)from posthog.hogql import ast@@ -176,7 +177,7 @@ class MetricEventsPrecompute:return "retention_window"def _source_ineligibility_reason(- self, source: EventsNode | ActionsNode | ExperimentDataWarehouseNode+ self, source: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode) -> Optional[str]:"""The per-source rules for a mean-shaped build: a mean metric's source or either ratio side."""if not isinstance(source, (EventsNode, ActionsNode)):diff --git a/products/experiments/backend/hogql_queries/metric_source.py b/products/experiments/backend/hogql_queries/metric_source.pyindex d75b52d02c9c..24a82733345d 100644--- a/products/experiments/backend/hogql_queries/metric_source.py+++ b/products/experiments/backend/hogql_queries/metric_source.py@@ -1,8 +1,9 @@from typing import Union-from posthog.schema import ActionsNode, EventsNode, ExperimentDataWarehouseNode+from posthog.schema import ActionsNode, EventsNode, ExperimentDataWarehouseNode, ExperimentWarehouseNativeNodefrom posthog.hogql import ast+from posthog.hogql.errors import ExposedHogQLErrorfrom posthog.hogql.parser import parse_exprfrom posthog.clickhouse.query_tagging import tag_contains_user_hogql@@ -27,7 +28,7 @@ class MetricSourceInfo:@classmethoddef from_source(cls,- source: Union[EventsNode, ActionsNode, ExperimentDataWarehouseNode],+ source: Union[EventsNode, ActionsNode, ExperimentDataWarehouseNode, ExperimentWarehouseNativeNode],entity_key: str | None = None,) -> "MetricSourceInfo":"""@@ -35,6 +36,8 @@ class MetricSourceInfo:Events and actions sources require it and raise ValueError without it. Datawarehouse sources ignore it and use their data_warehouse_join_key."""+ if isinstance(source, ExperimentWarehouseNativeNode):+ raise ExposedHogQLError("Warehouse-native sources cannot be calculated yet.")if isinstance(source, ExperimentDataWarehouseNode):# `data_warehouse_join_key` is the user-supplied HogQL parsed below.tag_contains_user_hogql()diff --git a/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_experiment_exposures_query_runner.py b/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_experiment_exposures_query_runner.pyindex 09ac44586d26..87ed58b53529 100644--- a/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_experiment_exposures_query_runner.py+++ b/products/experiments/backend/hogql_queries/test/experiment_query_runner/test_experiment_exposures_query_runner.py@@ -14,11 +14,15 @@ from rest_framework.exceptions import ValidationErrorfrom posthog.schema import (ActionsNode,ExperimentEventExposureConfig,+ ExperimentExposureCriteria,ExperimentExposureHealthFindingCode,ExperimentExposureQuery,+ ExperimentWarehouseNativeExposureConfig,MultipleVariantHandling,)+from posthog.hogql.errors import ExposedHogQLError+from posthog.clickhouse.query_tagging import AccessMethod, tags_contextfrom posthog.constants import AvailableFeaturefrom posthog.models.activity_logging.activity_log import ActivityLog@@ -86,6 +90,20 @@ class TestExperimentExposuresQueryRunner(ExperimentQueryRunnerBaseTest):self.assertIn("has no variants", str(ctx.exception))+ def test_refuses_warehouse_native_exposure_criteria_as_a_query_error(self):+ # The request carries its own criteria, so a warehouse-native exposure reaches the runner+ # without a save. It must fail as a query error (a 400), not as a server error.+ query = self._null_multivariate_query()+ query.exposure_criteria = ExperimentExposureCriteria(+ exposure_config=ExperimentWarehouseNativeExposureConfig(+ connection_id="00000000-0000-0000-0000-000000000000",+ query="SELECT user_id AS entity_id, variant, exposed_at AS timestamp FROM exposures",+ )+ )++ with self.assertRaisesMessage(ExposedHogQLError, "Warehouse-native sources cannot be calculated yet."):+ ExperimentExposuresQueryRunner(team=self.team, query=query).calculate()+def test_missing_experiment_raises_validation_error(self):# Cached exposure queries can outlive their experiment; a stale id must# surface as a validation error, not an uncaught Experiment.DoesNotExist.diff --git a/products/experiments/backend/hogql_queries/test/test_experiment_actors_query.py b/products/experiments/backend/hogql_queries/test/test_experiment_actors_query.pyindex 2305095a22d0..86721de5bf68 100644--- a/products/experiments/backend/hogql_queries/test/test_experiment_actors_query.py+++ b/products/experiments/backend/hogql_queries/test/test_experiment_actors_query.py@@ -30,10 +30,12 @@ from posthog.schema import (ExperimentEventExposureConfig,ExperimentFunnelMetric,ExperimentQuery,+ ExperimentWarehouseNativeExposureConfig,HogQLPropertyFilter,)from posthog.hogql.context import HogQLContext+from posthog.hogql.errors import ExposedHogQLErrorfrom posthog.hogql_queries.actors_query_runner import ActorsQueryRunner@@ -228,6 +230,26 @@ class TestExperimentActorsQuery(ExperimentQueryRunnerBaseTest, ClickhouseTestMixwith self.assertRaisesMessage(ValidationError, "Persons are not available for evaluation pass rate metrics."):ActorsQueryRunner(query=actors_query, team=self.team).calculate()+ def test_experiment_actors_refuses_warehouse_native_exposure_override(self) -> None:+ # The override skips the save-time validation, so the runner must reject it as a query error.+ _feature_flag, _experiment, experiment_query = self._create_experiment_with_funnel()+ actors_query = ActorsQuery(+ source=ExperimentActorsQuery(+ kind="ExperimentActorsQuery",+ source=experiment_query,+ funnelStep=1,+ funnelStepBreakdown="control",+ exposureConfig=ExperimentWarehouseNativeExposureConfig(+ connection_id="00000000-0000-0000-0000-000000000000",+ query="SELECT user_id AS entity_id, variant, exposed_at AS timestamp FROM exposures",+ ),+ ),+ select=["id", "person"],+ )++ with self.assertRaisesMessage(ExposedHogQLError, "Warehouse-native sources cannot be calculated yet."):+ ActorsQueryRunner(query=actors_query, team=self.team).calculate()+@time_machine.travel(EXPERIMENT_EXPOSURE_EVENT_CUTOFF + timedelta(days=4), tick=False)def test_experiment_funnel_actors_resolves_explicit_default_exposure_event(self) -> None:feature_flag, experiment, experiment_query = self._create_experiment_with_funnel()diff --git a/products/experiments/backend/hogql_queries/test/test_exposure_query_logic.py b/products/experiments/backend/hogql_queries/test/test_exposure_query_logic.pyindex f0ef203615f8..1db109ee2973 100644--- a/products/experiments/backend/hogql_queries/test/test_exposure_query_logic.py+++ b/products/experiments/backend/hogql_queries/test/test_exposure_query_logic.py@@ -2,10 +2,18 @@ import pytestfrom parameterized import parameterized-from posthog.schema import ExperimentEventExposureConfig, ExperimentExposureCriteria, MultipleVariantHandling+from posthog.schema import (+ ExperimentEventExposureConfig,+ ExperimentExposureCriteria,+ ExperimentWarehouseNativeExposureConfig,+ MultipleVariantHandling,+)++from posthog.hogql.errors import ExposedHogQLErrorfrom posthog.models.team import Team+from products.experiments.backend.hogql_queries.experiment_query_builder import get_exposure_config_params_for_builderfrom products.experiments.backend.hogql_queries.exposure_query_logic import (DEFAULT_EXPOSURE_EVENT,EXPERIMENT_EXPOSURE_EVENT,@@ -20,6 +28,12 @@ def _event_config(event):return {"exposure_config": {"kind": "ExperimentEventExposureConfig", "event": event, "properties": []}}+_WAREHOUSE_NATIVE_EXPOSURE = ExperimentWarehouseNativeExposureConfig(+ connection_id="00000000-0000-0000-0000-000000000000",+ query="SELECT user_id AS entity_id, variant, exposed_at AS timestamp FROM exposures",+)++class TestGetExposureEventAndProperty:@parameterized.expand([@@ -122,6 +136,27 @@ class TestNormalizeToExposureCriteria:# Should return the exact same object, not a copyassert result is typed_criteria+ def test_stored_warehouse_native_exposure_config_matches_the_typed_object(self):+ # Stored criteria are a dict. A dict read as an event config would slip past the+ # warehouse-native guards and fail later with an unrelated error.+ from_dict = normalize_to_exposure_criteria(+ {"exposure_config": _WAREHOUSE_NATIVE_EXPOSURE.model_dump(mode="json")}+ )++ assert from_dict == ExperimentExposureCriteria(exposure_config=_WAREHOUSE_NATIVE_EXPOSURE)+++class TestGetExposureConfigParamsForBuilder:+ @parameterized.expand(+ [+ ("stored_dict", {"exposure_config": _WAREHOUSE_NATIVE_EXPOSURE.model_dump(mode="json")}),+ ("typed", ExperimentExposureCriteria(exposure_config=_WAREHOUSE_NATIVE_EXPOSURE)),+ ]+ )+ def test_refuses_warehouse_native_exposure_as_a_query_error(self, _name, exposure_criteria):+ with pytest.raises(ExposedHogQLError, match="cannot be calculated yet"):+ get_exposure_config_params_for_builder(exposure_criteria, Team(id=1, project_id=1), None)+class TestGetTestAccountsFilter:_team_filter = {"key": "$host", "type": "event", "value": "localhost", "operator": "not_icontains"}diff --git a/products/experiments/backend/metric_events.py b/products/experiments/backend/metric_events.pyindex ead78d62a61f..79d1c8e2a1a8 100644--- a/products/experiments/backend/metric_events.py+++ b/products/experiments/backend/metric_events.py@@ -30,6 +30,7 @@ from posthog.schema import (ExperimentMeanMetric,ExperimentRatioMetric,ExperimentRetentionMetric,+ ExperimentWarehouseNativeNode,HogQLQueryModifiers,)@@ -173,7 +174,9 @@ class MetricScanResult:dropped_metric_uuids: set[str]-def node_signature(node: MetricSourceNode | ExperimentDataWarehouseNode | ExperimentExposureNode) -> str:+def node_signature(+ node: MetricSourceNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode | ExperimentExposureNode,+) -> str:"""A stable identity for a source node. Two nodes with the same signature match the same eventsand share one aggregate in the scan, so they can only ever render identical hits."""return node.model_dump_json(exclude_none=True)@@ -181,7 +184,12 @@ def node_signature(node: MetricSourceNode | ExperimentDataWarehouseNode | Experidef _metric_sources(metric: ExperimentMetric,-) -> list[tuple[MetricSourceRole, MetricSourceNode | ExperimentDataWarehouseNode | ExperimentExposureNode]]:+) -> list[+ tuple[+ MetricSourceRole,+ MetricSourceNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode | ExperimentExposureNode,+ ]+]:if isinstance(metric, ExperimentMeanMetric):return [(MetricSourceRole.SOURCE, metric.source)]if isinstance(metric, ExperimentFunnelMetric):@@ -197,15 +205,20 @@ def _metric_sources(# the start's: a duplicate chip implying a return the scan can't distinguish from the entry. A# distinct completion event (or the same event narrowed by different properties) is a separate# signal worth showing, whichever window it opens in.- sources: list[tuple[MetricSourceRole, MetricSourceNode | ExperimentDataWarehouseNode | ExperimentExposureNode]] = [- (MetricSourceRole.RETENTION_START, metric.start_event)- ]+ sources: list[+ tuple[+ MetricSourceRole,+ MetricSourceNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode | ExperimentExposureNode,+ ]+ ] = [(MetricSourceRole.RETENTION_START, metric.start_event)]if node_signature(metric.completion_event) != node_signature(metric.start_event):sources.append((MetricSourceRole.RETENTION_COMPLETION, metric.completion_event))return sources-def _source_title(node: MetricSourceNode | ExperimentDataWarehouseNode | ExperimentExposureNode) -> str | None:+def _source_title(+ node: MetricSourceNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode | ExperimentExposureNode,+) -> str | None:"""Display name for one metric source node, mirroring the frontend `getDefaultName`."""if isinstance(node, EventsNode):return node.name or node.event@@ -213,6 +226,8 @@ def _source_title(node: MetricSourceNode | ExperimentDataWarehouseNode | Experimreturn node.name or f"Action {node.id}"if isinstance(node, ExperimentDataWarehouseNode):return node.table_name+ if isinstance(node, ExperimentWarehouseNativeNode):+ return node.custom_name or "Warehouse-native query"if isinstance(node, ExperimentExposureNode):return "Exposure"diff --git a/products/experiments/backend/metric_resolution.py b/products/experiments/backend/metric_resolution.pyindex 4dbd67fbd515..efedd3bfbba3 100644--- a/products/experiments/backend/metric_resolution.py+++ b/products/experiments/backend/metric_resolution.py@@ -15,6 +15,7 @@ from posthog.schema import (ExperimentMeanMetric,ExperimentRatioMetric,ExperimentRetentionMetric,+ ExperimentWarehouseNativeNode,)from posthog.dataclasses import frozen@@ -39,7 +40,12 @@ DAILY_TIMESERIES_METRIC_TYPES: frozenset[str] = frozenset(METRIC_BUILDERS)def is_daily_timeseries_metric(metric: dict[str, Any] | None) -> bool:- return bool(metric and metric.get("metric_type") in DAILY_TIMESERIES_METRIC_TYPES)+ return bool(+ metric+ and metric.get("metric_type") in DAILY_TIMESERIES_METRIC_TYPES+ # Warehouse-native sources have no calculation path yet, so the daily run must not attempt them.+ and not metric_dict_uses_warehouse_native_source(metric)+ )MetricRole = Literal["primary", "secondary"]@@ -204,23 +210,19 @@ def build_metric(metric_dict: dict[str, Any]) -> ExperimentMetric:# Such metrics never precompute (the precomputed table lacks the join keys). The source-bearing fields# are the same across the two readers below: source, series[*], numerator, denominator, start_event,# completion_event. Keep the pair in step — one reads the typed metric, the other a raw saved definition.-def metric_reads_data_warehouse(metric: ExperimentMetric) -> bool:- """Typed check, for callers that already hold a built metric (the query runner)."""+def metric_source_nodes(metric: ExperimentMetric) -> list[Any]:if isinstance(metric, ExperimentMeanMetric):- nodes: list[Any] = [metric.source]- elif isinstance(metric, ExperimentFunnelMetric):- nodes = list(metric.series)- elif isinstance(metric, ExperimentRatioMetric):- nodes = [metric.numerator, metric.denominator]- else:- nodes = [metric.start_event, metric.completion_event]- return any(isinstance(node, ExperimentDataWarehouseNode) for node in nodes)+ return [metric.source]+ if isinstance(metric, ExperimentFunnelMetric):+ return list(metric.series)+ if isinstance(metric, ExperimentRatioMetric):+ return [metric.numerator, metric.denominator]+ return [metric.start_event, metric.completion_event]-def metric_dict_reads_data_warehouse(metric_dict: dict[str, Any]) -> bool:- """Dict check, for callers that only hold a saved definition they may not be able to build (canary- sampling). A field absent on a shape is simply missing from the dict."""- nodes = [+def _metric_dict_source_nodes(metric_dict: dict[str, Any]) -> list[Any]:+ """A field absent on a shape is simply missing from the dict."""+ return [metric_dict.get("source"),*(metric_dict.get("series") or []),metric_dict.get("numerator"),@@ -228,4 +230,29 @@ def metric_dict_reads_data_warehouse(metric_dict: dict[str, Any]) -> bool:metric_dict.get("start_event"),metric_dict.get("completion_event"),]- return any(isinstance(node, dict) and node.get("kind") == "ExperimentDataWarehouseNode" for node in nodes)+++def metric_reads_data_warehouse(metric: ExperimentMetric) -> bool:+ """Typed check, for callers that already hold a built metric (the query runner)."""+ return any(isinstance(node, ExperimentDataWarehouseNode) for node in metric_source_nodes(metric))+++def metric_dict_reads_data_warehouse(metric_dict: dict[str, Any]) -> bool:+ """Dict check, for callers that only hold a saved definition they may not be able to build (canary+ sampling)."""+ return any(+ isinstance(node, dict) and node.get("kind") == "ExperimentDataWarehouseNode"+ for node in _metric_dict_source_nodes(metric_dict)+ )+++# A metric with a warehouse-native source runs in the customer's warehouse, not in ClickHouse.+def metric_uses_warehouse_native_source(metric: ExperimentMetric) -> bool:+ return any(isinstance(node, ExperimentWarehouseNativeNode) for node in metric_source_nodes(metric))+++def metric_dict_uses_warehouse_native_source(metric_dict: dict[str, Any]) -> bool:+ return any(+ isinstance(node, dict) and node.get("kind") == "ExperimentWarehouseNativeNode"+ for node in _metric_dict_source_nodes(metric_dict)+ )diff --git a/products/experiments/backend/metric_utils.py b/products/experiments/backend/metric_utils.pyindex 671401234878..204d1249b37c 100644--- a/products/experiments/backend/metric_utils.py+++ b/products/experiments/backend/metric_utils.py@@ -20,6 +20,8 @@ def _get_source_name(source: object) -> str:return source.get("table_name") or "Table"if kind == "ExperimentExposureNode":return "Exposure"+ if kind == "ExperimentWarehouseNativeNode":+ return source.get("custom_name") or "Warehouse-native query"# EventsNode or ActionsNodereturn source.get("name") or source.get("event") or "Event"diff --git a/products/experiments/backend/metric_validation.py b/products/experiments/backend/metric_validation.pyindex d9c12cdcc1b1..300fcf80955c 100644--- a/products/experiments/backend/metric_validation.py+++ b/products/experiments/backend/metric_validation.py@@ -32,7 +32,11 @@ from products.event_definitions.backend.models import EventDefinition, effectivefrom products.experiments.backend.hogql_queries.base_query_utils import is_threshold_supported_mathfrom products.experiments.backend.hogql_queries.funnel_validation import FunnelDWValidatorfrom products.experiments.backend.hogql_queries.retention_validation import retention_metric_error-from products.experiments.backend.metric_resolution import METRIC_BUILDERS, ExperimentMetric+from products.experiments.backend.metric_resolution import (+ METRIC_BUILDERS,+ ExperimentMetric,+ metric_uses_warehouse_native_source,+)from products.experiments.backend.models.experiment import LEGACY_METRIC_KINDSlogger = structlog.get_logger(__name__)@@ -144,6 +148,9 @@ def parse_and_validate_metric(metric: object, *, error_prefix: str) -> Experimenraise ValidationError(f"{error_prefix}{_pydantic_error_message(e)}")error = _semantic_error(parsed)+ if error is None and metric_uses_warehouse_native_source(parsed):+ # The source kind exists so the rest of the product can be built against it; nothing can run it yet.+ error = "warehouse-native sources are not supported yet."if error:raise ValidationError(f"{error_prefix}{error}")return parseddiff --git a/products/experiments/backend/setup_context.py b/products/experiments/backend/setup_context.pyindex 3cf1c92e945d..6e6a3d8e9246 100644--- a/products/experiments/backend/setup_context.py+++ b/products/experiments/backend/setup_context.py@@ -1135,7 +1135,10 @@ def _custom_exposure(experiment: Experiment, exposure_criteria: dict[str, Any])return exposureif isinstance(config, ActionsNode):return dataclasses.replace(exposure, action_id=int(config.id))- return dataclasses.replace(exposure, event=str(config.event) if config and config.event else None)+ return dataclasses.replace(+ exposure,+ event=str(config.event) if isinstance(config, ExperimentEventExposureConfig) and config.event else None,+ )def _filters_test_accounts(exposure_criteria: dict[str, Any]) -> bool:diff --git a/products/experiments/backend/test/test_experiment_saved_metric_service.py b/products/experiments/backend/test/test_experiment_saved_metric_service.pyindex 56b9adf10f4f..272661eb1dbb 100644--- a/products/experiments/backend/test/test_experiment_saved_metric_service.py+++ b/products/experiments/backend/test/test_experiment_saved_metric_service.py@@ -16,7 +16,19 @@ _THRESHOLD_MEAN: dict[str, object] = {"source": {"kind": "EventsNode", "event": "$pageview", "math": "sum", "math_property": "amount"},}+_WAREHOUSE_NATIVE_MEAN: dict[str, object] = {+ "kind": "ExperimentMetric",+ "metric_type": "mean",+ "source": {+ "kind": "ExperimentWarehouseNativeNode",+ "connection_id": "00000000-0000-0000-0000-000000000000",+ "query": "SELECT user_id AS entity_id, paid_at AS timestamp, amount AS value FROM payments",+ "math": "sum",+ },+}+_SHARED_RULE_CASES: list[tuple[str, dict[str, object], str]] = [+ ("warehouse_native_not_supported_yet", _WAREHOUSE_NATIVE_MEAN, "warehouse-native sources are not supported yet"),("funnel_without_steps",{"kind": "ExperimentMetric", "metric_type": "funnel", "series": []},diff --git a/products/experiments/backend/test/test_experiment_service.py b/products/experiments/backend/test/test_experiment_service.pyindex 58ae7b8db316..5576ad0a5f88 100644--- a/products/experiments/backend/test/test_experiment_service.py+++ b/products/experiments/backend/test/test_experiment_service.py@@ -875,6 +875,34 @@ class TestExperimentService(APIBaseTest):"exposure_criteria.exposure_config.kind must be one of ""['ExperimentEventExposureConfig', 'ActionsNode'], got 'EventsNode'",),+ (+ "exposure_config_warehouse_native_not_supported",+ {+ "exposure_config": {+ "kind": "ExperimentWarehouseNativeExposureConfig",+ "connection_id": "00000000-0000-0000-0000-000000000000",+ "query": "SELECT user_id AS entity_id, variant, exposed_at AS timestamp FROM exposures",+ }+ },+ "exposure_criteria.exposure_config: warehouse-native exposures are not supported yet",+ ),+ (+ "activation_config_warehouse_native_rejected",+ {+ "activation_config": {+ "kind": "ExperimentWarehouseNativeExposureConfig",+ "connection_id": "00000000-0000-0000-0000-000000000000",+ "query": "SELECT user_id AS entity_id, variant, exposed_at AS timestamp FROM exposures",+ }+ },+ "exposure_criteria.activation_config.kind must be one of "+ "['ExperimentEventExposureConfig', 'ActionsNode'], got 'ExperimentWarehouseNativeExposureConfig'",+ ),+ (+ "exposure_config_warehouse_native_missing_query",+ {"exposure_config": {"kind": "ExperimentWarehouseNativeExposureConfig", "connection_id": "c"}},+ "Invalid exposure_criteria.exposure_config (kind='ExperimentWarehouseNativeExposureConfig')",+ ),("exposure_config_event_kind_missing_event",{"exposure_config": {"kind": "ExperimentEventExposureConfig", "properties": []}},diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.tsindex 8ae567f1b9d1..16882a160ed3 100644--- a/products/experiments/frontend/generated/api.schemas.ts+++ b/products/experiments/frontend/generated/api.schemas.ts@@ -1860,6 +1860,32 @@ export interface ExperimentDataWarehouseNodeApi {version?: number | null}+export type ExperimentWarehouseNativeMathTypeApi =+ (typeof ExperimentWarehouseNativeMathTypeApi)[keyof typeof ExperimentWarehouseNativeMathTypeApi]++export const ExperimentWarehouseNativeMathTypeApi = {+ Total: 'total',+ Sum: 'sum',+} as const++export type ExperimentWarehouseNativeNodeApiResponse = { [key: string]: unknown } | null++export interface ExperimentWarehouseNativeNodeApi {+ /** The direct-query source (an ExternalDataSource id) the SQL is written for. */+ connection_id: string+ custom_name?: string | null+ kind?: 'ExperimentWarehouseNativeNode'+ /** How to aggregate the rows per entity. Defaults to `total` (row count). */+ math?: ExperimentWarehouseNativeMathTypeApi | null+ /** The numeric column `math` reads. Required when `math` is `sum`. One SQL relation can serve several metrics, each reading a different column. */+ math_property?: string | null+ /** Read-only SQL in the warehouse's dialect, returning one row per outcome with `entity_id` and `timestamp` columns plus any numeric columns a metric can measure. */+ query: string+ response?: ExperimentWarehouseNativeNodeApiResponse+ /** version of the node, used for schema migrations */+ version?: number | null+}+export type ExperimentMeanMetricApiResponse = { [key: string]: unknown } | nullexport interface ExperimentMeanMetricApi {@@ -1877,7 +1903,7 @@ export interface ExperimentMeanMetricApi {name?: string | nullresponse?: ExperimentMeanMetricApiResponsesharedMetricId?: number | null- source: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi+ source: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi | ExperimentWarehouseNativeNodeApi/** When set, reports the percentage of users whose per-user summed/counted value reaches or exceeds this threshold. Only meaningful for sum/count math types. */threshold?: number | null/** Winsorization upper percentile bound, as a fraction in [0, 1] (e.g. 0.99 for the 99th percentile). */@@ -1957,7 +1983,7 @@ export interface ExperimentRatioMetricApi {breakdownFilter?: BreakdownFilterApi | nullconversion_window?: number | nullconversion_window_unit?: FunnelConversionWindowTimeUnitApi | null- denominator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi+ denominator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi | ExperimentWarehouseNativeNodeApidenominator_outlier_handling?: ExperimentMetricOutlierHandlingApi | nullfingerprint?: string | nullgoal?: ExperimentMetricGoalApi | null@@ -1965,7 +1991,7 @@ export interface ExperimentRatioMetricApi {kind?: 'ExperimentMetric'metric_type: ExperimentRatioMetricApiMetricTypename?: string | null- numerator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi+ numerator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi | ExperimentWarehouseNativeNodeApinumerator_outlier_handling?: ExperimentMetricOutlierHandlingApi | nullresponse?: ExperimentRatioMetricApiResponsesharedMetricId?: number | nulldiff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex fbbc98e5af92..0c7129287620 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -5276,6 +5276,19 @@ export interface ExperimentEventExposureConfigApi {version?: number | null}+export type ExperimentWarehouseNativeExposureConfigApiResponse = { [key: string]: unknown } | null++export interface ExperimentWarehouseNativeExposureConfigApi {+ /** The direct-query source (an ExternalDataSource id) the SQL is written for. */+ connection_id: string+ kind?: 'ExperimentWarehouseNativeExposureConfig'+ /** Read-only SQL in the warehouse's dialect, returning one row per exposure with `entity_id`, `variant` and `timestamp` columns. PostHog keeps the first exposure per entity and applies the experiment's date range and multiple-variant handling. */+ query: string+ response?: ExperimentWarehouseNativeExposureConfigApiResponse+ /** version of the node, used for schema migrations */+ version?: number | null+}+export type MultipleVariantHandlingApi = (typeof MultipleVariantHandlingApi)[keyof typeof MultipleVariantHandlingApi]export const MultipleVariantHandlingApi = {@@ -5380,6 +5393,32 @@ export interface ExperimentDataWarehouseNodeApi {version?: number | null}+export type ExperimentWarehouseNativeMathTypeApi =+ (typeof ExperimentWarehouseNativeMathTypeApi)[keyof typeof ExperimentWarehouseNativeMathTypeApi]++export const ExperimentWarehouseNativeMathTypeApi = {+ Total: 'total',+ Sum: 'sum',+} as const++export type ExperimentWarehouseNativeNodeApiResponse = { [key: string]: unknown } | null++export interface ExperimentWarehouseNativeNodeApi {+ /** The direct-query source (an ExternalDataSource id) the SQL is written for. */+ connection_id: string+ custom_name?: string | null+ kind?: 'ExperimentWarehouseNativeNode'+ /** How to aggregate the rows per entity. Defaults to `total` (row count). */+ math?: ExperimentWarehouseNativeMathTypeApi | null+ /** The numeric column `math` reads. Required when `math` is `sum`. One SQL relation can serve several metrics, each reading a different column. */+ math_property?: string | null+ /** Read-only SQL in the warehouse's dialect, returning one row per outcome with `entity_id` and `timestamp` columns plus any numeric columns a metric can measure. */+ query: string+ response?: ExperimentWarehouseNativeNodeApiResponse+ /** version of the node, used for schema migrations */+ version?: number | null+}+export type ExperimentMeanMetricApiResponse = { [key: string]: unknown } | nullexport interface ExperimentMeanMetricApi {@@ -5397,7 +5436,7 @@ export interface ExperimentMeanMetricApi {name?: string | nullresponse?: ExperimentMeanMetricApiResponsesharedMetricId?: number | null- source: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi+ source: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi | ExperimentWarehouseNativeNodeApi/** When set, reports the percentage of users whose per-user summed/counted value reaches or exceeds this threshold. Only meaningful for sum/count math types. */threshold?: number | null/** Winsorization upper percentile bound, as a fraction in [0, 1] (e.g. 0.99 for the 99th percentile). */@@ -5446,7 +5485,7 @@ export interface ExperimentRatioMetricApi {breakdownFilter?: BreakdownFilterApi | nullconversion_window?: number | nullconversion_window_unit?: FunnelConversionWindowTimeUnitApi | null- denominator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi+ denominator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi | ExperimentWarehouseNativeNodeApidenominator_outlier_handling?: ExperimentMetricOutlierHandlingApi | nullfingerprint?: string | nullgoal?: ExperimentMetricGoalApi | null@@ -5454,7 +5493,7 @@ export interface ExperimentRatioMetricApi {kind?: 'ExperimentMetric'metric_type?: 'ratio'name?: string | null- numerator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi+ numerator: EventsNodeApi | ActionsNodeApi | ExperimentDataWarehouseNodeApi | ExperimentWarehouseNativeNodeApinumerator_outlier_handling?: ExperimentMetricOutlierHandlingApi | nullresponse?: ExperimentRatioMetricApiResponsesharedMetricId?: number | null@@ -5626,7 +5665,11 @@ export interface ExperimentQueryApi {export interface ExperimentActorsQueryApi {/** Exposure configuration for filtering events. Defines when users were first exposed to the experiment. */- exposureConfig?: ExperimentEventExposureConfigApi | ActionsNodeApi | null+ exposureConfig?:+ | ExperimentEventExposureConfigApi+ | ActionsNodeApi+ | ExperimentWarehouseNativeExposureConfigApi+ | null/** Feature flag key for breakdown filtering. */featureFlagKey?: string | null/** Index of the step for which we want to get actors for, per experiment variant. Positive for converted persons, negative for dropped off persons. */diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 5ca8a7eb45c5..4507f258c2a9 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -7423,6 +7423,19 @@ export namespace Schemas {version?: number | null;}+ export type ExperimentWarehouseNativeExposureConfigResponse = { [key: string]: unknown } | null;++ export interface ExperimentWarehouseNativeExposureConfig {+ /** The direct-query source (an ExternalDataSource id) the SQL is written for. */+ connection_id: string;+ kind?: 'ExperimentWarehouseNativeExposureConfig';+ /** Read-only SQL in the warehouse's dialect, returning one row per exposure with `entity_id`, `variant` and `timestamp` columns. PostHog keeps the first exposure per entity and applies the experiment's date range and multiple-variant handling. */+ query: string;+ response?: ExperimentWarehouseNativeExposureConfigResponse;+ /** version of the node, used for schema migrations */+ version?: number | null;+ }+export type MultipleVariantHandling = typeof MultipleVariantHandling[keyof typeof MultipleVariantHandling];@@ -7473,6 +7486,32 @@ export namespace Schemas {version?: number | null;}+ export type ExperimentWarehouseNativeMathType = typeof ExperimentWarehouseNativeMathType[keyof typeof ExperimentWarehouseNativeMathType];+++ export const ExperimentWarehouseNativeMathType = {+ Total: 'total',+ Sum: 'sum',+ } as const;++ export type ExperimentWarehouseNativeNodeResponse = { [key: string]: unknown } | null;++ export interface ExperimentWarehouseNativeNode {+ /** The direct-query source (an ExternalDataSource id) the SQL is written for. */+ connection_id: string;+ custom_name?: string | null;+ kind?: 'ExperimentWarehouseNativeNode';+ /** How to aggregate the rows per entity. Defaults to `total` (row count). */+ math?: ExperimentWarehouseNativeMathType | null;+ /** The numeric column `math` reads. Required when `math` is `sum`. One SQL relation can serve several metrics, each reading a different column. */+ math_property?: string | null;+ /** Read-only SQL in the warehouse's dialect, returning one row per outcome with `entity_id` and `timestamp` columns plus any numeric columns a metric can measure. */+ query: string;+ response?: ExperimentWarehouseNativeNodeResponse;+ /** version of the node, used for schema migrations */+ version?: number | null;+ }+export type ExperimentMeanMetricResponse = { [key: string]: unknown } | null;export interface ExperimentMeanMetric {@@ -7490,7 +7529,7 @@ export namespace Schemas {name?: string | null;response?: ExperimentMeanMetricResponse;sharedMetricId?: number | null;- source: EventsNode | ActionsNode | ExperimentDataWarehouseNode;+ source: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode;/** When set, reports the percentage of users whose per-user summed/counted value reaches or exceeds this threshold. Only meaningful for sum/count math types. */threshold?: number | null;/** Winsorization upper percentile bound, as a fraction in [0, 1] (e.g. 0.99 for the 99th percentile). */@@ -7553,7 +7592,7 @@ export namespace Schemas {breakdownFilter?: BreakdownFilter | null;conversion_window?: number | null;conversion_window_unit?: FunnelConversionWindowTimeUnit | null;- denominator: EventsNode | ActionsNode | ExperimentDataWarehouseNode;+ denominator: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode;denominator_outlier_handling?: ExperimentMetricOutlierHandling | null;fingerprint?: string | null;goal?: ExperimentMetricGoal | null;@@ -7561,7 +7600,7 @@ export namespace Schemas {kind?: 'ExperimentMetric';metric_type: ExperimentRatioMetricMetricType;name?: string | null;- numerator: EventsNode | ActionsNode | ExperimentDataWarehouseNode;+ numerator: EventsNode | ActionsNode | ExperimentDataWarehouseNode | ExperimentWarehouseNativeNode;numerator_outlier_handling?: ExperimentMetricOutlierHandling | null;response?: ExperimentRatioMetricResponse;sharedMetricId?: number | null;@@ -7738,7 +7777,7 @@ export namespace Schemas {export interface ExperimentActorsQuery {/** Exposure configuration for filtering events. Defines when users were first exposed to the experiment. */- exposureConfig?: ExperimentEventExposureConfig | ActionsNode | null;+ exposureConfig?: ExperimentEventExposureConfig | ActionsNode | ExperimentWarehouseNativeExposureConfig | null;/** Feature flag key for breakdown filtering. */featureFlagKey?: string | null;/** Index of the step for which we want to get actors for, per experiment variant. Positive for converted persons, negative for dropped off persons. */@@ -47727,9 +47766,9 @@ export namespace Schemas {}export interface ExperimentExposureCriteria {- /** Additional event (or action) an entity must emit at/after their first default exposure event before they count as exposed; exposure time becomes this event's timestamp. Only valid with the default exposure event, not a custom `exposure_config`. */+ /** Additional event (or action) an entity must emit at/after their first default exposure event before they count as exposed; exposure time becomes this event's timestamp. Only valid with the default exposure event, not a custom `exposure_config`. Warehouse-native activation has no defined semantics yet, so only events and actions apply here. */activation_config?: ExperimentEventExposureConfig | ActionsNode | null;- exposure_config?: ExperimentEventExposureConfig | ActionsNode | null;+ exposure_config?: ExperimentEventExposureConfig | ActionsNode | ExperimentWarehouseNativeExposureConfig | null;filterTestAccounts?: boolean | null;multiple_variant_handling?: MultipleVariantHandling | null;}