Wired up source to conversions on analytics page

refs https://github.com/TryGhost/Team/issues/2157

- The source links to the referrer url if there is any
- A dash is used if no source is available
This commit is contained in:
Simon Backx 2022-10-25 14:30:40 +02:00
parent bd091c65c7
commit fee493af45
2 changed files with 26 additions and 2 deletions

View File

@ -58,7 +58,15 @@
</div>
{{#if (eq this.eventType "conversion")}}
<div class="gh-dashboard-list-item-sub">
Source
{{#if parsedEvent.source}}
{{#if parsedEvent.source.url}}
<a href={{parsedEvent.source.url}} rel="noopener noreferrer" target="_blank">{{parsedEvent.source.name}}</a>
{{else}}
<span>{{parsedEvent.source.name}}</span>
{{/if}}
{{else}}
<span class="midlightgrey">&mdash;</span>
{{/if}}
</div>
{{/if}}
<div class="gh-dashboard-list-item-sub">

View File

@ -18,6 +18,7 @@ export default class ParseMemberEventHelper extends Helper {
const object = this.getObject(event);
const url = this.getURL(event);
const timestamp = moment(event.data.created_at);
const source = this.getSource(event);
return {
memberId: event.data.member_id ?? event.data.member?.id,
@ -29,6 +30,7 @@ export default class ParseMemberEventHelper extends Helper {
action,
join,
object,
source,
info,
description,
url,
@ -226,6 +228,20 @@ export default class ParseMemberEventHelper extends Helper {
return '';
}
/**
* Clickable object, shown between action and info, or in a separate column in some views
*/
getSource(event) {
if (event.data?.attribution?.referrer_source) {
return {
name: event.data.attribution.referrer_source,
url: event.data.attribution.referrer_url ?? null
};
}
return null;
}
getInfo(event) {
if (event.type === 'subscription_event') {
let mrrDelta = getNonDecimal(event.data.mrr_delta, event.data.currency);