Class: TrafficSourceMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/visitor_sources/traffic_source_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ TrafficSourceMiddleware

Returns a new instance of TrafficSourceMiddleware.



2
3
4
5
# File 'lib/visitor_sources/traffic_source_middleware.rb', line 2

def initialize(app, options={})
  @app = app
  @options = options
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/visitor_sources/traffic_source_middleware.rb', line 7

def call(env)
  @options[:custom_parameter_mapping] ||= {}        
  @options[:ignore_duplicate_source_within] ||= 120 #2 mins
  env["rack.request.query_hash"] = Rack::Utils.parse_query(env["QUERY_STRING"]) 
  env = TrafficSource.updated_rack_environment(env, @options[:custom_parameter_mapping])
  env[:traffic_sources] = TrafficSources.new(env["rack.session"][:traffic_sources])        
  @status, @headers, @response = @app.call(env)    
  [@status, @headers, @response]
end