Skip to content

Commit

Permalink
Record the referer url on open events
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Apr 18, 2013
1 parent 73d1e6a commit 50f3768
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/controllers/deliveries_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class DeliveriesController < ApplicationController
def open_track
Delivery.find_by!(open_tracked_hash: params[:hash]).open_events.create!(user_agent: request.env['HTTP_USER_AGENT'])
Delivery.find_by!(open_tracked_hash: params[:hash]).open_events.create!(
user_agent: request.env['HTTP_USER_AGENT'],
referer: request.referer
)
# TODO Check that we are asking for a gif and only accept those for the time being
# This sends a 1x1 transparent gif
send_data(Base64.decode64("R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="), :type => "image/gif", :disposition => "inline")
Expand Down
2 changes: 2 additions & 0 deletions app/views/deliveries/_delivery.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
%tr
%th Time
%th User agent
%th Referer
%th Client
%th OS
%tbody
Expand All @@ -36,6 +37,7 @@
= time_ago_in_words(event.created_at)
ago
%td= event.user_agent
%td= event.referer
%td
= link_to event.ua_family, event.ua_url
%td
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20130418095518_add_referer_to_open_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddRefererToOpenEvents < ActiveRecord::Migration
def change
add_column :open_events, :referer, :text
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20130418054241) do
ActiveRecord::Schema.define(version: 20130418095518) do

create_table "addresses", force: true do |t|
t.string "text"
Expand Down Expand Up @@ -68,6 +68,7 @@
t.datetime "created_at"
t.datetime "updated_at"
t.text "user_agent"
t.text "referer"
end

create_table "postfix_log_lines", force: true do |t|
Expand Down

0 comments on commit 50f3768

Please sign in to comment.