diff --git a/modules/base/classes/settings.php b/modules/base/classes/settings.php index 9f46801d..70e403ca 100644 --- a/modules/base/classes/settings.php +++ b/modules/base/classes/settings.php @@ -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'] ) ); diff --git a/modules/base/handlers/refererHandlers.php b/modules/base/handlers/refererHandlers.php index 55e3b760..3c5320fd 100644 --- a/modules/base/handlers/refererHandlers.php +++ b/modules/base/handlers/refererHandlers.php @@ -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() ) { @@ -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); @@ -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(); } @@ -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; }