Connehito / cake-sentry

CakePHP plugin integration for Sentry
MIT License
34 stars 26 forks source link

Exception not being sent to Sentry #23

Closed jtraulle closed 4 years ago

jtraulle commented 4 years ago

Hello,

I am trying to upgrade to the 2.x version of the plugin.

I have correctly setup everything but exception are not being sent to Sentry. Trying to understand what is going on, I succeeded to send the exception to Sentry if I replace

if (!Hash::get($config, 'before_send')) {
     $config['before_send'] = function () {
          $event = new Event('CakeSentry.Client.afterCapture', $this, func_get_args());
          $this->getEventManager()->dispatch($event);
     };
}

by

if (!Hash::get($config, 'before_send')) {
     $config['before_send'] = function ($event) {
         return $event;
     };
}

in the file vendor/connehito/cake-sentry/src/Http/Client.php


If I do not do that, when prepareEvent() function is called in vendor/sentry/sentry/src/Client.php, \call_user_func($this->options->getBeforeSendCallback(), $event); returns null instead of the expected object(Sentry\Event) causing the exception to not being sent to Sentry :(

Of course, swapping

'Sentry' => [
        'dsn' => env('SENTRY_DSN'),
    ],

to

'Sentry' => [
        'dsn' => env('SENTRY_DSN'),
        'before_send' => function ($event) {
            return $event;
        }
    ],

in app.php works as expected but this should not be necessary, right ?

Any idea why this is happening ? Thanks :wink:

o0h commented 4 years ago

Thanks for reporting the issue. Sorry for the late reply, I have been preparing to attend a conference in Japan on Dec 1st.

I investigate this, please wait for further information.

GrantAnt commented 4 years ago

Will there be soon a release or should I use version 1 of the package?

ToX82 commented 4 years ago

Same issue here.

@androideo , I've fixed it by reading the last part of this same issue, thus adding this to the Sentry configuration in config/app.php

    'before_send' => function ($event) {
        return $event;
    }