You are here

class Timing in Googalytics - Google Analytics 8

Class Timing.

Hierarchy

Expanded class hierarchy of Timing

File

src/AnalyticsCommand/Timing.php, line 8

Namespace

Drupal\ga\AnalyticsCommand
View source
class Timing extends Send {

  /**
   * A string for categorizing all user timing variables into logical groups.
   *
   * @var string
   */
  protected $timingCategory;

  /**
   * A string to identify the variable being recorded.
   *
   * @var string
   */
  protected $timingVar;

  /**
   * The number of milliseconds in elapsed time.
   *
   * @var int
   */
  protected $timingValue;

  /**
   * A string that can be used to add flexibility in visualizing user timings.
   *
   * @var null|string
   */
  protected $timingLabel;

  /**
   * Create constructor.
   *
   * @param string $category
   *   A string for categorizing all user timing variables into logical groups.
   * @param string $var
   *   A string to identify the variable being recorded.
   * @param int $value
   *   The number of milliseconds in elapsed time.
   * @param string|null $label
   *   A string that can be used to add flexibility in visualizing user timings
   *   in the reports.
   * @param array $fields_object
   *   A map of values for the command's fieldsObject parameter.
   * @param string $tracker_name
   *   The tracker name (optional).
   * @param int $priority
   *   The command priority.
   */
  public function __construct($category, $var, $value, $label = NULL, array $fields_object = [], $tracker_name = NULL, $priority = self::DEFAULT_PRIORITY) {
    $this->timingCategory = $category;
    $this->timingVar = $var;
    if (!is_int($value)) {
      throw new \InvalidArgumentException("Timing value must be an integer");
    }
    $this->timingValue = $value;
    $this->timingLabel = $label;
    parent::__construct('timing', $fields_object, $tracker_name, $priority);
  }

  /**
   * {@inheritdoc}
   */
  public function getSettingCommands() {
    $command = [
      ($this->trackerName ? $this->trackerName . '.' : '') . $this->command,
      $this->hitType,
      $this->timingCategory,
      $this->timingVar,
      $this->timingValue,
    ];
    if (!is_null($this->timingLabel)) {
      $command[] = $this->timingLabel;
    }
    if (!empty($this->fieldsObject)) {
      $command[] = $this->fieldsObject;
    }
    return [
      $command,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalSettingCommandsTrait::$priority protected property Priority integer.
DrupalSettingCommandsTrait::getPriority public function An integer value for sorting by priority.
Generic::$command protected property The command name.
Generic::$fieldsObject protected property A map of values for the command's fieldsObject parameter.
Generic::$trackerName protected property The name of the tracker for this command.
Generic::getCommand public function Get the command name.
Generic::getFieldsObject public function Get the map of values for the command's fieldsObject parameter.
Generic::getTrackerName public function The tracker this command will be applied to, if specified.
Send::$hitType protected property The event hitType parameter.
Send::$hitTypes private static property
Send::DEFAULT_PRIORITY constant Overrides Generic::DEFAULT_PRIORITY 1
Timing::$timingCategory protected property A string for categorizing all user timing variables into logical groups.
Timing::$timingLabel protected property A string that can be used to add flexibility in visualizing user timings.
Timing::$timingValue protected property The number of milliseconds in elapsed time.
Timing::$timingVar protected property A string to identify the variable being recorded.
Timing::getSettingCommands public function An array of commands to be sent to Google Analytics. Overrides Send::getSettingCommands
Timing::__construct public function Create constructor. Overrides Send::__construct