Index: episodes_user.info
===================================================================
RCS file: episodes_user.info
diff -N episodes_user.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ episodes_user.info	6 Apr 2010 03:39:26 -0000
@@ -0,0 +1,9 @@
+; $Id$
+name = Episodes User Logging
+description = "Track whether users are logged in using the Episodes module."
+
+core = 6.x
+package = Performance
+php = 5.2
+
+dependencies[] = episodes
Index: episodes_user.module
===================================================================
RCS file: episodes_user.module
diff -N episodes_user.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ episodes_user.module	6 Apr 2010 03:39:26 -0000
@@ -0,0 +1,55 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Implementation of the core hooks, defines and public functions.
+ */
+
+define('EPISODES_LOG_USERS_VARIABLE', 'episodes_log_uid');
+define('EPISODES_LOG_USERS_DEFAULT', FALSE);
+
+
+//----------------------------------------------------------------------------
+// Drupal core hooks.
+
+/**
+ * Implementation of hook_init().
+ */
+function episodes_user_init() {
+  // Only do something if the user is disabled.
+  if (episodes_is_enabled()) {  
+    global $user;
+    
+    $logged_in = FALSE;
+    if ($user->uid > 0) {
+      $logged_in = TRUE;
+    }
+
+    $js_code = array(
+      'window.postMessage("EPISODES:status:logged_in:'. intval($logged_in) .'", document.location);',
+    );
+
+    if ($logged_in && variable_get(EPISODES_LOG_USERS_VARIABLE, FALSEPISODES_LOG_USERS_DEFAULTE)) {
+      $js_code[] = 'window.postMessage("EPISODES:status:uid:'. intval($user->uid) .'", document.location);';
+    }
+    
+    drupal_set_html_head('<script type="text/javascript">' . implode('', $js_code) . '</script>');
+  }
+}
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function episodes_user_form_alter(&$form, $form_state, $form_id) {
+  // Extend the main Episodes module settings page.
+  if ($form_id == 'episodes_admin_settings') {
+    // Add an option to control whether the user ID logging is enabled.
+    $form['logging'][EPISODES_LOG_USERS_VARIABLE] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Log user id (uid)?'),
+      '#default_value' => variable_get(EPISODES_LOG_USERS_VARIABLE, EPISODES_LOG_USERS_DEFAULT),
+      '#description' => t('The Episodes User Logging module is enabled so it is tracking whether the user is logged in.  Enabling this module will also track their user id (uid).'),
+    );
+  }
+}
Index: lib/episodes.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/episodes/lib/episodes.js,v
retrieving revision 1.1
diff -u -p -r1.1 episodes.js
--- lib/episodes.js	1 Jul 2009 10:41:31 -0000	1.1
+++ lib/episodes.js	6 Apr 2010 03:39:26 -0000
@@ -98,6 +98,13 @@ EPISODES.handleEpisodeMessage = function
     		EPISODES.sendBeacon(EPISODES.beaconUrl);
     	}
     }
+    // Everything else gets stored with the action name as the prefix.
+    else {
+      // "EPISODES:action:statusName:statusValue"
+      var statusName = aParts[2];
+      var statusValue = aParts[3];
+      EPISODES.measures[action + '/' + statusName] = parseInt(statusValue);
+    }
 };
 
 // Return an object of episode names and their corresponding durations.
