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

feat: log warning if there is diff between client/features and delta api #9047

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,9 @@ export default class FeatureController extends Controller {
a.name.localeCompare(b.name),
);

const deepEqualIgnoreOrder = (obj1, obj2) => {
const sortedObj1 = JSON.parse(
JSON.stringify(obj1, Object.keys(obj1).sort()),
);
const sortedObj2 = JSON.parse(
JSON.stringify(obj2, Object.keys(obj2).sort()),
);
return isEqual(sortedObj1, sortedObj2);
};

if (!deepEqualIgnoreOrder(sortedToggles, sortedNewToggles)) {
if (
!this.deepEqualIgnoreOrder(sortedToggles, sortedNewToggles)
) {
this.logger.warn(
`old features and new features are different. Old count ${
features.length
Expand Down Expand Up @@ -407,4 +399,14 @@ export default class FeatureController extends Controller {
const jsonString = JSON.stringify(value);
return Buffer.byteLength(jsonString, 'utf8');
}

deepEqualIgnoreOrder = (obj1, obj2) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

types seem to be missing here and this function doesn't need to be attached to class

const sortedObj1 = JSON.parse(
JSON.stringify(obj1, Object.keys(obj1).sort()),
);
const sortedObj2 = JSON.parse(
JSON.stringify(obj2, Object.keys(obj2).sort()),
);
return isEqual(sortedObj1, sortedObj2);
};
}
Loading