mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-03 00:15:11 +03:00
3e228072ba
refs https://github.com/TryGhost/Ghost/issues/12608 - adds `admin/canary/themes/install` endpoint to the Admin API - requires two query params. `source` must be set to "github". `ref` should refer to a GitHub repo in the format "{org}/{repo}" - downloads zip archive for the repo from github - runs downloaded zip through the same process as uploaded zips
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
const _ = require('lodash');
|
|
const Analytics = require('analytics-node');
|
|
const config = require('../shared/config');
|
|
const {events} = require('./lib/common');
|
|
|
|
module.exports.init = function () {
|
|
const analytics = new Analytics(config.get('segment:key'));
|
|
const trackDefaults = config.get('segment:trackDefaults') || {};
|
|
const prefix = config.get('segment:prefix') || '';
|
|
|
|
const toTrack = [
|
|
{
|
|
event: 'post.published',
|
|
name: 'Post Published'
|
|
},
|
|
{
|
|
event: 'page.published',
|
|
name: 'Page Published'
|
|
},
|
|
{
|
|
event: 'theme.uploaded',
|
|
name: 'Theme Uploaded',
|
|
// {keyOnSuppliedEventData: keyOnTrackedEventData}
|
|
// - used to extract specific properties from event data and give them meaningful names
|
|
data: {name: 'name'}
|
|
},
|
|
{
|
|
event: 'integration.added',
|
|
name: 'Custom Integration Added'
|
|
}
|
|
];
|
|
|
|
_.each(toTrack, function (track) {
|
|
events.on(track.event, function (eventData = {}) {
|
|
// extract desired properties from eventData and rename keys if necessary
|
|
const data = _.mapValues(track.data || {}, v => eventData[v]);
|
|
|
|
analytics.track(_.extend(trackDefaults, data, {event: prefix + track.name}));
|
|
});
|
|
});
|
|
};
|