Class: Gabrake::Notifier::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/gabrake/notifier.rb

Class Method Summary collapse

Class Method Details

.extract_context(env) ⇒ Object



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

def self.extract_context(env)
  cookies = env['action_dispatch.cookies']
  default_client_id = "GA1.1.#{(rand() * 2147483647).to_i}.#{Time.now.to_i}"
  _, version, client_id = *(cookies['_ga'] || default_client_id).match(/GA(\d+)\..+\.(\d+\.\d+)\z/)

  {
    version: version,
    client_id: client_id,
    url: env['REQUEST_URI']
  }
end