Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a disabled option for local development #81

Open
mdunisch opened this issue Feb 10, 2021 · 5 comments
Open

Need a disabled option for local development #81

mdunisch opened this issue Feb 10, 2021 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mdunisch
Copy link
Contributor

While i develop locally i create a lot of traffic. In vue-gtag there is option for it:
https://matteogabriele.gitbooks.io/vue-analytics/content/docs/turn-off-development.html

Is there anything similar in vue-matomo?

@AmazingDreams
Copy link
Owner

Sorry I have had little time lately. Such a feature does not yet exist, but I think it is a good feature.

@AmazingDreams AmazingDreams added enhancement New feature or request good first issue Good for newcomers labels Mar 1, 2021
@mdunisch
Copy link
Contributor Author

mdunisch commented Mar 1, 2021

At the moment i do this as a workaround:

index.js

Vue.use(VueMatomo, {
  requireConsent: true
});

App.vue

created(){
    if (process.env.NODE_ENV === 'production') {
      this.$matomo.rememberConsentGiven();
    }
}

but would be awesome to just disable the tracking and not use a other feature as a workaround

@AdrienAdB
Copy link

Hi, you can setup URLs and "Only track visits... from URLs..." in Matomo website settings.
It works fine when I develop from localhost or dev (sub-)domains.

I ended up on this issue as I was looking for a way to disable tracking based on specific parameters, such as http://mywebsite.com/?optout=1

@jebarjonet
Copy link

You can enable it only when you are in production like this :

if (process.env.NODE_ENV === "production") {
  Vue.use(VueMatomo);
}

@JoostKersjes
Copy link

This is what I ended up doing:

import App from "@/App.vue";
import { router } from "@/router";
import { createApp, type Plugin } from "vue";
import VueMatomo from "vue-matomo";

// Config from Vite .env file(s)
const siteId = import.meta.env.VITE_MATOMO_SITE_ID;
const hostDomain = import.meta.env.VITE_MATOMO_HOST;

// Wrapper plugin
const matomoPlugin: Plugin = {
  install(app) {
    if (!hostDomain || !siteId) {
      // eslint-disable-next-line no-console
      console.warn("Matomo did not load because options are missing.");
      return;
    }

    app.use(VueMatomo, {
      host: `//${hostDomain}`,
      siteId: siteId,
      router: router,
    });
  },
};

createApp(App)
  .use(router)
  .use(matomoPlugin)
  .mount("#app");

And of course you can change the if to be any condition you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants