Skip to content

Commit

Permalink
fix: include tags in variants event (#4711)
Browse files Browse the repository at this point in the history
https://linear.app/unleash/issue/2-1396/fix-variants-event-should-include-the-respective-feature-flag-tags

This fixes an issue where the `feature-environment-variants-updated`
event would not post to a tagged Slack channel, since it would not take
into consideration the feature flag tags.
  • Loading branch information
nunogois committed Sep 15, 2023
1 parent 14fa908 commit 523cf87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/lib/services/feature-toggle-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,8 @@ class FeatureToggleService {
).variants ||
[];

const tags = await this.tagStore.getAllTagsForFeature(featureName);

await this.eventStore.store(
new EnvironmentVariantEvent({
featureName,
Expand All @@ -1883,6 +1885,7 @@ class FeatureToggleService {
createdBy: user,
oldVariants: theOldVariants,
newVariants: fixedVariants,
tags,
}),
);
await this.featureEnvironmentStore.setVariantsToFeatureEnvironments(
Expand Down Expand Up @@ -1948,6 +1951,9 @@ class FeatureToggleService {
});
oldVariants[env] = featureEnv.variants || [];
}

const tags = await this.tagStore.getAllTagsForFeature(featureName);

await this.eventStore.batchStore(
environments.map(
(environment) =>
Expand All @@ -1958,6 +1964,7 @@ class FeatureToggleService {
createdBy: user,
oldVariants: oldVariants[environment],
newVariants: fixedVariants,
tags,
}),
),
);
Expand Down
3 changes: 2 additions & 1 deletion src/lib/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,11 @@ export class EnvironmentVariantEvent extends BaseEvent {
environment: string;
project: string;
createdBy: string | IUser;
tags: ITag[];
newVariants: IVariant[];
oldVariants: IVariant[];
}) {
super(FEATURE_ENVIRONMENT_VARIANTS_UPDATED, p.createdBy);
super(FEATURE_ENVIRONMENT_VARIANTS_UPDATED, p.createdBy, p.tags);
this.featureName = p.featureName;
this.environment = p.environment;
this.project = p.project;
Expand Down

0 comments on commit 523cf87

Please sign in to comment.