11<?php
2+
23/**
34 * Matomo - free/libre analytics platform
45 *
1617
1718class AnonymousPiwikUsageMeasurement extends \Piwik \Plugin
1819{
19- const TRACKING_DOMAIN = 'https://demo-anonymous.matomo.org ' ;
20- const EXAMPLE_DOMAIN = 'http://example.com ' ;
20+ public const TRACKING_DOMAIN = 'https://demo-anonymous.matomo.org ' ;
21+ public const EXAMPLE_DOMAIN = 'http://example.com ' ;
2122
2223 private $ profilingStack = array ();
2324
@@ -79,11 +80,9 @@ public function trackApiCall(&$return, $endHookParams)
7980
8081 // we need to make sure the call was actually for this method to not send wrong data.
8182 if ($ method === $ call ['method ' ]) {
82-
8383 $ neededTimeInMs = ceil (($ endTime - $ call ['time ' ]) * 1000 );
8484 break ;
8585 }
86-
8786 } while (!empty ($ this ->profilingStack ));
8887
8988 if (empty ($ neededTimeInMs )) {
@@ -118,9 +117,11 @@ public function addMatomoClientTracking(&$out)
118117 'userId ' => Piwik::getCurrentUserLogin ()
119118 );
120119
121- if (Piwik::isUserIsAnonymous ()
120+ if (
121+ Piwik::isUserIsAnonymous ()
122122 || !$ settings ->canUserOptOut ->getValue ()
123- || $ userSettings ->userTrackingEnabled ->getValue ()) {
123+ || $ userSettings ->userTrackingEnabled ->getValue ()
124+ ) {
124125 // an anonymous user is currently always tracked, an anonymous user would not have permission to read
125126 // this user setting. The `isUserIsAnonymous()` check is not needed but there to improve performance
126127 // in case user is anonymous. Then we avoid checking whether user has access to any sites which can be slow
@@ -135,5 +136,4 @@ public function addMatomoClientTracking(&$out)
135136
136137 $ out .= "\nvar piwikUsageTracking = " . json_encode ($ config ) . "; \n" ;
137138 }
138-
139139}
0 commit comments