Ghost/ghost/admin/app/components/posts/post-activity-feed.js
Simon Backx b916300ceb
Added aggregated click events (#15713)
fixes https://github.com/TryGhost/Team/issues/2175

- New event type `aggregated_click_event` that is disabled by default in all the existing activity feeds
- This returns click events, but only the first click events for each member/post combination.
- It includes the total count of unique link clicks for that member on that post combination
- Had to resort to some custom knex queries to make this work easily
- Requires `@tryghost/bookshelf-pagination@0.1.31`, included in `@tryghost/bookshelf-plugins@0.6.1` (this fixes an issue with custom selects breaking the total count query of pages)
- Went a bit overboard with the pagination tests to cover as much unknown edge cases as possible
2022-10-27 17:23:45 +02:00

68 lines
1.6 KiB
JavaScript

import Component from '@glimmer/component';
import {action} from '@ember/object';
const eventTypes = {
sent: ['email_sent_event'],
opened: ['email_opened_event'],
clicked: ['aggregated_click_event'],
feedback: ['feedback_event'],
conversion: ['subscription_event', 'signup_event']
};
export default class PostActivityFeed extends Component {
tooltipNode = null;
_pageSize = 5;
get getEventTypes() {
return eventTypes[this.args.eventType];
}
get pageSize() {
return this._pageSize;
}
@action
onTooltipInsert(node) {
this.tooltipNode = node;
}
@action
onMouseleave() {
this.tooltipNode.style.opacity = '0';
this.tooltipNode.style.position = 'fixed';
this.tooltipNode.style.left = '2000';
}
get eventType() {
return this.args.eventType;
}
// calculate amount of empty rows which require to keep table height the same for each tab/page
@action
getAmountOfStubs({data}) {
const stubs = this._pageSize - data.length;
return new Array(stubs).fill(1);
}
@action
isPreviousButtonDisabled({hasReachedStart, isLoading}) {
return hasReachedStart || isLoading;
}
@action
isNextButtonDisabled({hasReachedEnd, isLoading}) {
return hasReachedEnd || isLoading;
}
@action
isPaginationNotNeeded({totalEvents}) {
return (totalEvents <= this._pageSize);
}
@action
areStubsNeeded({totalEvents}) {
return totalEvents > this._pageSize || this.args.eventType === 'feedback';
}
}