nate-strauser / meteor-analyticsjs

Analytics.js packaged for Meteor

Home Page:https://atmospherejs.com/natestrauser/analyticsjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reactive variable for when analytics is ready?

wizonesolutions opened this issue · comments

So I'm trying to do this:

Meteor.startup ->
  # Send metadata to stuff
  analytics.initialize {
    'Errorception': {
      meta: true
    }
  }

Works fine on dev, but I get this on prod.

Uncaught TypeError: Object [object Array] has no method 'initialize'

(I got that on dev before putting it in a Meteor.startup block.)

Is it possible to get an event handler or a reactive variable that I can respond to (either in Deps.autorun or by setting analytics.on('ready', someFunction) in my Meteor.startup)?

For now I've just commented it out. Not a super huge deal yet.

+1. The Object [object Array] error is confusing. I've sent a PR for an explicit error on when there's no API key in Meteor.settings.

can you try out the master branch and let me know if that works for you? i'm setting a session var AnalyticsJS_loaded - not sure if this will work perfectly, might require the scripts loading to be done synchronously like shown here http://www.html5rocks.com/en/tutorials/speed/script-loading/

published a new version that sets the described session variable - let me know if that doesnt do the trick for you