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

Avoid API request for API.getPagesComparisonsDisabledFor on Login pages #20578

Merged
merged 7 commits into from May 4, 2023

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Apr 13, 2023

Description:

While testing another issue I saw that on login pages a request to API.getPagesComparisonsDisabledFor was sent. This is actually unneeded.

Review

@sgiehl sgiehl added the Needs Review PRs that need a code review label Apr 13, 2023
@sgiehl sgiehl added this to the 5.0.0 milestone Apr 13, 2023
@sgiehl sgiehl requested a review from diosmosis April 13, 2023 13:17
Comment on lines 80 to 82
document.addEventListener('DOMContentLoaded', () => {
this.loadComparisonsDisabledFor();
});
Copy link
Member Author

Choose a reason for hiding this comment

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

This change was needed as window.broadcast.isLoginPage() checks if the body element has a certain id. But the javascript might currently already be parsed before the browser starts to render the html, which makes it impossible to look for html elements id.
Not sure if there is a smarter approach for this...

Copy link
Member

Choose a reason for hiding this comment

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

just a thought that came up, but an alternative might be to make Piwik::getLoginPluginName() a global in jsGlobalVariables.twig and check if the URL module == that or 'Login'

@diosmosis
Copy link
Member

haven't tested it, but the code looks fine

@sgiehl sgiehl requested a review from bx80 April 14, 2023 13:40
@github-actions
Copy link
Contributor

This issue is in "needs review" but there has been no activity for 7 days. ping @matomo-org/core-reviewers

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Apr 22, 2023
Copy link
Contributor

@bx80 bx80 left a comment

Choose a reason for hiding this comment

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

This worked well for me when testing, the unnecessary API call is not made when loading the login page 👍

@bx80 bx80 merged commit 3d26a81 into 5.x-dev May 4, 2023
15 of 19 checks passed
@bx80 bx80 deleted the comparisonapi branch May 4, 2023 01:15
@sgiehl sgiehl added c: Performance For when we could improve the performance / speed of Matomo. Regression Indicates a feature used to work in a certain way but it no longer does even though it should. and removed Needs Review PRs that need a code review Stale The label used by the Close Stale Issues action labels May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Performance For when we could improve the performance / speed of Matomo. Regression Indicates a feature used to work in a certain way but it no longer does even though it should.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants