-
Notifications
You must be signed in to change notification settings - Fork 23
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: [DHIS2-12544] Add verbose logging to rules engine #3480
feat: [DHIS2-12544] Add verbose logging to rules engine #3480
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @eirikhaugstulen,
Can you add some unit tests for the new flag
logic you added in RulesEngine.js and runExpression.js? Ideally, we should aim to keep the same coverage percentage and test all new features.
Thank you!
Sure thing, @simonadomnisoru! Thanks for pointing that out 👍 |
🚀 Deployed on https://deploy-preview-3480--dhis2-capture.netlify.app |
src/components/App/App.component.js
Outdated
</React.Fragment> | ||
); | ||
export const App = ({ store }: Props) => { | ||
useRuleEngineFlags(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, this will cause the App component to re-render every time the url changes. Consequently, all children will render unless we have a PureComponent
in the chain. I think it would be beneficial to use a PureComponent
as the child where we use this hook (For a function component: Wrap it in a Memo
).
useEffect(() => { | ||
if (verbose === 'true') { | ||
updateFlags({ verbose: true }); | ||
} else { | ||
updateFlags({ verbose: false }); | ||
} | ||
}, [verbose]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this approach we can in theory run the rules engine before the verbose flag has been set, because an useEffect
in an inner component will run before this one (in practice it will probably work because we use async functions). Did you put this in an useEffect because side-effects should not be part of the rendering, or because some part of react-router-dom is not fully initialised in the render? The preferred solution here might be to use useLayoutEffect
(as that one is fired before useLayout
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No special thoughts behind it, just choosing useEffect over useLayoutEffect by default. Switched now 👍
…Engine' into eh/feat/DHIS2-12544_VerboseRulesEngine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested successfully on 2.41,2.40.3,2.39.5,2.38.6 versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Nice!
# [100.49.0](v100.48.0...v100.49.0) (2023-12-18) ### Features * [DHIS2-12544] Add verbose logging to rules engine ([#3480](#3480)) ([2a6d4a8](2a6d4a8))
🎉 This PR is included in version 100.49.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Tech-summary:
verbose=true
in the urlonVerboseLog
callback to the rules engineRulesEngine.js
-class