MatteoGabriele / vue-gtag-next

Global Site Tag plugin for Vue 3 (gtag.js)
MIT License
44 stars 3 forks source link

`bootstrap` doesn't exists on vue-gtag-next #44

Closed rubencanovaca closed 1 year ago

rubencanovaca commented 1 year ago

How could I wait fot the bootstrap resolution in order to get the gtag object and do something with it in Vue 3?

I'm migrating some components from vue 2 to vue 3 with composition API (not all components) and I bootstrap gtag by this way:

import { App } from 'vue'
import VueGtag, { bootstrap } from 'vue-gtag'
(...)
App.use(VueGtag, { bootstrap: false, config: { id: GA_TRACKER, cookie_domain: GA_COOKIE_DOMAIN } })
(...)
bootstrap().then((gtag) => {
    App.provide('gtag', gtag)
})

I wanna use the useGtag that provides this version, because I can't use this.$gtag in composition API. But I must continue using the legacy way for some parts of the application that are using Options API yet.

I mean, I wanna use both forms: useGtag and this.$gtag in my application.

rubencanovaca commented 1 year ago

I know that in this version, instead of calling the bootstrap() method, gtag can be instantiated by passing the id to the property object. But I don't know how to get the "gtag" object that I used to get with the bootstrap() method before.

EDIT: It's seems that it's not necessary. Version 3 continue using the same global namespace. https://matteo-gabriele.gitbook.io/vue-gtag/v/next/global-namespace

CLOSED