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.

feat(experiments): Replace AI analysis tab with in-context summarize buttons (#77518)

Juraj Majerik4cf26b96d679
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index c993acda9845..513d4cf41d17 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5909,21 +5909,21 @@ snapshots:
scenes-app-experiments--experiment-asymmetric-intervals--dark:
hash: v1.k794b7964.5467f631734e8f360299aa3d5e4a8da5d7ecc2dbe47a5d0727ddfb0dbc9e7ce6.ZGcS-wnQsOO1G4M5I_hw9Aba6YZ1hKpvya9gfWsZvCs
scenes-app-experiments--experiment-asymmetric-intervals--light:
- hash: v1.k794b7964.595a7efdddc81a3e15f508362a59e9487a3de93950597c714383efc66b6d4e6e.aeWvu1wPNmshDJ_cD8s1hqgaiNAeRROJnYkZu1m2niI
+ hash: v1.k794b7964.b2bc93939d938d962fbd42530c5c06ea637feef8192291232d4726aed5805cb4.Hl0K2n_pRnLrochHVl4MEGZG6PcHg72tGPuBxwQc9J8
scenes-app-experiments--experiment-exposures-expanded--dark:
hash: v1.k794b7964.56095d76684633d164b2bd7f3e3da2aefefba1272f2818e3c8f2e4d1bff595c7.jIZ5N9SItEnQIRj-axX2BfRM21O5JSz_MSSH3JyLAd4
scenes-app-experiments--experiment-exposures-expanded--light:
hash: v1.k794b7964.724a28250f085bea69008b564ca8266298b8f927f6231d8c3ee40571356c99b5.hX_fvUeWfYI85mX0qLAi3WWzB-bHfef61kIPRKsrw8U
scenes-app-experiments--experiment-frequentist-five-variants--dark:
- hash: v1.k794b7964.3e22f4570288ab145bb9ad96e4da9ad237e46a29cfefb3f758d9d7cf8db5a5d0.VPkcfBFukWV6eRSdNZJ65235H8o-OPsAkEmop4q68Co
+ hash: v1.k794b7964.e8a5b05a1e2fac506182f04dd0fb26649c927ca30a0166fd6dedefc6db83a3e7.bpIufNF51-pPDeWrq6e-Hu3o6Au6R9QlRzAUNeOcYgE
scenes-app-experiments--experiment-frequentist-five-variants--light:
hash: v1.k794b7964.ca65930ed4fba58aa886be84c0489a0702ef118abac3516ed530db42a772ad71.fp95LwvCUvwV1spa0Back9q7nUlZVypBoc4UMXJh9qc
scenes-app-experiments--experiment-frequentist-two-variants--dark:
hash: v1.k794b7964.045c33562841fedac0650c2b70ad4fda3b5bac5a2f43fc01310759ba3347a24f.ZwvpM3E6g3mcUx0ZrbltZHnAWoaSX7wlgu79kfGkRb8
scenes-app-experiments--experiment-frequentist-two-variants--light:
- hash: v1.k794b7964.b349b1f26f7d80b19b9772a0b011dfb52f23470ad04cf37b051ee3ff4ad9fdda.b7dOvKFXgBwnaUoLtGjiaVaT6ai_j3-UXDxx3IRcOzw
+ hash: v1.k794b7964.78c1d7249257f5c718f08f0891a67457acd2dd9db209f029e07e6b40032bc0f2.1OlEHxGwB9WRLVeWyifax0PiHjsUA46RUx0np37kSjM
scenes-app-experiments--experiment-with-funnel-metric--dark:
- hash: v1.k794b7964.1e725bd5acc7be5d19a5f22bf08cd4e364822f9d2db47d540e275ae91a701dc0.WoLqVhhEhSieveL0LuILYgB36bwhCaaIkruNs64XNBo
+ hash: v1.k794b7964.96b1395012157c8db6f8b7c202fde3bc61fe5eac1ffc69e94e6aa7555d7aa761.Li7ufJd8K-fsREg0jONxzGhDJuDnuWcatmvY5cvdJRI
scenes-app-experiments--experiment-with-funnel-metric--light:
hash: v1.k794b7964.8c14414398b3c6b47e0968adeea6d040b7a48c8f7f72d15bcd33392a005ca439.0tOTaEYTCs0PMiFDlR1l4QI6xLkEBXJE6o_kYkPV1BI
scenes-app-experiments--experiment-with-legacy-funnels-query--dark:
@@ -5935,21 +5935,21 @@ snapshots:
scenes-app-experiments--experiment-with-legacy-trends-query--light:
hash: v1.k794b7964.42c2f3656a5c989d4b1ee34296ca4bb59e186241920a5f8ca21f319069cc6825.6R2u2nPGBnbJYFX2aAn-ZEDtNpa4m1bQA-1aYg8Y7sM
scenes-app-experiments--experiment-with-mean-metric--dark:
- hash: v1.k794b7964.531f25ad73b1a28ac9dd34a14c56ebd7f60ea338d04c31b7abcbc0bb888fae20.qZinILYy_OUWX1rBHEMFlpC9dnm0m07xtskBMq5_XC0
+ hash: v1.k794b7964.3e78a41658e9e1b76cb2428cbb32582077b1b43f820744966285c0862ff7f556.0t5TdyC6dx2nKUFHy-DqEyw4L-07MqrloiHmOD5bo4Y
scenes-app-experiments--experiment-with-mean-metric--light:
- hash: v1.k794b7964.0d066f1db27a8041bea4f1b703a0038234af4b8f76197b37afefb78becae79de.3EV6FQYXIAswfa0spVGKURzGePFgNIFjfsI0Q4KU1QA
+ hash: v1.k794b7964.2bd044c1fb951cc5280c8befc03b7534774e703e92aa268f228ab20bd2522411.AFij815dd9946fOpsJgW7T2G_FjYM3Njr7LJ87amVrQ
scenes-app-experiments--experiment-with-multiple-metrics--dark:
- hash: v1.k794b7964.2bcc5f25af7c8178f4b337e739b27d17b4266711a5ab7fb6ec7211f6fece3108.c5cBK4uVvo8AgqY9t-pB9sOwxH4KIHjAcAKoR0tv9WA
+ hash: v1.k794b7964.1c6ec257ea31fe08adfd5f72270032c58fb9eea0c8a68409fb954152035a41ca.6PcGl1qAelTN8aq72lqgcYZw_sGKGunuXghGOUhkdVk
scenes-app-experiments--experiment-with-multiple-metrics--light:
- hash: v1.k794b7964.6cb83522346e9139a4d4a22937117c44151076ce8f6a7b385c2285133731312b.q9mFBAs-mRCLnqf5r5uKd0dkUY9CVIrAr0y6NFWtqjQ
+ hash: v1.k794b7964.6b5d896de6354dd8b5f191d4fbb2b87d167a3f3cc93f62c62284a782ec430bc6.7-LXuxxEUV_5ZlG5tUbyAmm4K2yP4rMwOiTDpAZkeTU
scenes-app-experiments--experiment-with-multiple-metrics-reordered--dark:
- hash: v1.k794b7964.cbd70b40c9fd112364d678bbeef3a294acae69c796c5e24ed68e2ec8f466288a.AYWkA-lSSgSsFpaIAmTZjh8NsLuwqT6oEaSd_XZrD7s
+ hash: v1.k794b7964.0aa35284172e036a686089dc570689700b128d0f606e100d0c8ae087cb712e93.aN_1UIRF5SlRbAPWl6PYs5zLUdQVQRB4CoKp5FXX0ww
scenes-app-experiments--experiment-with-multiple-metrics-reordered--light:
- hash: v1.k794b7964.a8a74e26b29f40af5ef40ee6670517de82f297b08915710f24a6e7559d72db58.hzHbun575N0FaJzBeF5HjlO3MwHkz7D5JR6Egi6pdGw
+ hash: v1.k794b7964.0ca14c6de1840b81c5389bd9b544ec815c845027a909e002090ead17d6d82b45.aqoPvTeNXn14TqXpZO-ZxNgWLw4tzzHYaHrTib8pHbM
scenes-app-experiments--experiment-with-ratio-metric--dark:
- hash: v1.k794b7964.5f615cd14d90bd13d4aaf4d23cad132c8808965cc3fc1b639dc6ce7e05756bf1.z2rKr_3rlC2Z_oZh1fxKt1d2t0S_fuwgrSyhRO1xsr0
+ hash: v1.k794b7964.f7d50e2c065ff1b918c01fae91091f1e6e7ac248a375529d04316a6e5a6ec521.0EZJzXkY1jfkXaoPiKnv3j5o8CNzqI0VBR8Wxs9JC0Y
scenes-app-experiments--experiment-with-ratio-metric--light:
- hash: v1.k794b7964.2e2dff597a499b51b8db08087d3c9610dcda4e5ecbd4f8bd809f6408e33a8d73.f0AqCDPbxx5XMVZ0S1K6bDRSIPDipNneYyTQVQhoBtE
+ hash: v1.k794b7964.cc2a5bbb71b901b5db0d97f8ace2666cef4f13301086dd388c6c72d3a3759049.rVJk1AMixaOqQ3KPxmL2IrJZ_3JFQVpVm-XchLm6Bpw
scenes-app-experiments--experiments--dark:
hash: v1.k794b7964.bb7a67466cb94c2155158d13444e7f6f473d8176c5823908c467b2d19c0f3ac9.uPI1H-JnVAqnEUTczdLstoglvGWvSOBV5k4w-FXpLWc
scenes-app-experiments--experiments--light:
diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentReplayTab.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentReplayTab.tsx
index 9bc5ab5ccd20..60e6c301f03f 100644
--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentReplayTab.tsx
+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentReplayTab.tsx
@@ -21,6 +21,7 @@ import { SessionRecordingsPlaylist } from 'scenes/session-recordings/playlist/Se
import { Experiment } from '~/types'
+import { SummarizeSessionReplaysButton } from '../components/SummarizeSessionReplaysButton'
import { isLaunched } from '../experimentStatus'
import { NOT_A_FUNNEL_REASON } from '../utils'
import { EXPOSURE_FALLBACK_NOTICE, EXPOSURE_UNLINKABLE_REASON } from '../viewRecordingsLinkabilityLogic'
@@ -300,6 +301,9 @@ export function ExperimentReplayTab({ experiment }: { experiment: Experiment }):
</DropdownMenuContent>
</DropdownMenu>
)}
+ <div className="ml-auto">
+ <SummarizeSessionReplaysButton experiment={experiment} />
+ </div>
</div>
{/* The default mode also uses the endpoint for a single multi-source metric, so the
caption follows the request, not the mode. */}
diff --git a/frontend/src/scenes/experiments/ExperimentView/ExperimentView.tsx b/frontend/src/scenes/experiments/ExperimentView/ExperimentView.tsx
index 4b985c6ef55f..b45aa24cab1d 100644
--- a/frontend/src/scenes/experiments/ExperimentView/ExperimentView.tsx
+++ b/frontend/src/scenes/experiments/ExperimentView/ExperimentView.tsx
@@ -1,21 +1,17 @@
import { useActions, useValues } from 'kea'
-import { IconSparkles } from '@posthog/icons'
import { LemonTab, LemonTabs } from '@posthog/lemon-ui'
import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { PendingChangeRequestBanner } from 'scenes/approvals/PendingChangeRequestBanner'
-import { EXPERIMENT_MIN_EXPOSURES_FOR_RESULTS } from 'scenes/experiments/constants'
import { WebExperimentImplementationDetails } from 'scenes/experiments/WebExperimentImplementationDetails'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { LegacyExperimentView } from '~/scenes/experiments/legacy'
import { ActivityScope } from '~/types'
-import { SummarizeExperimentButton } from '../components/SummarizeExperimentButton'
-import { SummarizeSessionReplaysButton } from '../components/SummarizeSessionReplaysButton'
import { EmptyMetricsPanel } from '../ExperimentForm/MetricsPanel/EmptyMetricsPanel'
import { ExperimentImplementationDetails } from '../ExperimentImplementationDetails'
import { experimentLogic } from '../experimentLogic'
@@ -47,34 +43,6 @@ import { ReleaseConditionsModal, ReleaseConditionsTable } from './ReleaseConditi
import { ResultsNotificationBanner } from './ResultsNotificationBanner'
import { SettingsTab } from './SettingsTab'
-const AiAnalysisTab = (): JSX.Element => {
- const { experiment, hasMinimumExposureForResults } = useValues(experimentLogic)
-
- return (
- <div className="flex flex-col gap-4 items-start">
- <div className="flex flex-col gap-1 items-start">
- <SummarizeExperimentButton
- disabledReason={
- !hasMinimumExposureForResults
- ? `Experiment needs at least ${EXPERIMENT_MIN_EXPOSURES_FOR_RESULTS} exposures to summarize results.`
- : undefined
- }
- />
- <p className="text-muted text-xs m-0">
- Analyze your experiment's metric results, statistical significance, and variant performance using
- AI.
- </p>
- </div>
- <div className="flex flex-col gap-1 items-start">
- <SummarizeSessionReplaysButton experiment={experiment} />
- <p className="text-muted text-xs m-0">
- Compare session recordings across variants to identify differences in user behavior.
- </p>
- </div>
- </div>
- )
-}
-
const MetricsTab = (): JSX.Element => {
const { experiment, orderedPrimaryMetricsWithResults, orderedSecondaryMetricsWithResults, isExperimentLaunched } =
useValues(experimentLogic)
@@ -134,16 +102,8 @@ const VariantsTab = (): JSX.Element => {
}
export function ExperimentView(): JSX.Element {
- const {
- experimentLoading,
- experimentId,
- experiment,
- isExperimentDraft,
- isExperimentLaunched,
- orderedPrimaryMetricsWithResults,
- exposureCriteria,
- showDebugPanel,
- } = useValues(experimentLogic)
+ const { experimentLoading, experimentId, experiment, isExperimentDraft, exposureCriteria, showDebugPanel } =
+ useValues(experimentLogic)
const { featureFlags } = useValues(featureFlagLogic)
const {
setExperiment,
@@ -177,21 +137,6 @@ export function ExperimentView(): JSX.Element {
label: 'Metrics',
content: <MetricsTab />,
},
- // Both AI analysis actions require a launched experiment with primary metrics
- ...(isExperimentLaunched && orderedPrimaryMetricsWithResults.length > 0
- ? [
- {
- key: 'ai_analysis',
- label: (
- <div className="flex items-center gap-1">
- <IconSparkles />
- <span>AI analysis</span>
- </div>
- ),
- content: <AiAnalysisTab />,
- },
- ]
- : []),
...(featureFlags[FEATURE_FLAGS.EXPERIMENT_RECORDINGS_TAB]
? [
{
diff --git a/frontend/src/scenes/experiments/MetricsView/new/Metrics.tsx b/frontend/src/scenes/experiments/MetricsView/new/Metrics.tsx
index a165b1336b08..92f698d4df94 100644
--- a/frontend/src/scenes/experiments/MetricsView/new/Metrics.tsx
+++ b/frontend/src/scenes/experiments/MetricsView/new/Metrics.tsx
@@ -8,6 +8,7 @@ import { IconAreaChart } from 'lib/lemon-ui/icons'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import type { ExperimentMetric } from '~/queries/schema/schema-general'
+import { SummarizeExperimentButton } from '~/scenes/experiments/components/SummarizeExperimentButton'
import { experimentLogic } from '~/scenes/experiments/experimentLogic'
import { experimentMetricsLogic } from '~/scenes/experiments/experimentMetricsLogic'
import { AddMetricButton } from '~/scenes/experiments/Metrics/AddMetricButton'
@@ -87,17 +88,12 @@ function MetricsContent({ experiment, isSecondary }: { experiment: Experiment; i
<h2 className="mb-0 font-semibold text-lg leading-6">
{isSecondary ? 'Secondary metrics' : 'Primary metrics'}
</h2>
- {metrics.length > 0 && (
- <Tooltip
- title={
- isSecondary
- ? 'Secondary metrics capture additional outcomes or behaviors affected by your experiment. They help you understand broader impacts and potential side effects beyond the primary goal.'
- : 'Primary metrics represent the main goal of your experiment. They directly measure whether your hypothesis was successful and are the key factor in deciding if the test achieved its primary objective.'
- }
- >
+ {isSecondary && metrics.length > 0 && (
+ <Tooltip title="Secondary metrics capture additional outcomes or behaviors affected by your experiment. They help you understand broader impacts and potential side effects beyond the primary goal.">
<IconInfo className="text-secondary text-lg" />
</Tooltip>
)}
+ {!isSecondary && hasMinimumExposureForResults && <SummarizeExperimentButton />}
{hasSomeResults && !isSecondary && <HowToReadTooltip />}
</div>
</div>
diff --git a/frontend/src/scenes/experiments/components/SummarizeExperimentButton.tsx b/frontend/src/scenes/experiments/components/SummarizeExperimentButton.tsx
index 2afad5ab0f64..df9ce0efe41d 100644
--- a/frontend/src/scenes/experiments/components/SummarizeExperimentButton.tsx
+++ b/frontend/src/scenes/experiments/components/SummarizeExperimentButton.tsx
@@ -2,9 +2,9 @@ import { useActions, useValues } from 'kea'
import posthog from 'posthog-js'
import { useMemo } from 'react'
-import { IconAI } from '@posthog/icons'
+import { IconSparkles } from '@posthog/icons'
+import { Tooltip } from '@posthog/lemon-ui'
-import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { addProductIntent } from 'lib/utils/product-intents'
import { useMaxTool } from 'scenes/max/useMaxTool'
@@ -96,7 +96,11 @@ function useExperimentSummaryMaxTool(): ReturnType<typeof useMaxTool> {
return maxToolResult
}
-export function SummarizeExperimentButton({ disabledReason }: { disabledReason?: string }): JSX.Element | null {
+/**
+ * Icon-only spark affordance that opens PostHog AI to summarize experiment results.
+ * Styled after the MaxTool corner button.
+ */
+export function SummarizeExperimentButton(): JSX.Element | null {
const { openMax } = useExperimentSummaryMaxTool()
const { experiment } = useValues(experimentLogic)
const { reportExperimentAiSummaryRequested } = useActions(experimentLogic)
@@ -105,17 +109,19 @@ export function SummarizeExperimentButton({ disabledReason }: { disabledReason?:
}
return (
- <LemonButton
- size="small"
- onClick={() => {
- reportExperimentAiSummaryRequested(experiment)
- openMax()
- }}
- type="secondary"
- icon={<IconAI />}
- disabledReason={disabledReason}
- >
- Summarize results
- </LemonButton>
+ <Tooltip title="Summarize results with PostHog AI" placement="top-end" delayMs={0}>
+ <button
+ type="button"
+ aria-label="Summarize results with PostHog AI"
+ data-attr="experiment-summarize-results"
+ className="size-6 shrink-0 cursor-pointer rounded-md border border-dashed border-ai bg-ai/08 backdrop-blur-[2px] transition duration-50 hover:scale-110 dark:bg-ai/20"
+ onClick={() => {
+ reportExperimentAiSummaryRequested(experiment)
+ openMax()
+ }}
+ >
+ <IconSparkles className="relative size-full p-1 text-ai dark:text-white" />
+ </button>
+ </Tooltip>
)
}
diff --git a/frontend/src/scenes/experiments/components/SummarizeSessionReplaysButton.tsx b/frontend/src/scenes/experiments/components/SummarizeSessionReplaysButton.tsx
index 1d4964febd5b..ae917cb9e85f 100644
--- a/frontend/src/scenes/experiments/components/SummarizeSessionReplaysButton.tsx
+++ b/frontend/src/scenes/experiments/components/SummarizeSessionReplaysButton.tsx
@@ -1,6 +1,6 @@
import { useActions, useValues } from 'kea'
-import { IconRewindPlay } from '@posthog/icons'
+import { IconSparkles } from '@posthog/icons'
import { LemonTag } from '@posthog/lemon-ui'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
@@ -37,8 +37,9 @@ export const SummarizeSessionReplaysButton = ({
const useSkill = featureFlags[FEATURE_FLAGS.EXPERIMENT_SESSION_REPLAYS_SKILL]
- // When using MaxTool, openMax is null if the button shouldn't show
- if (!useSkill && !openMax) {
+ // openMax is null when the tool isn't available (draft experiment or no results yet).
+ // Gate rendering on it for both click paths, so the skill path can't offer an unusable flow.
+ if (!openMax) {
return null
}
@@ -52,16 +53,16 @@ export const SummarizeSessionReplaysButton = ({
if (useSkill) {
// Open PostHog AI in a new tab with skill-based prompt
openPostHogAI(skillPrompt)
- } else if (openMax) {
+ } else {
// Use legacy MaxTool approach
openMax()
}
}}
type="secondary"
- icon={<IconRewindPlay />}
- tooltip="Use AI to analyze session recordings and identify patterns in user behavior across experiment variants. Discover insights about how users interact with your variants."
+ icon={<IconSparkles />}
+ tooltip="Use AI to compare session recordings across variants and spot differences in user behavior."
>
- Summarize session recordings
+ Summarize recordings
<LemonTag type="highlight" size="small" className="ml-1">
Beta
</LemonTag>