-
Notifications
You must be signed in to change notification settings - Fork 395
[ui-Quick Start-Analytics] Updating the analytics Frontend code by integrating with new public API and using predefined hooks #4126
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
base: master
Are you sure you want to change the base?
Conversation
✅ Test files were modified. Ensure that the tests cover all relevant changes. ✅ |
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 work.
5a620d6
to
8d1d537
Compare
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.
Pull Request Overview
This pull request updates the analytics Frontend by integrating it with a new public API and refactoring the code to use predefined hooks for data loading and saving.
- Updates in test files to use new API endpoints and payload properties.
- Refactoring of the Analytics component to remove local state and use hook-based data management.
- Updates to API utility constants and payload type definitions for consistency with the new API.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
desktop/core/src/desktop/js/apps/admin/Overview/OverviewTab.test.tsx | Updated tests to call new API endpoint and validate payload using analytics_enabled. |
desktop/core/src/desktop/js/apps/admin/Overview/Analytics.tsx | Refactored Analytics component to use useLoadData and useSaveData hooks and wrapped the UI with a loading/error component. |
desktop/core/src/desktop/js/apps/admin/Components/utils.ts | Replaced the old API constant with new API endpoints and defined the payload interface. |
Comments suppressed due to low confidence (2)
desktop/core/src/desktop/js/apps/admin/Overview/Analytics.tsx:87
- Consider normalizing the API response to use a single property for the analytics status to reduce ambiguity in the 'checked' prop. If both properties are needed for backward compatibility, please add a comment explaining the rationale.
checked={usageAnalyticsData?.analyticsEnabled ?? usageAnalyticsData?.analytics_enabled ?? false}
desktop/core/src/desktop/js/apps/admin/Overview/Analytics.tsx:90
- Ensure that 'event.target.checked' reliably returns a boolean as expected by the API; consider adding additional type checking if necessary.
onChange={event => updateAnalyticsPreference({ analytics_enabled: event.target.checked })}
0a58cba
to
915f373
Compare
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.
LGTM
export const INSTALL_APP_EXAMPLES_API_URL = '/api/v1/install_app_examples'; | ||
export const INSTALL_AVAILABLE_EXAMPLES_API_URL = '/api/v1/available_app_examples'; | ||
export const HUE_DOCS_CONFIG_URL = 'https://docs.gethue.com/administrator/configuration/'; | ||
export const GET_USAGE_ANALYTICS_API_URL = '/api/v1/usage_analytics'; |
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.
@Harshg999 Why do we have '/api/v1/usage_analytics/update' end point? If we are going for true restful APIs there would be no need for a specific update url right?
setCollectUsage(newPreference); | ||
saveCollectUsagePreference(newPreference); | ||
const handleAnalyticsCheckboxChange = (checked: boolean) => { | ||
const formData = new FormData(); |
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.
If we are using the new public APIs why are we still sending formData and not json?
save: updateAnalyticsPreference, | ||
loading: updatingAnalyticsPreference, | ||
error: updateAnalyticsPreferenceError | ||
} = useSaveData<{ analytics_enabled: boolean }>(UPDATE_USAGE_ANALYTICS_API_URL, { |
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.
@ramprasadagarwal @ananya-agarwal for useLoadData we get cameCase response but for useSaveData we still get snake_case response, is that correct? And do we have a jira to sync them?
What changes were proposed in this pull request?
Updating the analytics Frontend code by integrating with new public API sent by backend which was updated in the PR:
https://github.com/cloudera/hue/pull/4117/files
How was this patch tested?
The Analytics unit test has also been modified, manual testing
Updated Analytics:
Uploading Screen Recording 2025-06-06 at 3.04.31 PM.mov…
Please review Hue Contributing Guide before opening a pull request.