function _drush_usage_mongolab

8.0.x _drush_usage_mongolab($file, $min_size_to_send)
6.x _drush_usage_mongolab($file, $min_size_to_send)
7.x _drush_usage_mongolab($file, $min_size_to_send)
5.x _drush_usage_mongolab($file, $min_size_to_send)
1 call to _drush_usage_mongolab()
usage_drush_exit in commands/core/
Log and/or send usage data to Mongolab.


commands/core/, line 148
Send scrubbed usage data to drush. Omits arguments and option values in order to assure that no sensitive data is shared. See


function _drush_usage_mongolab($file, $min_size_to_send) {
  $json = '[' . file_get_contents($file) . ']';
  if (filesize($file) > $min_size_to_send) {
    $base = '';
    $apikey = '4eb95456e4b0bcd285d8135d'; // submitter account.
    $database = 'usage';
    $collection = 'usage';
    $action = "/databases/$database/collections/$collection";
    $url = $base . $action . "?apiKey=$apikey";
    $header = 'Content-Type: application/json';
    if (!drush_shell_exec("wget -q -O - --no-check-certificate --timeout=20 --header=\"$header\" --post-data %s %s", $json, $url)) {
      if (!drush_shell_exec("curl -s --connect-timeout 20 --header \"$header\" --data %s %s", $json, $url)) {
        drush_log(dt('Drush usage statistics failed to post.'), LogLevel::DEBUG);
        return FALSE;
    drush_log(dt('Drush usage statistics successfully posted.'), LogLevel::DEBUG);
    // Empty the usage.txt file.
    return TRUE;