function _drush_usage_mongolab

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

File

commands/core/usage.drush.inc, line 150
Send scrubbed usage data to drush. Omits arguments and option values in order to assure that no sensitive data is shared. See http://drupal.org/node/1246738.

Code

function _drush_usage_mongolab($file, $min_size_to_send) {
  $json = '[' . file_get_contents($file) . ']';
  if (filesize($file) > $min_size_to_send) {
    $base = 'https://api.mongolab.com/api/1';
    $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.
    unlink($file);
    return TRUE;
  }
}