How to track exceptions in Meteor apps with Atatus
If you are building apps with Meteor, client-side error logging has become essential in creating stable apps. But collecting the right error information, when it occurs, isn’t always easy. We set out to fix this by seamlessly tracking client-side JavaScript errors with enough information to actually fix them!
In the recent past, technology has been changing rapidly. But, how we track and fix errors hasn’t changed that much specially for apps running live on production.
Let’s fix this!
Atatus makes this easy by receiving every exception that your meteor app throws, and captures the actions that triggers the specific error, such as how many characters the user keyed in as input and what the user clicked.
1.Install Atatus meteor integration package using
meteor add atatus:atatus
2.Add AtatusNotifier.initialize(settings)
to Meteor.startup()
on the client, ie:
Meteor.startup(function () {
AtatusNotifier.initialize({
client: {
apiKey: 'YOUR_API_KEY',
options: {
tags: ['paid_user', 'premium'],
customData: {
name: "John Doe",
plan: "premium",
beta_access: true
},
version: '1.0.0'
}
},
trackUser: true
});
});
where client.apiKey is your project’s API key. client.options is an advanced configuration to Atatus and it is optional.
By placing the above snippet in your code, all errors will be sent off to Atatus service for your perusal. Now you can start seeing your JS errors in Atatus. Along with capturing the error, we also capture the context and events related to the error.
Manually sending errors
Atatus can capture errors automatically. You can also manually notify error as follows
AtatusNotifier.notify(new Error('Test error'));
Optionally you can pass a custom data as second argument and tags as third argument:
AtatusNotifier.notify(new Error('Test error'), {
name: "John Doe",
plan: "premium",
beta_access: true
}, ['production', 'premium']);
Atatus also works very well with saving full error and exception stack traces. Simply pass an Error or a Meteor.Error object to the log method to keep the stack trace.
AtatusNotifier.notify(new Meteor.Error(422, 'Failed to save object to database'));
There’s also a bunch of other useful options available including unique user tracking, version tracking, tags and more – check out the documentation here for all the details.
Ready to get Atatus?
Atatus makes error tracking easier on your live Meteor applications with little effort along with user interactions that lead to the error. Try out the free 14 day trial – no credit card required. If you have any questions, we’d love to hear from you.