feat(debug): Make data reliable when debuging - #316
Open
jrosendahl-opt wants to merge 3 commits into
Open
Conversation
jplaroche
reviewed
Aug 19, 2026
| * @returns true if the event should be sampled and analytics calls may proceed. | ||
| */ | ||
| shouldSample(): boolean { | ||
| if (getFlags().optableDebug) return true; |
Contributor
There was a problem hiding this comment.
Personally, I'd bind this to optableControlGroup instead of optableDebug.
Contributor
Author
There was a problem hiding this comment.
This PR has both controlGroup and the sample rate tied to debug with the assumption that when you are debugging you don't want activity hidden by sampling.
Most of the time the first question is did x happen. If id does not happen because of some sampling issue, debugging becomes non-intuitive until you realize sampling is the issue, and then you have to figure out how to turn sampling off.
Is there a use case where logging + sampling + control + turning off bot detection this would present a problem?
If so we could use a different parameter than optableDebug.
…nd bypasses bot detection Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… flag optableDebug is documented for publishers as a logging switch, so overloading it silently changed sampling, A/B assignment and bot detection for anyone already setting it. The overrides move to their own flag, read through flagEnabled so an explicit "=0" turns them off. Three further problems the overrides introduced: - The witness payload reported the configured samplingRate while sampling was forced on, so the processor extrapolated a debug session as a full sample: a 0.1 rate scaled one debug auction to ten. It now reports the effective rate and tags the event with optableDebugOverrides so debug traffic can be excluded from aggregates. - OPTABLE_TARGETING_DONE outlives the flag, so a session that had already been bot-detected kept short-circuiting RTD even with the override on. The override now clears the key. - A flag-forced A/B variant was written to localStorage, pinning the browser to that group long after the flag was gone. Forced variants are no longer persisted, which also fixes the pre-existing optableControlGroup case.
mosherBT
force-pushed
the
feat/debug-flag-overrides
branch
from
September 8, 2026 19:59
b6a8e7e to
23d77a9
Compare
- flags.md gained the optableDebugOverrides row. That registry is the documented source of truth, and the key had only been described in a FLAG_KEYS comment, which is now trimmed to the one thing visible from the key list: why a second debug flag exists at all. - setupAB persists inside the priority-3 branch that assigns the variant, so the "never persist a forced variant" rule no longer rides on a boolean whose meaning depends on sitting between two priority blocks. A new resolution step can no longer silently inherit it. - SkipTargetingForBots reuses the try/catch it already had instead of adding a second one ahead of it. - effectiveSamplingRate() collapses into one local in the payload builder, its only caller, so the reported rate and the debug tag are read once and cannot disagree for a single event. Its tests now assert the payload fields rather than the helper, covering the contract that actually matters. - botDetection.md documents the SkipTargetingForBots contract change, and the per-feature docs link to flags.md instead of restating the =0 semantics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When you are debuging a page the sampling and a/b infrastructure get in the way. This change makes it so when you are in debug mode you are also in the production group and there is no analytics sampling.
shouldSample()now returnstrueimmediately whenoptableDebugis set, regardless of the configuredsamplingRateoptableDebugforces the production/treatment group, same asoptableControlGroup=0— explicitoptableControlGroup=1still takes prioritySkipTargetingForBots()returnsfalseimmediately whenoptableDebugis set, so targeting always runs even in bot-like environments (e.g. headless browsers during development)Activated via
?optableDebugURL param orsessionStorage.setItem("optableDebug", "1")in the browser console, using the existing flags system.Test plan
optableDebugin sessionStorage causesshouldSample()to returntrueeven withsamplingRate: 0optableDebugforces production group assignment even when random bucket would land in controloptableControlGroup=1overridesoptableDebug(explicit control override still works)SkipTargetingForBots()returnsfalsewhenoptableDebugis setnpx jest)🤖 Generated with Claude Code