Giter Club home page Giter Club logo

esplora's Introduction

Esplora Esplora - Easy Tracker Visits

Esplora is an open-source package for Laravel with which you can easily collect visitor analytics. All analytic data about website visitors that the package contains and structures belong solely to the website owner. Don't sell your users! Use your own private storage.

How It Works

After the client has received a useful response from the server, we process his request by collecting and write to the database the following information:

  • Requested URL
  • IP address
  • Device (Mobile, Desktop, Tablet, Robot)
  • Platform (Ubuntu, Windows, OS X)
  • Browser (Chrome, IE, Safari, Firefox)
  • Preferred Language
  • Referer

Installation

You may install Esplora into your project using the Composer package manager:

composer require esplora/esplora

Next, you should publish the Esplora configuration and migration files using the vendor:publish Artisan command. The esplora.php configuration file will be placed in your application's config directory:

php artisan vendor:publish --provider="Esplora\Tracker\EsploraServiceProvider.php"

Finally, you should run your database migrations. Esplora will create database tables in which to store users visits:

php artisan migrate

Next, if you plan to utilize Esplora to tracking web requests, you should add middleware to your web middleware group within your application's app/Http/Kernel.php file:

'web' => [
    \App\Http\Middleware\EncryptCookies::class,
    \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
    \Illuminate\Session\Middleware\StartSession::class,
    // \Illuminate\Session\Middleware\AuthenticateSession::class,
    \Illuminate\View\Middleware\ShareErrorsFromSession::class,
    \App\Http\Middleware\VerifyCsrfToken::class,
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
    
    //new Esplora:
    \Esplora\Tracker\Middleware\Tracking::class,
],

Or set for a specific route:

use Esplora\Tracker\Middleware\Tracking;

Route::get('about', function (){
  // code
})->middleware(Tracking::class);

Configuration

After publishing Esplora's assets, its primary configuration file will be located at config/esplora.php. This configuration file allows you to configure the request tracking options for your application. Each configuration option includes a description of its purpose, so be sure to explore this file thoroughly.

Executing Goals

Goals allow you to track important events on the site: clicks on buttons, views of certain pages, downloading files, submitting forms, and many others. You can define a target as completed with a simple call:

use Esplora\Tracker\Facades\Tracker;

Tracker::goal('Dark theme', [
    'enabled' => false,
]);

Batch Import

With many visits, the number of Insert queries to the database can take up a lot of server resources. To do this, you can use an intermediate Redis store, from which information will then be inserted in batches.

php artisan esplora:insert

You may define the time of recording to permanent storage using a schedule of scheduled tasks in the schedule method of your application's App\Console\Kernel class. For example, every 10 minutes:

$schedule->command('esplora:insert')->everyTenMinutes();

Data Pruning

Without pruning, the esplora_visits and esplora_goals tables can accumulate records very quickly. To mitigate this, you should schedule the model:prune Artisan command to run daily:

use Esplora\Tracker\Models\Visit;
use Esplora\Tracker\Models\Goal;

$schedule->command('model:prune', [
    '--model' => [Visit::class, Goal::class],
])->daily();

License

The MIT License (MIT). Please see License File for more information.

esplora's People

Contributors

sadelephant avatar tabuna avatar taylorotwell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.