diff --git a/.eslintrc.json b/.eslintrc.json index 90c7771..3e5a7e2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -37,6 +37,7 @@ "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-inferrable-types": "off", "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-call": "off", "@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/prefer-nullish-coalescing": "warn", @@ -66,6 +67,7 @@ { "minLength": 3, "skipWords": [ + "cancelled", "globals", "googletagmanager", "gtm", diff --git a/CHANGELOG.md b/CHANGELOG.md index 89003ae..ca32cd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ - Provide possibility to override `isInBrowserContext` check ([01f3651]) - Significantly improve JSDoc ([9edc30d]) - Add `vue-router` as `devDependency` for type definition ([593af25]) +- Do not track any views if navigation is aborted or cancelled + _You can see logs in the browser console if you have enabled debug mode_ +- Fix `vue-router` access `base` from history options + _This only affects Vue 3_ [01f3651]: https://github.com/mib200/vue-gtm/commit/01f3651de1df4f679c60af05697af41b1a38d39b [9edc30d]: https://github.com/mib200/vue-gtm/commit/9edc30daf0c2bdf542c82d07c2f413421f44de3d diff --git a/src/index.ts b/src/index.ts index 5161fa9..ec6929e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -92,7 +92,7 @@ function initVueRouterGuard( vueRouter: VueGtmUseOptions["vueRouter"], ignoredViews: VueGtmUseOptions["ignoredViews"] = [], trackOnNextTick: VueGtmUseOptions["trackOnNextTick"] -): string[] | undefined { +): void { if (!vueRouter) { console.warn("[VueGtm]: You tried to register 'vueRouter' for vue-gtm, but 'vue-router' was not found."); return; @@ -101,7 +101,6 @@ function initVueRouterGuard( // Flatten routes name ignoredViews = ignoredViews.map((view) => view.toLowerCase()); - // eslint-disable-next-line @typescript-eslint/no-unsafe-call vueRouter.afterEach((to) => { // Ignore some routes if (typeof to.name !== "string" || ignoredViews.indexOf(to.name.toLowerCase()) !== -1) { @@ -126,8 +125,6 @@ function initVueRouterGuard( gtmPlugin?.trackView(name, fullUrl, additionalEventData); } }); - - return ignoredViews; } declare module "vue/types/vue" {