Using faisalman:ua-parser-js

Before filing an issue on it’s github, can’t ua-parser-js be used on the client in Meteor? I have added 0.7.9 successfully to my 1.1.0.3 app with meteor add faisalman:ua-parser-js. It seems to be exported as UAParser in package.js here, for both client and server. Still, I can’t seem to acccess it? See this MeteorPad for examples of what I’ve tried.

you can register helper, for example

Template.registerHelper('parseUA', function(ua) {
  var parser = new UAParser();

  parser.setUA(ua)
  var result = parser.getResult();

  return parser.getOS().name + ", " + result.browser.name
});

and will using in template

{{parseUA status.lastLogin.userAgent }}

for you i think ua-parser is not initialize in rendered method, use it in helpers, just

var parser = new UAParser();
1 Like

Thanks. Sorry for not getting back to you on this. The problem here is deeper I think. If you see the Meteorpad. Setting breakpoints all over my app where you’d think it would be accessible (in templates, helpers, etc), (window./global.)UAParser is undefined.