1 telemetry.module telemetry_cron()

Implements hook_cron().

File

core/modules/telemetry/telemetry.module, line 102
Collects usage information to help improve Backdrop CMS.

Code

function telemetry_cron() {
  if (settings_get('telemetry_enabled', TRUE)) {
    $last_run = state_get('telemetry_cron_last');
    $interval = 86400; // One day in seconds.
    if (REQUEST_TIME - $last_run > $interval) {
      $telemetry_data = telemetry_get_data();
      $destination_url = config_get('telemetry.settings', 'destination');
      $response = backdrop_http_request($destination_url, array(
        'method' => 'POST',
        'data' => backdrop_json_encode($telemetry_data),
        'headers' => array(
          'Content-Type' => 'application/json',
          'X-Site-Key' => _telemetry_site_key(),
        ),
      ));
      if ($response->code == 200) {
        state_set('telemetry_cron_last', REQUEST_TIME);
      }
    }
  }
}