Ghost/core/server/analytics-events.js
Aileen Nowak 93b936d2fb Added back "theme.uploaded" analytics event (#10450)
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
2019-02-05 17:38:40 +01:00

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}));
});
});
};