MatteoGabriele / vue-gtag

Global Site Tag plugin for Vue (gtag.js)
https://matteo-gabriele.gitbook.io/vue-gtag/
MIT License
875 stars 67 forks source link

Error when using pageTrackerSkipSamePath option - types don't match #535

Open mrchimp opened 1 year ago

mrchimp commented 1 year ago

Environment *

Run this command in the project folder and fill in their results:

npm ls vue-gtag:

package.json@0.0.0 /home/mrchimp/code/project
└── vue-gtag@2.0.1

npm ls vue:

package.json@0.0.0 /home/mrchimp/code/project
├─┬ vue@3.2.47
└─┬ vuex@4.1.0
  └── vue@3.2.47 deduped

Then, specify:

  1. Operating system: Ubuntu 22.04.2
  2. Browser and version: n/a

Description *

I am seeing a type error when trying to use the pageTrackerSkipSamePath option in TypeScript, like so:

app.use(
  VueGtag,
  {
    pageTrackerSkipSamePath: false, // This is line 34
    config: { id: import.meta.env.VITE_GA },
  },
  router
);

Expected behavior

Compile without error.

Actual behavior

I get an error:

src/main.ts:34:5 - error TS2345: Argument of type '{ pageTrackerSkipSamePath: boolean; config: { id: any; }; }' is not assignable to parameter of type 'PluginOptions'.
  Object literal may only specify known properties, and 'pageTrackerSkipSamePath' does not exist in type 'PluginOptions'.

34     pageTrackerSkipSamePath: false,

Further Info

It seems that the options don't match up with the type definition.

jimmiejackson commented 1 year ago

The same thing is happening when I'm trying to use pageTrackerExcludedRoutes, and doesn't appear to be actually excluding routes either.

Stevie-Ray commented 2 months ago

As a quick workaround, you can use

declare module 'vue-gtag' {
  interface PluginOptions {
    pageTrackerSkipSamePath?: boolean;
  }
}