: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
import { useValues } from 'kea'
import { insightLogic } from 'scenes/insights/insightLogic'
import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
import {
daysOfWeekLabel,
getExcludedDaysOfWeek,
querySupportsDaysOfWeek,
} from '~/queries/nodes/InsightViz/daysOfWeekFilterUtils'
import { ComputationTimeWithRefresh } from './ComputationTimeWithRefresh'
type InsightResultMetadataProps = {
disableLastComputation?: boolean
disableLastComputationRefresh?: boolean
}
export const InsightResultMetadata = ({
disableLastComputation,
disableLastComputationRefresh,
}: InsightResultMetadataProps): JSX.Element => {
const { insightProps } = useValues(insightLogic)
const { samplingFactor, dateRange, querySource } = useValues(insightVizDataLogic(insightProps))
// Only insights that apply daysOfWeek server-side get the note
const excludedDays = querySupportsDaysOfWeek(querySource) ? getExcludedDaysOfWeek(dateRange) : []
const excludedLabel = daysOfWeekLabel(excludedDays)
const excludedText = ['Weekends', 'Weekdays'].includes(excludedLabel) ? excludedLabel.toLowerCase() : excludedLabel
return (
<>
{!disableLastComputation && <ComputationTimeWithRefresh disableRefresh={disableLastComputationRefresh} />}
{samplingFactor ? (
<span className="text-secondary">
{!disableLastComputation && <span className="mx-1">•</span>}
Results calculated from {samplingFactor * 100}% of users
</span>
) : null}
{excludedDays.length > 0 ? (
<span className="text-secondary">
<span className="mx-1">•</span>
Excluding {excludedText}
</span>
) : null}
{dateRange?.excludeIncompletePeriods ? (
<span className="text-secondary">
<span className="mx-1">•</span>
Incomplete periods excluded
</span>
) : null}
</>
)
}