]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5877 @@0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 26 May 2023 07:37:10 +0000 (09:37 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 26 May 2023 07:37:10 +0000 (09:37 +0200)
app/Fluidbook/Stats.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/StatsOperation.php

index c712191e1c140af1e566e3d345ae03ef6f8ec5e3..b8ca0832ae85c67089a0aaf95be319c5283876b2 100644 (file)
@@ -23,6 +23,13 @@ class Stats extends Reporting
     // - https://redmine.cubedesigners.com/issues/5473
     const SHOW_VISITORS_CUTOFF = 20687;
 
+    const TOKENS=[
+        'stats3.fluidbook.com' => '9df722a0bd30878ddc4d737352427502',
+        'stats4.fluidbook.com' => '3ffdbe052ae625f065573df9fa9515df',
+        'stats5.fluidbook.com' => '85e9cc307b6e5083249949e9472a80b8',
+        'stats6.fluidbook.com' => '16f4c1d77cdc4792b807718388db96a0',
+    ];
+
 
     /**
      * @var int
@@ -80,18 +87,6 @@ class Stats extends Reporting
         return $this->getMatomoToken(static::getMatomoServer($this->fluidbook->id));
     }
 
-    protected function getMatomoTokens()
-    {
-        // Each stats server has a different instance of Matamo, so we need to provide different API tokens for each
-        // Normally this information would be stored in the .env but there's no good way to do that with an array, so
-        // it is simpler to keep it here. These are also stored in the shared Bitwarden entry for Matomo.
-        return [
-            'stats3.fluidbook.com' => '9df722a0bd30878ddc4d737352427502',
-            'stats4.fluidbook.com' => '3ffdbe052ae625f065573df9fa9515df',
-            'stats5.fluidbook.com' => '85e9cc307b6e5083249949e9472a80b8',
-            'stats6.fluidbook.com' => '16f4c1d77cdc4792b807718388db96a0',
-        ];
-    }
 
     protected static function getPeriods()
     {
@@ -138,8 +133,7 @@ class Stats extends Reporting
 
     protected function getMatomoToken($server): bool|string
     {
-        $tokens = $this->getMatomoTokens();
-        return $tokens[$server] ?? false;
+        return self::TOKENS[$server] ?? false;
     }
 
     protected function setDatesAndPeriod($period_override = null)
index 730f5f345a365a7b1f834a8564bbb801403134d1..923f919899f077c198c2caad7f2621f59f6035af 100644 (file)
@@ -85,7 +85,7 @@ trait StatsOperation
             return response(null)->setStatusCode('403');
         }
 
-        $matomo_tokens = json_encode($this->getMatomoTokens());
+        $matomo_tokens = json_encode(Stats::TOKENS);
         return view('fluidbook_stats.API', compact('matomo_tokens', 'id'));
     }