layout | title | description | permalink |
---|---|---|---|
docs |
Event logging |
Event logging |
/docs/pages/events/ |
This mechanism allows you to track important events happening in your code. You can also subscribe to a specific event to receive an email every time it occurs.
For example:
- A new user has registered
- A new email has been sent
- A robot has finished its jobs and you want to know what happened
You first need to install pmx, the prototype is then as simple as that:
pmx.emit(EVENT_NAME, DATA)
EVENT_NAME must be a string. DATA can be an object (an array will not work) or a string.
var pmx = require('pmx');
pmx.emit('user:register', {
user : 'Alex registered',
email : 'thorustor@gmail.com'
});
var pmx = require('pmx');
pmx.emit('content:page:created', 'A new page has been created');
To subscribe to an event just click on "Subscribe by mail to this event":