Meteor Integration
Meteor is a complete platform for building web and mobile apps in pure JavaScript. Atatus provides meteor package for monitoring errors and performance of your meteor apps.
Meteor Client Installation
To track meteor errors and performances in Meteor client, you have to install Atatus meteor integration package using
meteor add atatus:atatus
Add AtatusNotifier.initialize(settings)
to Meteor.startup()
on the client, ie:
if (Meteor.isClient) {
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.
If you are using the Meteor Accounts package, you can enable user tracking on errors with trackUser
option.
Meteor Server Installation
To track meteor errors in Meteor server, you need to create Node.js APM project and install Atatus Node.js agent.
// Install Atatus Node Agent
npm install --save atatus-node
Initialize atatus in your meteor server as follows
if (Meteor.isServer) {
var atatus = require("atatus-node");
// var atatus = Meteor.npmRequire("atatus-node"); // For older meteor
atatus.start({
apiKey: 'NODE_PROJECT_API_KEY',
beforeErrorSend: function (payload) {
// Remove stack trace from error message.
if (payload.exceptions && payload.exceptions[0] &&
payload.exceptions[0].message) {
var message = payload.exceptions[0].message;
var atIndex = message.indexOf(' at');
if (atIndex > 10) {
message = message.substring(0, atIndex);
payload.exceptions[0].message = message;
}
}
return true;
}
});
var consoleLogOrig = console.log;
console.log = function (message) {
// special case for meteor dev mode
if(message === 'LISTENING') {
return consoleLogOrig.call(console, 'LISTENING');
}
if (typeof message === 'string' && message.indexOf('Exception') === 0) {
atatus.notifyError(message);
}
consoleLogOrig.apply(console, arguments);
};
}
Notify Error from Meteor Client
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'));