[Feature Request]: Add Views to documents #114
Replies: 1 comment 1 reply
-
Hey @kyledoesdev, thanks for the feature request. I like the idea of integrating some kind of analytics into Prezet. One challenge is that the prezet database connection is somewhat ephemeral. Every time prezet indexes new content it wipes out the database and reloads everything from the markdown files. I see that you may have already solved for that by using a separate connection to store the DocumentView, I just don't know how I would integrate that into prezet right now. The other issue is I mainly serve my prezet blogs from an edge cache. You can see the documentation for that here: https://prezet.com/deployment/cloudflare. In that kind of setup only the first request would get logged to the DocumentView table. So you'd have to send something from javascript to properly track views. |
Beta Was this translation helpful? Give feedback.
-
What happened?
Hey, I am adding this feature request here. I believe it will add it labeled bug but this is not a bug. I wanted to to start a discussion about adding views to documents. This is something I did in my own project I am using prezet in and I think it would be a cool addition.
In my own system I added a document_views table with a reference to the prezet document id & user ip address to keep track of users who read the document. (My app does not have authenticated users). I then queried and did some collection work to fetch the documents & views together. I use this data in an admin dashboard that lists every document and some of the frontmatter about each & plan to add it to the document show page,
I overrode the ShowController and just updateOrCreate a document view before returning the view.
I think this could be a great addition. I debated trying to write a PR myself, but didn't know how you would want to handle user view tracking or even track it at all. I did not know if it is possible to, based off of a new config setting, dictate how to store views or disable them entirely. For example:
Then based off of the setting dictated here the system would count and track views based off of the selection.
I apologize if requesting this feature here is an inappropriate manor of communication. There are no discussions set up or a feature request issue option when creating a bug.
If this is something that you think is outside of the scope of prezet's core offering I completely understand. I am entirely satisfied with my current implementation. It works! I attached some of the code below if anyone was interested.
How to reproduce the bug
There is nothing to reproduce here.
Package Version
0.20.1
PHP Version
8.3
Laravel Version
11.35
Which operating systems does with happen with?
No response
Notes
No response
Beta Was this translation helpful? Give feedback.
All reactions