Add Atatus Laravel Middleware steps
- Make sure the Atatus PHP agent is installed on your host. If not, follow the installation steps to install the Atatus PHP agent.
-
Install/Config the atatus middleware
Option 1: Install the laravel package using composer.
Option 2: Add
atatus/laravel-atatusto your project’s composer.json file, and install composer. -
Add Atatus provider to service provider in
config/app.phpfile. -
Add Atatus middleware in your
App/Http/Kernel.phpfileIf you only want to add tracking for APIs under specific route group, add to your route group, but be sure to remove from the global Middleware stack from above global list.To track only certain routes, use route specific middleware setup. -
Publish the package config file.
-
Add configuration in
config/atatus.phpfile.
Configuration options
You can define Atatus configuration options in theconfig/atatus.php file.
Configuration class (Optional)
Because configuration hooks and functions cannot be placed in theconfig/atatus.php file, these reside in a PHP class that you create.
Set the path to this class using the configClass option. You can define any of the following hooks:
-
identifyUserId
Type:($request, $response) => StringOptional, a function that takes a $request and $response and return a string for userId. Atatus automatically obtains end userId via$request->user()['id'], In case you use a non standard way of injecting user into $request or want to override userId, you can do so with identifyUserId. -
identifyCompanyId
Type:($request, $response) => StringOptional, a function that takes a $request and $response and return a string for companyId. -
maskRequestBody
Type:$body => $bodyOptional, a function that takes a $body, which is an associative array representation of JSON, and returns an associative array with any information removed. -
maskResponseBody
Type:$body => $bodyOptional, same as above, but for Responses.