From 7239dcaeabeba21bb0fca58ebabfc37b275523f1 Mon Sep 17 00:00:00 2001
From: Fabiano Sant'Ana <fabiano@chuva-inc.com>
Date: Tue, 6 Mar 2012 14:23:01 -0300
Subject: [PATCH 2/4] Fixes #1470632 + Code cleanup

---
 mixpanel.module |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/mixpanel.module b/mixpanel.module
index 83964c6..02101f7 100644
--- a/mixpanel.module
+++ b/mixpanel.module
@@ -110,21 +110,24 @@ function mixpanel_get_defaults($user = NULL, $reset = FALSE) {
 
   if (!isset($defaults) || $reset) {
     $cohort = format_date($account->created, 'custom', "M-Y");
-    $defaults = array('uid' => $account->uid,
-                       'cohort' => $cohort,
-                       'distinct_id' => $account->uid,
-                       'ip' => $_SERVER['REMOTE_ADDR'],
+    $defaults = array(
+      'uid' => $account->uid,
+      'user_created' => $account->created,
+      'cohort' => $cohort,
+      'distinct_id' => $account->uid,
+      'ip' => $_SERVER['REMOTE_ADDR'],
     );
 
     // Let other modules alter the defaults.
-    drupal_alter('mixpanel_defaults', $defaults);
+    drupal_alter('mixpanel_defaults', $defaults, $account);
   }
 
   return $defaults;
 }
 
-
 function mixpanel_track($event, $custom_properties = array(), $account = NULL) {
+  global $user;
+  
   if (variable_get('mixpanel_token', '') == '') {
     return;
   }
-- 
1.7.7.4

