public function ServicePluginBase::canTrack in Analytics 8
Determines if the current service can track the current request.
Return value
bool TRUE if the service should output on the current page, otherwise FALSE.
Overrides ServicePluginInterface::canTrack
File
- src/Plugin/ ServicePluginBase.php, line 64 
Class
- ServicePluginBase
- Defines a base implementation for analytics service plugins will extend.
Namespace
Drupal\analytics\PluginCode
public function canTrack() {
  // @todo Move this to an entity operation on AnalyticsService?
  $access = AccessResult::allowedIf(!\Drupal::service('router.admin_context')
    ->isAdminRoute());
  $access
    ->addCacheContexts([
    'url.path',
  ]);
  $access = $access
    ->andIf(AccessResult::allowedIf(!\Drupal::currentUser()
    ->hasPermission('bypass all analytics services')));
  $access
    ->cachePerPermissions();
  \Drupal::moduleHandler()
    ->alter('analytics_service_can_track_access', $access, $this);
  return $access
    ->isAllowed();
}