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

Analytics: move page views to its own endpoint #7739

Merged
merged 2 commits into from
Dec 10, 2020
Merged

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Dec 9, 2020

This allow us to cache the footer response and keep receiving page
views.

I have removed the analytics signals, since they were only used for this purpose, there are other PRs in -ext and -corp to follow this change.

This allow us to cache the footer response and keep receiving page
views.
@stsewd stsewd requested a review from a team December 9, 2020 18:34
@stsewd stsewd mentioned this pull request Dec 9, 2020
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

Looks good to me!

readthedocs/analytics/proxied_api.py Show resolved Hide resolved
Comment on lines -246 to -255
# Allow folks to hook onto the footer response for various information
# collection, or to modify the resp_data.
footer_response.send(
sender=None,
request=request,
context=context,
response_data=resp_data,
absolute_uri=self.request.GET.get('absolute_uri'),
)

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we keep sending this signal here?

We were only using it for pageviews here, but it could be useful for other things as well. Besides, it may have an impact downstream.

Copy link
Member Author

@stsewd stsewd Dec 10, 2020

Choose a reason for hiding this comment

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

Don't think this is useful, it also hides additional queries. The class can be extended already with OverrideSettginsObject, that's better than using signals for this case.

@readthedocs/core thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

My only worry is about custom installs that might be using it, but I don't expect it to be heavily used there. We plan to cache it in prod, but not all users will necessarily do that. I think I'm OK removing it, and we can re-add it if someone yells :)

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

This looks great. I think we should extend this code to include more data, but given that it's just a refactor I think this is great.

readthedocs/analytics/proxied_api.py Outdated Show resolved Hide resolved
permission_classes = [IsAuthorizedToViewVersion]

def _get_project(self):
cache_key = '__cached_project'
Copy link
Member

Choose a reason for hiding this comment

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

We have this code in a few places now, we should probably move it to a mixin.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do another PR with that

Comment on lines -246 to -255
# Allow folks to hook onto the footer response for various information
# collection, or to modify the resp_data.
footer_response.send(
sender=None,
request=request,
context=context,
response_data=resp_data,
absolute_uri=self.request.GET.get('absolute_uri'),
)

Copy link
Member

Choose a reason for hiding this comment

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

My only worry is about custom installs that might be using it, but I don't expect it to be heavily used there. We plan to cache it in prod, but not all users will necessarily do that. I think I'm OK removing it, and we can re-add it if someone yells :)

@@ -427,7 +427,7 @@ def test_highest_version_without_tags(self):
class TestFooterPerformance(TestCase):
# The expected number of queries for generating the footer
# This shouldn't increase unless we modify the footer API
EXPECTED_QUERIES = 18
EXPECTED_QUERIES = 14
Copy link
Member

Choose a reason for hiding this comment

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

❤️

@stsewd stsewd merged commit 702f9a3 into master Dec 10, 2020
@stsewd stsewd deleted the move-analytics branch December 10, 2020 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants