PHP code example of techies-africa / laravel_trakker

1. Go to this page and download the library: Download techies-africa/laravel_trakker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

techies-africa / laravel_trakker example snippets




namespace TechiesAfrica\LaravelTrakker\Middlewares;

use TechiesAfrica\LaravelTrakker\Services\TrakkerService;
use Closure;
use Illuminate\Http\Request;

class TrakkerMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        $tracker = TrakkerService::tracker();
        // $tracker->setIgnoreRoutes([
        //     "web.read_file"
        // ]);
        // $tracker->setAuthenticatedMiddlewares(["auth" , "admin" , "verified"]);
        // $tracker->setIgnoreMiddlewares(["Barryvdh\Debugbar\Middleware\DebugbarEnabled"]);
        // $tracker->setUserFields(["id" => "id", "name" => "full_name", "email" => "email"]);
        // $tracker->setShouldLog(false);
        $tracker->preRequest($request);

        $response =  $next($request);

        // TrakkerService::log("pushing data");
        $tracker->postRequest($request)
            ->push();

        return $response;
    }
}



TRAKKER_BASE_URL="https://trakker.techies.africa"
TRAKKER_APP_KEY="*************"
TRAKKER_APP_SECRET="********"
TRAKKER_LOG_CHANNEL="stack"