namespace App\Http\Controllers;
use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
-use Cubist\Util\PHP;
+use Illuminate\Support\Facades\Auth;
class CatalogController extends Controller
{
$cpath = $forceGuest || auth()->guard('client')->guest() ? 'fluidbooks/catalogue_invite' : 'fluidbooks/catalogue';
$relayPath = base_path($cpath) . '/' . $path;
+
+ $user = Auth::guard('client')->user();
+ if ($path === 'index.html' && $user) {
+ $html = file_get_contents($relayPath);
+ $html = str_replace('</head>', '<script>MATOMO_USER_ID="' . $user->email . '";</script></head>', $html);
+ return response($html)->header('Content-Type', 'text/html');
+
+ }
+
return XSendFileController::sendfileNoCache($relayPath);
}
class LandingController extends Controller
{
- use ForgotPassword;
+ use ForgotPassword;
public function catchall($path = '')
{
$relayPath = resource_path('webflow') . '/' . $path;
if (str_ends_with($path, '.html')) {
$html = file_get_contents($relayPath);
- $html = str_replace('</head>', '<meta name="csrf-token" content="' . csrf_token() . '"/></head>', $html);
+ $html = str_replace('</head>', '<meta name="csrf-token" content="' . csrf_token() . '"/>' . self::matomoTag() . '</head>', $html);
$user = Auth::guard('client')->user();
if ($user) {
$html = str_replace('Prénom Nom', $user->firstname . ' ' . $user->name, $html);
return XSendFileController::sendfile($relayPath);
}
+ public static function matomoTag()
+ {
+ $guard = Auth::guard('client');
+
+ $user = '';
+ if (!$guard->guest()) {
+ $user = "_paq.push(['setUserId', '" . $guard->user()->email . "']);";
+ }
+
+ return "<!-- Matomo -->
+<script>
+ var _paq = window._paq = window._paq || [];
+ /* tracker methods like \"setCustomDimension\" should be called before \"trackPageView\" */
+ _paq.push(['trackPageView']);
+ $user
+ _paq.push(['enableLinkTracking']);
+ (function() {
+ var u=\"//matomo.bastide-resah.fluidbook.com/\";
+ _paq.push(['setTrackerUrl', u+'matomo.php']);
+ _paq.push(['setSiteId', '1']);
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
+ g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
+ })();
+</script>
+<!-- End Matomo Code -->";
+ }
+
public function login()
{
$request = request();