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

Track pageviews for custom pages #20879

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

PhilipHow
Copy link
Contributor

@PhilipHow PhilipHow commented Apr 22, 2024

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Adds page_id to PageViews and tracks page views when a user visits a page.

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Please replace this line with instructions on how to test your changes, a note
on the devices and browsers this has been tested on, as well as any relevant
images for UI changes.

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above.

  • Yes
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

alt_text

app/controllers/page_views_controller.rb Outdated Show resolved Hide resolved
app/controllers/page_views_controller.rb Outdated Show resolved Hide resolved
app/workers/articles/update_page_views_worker.rb Outdated Show resolved Hide resolved
app/workers/articles/update_page_views_worker.rb Outdated Show resolved Hide resolved
spec/models/page_view_spec.rb Outdated Show resolved Hide resolved
spec/models/page_view_spec.rb Outdated Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Apr 22, 2024

Uffizzi Ephemeral Environment Deploying

☁️ https://app.uffizzi.com/github.com/forem/forem/pull/20879

⚙️ Updating now by workflow run 9019123388.

What is Uffizzi? Learn more!

@PhilipHow PhilipHow changed the title [WIP] Track pageviews for custom pages Track pageviews for custom pages Apr 23, 2024
@PhilipHow PhilipHow marked this pull request as ready for review April 23, 2024 15:20
@PhilipHow PhilipHow requested review from a team as code owners April 23, 2024 15:20
@PhilipHow PhilipHow requested review from maestromac and lightalloy and removed request for a team April 23, 2024 15:20
@PhilipHow PhilipHow marked this pull request as draft April 23, 2024 15:21
@PhilipHow PhilipHow marked this pull request as ready for review April 24, 2024 16:01
@PhilipHow PhilipHow requested review from benhalpern and removed request for lightalloy April 24, 2024 16:01
Comment on lines +1 to +7
class AddPageToPageViews < ActiveRecord::Migration[7.0]
disable_ddl_transaction!

def change
add_reference :page_views, :page, null: true, index: {algorithm: :concurrently}
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little bit conflicted on this. The ideal way to go about this is to make a polymorphic association/model that will then allow any model to be in relation with PageView but I can see this to be a quick way to get this feature implemented first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I discussed this with @benhalpern. Data migration was the main concern with a polymorphic approach.

Are there any ways of sidestepping this issue if we went down a polymorphic approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think this has to be the first take on this as the path forward

app/controllers/page_views_controller.rb Outdated Show resolved Hide resolved
app/javascript/packs/baseTracking.js Outdated Show resolved Hide resolved
app/models/page_view.rb Show resolved Hide resolved
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.

Track pageviews for custom pages
3 participants