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(
|
async insert(
|
||||||
featureLifecycleStages: FeatureLifecycleStage[],
|
featureLifecycleStages: FeatureLifecycleStage[],
|
||||||
): Promise<void> {
|
): 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')
|
await this.db('feature_lifecycles')
|
||||||
.insert(
|
.insert(
|
||||||
featureLifecycleStages.map((stage) => ({
|
validStages.map((stage) => ({
|
||||||
feature: stage.feature,
|
feature: stage.feature,
|
||||||
stage: stage.stage,
|
stage: stage.stage,
|
||||||
})),
|
})),
|
||||||
|
@ -87,7 +87,12 @@ test('should return lifecycle stages', async () => {
|
|||||||
await reachedStage('initial');
|
await reachedStage('initial');
|
||||||
await expectFeatureStage('initial');
|
await expectFeatureStage('initial');
|
||||||
eventBus.emit(CLIENT_METRICS, {
|
eventBus.emit(CLIENT_METRICS, {
|
||||||
bucket: { toggles: { my_feature_a: 'irrelevant' } },
|
bucket: {
|
||||||
|
toggles: {
|
||||||
|
my_feature_a: 'irrelevant',
|
||||||
|
non_existent_feature: 'irrelevent',
|
||||||
|
},
|
||||||
|
},
|
||||||
environment: 'default',
|
environment: 'default',
|
||||||
});
|
});
|
||||||
// missing feature
|
// missing feature
|
||||||
|
Loading…
Reference in New Issue
Block a user