Skip to content

Commit

Permalink
allow for slowing changing referer medium
Browse files Browse the repository at this point in the history
  • Loading branch information
padams committed Jan 24, 2022
1 parent 0d5740c commit b04fbb0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions modules/base/classes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ private function getDefaultSettingsArray() {
'archive_old_events' => true, // used by event queues to archive processed events.
'request_mode' => 'web_app',
'useStaticConfigOnly' => false,
'allow_slowly_changing_dimensions' => true,
'db_supported_types' => ['mysql' => 'MySQL']
)
);
Expand Down
21 changes: 18 additions & 3 deletions modules/base/handlers/refererHandlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ function notify($event) {
$r = owa_coreAPI::entityFactory('base.referer');

$r->load( $event->get( 'referer_id' ) );

$medium = $event->get('medium');

if ( ! $r->wasPersisted() ) {

Expand All @@ -68,8 +70,6 @@ function notify($event) {

$r->set( 'site', $url['host'] );

$medium = $event->get('medium');

if ( $medium === 'organic-search' ) {

$r->set('is_searchengine', true);
Expand All @@ -79,7 +79,8 @@ function notify($event) {
$r->set('page_title', '(not set)');

// Crawl and analyze refering page
if ($medium != 'organic-search' ) {
if ( $medium != 'organic-search' || $medium != 'social-network' ) {

$r->crawlReferer();
}

Expand All @@ -93,6 +94,20 @@ function notify($event) {
}

} else {

// check and update medium if it's new
// @todo make this check for a "allow_slowly_changing_dimensions" setting flag

if ( owa_coreAPI::getSetting('base', 'allow_slowly_changing_dimensions') ) {

if ( $medium != $r->get( 'medium' ) ) {

$r->set( 'medium', $medium );
$r->save();
owa_coreAPI::debug("Updating Referrer medium to be: $medium");
}
}

owa_coreAPI::debug('Not Persisting. Referrer already exists.');
return OWA_EHS_EVENT_HANDLED;
}
Expand Down

0 comments on commit b04fbb0

Please sign in to comment.