93b936d2fb
no issue
- With the changes in 79ca6c575c
we removed old unused events
- The theme upload event is still used and needed to be put back
- Added the event emit right after the successful upload of the theme
- Renamed analytics events for more consistency
- We need to add the same event emitter to the v0.1 API as it's not deprecated
- emits a `theme.uploaded` event after the theme was successfully uploaded and saved
34 lines
890 B
JavaScript
34 lines
890 B
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.published',
|
|
name: 'Post Published'
|
|
},
|
|
{
|
|
event: 'page.published',
|
|
name: 'Page Published'
|
|
},
|
|
{
|
|
event: 'theme.uploaded',
|
|
name: 'Theme Uploaded'
|
|
}
|
|
];
|
|
|
|
_.each(toTrack, function (track) {
|
|
common.events.on(track.event, function () {
|
|
analytics.track(_.extend(trackDefaults, {event: prefix + track.name}));
|
|
});
|
|
});
|
|
};
|