Skip to content

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

chore(experiments): delete unused ResultsBreakdown and metrics view leftovers (#100031)

Andersc0b80792f348
diff --git a/frontend/src/scenes/experiments/MetricsView/shared/AddMetric.tsx b/frontend/src/scenes/experiments/MetricsView/shared/AddMetric.tsx
deleted file mode 100644
index 131a8a4b94ee..000000000000
--- a/frontend/src/scenes/experiments/MetricsView/shared/AddMetric.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { useActions } from 'kea'
-
-import { IconPlus } from '@posthog/icons'
-
-import { LemonButton } from 'lib/lemon-ui/LemonButton'
-import { modalsLogic } from 'scenes/experiments/modalsLogic'
-
-export function AddPrimaryMetric(): JSX.Element {
- const { openPrimaryMetricSourceModal } = useActions(modalsLogic)
-
- return (
- <LemonButton
- icon={<IconPlus />}
- type="secondary"
- size="xsmall"
- onClick={() => {
- openPrimaryMetricSourceModal()
- }}
- >
- Add primary metric
- </LemonButton>
- )
-}
-
-export function AddSecondaryMetric(): JSX.Element {
- const { openSecondaryMetricSourceModal } = useActions(modalsLogic)
-
- return (
- <LemonButton
- icon={<IconPlus />}
- type="secondary"
- size="xsmall"
- onClick={() => {
- openSecondaryMetricSourceModal()
- }}
- >
- Add secondary metric
- </LemonButton>
- )
-}
diff --git a/frontend/src/scenes/experiments/MetricsView/shared/GridLines.tsx b/frontend/src/scenes/experiments/MetricsView/shared/GridLines.tsx
deleted file mode 100644
index cadf1138679b..000000000000
--- a/frontend/src/scenes/experiments/MetricsView/shared/GridLines.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { COLORS } from './colors'
-
-interface GridLinesProps {
- tickValues: number[]
- valueToX: (value: number) => number
- height: number
-}
-
-export function GridLines({ tickValues, valueToX, height }: GridLinesProps): JSX.Element {
- return (
- <>
- {tickValues.map((value) => {
- const x = valueToX(value)
- return (
- <line
- key={value}
- x1={x}
- y1={0}
- x2={x}
- y2={height}
- stroke={value === 0 ? COLORS.ZERO_LINE : COLORS.BOUNDARY_LINES}
- strokeWidth={value === 0 ? 1 : 0.5}
- />
- )
- })}
- </>
- )
-}
diff --git a/frontend/src/scenes/experiments/MetricsView/shared/utils.ts b/frontend/src/scenes/experiments/MetricsView/shared/utils.ts
index ebab8c9a00c9..f6bdd62cca13 100644
--- a/frontend/src/scenes/experiments/MetricsView/shared/utils.ts
+++ b/frontend/src/scenes/experiments/MetricsView/shared/utils.ts
@@ -9,7 +9,6 @@ import type {
ExperimentTrendsQuery,
ExperimentVariantResultBayesian,
ExperimentVariantResultFrequentist,
- NewExperimentQueryResponse,
} from '~/queries/schema/schema-general'
import {
ExperimentDataWarehouseNode,
@@ -374,16 +373,6 @@ export function getMetricColors(
}
}
-export function hasValidationFailures(result: NewExperimentQueryResponse | null): boolean {
- if (!result) {
- return false
- }
- return !!(
- result.baseline?.validation_failures?.length ||
- result.variant_results?.some((v) => v.validation_failures?.length)
- )
-}
-
export function getValidationFailureType(variant: ExperimentStatsBaseValidated): 'not-enough-data' | 'error' | null {
if (!variant.validation_failures || variant.validation_failures.length === 0) {
return null
diff --git a/frontend/src/scenes/experiments/components/ResultsBreakdown/ExploreAsInsightButton.tsx b/frontend/src/scenes/experiments/components/ResultsBreakdown/ExploreAsInsightButton.tsx
deleted file mode 100644
index 674ec83140df..000000000000
--- a/frontend/src/scenes/experiments/components/ResultsBreakdown/ExploreAsInsightButton.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { IconAreaChart } from 'lib/lemon-ui/icons'
-import { LemonButton } from 'lib/lemon-ui/LemonButton'
-import { urls } from 'scenes/urls'
-
-import type { ResultBreakdownRenderProps } from './types'
-
-/**
- * make the props non-nullable
- */
-type SafeResultBreakdownRenderProps = {
- [K in keyof Pick<ResultBreakdownRenderProps, 'query'>]: NonNullable<ResultBreakdownRenderProps[K]>
-}
-
-export function ExploreAsInsightButton({ query }: SafeResultBreakdownRenderProps): JSX.Element {
- return (
- <LemonButton
- className="ml-auto -translate-y-2"
- size="xsmall"
- type="primary"
- icon={<IconAreaChart />}
- to={urls.insightNew({ query })}
- targetBlank
- >
- Explore as Insight
- </LemonButton>
- )
-}
diff --git a/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsBreakdown.tsx b/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsBreakdown.tsx
deleted file mode 100644
index 59e9de31ea42..000000000000
--- a/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsBreakdown.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { BindLogic } from 'kea'
-
-import type { CachedExperimentQueryResponse } from '~/queries/schema/schema-general'
-import type { Experiment } from '~/types'
-
-import { ResultsBreakdownContent } from './ResultsBreakdownContent'
-import { resultsBreakdownLogic } from './resultsBreakdownLogic'
-import type { ResultBreakdownRenderProps } from './types'
-
-export const ResultsBreakdown = ({
- result,
- experiment,
- metricUuid,
- isPrimary,
- children,
-}: {
- result: CachedExperimentQueryResponse
- experiment: Experiment
- metricUuid: string
- isPrimary: boolean
- children?: (props: ResultBreakdownRenderProps) => JSX.Element | null
-}): JSX.Element | null => {
- return (
- <BindLogic logic={resultsBreakdownLogic} props={{ experiment, metric: result.metric, metricUuid, isPrimary }}>
- <ResultsBreakdownContent result={result}>{children}</ResultsBreakdownContent>
- </BindLogic>
- )
-}
diff --git a/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsBreakdownContent.tsx b/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsBreakdownContent.tsx
deleted file mode 100644
index 49fceacd0e3e..000000000000
--- a/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsBreakdownContent.tsx
+++ /dev/null
@@ -1,90 +0,0 @@
-import { useValues } from 'kea'
-
-import { isNewExperimentResponse } from 'scenes/experiments/experimentLogic'
-
-import {
- CachedExperimentQueryResponse,
- CachedNewExperimentQueryResponse,
- ExperimentVariantFunnelsBaseStats,
- ExperimentVariantTrendsBaseStats,
-} from '~/queries/schema/schema-general'
-import { FunnelStep } from '~/types'
-
-import { resultsBreakdownLogic } from './resultsBreakdownLogic'
-import type { ResultBreakdownRenderProps } from './types'
-
-const isExperimentVariantFunnels = (
- variant: ExperimentVariantTrendsBaseStats | ExperimentVariantFunnelsBaseStats
-): variant is ExperimentVariantFunnelsBaseStats => {
- return 'success_count' in variant && 'failure_count' in variant
-}
-
-const calculateLegacyExposureCount = (result: CachedExperimentQueryResponse): number => {
- if (!result.variants) {
- return -1
- }
-
- return (result.variants as (ExperimentVariantTrendsBaseStats | ExperimentVariantFunnelsBaseStats)[]).reduce(
- (acc: number, variant: ExperimentVariantTrendsBaseStats | ExperimentVariantFunnelsBaseStats) => {
- if (isExperimentVariantFunnels(variant)) {
- return acc + variant.success_count + variant.failure_count
- }
- return acc + variant.count
- },
- 0
- )
-}
-
-const calculateExposureCount = (result: CachedNewExperimentQueryResponse): number =>
- [result.baseline, ...(result.variant_results || [])].reduce(
- (acc, { number_of_samples }) => acc + number_of_samples,
- 0
- )
-
-/**
- * we calculate the exposure difference between the metric results and the breakdown results.
- * we can get exposure count from the experiment logic or the metric results, but this may change in the future.
- *
- * If something fails, we return -1.
- */
-const calculateExposureDifference = (
- result: CachedExperimentQueryResponse,
- breakdownResults: FunnelStep[][] | null
-): number => {
- // calculate the breakdown results total
- const breakdownResultsTotalExposureCount = breakdownResults
- ? breakdownResults.reduce((acc, result) => {
- return acc + result[0].count
- }, 0)
- : 0
-
- if (isNewExperimentResponse(result)) {
- return calculateExposureCount(result) - breakdownResultsTotalExposureCount
- }
-
- return calculateLegacyExposureCount(result) - breakdownResultsTotalExposureCount
-}
-
-export const ResultsBreakdownContent = ({
- result,
- children,
-}: {
- result: CachedExperimentQueryResponse
- children?: (props: ResultBreakdownRenderProps) => JSX.Element | null
-}): JSX.Element | null => {
- const { query, breakdownResults, breakdownResultsLoading, breakdownLastRefresh } = useValues(resultsBreakdownLogic)
-
- const exposureDifference = calculateExposureDifference(result, breakdownResults as FunnelStep[][])
-
- /**
- * if `children` is a function, we call it with the query and breakdown results,
- * otherwise we return null.
- * children can narrow the props type to omit or make it non-nullable.
- *
- * This is the limit for a render prop. If we need to pass more props,
- * we should use a shared context with props.
- */
- return children && typeof children === 'function'
- ? children({ query, breakdownResults, breakdownResultsLoading, exposureDifference, breakdownLastRefresh })
- : null
-}
diff --git a/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsBreakdownSkeleton.tsx b/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsBreakdownSkeleton.tsx
deleted file mode 100644
index bdfcee2c76c0..000000000000
--- a/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsBreakdownSkeleton.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'
-
-export const ResultsBreakdownSkeleton = (): JSX.Element => {
- /**
- * this is matching the styles of ChartLoadingState.tsx. Why not reuse that component?
- * it takes a height prop, but we don't need it here.
- */
- return (
- <div className="space-y-4">
- <div className="border rounded-lg p-4 bg-bg-light space-y-3">
- <div className="flex items-center justify-center gap-2 font-normal">
- <Spinner className="text-lg" />
- <span>Loading breakdown</span>
- </div>
- </div>
- </div>
- )
-}
diff --git a/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsInsightInfoBanner.tsx b/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsInsightInfoBanner.tsx
deleted file mode 100644
index d473e81faea8..000000000000
--- a/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsInsightInfoBanner.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { LemonBanner, Link } from '@posthog/lemon-ui'
-
-import type { ResultBreakdownRenderProps } from './types'
-
-type SafeResultsInsightInfoBanner = {
- [K in keyof Pick<ResultBreakdownRenderProps, 'exposureDifference'>]: NonNullable<ResultBreakdownRenderProps[K]>
-}
-
-export const ResultsInsightInfoBanner = ({ exposureDifference }: SafeResultsInsightInfoBanner): JSX.Element | null => {
- if (exposureDifference === 0) {
- return null
- }
-
- return (
- <LemonBanner type="info" className="mb-4">
- <div className="items-center inline-flex flex-wrap">
- <span>
- Insight results may be slightly different from exposure results due to a difference in data
- processing methods. We're actively working on fixing this.&nbsp;
- <Link
- to="https://posthog.com/docs/experiments/common-questions"
- className="font-semibold text-primary hover:text-primary-dark"
- >
- Learn more in our docs
- </Link>
- .
- </span>
- </div>
- </LemonBanner>
- )
-}
diff --git a/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsQuery.tsx b/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsQuery.tsx
deleted file mode 100644
index 6c64f304919a..000000000000
--- a/frontend/src/scenes/experiments/components/ResultsBreakdown/ResultsQuery.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import { Query } from '~/queries/Query/Query'
-import { NodeKind } from '~/queries/schema/schema-general'
-import type { InsightShortId } from '~/types'
-
-import type { ResultBreakdownRenderProps } from './types'
-
-/**
- * make the props non-nullable except for breakdownLastRefresh which can be null
- */
-type SafeResultBreakdownRenderProps = {
- [K in keyof Omit<
- ResultBreakdownRenderProps,
- 'breakdownResultsLoading' | 'exposureDifference' | 'breakdownLastRefresh'
- >]: NonNullable<ResultBreakdownRenderProps[K]>
-} & {
- breakdownLastRefresh: string | null
-}
-
-/**
- * shows a breakdown of the results for ExperimentFunnelsQueryResponse
- */
-export const ResultsQuery = ({
- query,
- breakdownResults,
- breakdownLastRefresh,
-}: SafeResultBreakdownRenderProps): JSX.Element | null => {
- /**
- * bail if the result is from a trends query.
- * trends queries are not supported yet.
- */
- if (query.source.kind === NodeKind.TrendsQuery) {
- return null
- }
-
- const fakeInsightId = Math.random().toString(36).substring(2, 15)
-
- return (
- <Query
- query={query}
- context={{
- insightProps: {
- dashboardItemId: fakeInsightId as InsightShortId,
- cachedInsight: {
- short_id: fakeInsightId as InsightShortId,
- query,
- result: breakdownResults,
- last_refresh: breakdownLastRefresh,
- disable_baseline: true,
- },
- doNotLoad: true,
- },
- }}
- readOnly
- />
- )
-}
diff --git a/frontend/src/scenes/experiments/components/ResultsBreakdown/index.ts b/frontend/src/scenes/experiments/components/ResultsBreakdown/index.ts
deleted file mode 100644
index 6b81a408ca65..000000000000
--- a/frontend/src/scenes/experiments/components/ResultsBreakdown/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export * from './ExploreAsInsightButton'
-export * from './ResultsBreakdown'
-export * from './ResultsBreakdownSkeleton'
-export * from './ResultsInsightInfoBanner'
-export * from './ResultsQuery'
diff --git a/frontend/src/scenes/experiments/components/ResultsBreakdown/resultsBreakdownLogic.ts b/frontend/src/scenes/experiments/components/ResultsBreakdown/resultsBreakdownLogic.ts
deleted file mode 100644
index ef998bd15511..000000000000
--- a/frontend/src/scenes/experiments/components/ResultsBreakdown/resultsBreakdownLogic.ts
+++ /dev/null
@@ -1,334 +0,0 @@
-import { MakeLogicType, actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
-import { loaders } from 'kea-loaders'
-import { P, match } from 'ts-pattern'
-
-import { FunnelLayout } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { experimentLogic } from 'scenes/experiments/experimentLogic'
-
-import { performQuery } from '~/queries/query'
-import type {
- ExperimentEventExposureConfig,
- ExperimentMetric,
- FunnelsQuery,
- InsightVizNode,
- TrendsQuery,
-} from '~/queries/schema/schema-general'
-import { ExperimentMetricType, NodeKind, isExperimentFunnelMetric } from '~/queries/schema/schema-general'
-import { getExposureEventAndProperty, resolvedExposureEvent } from '~/scenes/experiments/exposureContract'
-import {
- addExposureToMetric,
- compose,
- getExperimentDateRange,
- getExperimentRefreshMode,
- getExposureConfigEventsNode,
- getInsight,
- getQuery,
-} from '~/scenes/experiments/metricQueryUtils'
-import { getExperimentVariants } from '~/scenes/experiments/utils'
-import type { Experiment, FunnelStep } from '~/types'
-import {
- BreakdownAttributionType,
- FunnelConversionWindowTimeUnit,
- FunnelStepReference,
- FunnelVizType,
- StepOrderValue,
-} from '~/types'
-
-import type { FeatureFlagsSet } from '../../../../lib/logic/featureFlagLogic'
-import type { InsightQueryNode } from '../../../../queries/schema/schema-general'
-import type { ExperimentTriggeredBy } from '../../experimentLogic'
-
-const filterFunnelSteps = (steps: FunnelStep[], variants: string[]): FunnelStep[] =>
- steps.filter((step) =>
- match(step.breakdown_value)
- .with(undefined, () => false)
- .with(P.array(P.string), (values) => values.some((value) => variants.includes(value)))
- .otherwise(() => variants.includes(step.breakdown_value as string))
- )
-
-export type ResultBreakdownLogicProps = {
- experiment: Experiment
- metric?: ExperimentMetric
- metricUuid: string
- isPrimary: boolean
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface resultsBreakdownLogicValues {
- featureFlags: FeatureFlagsSet // featureFlagLogic
- breakdownLastRefresh: string | null
- breakdownResults: FunnelStep[] | FunnelStep[][] | null
- breakdownResultsLoading: boolean
- query: InsightVizNode<InsightQueryNode> | null
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface resultsBreakdownLogicActions {
- refreshExperimentResults: (
- forceRefresh?: boolean | undefined,
- triggeredBy?: ExperimentTriggeredBy | undefined,
- refreshIfStale?: boolean | undefined
- ) => {
- forceRefresh: boolean | undefined
- refreshIfStale: boolean
- triggeredBy: ExperimentTriggeredBy
- } // experimentLogic
- loadBreakdownResults: (refresh?: boolean) => {
- refresh: boolean | undefined
- }
- loadBreakdownResultsFailure: (
- error: string,
- errorObject?: any
- ) => {
- error: string
- errorObject?: any
- }
- loadBreakdownResultsSuccess: (
- breakdownResults: FunnelStep[] | FunnelStep[][],
- payload?: {
- refresh: boolean | undefined
- }
- ) => {
- breakdownResults: FunnelStep[] | FunnelStep[][]
- payload?: {
- refresh: boolean | undefined
- }
- }
- setBreakdownLastRefresh: (lastRefresh: string | null) => {
- lastRefresh: string | null
- }
-}
-
-// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
-export interface resultsBreakdownLogicMeta {
- key: string
- __keaTypeGenInternalSelectorTypes: {
- query: (arg: any) => InsightVizNode<InsightQueryNode> | null
- }
-}
-
-export type resultsBreakdownLogicType = MakeLogicType<
- resultsBreakdownLogicValues,
- resultsBreakdownLogicActions,
- ResultBreakdownLogicProps,
- resultsBreakdownLogicMeta
->
-
-/**
- * This logic only works with the new query runner.
- * Legacy Funnels and Trends engine are resolved backend side.
- */
-export const resultsBreakdownLogic = kea<resultsBreakdownLogicType>([
- props({
- experiment: {} as Experiment,
- metric: {} as ExperimentMetric,
- } as ResultBreakdownLogicProps),
-
- key((props) => `${props.experiment.id}-${props.metricUuid}-${props.isPrimary ? 'primary' : 'secondary'}`),
-
- path((key) => ['scenes', 'experiment', 'experimentResultBreakdownLogic', key]),
-
- connect((props: ResultBreakdownLogicProps) => ({
- values: [featureFlagLogic, ['featureFlags']],
- actions: [experimentLogic({ experimentId: props.experiment.id }), ['refreshExperimentResults']],
- })),
-
- actions({
- loadBreakdownResults: (refresh?: boolean) => ({ refresh }),
- setBreakdownLastRefresh: (lastRefresh: string | null) => ({ lastRefresh }),
- }),
-
- selectors({
- query: [
- () => [(_, props) => props],
- ({ experiment, metric }: ResultBreakdownLogicProps) => {
- if (!metric) {
- return null
- }
-
- /**
- * we create the exposure node. For this case, we need
- * need to use the experiment's exposure config
- */
- const exposureEventNode = getExposureConfigEventsNode(
- experiment.exposure_criteria?.exposure_config as ExperimentEventExposureConfig,
- {
- featureFlagKey: experiment.feature_flag_key,
- featureFlagVariants: getExperimentVariants(experiment),
- resolvedExposureEvent: resolvedExposureEvent(experiment),
- }
- )
-
- /**
- * we create the query builder with all the options.
- */
- const queryBuilder = compose<
- ExperimentMetric,
- ExperimentMetric,
- FunnelsQuery | TrendsQuery | undefined,
- InsightVizNode | undefined
- >(
- addExposureToMetric(exposureEventNode),
- getQuery({
- filterTestAccounts: !!experiment.exposure_criteria?.filterTestAccounts,
- dateRange: getExperimentDateRange(experiment),
- breakdownFilter: {
- breakdown: getExposureEventAndProperty({
- featureFlagKey: experiment.feature_flag_key,
- exposureCriteria: experiment.exposure_criteria,
- }).variantProperty,
- breakdown_type: 'event',
- },
- funnelsFilter: {
- layout: FunnelLayout.vertical,
- /* We want to break down results by the flag value from the _first_ step
- which is the expsoure criteria */
- breakdownAttributionType: BreakdownAttributionType.Step,
- breakdownAttributionValue: 0,
- funnelOrderType:
- (isExperimentFunnelMetric(metric) && metric.funnel_order_type) ||
- StepOrderValue.ORDERED,
- funnelStepReference: FunnelStepReference.total,
- funnelVizType: FunnelVizType.Steps,
- funnelWindowInterval: 14,
- funnelWindowIntervalUnit: FunnelConversionWindowTimeUnit.Day,
- },
- }),
- getInsight({
- showTable: true,
- showLastComputation: true,
- showLastComputationRefresh: false,
- })
- )
-
- /**
- * take the metric and the experiment and create a new Funnel or Trends query.
- * we need the experiment for exposure configuration.
- */
- return queryBuilder(metric) || null
- },
- ],
- }),
-
- reducers({
- breakdownLastRefresh: [
- null as string | null,
- {
- setBreakdownLastRefresh: (_, { lastRefresh }) => lastRefresh,
- loadBreakdownResults: () => null, // Clear when loading starts
- },
- ],
- }),
-
- loaders(({ props, values, actions }) => ({
- breakdownResults: [
- null as FunnelStep[] | FunnelStep[][] | null,
- {
- loadBreakdownResults: async ({ refresh }): Promise<FunnelStep[] | FunnelStep[][]> => {
- try {
- const { experiment } = props
- const query = values.query
-
- if (!query) {
- throw new Error('No query returned from queryBuilder')
- }
-
- if (query.source.kind === NodeKind.TrendsQuery) {
- return []
- }
-
- /**
- * perform the query - use cache on normal load, force refresh when explicitly requested
- */
- const response = (await performQuery(
- query,
- undefined,
- getExperimentRefreshMode(values.featureFlags, !!refresh)
- )) as {
- results: FunnelStep[] | FunnelStep[][]
- last_refresh?: string
- }
-
- if (!response?.results) {
- throw new Error('No results returned from query')
- }
-
- // Capture the last_refresh timestamp for use in cachedInsight
- if (response.last_refresh) {
- actions.setBreakdownLastRefresh(response.last_refresh)
- }
-
- let results = response.results
-
- /**
- * we need to filter the results to remove any non-variant breakdown
- */
- const variants = getExperimentVariants(experiment).map(({ key }) => key)
-
- results = match(results)
- /**
- * filter for FunnelSteps[][]. In this case, we get an array for each breakdown group,
- * each with an array of steps. We need to filter for each group and remove any empty arrays.
- */
- .with(P.array(P.array({ breakdown_value: P.any })), (nestedSteps) =>
- nestedSteps
- .map((stepGroup) => filterFunnelSteps(stepGroup, variants))
- .filter((steps) => steps.length > 0)
- )
- /**
- * filter for FunnelSteps[]. In this case, we just get an array of steps
- */
- .with(P.array({ breakdown_value: P.any }), (flatSteps) =>
- filterFunnelSteps(flatSteps, variants)
- )
- .otherwise(() => [])
-
- return results
- } catch (error) {
- throw new Error(
- error instanceof Error
- ? `Failed to load experiment results: ${error.message}`
- : 'Failed to load experiment results'
- )
- }
- },
- },
- ],
- })),
-
- listeners(({ actions, props }) => ({
- refreshExperimentResults: () => {
- const { metric, experiment } = props
-
- // bail if no valid props
- if (!experiment || !metric) {
- return
- }
-
- // bail if unsupported metric type
- if (metric.kind !== NodeKind.ExperimentMetric || metric.metric_type !== ExperimentMetricType.FUNNEL) {
- return
- }
-
- // Refresh the breakdown results when experiment results are refreshed
- actions.loadBreakdownResults(true)
- },
- })),
-
- afterMount(({ actions, props }) => {
- const { metric, experiment } = props
-
- // bail if no valid props
- if (!experiment || !metric) {
- return
- }
-
- // bail if unsupported metric type
- if (metric.kind !== NodeKind.ExperimentMetric || metric.metric_type !== ExperimentMetricType.FUNNEL) {
- return
- }
-
- actions.loadBreakdownResults()
- }),
-])
diff --git a/frontend/src/scenes/experiments/components/ResultsBreakdown/types.ts b/frontend/src/scenes/experiments/components/ResultsBreakdown/types.ts
deleted file mode 100644
index 26b5bd3ca07c..000000000000
--- a/frontend/src/scenes/experiments/components/ResultsBreakdown/types.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import type { InsightVizNode } from '~/queries/schema/schema-general'
-import type { FunnelStep, TrendResult } from '~/types'
-
-export type ResultBreakdownRenderProps = {
- query: InsightVizNode | null
- breakdownResultsLoading: boolean
- breakdownResults: FunnelStep[] | FunnelStep[][] | TrendResult[] | null
- exposureDifference: number
- breakdownLastRefresh: string | null
-}
diff --git a/frontend/src/scenes/experiments/experimentActivityDescriber.tsx b/frontend/src/scenes/experiments/experimentActivityDescriber.tsx
index 17c790e7107b..4ece3b9a0b1d 100644
--- a/frontend/src/scenes/experiments/experimentActivityDescriber.tsx
+++ b/frontend/src/scenes/experiments/experimentActivityDescriber.tsx
@@ -2,7 +2,6 @@ import { match } from 'ts-pattern'
import { ActivityLogItem, ActivityLogUserName, HumanizedChange } from 'lib/components/ActivityLog/humanizeActivity'
import { SentenceList } from 'lib/components/ActivityLog/SentenceList'
-import { LemonCard } from 'lib/lemon-ui/LemonCard'
import { ExperimentStatus } from '~/types'
@@ -16,27 +15,6 @@ import {
nameOrLinkToSharedMetric,
} from './activity-descriptions'
-//exporting so the linter doesn't complain about this not being used
-export const ExperimentDetails = ({
- logItem,
- status,
-}: {
- logItem: ActivityLogItem
- status: ExperimentStatus
-}): JSX.Element => {
- return (
- <LemonCard className="flex items-center justify-between gap-3 p-4">
- <div className="flex flex-col gap-1">
- <strong className="text-sm font-semibold">
- {nameOrLinkToExperiment(logItem.detail.name, logItem.item_id)}
- </strong>
- <span className="text-xs text-muted">Experiment</span>
- </div>
- <StatusTag status={status} />
- </LemonCard>
- )
-}
-
const UnknownAction = ({ logItem }: { logItem: ActivityLogItem }): JSX.Element => {
return (
<SentenceList
diff --git a/frontend/src/scenes/experiments/experimentMetricsLogic.ts b/frontend/src/scenes/experiments/experimentMetricsLogic.ts
index 9acb05cd6cd3..6ea91a6170c1 100644
--- a/frontend/src/scenes/experiments/experimentMetricsLogic.ts
+++ b/frontend/src/scenes/experiments/experimentMetricsLogic.ts
@@ -54,8 +54,6 @@ export const RECALCULATION_STATUSES = {
failed: 'failed',
} as const
-export type RecalculationStatuses = (typeof RECALCULATION_STATUSES)[keyof typeof RECALCULATION_STATUSES]
-
/** Transient per-metric retry state written by the calc activity between failed attempts. */
export interface MetricRetryInfo {
attempt: number
diff --git a/frontend/src/scenes/experiments/metricQueryUtils.ts b/frontend/src/scenes/experiments/metricQueryUtils.ts
index ee28e34769ef..1671d63e2526 100644
--- a/frontend/src/scenes/experiments/metricQueryUtils.ts
+++ b/frontend/src/scenes/experiments/metricQueryUtils.ts
@@ -29,7 +29,7 @@ import type {
} from '~/queries/schema/schema-general'
import { ExperimentMetricSource, ExperimentMetricType, NodeKind } from '~/queries/schema/schema-general'
import { setLatestVersionsOnQuery } from '~/queries/utils'
-import type { Experiment, FilterType, IntervalType, MultivariateFlagVariant } from '~/types'
+import type { FilterType, IntervalType, MultivariateFlagVariant } from '~/types'
import { ChartDisplayType, ExperimentMetricMathType, PropertyFilterType, PropertyOperator } from '~/types'
import { EXPOSURE_DEFAULT_EVENT, EXPOSURE_FEATURE_FLAG_PROPERTY, featureFlagVariantProperty } from './exposureContract'
@@ -107,24 +107,12 @@ const defaultFunnelsFilter: FunnelsFilter = {
/**
* returns the default date range
*/
-export const getDefaultDateRange = (): DateRange => ({
+const getDefaultDateRange = (): DateRange => ({
date_from: dayjs().subtract(EXPERIMENT_DEFAULT_DURATION, 'day').format('YYYY-MM-DDTHH:mm'),
date_to: dayjs().endOf('d').format('YYYY-MM-DDTHH:mm'),
explicitDate: true,
})
-/**
- * returns a date range using an experiment's start and end date, or the default duration if not set.
- */
-export const getExperimentDateRange = (experiment: Experiment): DateRange => {
- const defaultRange = getDefaultDateRange()
- return {
- date_from: experiment.start_date ?? defaultRange.date_from,
- date_to: experiment.end_date ?? defaultRange.date_to,
- explicitDate: true,
- }
-}
-
/**
* returns the math properties for the source
*/
@@ -576,20 +564,6 @@ export const addExposureToMetric =
})
.otherwise(() => metric)
-/**
- * unlike metrics, both Funnels and Trends queries have a series property,
- * so we can add the exposure event to the series.
- */
-export const addExposureToQuery =
- (exposureEvent: EventsNode | ActionsNode) =>
- (query: FunnelsQuery | TrendsQuery | undefined): FunnelsQuery | TrendsQuery | undefined =>
- query
- ? ({
- ...query,
- series: [exposureEvent, ...query.series],
- } as typeof query)
- : undefined
-
type InsightVizNodeOptions = {
showTable: boolean
showLastComputation: boolean
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9df9f70fd24f..34bd5ad2f044 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -3431,9 +3431,6 @@ importers:
clsx:
specifier: '*'
version: 1.2.1
- fuse.js:
- specifier: '*'
- version: 6.6.2
kea:
specifier: 'catalog:'
version: 4.0.0-pre.6(patch_hash=139b8d1f1304f9d9da452a9a1244c94ea679dbcb85687d8999563146879fb6f5)([email protected])
@@ -3446,9 +3443,6 @@ importers:
react:
specifier: 18.3.1
version: 18.3.1
- ts-pattern:
- specifier: 'catalog:'
- version: 4.3.0
devDependencies:
'@storybook/react':
specifier: 'catalog:'
diff --git a/products/experiments/frontend/constants.ts b/products/experiments/frontend/constants.ts
index 54a22c44f8ad..5e6243fbd042 100644
--- a/products/experiments/frontend/constants.ts
+++ b/products/experiments/frontend/constants.ts
@@ -47,7 +47,6 @@ export const MAX_LOOKBACK_DAYS = 30
export const DEFAULT_MDE = 30
// Autorefresh constants
-export const EXPERIMENT_MIN_REFRESH_INTERVAL_MINUTES = 5
export const EXPERIMENT_AUTO_REFRESH_INITIAL_INTERVAL_SECONDS = 1800 // 30 min
// While a launched experiment is still gathering its first exposures, force refresh results on page
// load (queries are fast with little data and this is better UX to not let users wait until they see
diff --git a/products/experiments/package.json b/products/experiments/package.json
index fd1c3e42197d..77b6e494c594 100644
--- a/products/experiments/package.json
+++ b/products/experiments/package.json
@@ -7,8 +7,7 @@
"@posthog/brand": "catalog:",
"kea": "catalog:",
"kea-loaders": "catalog:",
- "kea-router": "catalog:",
- "ts-pattern": "catalog:"
+ "kea-router": "catalog:"
},
"devDependencies": {
"@storybook/react": "catalog:",
@@ -25,7 +24,6 @@
"@testing-library/user-event": "*",
"@types/react": "*",
"clsx": "*",
- "fuse.js": "*",
"react": "*"
}
}