moritzsternemann / vue-plausible

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

Nuxt 3 Support #18

Open eMeRiKa13 opened 2 years ago

eMeRiKa13 commented 2 years ago

Hi,

Is this plugin compatible with Nuxt 3?

Thank you

toniengelhardt commented 2 years ago

Doesn't seem to work atm, it doesn't send any data...

moritzsternemann commented 2 years ago

Thanks for filing the issue! Nuxt 3 as well as Vue 3 support is a priority but unfortunately I won't have time to work on this until mid February. I'll update you as soon as I know more.

toniengelhardt commented 2 years ago

Update:

It actually seems to work. Forgot to set the domain in settings...

You just have to add the module and set the domain in "plausible" settings:

// nuxt.config.ts

modules: [
  'vue-plausible',
],

plausible: {
  domain: 'my-domain.com',
},

Disclaimer:

Haven't tested if all events are fired correctly, but at first glance it looks good.

Update:

The module creates problems with <a> tags, see comment below.

Atinux commented 2 years ago

I can confirm it works with Nuxt 3 😊

IzakJackson commented 2 years ago

Having an issue on Nuxt 3 where my modals open then refresh the page as soon as I install this module. When I remove the module everything works as normal.

toniengelhardt commented 2 years ago

@IzakJackson you are right, I have a similar problem with <a> tags. Until I saw your comment I didn't realize it was caused by the Plausible module. As soon as I enable the module <a> tags behave weird, target="_blank" doesn't work, all links always open in the current tab and when using an <a> tag without href, e.g. as a button, clicking on it will refresh the page.

IzakJackson commented 2 years ago

@toniengelhardt Yeah, it was on an <a> tag that I was having this issue actually.

toniengelhardt commented 2 years ago

@IzakJackson as a temporary workaround you can use <div>s instead of anchors.

bmhtech07 commented 2 years ago

@IzakJackson you are right, I have a similar problem with <a> tags. Until I saw your comment I didn't realize it was caused by the Plausible module. As soon as I enable the module <a> tags behave weird, target="_blank" doesn't work, all links always open in the current tab and when using an <a> tag without href, e.g. as a button, clicking on it will refresh the page.

I've encountered the same problem, but found that disabling enableOutboundTracking fixed the target="_blank" problem. Not a great solution though...

toniengelhardt commented 2 years ago

Thanks @bmhtech07, you're right, disabling outbound tracking resolves the problem!

productdevbook commented 1 year ago
 ERROR  [vite]: Rollup failed to resolve import "plausible-tracker" from "virtual:nuxt:/home/productdevbook/Documents/GitHub/vucod/bb/.nuxt/vue-plausible.client.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
blackspike commented 1 year ago

omg I was wondering why my "_blank" links weren't working! same issue here, disabling enableOutboundTracking fixes it but would love to have both blank & outbound tracking!

ricky11 commented 1 year ago

module does work with with nuxt3 rc 11, BUT console shows errors (below), anything we can do to silence these ?

warn] [nuxt] You are using a plugin with legacy Nuxt 2 format (context, inject) which is likely to be broken. In the future they will be ignored: PlausiblePlugin

productdevbook commented 1 year ago

Nuxt 3 library

our own library

dissy123 commented 1 year ago

Plugin not working with Nuxt3 Stable 3.0.0

Cannot read properties of undefined (reading 'options') 23:39:55

at PlausibleModule (node_modules/vue-plausible/lib/cjs/nuxt-module.js:18:89)
at installModule (node_modules/@nuxt/kit/dist/index.mjs:416:9)
at async initNuxt (node_modules/nuxt/dist/index.mjs:1825:7)
at async loadNuxt (node_modules/nuxt/dist/index.mjs:1857:5)
at async loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:493:19)
at async Object.invoke (node_modules/nuxi/dist/chunks/build.mjs:34:18)
at async _main (node_modules/nuxi/dist/cli.mjs:50:20)

Options were set in nuxt.config.ts It Stopped working after upgrading from RC11 to 3.0.0