Class: MixpanelMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/mixpanel/mixpanel_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, mixpanel_token, options = {}) ⇒ MixpanelMiddleware

Returns a new instance of MixpanelMiddleware.



4
5
6
7
8
9
10
# File 'lib/mixpanel/mixpanel_middleware.rb', line 4

def initialize(app, mixpanel_token, options={})
  @app = app
  @token = mixpanel_token
  @options = {
    :async => false
  }.merge(options)
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mixpanel/mixpanel_middleware.rb', line 12

def call(env)
  @env = env

  @status, @headers, @response = @app.call(env)
  
  update_response!
  update_content_length!
  delete_event_queue!
  
  [@status, @headers, @response]
end