mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
Handled storing referrer information in DB
refs https://github.com/TryGhost/Team/issues/1931 - stores `referrer_source`, `referrer_medium` and `referrer_url` in event tables for new members and paid subscriptions
This commit is contained in:
parent
3b9998cdd6
commit
bb0d900937
@ -228,15 +228,15 @@ module.exports = class RouterController {
|
||||
}
|
||||
|
||||
if (attribution.refSource) {
|
||||
metadata.attribution_ref_source = attribution.refSource;
|
||||
metadata.referrer_source = attribution.refSource;
|
||||
}
|
||||
|
||||
if (attribution.refMedium) {
|
||||
metadata.attribution_ref_medium = attribution.refMedium;
|
||||
metadata.referrer_medium = attribution.refMedium;
|
||||
}
|
||||
|
||||
if (attribution.refUrl) {
|
||||
metadata.attribution_ref_url = attribution.refUrl;
|
||||
metadata.referrer_url = attribution.refUrl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,8 @@ const {MemberCreatedEvent, SubscriptionCreatedEvent} = require('@tryghost/member
|
||||
*/
|
||||
class EventStorage {
|
||||
/**
|
||||
*
|
||||
* @param {Object} deps
|
||||
*
|
||||
* @param {Object} deps
|
||||
* @param {Object} deps.labsService
|
||||
* @param {Object} deps.models
|
||||
* @param {Object} deps.models.MemberCreatedEvent
|
||||
@ -37,7 +37,10 @@ class EventStorage {
|
||||
attribution_id: attribution?.id ?? null,
|
||||
attribution_url: attribution?.url ?? null,
|
||||
attribution_type: attribution?.type ?? null,
|
||||
source: event.data.source
|
||||
source: event.data.source,
|
||||
referrer_source: attribution?.refSource ?? null,
|
||||
referrer_medium: attribution?.refMedium ?? null,
|
||||
referrer_url: attribution?.refUrl ?? null
|
||||
});
|
||||
});
|
||||
|
||||
@ -56,7 +59,10 @@ class EventStorage {
|
||||
created_at: event.timestamp,
|
||||
attribution_id: attribution?.id ?? null,
|
||||
attribution_url: attribution?.url ?? null,
|
||||
attribution_type: attribution?.type ?? null
|
||||
attribution_type: attribution?.type ?? null,
|
||||
referrer_source: attribution?.refSource ?? null,
|
||||
referrer_medium: attribution?.refMedium ?? null,
|
||||
referrer_url: attribution?.refUrl ?? null
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -226,7 +226,10 @@ module.exports = class WebhookController {
|
||||
const attribution = {
|
||||
id: session.metadata.attribution_id ?? null,
|
||||
url: session.metadata.attribution_url ?? null,
|
||||
type: session.metadata.attribution_type ?? null
|
||||
type: session.metadata.attribution_type ?? null,
|
||||
refSource: session.metadata.referrer_source ?? null,
|
||||
refMedium: session.metadata.referrer_medium ?? null,
|
||||
refUrl: session.metadata.referrer_url ?? null
|
||||
};
|
||||
|
||||
const payerName = _.get(customer, 'subscriptions.data[0].default_payment_method.billing_details.name');
|
||||
@ -254,7 +257,10 @@ module.exports = class WebhookController {
|
||||
const attribution = {
|
||||
id: session.metadata?.attribution_id ?? null,
|
||||
url: session.metadata?.attribution_url ?? null,
|
||||
type: session.metadata?.attribution_type ?? null
|
||||
type: session.metadata?.attribution_type ?? null,
|
||||
refSource: session.metadata.referrer_source ?? null,
|
||||
refMedium: session.metadata.referrer_medium ?? null,
|
||||
refUrl: session.metadata.referrer_url ?? null
|
||||
};
|
||||
|
||||
if (payerName && !member.get('name')) {
|
||||
|
Loading…
Reference in New Issue
Block a user