Calvin-Huang / amplitude-module

Amplitude module for Nuxtjs
MIT License
0 stars 2 forks source link

unusable #2

Open VladBern3 opened 4 years ago

VladBern3 commented 4 years ago

unusable module, nothing works, mute report

mikedidthis commented 4 years ago

Whilst the documentation is lacking, the module does work.

  1. Add nuxt-amplitude as a dev dependency with yarn or npm:
yarn add nuxt-amplitude --dev
npm install nuxt-amplitude --dev
  1. Add nuxt-amplitude config to nuxt.config.js:
export default {
  buildModules: [
    [
      'nuxt-amplitude',
      {
        apiKey: 'AMPLITUDE_KEY',
      }
    ]
  ]
}
  1. Call logEvent() in your components mounted() life cycle method:
export default {
  name: 'Index',
  mounted () {
    this.$amplitude.getInstance().logEvent('EVENT_NAME');
  }
}

Hope that helps!

dcrabbeYapily commented 3 years ago

thanks - tried this but get an error.

Cannot read properties of undefined (reading '$amplitude'

I've added this to default.vue.

onMounted(() => {
      this.$amplitude.getInstance().logEvent('EVENT_NAME');
});

Using cue with Composition API.