question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Send events from Vuex

See original GitHub issue

Hi @MatteoGabriele - firstly thank you for a fabulous plugin (also thank you for vue analytics)

This is just a quick query if I may.

Is it possible to send events or exceptions in my case from a Vuex module

I have a Vuex module in a file called auth.js and would like to send an exception to GA if an error happens in there, something along the lines of:

import { exception } from 'vue-gtag'

auth.checkSession((err, result) => {
  if (err) {
    exception({
      'description': err,
      'fatal': false
    })
  } else {
    // . . . carry on 
  }
})

I can’t seem to get to work though am I doing something wrong or hasn’t this been implemented (I haven’t seen it in the docs so I’m guessing the latter) - if not implemented is there a way I can get to work?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
Jamie4224commented, Oct 31, 2020

Just a quick comment, I think this should be added to the docs, I couldn’t really find it quickly while a lot of people need this.

4reactions
altescapecommented, Jan 21, 2020

A little bit more investigation and this works well for me:

import Vue from 'vue'

Vue.$gtag.event('event name', {
  'event_category': 'a-category',
  'event_label': 'a-label',
  'value': 21
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Emit an event when a specific piece of state changes in vuex ...
Inside a component I want to watch for changes to the authed state and send an AJAX call to the server. It needs...
Read more >
Integrating Server Sent Events with Vuex | Vue.js Developers
Updating your front-end with Server Sent Events (henceforth 'SSE') has never been easier, simpler and cleaner. Updating your application state in the ...
Read more >
Actions | Vuex
Action handlers receive a context object which exposes the same set of methods/properties on the store instance, so you can call context. ...
Read more >
A Guide to Vue $emit - How to Emit Custom Events in Vue
When we emit an event, we invoke a method with one or more arguments: ... Then, using the v-on or @ directive, a...
Read more >
When to use vuex store vs events? : r/vuejs - Reddit
If a simple pass downward and event bubble upward will work, then stick with that. If multiple components all share the same data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found