Class MatomoDataHelper

java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.webanalytics.matomo.MatomoDataHelper
All Implemented Interfaces:
LogEnabled, Initializable, Component

The matomo data helper
  • Field Details

  • Constructor Details

  • Method Details

    • initialize

      public void initialize() throws Exception
      Specified by:
      initialize in interface Initializable
      Throws:
      Exception
    • getMatomoSiteNbLastDays

      public long getMatomoSiteNbLastDays(Site site)
      Get the number of days from now to computed the number of visits
      Parameters:
      site - the site
      Returns:
      the number of days
    • getNbTotalVisits

      public int getNbTotalVisits(Site site, String pageUrl) throws MatomoException
      Get the number of visits since the begin year for the given page and site
      Parameters:
      site - the site
      pageUrl - the page URL
      Returns:
      the number of visits
      Throws:
      MatomoException - if an error with Matomo occurred
    • getNbVisitsFromLastDays

      public int getNbVisitsFromLastDays(Site site, String pageUrl) throws MatomoException
      Get the number of visits from the last days for the given page and site
      Parameters:
      site - the site
      pageUrl - the page URL
      Returns:
      the number of visits
      Throws:
      MatomoException - if an error with Matomo occurred
    • _getLiveVisitsOfDay

      protected int _getLiveVisitsOfDay(String siteId, String pageUrl, Long cacheValidityInMinutes) throws MatomoException
      Get the live number of visits of today for the given page and site
      Parameters:
      siteId - the site identifier in Matomo
      pageUrl - the page URL
      cacheValidityInMinutes - the number of minute of the cache validity
      Returns:
      the number of visits
      Throws:
      MatomoException - if an error with Matomo occurred
    • _getComputedVisitsFromBeginYear

      protected int _getComputedVisitsFromBeginYear(String siteId, String pageUrl, String beginYear) throws MatomoException
      Get the computed number of visits from the last years starting from the begin year for the given page and site
      Parameters:
      siteId - the site identifier in matomo
      pageUrl - the page URL
      beginYear - the begin year
      Returns:
      the number of visits
      Throws:
      MatomoException - if an error with Matomo occurred
    • _getComputedVisitsOfCurrentDay

      protected int _getComputedVisitsOfCurrentDay(String siteId, String pageUrl) throws MatomoException
      Get the computed number of visits of today for the given page and site
      Parameters:
      siteId - the site identifier in matomo
      pageUrl - the page URL
      Returns:
      the number of visits
      Throws:
      MatomoException - if an error with Matomo occurred
    • _getComputedVisitsFromLastDays

      protected int _getComputedVisitsFromLastDays(String siteId, String pageUrl, long nbDay) throws MatomoException
      Get the computed number of visits from the last n days (starting from yesterday) for the given page and site
      Parameters:
      siteId - the site identifier in matomo
      pageUrl - the page URL
      nbDay - the number of day
      Returns:
      the number of visits
      Throws:
      MatomoException - if an error with Matomo occurred