Download the PHP package code16/metrics without Composer
On this page you can find all versions of the php package code16/metrics. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download code16/metrics
More information about code16/metrics
Files in code16/metrics
Package metrics
Short Description Metrics Package for Laravel
License MIT
Homepage https://code16.fr
Informations about the package metrics
Metrics
Metrics is a Laravel 5 package aimed at logging visitor's usage of your web application and provides an ensemble of classes and functionnality to help you generate statistics out of it.
It is compliant with EU
regulations regarding privacy, and GDPR-Ready
.
Installation
You can install the metrics package by typing the following command :
Configuration
THe package ships with a set of ready-to-user Analyzers
that are included in default's config file. If you want to customize it, just publish using the appropriate artisan command :
Tracking
Metrics
works by placing a tracking cookie on the user's device, which will be linked to a specific user_id when a user is logged in, so there will be a unique identifier for a single user, whichever device he's using, and the cookie will stay on after a user has logged out, meaning that you can reconstruct a user's sequence before, or after he was logged into the application.
By default, Metrics
will log any route accessed within the application, with the exception of when the user has a Do Not Track
header set to true. If you do not wish a specific route or group of route to be logged, you can use the included NoTrackingMiddleware
, or add a filter in config.
Actions
Actions
are an important concept in Metrics
. They give you the opportunity to highlight and gather data for further statistic analyzis on some important part of your application. They are very similar to events in how they work, and they are serialized in the metrics_visits
table.
For example, you can create an action class for everytime a user add a product to his cart :
Then, you can attach the action to the current Visit object, by calling the following method on the manager class :
Alternatively, you can use the helper function :
Analyzers & Consoliders
On top of logging your user's visits into a table, Metrics
comes with a little "framework" which aims to help you extract statistics from these raw informations. It come out of the box with some basic statistics functions that will for example count the number of unique visitors or analysis the repartition of your users by browser or user agent.
There are two distinct operations that Metrics
handles :
Analyze
: This operation will produce a statistic array from raw Visit
records. Basically metrics passes all rows from the metrics_visit
table and listen and store statistics data that is calculated from these raw visit log.
Consolidate
: This operation takes several results from several smaller time periods into a larger one.
Raw data are analyzed and consolidated into four incremental time periods :
- Hour
- Day
- Month
- Year
For some example on how to write custom analyzers/consoliders for your application, you can look into the classes which are included in the package (Code16\Metrics\Analyzers).
Updating statistics
To calculate and update the statistics, simply run artisan metrics:update
at any time. Doing so will calculate statistics for all complete period (last hour, last day, last month..), that haven't been calculated yet. TIP : If you implement new Analyzers
during the application lifetime, and you want to calculate statistics on previous period, simply truncate metric_metrics
table and run another update.
All versions of metrics with dependencies
illuminate/support Version ^11.0
jenssegers/agent Version ^2.3
doctrine/dbal Version ^3.0