8000 Fixes issues with ExperimentRandomWeighed and ExperimentUniqueIdWeighed by engvik · Pull Request #7 · soldotno/react-abtest · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixes issues with ExperimentRandomWeighed and ExperimentUniqueIdWeighed #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-abtest",
"version": "3.0.1",
"version": "3.0.2",
"description": "A simple React and React Native AB test component.",
"main": "dist/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/ExperimentRandomWeighed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ const ExperimentRandomWeighed = ({ weights, variants, logger }) => {
const totWeight = totalWeight(weights);
const random = randomFloat(0, totWeight);
const variant = getWeighedIndex(weights, random);
const VariantComponent = variant ? variants[variant] : null;
const VariantComponent = variants[variant];

if (VariantComponent && logger && typeof logger === 'function') {
if (logger && typeof logger === 'function') {
logger(variant);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ExperimentUniqueIdWeighed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const ExperimentUniqueIdWeighed = ({ experimentName, uid, weights, variants, log
const hashFloat = parseFloat(`0.${hash}`);
const rangeVal = customRange(hashFloat, 0.0, totWeight);
const variant = getWeighedIndex(weights, rangeVal);
const VariantComponent = variant ? variants[variant] : null;
const VariantComponent = variants[variant];

if (VariantComponent && logger && typeof logger === 'function') {
if (logger && typeof logger === 'function') {
logger(variant);
}

Expand Down
0