Skip to content

phuocdaivl/app-insights

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DaiDP Application Insights

Application Insight for Larvel

Latest Version on Packagist Software License Build Status Total Downloads

This library uses the official Application Insights PHP API. To get started, you should have a basic knowledge of how Application Insights works (Tracking Event, Tracking Error, Tracking PageView, Tracking Request, ...).

Download & Install

composer require phuocdaivl/app-insights

Add service provider

Add the service provider to the providers array in the config/app.php config file as follows:

'providers' => [

    ...

    DaiDP\AppInsights\Providers\AzureAppInsightsProvider::class,
]

Well done.

Handle Error

Open file app/Exceptions/Handler.php and add following code:

public function render($request, Exception $exception)
{
    $telemetry = app()->get(\DaiDP\AppInsights\TelemetryClient::class);
    $telemetry->trackException($exception);
    $telemetry->flush();
    
    ...
}

Log customize error

  • Add log from try catch
try {
  // To do something
  ...
} catch(\Exception $ex) {
    $telemetry = app()->get(\DaiDP\AppInsights\TelemetryClient::class);
    $telemetry->trackException($ex);
    $telemetry->flush();
}
  • Add any customize log
$ex = new Exception('Some message');

$telemetry = app()->get(\DaiDP\AppInsights\TelemetryClient::class);
$telemetry->trackException($ex);
$telemetry->flush();

About

Application Insights for Laravel Framework

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages