eyestreet-analytics_goo 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{analytics_goo}
5
- s.version = "0.1.0"
5
+ s.version = "0.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Rob Christie"]
@@ -10,6 +10,20 @@ module AnalyticsGoo
10
10
  end
11
11
 
12
12
 
13
+ class AnalyticsAdapter
14
+ def initialize(adapter)
15
+ @adapter = adapter
16
+ end
17
+
18
+ def track_page_view(path)
19
+ @adapter.track_page_view(path)
20
+ end
21
+
22
+ def env
23
+ @adapter.env
24
+ end
25
+ end
26
+
13
27
  # Factory for returning the appropriate analytics object. The <tt>type</tt> is
14
28
  # a symbol that defines the type of analytics tracker you want to create. Currently,
15
29
  # the only acceptable value is :google_analytics. The <tt>analytics</tt> hash holds
@@ -29,11 +43,11 @@ module AnalyticsGoo
29
43
  for framework in ([ :active_record, :action_controller, :action_mailer ])
30
44
  framework.to_s.camelize.constantize.const_get("Base").send :include, AnalyticsGoo::InstanceMethods
31
45
  end
32
- silence_warnings { Object.const_set "ANALYTICS_TRACKER", tracker }
46
+ silence_warnings { Object.const_set "ANALYTICS_TRACKER", AnalyticsGoo::AnalyticsAdapter.new(tracker) }
33
47
  else
34
48
  tracker = adapter.constantize.new(analytics)
35
49
  end
36
- tracker
50
+ AnalyticsGoo::AnalyticsAdapter.new(tracker)
37
51
  rescue StandardError
38
52
  raise AnalyticsAdapterNotFound
39
53
  end
@@ -127,4 +127,18 @@ class AnalyticsGooTest < ActiveSupport::TestCase
127
127
  end
128
128
  end
129
129
  end
130
+ context "An analytics tracking event using the adapter class" do
131
+ setup do
132
+ test = AnalyticsGoo::GoogleAnalyticsAdapter.new(:analytics_id => "UA-3536616-5",:domain => "demo.mobilediscovery.com")
133
+ @ga4 = AnalyticsGoo::AnalyticsAdapter.new(test)
134
+ end
135
+ context "makes a request for an image on the google analytics server" do
136
+ setup do
137
+ @resp = @ga4.track_page_view("/testFoo/myPage.html")
138
+ end
139
+ should "be a valid response" do
140
+ assert @resp.is_a?(Net::HTTPOK)
141
+ end
142
+ end
143
+ end
130
144
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyestreet-analytics_goo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Christie