: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
chore(experiments): remove old experiment information bar code (#103247)
Rodrigo Iloro3cb4d9d2ac20
diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.tsindex ea3bde0b4e3f..da78b9db7240 100644--- a/frontend/src/lib/utils/eventUsageLogic.ts+++ b/frontend/src/lib/utils/eventUsageLogic.ts@@ -1377,15 +1377,6 @@ export interface eventUsageLogicActions {reportExperimentAiSummaryRequested: (experiment: Experiment) => {experiment: Experiment}- reportExperimentAutoRefreshToggled: (- experiment: Experiment,- enabled: boolean,- interval: number- ) => {- enabled: boolean- experiment: Experiment- interval: number- }reportExperimentBehaviorComparisonFailed: (experimentId: ExperimentIdType,context: ExperimentWatchLoadFailedContext@@ -2985,11 +2976,6 @@ export const eventUsageLogic = kea<eventUsageLogicType>([forceRefresh,context,}),- reportExperimentAutoRefreshToggled: (experiment: Experiment, enabled: boolean, interval: number) => ({- experiment,- enabled,- interval,- }),reportExperimentMetricBreakdownAdded: (experiment: Experiment,metricUuid: string,@@ -4174,13 +4160,6 @@ export const eventUsageLogic = kea<eventUsageLogicType>([previous_refresh_triggered_by: context?.previous_refresh_triggered_by ?? null,})},- reportExperimentAutoRefreshToggled: ({ experiment, enabled, interval }) => {- posthog.capture('experiment auto refresh toggled', {- ...getEventPropertiesForExperiment(experiment),- enabled,- interval,- })- },reportExperimentMetricBreakdownAdded: ({ experiment, metricUuid, breakdown, isPrimary }) => {posthog.capture('experiment metric breakdown added', {...getEventPropertiesForExperiment(experiment),diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentDuration.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentDuration.tsxdeleted file mode 100644index 5dc989037c4b..000000000000--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentDuration.tsx+++ /dev/null@@ -1,94 +0,0 @@-import { useActions, useValues } from 'kea'-import { useState } from 'react'--import { IconArrowRight } from '@posthog/icons'-import { LemonButton } from '@posthog/lemon-ui'--import { TZLabel } from 'lib/components/TZLabel'-import { dayjs } from 'lib/dayjs'-import { LemonCalendarSelect } from 'lib/lemon-ui/LemonCalendar/LemonCalendarSelect'-import { Popover } from 'lib/lemon-ui/Popover'-import { Label } from 'lib/ui/Label/Label'--import { experimentLogic } from '../experimentLogic'--interface DateButtonProps {- date: string | null | undefined- type: 'start' | 'end'- onChange: (date: string) => void-}--const DateButton = ({ date, type, onChange }: DateButtonProps): JSX.Element => {- const containerWidth = 'w-44'- const [isOpen, setIsOpen] = useState(false)-- return (- <div className={containerWidth}>- <Popover- actionable- onClickOutside={() => setIsOpen(false)}- visible={isOpen}- overlay={- <LemonCalendarSelect- value={date ? dayjs(date) : null}- onChange={(value) => {- onChange(value.toISOString())- setIsOpen(false)- }}- onClose={() => setIsOpen(false)}- granularity="minute"- selectionPeriod={type === 'start' ? 'past' : undefined}- />- }- >- <LemonButton- type="secondary"- size="xsmall"- onClick={() => setIsOpen(true)}- fullWidth- disabledReason={- !date && type === 'start'- ? 'No start date'- : !date && type === 'end'- ? 'Experiment is still running'- : undefined- }- >- {date ? (- <TZLabel- time={date}- formatDate="MMM DD, YYYY"- formatTime="hh:mm A"- showPopover={true}- noStyles={true}- />- ) : type === 'end' ? (- 'Present'- ) : (- 'No date'- )}- </LemonButton>- </Popover>- </div>- )-}--export const ExperimentDuration = (): JSX.Element => {- const { experiment } = useValues(experimentLogic)- const { changeExperimentStartDate, changeExperimentEndDate } = useActions(experimentLogic)-- const { start_date, end_date } = experiment-- return (- <div>- <Label intent="menu">Duration</Label>- <div className="flex gap-2 items-center">- <div className="flex items-center gap-2">- <DateButton date={start_date} type="start" onChange={changeExperimentStartDate} />- <IconArrowRight className="text-base" />- <DateButton date={end_date} type="end" onChange={changeExperimentEndDate} />- </div>- </div>- </div>- )-}diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentReloadAction.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentReloadAction.tsxdeleted file mode 100644index 41f088c14a86..000000000000--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentReloadAction.tsx+++ /dev/null@@ -1,236 +0,0 @@-import { useActions, useValues } from 'kea'-import { useCallback, useEffect, useRef } from 'react'--import { IconRefresh } from '@posthog/icons'-import { LemonBadge, LemonButton, LemonSwitch } from '@posthog/lemon-ui'--import { TZLabel } from 'lib/components/TZLabel'-import { dayjs } from 'lib/dayjs'-import { usePageVisibilityCb } from 'lib/hooks/usePageVisibility'-import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'-import { LemonRadio } from 'lib/lemon-ui/LemonRadio'-import { Spinner } from 'lib/lemon-ui/Spinner'-import { Label } from 'lib/ui/Label/Label'-import { humanFriendlyDuration } from 'lib/utils/durations'--import { hasEnded } from 'products/experiments/frontend/experimentStatus'--import { experimentLogic } from '../experimentLogic'--/**- * Hook to check if experiment data is stale and trigger refresh if needed.- * Checks on mount and when page becomes visible after being hidden.- *- * This is a workaround to avoid kea race conditions when loading experiment data.- * If we save the last refresh time at the experiment level this should go away.- */-function useStaleDataCheck({- lastRefresh,- enabled,- intervalSeconds,- onRefresh,-}: {- lastRefresh: string | null- enabled: boolean- intervalSeconds: number- onRefresh: () => void-}): void {- const hasCheckedOnMountRef = useRef(false)- const pageWasHiddenRef = useRef(false)-- usePageVisibilityCb((isVisible) => {- if (!isVisible) {- pageWasHiddenRef.current = true- }- })-- useEffect(() => {- // Only check on mount or after page was hidden and became visible again- if (hasCheckedOnMountRef.current && !pageWasHiddenRef.current) {- return- }-- // Skip if disabled or no timestamp (but don't mark as checked yet)- if (!enabled || !lastRefresh) {- return- }-- // Check if data is stale- const secondsSinceRefresh = dayjs().diff(dayjs(lastRefresh), 'seconds')- if (secondsSinceRefresh > intervalSeconds) {- onRefresh()- }-- // Only mark as checked after we've actually performed a check- hasCheckedOnMountRef.current = true- pageWasHiddenRef.current = false- }, [lastRefresh, enabled, intervalSeconds, onRefresh])-}--export const ExperimentLastRefreshText = ({- lastRefresh,- showStaleness = true,-}: {- lastRefresh: string | null- showStaleness?: boolean-}): JSX.Element => {- const colorClass =- showStaleness && lastRefresh- ? dayjs().diff(dayjs(lastRefresh), 'hours') > 12- ? 'text-danger'- : dayjs().diff(dayjs(lastRefresh), 'hours') > 6- ? 'text-warning'- : ''- : ''-- return <span className={colorClass}>{lastRefresh ? <TZLabel time={lastRefresh} /> : 'a while ago'}</span>-}--const getExperimentRefreshIntervalSeconds = (): number[] => {- if (process.env.NODE_ENV === 'development') {- return [10, 300, 900, 1800] // 10s, 5min, 15min, 30min- }- return [300, 900, 1800] // 5min, 15min, 30min-}--const INTERVAL_OPTIONS = Array.from(getExperimentRefreshIntervalSeconds(), (value) => ({- label: humanFriendlyDuration(value),- value: value,-}))--export const ExperimentReloadAction = ({- isRefreshing,- lastRefresh,- onClick,- progress,- queuedHint,-}: {- isRefreshing: boolean- lastRefresh: string | null- onClick: () => void- progress?: { completed: number; total: number }- queuedHint?: string-}): JSX.Element => {- const { autoRefresh, experiment } = useValues(experimentLogic)- const { setAutoRefresh, setPageVisibility, stopAutoRefreshInterval } = useActions(experimentLogic)-- // Completed experiments have final results: no staleness warning, no auto refresh- const ended = hasEnded(experiment)-- // Check if data is stale on mount or when page becomes visible- useStaleDataCheck({- lastRefresh,- enabled: autoRefresh.enabled && !ended,- intervalSeconds: autoRefresh.interval,- onRefresh: onClick,- })-- // Memoize the page visibility callback to prevent unnecessary event listener churn- const handlePageVisibilityChange = useCallback(- (pageIsVisible: boolean) => {- setPageVisibility(pageIsVisible)- },- [setPageVisibility]- )-- usePageVisibilityCb(handlePageVisibilityChange)-- // Stop auto-refresh interval when component unmounts (e.g., navigating away)- useEffect(() => {- return () => {- stopAutoRefreshInterval()- }- }, [stopAutoRefreshInterval])-- const options = INTERVAL_OPTIONS.map((option) => ({- ...option,- disabledReason: !autoRefresh.enabled ? 'Enable auto refresh to set the interval' : undefined,- }))-- const loadingText =- progress && progress.total > 0 ? `Loaded ${progress.completed} of ${progress.total} metrics` : 'Loading…'-- return (- <div className="flex flex-col">- <Label intent="menu">Last refreshed</Label>- <div className="relative">- <LemonButton- onClick={onClick}- type="secondary"- size="xsmall"- icon={isRefreshing ? <Spinner textColored /> : <IconRefresh />}- data-attr="refresh-experiment"- disabledReason={isRefreshing ? (queuedHint ?? 'Loading...') : null}- sideAction={- ended- ? undefined- : {- 'data-attr': 'refresh-experiment-dropdown',- dropdown: {- closeOnClickInside: false,- placement: 'bottom-end',- overlay: (- <LemonMenuOverlay- items={[- {- label: () => (- <LemonSwitch- onChange={(checked) =>- setAutoRefresh(checked, autoRefresh.interval)- }- label="Auto refresh while on page"- checked={autoRefresh.enabled}- fullWidth- className="mt-1 mb-2"- />- ),- },- ...(autoRefresh.enabled- ? [- {- title: 'Refresh interval',- items: [- {- label: () => (- <LemonRadio- value={autoRefresh.interval}- options={options}- onChange={(value: number) => {- setAutoRefresh(true, value)- }}- className="mx-2 mb-1"- />- ),- },- ],- },- ]- : []),- ]}- />- ),- },- }- }- >- {isRefreshing ? (- loadingText- ) : (- <ExperimentLastRefreshText lastRefresh={lastRefresh} showStaleness={!ended} />- )}- </LemonButton>- <LemonBadge- size="small"- content={- <>- <IconRefresh className="mr-0" /> {humanFriendlyDuration(autoRefresh.interval)}- </>- }- visible={autoRefresh.enabled && !ended}- position="top-right"- status="muted"- />- </div>- </div>- )-}diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentReloadActionContainer.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentReloadActionContainer.tsxdeleted file mode 100644index 330faa35673f..000000000000--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentReloadActionContainer.tsx+++ /dev/null@@ -1,86 +0,0 @@-import { useActions, useValues } from 'kea'--import { FEATURE_FLAGS } from 'lib/constants'-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'--import { Experiment } from '~/types'--import { experimentLogic, previousRefreshAnalytics } from '../experimentLogic'-import { experimentMetricsLogic } from '../experimentMetricsLogic'-import { ExperimentReloadAction } from './ExperimentReloadAction'--/**- * Wires the reload button to the right loading source: on the recalculation flow it reads- * experimentMetricsLogic (progress + isRecalculating, triggers a fresh recalculation on click);- * otherwise it mirrors the legacy primary/secondary loading rules from experimentLogic.- *- * Rendered only for non-draft experiments, so `experiment` is always real here.- */-export function ExperimentReloadActionContainer({- experiment,- lastRefresh,-}: {- experiment: Experiment- /** Legacy "last refreshed" timestamp from experimentLogic results, used only on the legacy path.- * The recalculation path derives its own from the completed run. */- lastRefresh: string-}): JSX.Element {- const { featureFlags } = useValues(featureFlagLogic)- const recalculationFlow = !!featureFlags[FEATURE_FLAGS.EXPERIMENTS_METRICS_RECALCULATION]-- return recalculationFlow ? (- <RecalculationReloadAction experiment={experiment} />- ) : (- <LegacyReloadAction experiment={experiment} lastRefresh={lastRefresh} />- )-}--function RecalculationReloadAction({ experiment }: { experiment: Experiment }): JSX.Element {- const metricsLogic = experimentMetricsLogic({ experiment })- const { isRecalculating, recalculationProgress, lastRefresh, queuedRerun } = useValues(metricsLogic)- const { triggerRecalculation } = useActions(metricsLogic)- const { autoRefresh, currentRefresh } = useValues(experimentLogic)- const { refreshExperimentResults, reportExperimentMetricsRefreshed } = useActions(experimentLogic)-- return (- <ExperimentReloadAction- isRefreshing={isRecalculating}- lastRefresh={lastRefresh}- progress={recalculationProgress}- queuedHint={queuedRerun ? 'Changes will apply after the current recalculation finishes' : undefined}- onClick={() => {- reportExperimentMetricsRefreshed(experiment, true, {- triggered_by: 'manual',- auto_refresh_enabled: autoRefresh.enabled,- auto_refresh_interval: autoRefresh.interval,- ...previousRefreshAnalytics(currentRefresh),- })- triggerRecalculation()- // Exposures still live in experimentLogic; keep refreshing them on manual reload.- refreshExperimentResults(true, 'manual')- }}- />- )-}--function LegacyReloadAction({ experiment, lastRefresh }: { experiment: Experiment; lastRefresh: string }): JSX.Element {- const { primaryMetricsResultsLoading, secondaryMetricsResultsLoading, autoRefresh, currentRefresh } =- useValues(experimentLogic)- const { refreshExperimentResults, reportExperimentMetricsRefreshed } = useActions(experimentLogic)-- return (- <ExperimentReloadAction- isRefreshing={primaryMetricsResultsLoading || secondaryMetricsResultsLoading}- lastRefresh={lastRefresh}- onClick={() => {- reportExperimentMetricsRefreshed(experiment, true, {- triggered_by: 'manual',- auto_refresh_enabled: autoRefresh.enabled,- auto_refresh_interval: autoRefresh.interval,- ...previousRefreshAnalytics(currentRefresh),- })- refreshExperimentResults(true, 'manual')- }}- />- )-}diff --git a/frontend/src/scenes/experiments/ExperimentView/Info.tsx b/frontend/src/scenes/experiments/ExperimentView/Info.tsxdeleted file mode 100644index 4ace9676144d..000000000000--- a/frontend/src/scenes/experiments/ExperimentView/Info.tsx+++ /dev/null@@ -1,260 +0,0 @@-import clsx from 'clsx'-import { useActions, useValues } from 'kea'--import { IconPencil, IconWarning } from '@posthog/icons'-import { LemonButton, LemonCard, LemonTag, Link, ProfilePicture, Tooltip } from '@posthog/lemon-ui'--import { CopyToClipboardInline } from 'lib/components/CopyToClipboard'-import { IconOpenInNew } from 'lib/lemon-ui/icons'-import { Label } from 'lib/ui/Label/Label'-import { urls } from 'scenes/urls'--import { ExperimentStatsMethod, ExperimentStatus } from '~/types'--import { StatusTag } from 'products/experiments/frontend/components/StatusTag'-import { CONCLUSION_DISPLAY_CONFIG } from 'products/experiments/frontend/constants'-import { getExperimentStatus, isExperimentPaused } from 'products/experiments/frontend/experimentStatus'--import { experimentLogic } from '../experimentLogic'-import { modalsLogic } from '../modalsLogic'-import { ConclusionComment } from './ConclusionComment'-import { ExperimentDuration } from './ExperimentDuration'-import { ExperimentReloadActionContainer } from './ExperimentReloadActionContainer'-import { flagCleanupTaskLogic } from './flagCleanupTaskLogic'-import { RunningTime } from './RunningTime'--function FlagCleanupField({ experimentId, taskId }: { experimentId: number; taskId: string }): JSX.Element | null {- const { cleanupTask } = useValues(flagCleanupTaskLogic({ experimentId }))-- if (!cleanupTask) {- return null- }-- let text = 'Preparing cleanup PR…'- let prUrl: string | null = null- if (cleanupTask.is_terminal) {- if (cleanupTask.run_status === 'completed' && cleanupTask.pr_url) {- text = 'Cleanup PR opened'- prUrl = cleanupTask.pr_url- } else if (cleanupTask.run_status === 'completed') {- text = 'Cleanup found no flag code to remove'- } else if (cleanupTask.run_status === 'failed') {- text = 'Cleanup PR failed'- } else {- text = 'Cleanup PR cancelled'- }- }-- const isExternalLink = prUrl !== null- // The task page 404s for everyone but the task's creator — hide the internal link from others.- const showLink = isExternalLink || cleanupTask.can_view_task-- return (- <div className="flex flex-col" data-attr="experiment-flag-cleanup">- <Label intent="menu">Flag cleanup</Label>- <div className="flex items-center gap-1">- {text}- {showLink && (- <>- ·- <Link- target={isExternalLink ? '_blank' : undefined}- className="flex items-center gap-0.5"- to={prUrl ?? urls.taskDetail(taskId)}- >- {isExternalLink ? (- <>- View on GitHub <IconOpenInNew fontSize="14" />- </>- ) : (- 'View task'- )}- </Link>- </>- )}- </div>- </div>- )-}--export function Info(): JSX.Element {- const {- experiment,- primaryMetricsResults,- secondaryMetricsResults,- statsMethod,- isExperimentDraft,- isSingleVariantShipped,- shippedVariantKey,- } = useValues(experimentLogic)- const { openEditConclusionModal, openRunningTimeConfigModal } = useActions(modalsLogic)-- const { created_by } = experiment-- if (!experiment.feature_flag) {- return <></>- }-- // Get the last refresh timestamp from either legacy or new results format- // Check both primary and secondary metrics for the most recent timestamp- const lastRefresh = primaryMetricsResults?.[0]?.last_refresh || secondaryMetricsResults?.[0]?.last_refresh-- const status = getExperimentStatus(experiment)- const isPaused = isExperimentPaused(experiment)-- return (- <>- <div className="grid gap-2 overflow-hidden grid-cols-1 min-[1100px]:grid-cols-[3fr_2fr]">- {/* Column 1 */}- <div className="flex flex-col gap-0 overflow-hidden min-w-0">- {/* Row 1: Status, Feature flag, Stats engine */}- <div className="flex flex-wrap gap-x-4 gap-y-2">- <div className="flex flex-col" data-attr="experiment-status">- <Label intent="menu">Status</Label>- <div className="flex gap-1">- {isPaused ? (- <Tooltip- placement="bottom"- title="Your experiment is paused. The linked flag is disabled and no data is being collected."- >- <StatusTag status={status} />- </Tooltip>- ) : (- <StatusTag status={status} />- )}- {isSingleVariantShipped && (- <Tooltip- title={`Variant "${shippedVariantKey}" has been rolled out to 100% of users`}- >- <LemonTag type="completion" className="cursor-default">- <b className="uppercase">100% rollout</b>- </LemonTag>- </Tooltip>- )}- </div>- </div>- {experiment.feature_flag && (- <div className="flex flex-col max-w-[500px]">- <Label intent="menu">Feature flag</Label>- <div className="flex gap-1 items-center">- {isPaused && (- <Tooltip- placement="bottom"- title="Your experiment is paused. The linked flag is disabled and no data is being collected."- >- <IconWarning- style={{ transform: 'translateY(2px)' }}- className="mr-1 text-danger"- fontSize="18px"- />- </Tooltip>- )}- <CopyToClipboardInline- iconStyle={{ color: 'var(--lemon-button-icon-opacity)' }}- className="font-normal text-sm"- description="feature flag key"- >- {experiment.feature_flag.key}- </CopyToClipboardInline>- <Link- target="_blank"- className="font-semibold"- to={- experiment.feature_flag- ? urls.featureFlag(experiment.feature_flag.id)- : undefined- }- >- <IconOpenInNew fontSize="18" />- </Link>- </div>- </div>- )}- <div className="flex flex-col">- <Label intent="menu">Statistics</Label>- <span>- {statsMethod === ExperimentStatsMethod.Bayesian ? 'Bayesian' : 'Frequentist'}- {' / '}- {statsMethod === ExperimentStatsMethod.Bayesian- ? `${((experiment.stats_config?.bayesian?.ci_level ?? 0.95) * 100).toFixed(0)}%`- : `${((1 - (experiment.stats_config?.frequentist?.alpha ?? 0.05)) * 100).toFixed(0)}%`}- </span>- </div>- {experiment.conclusion && experiment.end_date && (- <div className="flex flex-col" data-attr="experiment-conclusion">- <Label intent="menu">Conclusion</Label>- <div className="flex items-center gap-2">- <div- className={clsx(- 'w-2 h-2 rounded-full shrink-0',- CONCLUSION_DISPLAY_CONFIG[experiment.conclusion]?.color || ''- )}- />- <span className="font-semibold">- {CONCLUSION_DISPLAY_CONFIG[experiment.conclusion]?.title ||- experiment.conclusion}- </span>- <LemonButton- type="secondary"- size="xsmall"- icon={<IconPencil />}- onClick={openEditConclusionModal}- tooltip="Edit conclusion"- />- </div>- </div>- )}- {experiment.flag_cleanup_task_id && typeof experiment.id === 'number' && (- <FlagCleanupField experimentId={experiment.id} taskId={experiment.flag_cleanup_task_id} />- )}- </div>- </div>-- {/* Column 2 */}- <div className="flex flex-col gap-4 overflow-hidden items-start min-[1100px]:items-end min-w-0">- {/* Row 1: Duration (date pickers) - only for launched experiments */}- {!isExperimentDraft && <ExperimentDuration />}-- {/* Row 2: Running time, Last refreshed, Created by */}- <div className="flex flex-col overflow-hidden items-start min-[1100px]:items-end">- <div className="flex flex-wrap gap-x-8 gap-y-2 justify-end">- <RunningTime- experiment={experiment}- onClick={openRunningTimeConfigModal}- isExperimentDraft={isExperimentDraft}- />- {status !== ExperimentStatus.Draft && (- <ExperimentReloadActionContainer experiment={experiment} lastRefresh={lastRefresh} />- )}- <div className="flex flex-col">- <Label intent="menu">Created by</Label>- {created_by && <ProfilePicture user={created_by} size="md" showName />}- </div>- </div>- </div>- </div>- </div>- {experiment.conclusion && experiment.end_date && experiment.conclusion_comment && (- <LemonCard- hoverEffect={false}- className="mt-2 bg-[var(--color-bg-table)] px-3 py-2.5"- data-attr="experiment-conclusion-comment"- >- <div className="flex items-center gap-2">- <span className="metric-cell-header font-bold">Conclusion</span>- <div- className={clsx(- 'w-2 h-2 rounded-full shrink-0',- CONCLUSION_DISPLAY_CONFIG[experiment.conclusion]?.color || ''- )}- />- <span className="metric-cell font-semibold">- {CONCLUSION_DISPLAY_CONFIG[experiment.conclusion]?.title || experiment.conclusion}- </span>- </div>- <ConclusionComment comment={experiment.conclusion_comment} />- </LemonCard>- )}- </>- )-}diff --git a/frontend/src/scenes/experiments/ExperimentView/RunningTime.tsx b/frontend/src/scenes/experiments/ExperimentView/RunningTime.tsxdeleted file mode 100644index 087b0317841a..000000000000--- a/frontend/src/scenes/experiments/ExperimentView/RunningTime.tsx+++ /dev/null@@ -1,87 +0,0 @@-import { useValues } from 'kea'--import { IconCalculator, IconCheck, IconClock, IconGear } from '@posthog/icons'-import { LemonButton } from '@posthog/lemon-ui'--import { LemonProgressCircle } from 'lib/lemon-ui/LemonProgressCircle/LemonProgressCircle'-import { Label } from 'lib/ui/Label/Label'--import { Experiment } from '~/types'--import { RunningTimeConfigModal } from 'products/experiments/frontend/modals/RunningTimeConfigModal/RunningTimeConfigModal'--import { runningTimeLogic } from '../RunningTimeCalculator/runningTimeLogic'--export const RunningTime = ({- experiment,- onClick,- isExperimentDraft,-}: {- experiment: Experiment- onClick: () => void- isExperimentDraft: boolean-}): JSX.Element => {- const {- remainingDays,- currentExposures,- targetSampleSize,- isComplete,- isManualMode,- primaryMetricsResultsLoading,- } = useValues(runningTimeLogic({ experiment }))-- const showProgress = currentExposures !== null && targetSampleSize !== null-- return (- <>- <div className="flex flex-col">- <Label intent="menu">{isExperimentDraft ? 'Estimated duration' : 'Remaining time'}</Label>- <div className="inline-flex items-center gap-2">- {primaryMetricsResultsLoading && !isManualMode ? (- <span>Loading...</span>- ) : remainingDays === null ? (- <span className="inline-flex items-center gap-1">- {isExperimentDraft ? (- <>- <IconCalculator />- Not calculated- </>- ) : (- <>- <IconClock />- Pending- </>- )}- </span>- ) : isComplete ? (- <span className="inline-flex items-center gap-1">- <IconCheck className="text-success" />- Complete- </span>- ) : (- <>- <span>- ~{Math.ceil(remainingDays)} day- {Math.ceil(remainingDays) !== 1 ? 's' : ''}- </span>- {showProgress && (- <LemonProgressCircle- progress={Math.min(currentExposures / targetSampleSize, 1)}- size={22}- />- )}- </>- )}- <LemonButton- type="secondary"- size="xsmall"- onClick={onClick}- icon={<IconGear />}- tooltip={isExperimentDraft ? 'Calculate estimated duration' : 'Configure'}- />- </div>- </div>- <RunningTimeConfigModal experiment={experiment} />- </>- )-}diff --git a/frontend/src/scenes/experiments/experimentLogic.tsx b/frontend/src/scenes/experiments/experimentLogic.tsxindex c696a6bec234..361e9c5b7ed0 100644--- a/frontend/src/scenes/experiments/experimentLogic.tsx+++ b/frontend/src/scenes/experiments/experimentLogic.tsx@@ -77,7 +77,6 @@ import {} from '~/types'import {- EXPERIMENT_AUTO_REFRESH_INITIAL_INTERVAL_SECONDS,EXPERIMENT_MIN_EXPOSURES_FOR_RESULTS,NEW_EXPERIMENT,NEW_EXPERIMENT_FORCE_REFRESH_AFTER_MINUTES,@@ -527,10 +526,6 @@ export interface experimentLogicValues {currentTeamId: number | null // teamLogictrendResults: TrendResult[] // trendsDataLogicactualRunningTime: number- autoRefresh: {- enabled: boolean- interval: number- }compatibleSharedMetrics: SharedMetric[]currentRefresh: CurrentRefreshSnapshot | nulleditingPrimaryMetricUuid: string | null@@ -571,7 +566,6 @@ export interface experimentLogicValues {isExperimentRunning: booleanisExperimentStopped: booleanisFlagActive: boolean- isPageVisible: booleanisSingleVariantShipped: booleanlaunchExperimentLoading: booleanminimumDetectableEffect: number@@ -616,15 +610,6 @@ export interface experimentLogicActions {reportExperimentAiSummaryRequested: (experiment: Experiment) => {experiment: Experiment} // eventUsageLogic- reportExperimentAutoRefreshToggled: (- experiment: Experiment,- enabled: boolean,- interval: number- ) => {- enabled: boolean- experiment: Experiment- interval: number- } // eventUsageLogicreportExperimentCreated: (experiment: Experiment,metadata?:@@ -1025,9 +1010,6 @@ export interface experimentLogicActions {isSecondary: booleanorderedUuids: string[]}- resetAutoRefreshInterval: () => {- value: true- }resetRunningExperiment: () => {value: true}@@ -1043,13 +1025,6 @@ export interface experimentLogicActions {retrySecondaryMetric: (index: number) => {index: number}- setAutoRefresh: (- enabled: boolean,- interval: number- ) => {- enabled: boolean- interval: number- }setEditExperiment: (editing: boolean) => {editing: boolean}@@ -1133,9 +1108,6 @@ export interface experimentLogicActions {setNotifyWhenResultsReady: (notify: boolean) => {notify: boolean}- setPageVisibility: (visible: boolean) => {- visible: boolean- }setPrimaryMetricsResults: (results: CachedNewExperimentQueryResponse[]) => {results: CachedNewExperimentQueryResponse[]}@@ -1208,9 +1180,6 @@ export interface experimentLogicActions {excluded: booleanvariantKey: string}- stopAutoRefreshInterval: () => {- value: true- }subscribeToResultsNotification: () => {value: true}@@ -1445,7 +1414,6 @@ export const experimentLogic = kea<experimentLogicType>(['reportExperimentTimeseriesRecalculated','reportExperimentAiSummaryRequested','reportExperimentMetricsRefreshed',- 'reportExperimentAutoRefreshToggled','reportExperimentMetricBreakdownAdded','reportExperimentMetricBreakdownRemoved',],@@ -1694,10 +1662,6 @@ export const experimentLogic = kea<experimentLogicType>([variants,rolloutPercentage,}),- setAutoRefresh: (enabled: boolean, interval: number) => ({ enabled, interval }),- resetAutoRefreshInterval: true,- stopAutoRefreshInterval: true,- setPageVisibility: (visible: boolean) => ({ visible }),subscribeToResultsNotification: true,dismissNotificationOffer: true,setShowNotificationOffer: (show: boolean) => ({ show }),@@ -2314,22 +2278,6 @@ export const experimentLogic = kea<experimentLogicType>([setHogfettiTrigger: (_, { trigger }) => trigger,},],- autoRefresh: [- {- interval: EXPERIMENT_AUTO_REFRESH_INITIAL_INTERVAL_SECONDS,- enabled: false,- } as { interval: number; enabled: boolean },- { persist: true, prefix: '2_' },- {- setAutoRefresh: (_, { enabled, interval }) => ({ enabled, interval }),- },- ],- isPageVisible: [- true as boolean,- {- setPageVisibility: (_, { visible }) => visible,- },- ],showNotificationOffer: [false,{@@ -2347,7 +2295,6 @@ export const experimentLogic = kea<experimentLogicType>([}),listeners(({ values, actions, asyncActions, cache, props }) => ({beforeUnmount: () => {- actions.stopAutoRefreshInterval()clearTimeout(cache.notificationOfferTimer)},subscribeToResultsNotification: async () => {@@ -2674,17 +2621,6 @@ export const experimentLogic = kea<experimentLogicType>([actions.setShowNotificationOffer(false)actions.setNotifyWhenResultsReady(false)- // Only set up auto-refresh if enabled AND page is visible- // This prevents the interval from restarting when async operations complete after the page becomes invisible- if (- values.experiment &&- values.autoRefresh.enabled &&- isLaunched(values.experiment) &&- values.isPageVisible- ) {- actions.resetAutoRefreshInterval()- }-// A warming-up experiment can show a stale "no results yet" snapshot on load, so fetch// fresh once. When it has results we leave it to the in-tab auto-refresh, since recomputes// might be expensive. Gated on `!forceRefresh` so the refresh we trigger here can't loop.@@ -3675,47 +3611,6 @@ export const experimentLogic = kea<experimentLogicType>([throw error}},- setAutoRefresh: ({ enabled, interval }) => {- // Track when user toggles auto-refresh settings- actions.reportExperimentAutoRefreshToggled(values.experiment, enabled, interval)- actions.resetAutoRefreshInterval()- },- stopAutoRefreshInterval: () => {- cache.disposables.dispose('autoRefreshInterval')- },- setPageVisibility: ({ visible }) => {- if (!visible) {- actions.stopAutoRefreshInterval()- } else if (values.autoRefresh.enabled) {- actions.resetAutoRefreshInterval()- }- },- resetAutoRefreshInterval: () => {- // Clear any existing interval first- cache.disposables.dispose('autoRefreshInterval')-- // Completed experiments have final results — never poll them- if (values.autoRefresh.enabled && !hasEnded(values.experiment)) {- cache.disposables.add(() => {- const intervalId = window.setInterval(() => {- // The experiment may have ended while the interval was running- if (hasEnded(values.experiment)) {- cache.disposables.dispose('autoRefreshInterval')- return- }- // Track auto-refresh trigger- actions.reportExperimentMetricsRefreshed(values.experiment, true, {- triggered_by: 'auto-refresh',- auto_refresh_enabled: values.autoRefresh.enabled,- auto_refresh_interval: values.autoRefresh.interval,- ...previousRefreshAnalytics(values.currentRefresh),- })- actions.refreshExperimentResults(true, 'auto_refresh')- }, values.autoRefresh.interval * 1000)- return () => clearInterval(intervalId)- }, 'autoRefreshInterval')- }- },})),loaders(({ actions, values, cache }) => ({experiment: {diff --git a/products/experiments/frontend/components/ExperimentMetaBar/ExperimentLastRefreshText.tsx b/products/experiments/frontend/components/ExperimentMetaBar/ExperimentLastRefreshText.tsxnew file mode 100644index 000000000000..e30ea24db7eb--- /dev/null+++ b/products/experiments/frontend/components/ExperimentMetaBar/ExperimentLastRefreshText.tsx@@ -0,0 +1,16 @@+import { TZLabel } from 'lib/components/TZLabel'+import { dayjs } from 'lib/dayjs'++export function ExperimentLastRefreshText({ lastRefresh }: { lastRefresh: string | null }): JSX.Element {+ const hoursSinceRefresh = lastRefresh ? dayjs().diff(dayjs(lastRefresh), 'hours') : null+ const colorClass =+ hoursSinceRefresh === null+ ? ''+ : hoursSinceRefresh > 12+ ? 'text-danger'+ : hoursSinceRefresh > 6+ ? 'text-warning'+ : ''++ return <span className={colorClass}>{lastRefresh ? <TZLabel time={lastRefresh} /> : 'a while ago'}</span>+}diff --git a/products/experiments/frontend/components/ExperimentMetaBar/ExperimentRefreshButton.tsx b/products/experiments/frontend/components/ExperimentMetaBar/ExperimentRefreshButton.tsxindex b1def50d7da9..111600f2a65d 100644--- a/products/experiments/frontend/components/ExperimentMetaBar/ExperimentRefreshButton.tsx+++ b/products/experiments/frontend/components/ExperimentMetaBar/ExperimentRefreshButton.tsx@@ -8,10 +8,11 @@ import { Spinner } from 'lib/lemon-ui/Spinner'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { experimentLogic, previousRefreshAnalytics } from 'scenes/experiments/experimentLogic'import { experimentMetricsLogic } from 'scenes/experiments/experimentMetricsLogic'-import { ExperimentLastRefreshText } from 'scenes/experiments/ExperimentView/ExperimentReloadAction'import { Experiment } from '~/types'+import { ExperimentLastRefreshText } from './ExperimentLastRefreshText'+interface RefreshButtonProps {isRefreshing: booleanlastRefresh: string | null@@ -56,7 +57,7 @@ function RecalculationRefreshButton({ experiment }: { experiment: Experiment }):const metricsLogic = experimentMetricsLogic({ experiment })const { isRecalculating, recalculationProgress, lastRefresh, queuedRerun } = useValues(metricsLogic)const { triggerRecalculation } = useActions(metricsLogic)- const { autoRefresh, currentRefresh } = useValues(experimentLogic)+ const { currentRefresh } = useValues(experimentLogic)const { reportExperimentMetricsRefreshed } = useActions(experimentLogic)const { refreshExperimentResults } = useAsyncActions(experimentLogic)@@ -69,8 +70,6 @@ function RecalculationRefreshButton({ experiment }: { experiment: Experiment }):onRefresh={() => {reportExperimentMetricsRefreshed(experiment, true, {triggered_by: 'manual',- auto_refresh_enabled: autoRefresh.enabled,- auto_refresh_interval: autoRefresh.interval,...previousRefreshAnalytics(currentRefresh),})triggerRecalculation()@@ -89,7 +88,6 @@ function LegacyRefreshButton({ experiment }: { experiment: Experiment }): JSX.ElsecondaryMetricsResults,primaryMetricsResultsLoading,secondaryMetricsResultsLoading,- autoRefresh,currentRefresh,} = useValues(experimentLogic)const { reportExperimentMetricsRefreshed } = useActions(experimentLogic)@@ -104,8 +102,6 @@ function LegacyRefreshButton({ experiment }: { experiment: Experiment }): JSX.ElonRefresh={() => {reportExperimentMetricsRefreshed(experiment, true, {triggered_by: 'manual',- auto_refresh_enabled: autoRefresh.enabled,- auto_refresh_interval: autoRefresh.interval,...previousRefreshAnalytics(currentRefresh),})void refreshExperimentResults(true, 'manual').catch(() => {diff --git a/products/experiments/frontend/constants.ts b/products/experiments/frontend/constants.tsindex 5e6243fbd042..5d8b6d9d110b 100644--- a/products/experiments/frontend/constants.ts+++ b/products/experiments/frontend/constants.ts@@ -47,7 +47,6 @@ export const MAX_LOOKBACK_DAYS = 30export const DEFAULT_MDE = 30// Autorefresh constants-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// the experiment is working).