Skip to content

Commit 7c385b9

Browse files
committed
feat: remove cwvInterpolationFN, simpleCWVInterploationFN, and INTERPOLATION_THRESHOLD from utils
1 parent ddba71d commit 7c385b9

File tree

2 files changed

+0
-38
lines changed

2 files changed

+0
-38
lines changed

index.js

-6
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ import {
3535
reclassifyAcquisition,
3636
reclassifyEnter,
3737
addCalculatedProps,
38-
cwvInterpolationFn,
39-
simpleCWVInterpolationFn,
40-
INTERPOLATION_THRESHOLD,
4138
} from './utils.js';
4239

4340
const utils = {
@@ -51,9 +48,6 @@ const utils = {
5148
reclassifyAcquisition,
5249
reclassifyEnter,
5350
addCalculatedProps,
54-
cwvInterpolationFn,
55-
simpleCWVInterpolationFn,
56-
INTERPOLATION_THRESHOLD,
5751
};
5852
const stats = {
5953
zTestTwoProportions,

utils.js

-32
Original file line numberDiff line numberDiff line change
@@ -172,38 +172,6 @@ export function scoreBundle(bundle) {
172172
return 'poor';
173173
}
174174

175-
export const INTERPOLATION_THRESHOLD = 10;
176-
177-
export function simpleCWVInterpolationFn(metric, threshold) {
178-
return (cwvs) => {
179-
const valuedWeights = Object.values(cwvs)
180-
.filter((value) => value.weight !== undefined)
181-
.map((value) => value.weight)
182-
.reduce((acc, value) => acc + value, 0);
183-
return cwvs[threshold + metric].weight / valuedWeights;
184-
};
185-
}
186-
export function cwvInterpolationFn(targetMetric) {
187-
return (cwvs) => {
188-
const valueCount = cwvs.goodCWV.count + cwvs.niCWV.count + cwvs.poorCWV.count;
189-
const valuedWeights = cwvs.goodCWV.weight + cwvs.niCWV.weight + cwvs.poorCWV.weight;
190-
191-
if (valueCount < INTERPOLATION_THRESHOLD) {
192-
// not enough data to interpolate
193-
return 0;
194-
}
195-
// total weight
196-
const totalWeight = cwvs.goodCWV.weight
197-
+ cwvs.niCWV.weight
198-
+ cwvs.poorCWV.weight
199-
+ cwvs.noCWV.weight;
200-
// share of targetMetric compared to all CWV
201-
const share = cwvs[targetMetric].weight / (valuedWeights);
202-
// interpolate the share to the total weight
203-
return Math.round(share * totalWeight);
204-
};
205-
}
206-
207175
/**
208176
* Conversion rates are computed as the ratio of conversions to visits. The conversion rate is
209177
* capped at 100%.

0 commit comments

Comments
 (0)