You are here

acquia_telemetry.module in Lightning Core 8.3

Same filename and directory in other branches
  1. 8.4 modules/acquia_telemetry/acquia_telemetry.module

Install, update, and uninstall functions for the Acquia Telemetry module.

File

modules/acquia_telemetry/acquia_telemetry.module
View source
<?php

/**
 * @file
 * Install, update, and uninstall functions for the Acquia Telemetry module.
 */

/**
 * Implements hook_cron().
 */
function acquia_telemetry_cron() {

  /** @var \Drupal\acquia_telemetry\Telemetry $telemetry_service */
  $telemetry_service = \Drupal::service('acquia.telemetry');
  $telemetry_service
    ->sendTelemetry('Drupal cron ran');
}

/**
 * Implements hook_modules_installed().
 */
function acquia_telemetry_modules_installed(array $modules) {

  /** @var \Drupal\acquia_telemetry\Telemetry $telemetry_service */
  $telemetry_service = \Drupal::service('acquia.telemetry');
  $installed_acquia_extensions = array_intersect($modules, $telemetry_service
    ->getAcquiaExtensionNames());
  if ($installed_acquia_extensions) {
    $event_properties = [
      'installed_extensions' => array_values($installed_acquia_extensions),
    ];
    $telemetry_service
      ->sendTelemetry('Acquia extensions installed', $event_properties);
  }
}

/**
 * Implements hook_modules_uninstalled().
 */
function acquia_telemetry_modules_uninstalled(array $modules) {

  /** @var \Drupal\acquia_telemetry\Telemetry $telemetry_service */
  $telemetry_service = \Drupal::service('acquia.telemetry');
  $uninstalled_acquia_extensions = array_intersect($modules, $telemetry_service
    ->getAcquiaExtensionNames());
  if ($uninstalled_acquia_extensions) {
    $event_properties = [
      'uninstalled_extensions' => array_values($uninstalled_acquia_extensions),
    ];
    $telemetry_service
      ->sendTelemetry('Acquia extensions uninstalled', $event_properties);
  }
}