Skip to content

Collectors#

A collector is a config entity, analytic.collector.*. It points at a plugin and can be disabled. Every enabled collector records the day. Week, month, and year are reduced from those day rows.

Plugins#

A plugin implements Drupal\analytic\AnalyticInterface and lives in Plugin/Analytic. calculate() returns one float for a day, or NULL when the sample should be skipped. The runner does not call it for a week, month, or year.

aggregation() is snapshot or sum.

  • A snapshot week, month, or year copies the day row on the period's end date. That is the closing level. Missed days are not rebuilt, because the old value is gone.
  • A sum adds the stored day samples when every day in that window has a row. A missing day leaves the period empty. It is not calculated again.

The base class does not add days together. That would turn "how many entities are published" into a meaningless total.

Published entities#

PublishedEntities is the only plugin this module calculates itself. A deriver adds:

  • published:{entity_type} for each content entity type whose class implements EntityPublishedInterface and defines a published key.
  • published:{entity_type}:{bundle} for each bundle, when the type has a bundle key.

The count is an entity query with accessCheck(FALSE). Node, media, and a custom entity use the same code. Creating or deleting a bundle clears plugin discovery and Views data, so the new bundle shows up as a plugin that can be enabled.

Active users, and any other metric that is not "published entities," are a View or a plugin from the module that owns the data.

Views#

The view plugin reads one number from a View. The display must already aggregate exactly one field, using count, count distinct, sum, average, minimum, or maximum. See Collect a number.