mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: playground result count buckets (#8555)
This commit is contained in:
		
							parent
							
								
									eaab9db60d
								
							
						
					
					
						commit
						e666f90e1e
					
				| @ -30,7 +30,7 @@ import type { | |||||||
| import { capitalizeFirst } from 'utils/capitalizeFirst'; | import { capitalizeFirst } from 'utils/capitalizeFirst'; | ||||||
| import { AdvancedPlaygroundEnvironmentDiffCell } from './AdvancedPlaygroundEnvironmentCell/AdvancedPlaygroundEnvironmentDiffCell'; | import { AdvancedPlaygroundEnvironmentDiffCell } from './AdvancedPlaygroundEnvironmentCell/AdvancedPlaygroundEnvironmentDiffCell'; | ||||||
| import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; | import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; | ||||||
| import { countCombinations } from './combinationCounter'; | import { countCombinations, getBucket } from './combinationCounter'; | ||||||
| 
 | 
 | ||||||
| const defaultSort: SortingRule<string> = { id: 'name' }; | const defaultSort: SortingRule<string> = { id: 'name' }; | ||||||
| const { value, setValue } = createLocalStorage( | const { value, setValue } = createLocalStorage( | ||||||
| @ -54,7 +54,7 @@ export const AdvancedPlaygroundResultsTable = ({ | |||||||
|         trackEvent('playground', { |         trackEvent('playground', { | ||||||
|             props: { |             props: { | ||||||
|                 eventType: 'number-of-combinations', |                 eventType: 'number-of-combinations', | ||||||
|                 count: countCombinations(features), |                 count: getBucket(countCombinations(features)), | ||||||
|             }, |             }, | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import { countCombinations } from './combinationCounter'; | import { countCombinations, getBucket } from './combinationCounter'; | ||||||
| import type { | import type { | ||||||
|     AdvancedPlaygroundEnvironmentFeatureSchema, |     AdvancedPlaygroundEnvironmentFeatureSchema, | ||||||
|     AdvancedPlaygroundFeatureSchema, |     AdvancedPlaygroundFeatureSchema, | ||||||
| @ -95,3 +95,12 @@ it('counts the correct number of combinations', () => { | |||||||
|     }); |     }); | ||||||
|     assertCount(5, ['development'], { x: ['1', '2'] }); |     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+'); | ||||||
|  | }); | ||||||
|  | |||||||
| @ -11,3 +11,20 @@ export const countCombinations = ( | |||||||
|             ).length, |             ).length, | ||||||
|         0, |         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'; | ||||||
|  |     } | ||||||
|  | }; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user