analytics-client
Advanced tools
Comparing version 0.4.0-roman-experiments-9029e90b17983103aeebb91839da200f0b0de4ba to 0.4.0-roman-experiments-96b5b020f19f06ac1b7313fa3077178b7895a211
@@ -11,2 +11,6 @@ # Change Log | ||
## 0.3.1 - 2020-03-18 | ||
* Bump balena linter [Roman Mazur] | ||
## 0.3.0 - 2020-03-17 | ||
@@ -13,0 +17,0 @@ |
@@ -12,3 +12,2 @@ import { Client } from './client'; | ||
constructor(name: string, analytics?: Client | undefined); | ||
private static checkPercent; | ||
private checkDuplicates; | ||
@@ -15,0 +14,0 @@ private static dataString; |
@@ -5,2 +5,7 @@ "use strict"; | ||
var LOCAL_STORAGE_EXPERIMENTS_PREFIX = '__analytics_experiments_'; | ||
var checkPercent = function (f) { | ||
if (isNaN(f) || f < 0 || f > 100) { | ||
throw new Error('Variation target percent must be defined as a percent value between 0 and 100'); | ||
} | ||
}; | ||
var LocalExperiment = (function () { | ||
@@ -13,7 +18,2 @@ function LocalExperiment(name, analytics) { | ||
} | ||
LocalExperiment.checkPercent = function (f) { | ||
if (isNaN(f) || f < 0 || f > 100) { | ||
throw new Error('Variation fraction must be defines as a percent value between 0 and 100'); | ||
} | ||
}; | ||
LocalExperiment.prototype.checkDuplicates = function (variation) { | ||
@@ -31,3 +31,3 @@ var present = this.data.find(function (d) { return d.variation === variation; }); | ||
LocalExperiment.prototype.define = function (variation, targetPercent) { | ||
LocalExperiment.checkPercent(targetPercent); | ||
checkPercent(targetPercent); | ||
this.checkDuplicates(variation); | ||
@@ -34,0 +34,0 @@ var varData = { variation: variation, targetPercent: targetPercent }; |
{ | ||
"name": "analytics-client", | ||
"version": "0.4.0-roman-experiments-9029e90b17983103aeebb91839da200f0b0de4ba", | ||
"version": "0.4.0-roman-experiments-96b5b020f19f06ac1b7313fa3077178b7895a211", | ||
"description": "Convenient builders to compose analytics tools", | ||
@@ -14,4 +14,4 @@ "repository": { | ||
"test": "jest", | ||
"prettify": "resin-lint --typescript --fix src/ test/ index.ts", | ||
"lint": "resin-lint --typescript src/ test/ index.ts && tsc --noEmit", | ||
"prettify": "balena-lint --typescript --fix src/ test/ index.ts", | ||
"lint": "balena-lint --typescript src/ test/ index.ts && tsc --noEmit", | ||
"build": "npm run lint && npm run test && tsc && webpack", | ||
@@ -26,2 +26,3 @@ "prepublish": "npm run build" | ||
"devDependencies": { | ||
"@balena/lint": "^4.0.1", | ||
"@types/jest": "^24.0.18", | ||
@@ -35,3 +36,2 @@ "@types/js-cookie": "^2.2.5", | ||
"mixpanel-browser": "^2.29.1", | ||
"resin-lint": "^3.3.1", | ||
"ts-jest": "^24.1.0", | ||
@@ -45,6 +45,6 @@ "ts-loader": "^6.2.0", | ||
"*.ts": [ | ||
"resin-lint --typescript --fix" | ||
"balena-lint --typescript --fix" | ||
], | ||
"test/**/*.ts": [ | ||
"resin-lint --typescript --no-prettier --tests" | ||
"balena-lint --typescript --no-prettier --tests" | ||
] | ||
@@ -51,0 +51,0 @@ }, |
@@ -17,2 +17,10 @@ import { Identify } from 'amplitude-js'; | ||
const checkPercent = (f: number) => { | ||
if (isNaN(f) || f < 0 || f > 100) { | ||
throw new Error( | ||
'Variation target percent must be defined as a percent value between 0 and 100', | ||
); | ||
} | ||
}; | ||
/** LocalExperiment allows describing an Experiment implemented with local storage. */ | ||
@@ -29,10 +37,2 @@ export class LocalExperiment<Variation extends string> | ||
private static checkPercent(f: number) { | ||
if (isNaN(f) || f < 0 || f > 100) { | ||
throw new Error( | ||
'Variation fraction must be defines as a percent value between 0 and 100', | ||
); | ||
} | ||
} | ||
private checkDuplicates(variation: Variation) { | ||
@@ -57,3 +57,3 @@ const present = this.data.find(d => d.variation === variation); | ||
): LocalExperiment<Variation> { | ||
LocalExperiment.checkPercent(targetPercent); | ||
checkPercent(targetPercent); | ||
this.checkDuplicates(variation); | ||
@@ -60,0 +60,0 @@ const varData = { variation, targetPercent }; |
Sorry, the diff of this file is too big to display
221218
1367