sojourn 1.0.0.pre → 1.0.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9caf4fdd9129f3391d00292849ea95096e2e7bb8
4
- data.tar.gz: 3cae47fe7eea5430c668cb8d63993ab9eca5a89f
3
+ metadata.gz: dde9bf6c84552264bd06b6465dcbf764952eb15f
4
+ data.tar.gz: a45e882088fb6d3e3cb4bed30a49a5e3e74c99e1
5
5
  SHA512:
6
- metadata.gz: cb52529bf9c8f7623ad5e35ace62dc89933c7c11b086a39241d92b98bfaebf4fc1d7de7f4b62f009f107fce7e8cad8d8c1548bbbdc31b61b6b5b8d1a581b6567
7
- data.tar.gz: 6db0dd0268c3fd39d40340b6e9254b436f367f03bfb013259c80920e445b239adc4e2db329b76cd11e362153d1ef78de43b3545ee472a781170b53dce192ade3
6
+ metadata.gz: ade417af7eb156d6d1e1d424e14bc500bdb47373367b15a0feb4700f7ab0a7489b04398917410231c5dad1a4ff2a2b1c99dd582cfb1139d68b858cfd48662864
7
+ data.tar.gz: 027a5f0c51b26ba6672811e855dde81bcc73a35bc1c639e1e2947fbbd229982de292db271293987a2e193c0570e7c7de0e001c6b291526f9c16be51cbb0c4553
@@ -2,6 +2,7 @@ require_relative 'campaign'
2
2
  require_relative 'browser'
3
3
  require_relative 'serializers/symbol'
4
4
  require 'addressable/uri'
5
+ require 'referer-parser'
5
6
 
6
7
  module Sojourn
7
8
  class Request < ActiveRecord::Base
@@ -32,7 +33,7 @@ module Sojourn
32
33
  end
33
34
 
34
35
  def outside_referer?
35
- referer.present? && Addressable::URI.parse(referer).host != host
36
+ referer.present? && referer_host != host
36
37
  end
37
38
 
38
39
  def any_utm_data?
@@ -55,8 +56,24 @@ module Sojourn
55
56
  }
56
57
  end
57
58
 
59
+ def referer_data
60
+ return @referer_data if @referer_data
61
+ p = RefererParser::Parser.new.parse(referer)
62
+ @referer_data = {
63
+ known: p[:known],
64
+ host: referer_host,
65
+ source: p[:source],
66
+ medium: p[:medium],
67
+ term: p[:term]
68
+ }
69
+ end
70
+
58
71
  private
59
72
 
73
+ def referer_host
74
+ @referer_host ||= Addressable::URI.parse(referer).host
75
+ end
76
+
60
77
  def downcased_params
61
78
  params.each_with_object({}) { |(k, v), h| h[k.to_s.downcase] = v }
62
79
  end
@@ -73,6 +73,7 @@ module Sojourn
73
73
  @ctx.sojourn_event_properties(properties) if @ctx.respond_to? :sojourn_event_properties
74
74
  properties.merge!(campaign: request.tracked_params) if request.tracked_params.any?
75
75
  properties.merge! browser: request.browser_data
76
+ properties.merge! referer: request.referer_data if request.referer.present?
76
77
  properties
77
78
  end
78
79
  end
@@ -1,3 +1,3 @@
1
1
  module Sojourn
2
- VERSION = '1.0.0.pre'
2
+ VERSION = '1.0.0.pre2'
3
3
  end
@@ -25,4 +25,5 @@ sojourn tracks the referer, utm data, and logged-in user (if any)).gsub("\n", '
25
25
 
26
26
  spec.add_dependency 'browser', '>= 0.8.0'
27
27
  spec.add_dependency 'addressable', '>= 2.3.1'
28
+ spec.add_dependency 'referer-parser', '~> 0.3.0'
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sojourn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre
4
+ version: 1.0.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smudge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.3.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: referer-parser
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.3.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.3.0
69
83
  description: ' Sojourn tracks site visitors and sources, with the ability to recognise
70
84
  multiple sources per visitor. Each time a new source is detected, sojourn tracks
71
85
  the referer, utm data, and logged-in user (if any)'