1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

Fix/show tag events (#3064)

This PR fixes two issues with events today:

1. Feature toggles "Event log" must include all events, regardless of
the project. This is important as feature toggles may move between
2. Add/remove tags on a feature toggle events should include project id
in order to show up in the project specific event log.
This commit is contained in:
Ivar Conradi Østhus 2023-02-08 19:57:21 +01:00 committed by GitHub
parent 5158d04c52
commit 07e8a351bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View File

@ -20,12 +20,7 @@ const FeatureLog = () => {
return (
<StyledContainer>
<EventLog
title="Event log"
project={projectId}
feature={featureId}
displayInline
/>
<EventLog title="Event log" feature={featureId} displayInline />
</StyledContainer>
);
};

View File

@ -1,9 +1,8 @@
import NotFoundError from '../error/notfound-error';
import { Logger } from '../logger';
import { nameSchema } from '../schema/feature-schema';
import { FEATURE_TAGGED, FEATURE_UNTAGGED, TAG_CREATED } from '../types/events';
import { IUnleashConfig } from '../types/option';
import { IUnleashStores } from '../types/stores';
import { IFeatureToggleStore, IUnleashStores } from '../types/stores';
import { tagSchema } from './tag-schema';
import { IFeatureTagStore } from '../types/stores/feature-tag-store';
import { IEventStore } from '../types/stores/event-store';
@ -15,6 +14,8 @@ class FeatureTagService {
private featureTagStore: IFeatureTagStore;
private featureToggleStore: IFeatureToggleStore;
private eventStore: IEventStore;
private logger: Logger;
@ -24,12 +25,17 @@ class FeatureTagService {
tagStore,
featureTagStore,
eventStore,
}: Pick<IUnleashStores, 'tagStore' | 'featureTagStore' | 'eventStore'>,
featureToggleStore,
}: Pick<
IUnleashStores,
'tagStore' | 'featureTagStore' | 'eventStore' | 'featureToggleStore'
>,
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
) {
this.logger = getLogger('/services/feature-tag-service.ts');
this.tagStore = tagStore;
this.featureTagStore = featureTagStore;
this.featureToggleStore = featureToggleStore;
this.eventStore = eventStore;
}
@ -43,7 +49,7 @@ class FeatureTagService {
tag: ITag,
userName: string,
): Promise<ITag> {
await nameSchema.validateAsync({ name: featureName });
const featureToggle = await this.featureToggleStore.get(featureName);
const validatedTag = await tagSchema.validateAsync(tag);
await this.createTagIfNeeded(validatedTag, userName);
await this.featureTagStore.tagFeature(featureName, validatedTag);
@ -52,6 +58,7 @@ class FeatureTagService {
type: FEATURE_TAGGED,
createdBy: userName,
featureName,
project: featureToggle.project,
data: validatedTag,
});
return validatedTag;
@ -78,11 +85,13 @@ class FeatureTagService {
tag: ITag,
userName: string,
): Promise<void> {
const featureToggle = await this.featureToggleStore.get(featureName);
await this.featureTagStore.untagFeature(featureName, tag);
await this.eventStore.store({
type: FEATURE_UNTAGGED,
createdBy: userName,
featureName,
project: featureToggle.project,
data: tag,
});
}