New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setBeforeNotifyFunction is not working. #12
Comments
Is there nothing in the logs that show what went wrong? We use call_user_func to call the function, so if the function isnt a global we wont be able to call it. If you add a log message into the function to double check it is being successfully called it should help scope the issue. |
@Jamesking56 could you try different approach to set beforeNotify function. I am not sure that composer autoloader is correct way. My implementation is to create $app['bugsnag']->setBeforeNotifyFunction("before_bugsnag_notify");
$app['bugsnag']->setType("laravel");
if (!function_exists('before_bugsnag_notify')) {
function before_bugsnag_notify(Bugsnag_Error $error) { .... } Moreover you should include that file in Moreover in staging and production you probably would return some user friendly page for generic not catched exceptions in: App::error(function (Exception $exception, $code) { ... } If App::error return Response::view then Bugsnag does not log any error or exception so be sure that App::error has |
@Jamesking56 Here is how I created it and I can confirm this works: I created new file just for bugsnag, but your helpers.php will do the job. // Put this at end of global.php file
require app_path().'/LicenseApp/helpers.php'; Your helpers.php file should look like this: function bugsnagBefore($error)
{
$data = ['user' => null];
if (\Auth::check()) {
$data['user'] = [
'name' => \Auth::user()->username,
'email' => \Auth::user()->email
];
} else {
$data['user'] = [
'name' => 'Guest'
];
}
$error->setMetaData($data);
}
Bugsnag::setBeforeNotifyFunction("bugsnagBefore"); And that's it!! Just invoke any Exception and it will work!! Hope this helps you. |
@Jamesking56 have you resolved this now? Going to close but feel free to re-open & comment if you are still having issues! |
Hello,
I have a Laravel 4.1 application and I have added BugSnag-Laravel to it.
Unfortunately, the setBeforeNotifyFunction isn't working.
Here is my function I created in my
helpers.php
file which is autoloaded using composer:helpers.php
is autoloaded in composer:Then, I told BugSnag about my function in my
App::before
filter:This however, doesn't work. The extra information doesn't appear in BugSnag. Any reason why?
The text was updated successfully, but these errors were encountered: