mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
fix: ignore metrics for non-existent features (#6945)
This commit is contained in:
parent
8ed15165d2
commit
31ab38e162
@ -22,9 +22,22 @@ export class FeatureLifecycleStore implements IFeatureLifecycleStore {
|
||||
async insert(
|
||||
featureLifecycleStages: FeatureLifecycleStage[],
|
||||
): Promise<void> {
|
||||
const existingFeatures = await this.db('features')
|
||||
.select('name')
|
||||
.whereIn(
|
||||
'name',
|
||||
featureLifecycleStages.map((stage) => stage.feature),
|
||||
);
|
||||
const existingFeaturesSet = new Set(
|
||||
existingFeatures.map((item) => item.name),
|
||||
);
|
||||
const validStages = featureLifecycleStages.filter((stage) =>
|
||||
existingFeaturesSet.has(stage.feature),
|
||||
);
|
||||
|
||||
await this.db('feature_lifecycles')
|
||||
.insert(
|
||||
featureLifecycleStages.map((stage) => ({
|
||||
validStages.map((stage) => ({
|
||||
feature: stage.feature,
|
||||
stage: stage.stage,
|
||||
})),
|
||||
|
@ -87,7 +87,12 @@ test('should return lifecycle stages', async () => {
|
||||
await reachedStage('initial');
|
||||
await expectFeatureStage('initial');
|
||||
eventBus.emit(CLIENT_METRICS, {
|
||||
bucket: { toggles: { my_feature_a: 'irrelevant' } },
|
||||
bucket: {
|
||||
toggles: {
|
||||
my_feature_a: 'irrelevant',
|
||||
non_existent_feature: 'irrelevent',
|
||||
},
|
||||
},
|
||||
environment: 'default',
|
||||
});
|
||||
// missing feature
|
||||
|
Loading…
Reference in New Issue
Block a user