Sure:
Step 1:
Add the following to your client: (In my case /imports/startup/client/index.js)
Meteor.startup(function () {
let sentryURL = 'https://' + Meteor.settings.public.sentryPublicKey + '@sentry.io/' + Meteor.settings.public.sentryAppId;
let settings = {
release: commitInfo.appHash, // In my case this is the commit hash - but this can be a random string
environment: Meteor.settings.public.environment, // your environment prod / test / staging ... can also be a random string
autoBreadcrumbs: {
http: true // This is cool, auto clicks / navigations / etc.
},
shouldSendCallback: function(data) {
return commitInfo.appHash !== 'dev'; // here you can decide if you want to send the errors to Sentry (in my case if the appHash equals 'dev', I don't want to send the errors.
}
};
ravenClient.config(sentryURL, settings).install();
let originalMeteorDebug = Meteor._debug;
Meteor._debug = function(m, s) {
// We need to asign variables like this. Otherwise,
// we can't see proper error messages.
// See: https://github.com/meteorhacks/kadira/issues/193
var message = m;
var stack = s;
// We hate Meteor._debug (no single usage pattern)
if(message instanceof Error) {
ravenClient.captureException(message);
} else if(typeof message === 'string') {
let extra = {level: "error"};
//meteor._debug never seems to receive a stack here but just incase let's add it as context.
if(stack) {
extra.stack = stack;
} else {
//otherwise let's generate a stack trace
extra.stacktrace = true;
}
ravenClient.captureMessage(message, extra);
}
return originalMeteorDebug.apply(this, arguments);
};
});
Step 2 (optional):
Attach the account onLogin & onLogout to also track the user info. (add this in the same file)
Accounts.onLogin(function() {
ravenClient.setUserContext({
email: Meteor.user().emails[0].address,
id: Meteor.userId()
});
});
Accounts.onLogout(function() {
ravenClient.setUserContext();
});
Hope this helps!