Olivier Massot il y a 5 ans
Parent
commit
5d08f4eff9

+ 14 - 0
ot_stats/Classes/Controller/OtStatsController.php

@@ -38,6 +38,20 @@ class OtStatsController extends SelectedSiteController {
         }
         $this->view->assign('matomoSiteId', (int)$matomoId);
         $this->view->assign('matomoToken', self::MATOMO_TOKEN);
+
+        // Default interval
+        $date_end = new \DateTime('today');
+        $date_start = clone $date_end;
+        $date_start->sub(new \DateInterval('P1M'));
+
+        $this->view->assign('date_start', $date_start);
+        $this->view->assign('date_end', $date_end);
+
+
+        // <-- Shall be removed when a fix is released for https://github.com/matomo-org/matomo/issues/16867
+        $matomoRepository = GeneralUtility::makeInstance(MatomoWebsiteRepository::class);
+        $matomoRepository->clearBruteforceLog();
+        // -->
     }
 
     /**

+ 7 - 5
ot_stats/Readme.md

@@ -3,7 +3,7 @@
 
 Extension de suivi des statistiques typo3.
 
-**Pré-requis**: Cette extension a été développée pour fonctionner avec Matomo 4.0.0. 
+**Pré-requis**: Cette extension a été développée pour fonctionner avec Matomo 4.0+ 
 
 |||
 |---|---|
@@ -12,13 +12,15 @@ Extension de suivi des statistiques typo3.
 | Nom | OtStats |
 
 Cette extension ajoute un module 'Statistiques' au backend typo3, qui permet aux administrateurs
-des sites d'activer le suivi de leur site.
+des sites de suivre l'activité sur leur site.
 
-Lorsqu'ils activent le suivi, l'extension va créer une nouvelle entrée de site dans la base de données
+Lorsqu'ils activent le suivi, l'extension va créer une nouvelle entrée dans la base de données
 Matomo, et récupère l'Id du site ainsi créé.
 Cette Id est ensuite stocké dans un champs dédié de la table 'pages'.
 
 Si un Id de site matomo est enregistré, l'extension intégrera alors le script de suivi matomo aux
-pages du site. Une bannière sera également présentée aux nouveaux visiteurs les avertissant de l'usage 
-de cookies de suivi et demandant leur accord. 
+pages du site. 
 
+Aucune bannière demandant le consentement des utilisateurs n'est nécessaire d'après le RGPD, car
+les données sont anonymisées et ne sont pas utilisées pour des traitements externes à Typo3 (voir 
+[ici](https://www.cnil.fr/fr/cookies-solutions-pour-les-outils-de-mesure-daudience))

+ 47 - 0
ot_stats/Resources/Private/Partials/ReportCard.html

@@ -0,0 +1,47 @@
+<f:comment><!-- Displays a matomo widget --></f:comment>
+
+<f:comment>
+<!--
+   The following arguments are expected here:
+   * {title}           (string)   The widget title
+   * {id}              (string)   an html id
+   * {matomoSiteId}    (int)      the matomo site's id
+   * {matomoToken}     (string)   the matomo's user token
+   * {module}          (string)   the matomo 'moduleToWidgetize' parameter
+   * {action}          (string)   the matomo 'actionToWidgetize' parameter
+   * {date_start}      (Datetime) The perdiod starting date
+   * {date_end}        (Datetime) The perdiod ending date
+   * {additionalUrl}   (string)   [Optional] This string will be added at the end of the iframe's url without any formatting
+   * {width}           (int)      [Optional] Override the default card width
+   * {height}          (int)      [Optional] Override the default card height, and disable auto-resizing
+ -->
+</f:comment>
+
+<div class="reportCard">
+    <h4>{title}</h4>
+    <div class="widgetIframe">
+        <iframe width="{f:if(condition: '{width} > 0', then: width, else: '500')}"
+                height="{f:if(condition: '{height} > 0', then: height, else: '350')}"
+                id="{id}"
+				src="https://stats.2iopenservice.com/index.php?module=Widgetize
+						&action=iframe
+						&disableLink=1
+						&widget=1
+						&moduleToWidgetize={module}
+						&actionToWidgetize={action}
+						&idSite={matomoSiteId}
+						&period=month
+						&date=today
+						&token_auth={matomoToken}
+						{additionalUrl}"
+                scrolling="yes"
+                frameborder="0"
+                marginheight="0"
+                marginwidth="0"></iframe>
+        <f:if condition="{height}>0"><f:then>
+            <f:comment><!-- no resizing --></f:comment>
+        </f:then><f:else>
+            <script defer>iFrameResize(<f:format.raw value="{"/><f:format.raw value="}"/>, '#{id}')</script>
+        </f:else></f:if>
+    </div>
+</div>

+ 75 - 105
ot_stats/Resources/Private/Templates/OtStats/Index.html

@@ -6,127 +6,97 @@
 <f:section name="content">
     <div class="ot-be-module ot-stats">
         <h1>Statistiques d'utilisation</h1>
+
+        <div id="matomoFilters">
+            Données affichées pour la période du
+                <b><f:format.date format="d/m/Y">{date_start}</f:format.date></b>
+                au
+                <b><f:format.date format="d/m/Y">{date_end}</f:format.date></b>
+            <a id="matomoFiltersEdit" href="" title="Modifier"><i class="fa fa-edit"></i></a>
+        </div>
+
         <div id="matomoReport">
 
             <div class="reportSection">
 
-                <div class="reportSubSection">
-                    <div class="reportCard">
-                        <f:comment><!-- Real time visits--></f:comment>
-                        <h4>Visites en temps réel</h4>
-                        <div class="widgetIframe">
-                            <iframe width="500" height="350" id="realTimeVisits" src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=Live&actionToWidgetize=widget&idSite={matomoSiteId}&period=month&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>
-                            <script defer>iFrameResize({}, '#realTimeVisits')</script>
-                        </div>
-
-                    </div>
-
-                    <f:comment>
-                        <!-- Disabled until this is fixed: https://github.com/matomo-org/matomo/issues/16867 -->
-                        <!-- <div class="reportCard"> -->
-                        <!-- <f:comment>&lt;!&ndash; Last visits graph&ndash;&gt;</f:comment> -->
-                        <!-- <div class="widgetIframe" id="lastVisitsGraph"><iframe width="450" height="260" src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=VisitsSummary&actionToWidgetize=getEvolutionGraph&idSite={matomoSiteId}&period=day&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>-->
-                        <!-- </div> -->
-                    </f:comment>
-                </div>
-
-                <div class="reportCard">
-                    <f:comment><!-- Visits Summary --></f:comment>
-                    <h4>Résumé</h4>
-                    <div class="widgetIframe">
-                        <iframe width="500" height="350" id="visitsSummary"
-                                src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=VisitsSummary&actionToWidgetize=get&idSite={matomoSiteId}&period=month&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>
-                        <script defer>iFrameResize({}, '#visitsSummary')</script>
-                    </div>
-                </div>
+                <f:comment><!-- Real time visits--></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'Visites en temps réel', id: 'realTimeVisits',
+                                      module: 'Live', action: 'widget',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
+
+                 <f:comment><!-- Last visits graph--></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'Dernières visites', id: 'lastVisitsGraph',
+                                      module: 'VisitsSummary', action: 'getEvolutionGraph',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
+
+                <f:comment><!-- Visits Summary --></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'Résumé', id: 'visitsSummary',
+                                      module: 'VisitsSummary', action: 'get',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
             </div>
 
             <div class="reportSection">
-                <div class="reportCard">
-                    <f:comment><!-- By weekday --></f:comment>
-                    <h4>Par jours de la semaine</h4>
-                    <div class="widgetIframe">
-                        <iframe width="500" height="350" id="visitsByWeekday"
-                                src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=VisitTime&actionToWidgetize=getByDayOfWeek&idSite={matomoSiteId}&period=month&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>
-                        <script defer>iFrameResize({}, '#visitsByWeekday')</script>
-                    </div>
-                </div>
-
-                <div class="reportCard">
-                    <f:comment><!-- By local hour --></f:comment>
-                    <h4>Par heures locales</h4>
-                    <div class="widgetIframe">
-                        <iframe width="500" height="350" id="visitsByHour"
-                                src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=VisitTime&actionToWidgetize=getByDayOfWeek&idSite={matomoSiteId}&period=month&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>
-                        <script defer>iFrameResize({}, '#visitsByHour')</script>
-                    </div>
-                </div>
-
-                <div class="reportCard">
-                    <f:comment><!-- Map --></f:comment>
-                    <h4>Répartition géographique</h4>
-                    <div class="widgetIframe">
-                        <iframe width="500" height="450" id="visitsMap"
-                                src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=UserCountryMap&actionToWidgetize=visitorMap&idSite={matomoSiteId}&period=month&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>
-                        <f:comment><!-- Don't resize here! That makes the map shrink --></f:comment>
-                    </div>
-                </div>
+
+                <f:comment><!-- By weekday --></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'Par jours de la semaine', id: 'visitsByWeekday',
+                                      module: 'VisitTime', action: 'getByDayOfWeek',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
+
+                <f:comment><!-- By local hour --></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'Par heures locales', id: 'visitsByHour',
+                                      module: 'VisitTime', action: 'getVisitInformationPerLocalTime',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
+
+                <f:comment><!-- Map --></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'Répartition géographique', id: 'visitsMap',
+                                      module: 'UserCountryMap', action: 'visitorMap', height: '450',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
             </div>
 
             <div class="reportSection">
-                <div class="reportCard">
-                    <f:comment><!-- Refferers --></f:comment>
-                    <h4>Référents</h4>
-                    <div class="widgetIframe">
-                        <iframe width="500" height="350" id="visitsRefferers"
-                                src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=Referrers&actionToWidgetize=getAll&idSite={matomoSiteId}&period=month&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>
-                        <script defer>iFrameResize({}, '#visitsRefferers')</script>
-                    </div>
-                </div>
-
-                <div class="reportCard">
-                    <f:comment><!-- By web-browsers   --></f:comment>
-                    <h4>Navigateurs</h4>
-                    <div class="widgetIframe">
-                        <iframe width="500" height="350" id="visitsByBrowsers"
-                                src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=DevicesDetection&actionToWidgetize=getBrowsers&idSite={matomoSiteId}&period=month&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>
-                        <script defer>iFrameResize({}, '#visitsByBrowsers')</script>
-                    </div>
-                </div>
+
+                <f:comment><!-- Refferers --></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'Origines', id: 'visitsRefferers',
+                                      module: 'Referrers', action: 'getAll',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
+
+                <f:comment><!-- By web-browsers   --></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'DevicesDetection', id: 'getBrowsers',
+                                      module: 'Referrers', action: 'getAll',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
+
             </div>
 
             <div class="reportSection">
-                <div class="reportCard">
-                    <f:comment><!-- By page   --></f:comment>
-                    <h4>Pages</h4>
-                    <div class="widgetIframe">
-                        <iframe width="1028" height="350" id="visitsByPage"
-                                src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=Actions&actionToWidgetize=getPageUrls&idSite={matomoSiteId}&period=month&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>
-                        <script defer>iFrameResize({}, '#visitsByPage')</script>
-                    </div>
-                </div>
+
+                <f:comment><!-- By page   --></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'Pages visitées', id: 'visitsByPage',
+                                      module: 'Actions', action: 'getPageUrls', width: '1028',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
             </div>
 
             <div class="reportSection">
-                <div class="reportCard">
-                    <f:comment><!-- By entry page --></f:comment>
-                    <h4>Pages d'entrée</h4>
-                    <div class="widgetIframe">
-                        <iframe width="500" height="350" id="visitorsEntryPoints"
-                                src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=Actions&actionToWidgetize=getEntryPageUrls&idSite={matomoSiteId}&period=month&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>
-                        <script defer>iFrameResize({}, '#visitorsEntryPoints')</script>
-                    </div>
-                </div>
-
-                <div class="reportCard">
-                    <f:comment><!-- By visits duration   --></f:comment>
-                    <h4>Durées de visite</h4>
-                    <div class="widgetIframe">
-                        <iframe width="500" height="350" id="visitsByDuration"
-                                src="https://stats.2iopenservice.com/index.php?module=Widgetize&action=iframe&disableLink=1&widget=1&moduleToWidgetize=VisitorInterest&actionToWidgetize=getNumberOfVisitsPerVisitDuration&idSite={matomoSiteId}&period=month&date=today&token_auth={matomoToken}" scrolling="yes" frameborder="0" marginheight="0" marginwidth="0"></iframe>
-                        <script defer>iFrameResize({}, '#visitsByDuration')</script>
-                    </div>
-                </div>
+
+                <f:comment><!-- By entry page --></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'Pages d\'entrée', id: 'visitorsEntryPoints',
+                                      module: 'Actions', action: 'getEntryPageUrls',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
+
+                <f:comment><!-- By visits duration   --></f:comment>
+                <f:render partial="ReportCard"
+                          arguments="{title: 'Durée des visite', id: 'visitsByDuration',
+                                      module: 'VisitorInterest', action: 'getNumberOfVisitsPerVisitDuration',
+                                      matomoSiteId: matomoSiteId, matomoToken: matomoToken, date_start: date_start, date_end: date_end}"/>
             </div>
 
             <div class="reportFooter">

+ 0 - 2
ot_stats/Resources/Public/assets/Backend/style/ot_stats.css

@@ -42,8 +42,6 @@
 #matomoReport .widgetIframe {
 }
 
-#matomoReport h3, h4, h5
-
 .reportFooter {
     display: flex;
     flex-direction: row;

+ 1 - 0
ot_stats/ext_emconf.php

@@ -24,6 +24,7 @@ $EM_CONF[$_EXTKEY] = [
             'typo3' => '8.7.0-10.4.99',
             'flux'  => '9.3.0-9.4.99',
             'vhs'  => '6.0.0-6.0.99',
+            'ot_core' => '*'
         ],
         'conflicts' => [],
         'suggests' => [],