diff --git a/.meteor/versions b/.meteor/versions index 12f8c33738e..73c0166c569 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -39,7 +39,7 @@ htmljs@1.0.4 http@1.1.0 id-map@1.0.3 idorecall:email-normalize@1.0.0 -jalik:ufs@0.2.7 +jalik:ufs@0.2.8 jalik:ufs-gridfs@0.1.0 jparker:crypto-core@0.1.0 jparker:crypto-md5@0.1.1 diff --git a/client/views/admin/adminStatistics.coffee b/client/views/admin/adminStatistics.coffee index 454a0e16711..f0d629a7f78 100644 --- a/client/views/admin/adminStatistics.coffee +++ b/client/views/admin/adminStatistics.coffee @@ -26,12 +26,30 @@ Template.adminStatistics.helpers return out numFormat: (number) -> return _.numberFormat(number, 2) + optOut: -> + return RocketChat.settings.get 'Statistics_opt_out' + +Template.adminStatistics.events + 'click input[name=opt-out-statistics]': (e) -> + if $(e.currentTarget).prop('checked') + $('#opt-out-warning').show() + RocketChat.settings.set 'Statistics_opt_out', true, -> + toastr.success TAPi18next.t 'project:Settings_updated' + else + $('#opt-out-warning').hide() + RocketChat.settings.set 'Statistics_opt_out', false, -> + toastr.success TAPi18next.t 'project:Settings_updated' Template.adminStatistics.onRendered -> Tracker.afterFlush -> SideNav.setFlex "adminFlex" SideNav.openFlex() + if RocketChat.settings.get 'Statistics_opt_out' + $('#opt-out-warning').show() + else + $('#opt-out-warning').hide() + Template.adminStatistics.onCreated -> instance = @ @statistics = new ReactiveVar {} diff --git a/client/views/admin/adminStatistics.html b/client/views/admin/adminStatistics.html index 7a6d8b0ecb2..fd02286c166 100644 --- a/client/views/admin/adminStatistics.html +++ b/client/views/admin/adminStatistics.html @@ -109,6 +109,12 @@ {{_ "Please_wait_statistics"}} {{/if}} {{/unless}} +
+ +
+ {{_ "Opt_out_statistics_warning"}} +
+
\ No newline at end of file diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 493b0248894..4ac0e4a4a69 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -168,6 +168,8 @@ "Notify_all_in_this_room" : "Notify all in this room", "Online" : "Online", "Oops!" : "Oops", + "Opt_out_statistics": "Don't send my anonymous statistics to Rocket.Chat", + "Opt_out_statistics_warning": "By sending your anonymous statistics, you'll help us identify how many instances of Rocket.Chat are deployed, as well as how good the system is behaving, so we can further improve it. If you want to continue sending us your anonymous statistics, uncheck the above checkbox. Thank you.", "others" : "others", "Password" : "Password", "Password_changed_successfully" : "Password changed successfully", diff --git a/packages/rocketchat-lib/server/functions/checkUsernameAvailability.coffee b/packages/rocketchat-lib/server/functions/checkUsernameAvailability.coffee index 1dd34b347b5..ea855eb7ecc 100644 --- a/packages/rocketchat-lib/server/functions/checkUsernameAvailability.coffee +++ b/packages/rocketchat-lib/server/functions/checkUsernameAvailability.coffee @@ -1,2 +1,2 @@ RocketChat.checkUsernameAvailability = (username) -> - return not Meteor.users.findOne({ username: { $regex : new RegExp("^" + _.trim(username) + "$", "i") } }) \ No newline at end of file + return not Meteor.users.findOne({ username: { $regex : new RegExp("^" + s.trim(username) + "$", "i") } }) \ No newline at end of file diff --git a/packages/rocketchat-lib/server/functions/getStatistics.coffee b/packages/rocketchat-lib/server/functions/getStatistics.coffee index 07a35c9b276..0dbd632487e 100644 --- a/packages/rocketchat-lib/server/functions/getStatistics.coffee +++ b/packages/rocketchat-lib/server/functions/getStatistics.coffee @@ -2,6 +2,7 @@ RocketChat.getStatistics = -> statistics = {} # Version + statistics.uniqueId = Settings.findOne({ _id: "uniqueID" })?.value statistics.version = BuildInfo?.commit?.hash statistics.versionDate = BuildInfo?.commit?.date diff --git a/packages/rocketchat-lib/server/functions/setUsername.coffee b/packages/rocketchat-lib/server/functions/setUsername.coffee index b16764b61fa..aed65e1e30a 100644 --- a/packages/rocketchat-lib/server/functions/setUsername.coffee +++ b/packages/rocketchat-lib/server/functions/setUsername.coffee @@ -1,5 +1,5 @@ RocketChat.setUsername = (user, username) -> - username = _.trim username + username = s.trim username if not user or not username return false diff --git a/server/startup/cron.coffee b/server/startup/cron.coffee index 0ef3a1f6eaf..0ec5602289e 100644 --- a/server/startup/cron.coffee +++ b/server/startup/cron.coffee @@ -12,19 +12,11 @@ Meteor.startup -> return parser.text 'every 1 hour' job: -> statistics = RocketChat.saveStatistics() - return - - unless RocketChat.settings.get 'Statistics_opt_out' - # Generate and save statistics every hour - SyncedCron.add - name: 'Send statistics to Rocket.Chat', - schedule: (parser) -># parser is a later.parse object - return parser.text 'every 1 day' - job: -> - statistics = RocketChat.getAvgStatistics() - # HTTP.post 'http://localhost:3005/stats', + unless RocketChat.settings.get 'Statistics_opt_out' + console.log 'Sending statistics data to Rocket.Chat' HTTP.post 'https://rocket.chat/stats', data: statistics - return + + return SyncedCron.start()