Skip to content

Instantly share code, notes, and snippets.

@arenowebdev
Created August 29, 2016 21:11
Show Gist options
  • Save arenowebdev/d67dd609ecff5d6cae55febb8f64c383 to your computer and use it in GitHub Desktop.
Save arenowebdev/d67dd609ecff5d6cae55febb8f64c383 to your computer and use it in GitHub Desktop.
Sentry .env in Laravel
<?php
// In .env:
SENTRY_PRIVATE_DSN=https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy@app.getsentry.com/#####
SENTRY_PUBLIC_DSN=https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@app.getsentry.com/#####
// On our config server, each environment receives their own version of the .env file
// Depending upon the environment being deployed to, we grab that config and place it
// within the app directory. Now when the sentry config is used, it will have the environment
// specific configuration and will report exceptions for the environment that is being
// tested against.
// /config/sentry.php
return [
'public_dsn' => env('SENTRY_PUBLIC_DSN'),
'dsn' => env('SENTRY_PRIVATE_DSN'),
'release' => trim(exec('git describe --tags --always --long')),
];
// app/Exceptions/Handler.php
// ...
public function report(Exception $e)
{
if ($this->shouldReport($e)) {
app('sentry')->captureException($e);
}
return parent::report($e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment