Opt out statistics;

pull/643/head
Marcelo Schmidt 11 years ago
parent c3d268461d
commit ecebbdbe64
  1. 2
      .meteor/versions
  2. 18
      client/views/admin/adminStatistics.coffee
  3. 6
      client/views/admin/adminStatistics.html
  4. 2
      i18n/en.i18n.json
  5. 2
      packages/rocketchat-lib/server/functions/checkUsernameAvailability.coffee
  6. 1
      packages/rocketchat-lib/server/functions/getStatistics.coffee
  7. 2
      packages/rocketchat-lib/server/functions/setUsername.coffee
  8. 16
      server/startup/cron.coffee

@ -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

@ -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 {}

@ -109,6 +109,12 @@
{{_ "Please_wait_statistics"}}
{{/if}}
{{/unless}}
<div style="margin: 30px 0">
<label for="opt-out-statistics"><input type="checkbox" value="1" name="opt-out-statistics" id="opt-out-statistics" checked="{{optOut}}"> {{_ "Opt_out_statistics"}}</label>
<div id="opt-out-warning" class="alert-warning" style="margin-top: 10px; padding: 10px;">
{{_ "Opt_out_statistics_warning"}}
</div>
</div>
</div>
</section>
</template>

@ -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",

@ -1,2 +1,2 @@
RocketChat.checkUsernameAvailability = (username) ->
return not Meteor.users.findOne({ username: { $regex : new RegExp("^" + _.trim(username) + "$", "i") } })
return not Meteor.users.findOne({ username: { $regex : new RegExp("^" + s.trim(username) + "$", "i") } })

@ -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

@ -1,5 +1,5 @@
RocketChat.setUsername = (user, username) ->
username = _.trim username
username = s.trim username
if not user or not username
return false

@ -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()

Loading…
Cancel
Save