Skip to content

Commit

Permalink
Moved SPA/PWA class to TagManager
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Sep 15, 2023
1 parent 38d071b commit 215f276
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 11 deletions.
54 changes: 54 additions & 0 deletions SiteContentDetection/SpaPwa.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/

namespace Piwik\Plugins\TagManager\SiteContentDetection;

use Piwik\Container\StaticContainer;
use Piwik\Piwik;
use Piwik\Plugins\SitesManager\SiteContentDetection\SiteContentDetectionAbstract;
use Piwik\SiteContentDetector;
use Piwik\View;

class SpaPwa extends SiteContentDetectionAbstract
{
public static function getName(): string
{
return 'SPA / PWA';
}

public static function getContentType(): string
{
return self::TYPE_JS_FRAMEWORK;
}

public static function getPriority(): int
{
return 70;
}

public function detectByContent(?string $data = null, ?array $headers = null): bool
{
return false;
}

public function shouldShowInstructionTab(SiteContentDetector $detector = null): bool
{
return true;
}

public function renderInstructionsTab(SiteContentDetector $detector = null): string
{
$model = StaticContainer::get('Piwik\Plugins\TagManager\Model\Container');
$view = new View("@TagManager/trackingSPA");
$view->action = Piwik::getAction();
$view->showContainerRow = $model->getNumContainersTotal() > 1;
return $view->render();
}
}
11 changes: 0 additions & 11 deletions TagManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public function registerEvents()
'TwoFactorAuth.requiresTwoFactorAuthentication' => 'requiresTwoFactorAuthentication',
'Db.getTablesInstalled' => 'getTablesInstalled',
'Template.siteWithoutDataTab.ReactJs.content' => 'embedReactTagManagerTrackingCode',
'Template.siteWithoutDataTab.SpaPwa.content' => 'embedSPATagManagerTrackingCode',
);
}

Expand Down Expand Up @@ -289,16 +288,6 @@ public function embedReactTagManagerTrackingCode(&$out)
$out .= $view->render();
}

public function embedSPATagManagerTrackingCode(&$out)
{
Piwik::checkUserHasSomeViewAccess();
$model = $this->getContainerModel();
$view = new View("@TagManager/trackingSPA");
$view->action = Piwik::getAction();
$view->showContainerRow = $model->getNumContainersTotal() > 1;
$out .= $view->render();
}

public function addTagManagerTrackingCodeHelp(&$out)
{
$idSite = Common::getRequestVar('idSite', 0, 'int');
Expand Down

0 comments on commit 215f276

Please sign in to comment.