Skip to content

Commit

Permalink
Fix/show tag events (#3064)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ivarconr committed Feb 8, 2023
1 parent 5158d04 commit 07e8a35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Expand Up @@ -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>
);
};
Expand Down
17 changes: 13 additions & 4 deletions src/lib/services/feature-tag-service.ts
@@ -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';
Expand All @@ -15,6 +14,8 @@ class FeatureTagService {

private featureTagStore: IFeatureTagStore;

private featureToggleStore: IFeatureToggleStore;

private eventStore: IEventStore;

private logger: Logger;
Expand All @@ -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;
}

Expand All @@ -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);
Expand All @@ -52,6 +58,7 @@ class FeatureTagService {
type: FEATURE_TAGGED,
createdBy: userName,
featureName,
project: featureToggle.project,
data: validatedTag,
});
return validatedTag;
Expand All @@ -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,
});
}
Expand Down

0 comments on commit 07e8a35

Please sign in to comment.