0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

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
This commit is contained in:
Aileen Nowak 2019-03-11 22:28:17 +08:00 committed by Katharina Irrgang
parent 160d50a258
commit 23215e7d74
2 changed files with 15 additions and 0 deletions

View file

@ -22,6 +22,10 @@ module.exports.init = function () {
{
event: 'theme.uploaded',
name: 'Theme Uploaded'
},
{
event: 'integration.added',
name: 'Custom Integration Added'
}
];

View file

@ -16,6 +16,11 @@ const Integration = ghostBookshelf.Model.extend({
};
},
emitChange: function emitChange(event, options) {
const eventToTrigger = 'integration' + '.' + event;
ghostBookshelf.Model.prototype.emitChange.bind(this)(this, eventToTrigger, options);
},
add(data, options) {
const addIntegration = () => {
return ghostBookshelf.Model.add.call(this, data, options)
@ -67,6 +72,12 @@ const Integration = ghostBookshelf.Model.extend({
}
},
onCreated: function onCreated(model, response, options) {
ghostBookshelf.Model.prototype.onCreated.apply(this, arguments);
model.emitChange('added', options);
},
permittedAttributes(...args) {
return ghostBookshelf.Model.prototype.permittedAttributes.apply(this, args).concat(this.relationships);
},