-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
Add Google Analytics #1049
Add Google Analytics #1049
Conversation
Your Render PR Server URL is https://toolpad-pr-1049.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-ccmv7ocgqg42l9btord0. |
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.
Wondering if it made sense to use something like https://www.npmjs.com/package/nextjs-google-analytics ? - if I understood correctly we get pretty much the same functionality there
I didn't know about this library, it doesn't seem very popular, maybe because it really isn't that much simpler/ easier to use than this integration, and does not provide any meaningful advantages? |
That's fair. I just looked around and this popped up, I don't know about the popularity, but seems that it is somewhat actively maintained and from the initial impression it already does all what you had to implement so my thinking was that we might be just able to use that out of the box. |
This implementation I made isn't too complex in my opinion, just analytics + page tracking + web vitals (not that web vitals are important for now, but they were just easy to add), so I don't think we'll have any issues maintaining it either. The kind of issues that could come from using the library isn't too probable in the short-term but would be something like:
|
As I mentioned that's fair enough, I'm not pushing to replace implementation, let's keep it as is, I just wanted to share how and why I was thinking of a library in the first place. |
Makes sense, let's keep an eye out for that sort of thing in the future. |
@@ -167,6 +167,6 @@ export default /** @type {import('next').NextConfig} */ ({ | |||
source: '/:path*', | |||
headers: securityHeaders, | |||
}, | |||
] |
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.
@apedroferreira Any idea on how this passed the prettier
CI check up until now?
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.
Same with docs/next.config.js
. It gets updated when I run yarn prettier:all
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.
not really, maybe it's not running for files with the .mjs
extension?
i probably just saved the file and prettier added this
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.
weird... if i run it locally this file always gets fixed
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.
Did prettier
get updated recently? CI only checks for changed files I believe. Perhaps we should run prettier:all
in CI?
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.
ah, i merged this from renovatebot 735011e
that was probably it
|
||
const router = useRouter(); | ||
|
||
React.useEffect(() => { |
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.
- How useful would this really be? We also have
react-router
on the editor, so the data wouldn't be exactly a good representation of user navigation throughout the app. - Did you verify we only send one event on hard reload?
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 took it from this example https://github.com/vercel/next.js/tree/canary/examples/with-google-analytics, just rechecked again and as far as I can tell:
- hard reload only triggers one page view
- client side router changes (creating a new connection for example) trigger page views too, probably because of
hashChangeComplete
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.
seems to run for the iframe routes too, not sure if that's helpful
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.
might make sense to disable for the app canvas
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.
ok actually it turns out this effect is doing nothing at all... the page view events are being sent automatically.
i'll remove this effect and see if i can filter out events from the iframe
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.
and because the page view events are sent automatically doesn't seem simple to filter out the ones from the canvas... - we can just ignore that data in the google analytics dashboard itself if we want to use page view data, im gonna make a PR that just removes the effect
Closes #997
I think this basic integration should cover all the data we need for now.