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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
Record representing the number of visits at the given local dateprotected class
The cache loader for the number of visits -
Field Summary
Modifier and TypeFieldDescriptionprotected LoadingCache<org.ametys.plugins.webanalytics.matomo.MatomoDataHelper.MatomoCacheKey,
MatomoDataHelper.NbVisits> The user information cache.static final String
The Matomo site id config parameter namestatic final String
The Matomo URL config parameter namestatic final String
The component role. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
_getComputedVisitsFromBeginYear
(String siteId, String pageUrl, String beginYear) Get the computed number of visits from the last years starting from the begin year for the given page and siteprotected int
_getComputedVisitsFromLastDays
(String siteId, String pageUrl, long nbDay) Get the computed number of visits from the last n days (starting from yesterday) for the given page and siteprotected int
_getComputedVisitsOfCurrentDay
(String siteId, String pageUrl) Get the computed number of visits of today for the given page and siteprotected int
_getLiveVisitsOfDay
(String siteId, String pageUrl, Long cacheValidityInMinutes) Get the live number of visits of today for the given page and sitelong
getMatomoSiteNbLastDays
(Site site) Get the number of days from now to computed the number of visitsint
getNbTotalVisits
(Site site, String pageUrl) Get the number of visits since the begin year for the given page and siteint
getNbVisitsFromLastDays
(Site site, String pageUrl) Get the number of visits from the last days for the given page and sitevoid
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
MATOMO_URL_CONFIG
The Matomo URL config parameter name- See Also:
-
MATOMO_SITE_ID_SITE_CONFIG
The Matomo site id config parameter name- See Also:
-
ROLE
The component role. -
_dataCache
protected LoadingCache<org.ametys.plugins.webanalytics.matomo.MatomoDataHelper.MatomoCacheKey,MatomoDataHelper.NbVisits> _dataCacheThe user information cache.
-
-
Constructor Details
-
MatomoDataHelper
public MatomoDataHelper()
-
-
Method Details
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getMatomoSiteNbLastDays
Get the number of days from now to computed the number of visits- Parameters:
site
- the site- Returns:
- the number of days
-
getNbTotalVisits
Get the number of visits since the begin year for the given page and site- Parameters:
site
- the sitepageUrl
- the page URL- Returns:
- the number of visits
- Throws:
MatomoException
- if an error with Matomo occurred
-
getNbVisitsFromLastDays
Get the number of visits from the last days for the given page and site- Parameters:
site
- the sitepageUrl
- 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 MatomopageUrl
- the page URLcacheValidityInMinutes
- 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 matomopageUrl
- the page URLbeginYear
- the begin year- Returns:
- the number of visits
- Throws:
MatomoException
- if an error with Matomo occurred
-
_getComputedVisitsOfCurrentDay
Get the computed number of visits of today for the given page and site- Parameters:
siteId
- the site identifier in matomopageUrl
- 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 matomopageUrl
- the page URLnbDay
- the number of day- Returns:
- the number of visits
- Throws:
MatomoException
- if an error with Matomo occurred
-