feat(debug): Make data reliable when debuging - #316
Open
jrosendahl-opt wants to merge 1 commit into
Open
Conversation
…nd bypasses bot detection Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
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