: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 { type TodayTone, useTodayTonePalette } from './todayTone'
export function TodayChange({
change,
tone,
unit = '%',
}: {
change: number | null
tone: TodayTone
unit?: '%' | 'pp'
}): JSX.Element | null {
const palette = useTodayTonePalette()
if (change === null) {
return null
}
const rounded = unit === 'pp' ? Math.round(change * 10) / 10 : Math.round(change)
const text =
unit === 'pp'
? `${rounded > 0 ? '+' : rounded < 0 ? '−' : ''}${Math.abs(rounded)} pp`
: rounded === 0
? '0%'
: `${rounded > 0 ? '+' : '−'}${Math.abs(rounded).toLocaleString('en-US')}%`
return (
<span
className="TodayChange"
translate="no"
// eslint-disable-next-line react/forbid-dom-props
style={tone === 'neutral' ? undefined : { color: palette[tone] }}
>
{text}
</span>
)
}