1

Currenlty i'm developing app using angular js but still figuring out how to send user's data to airbrake. I'm using ng-token-auth to handle the authorization (ng-token-auth)

This is my factory

'use strict';

app.factory('$exceptionHandler', ['$injector', function ($injector) {
    function log(exception, cause) {
      if (currentEnv === 'dev') {
        Airbrake.push({
           error : {
             message : exception.toString(),
             stack : exception.stack
           },
           params : {
             user : how_to_add_user_here
           }
         });
      }
    }
    return(log);
  }]
);

How I can inject the user to the factory?

Really appreciate your help.

Thanks

Community
  • 1
  • 1
Ardian
  • 155
  • 2
  • 11

1 Answers1

0
'use strict';

app.factory('$exceptionHandler', ['$injector', 'user', function ($injector, user) {
    function log(exception, cause) {
      if (currentEnv === 'dev') {
        Airbrake.push({
           error : {
             message : exception.toString(),
             stack : exception.stack
           },
           params : {
             user : user.name // for example
           }
         });
      }
    }
    return(log);
  }]
);
makeitmorehuman
  • 11,287
  • 3
  • 52
  • 76
  • That is my old question. it was the most helpful in finding the solution tho so i accepted this. Thanks a million for your answer! :) – Ardian Jul 24 '15 at 14:40