<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,13 +1,51 @@
 UserEventLogger
 ===============
 
-THIS CODE IS NOT YET READY FOR USE
+This plugin is extracted from several applications where I had similar problems:
+tracking various things that users did within the application. For example, I've
+used this to be able to log outgoing clicks without hooking up an analytics package,
+to count the number of times an ad was displayed, or to keep track of how often
+a particular page was visited.
 
+To use the plugin, you must first create the table that it uses:
+
+./script/generate user_event_logger add_event_table
+rake db:migrate
+
+After that, you can add information to the table from either your controllers or
+your views:
+
+log_user_event &quot;In controller&quot;, &quot;http://example.com&quot;, &quot;27&quot;
+&lt;%= log_user_event &quot;In view&quot;, &quot;http://example.com&quot;, &quot;27&quot; %&gt;
+
+The first argument is the event name, which is required. The second is the
+destination URL, which is optional. The third is arbitrary extra data, which is
+optional. The extra data is stored in a text column, so you can add as much
+as you want here.
+
+Reporting is left as an exercise for the user. The events table has these columns:
+
+create_table :events do |t|
+  t.column  :source_url, :string
+  t.column  :destination_url, :string
+  t.column  :remote_ip, :string
+  t.column  :logged_at, :datetime
+  t.column  :extra_data, :text
+  t.column  :event_type, :string
+end
 
 Example
 =======
 
-Example goes here.
+To do outgoing link tracking, you can set up a controller method similar to this one:
+
+def send_to 
+    @advertiser = Advertiser.find(params[:id])
+    destination_url = @advertiser.website.sub(/^www/, &quot;http://www&quot;)
+    log_user_event &quot;Clicked through&quot;, destination_url, params[:id]
+    redirect_to destination_url
+end 
+
 
 
 Copyright (c) 2008 Michael A. Gunderloy, released under the MIT license</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -5,6 +5,6 @@ Example:
     ./script/generate user_event_logger add_event_table
 
 This will create:
-    db/migrate/TIMESTAMP_create_user_event_logger
+    db/migrate/TIMESTAMP_add_event_table
 
 You will then need to run rake db:migrate to add the table to the database</diff>
      <filename>generators/user_event_logger/USAGE</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-class CreateEventsTable &lt; ActiveRecord::Migration
+class &lt;%= class_name %&gt; &lt; ActiveRecord::Migration
   def self.up
     create_table :events do |t|
       t.column  :source_url, :string</diff>
      <filename>generators/user_event_logger/templates/migration.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,7 @@
 class UserEventLoggerGenerator &lt; Rails::Generator::NamedBase
   def manifest
     record do |m|
-      # m.directory &quot;lib&quot;
-      # m.template 'README', &quot;README&quot;
-      m.migration_template 'migration.rb', 'db/migrate'
+      m.migration_template 'migration.rb', 'db/migrate', :migration_file_name =&gt; name
     end
   end
 end</diff>
      <filename>generators/user_event_logger/user_event_logger_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 require &quot;view_helpers&quot; 
-ActionView::Base.send :include, UserEventLoggerViewHelper
-
-ActionController::Base.send :include, UserEventLoggerMixin
+require &quot;user_event_logger&quot;
+ActionView::Base.send :include, UserEventLogger::UserEventLoggerViewHelper
+ActionController::Base.send :include, UserEventLogger::UserEventLoggerMixin
 
 path = File.join(directory, 'lib', 'models')
 $LOAD_PATH &lt;&lt; path</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,12 @@
-module UserEventLoggerMixin
-  def log_user_event(name, extra_data)
-    event = Event.create(:source_url =&gt; request.path,
-     :remote_ip =&gt; request.remote_ip,
-     :logged_at =&gt; Time.now,
-     :extra_data =&gt; extra_data,
-     :event_type =&gt; name
+module UserEventLogger
+  module UserEventLoggerMixin
+    def log_user_event(name, destination_url = nil, extra_data = nil)
+      event = Event.create(:source_url =&gt; request.path,
+       :destination_url =&gt; destination_url,
+       :remote_ip =&gt; request.remote_ip,
+       :logged_at =&gt; Time.now,
+       :extra_data =&gt; extra_data,
+       :event_type =&gt; name)
+    end
   end
 end
-</diff>
      <filename>lib/user_event_logger.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,15 @@
-module UserEventLoggerViewHelper
-  def log_user_event(name, extra_data)
-    returning &quot;&quot; do |result|
-      event = Event.create(:source_url =&gt; request.path,
-       :remote_ip =&gt; request.remote_ip,
-       :logged_at =&gt; Time.now,
-       :extra_data =&gt; extra_data,
-       :event_type =&gt; name
-      )
+module UserEventLogger
+  module UserEventLoggerViewHelper
+    def log_user_event(name, destination_url = nil, extra_data = nil)
+      returning &quot;&quot; do |result|
+        event = Event.create(:source_url =&gt; request.path,
+         :destination_url =&gt; destination_url,
+         :remote_ip =&gt; request.remote_ip,
+         :logged_at =&gt; Time.now,
+         :extra_data =&gt; extra_data,
+         :event_type =&gt; name
+        )
+      end
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/view_helpers.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>11b3f378795a6961f83e0071affb64eb74d004ad</id>
    </parent>
  </parents>
  <author>
    <name>Mike Gunderloy</name>
    <email>MikeG1@larkfarm.com</email>
  </author>
  <url>http://github.com/ffmike/user_event_logger/commit/4cfaaa389dac1ce5999efed187d116a5d0e31c2d</url>
  <id>4cfaaa389dac1ce5999efed187d116a5d0e31c2d</id>
  <committed-date>2008-07-27T05:49:14-07:00</committed-date>
  <authored-date>2008-07-27T05:49:14-07:00</authored-date>
  <message>Reasonably working code. Still needs tests. Bad developer, no biscuit.</message>
  <tree>74a5bf4b4b2e72b74e3f2145ad4df040c05897f2</tree>
  <committer>
    <name>Mike Gunderloy</name>
    <email>MikeG1@larkfarm.com</email>
  </committer>
</commit>
