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 ( return (
<StyledContainer> <StyledContainer>
<EventLog <EventLog title="Event log" feature={featureId} displayInline />
title="Event log"
project={projectId}
feature={featureId}
displayInline
/>
</StyledContainer> </StyledContainer>
); );
}; };

View File

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