Skip to content

Commit

Permalink
Convert rocketchat-analytics to main module structure (#12506)
Browse files Browse the repository at this point in the history
* First wave of removal of Meteor global

* Second wave of removal of Meteor global

* Third wave of removal of Meteor global

* Fix tests

* Remove global variable SHA256

* Remove global variable WebApp

* Remove global variable EJSON

* Remove global variable Email

* Remove global variable HTTP

* Remove global variable Random

* Remove global variable ReactiveDict

* Remove global variable ReactiveVar

* Remove global variable Accounts

* Remove globals variables Match and check

* Remove global variable Mongo

* Remove global variable moment

* Remove global variable Tracker

* Remove global variable Blaze

* Remove global variables FlowRouter and BlazeLayout

* Add FlowRouter to eslint global in tests file

* Remove global variable DDPRateLimiter

* Remove global variable Session

* Remove global variable UAParser

* Remove global variable Promise

* Remove global variable Reload

* Remove global variable CryptoJS

* Remove global variable Template

* Remove global variable TAPi18n

* Remove global variable TAPi18next

* Exposing t function from rocketchat:ui package

* Convert chatpal search to main module structure

* Fix ESLint

* Convert meteor-accounts-saml to main module structure

* Convert meteor-autocomplete to main module structure

* Convert meteor-timesync package to modular structure

* exposing modal global variable

* Convert rocketchat-2fa to main module structure

* Change exposing of fireGlobalEvent function from window to package

* Moved handleError function from client to rocketchat:lib package

* Convert rocketchat:action-linsk package to main module structure

* make ChatRoom exportable by package

* Convert rocketchat-analytics to main module structure

* disable eslint no-undef in fireGlobalEvent
  • Loading branch information
MarcosSpessatto authored and rodrigok committed Nov 1, 2018
1 parent 7c87514 commit bfcbcee
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/rocketchat-analytics/client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './loadScript';
import './trackEvents';
1 change: 1 addition & 0 deletions packages/rocketchat-analytics/client/loadScript.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { Template } from 'meteor/templating';
import { RocketChat } from 'meteor/rocketchat:lib';

Template.body.onRendered(() => {
Tracker.autorun((c) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-analytics/client/trackEvents.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { RocketChat } from 'meteor/rocketchat:lib';
import { ChatRoom } from 'meteor/rocketchat:ui';
import { Tracker } from 'meteor/tracker';

function trackEvent(category, action, label) {
Expand Down
15 changes: 11 additions & 4 deletions packages/rocketchat-analytics/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ Package.describe({
// Note: Piwik respects Google Chrome's No Track: http://piwik.org/docs/privacy/#step-4-respect-donottrack-preference

Package.onUse(function(api) {
api.use(['ecmascript', 'rocketchat:lib', 'tracker']);
api.use(['templating', 'kadira:flow-router'], 'client');
api.use([
'ecmascript',
'rocketchat:lib',
'tracker',
]);
api.use([
'templating',
'kadira:flow-router',
], 'client');

api.addFiles(['client/loadScript.js', 'client/trackEvents.js'], 'client');
api.addFiles(['server/settings.js'], 'server');
api.mainModule('client/index.js', 'client');
api.mainModule('server/index.js', 'server');
});
1 change: 1 addition & 0 deletions packages/rocketchat-analytics/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './settings';
2 changes: 2 additions & 0 deletions packages/rocketchat-analytics/server/settings.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { RocketChat } from 'meteor/rocketchat:lib';

RocketChat.settings.addGroup('Analytics', function addSettings() {
this.section('Piwik', function() {
const enableQuery = { _id: 'PiwikAnalytics_enabled', value: true };
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-ui/client/lib/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import _ from 'underscore';

this.ChatMessage = new Mongo.Collection(null);
this.CachedChatRoom = new RocketChat.CachedCollection({ name: 'rooms' });
this.ChatRoom = this.CachedChatRoom.collection;
ChatRoom = this.CachedChatRoom.collection;

this.CachedChatSubscription = new RocketChat.CachedCollection({ name: 'subscriptions' });
this.ChatSubscription = this.CachedChatSubscription.collection;
Expand All @@ -17,7 +17,7 @@ this.CachedUserList = new Mongo.Collection(null);

RocketChat.models.Users = _.extend({}, RocketChat.models.Users, Meteor.users);
RocketChat.models.Subscriptions = _.extend({}, RocketChat.models.Subscriptions, this.ChatSubscription);
RocketChat.models.Rooms = _.extend({}, RocketChat.models.Rooms, this.ChatRoom);
RocketChat.models.Rooms = _.extend({}, RocketChat.models.Rooms, ChatRoom);
RocketChat.models.Messages = _.extend({}, RocketChat.models.Messages, this.ChatMessage);

Meteor.startup(() => {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-ui/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,5 @@ Package.onUse(function(api) {
api.export('t', 'client');
api.export('modal', 'client');
api.export('fireGlobalEvent', 'client');
api.export('ChatRoom', 'client');
});

0 comments on commit bfcbcee

Please sign in to comment.