moritzsternemann / vue-plausible

Plausible Analytics Vue.js Plugin and NuxtJS Module
MIT License
120 stars 8 forks source link

Let Plausible fallback to location.hostname if no domain #19

Closed TobbenTM closed 2 years ago

TobbenTM commented 2 years ago

Like the README says, domain should be optional, with a fallback to location.hostname:

Option Type Description Default
domain string Your site's domain name, as declared by you in Plausible's settings. location.hostname

However, this didn't happen because the Nuxt plugin defers instantiating the tracking entirely if the domain is not set: https://github.com/moritzsternemann/vue-plausible/blob/02c72183762e5bd72ff7771003c6b91743cde14e/src/nuxt-plugin.ts#L24

This PR changes the behavior to still start up the tracker, and let it perform its internal fallback strategy instead of doing nothing.