Open CainHarniessFs opened 1 year ago
I had the same problem. You can declare your config as PluginOptions
.
import { PluginOptions } from 'vue-gtag'
{
pageTrackerTemplate(to: RouteLocationNormalized) {
return services.googleAnalyticsService.createPageview(
to.name?.toString() ?? "Untitled",
to.path,
to.fullPath
);
}
} as PluginOptions
Environment *
npm ls vue-gtag
:npm ls vue
:Windows
Edge 111.0.1661.51 (Official build) (64-bit)
Description *
I think the TypeScript type declaration from the
pageTrackerTemplate
property is incorrect when compared against the documentation. I believe it is missing both theto
andfrom
parameters.Please can you review the below and confirm whether this is intended?
Expected behavior
In the documentation for the page tracker template here, the
pageTrackerTemplate
in the code sample has the following signature.Additionally, there is the following note.
The pageTrackerTemplate method will have both the to and the from route instances passed as parameters.
I'd expect the below to be a valid
pageTrackerTemplate
declaration when using TypeScript in Vue 3 and Vue Router v4 - the latter meaning that the arguments are of typeRouteLocationNormalized
.where
googleAnalyticsService.createPageView
returns an interface that extends thevue-gtag
PageView
interface. (see other notes below).Actual behavior
I receive the following TypeScript error.
The type declaration is
It looks like it is missing both the
to
andfrom
parameters.Reproducible Demo in case of a bug report
I think my explanation above is sufficient for this issue. Let me know if you disagree.
Other Notes
We have extended the PageView interface in order to send additional values with page view events, and this worked on the previous version of
vue-gtag
.Thanks, Cain