Added referrer attribution columns to events table (#15436)

refs TryGhost/Team#1931

- referrer source, medium and url will be stored in the events table along with rest of attribution data
- stores referrer information on two tables
  - `members_created_events` for signups
  - `members_subscription_created_events` for paid conversions
This commit is contained in:
Rishabh Garg 2022-09-21 19:01:36 +05:30 committed by GitHub
parent fe46bd05fb
commit b99c5428d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 5 deletions

View File

@ -0,0 +1,21 @@
const {createAddColumnMigration, combineNonTransactionalMigrations} = require('../../utils');
module.exports = combineNonTransactionalMigrations(
createAddColumnMigration('members_created_events', 'referrer_source', {
type: 'string',
maxlength: 191,
nullable: true
}),
createAddColumnMigration('members_created_events', 'referrer_medium', {
type: 'string',
maxlength: 191,
nullable: true
}),
createAddColumnMigration('members_created_events', 'referrer_url', {
type: 'string',
maxlength: 2000,
nullable: true
})
);

View File

@ -0,0 +1,21 @@
const {createAddColumnMigration, combineNonTransactionalMigrations} = require('../../utils');
module.exports = combineNonTransactionalMigrations(
createAddColumnMigration('members_subscription_created_events', 'referrer_source', {
type: 'string',
maxlength: 191,
nullable: true
}),
createAddColumnMigration('members_subscription_created_events', 'referrer_medium', {
type: 'string',
maxlength: 191,
nullable: true
}),
createAddColumnMigration('members_subscription_created_events', 'referrer_url', {
type: 'string',
maxlength: 2000,
nullable: true
})
);

View File

@ -497,6 +497,9 @@ module.exports = {
}
},
attribution_url: {type: 'string', maxlength: 2000, nullable: true},
referrer_source: {type: 'string', maxlength: 191, nullable: true},
referrer_medium: {type: 'string', maxlength: 191, nullable: true},
referrer_url: {type: 'string', maxlength: 2000, nullable: true},
source: {
type: 'string', maxlength: 50, nullable: false, validations: {
isIn: [['member', 'import', 'system', 'api', 'admin']]
@ -634,7 +637,10 @@ module.exports = {
isIn: [['url', 'post', 'page', 'author', 'tag']]
}
},
attribution_url: {type: 'string', maxlength: 2000, nullable: true}
attribution_url: {type: 'string', maxlength: 2000, nullable: true},
referrer_source: {type: 'string', maxlength: 191, nullable: true},
referrer_medium: {type: 'string', maxlength: 191, nullable: true},
referrer_url: {type: 'string', maxlength: 2000, nullable: true}
},
offer_redemptions: {
id: {type: 'string', maxlength: 24, nullable: false, primary: true},

View File

@ -266,7 +266,7 @@ exports[`Members API - member attribution Returns sign up attributions in activi
Object {
"access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "8544",
"content-length": "8874",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding",
@ -3546,7 +3546,7 @@ exports[`Members API Can subscribe to a newsletter 5: [headers] 1`] = `
Object {
"access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "4756",
"content-length": "4822",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding",

View File

@ -421,7 +421,7 @@ exports[`Members API Member attribution Returns subscription created attribution
Object {
"access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "13578",
"content-length": "14106",
"content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding",

View File

@ -35,7 +35,7 @@ const validateRouteSettings = require('../../../../../core/server/services/route
*/
describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = 'dbff9c0145b92f7c6b18af1029b8fe7e';
const currentSchemaHash = '999d625400e6d87efe0fd66e6bda4059';
const currentFixturesHash = '8cf221f0ed930ac1fe8030a58e60d64b';
const currentSettingsHash = '2978a5684a2d5fcf089f61f5d368a0c0';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';