Ghost/core/server/analytics-events.js
Aileen Nowak 23215e7d74 Added event to integrations when created (#10588)
no issue

- There was no model event being sent yet when a new integration is being created
- Added this event type to our analytics listener
2019-03-11 15:28:17 +01:00

38 lines
996 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'
},
{
event: 'integration.added',
name: 'Custom Integration Added'
}
];
_.each(toTrack, function (track) {
common.events.on(track.event, function () {
analytics.track(_.extend(trackDefaults, {event: prefix + track.name}));
});
});
};