feat(dashboard): Affiche les statistiques des sources de trafic depuis Umami

This commit is contained in:
Serreau Jovann
2026-02-06 14:31:24 +01:00
parent 1526330ed3
commit 0284117326
3 changed files with 45 additions and 23 deletions

View File

@@ -104,18 +104,3 @@ export class UtmEvent extends HTMLElement {
} }
} }
} }
// Chargement automatique d'Umami si consentement
export function loadUmamiScript() {
if (sessionStorage.getItem('ldk_cookie') === 'accepted') {
if (!document.querySelector('script[data-website-id="38d713c3-3923-4791-875a-dfe5f45372c3"]')) {
const script = document.createElement('script');
script.defer = true;
script.src = "https://tools-security.esy-web.dev/script.js";
const umamiScript = document.querySelector('script[data-website-id]');
const websiteId = umamiScript ? umamiScript.getAttribute('data-website-id') : null;
script.setAttribute('data-website-id', websiteId);
document.head.appendChild(script);
}
}
}

View File

@@ -81,7 +81,6 @@ class HomeController extends AbstractController
} }
}); });
$this->cache->delete('umami_stats_24h');
// 2. Récupération des Stats (Cache 15min) // 2. Récupération des Stats (Cache 15min)
return $this->cache->get('umami_stats_24h', function (ItemInterface $item) use ($token) { return $this->cache->get('umami_stats_24h', function (ItemInterface $item) use ($token) {
$item->expiresAfter(900); $item->expiresAfter(900);
@@ -110,6 +109,7 @@ class HomeController extends AbstractController
'type' => 'referrer' 'type' => 'referrer'
], ],
]); ]);
dd($metricsResponse->getContent());
$referrers = $metricsResponse->toArray(); $referrers = $metricsResponse->toArray();
dd($referrers); dd($referrers);
// 3. Process Sources // 3. Process Sources
@@ -146,6 +146,7 @@ class HomeController extends AbstractController
'sources' => $sources 'sources' => $sources
]; ];
} catch (\Exception $e) { } catch (\Exception $e) {
dd($e);
return [ return [
'visitors' => 0, 'visitors' => 0,
'views' => 0, 'views' => 0,

View File

@@ -6,7 +6,7 @@
{# --- SEO Fondamental --- #} {# --- SEO Fondamental --- #}
<title> <title>
{% block title %}{{ 'base.seo.title'|trans }}{% endblock %} {% block title %}{{ 'Location Structure Gonflable & Châteaux pour vos Événements | Ludikevent'|trans }}{% endblock %}
</title> </title>
{% if block('description') is defined %} {% if block('description') is defined %}
@@ -17,7 +17,7 @@
<link rel="canonical" href="{{ app.request.schemeAndHttpHost }}{{ app.request.pathinfo }}"> <link rel="canonical" href="{{ app.request.schemeAndHttpHost }}{{ app.request.pathinfo }}">
{% endblock %} {% endblock %}
<meta name="keywords" content="{{ 'base.seo.keywords'|trans }}"> <meta name="keywords" content="{{ 'location structure gonflable, location chateau gonflable, location barnum, jeux exterieurs, animation anniversaire, location materiel evenementiel, parcours gonflable, location machine barbe a papa, ludikevent'|trans }}">
{# --- Open Graph --- #} {# --- Open Graph --- #}
<meta property="og:type" content="website"> <meta property="og:type" content="website">
@@ -27,6 +27,7 @@
<meta property="og:description" content="{{ block('description') }}"> <meta property="og:description" content="{{ block('description') }}">
{% endif %} {% endif %}
<meta property="og:image" content="{{ absolute_url(asset('provider/images/favicon.png')) }}"> <meta property="og:image" content="{{ absolute_url(asset('provider/images/favicon.png')) }}">
<meta property="article:publisher" content="https://www.facebook.com/profile.php?id=61574652399326">
{# --- Twitter Card --- #} {# --- Twitter Card --- #}
<meta name="twitter:card" content="summary"> <meta name="twitter:card" content="summary">
@@ -35,14 +36,49 @@
{% block extra_header %}{% endblock %} {% block extra_header %}{% endblock %}
{# ... scripts PWA / Analytics ... #} {# --- Données Structurées (JSON-LD) --- #}
<script type="application/ld+json">
[
{
"@context": "https://schema.org",
"@type": "LocalBusiness",
"name": "Ludikevent",
"image": "{{ absolute_url(asset('provider/images/favicon.png')) }}",
"telephone": "+33614172447",
"email": "contact@ludikevent.fr",
"url": "{{ app.request.schemeAndHttpHost }}",
"address": {
"@type": "PostalAddress",
"streetAddress": "6 Rue du Château",
"addressLocality": "Danizy",
"postalCode": "02800",
"addressCountry": "FR"
},
"geo": {
"@type": "GeoCoordinates",
"latitude": 49.6644,
"longitude": 3.3852
},
"sameAs": [
"https://www.facebook.com/profile.php?id=61574652399326"
],
"priceRange": "€€"
}
]
</script>
{% block jsonld %}{% endblock %}
{# --- PWA & Analytics --- #}
{% if app.environment != 'dev' %}
{{ pwa(swAttributes={ 'nonce': csp_nonce('script') }) }}
<script data-host-url="https://tools-security.esy-web.dev" nonce="{{ csp_nonce('script') }}" defer src="/utm_reserve.js" data-website-id="38d713c3-3923-4791-875a-dfe5f45372c3"></script>
{% else %}
<script data-host-url="https://tools-security.esy-web.dev" nonce="{{ csp_nonce('script') }}" defer src="/utm_reserve.js" data-website-id="3915e612-2df0-4ebe-b9e0-a171d7977d42"></script>
{% endif %}
<script nonce="{{ csp_nonce('script') }}" src="/ts.js"></script>
{{ vite_asset('reserve.js',{}) }} {{ vite_asset('reserve.js',{}) }}
{% block stylesheets %}{% endblock %} {% block stylesheets %}{% endblock %}
<link rel="alternate" type="application/rss+xml" title="LudikEvent - Tout" href="{{ url('app_rss_feed', {channel: 'all'}) }}">
<link rel="alternate" type="application/rss+xml" title="LudikEvent - Produits" href="{{ url('app_rss_feed', {channel: 'products'}) }}">
<link rel="alternate" type="application/rss+xml" title="LudikEvent - Formules" href="{{ url('app_rss_feed', {channel: 'formules'}) }}">
</head> </head>
<body class="bg-gray-50 text-gray-900 font-sans antialiased min-h-screen flex flex-col"> <body class="bg-gray-50 text-gray-900 font-sans antialiased min-h-screen flex flex-col">