Wired referrers API data to admin dashboard (#15454)

closes https://github.com/TryGhost/Team/issues/1939

- adds real source data counts to attribution table and chart on dashboard
This commit is contained in:
Rishabh Garg 2022-09-22 16:51:41 +05:30 committed by GitHub
parent b048b02f67
commit 98fc808e6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -53,7 +53,7 @@ export default class SourceAttributionChart extends Component {
} else {
const sortedByPaid = [...this.sources];
sortedByPaid.sort((a, b) => {
return b.paidPercentage - a.paidPercentage;
return b.paidConversions - a.paidConversions;
});
return {
labels: sortedByPaid.slice(0, 5).map(source => source.source),

View File

@ -259,7 +259,7 @@ export default class DashboardStatsService extends Service {
}
return acc;
}, []).sort((a, b) => {
return (b.signups + b.paidConversions) - (a.signups - a.paidConversions);
return b.signups - a.signups;
});
}
@ -547,14 +547,22 @@ export default class DashboardStatsService extends Service {
*/
@task
*_loadMemberAttributionStats() {
this.memberAttributionStats = null;
this.memberAttributionStats = [];
if (this.dashboardMocks.enabled) {
yield this.dashboardMocks.waitRandom();
this.memberAttributionStats = this.dashboardMocks.memberAttributionStats;
return;
}
return;
let statsUrl = this.ghostPaths.url.api('stats/referrers/history');
let stats = yield this.ajax.request(statsUrl);
this.memberAttributionStats = stats.stats.map((stat) => {
return {
...stat,
paidConversions: stat.paid_conversions
};
});
}
loadMrrStats() {