+
+ {t('other projects')}
+
+ );
+}
+
+export function SamplingBreakdown({period, sampleRates, ...props}: Props) {
+ const {data} = useProjectSampleCounts({period});
+
+ const spansWithSampleRates = data
+ ?.map(item => {
+ const sampledSpans = Math.floor(item.count * (sampleRates[item.project.id] ?? 1));
+ return {
+ project: item.project,
+ sampledSpans,
+ };
+ })
+ .toSorted((a, b) => b.sampledSpans - a.sampledSpans);
+
+ const hasOthers = spansWithSampleRates.length > ITEMS_TO_SHOW;
+
+ const topItems = hasOthers
+ ? spansWithSampleRates.slice(0, ITEMS_TO_SHOW - 1)
+ : spansWithSampleRates.slice(0, ITEMS_TO_SHOW);
+ const otherSpanCount = spansWithSampleRates
+ .slice(ITEMS_TO_SHOW - 1)
+ .reduce((acc, item) => acc + item.sampledSpans, 0);
+ const total = spansWithSampleRates.reduce((acc, item) => acc + item.sampledSpans, 0);
+
+ const getSpanPercent = spanCount => (spanCount / total) * 100;
+ const otherPercent = getSpanPercent(otherSpanCount);
+
+ return (
+