Adds web traffic reporting and analytics to an organisation, logging every HTTP request and exposing the resulting data through saved queries, dashboards and report pages. Every response is queued and written to the access log by a background daemon thread, then indexed by the WebHitAppIndexer so it can be searched and aggregated. Registers the Reporting and Queries admin menu items, a "Visits" tab on the profile page, and a set of KEditor components (date histogram, pie chart, query table, date range picker, org selector and others) that templates use to render report data. Also registers the ReportRunnerRole, ReportingAccessRole and ReportsManagerRole permissions that gate access to reporting artifacts. Its query and org-browsing methods (getQueries, getQuery, runQuery, numUsers, searchOrgs, browseUserOrgs and others) are called directly from report page templates.
Implements: MenuApplication, EventListener, LifecycleApplication, ChildPageApplication, AttachmentApplication, SearchableApplication, SettingsApplication, ComponentApplication, TemplatingApplication, ManageProfileApplication, DependentApplication
Properties
| Property | Returns | Description |
|---|---|---|
| geoIP | GeoIpWrapper | Shared MaxMind GeoIP2 lookup wrapper used to resolve a request's IP address to a geographic location for logging and reporting. |
| groups | List<Group> | Groups belonging to the current organisation, used by report components that let a user filter or count members by group. |
| instanceId | String | Key this application instance is registered under in the application manager, always the fixed string "Reporting". |
| legacy | boolean | |
| queries | List<QueryBean> | All saved queries available to the current organisation, used to populate report and dashboard components that pull data from a named query. |
| queryTables | Iterable<Table> | All saved query tables available to the current organisation, the underlying data tables that saved queries are built on top of. |
| roles | List<Role> | Roles this application registers: ReportRunnerRole, ReportingAccessRole and ReportsManagerRole, which together gate viewing, filtering and managing reporting artifacts. |
| userAgent | UserAgentParserWrapper | Shared user agent string parser used to derive browser, OS and device details from a request's User-Agent header when logging or reporting on traffic. |
| webHitAppIndexer | WebHitAppIndexer | Search indexer that stores and queries the web-hit access log entries recorded by this application, used by other apps that need to look up page view or web traffic data. |
Methods
getInstanceId() · log(RootFolder rf, Request request, Response response, long duration) · log(RootFolder rf, Request request, Response response, long duration, String path, String referrerUrl, String contentType) · log(RootFolder rf, Request request, Response response, long duration, String path, String referrerUrl, String contentType, String trackingId) · getWebHitAppIndexer() · getRoles() · getUserAgent() · getGeoIP() · getQueries() · getQueryTables() · getQuery(String name) · runQuery(QueryBean queryBean) · runQuery(QueryBean queryBean, Integer from, Integer size) · getQueryFieldNames(QueryBean queryBean) · getGroups() · numUsers(String groupName) · searchOrgs(String q) · listUserOrgs(Long parentId, List<Long> availableOrgs, int size) · listUserOrgs(int size, OrgData parent, boolean recursive, String groupNames) · browseUserOrgs(int size, Long parentId, boolean recursive, String groupNames)
getInstanceId()
Returns: String
Key this application instance is registered under in the application manager, always the fixed string "Reporting".
log(RootFolder rf, Request request, Response response, long duration)
Returns: String
Records this request/response pair as an access log entry, deriving the request path and referrer from the request itself. The entry is queued for asynchronous insertion and indexing rather than written immediately.
| Parameter | Description |
|---|---|
rf | the root folder the request was served from |
request | the request that was served |
response | the response that was returned |
duration | how long the request took to serve, in milliseconds |
log(RootFolder rf, Request request, Response response, long duration, String path, String referrerUrl, String contentType)
Returns: String
Records this request/response pair as an access log entry with an explicit path, referrer and content type, for callers that already know the response content type. The entry is queued for asynchronous insertion and indexing rather than written immediately.
| Parameter | Description |
|---|---|
rf | the root folder the request was served from |
request | the request that was served |
response | the response that was returned |
duration | how long the request took to serve, in milliseconds |
path | the request path, with any query string already removed |
referrerUrl | the referrer URL, with any query string already removed, may be null |
contentType | the response content type |
log(RootFolder rf, Request request, Response response, long duration, String path, String referrerUrl, String contentType, String trackingId)
Returns: String
Records this request/response pair as an access log entry with an explicit path, referrer, content type and tracking id, for callers that already have a tracking id for the visitor (e.g. from a tracking cookie). The entry is queued for asynchronous insertion and indexing rather than written immediately.
| Parameter | Description |
|---|---|
rf | the root folder the request was served from |
request | the request that was served |
response | the response that was returned |
duration | how long the request took to serve, in milliseconds |
path | the request path, with any query string already removed |
referrerUrl | the referrer URL, with any query string already removed, may be null |
contentType | the response content type |
trackingId | the visitor's tracking id, or null if not yet known |
getWebHitAppIndexer()
Returns: WebHitAppIndexer
Search indexer that stores and queries the web-hit access log entries recorded by this application, used by other apps that need to look up page view or web traffic data.
getRoles()
Returns: List<Role>
Roles this application registers: ReportRunnerRole, ReportingAccessRole and ReportsManagerRole, which together gate viewing, filtering and managing reporting artifacts.
getUserAgent()
Returns: UserAgentParserWrapper
Shared user agent string parser used to derive browser, OS and device details from a request's User-Agent header when logging or reporting on traffic.
getGeoIP()
Returns: GeoIpWrapper
Shared MaxMind GeoIP2 lookup wrapper used to resolve a request's IP address to a geographic location for logging and reporting.
getQueries()
Returns: List<QueryBean>
All saved queries available to the current organisation, used to populate report and dashboard components that pull data from a named query.
getQueryTables()
Returns: Iterable<Table>
All saved query tables available to the current organisation, the underlying data tables that saved queries are built on top of.
getQuery(String name)
Returns: QueryBean
Looks up one saved query by its source file name.
| Parameter | Description |
|---|---|
name | the query's source file name, matched exactly |
runQuery(QueryBean queryBean)
Returns: KSearchResponse
Executes a saved query against the search index using the default paging (all matching results), with query parameters taken from the current request.
| Parameter | Description |
|---|---|
queryBean | the saved query to execute |
runQuery(QueryBean queryBean, Integer from, Integer size)
Returns: KSearchResponse
Executes a saved query against the search index with explicit paging, with query parameters taken from the current request. This is an expensive call, as it performs a live search index query.
| Parameter | Description |
|---|---|
queryBean | the saved query to execute |
from | the offset of the first result to return, or null for the default offset |
size | the maximum number of results to return, or null for the default page size |
getQueryFieldNames(QueryBean queryBean)
Returns: List<String>
Names of the fields returned by a saved query, used to build column headers for a query table component.
| Parameter | Description |
|---|---|
queryBean | the saved query to inspect |
getGroups()
Returns: List<Group>
Groups belonging to the current organisation, used by report components that let a user filter or count members by group.
numUsers(String groupName)
Returns: Long
Counts the members of a named group in the current organisation, used by the numUsers report component.
| Parameter | Description |
|---|---|
groupName | the name of the group to count, looked up within the current organisation |
searchOrgs(String q)
Returns: List<OrgDatum>
Searches the organisations available to the current user by name or id prefix, for use in an org-picker component. This is an expensive call, as it performs a live search index query.
| Parameter | Description |
|---|---|
q | the search text; may contain several terms, each matched as a prefix against the org id and title |
listUserOrgs(Long parentId, List<Long> availableOrgs, int size)
Returns: KSearchResponse
Searches the org index for the direct or top-level children of an organisation, restricted to a set of available org ids. This is an expensive call, as it performs a live search index query.
| Parameter | Description |
|---|---|
parentId | the parent org id to list children of, or null to list top-level available orgs |
availableOrgs | the org ids the current user is allowed to see |
size | the maximum number of results to return |
listUserOrgs(int size, OrgData parent, boolean recursive, String groupNames)
Returns: List<OrgBean>
Lists the organisations the current user can browse under a given parent, optionally recursing into selected child orgs. This is an expensive call, as it performs a live search index query.
| Parameter | Description |
|---|---|
size | the maximum number of results to return at each level |
parent | the parent organisation to list children of, or null to list top-level available orgs |
recursive | if true, also fetch children of any org that is itself selected |
groupNames | names of groups to further restrict the available orgs to, or none for no restriction |
browseUserOrgs(int size, Long parentId, boolean recursive, String groupNames)
Returns: List<OrgBean>
Lists the organisations the current user can browse under a given parent id, optionally recursing into selected child orgs, restricted to a set of group names. This is an expensive call, as it performs a live search index query. This is the implementation behind listUserOrgs(int, OrgData, boolean, String...).
| Parameter | Description |
|---|---|
size | the maximum number of results to return at each level |
parentId | the parent org id to list children of, or null to list top-level available orgs |
recursive | if true, also fetch children of any org that is itself selected |
groupNames | names of groups to further restrict the available orgs to, or none for no restriction |