6f6c8f4521
refs #9178 - avoid importing 4 modules (logging, errors, events and i18n) - simply require common in each file
70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
var _ = require('lodash'),
|
|
Analytics = require('analytics-node'),
|
|
config = require('./config'),
|
|
common = require('./lib/common'),
|
|
analytics;
|
|
|
|
module.exports.init = function () {
|
|
analytics = new Analytics(config.get('segment:key'));
|
|
var toTrack,
|
|
trackDefaults = config.get('segment:trackDefaults') || {},
|
|
prefix = config.get('segment:prefix') || '';
|
|
|
|
toTrack = [
|
|
{
|
|
event: 'post.added',
|
|
name: 'Blog Post Created'
|
|
},
|
|
{
|
|
event: 'post.published',
|
|
name: 'Blog Post Published'
|
|
},
|
|
{
|
|
event: 'page.published',
|
|
name: 'Blog Page Published'
|
|
},
|
|
{
|
|
event: 'user.added',
|
|
name: 'User Invite Sent'
|
|
},
|
|
{
|
|
event: 'user.activated',
|
|
name: 'User Invite Activated'
|
|
},
|
|
{
|
|
event: 'user.activated.edited',
|
|
name: 'User Account Updated'
|
|
},
|
|
{
|
|
event: 'subscriber.added',
|
|
name: 'New Subscriber Added'
|
|
},
|
|
{
|
|
event: 'token.added',
|
|
name: 'Access Token Added'
|
|
},
|
|
{
|
|
event: 'setup.completed',
|
|
name: 'Created Owner Account'
|
|
},
|
|
{
|
|
event: 'theme.uploaded',
|
|
name: 'Uploaded Theme'
|
|
},
|
|
{
|
|
event: 'theme.downloaded',
|
|
name: 'Downloaded Theme'
|
|
},
|
|
{
|
|
event: 'theme.deleted',
|
|
name: 'Deleted Theme'
|
|
}
|
|
];
|
|
|
|
_.each(toTrack, function (track) {
|
|
common.events.on(track.event, function () {
|
|
analytics.track(_.extend(trackDefaults, {event: prefix + track.name}));
|
|
});
|
|
});
|
|
};
|