Comparing version
@@ -1,13 +0,11 @@ | ||
import { PluginObject } from "vue"; | ||
import { Plugin } from "vue"; | ||
import { VueGtmUseOptions } from "./config"; | ||
import GtmPlugin from "./plugin"; | ||
declare module "vue/types/vue" { | ||
interface Vue { | ||
export declare function createGtm(options: VueGtmUseOptions): VueGtmPlugin; | ||
declare module "@vue/runtime-core" { | ||
interface ComponentCustomProperties { | ||
$gtm: GtmPlugin; | ||
} | ||
interface VueConstructor<V extends Vue = Vue> { | ||
gtm: GtmPlugin; | ||
} | ||
} | ||
export declare type VueGtmPlugin = PluginObject<VueGtmUseOptions>; | ||
export declare type VueGtmPlugin = Plugin; | ||
export { VueGtmUseOptions } from "./config"; | ||
@@ -14,0 +12,0 @@ declare const _default: VueGtmPlugin; |
@@ -25,3 +25,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useGtm = void 0; | ||
exports.useGtm = exports.createGtm = void 0; | ||
var vue_1 = require("vue"); | ||
var config_1 = require("./config"); | ||
@@ -77,3 +78,3 @@ var plugin_1 = require("./plugin"); | ||
gtmPlugin = new plugin_1.default(config_1.default.id); | ||
Vue.prototype.$gtm = Vue.gtm = gtmPlugin; | ||
Vue.config.globalProperties.$gtm = gtmPlugin; | ||
// Handle vue-router if defined | ||
@@ -101,2 +102,3 @@ if (initConf.vueRouter) { | ||
} | ||
Vue.provide("gtm", initConf); | ||
} | ||
@@ -136,3 +138,3 @@ /** | ||
if (trackOnNextTick) { | ||
Vue.nextTick(function () { | ||
void vue_1.nextTick(function () { | ||
gtmPlugin === null || gtmPlugin === void 0 ? void 0 : gtmPlugin.trackView(name, fullUrl, additionalEventData); | ||
@@ -147,2 +149,6 @@ }); | ||
} | ||
function createGtm(options) { | ||
return { install: function (app) { return install(app, options); } }; | ||
} | ||
exports.createGtm = createGtm; | ||
var _default = { install: install }; | ||
@@ -149,0 +155,0 @@ exports.default = _default; |
{ | ||
"name": "vue-gtm", | ||
"version": "3.3.1-vue2", | ||
"version": "3.3.1", | ||
"description": "Google Tag Manager implementation in Vue application", | ||
@@ -76,7 +76,7 @@ "main": "dist/index.js", | ||
"typescript": "^4.1.3", | ||
"vue": "^2.6.12" | ||
"vue": "^3.0.0" | ||
}, | ||
"peerDependencies": { | ||
"vue": "^2.6.0" | ||
"vue": "^3.0.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import _Vue, { PluginObject } from "vue"; | ||
import { App, nextTick, Plugin } from "vue"; | ||
import pluginConfig, { VueGtmContainer, VueGtmQueryParams, VueGtmUseOptions } from "./config"; | ||
@@ -14,3 +14,3 @@ import GtmPlugin from "./plugin"; | ||
*/ | ||
function install(Vue: typeof _Vue, initConf: VueGtmUseOptions = { id: "" }): void { | ||
function install(Vue: App, initConf: VueGtmUseOptions = { id: "" }): void { | ||
if (Array.isArray(initConf.id)) { | ||
@@ -46,3 +46,3 @@ for (const idOrObject of initConf.id) { | ||
gtmPlugin = new GtmPlugin(pluginConfig.id); | ||
Vue.prototype.$gtm = Vue.gtm = gtmPlugin; | ||
Vue.config.globalProperties.$gtm = gtmPlugin; | ||
@@ -72,2 +72,4 @@ // Handle vue-router if defined | ||
} | ||
Vue.provide("gtm", initConf); | ||
} | ||
@@ -86,3 +88,3 @@ | ||
function initVueRouterGuard( | ||
Vue: typeof _Vue, | ||
Vue: App, | ||
{ vueRouter, ignoredViews = [], trackOnNextTick }: VueGtmUseOptions | ||
@@ -122,3 +124,3 @@ ): string[] | undefined { | ||
if (trackOnNextTick) { | ||
Vue.nextTick(() => { | ||
void nextTick(() => { | ||
gtmPlugin?.trackView(name, fullUrl, additionalEventData); | ||
@@ -135,12 +137,13 @@ }); | ||
declare module "vue/types/vue" { | ||
export interface Vue { | ||
export function createGtm(options: VueGtmUseOptions): VueGtmPlugin { | ||
return { install: (app: App) => install(app, options) }; | ||
} | ||
declare module "@vue/runtime-core" { | ||
export interface ComponentCustomProperties { | ||
$gtm: GtmPlugin; | ||
} | ||
export interface VueConstructor<V extends Vue = Vue> { | ||
gtm: GtmPlugin; | ||
} | ||
} | ||
export type VueGtmPlugin = PluginObject<VueGtmUseOptions>; | ||
export type VueGtmPlugin = Plugin; | ||
export { VueGtmUseOptions } from "./config"; | ||
@@ -147,0 +150,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
56980
0.51%925
0.54%0
-100%