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(insights): remove lemon-skin date picker experiment flag (#78146)

Sam Penningtond9e20a615517
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 5e8882560cfc..51db2c471ed7 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -434,7 +434,6 @@ export const FEATURE_FLAGS = {
PRODUCT_ANALYTICS_INSIGHT_HORIZONTAL_CONTROLS: 'insight-horizontal-controls', // owner: #team-product-analytics
PRODUCT_ANALYTICS_PATHS_V2: 'paths-v2', // owner: @thmsobrmlr #team-product-analytics
PRODUCT_ANALYTICS_QUARTER_YEAR_INTERVALS: 'product-analytics-quarter-year-intervals', // owner: @sampennington #team-product-analytics, gates quarter/year interval selection on insights
- PRODUCT_ANALYTICS_QUILL_DATE_FILTER: 'product-analytics-quill-date-filter', // owner: @sampennington #team-product-analytics, swaps the insight date filter for the chip-based quill date filter (lemon-skinned)
PRODUCT_ANALYTICS_RETENTION_AGGREGATION: 'retention-aggregation', // owner: @anirudhpillai #team-product-analytics
PRODUCT_ANALYTICS_RETENTION_DWH: 'retention-dwh', // owner: @thmsobrmlr #team-product-analytics
PRODUCT_AUTONOMY: 'product-autonomy', // owner: #team-self-driving
diff --git a/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx b/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx
index b1761b2dc394..ff1b98a513f3 100644
--- a/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx
+++ b/frontend/src/queries/nodes/InsightViz/InsightDisplayConfig.tsx
@@ -7,13 +7,11 @@ import { LemonButton } from '@posthog/lemon-ui'
import { ChartFilter } from 'lib/components/ChartFilter'
import { CompareFilter } from 'lib/components/CompareFilter/CompareFilter'
import { IntervalFilter } from 'lib/components/IntervalFilter'
-import { FEATURE_FLAGS, NON_TIME_SERIES_DISPLAY_TYPES } from 'lib/constants'
+import { NON_TIME_SERIES_DISPLAY_TYPES } from 'lib/constants'
import { LemonMenu } from 'lib/lemon-ui/LemonMenu'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { alignResolvedDateRangeToInterval, formatResolvedDateRange } from 'lib/utils/datetime'
import { funnelDataLogic } from 'scenes/funnels/funnelDataLogic'
import { InsightDateFilter } from 'scenes/insights/filters/InsightDateFilter'
-import { InsightQuillDateFilter } from 'scenes/insights/filters/InsightDateFilter/InsightQuillDateFilter'
import { RetentionChartPicker } from 'scenes/insights/filters/RetentionChartPicker'
import { insightLogic } from 'scenes/insights/insightLogic'
import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
@@ -71,8 +69,6 @@ export function InsightDisplayConfig(): JSX.Element {
((isTrends || isStickiness) && !(display && NON_TIME_SERIES_DISPLAY_TYPES.includes(display)))
const { items: advancedOptions, count: advancedOptionsCount } = useInsightDisplayOptions()
- const { featureFlags } = useValues(featureFlagLogic)
- const useQuillDateFilter = featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_QUILL_DATE_FILTER] === 'test'
return (
<div
@@ -82,11 +78,7 @@ export function InsightDisplayConfig(): JSX.Element {
<div className="flex items-center gap-x-2 flex-wrap gap-y-2">
{!isRetention && (
<ConfigFilter>
- {useQuillDateFilter ? (
- <InsightQuillDateFilter disabled={isFunnels && !!isEmptyFunnel} />
- ) : (
- <InsightDateFilter disabled={isFunnels && !!isEmptyFunnel} />
- )}
+ <InsightDateFilter disabled={isFunnels && !!isEmptyFunnel} />
</ConfigFilter>
)}
diff --git a/frontend/src/queries/nodes/InsightViz/InsightResultMetadata.tsx b/frontend/src/queries/nodes/InsightViz/InsightResultMetadata.tsx
index 112615a574f7..7bfe6b8cedd0 100644
--- a/frontend/src/queries/nodes/InsightViz/InsightResultMetadata.tsx
+++ b/frontend/src/queries/nodes/InsightViz/InsightResultMetadata.tsx
@@ -1,7 +1,5 @@
import { useValues } from 'kea'
-import { FEATURE_FLAGS } from 'lib/constants'
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import {
daysOfWeekLabel,
getExcludedDaysOfWeek,
@@ -23,12 +21,9 @@ export const InsightResultMetadata = ({
}: InsightResultMetadataProps): JSX.Element => {
const { insightProps } = useValues(insightLogic)
const { samplingFactor, trendsFilter, dateRange, querySource } = useValues(insightVizDataLogic(insightProps))
- const { featureFlags } = useValues(featureFlagLogic)
- const quillDateFilterEnabled = featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_QUILL_DATE_FILTER] === 'test'
// Only insights that apply daysOfWeek server-side get the note
- const excludedDays =
- quillDateFilterEnabled && querySupportsDaysOfWeek(querySource) ? getExcludedDaysOfWeek(dateRange) : []
+ const excludedDays = querySupportsDaysOfWeek(querySource) ? getExcludedDaysOfWeek(dateRange) : []
const excludedLabel = daysOfWeekLabel(excludedDays)
const excludedText = ['Weekends', 'Weekdays'].includes(excludedLabel) ? excludedLabel.toLowerCase() : excludedLabel
@@ -53,7 +48,7 @@ export const InsightResultMetadata = ({
Weekends hidden
</span>
) : null}
- {quillDateFilterEnabled && dateRange?.excludeIncompletePeriods ? (
+ {dateRange?.excludeIncompletePeriods ? (
<span className="text-secondary">
<span className="mx-1">•</span>
Incomplete period excluded
diff --git a/frontend/src/scenes/insights/filters/InsightDateFilter/InsightQuillDateFilter.test.tsx b/frontend/src/scenes/insights/filters/InsightDateFilter/InsightQuillDateFilter.test.tsx
deleted file mode 100644
index 1c296c08442b..000000000000
--- a/frontend/src/scenes/insights/filters/InsightDateFilter/InsightQuillDateFilter.test.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import '@testing-library/jest-dom'
-
-import { cleanup, render, waitFor } from '@testing-library/react'
-import { BindLogic, Provider } from 'kea'
-
-import { insightDataLogic } from 'scenes/insights/insightDataLogic'
-import { insightLogic } from 'scenes/insights/insightLogic'
-import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
-
-import { useMocks } from '~/mocks/jest'
-import { LifecycleQuery, NodeKind, TrendsQuery } from '~/queries/schema/schema-general'
-import { initKeaTests } from '~/test/init'
-import { InsightShortId } from '~/types'
-
-import type { IsoDayOfWeek } from './daysOfWeekFilterUtils'
-import { InsightQuillDateFilter } from './InsightQuillDateFilter'
-
-const Insight123 = '123' as InsightShortId
-const insightProps = { dashboardItemId: Insight123 }
-
-function makeTrendsQuery(daysOfWeek: IsoDayOfWeek[] | null = null): TrendsQuery {
- return {
- kind: NodeKind.TrendsQuery,
- series: [{ kind: NodeKind.EventsNode, name: '$pageview', event: '$pageview' }],
- dateRange: { date_from: '-7d', daysOfWeek },
- }
-}
-
-function makeLifecycleQuery(daysOfWeek: IsoDayOfWeek[] | null = null): LifecycleQuery {
- return {
- kind: NodeKind.LifecycleQuery,
- series: [{ kind: NodeKind.EventsNode, name: '$pageview', event: '$pageview' }],
- dateRange: { date_from: '-7d', daysOfWeek },
- }
-}
-
-describe('InsightQuillDateFilter', () => {
- let vizDataLogic: ReturnType<typeof insightVizDataLogic.build>
-
- beforeEach(() => {
- useMocks({
- get: {
- '/api/environments/:team_id/insights/trend': [],
- '/api/environments/:team_id/insights/': { results: [{}] },
- },
- })
- initKeaTests()
-
- insightLogic(insightProps).mount()
- insightDataLogic(insightProps).mount()
- vizDataLogic = insightVizDataLogic(insightProps)
- vizDataLogic.mount()
- })
-
- afterEach(() => {
- cleanup()
- })
-
- function setupAndRender(query: TrendsQuery | LifecycleQuery): void {
- vizDataLogic.actions.updateQuerySource(query)
-
- render(
- <Provider>
- <BindLogic logic={insightLogic} props={insightProps}>
- <InsightQuillDateFilter disabled={false} />
- </BindLogic>
- </Provider>
- )
- }
-
- it('clears daysOfWeek when the insight changes to a kind that does not support it', async () => {
- setupAndRender(makeTrendsQuery([1, 2, 3, 4, 5]))
- expect(vizDataLogic.values.dateRange?.daysOfWeek).toEqual([1, 2, 3, 4, 5])
-
- vizDataLogic.actions.updateQuerySource(makeLifecycleQuery([1, 2, 3, 4, 5]))
-
- await waitFor(() => {
- expect(vizDataLogic.values.dateRange?.daysOfWeek ?? null).toBeNull()
- })
- })
-
- it('leaves daysOfWeek untouched while the query kind keeps support for it', async () => {
- setupAndRender(makeTrendsQuery([1, 2, 3, 4, 5]))
-
- vizDataLogic.actions.updateQuerySource(makeTrendsQuery([1, 2, 3, 4, 5]))
-
- await waitFor(() => {
- expect(vizDataLogic.values.dateRange?.daysOfWeek).toEqual([1, 2, 3, 4, 5])
- })
- })
-})
diff --git a/frontend/src/scenes/insights/filters/InsightDateFilter/InsightQuillDateFilter.tsx b/frontend/src/scenes/insights/filters/InsightDateFilter/InsightQuillDateFilter.tsx
deleted file mode 100644
index f11bc366be6f..000000000000
--- a/frontend/src/scenes/insights/filters/InsightDateFilter/InsightQuillDateFilter.tsx
+++ /dev/null
@@ -1,202 +0,0 @@
-import { useActions, useValues } from 'kea'
-import { useEffect, useState } from 'react'
-
-import { IconCalendar, IconInfo } from '@posthog/icons'
-import {
- Button,
- Label,
- Popover,
- PopoverContent,
- PopoverTrigger,
- Switch,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from '@posthog/quill'
-
-import {
- DateFilterExclusionsControl,
- dateFilterExclusionParts,
- type DateFilterExclusions,
-} from 'lib/components/DateFilter/DateFilterExclusionsControl'
-import { selectionKeyOf, type DateRangeSelection } from 'lib/components/DateFilter/DateRangePresetsPanel'
-import { dateRangeForSelection, selectionForDateRange } from 'lib/components/DateFilter/dateRangeSelection'
-import { QuillDateFilter } from 'lib/components/DateFilter/QuillDateFilter'
-import { dateFilterToText, dateMapping } from 'lib/utils/dateFilters'
-import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
-import { insightLogic } from 'scenes/insights/insightLogic'
-import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
-import { teamLogic } from 'scenes/teamLogic'
-
-import {
- computeDaysOfWeekUpdate,
- getExcludedDaysOfWeek,
- querySupportsDaysOfWeek,
- type IsoDayOfWeek,
-} from './daysOfWeekFilterUtils'
-
-// Chip labels double as dateMapping keys; filter at module load so a renamed chip can never
-// silently produce the wrong range.
-const NAMED_CHIPS = ['Today', 'Yesterday', 'This week', 'This month', 'This year', 'All time'].filter((name) =>
- dateMapping.some(({ key }) => key === name)
-)
-
-function shortExclusionsLabel(parts: string[]): string {
- return parts.length > 1 ? `excl. ${parts[0]} +${parts.length - 1}` : `excl. ${parts[0]}`
-}
-
-const LEMON_SKIN_PROPS = { 'data-lemon-skin': 'true' }
-
-type InsightQuillDateFilterProps = {
- disabled: boolean
-}
-
-export function InsightQuillDateFilter({ disabled }: InsightQuillDateFilterProps): JSX.Element {
- const { insightProps, editingDisabledReason } = useValues(insightLogic)
- const { dateRange, trendsFilter, isTrends, isRetention, querySource } = useValues(insightVizDataLogic(insightProps))
- const { updateDateRange, updateQuerySource } = useActions(insightVizDataLogic(insightProps))
- const { reportInsightDatePickerOpened } = useActions(eventUsageLogic)
- const { weekStartDay } = useValues(teamLogic)
- const [open, setOpen] = useState(false)
-
- const storeSelection = selectionForDateRange(dateRange?.date_from ?? '-7d', dateRange?.date_to)
- // The store updates only after the logic's 300ms debounce — reflect picks immediately
- // so rapid stepper presses accumulate instead of re-deriving from a stale value.
- const [pendingSelection, setPendingSelection] = useState<DateRangeSelection | null>(null)
- const storeSelectionKey = selectionKeyOf(storeSelection)
- useEffect(() => {
- setPendingSelection(null)
- }, [storeSelectionKey])
- const selection = pendingSelection ?? storeSelection
- const triggerLabel =
- dateFilterToText(dateRange?.date_from ?? '-7d', dateRange?.date_to, 'Last 7 days', dateMapping, false) ??
- 'Last 7 days'
-
- // The picker speaks excluded days; the query schema stores included days. The legacy
- // display-only trendsFilter.hideWeekends is deliberately NOT folded in — different semantics.
- const excludedDays = getExcludedDaysOfWeek(dateRange)
- // The backend rejects daysOfWeek together with smoothing, so don't offer it
- const smoothingActive = isTrends && (trendsFilter?.smoothingIntervals ?? 1) > 1
- const showExcludedDays = querySupportsDaysOfWeek(querySource) && !smoothingActive
- const showIncompletePeriod = !isRetention
-
- // Hiding the exclusions control (smoothing turned on, or the insight changed to an
- // unsupported kind) must also clear any daysOfWeek already on the query — otherwise it
- // lingers with no UI left to remove it, and the backend rejects daysOfWeek alongside
- // smoothing.
- useEffect(() => {
- if (!showExcludedDays && dateRange?.daysOfWeek?.length) {
- updateQuerySource(computeDaysOfWeekUpdate([], dateRange))
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [showExcludedDays])
- const exclusions: DateFilterExclusions = {
- days: showExcludedDays ? excludedDays.map(String) : [],
- incomplete: !isRetention && !!dateRange?.excludeIncompletePeriods,
- }
- const handleExclusionsChange = (next: DateFilterExclusions): void => {
- if (showExcludedDays && next.days.join(',') !== exclusions.days.join(',')) {
- updateQuerySource(computeDaysOfWeekUpdate(next.days.map(Number) as IsoDayOfWeek[], dateRange))
- }
- if (!isRetention && next.incomplete !== exclusions.incomplete) {
- updateDateRange({ excludeIncompletePeriods: next.incomplete ? true : null }, true)
- }
- }
-
- const exclusionParts = dateFilterExclusionParts(exclusions)
-
- return (
- <Popover
- open={open}
- onOpenChange={(next) => {
- if (next && !open) {
- reportInsightDatePickerOpened(querySource?.kind)
- }
- setOpen(next)
- }}
- >
- <PopoverTrigger
- render={
- <Button
- variant="outline"
- data-quill
- data-lemon-skin
- disabled={disabled || !!editingDisabledReason}
- title={editingDisabledReason ?? undefined}
- data-attr="insight-quill-date-filter"
- />
- }
- >
- <IconCalendar />
- {triggerLabel}
- {exclusionParts.length > 0 && (
- <span className="text-muted-foreground font-normal">· {shortExclusionsLabel(exclusionParts)}</span>
- )}
- </PopoverTrigger>
- <PopoverContent
- align="start"
- collisionAvoidance={{ side: 'flip', align: 'shift', fallbackAxisSide: 'none' }}
- className="w-auto overflow-hidden border-none p-0 shadow-none ring-0"
- {...LEMON_SKIN_PROPS}
- >
- <QuillDateFilter
- selection={selection}
- onSelectionChange={(next) => {
- setPendingSelection(next)
- // Rolling changes ride the stepper click-by-click, so let them debounce
- updateDateRange(dateRangeForSelection(next), next.kind !== 'rolling')
- if (next.kind !== 'rolling') {
- setOpen(false)
- }
- }}
- onApplyCustom={(next) => {
- updateDateRange(dateRangeForSelection(next), true)
- setOpen(false)
- }}
- namedChips={NAMED_CHIPS}
- weekStartsOn={weekStartDay === 1 ? 1 : 0}
- portalProps={LEMON_SKIN_PROPS}
- presetsFooter={
- <>
- <div className="flex h-8 items-center justify-between gap-2 px-2">
- <Label htmlFor="date-filter-exact-time" className="flex items-center gap-1">
- Exact time range
- <Tooltip>
- <TooltipTrigger render={<span className="inline-flex" />}>
- <IconInfo className="h-4 w-4 text-muted-foreground" />
- </TooltipTrigger>
- <TooltipContent className="max-w-64 flex-col items-start whitespace-normal">
- <span>
- When enabled: uses the current time for period boundaries instead of
- full days.
- </span>
- <span>
- When disabled: dates are rounded to full day periods (start and end of
- day).
- </span>
- </TooltipContent>
- </Tooltip>
- </Label>
- <Switch
- id="date-filter-exact-time"
- size="sm"
- checked={dateRange?.explicitDate ?? false}
- onCheckedChange={(checked) => updateDateRange({ explicitDate: checked }, true)}
- />
- </div>
- {(showExcludedDays || showIncompletePeriod) && (
- <DateFilterExclusionsControl
- exclusions={exclusions}
- onChange={handleExclusionsChange}
- showDays={showExcludedDays}
- showIncomplete={showIncompletePeriod}
- panelProps={LEMON_SKIN_PROPS}
- />
- )}
- </>
- }
- />
- </PopoverContent>
- </Popover>
- )
-}