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.

Agent Installation

If you want to include Atatus script with your source, you can install using meteor integration package.

Installation

  1. Install Atatus meteor integration package using:

    copy
    icon/buttons/copy
    meteor add atatus:atatus
    
  2. Add AtatusNotifier.initialize(settings) to Meteor.startup() on the client, that is:

    copy
    icon/buttons/copy
    if (Meteor.isClient) {
      Meteor.startup(function () {
        AtatusNotifier.initialize({
          client: {
            apiKey: '0df5e8d5b5914dbd974b18ac036f9bb0',
            options: {
                tags: ['tag1', 'tag2'],
            }
          },
          trackUser: true
        });
      });
    }
    

Test Integration

To verify that your integration is working, call notify() in your application:

copy
icon/buttons/copy
atatus.notify(new Error('Test Atatus Setup'));

An error will appear in your project dashboard.

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:

copy
icon/buttons/copy
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.

copy
icon/buttons/copy
// Install Atatus Node Agent
npm install --save atatus-node

Initialize atatus in your meteor server as follows

copy
icon/buttons/copy
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

copy
icon/buttons/copy
AtatusNotifier.notify(new Error('Test error'));

Optionally you can pass a custom data as second argument and tags as third argument:

copy
icon/buttons/copy
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.

copy
icon/buttons/copy
AtatusNotifier.notify(new Meteor.Error(422, 'Failed to save object to database'));