| 1 | package Sentry::Integration; | ||
| 2 | use Mojo::Base -base, -signatures; | ||
| 3 | |||
| 4 | use Sentry::Hub; | ||
| 5 | use Sentry::Integration::DBI; | ||
| 6 | use Sentry::Integration::DieHandler; | ||
| 7 | use Sentry::Integration::MojoUserAgent; | ||
| 8 | use Sentry::Integration::LwpUserAgent; | ||
| 9 | |||
| 10 | my @Global_integrations = ( | ||
| 11 | Sentry::Integration::DieHandler->new, | ||
| 12 | Sentry::Integration::DBI->new, | ||
| 13 | Sentry::Integration::MojoUserAgent->new, | ||
| 14 | Sentry::Integration::LwpUserAgent->new, | ||
| 15 | ); | ||
| 16 | |||
| 17 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||
| 18 | sub _add_global_event_processor ($cb) { | ||
| 19 | Sentry::Hub->get_current_scope->add_event_processor($cb); | ||
| 20 | } | ||
| 21 | |||
| 22 | sub setup ($package, $custom_integrations = []) { | ||
| 23 | my @all_integrations = (@Global_integrations, $custom_integrations->@*); | ||
| 24 | foreach my $integration (@all_integrations) { | ||
| 25 | $integration->setup_once( | ||
| 26 | Sentry::Integration->can('_add_global_event_processor'), | ||
| 27 | Sentry::Hub->can('get_current_hub')); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; |