-
Notifications
You must be signed in to change notification settings - Fork 218
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
Implement analytics in Nuxt #844
Conversation
Full-stack documentation: Ready https://WordPress.github.io/openverse/_preview/844 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. |
Co-authored-by: Zack Krida <zackkrida@pm.me>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial feedback. Forgive me if I am missing something that invalidates my recommendation. This is exciting work and I don't want to delay it. I believe my recommendations (if valid) make the PR get in faster because I think they would massively reduce the amount of code required to implement the baseline for event tracking.
Gotcha, sorry about that. I misunderstood what we discussed in the Plausible RFC issue and thought you'd wanted me to share feedback here, folding in what I'd pointed out in the RFC. Apologies for moving too quickly. The summarised changes you shared here look great, I'll review the code today, but I'm sure it's great. One potential improvement is that we can use Nginx for the redirect, and it could be better performance wise to not tie up the event loop with those redirects, even if they're fast. Just something to note if we notice any degradation in performance, considering these requests happen for every new client page load. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great other than the question regarding the proxy configuration 🙂
@sarayourfriend I am really thankful and appreciative that you reviewed it as quickly and as thoroughly as you did. |
Plausible does not prevent us from sending events to it even if the site does not exist. So we could technically let the staging server keep sending info to Plausible that would be discarded by them. When we do need to track events, we can register the staging site on our Plausible cloud account, do the tracking we need to do, and then delete the site (and associated data) thus stopping tracking again. Also the feature flag for analytics would be switched off in staging during which no events will be sent to Plausible. $ curl --location 'https://plausible.io/api/event' \
--header 'Content-Type: application/json' \
--data '{
"n": "pageview",
"u": "https://staging.openverse.org/",
"d": "staging.openverse.org",
"r": "https://staging.openverse.org/",
"w": 999,
"h": 2
}'
ok
$ curl --location 'https://plausible.io/api/event' \
--header 'Content-Type: application/json' \
--data '{
"n": "CUSTOM_EVENT",
"u": "https://staging.openverse.org/",
"d": "staging.openverse.org",
"r": "https://staging.openverse.org/",
"p": "{\"key\":\"value\"}",
"w": 999,
"h": 2
}'
ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this locally, and it looks good to me. Everything works, following the testing instructions. Plausible's UI is simple but easy to use.
I noticed two three things as I was playing around with Plausible and the custom events. None of these are blocking issues and should be addressed in follow-up issues or clarified in documentation whether they're expected behaviour.
- The "entry" pages appears to be tied to a specific user/session. If a person reloads a page, it doesn't think of it as a new "entry" and so does not fully capture every server rendered page.
- The width and height props on custom events are going to be interesting to use and I wonder if there are other ways of encoding the data, perhaps as an additional prop (breakpoint, for width, like we do with the UI state cookie?). It currently gives a separate bar graph for every single instance of every single width, so at a glance, at least from the Plausible UI, it's basically useless. We can transform this ourselves once we're analysing the data in our own pipelines, but if we're doing anything "at a glance" with these, we'll want to consider encoding ranges as a separate prop to make it easier for a human to understand.
- To test things on localhost, you must visit with "localhost" as the domain. You cannot do what I tried to do (for far too long before I realised what was happening) and visit the site on another device on your local network at the LAN IP. We'd need to set up some kind of expected hosts file configuration for being able to test on multiple devices like
openverse.local
so that other devices can have the correct referrer on the request to Plausible. This is worth clarifying in the documentation (along with any other limitations we might be aware of in testing) and opening an issue to explore ways of fixing it that won't intrude on the average use case.
Anyway, like I said, none of these are blockers or should be addressed in this PR. This PR is good to go from my perspective and I'm exciting to start getting to use this!
Size Change: +3.64 kB (0%) Total Size: 882 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this locally and the events work well. Great to have everything typed.
There are no tests. Should we add them in subsequent PRs?
Good point, @obulat! I'll add tests in a separate PR, which will focus on the usage of this utility to record all the custom events. |
Fixes
Fixes #825 by @dhruvkb
Description
This PR implements a framework in Nuxt for sending analytic events to Plausible. It also adds an event as an example.
Testing Instructions
just up
just frontend/run dev
localhost:50288
.CLICK_HOME_GALLERY_IMAGE
in the Plausible UI.Checklist
Update index.md
).main
) ora parent feature branch.
errors.
Developer Certificate of Origin
Developer Certificate of Origin