Class: Rack::Klaviyo

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/klaviyo.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, api_key, options = {}) ⇒ Klaviyo

Returns a new instance of Klaviyo.



3
4
5
6
7
8
9
# File 'lib/rack/klaviyo.rb', line 3

def initialize(app, api_key, options={})
  @app = app
  @api_key = api_key
  @options = {
    :insert_js_last => true
  }.merge(options)
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  @env = env

  @status, @headers, @response = @app.call(env)

  if is_trackable_response?
    update_response!
    update_content_length!
  end

  [@status, @headers, @response]
end