: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 { percentage } from 'lib/utils/numbers'
/**
* The share of `total` spans that carry the ID. A partly covered set never reads as a flat
* 0% or 100%, because either would say the count beside it covers nothing or everything.
*/
export function formatIdentityCoverage(covered: number | undefined, total: number): string {
if (!covered || !total) {
return '0%'
}
const fraction = covered / total
if (fraction < 0.005) {
return '<1%'
}
if (fraction >= 0.995 && fraction < 1) {
return '>99%'
}
return percentage(fraction, 0)
}