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

event function doesn't throw an error when an event value is not supported by GA #87

Open
cbrwizard opened this issue Aug 17, 2017 · 1 comment

Comments

@cbrwizard
Copy link

Hey, I've just spent a couple hours debugging this and I think there is a room for improvement here.

At one point my events stopped being displayed in GA, while the universal-analytics was not throwing any errors.

Here is my code:

  new Promise((resolve, reject) => {
    try {
        const eventParams = {
          action: 'passed funMetric',
          category: 'business',
          value: userId, // a string UUID
        }

        GA.event( // GA is a universal-analytics instance
          eventParams.category,
          eventParams.action,
          eventParams.label,
          eventParams.value,
          (err) => {
            if (err) {
              logger.error({ err })
              throw err
            } else {
              logger.info(
                { ...eventParams, userId },
                'Created a GA event'
              )
              resolve()
            }
          }
        )
      }
    } catch (err) {
      logger.error({ err })
      reject(err)
    }
  })

I was getting 'Created a GA event' in my console, indicating that everything went fine. But it wasn't.

Randomly I've changed the value to 1 and it started working. I've checked the documentation https://github.com/peaksandpies/universal-analytics/blob/master/AcceptableParams.md#event-value it doesn't say anything about a requirement for a value to be a number. A string is also a non-negative value, right?

Here are the possible solutions for this issue:

  1. Best one: wait for GA to respond to a sent event and check if it was successful. If it's not - raise an error.
  2. In a event function check that, when passed, the value is an integer.
  3. Update the docs to indicate that only integers are supported.

What do you think?

@cbrwizard cbrwizard changed the title event function doesn't throw an error when an event value is not supported by GA event function doesn't throw an error when an event value is not supported by GA Aug 17, 2017
@BrandonCopley
Copy link

I am having the same problem, a string does not work and no error is being thrown. I think this module should attempt to convert strings to numbers and send to Google, but I don't know if Google is throwing errors here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants