4lejandrito / next-plausible

Simple integration for https://nextjs.org and https://plausible.io analytics
https://next-plausible.vercel.app
MIT License
603 stars 33 forks source link

Disable console logs #45

Closed alvarlagerlof closed 2 years ago

alvarlagerlof commented 2 years ago

I am getting a bunch of WARNING Ignoring Event: localhost that end up showing up in my build due to my setup. Coud PlausibleProvider have some kind of prop to disable logging?

4lejandrito commented 2 years ago

Hi @alvarlagerlof,

That's because you are including the script in development mode. I don't think there is a way to tell the plausible script to disable logging apart from disabling it (which happens by default in development mode). You can enable the trackLocalhost prop to get rid of the warning (but the events will be sent to the server) as described in this answer.

Let me know if that helps.

alvarlagerlof commented 2 years ago

Right, didn't realize it was their script doing that. Tracking localhost would make the stats off so not going to do that. Is there a way to disable the whole thing in localhost?

4lejandrito commented 2 years ago

Hi @alvarlagerlof,

Sorry for the late reply.

I don't know of a way to disable this on localhost. I don't know if nextjs exposes some kind of config variable with the domain. If that were the case you could pass the enabled property to PlausibleProvider checking that. But again, I am not sure that's possible.

alvarlagerlof commented 2 years ago

I see. It's okay. Just a minor nitpick.