generated from astrogoat/app-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add frontend and backend integrations
- Loading branch information
Showing
14 changed files
with
295 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,57 @@ | ||
<?php | ||
// config for Astrogoat/Sentry | ||
|
||
return [ | ||
/* | ||
* If you want to override the automatic injection of views | ||
* into some areas of your application so you to include | ||
* them yourself then you disable each in this array. | ||
*/ | ||
'include-frontend-views' => [ | ||
'head' => true, | ||
'body' => true, | ||
'end' => true, | ||
] | ||
|
||
'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), | ||
|
||
// capture release as git sha | ||
'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')), | ||
|
||
// When left empty or `null` the Laravel environment will be used | ||
'environment' => env('SENTRY_ENVIRONMENT'), | ||
|
||
'breadcrumbs' => [ | ||
// Capture Laravel logs in breadcrumbs | ||
'logs' => true, | ||
|
||
// Capture SQL queries in breadcrumbs | ||
'sql_queries' => true, | ||
|
||
// Capture bindings on SQL queries logged in breadcrumbs | ||
'sql_bindings' => true, | ||
|
||
// Capture queue job information in breadcrumbs | ||
'queue_info' => true, | ||
|
||
// Capture command information in breadcrumbs | ||
'command_info' => true, | ||
], | ||
|
||
'tracing' => [ | ||
// Trace queue jobs as their own transactions | ||
'queue_job_transactions' => env('SENTRY_TRACE_QUEUE_ENABLED', false), | ||
|
||
// Capture queue jobs as spans when executed on the sync driver | ||
'queue_jobs' => true, | ||
|
||
// Capture SQL queries as spans | ||
'sql_queries' => true, | ||
|
||
// Try to find out where the SQL query originated from and add it to the query spans | ||
'sql_origin' => true, | ||
|
||
// Capture views as spans | ||
'views' => true, | ||
|
||
// Indicates if the tracing integrations supplied by Sentry should be loaded | ||
'default_integrations' => true, | ||
], | ||
|
||
// @see: https://docs.sentry.io/platforms/php/configuration/options/#send-default-pii | ||
'send_default_pii' => env('SENTRY_SEND_DEFAULT_PII', false), | ||
|
||
'traces_sample_rate' => (float) (env('SENTRY_TRACES_SAMPLE_RATE', 0.0)), | ||
|
||
'controllers_base_namespace' => env('SENTRY_CONTROLLERS_BASE_NAMESPACE', 'App\\Http\\Controllers'), | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
{ | ||
"/public/js/sentry.js": "/public/js/sentry.js", | ||
"/public/css/sentry.css": "/public/css/sentry.css" | ||
"/public/js/sentry.js": "/public/js/sentry.js" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
// Javascript file for sentry | ||
import * as Sentry from "@sentry/browser"; | ||
|
||
window.Sentry = Sentry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@if(app()->bound('sentry') && Astrogoat\Sentry\Settings\SentrySettings::isEnabled()) | ||
@php $user = auth()->user(); @endphp | ||
<script src="{{ asset('vendor/sentry/js/sentry.js') }}" defer></script> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', () => { | ||
Sentry.setUser({ | ||
email: "{{ $user->email }}", | ||
fullName: "{{ $user->name }}", | ||
}); | ||
Sentry.init({ | ||
dsn: "{{ config('sentry.dsn') }}", | ||
environment: "{{ app()->environment() }}", | ||
beforeSend(event, hint) { | ||
// Check if it is an exception, and if so, show the report dialog | ||
if (event.exception && event.event_id) { | ||
Sentry.showReportDialog({ eventId: event.event_id }); | ||
} | ||
return event; | ||
}, | ||
integrations: [ | ||
Sentry.feedbackIntegration({ | ||
// Additional SDK configuration goes in here, for example: | ||
colorScheme: "system", | ||
showName: false, | ||
showEmail: false, | ||
useSentryUser: { | ||
email: "email", | ||
name: "fullName", | ||
}, | ||
}), | ||
Sentry.browserTracingIntegration(), | ||
], | ||
tracesSampleRate: {{ config('sentry.traces_sample_rate', 0.0) }}, | ||
}); | ||
}); | ||
</script> | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@if(app()->bound('sentry') && Astrogoat\Sentry\Settings\SentrySettings::isEnabled()) | ||
<script src="{{ asset('vendor/sentry/js/sentry.js') }}" defer></script> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', () => { | ||
Sentry.init({ | ||
dsn: "{{ config('sentry.dsn') }}", | ||
environment: "{{ app()->environment() }}", | ||
integrations: [ | ||
Sentry.browserTracingIntegration(), | ||
], | ||
tracesSampleRate: {{ config('sentry.traces_sample_rate', 0.0) }}, | ||
}); | ||
}); | ||
</script> | ||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Astrogoat\Sentry\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
use Astrogoat\Sentry\Settings\SentrySettings; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class AddAdditionalSentryInfo | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next | ||
*/ | ||
public function handle(Request $request, Closure $next): Response | ||
{ | ||
if (app()->bound('sentry') && SentrySettings::isEnabled()) { | ||
\Sentry\configureScope(function (\Sentry\State\Scope $scope): void { | ||
$scope->setTag('tenant.name', tenant()->name ?? 'Central'); | ||
$scope->setTag('tenant.id', tenant()->id ?? 'central'); | ||
|
||
if (auth()->check()) { | ||
$user = auth()->user(); | ||
|
||
$scope->setUser([ | ||
'id' => $user->id, | ||
'username' => $user->name, | ||
'email' => $user->email, | ||
'strata_user_id' => strata_user_id(), | ||
]); | ||
} else { | ||
$scope->setUser([ | ||
'id' => strata_user_id(), | ||
]); | ||
} | ||
}); | ||
} | ||
|
||
return $next($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.