fix(experiments): prevent NaN propagation and ACOS zero-value bug in experiment analysis

- Change ?? to || for salesAds/units/revenue in weekly aggregation to guard against NaN
- Add || 0 fallback to ads-only records in mergeSalesAndAdsData
- Fix parseCurrency to check isNaN on all EU-format return paths
- Handle ACOS edge case: cost > 0 with adRevenue = 0 now returns 100% instead of 0%
- Add diagnostic console logging to computeDiD for data flow tracing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Vidal Wolf
2026-02-25 16:34:55 +01:00
co-authored by Claude Opus 4.6
parent de1af7e0db
commit 8b774ae7ba
3 changed files with 36 additions and 15 deletions
+2 -2
View File
@@ -812,8 +812,8 @@ const ExperimentDetailView: React.FC<{
<td className="px-4 py-2.5 text-slate-300 font-medium">{METRIC_LABELS[metric] || metric}</td>
<td className="px-4 py-2.5 text-right text-slate-400">{formatMetricValue(r.treatment_before, metric)}</td>
<td className="px-4 py-2.5 text-right text-white font-medium">{formatMetricValue(r.treatment_after, metric)}</td>
<td className="px-4 py-2.5 text-right text-slate-400">{r.control_before ? formatMetricValue(r.control_before, metric) : '—'}</td>
<td className="px-4 py-2.5 text-right text-slate-400">{r.control_after ? formatMetricValue(r.control_after, metric) : '—'}</td>
<td className="px-4 py-2.5 text-right text-slate-400">{typeof r.control_before === 'number' ? formatMetricValue(r.control_before, metric) : '—'}</td>
<td className="px-4 py-2.5 text-right text-slate-400">{typeof r.control_after === 'number' ? formatMetricValue(r.control_after, metric) : '—'}</td>
<td className={`px-4 py-2.5 text-right font-medium ${r.did_estimate >= 0 ? 'text-emerald-400' : 'text-red-400'}`}>
{r.did_estimate >= 0 ? '+' : ''}{formatMetricValue(r.did_estimate, metric)}
</td>