Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow hooking Analytics and modifying prior to send.

  • Loading branch information...
commit d9a0316a28b27462eeb8e581b424147b4cf1cefe 1 parent 5452f23
@kaecyra kaecyra authored
Showing with 14 additions and 8 deletions.
  1. +14 −8 library/core/class.statistics.php
View
22 library/core/class.statistics.php
@@ -42,6 +42,12 @@ public function Analytics($Method, $RequestParameters, $Callback = FALSE) {
$ApiMethod
));
+ // Allow hooking of analytics events
+ $this->EventArguments['AnalyticsMethod'] = &$Method;
+ $this->EventArguments['AnalyticsArgs'] = &$RequestParameters;
+ $this->EventArguments['AnalyticsUrl'] = &$FinalURL;
+ $this->FireEvent('SendAnalytics');
+
// Sign request
$this->Sign($RequestParameters, TRUE);
@@ -355,10 +361,10 @@ public function Register() {
}
public function SettingsController_AnalyticsTick_Create($Sender) {
- Gdn::Statistics()->Tick();
- $Sender->DeliveryType(DELIVERY_TYPE_VIEW);
$Sender->DeliveryMethod(DELIVERY_METHOD_JSON);
-
+ $Sender->DeliveryType(DELIVERY_TYPE_DATA);
+
+ Gdn::Statistics()->Tick();
$this->FireEvent("AnalyticsTick");
$Sender->Render('tick', 'statistics', 'dashboard');
@@ -557,7 +563,7 @@ public function Tick() {
// If we're local and not allowed, or just directly disabled, gtfo
if (!self::CheckIsEnabled())
return;
-
+
if (Gdn::Session()->CheckPermission('Garden.Settings.Manage')) {
if (Gdn::Get('Garden.Analytics.Notify', FALSE) !== FALSE) {
$CallMessage = Sprite('Bandaid', 'InformSprite');
@@ -570,9 +576,9 @@ public function Tick() {
$ConfFile = PATH_CONF . '/config.php';
if (!is_writable($ConfFile))
return;
-
+
$InstallationID = Gdn::InstallationID();
-
+
// Check if we're registered with the central server already. If not, this request is
// hijacked and used to perform that task instead of sending stats or recording a tick.
if (is_null($InstallationID)) {
@@ -583,10 +589,10 @@ public function Tick() {
return $this->Register();
}
-
+
// Store the view, using denormalization if enabled
$this->AddView();
-
+
//
// // If we just tried to run the structure, and failed, don't blindly try again.
// // Just disable ourselves quietly.
Please sign in to comment.
Something went wrong with that request. Please try again.