* Ensuring we don't track views of author or unpublished
Prior to this commit, I was surprised to learn that we:
1) Tracked an author's view of their article.
2) Tracked views of an unpublished article.
This came up from a Forem creator asking if they could reset the view
counter. Or trigger the reset on publication.
I think a general business logic policy of don't track views for the
author and don't track views for unpublished articles is a reasonable
default.
Were we to pursue the clear views on publication, we'd need to consider
something that went from unpublished -> published -> unpublished ->
published. Without a more explicit state machine, triggering a
busineiss logic behavior seems a bit unexpected.
In other words, I wrote an article. There are 20 views when I realize
that I need to unpublished it. I make the changes in the unpublished
state, and re-publish. I'd assume that those 20 views would still be
"recorded" and counted towards my article's view counts.
* Adjusting condition structure
Prior to this commit, the `if` clause was rather far to the right. This
helps make the if clause more pronounced.
* Adding documentation and constant
This loosely relates to a request for information from Success team
about whether or not viewing a draft article counts towards it's stats.
* Apply suggestions from code review
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Extract page view updates into workers
* Restructure code
* Update specs
* Fix and reactive 2 specs
* Update according to PR feedback
* Use create! over create
* Replace current_user.id with efficient_current_user_id in high-leverage areas
* Update name of efficient_current_user_id
* Replace user_signed_in? in pageviews
* Remove unneeded ?
* Reorganize PageViewsController
* Add domain and path to PageView model
* Add before_create callback to populate domain and path
* Add list of referrers to AnalyticsService
* Add referrers to the UI
* Remove useless referrers card and tweak table line height
* Add referrer stats to article stats page
* Add not null and empty default to domain and path
* Refactor JS analytics client
* create_list is a step back here
* Revert "Add not null and empty default to domain and path"
This reverts commit bc02440076047a887c65d300bccd4661ecc8ffd0.
* Add index on domain concurrently
* Make the script more robust