main.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Template } from 'meteor/templating';
  2. import { ReactiveVar } from 'meteor/reactive-var';
  3. import get from 'lodash/get';
  4. import pick from 'lodash/pick';
  5. import "./main.html";
  6. import { Meteor } from "meteor/meteor";
  7. import {
  8. MeteorClientMethodSender,
  9. TrivialStrategy,
  10. ClientLogger,
  11. BrowserProcessor,
  12. } from "filog";
  13. Template.hello.onCreated(function helloOnCreated() {
  14. // counter starts at 0
  15. this.counter = new ReactiveVar(0);
  16. });
  17. Template.hello.helpers({
  18. counter() {
  19. return Template.instance().counter.get();
  20. },
  21. });
  22. Template.hello.events({
  23. 'click button'(event, instance) {
  24. // increment the counter when button is clicked
  25. instance.counter.set(instance.counter.get() + 1);
  26. },
  27. });
  28. class ExtendedBrowserProcessor extends BrowserProcessor {
  29. constructor(browserInfo) {
  30. super();
  31. this.browserInfo = pick(browserInfo, ['description', 'name', 'version', 'layout', 'os']);
  32. }
  33. process(context) {
  34. const result = super.process(context);
  35. return {
  36. ...result,
  37. browser: {
  38. ...result.browser,
  39. ...this.browserInfo,
  40. },
  41. sockJSProtocol: get(Meteor.connection, '_stream.socket.protocol', 'unknown'),
  42. };
  43. }
  44. }
  45. Meteor.startup(() => {
  46. const sender = new MeteorClientMethodSender();
  47. const strategy = new TrivialStrategy(sender);
  48. let logger = new ClientLogger(strategy);
  49. logger.processors.push(
  50. new ExtendedBrowserProcessor({}),
  51. new BrowserProcessor(),
  52. );
  53. window.logger = logger;
  54. });