GithubHelp home page GithubHelp logo

Comments (4)

snmaynard avatar snmaynard commented on May 12, 2024

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.

from bugsnag-laravel.

drekinov avatar drekinov commented on May 12, 2024

@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_init.php where i define a function and set all additional settings for Bugsnag PHP which are not supported through Bugsnag Service Provider:

$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 app/start/global.php like app/filters.php is included.
Probably that implementation is possible through additional service provider too.

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 Bugsnag::notifyException($exception); before returning Response::view, in case app.debug is false.
I hope that helps :)

from bugsnag-laravel.

pajcho avatar pajcho commented on May 12, 2024

@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.
Include helpers.php file in app/start/global.php

// 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.

from bugsnag-laravel.

snmaynard avatar snmaynard commented on May 12, 2024

@Jamesking56 have you resolved this now? Going to close but feel free to re-open & comment if you are still having issues!

from bugsnag-laravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.