Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: feature flag playground features in new store #5013

Merged
merged 6 commits into from
Oct 16, 2023

Conversation

FredrikOseberg
Copy link
Contributor

Have playground use the method in the feature-toggle-service instead of asking the client-feature-toggle-store

@vercel
Copy link

vercel bot commented Oct 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 10:27am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Oct 16, 2023 10:27am

if (this.flagResolver.isEnabled('separateAdminClientApi')) {
result = (await this.getFeatureToggles(
query,
)) as IFeatureToggleClient[];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will clean this up when we remove the feature flag

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we do one query or the other? Here we're fetching getPlayground first and then override it with another query

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we wanted to optimise this maximally, we could do that. But since this is the admin API and this feature flag should be removed asap to avoid holding all this context, I think it's fine.

@kwasniew kwasniew self-requested a review October 13, 2023 06:54
Copy link
Contributor

@kwasniew kwasniew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe run both in parallel (Promise.all) and console.warn when the results are different. Then we'll have extra value from those 2 queries.

Comment on lines +147 to +165
export const buildPlaygroundFeaturesFromRows = (
rows: any[],
dependentFeaturesEnabled: boolean,
featureQuery?: IFeatureToggleQuery,
): FeatureConfigurationClient[] => {
let result = rows.reduce((acc, r) => {
const feature: PartialDeep<IFeatureToggleClient> = acc[r.name] ?? {
strategies: [],
};
if (isUnseenStrategyRow(feature, r) && !r.strategy_disabled) {
feature.strategies?.push(rowToStrategy(r));
}
if (isNewTag(feature, r)) {
addTag(feature, r);
}
if (featureQuery?.inlineSegmentConstraints && r.segment_id) {
addSegmentToStrategy(feature, r);
} else if (!featureQuery?.inlineSegmentConstraints && r.segment_id) {
addSegmentIdsToStrategy(feature, r);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will clean up this duplication in a follow-up PR

@@ -36,6 +37,10 @@ export interface IFeatureToggleStore extends Store<FeatureToggle, string> {
userId?: number,
archived?: boolean,
): Promise<FeatureToggle[]>;
getPlaygroundFeatures(
dependentFeaturesEnabled: boolean,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we passing it as args instead of passing flag in a constructor as we did before in the previous client store?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to introduce it in the feature toggle store, because the feature toggle store does not currently receive the config. I decided to go this route for now, since I expect the feature flag to be removed shortly.

valueB: any;
}

export function deepDiff(arr1: any[], arr2: any[]): Difference[] | null {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this function in the old code. Is it new?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it have tests? what's the advantage over using lodash isEqual?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have noted that I plan to follow up with some more test coverage in the next PR. The advantage is that it will actually list the two objects that differ, so that you can see what is the difference instead of just getting a boolean value.

@FredrikOseberg FredrikOseberg merged commit b58d900 into main Oct 16, 2023
8 of 14 checks passed
@FredrikOseberg FredrikOseberg deleted the refactor/move-playground branch October 16, 2023 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants