Class MatomoDataHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.webanalytics.matomo.MatomoDataHelper
- All Implemented Interfaces:
LogEnabled
,Disposable
,Initializable
,Component
,Serviceable
public class MatomoDataHelper
extends AbstractLogEnabled
implements Component, Initializable, Serviceable, Disposable
The matomo data helper
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AbstractCacheManager
The cache managerprotected JSONUtils
JSON Utilsstatic final String
The Matomo site id config parameter namestatic final String
The Matomo URL config parameter namestatic final String
The component role. -
Constructor Summary
Constructors -
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) Get the live number of visits of today for the given page and siteprotected String
_truncateURL
(String pageUrl) Truncate parameters and fragments of the URLvoid
dispose()
long
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
void
service
(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The component role. -
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:
-
_cacheManager
The cache manager -
_jsonUtils
JSON Utils
-
-
Constructor Details
-
MatomoDataHelper
public MatomoDataHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
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
Get the live 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
-
_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
-
_truncateURL
Truncate parameters and fragments of the URL- Parameters:
pageUrl
- the page URL- Returns:
- the page URL without parameters and fragments
-
dispose
- Specified by:
dispose
in interfaceDisposable
-