How to Track Feature Flag Errors and A/B Test Latency (2026)
Variant B has 3x errors. Here's how to catch it.
A variant can win on conversions while quietly throwing more errors. Often the data to catch that already exists. LaunchDarkly knows which users saw which variant. Sentry knows which users hit errors. But unless someone wires up an integration, those are two datasets in two tools, which is the classic "data-rich and insight-poor" situation. The correlation ends up manual. (This is exactly the case against five-tool observability stacks.)
That's the setup for this guide.
What you'll have by the end
A working setup that answers these questions in real-time:
- What's the error rate for each feature flag variant?
- Is variant B adding latency compared to control?
- Which specific errors are unique to the treatment group?
- Should we kill this experiment early due to reliability issues?
We're using JustAnalytics for the implementation (it handles analytics, errors, and APM in one SDK), but the pattern works with any observability stack that supports custom properties on events.
Prerequisites
- A feature flagging tool (LaunchDarkly, Split.io, Statsig, Optimizely, PostHog, or similar)
- An observability tool with error tracking and custom event properties
- A frontend codebase (React, Vue, vanilla JS — doesn't matter)
- About 30 minutes for the initial setup
Honestly, the 30 minutes is optimistic. Budget an hour if your flag SDK has odd initialization timing. Flag SDKs and analytics scripts racing each other is the most common snag.
Step 1: Pass the variant assignment to your observability SDK
The core idea is simple: when your feature flag service assigns a user to a variant, record that assignment as a property that follows them through errors, pageviews, and performance events.
Here's what that looks like with LaunchDarkly and JustAnalytics:
import { initialize } from 'launchdarkly-js-client-sdk';
// After the LD client initializes (the JustAnalytics script tag is already on the page)
const ldClient = initialize('your-client-id', { key: userId });
await ldClient.waitForInitialization();
// Get all active flag assignments
const allFlags = ldClient.allFlags();
// Record each assignment as a user property (analytics side)
window.JustAnalytics.setUserProperty('flag_checkout_redesign', allFlags['checkout-redesign']);
window.JustAnalytics.setUserProperty('flag_payment_flow_v2', allFlags['payment-flow-v2']);
window.JustAnalytics.setUserProperty('flag_new_address_validation', allFlags['new-address-validation']);
// ...and as a tag, so every captured error carries it too
window.JA.setTag('flag_checkout_redesign', allFlags['checkout-redesign']);
window.JA.setTag('flag_payment_flow_v2', allFlags['payment-flow-v2']);
window.JA.setTag('flag_new_address_validation', allFlags['new-address-validation']);
There's no npm package for the browser side: the tracker loads from its script tag and exposes window.JustAnalytics. setUserProperty stores each assignment against the visitor, so you can group sessions by flag_checkout_redesign = 'variant-b' later. Error events don't pick up user properties, though: they carry the tags you set with window.JA.setTag, which is why each assignment is set both ways. One caveat: setUserProperty writes to localStorage regardless of the consent state, so treat flag names and values as non-sensitive and think about your consent setup. The query examples below use an illustrative schema (a flags JSON column on sessions and errors). Map the names to whatever your export or dashboard exposes.
Why this step matters: without it, you're correlating data manually. Teams often export CSVs from their flag service, CSVs from Sentry, join on user ID in a Jupyter notebook, and call it "experiment observability."
It works once. Nobody does it twice.
Step 2: Verify the context is flowing through
Before you trust the data, verify it's actually attached. Fire a test error and check that the flag context appears:
// Temporary test — remove after verification
window.JA.captureException(new Error('Test error for variant context'));
In your error dashboard, find that test error. The event details should show your flag assignments as tags. If they're missing, your initialization order is probably wrong — the flag client is evaluating before the tracker is ready.
What you should see: the test error with flag_checkout_redesign: 'variant-b' (or whatever your test values are) attached. If the tag is empty, the setTag calls are firing before the flag client returns values.
Step 3: Build the variant error comparison view
Now for the actual analysis. You want a dashboard or query that shows error rate per variant, side by side.
Against the illustrative schema from Step 1, that query looks like this:
SELECT
s.flags->>'checkout_redesign' as variant,
COUNT(*) as total_errors,
COUNT(DISTINCT e.session_id) as affected_sessions,
ROUND(
100.0 * COUNT(DISTINCT e.session_id) /
(SELECT COUNT(DISTINCT s2.id) FROM sessions s2
WHERE s2.flags->>'checkout_redesign' = s.flags->>'checkout_redesign'
AND s2.timestamp > NOW() - INTERVAL '7 days'),
2
) as error_rate
FROM errors e
JOIN sessions s ON e.session_id = s.id
WHERE
e.timestamp > NOW() - INTERVAL '7 days'
AND s.flags->>'checkout_redesign' IS NOT NULL
GROUP BY s.flags->>'checkout_redesign'
ORDER BY error_rate DESC;
Example output:
| Variant | Total Errors | Affected Sessions | Error Rate |
|---|---|---|---|
| variant-b | 847 | 412 | 3.2% |
| control | 298 | 289 | 1.1% |
That 3x difference is the signal. Variant B has a bug — or at least an edge case — that control doesn't.
If you're working from a dashboard rather than SQL, you're looking for a filter like flag_checkout_redesign = variant-b applied to your error list, then comparing counts manually. Doable, but slower. We covered correlating errors with analytics funnel drop-off for funnel-specific analysis.
Step 4: Add latency tracking per variant
Errors are one failure mode. Slowness is another — and it often converts to errors as users rage-click or abandon.
Track your critical operations with variant context:
async function submitCheckout(cart: Cart) {
const start = performance.now();
try {
const result = await processPayment(cart);
window.JustAnalytics.track('checkout_completed', {
duration_ms: performance.now() - start,
variant: getCurrentVariant('checkout-redesign'),
cart_value: cart.total,
});
return result;
} catch (error) {
window.JustAnalytics.track('checkout_failed', {
duration_ms: performance.now() - start,
variant: getCurrentVariant('checkout-redesign'),
error_type: error.name,
});
throw error;
}
}
Now your events table has timing data broken out by variant. The comparison query:
SELECT
variant,
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY duration_ms) as p50,
PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY duration_ms) as p95,
PERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY duration_ms) as p99
FROM events
WHERE
event_name = 'checkout_completed'
AND timestamp > NOW() - INTERVAL '7 days'
GROUP BY variant;
If control has a p95 of 1,200ms and variant-b has a p95 of 2,800ms, you've found a performance regression. That 1.6 second difference might explain the error rate increase too — timeouts, user abandonment, retry storms.
Side note: p95 is often more useful than p50 for experiment analysis. Median performance can look fine while a subset of users gets hammered. A variant can look identical at p50 while its p99 is much worse.
To pinpoint where the latency spike originates, compare p95 and p99 latencies per API endpoint — the outliers usually cluster on one or two operations.
Step 5: Set up automated alerts for variant regressions
Don't wait for someone to manually check. Alert when a variant's error rate exceeds a threshold relative to control.
// Backend job, runs hourly
async function checkVariantHealth() {
const stats = await db.query(`
SELECT
flags->>'checkout_redesign' as variant,
COUNT(DISTINCT e.session_id)::float /
(SELECT COUNT(DISTINCT s.id) FROM sessions s
WHERE s.flags->>'checkout_redesign' = e.flags->>'checkout_redesign'
AND s.timestamp > NOW() - INTERVAL '24 hours')
as error_rate
FROM errors e
WHERE e.timestamp > NOW() - INTERVAL '24 hours'
AND e.flags->>'checkout_redesign' IS NOT NULL
GROUP BY e.flags->>'checkout_redesign'
`);
const control = stats.find(s => s.variant === 'control');
if (!control || control.error_rate === 0) return; // nothing to compare against yet
const variants = stats.filter(s => s.variant !== 'control');
for (const variant of variants) {
if (variant.error_rate > control.error_rate * 2) {
await sendAlert({
channel: '#experiments',
severity: 'warning',
message: `Variant ${variant.variant} has ${(variant.error_rate / control.error_rate).toFixed(1)}x the error rate of control`,
action: 'Consider pausing experiment or investigating errors',
});
}
}
}
The 2x threshold is a starting point. Honestly, it's arbitrary — it's easy to explain to product managers. Adjust based on your traffic volume and tolerance. High-traffic experiments can use tighter thresholds (1.5x) because the sample size supports confident detection. Low-traffic? You might need 3x before you're confident it's signal and not noise.
Common errors and how to fix them
Variant property is null on error events
Your flag service is evaluating after your observability SDK initializes. Either await the flag client before setting experiment context, or use a callback-based approach where you update context once flags are ready. Some SDKs support late binding of context properties — check your docs.
Control and variant have identical error rates but different errors
The total error rate can be the same while the mix changes. Variant B might suppress one type of error while introducing another. Don't just compare rates — look at the actual error messages and stack traces per variant. A variant that trades intermittent network errors for consistent TypeError exceptions isn't neutral.
Error rate is higher for variant but conversion is also higher
Sometimes the variant breaks a flow that low-intent users would have abandoned anyway. Your job is to report both facts to the product owner: "Variant B has +14% conversion and +3x error rate. The errors primarily affect users who would have bounced regardless, but a subset are high-intent users hitting the address validator bug." Let them decide. For session replay of what's happening in those error cases, our GDPR session replay and PII masking guide covers privacy setup.
You can't filter errors by variant in your current tool
If your error tracking service doesn't support custom properties (or charges extra for them), you have a few options. You can switch tools, you can export data and correlate externally, or you can add variant information to error messages themselves (hacky but functional): new Error('[variant-b] Address validation failed').
The last option is a hack. Sometimes "works" beats "elegant."
Next steps
Once you've got basic variant error tracking running, a few natural extensions:
Per-page or per-feature breakdown. A/B tests often affect multiple pages. Segment your error rate by page path to find where the variant is actually problematic. Sometimes it's fine everywhere except one edge case route.
Connect to revenue. If variant B has more errors but higher conversion, the next question is: are those error-affected sessions churning at higher rates? Track retention metrics for each variant over 30–60 days to see if the error-affected cohort has lower repeat usage or lifetime value.
Hook into your flag service. Some flag tools (LaunchDarkly, Split.io) support metrics integrations that can automatically ingest error rates as experiment metrics. Worth configuring if you're running dozens of experiments — manual dashboards don't scale.
For teams running experiments on landing pages with paid traffic, ClickzProtect helps you separate real user behavior from bot traffic that might skew your variant comparisons.
Frequently Asked Questions
How do I track errors per feature flag variant?
Add the variant assignment as a custom property on every error event. When a user sees variant B, tag their session with variant: 'B'. Then filter your error dashboard by that property. You'll see error counts, stack traces, and affected browsers broken out per variant — without leaving your observability tool.
What's a safe error rate threshold for feature flag variants?
Compare against your baseline, not an absolute number. If your control variant has a 0.3% error rate and your treatment hits 0.9%, that's a 3x regression — significant even though both numbers look small. A common starting point is an alert at 1.5x-2x the control error rate, though the right threshold depends on traffic volume and how critical the feature is.
Can I correlate feature flag performance with A/B test conversion results?
Yes. If your observability tool tracks custom events with variant properties (and shares session context with analytics), you can join conversion events to latency and error data. High-converting variants with poor reliability should trigger investigation — the conversion lift may disappear once error-affected users start churning.
Should I stop an experiment if the treatment variant has more errors?
It depends on magnitude and user impact. A 10% error increase on a non-critical tooltip is probably fine to keep running. A 50% error increase on checkout is an emergency stop. The decision tree: is the error user-facing, is it blocking a critical flow, and how confident are you that the errors are caused by the variant versus coincidental timing?
Try JustAnalytics
All-in-one observability in one under-5KB script: cookieless analytics + error tracking + APM + session replay + uptime + structured logs. Replaces GA4 + Sentry + Datadog + Pingdom + LogRocket. Free tier (100K events/mo), Pro $49/month ($39 annual).
Author at JustAnalytics.