Repository navigation
fix!: bucket per experiment and run in browsers (0.2.0) - #1
Merged
Merged
Conversation
The hash ignored experimentName, so a user got the same variant in every experiment: anyone in treatment for one experiment was in treatment for all of them, and concurrent experiments skewed each other's results. - Hash `experimentName:uniqueId`. `legacyHashing: true` buckets by uniqueId alone and reproduces 0.1.x exactly (checked against 0.1.8 over 1M IDs). - Replace node:crypto and Buffer with a small synchronous SHA-256, so the package works in browsers and edge runtimes and the API stays sync. - Throw on invalid input (empty IDs, NaN or non-number percentages) instead of returning resolvedVariant: null. - Ship CommonJS as well as ES modules, with an exports map; the module field pointed at a file that didn't exist. - Tests pin exact buckets and check independence across experiments and stability when exposure or the split is raised. BREAKING CHANGE: users are reassigned unless legacyHashing is set. Invalid input throws.
…t release The workflow only ever bumped the patch number, so a breaking change would have shipped as 0.1.9 to everyone on ^0.1.x.
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.
Bug
getABExperimentBuckethashed onlyuniqueId;experimentNamewas never used. A user got the same variant in every experiment. Over 100k simulated users, the variant matched across two experiments 100% of the time, and 50% were in treatment for both (independent assignment gives 25%). Experiments running at the same time skewed each other's results.Changes
experimentName:uniqueId.legacyHashing: truebuckets byuniqueIdalone and reproduces 0.1.x exactly: 0 differences against the published 0.1.8 over 1M IDs with random splits and exposures.node:cryptoandBuffer, and the API stays sync. I ran the built ESM file in a browser and it gave the same assignments as Node.resolvedVariant: null.exportsmap. Themodulefield used to point at a file that didn't exist.package.jsonnewer than the last release is used as-is, so this ships as 0.2.0 instead of an automatic 0.1.9 patch.Breaking
Users are reassigned unless
legacyHashing: trueis passed, and invalid input now throws. The README has an "Upgrading from 0.1.x" section.