1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

feat: playground result count buckets (#8555)

This commit is contained in:
Mateusz Kwasniewski 2024-10-28 15:43:07 +01:00 committed by GitHub
parent eaab9db60d
commit e666f90e1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 3 deletions

View File

@ -30,7 +30,7 @@ import type {
import { capitalizeFirst } from 'utils/capitalizeFirst';
import { AdvancedPlaygroundEnvironmentDiffCell } from './AdvancedPlaygroundEnvironmentCell/AdvancedPlaygroundEnvironmentDiffCell';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import { countCombinations } from './combinationCounter';
import { countCombinations, getBucket } from './combinationCounter';
const defaultSort: SortingRule<string> = { id: 'name' };
const { value, setValue } = createLocalStorage(
@ -54,7 +54,7 @@ export const AdvancedPlaygroundResultsTable = ({
trackEvent('playground', {
props: {
eventType: 'number-of-combinations',
count: countCombinations(features),
count: getBucket(countCombinations(features)),
},
});
}

View File

@ -1,4 +1,4 @@
import { countCombinations } from './combinationCounter';
import { countCombinations, getBucket } from './combinationCounter';
import type {
AdvancedPlaygroundEnvironmentFeatureSchema,
AdvancedPlaygroundFeatureSchema,
@ -95,3 +95,12 @@ it('counts the correct number of combinations', () => {
});
assertCount(5, ['development'], { x: ['1', '2'] });
});
it('assigns bucket', () => {
expect(getBucket(-1)).toBe('invalid bucket');
expect(getBucket(0)).toBe('0-100');
expect(getBucket(100)).toBe('100-1000');
expect(getBucket(1000)).toBe('1000-10000');
expect(getBucket(10000)).toBe('10000-20000');
expect(getBucket(20000)).toBe('20000+');
});

View File

@ -11,3 +11,20 @@ export const countCombinations = (
).length,
0,
);
export const getBucket = (value: number): string => {
if (value < 0) {
return 'invalid bucket';
}
if (value >= 20000) {
return '20000+';
} else if (value >= 10000) {
return '10000-20000';
} else if (value >= 1000) {
return '1000-10000';
} else if (value >= 100) {
return '100-1000';
} else {
return '0-100';
}
};