AnalyticsJsMarkup.php in Analytics 8
File
src/Render/AnalyticsJsMarkup.php
View source
<?php
namespace Drupal\analytics\Render;
use Drupal\Component\Render\MarkupInterface;
use Drupal\Component\Render\MarkupTrait;
final class AnalyticsJsMarkup implements MarkupInterface, \Countable {
use MarkupTrait;
static $isDntEnforced;
public static function create($string) {
if ($string instanceof self) {
return $string;
}
$string = (string) $string;
if ($string === '') {
return '';
}
if (static::isDntEnforced()) {
$string = "if (!navigator.doNotTrack && !window.doNotTrack && !navigator.msDoNotTrack) {\n" . $string . "\n}";
}
$safe_string = new static();
$safe_string->string = $string;
return $safe_string;
}
public static function isDntEnforced() {
if (!isset(static::$isDntEnforced)) {
static::$isDntEnforced = \Drupal::config('analytics.settings')
->get('privacy.dnt');
}
return static::$isDntEnforced;
}
}