eyestreet-analytics_goo 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/analytics_goo.gemspec +1 -1
- data/lib/analytics_goo.rb +16 -2
- data/test/analytics_goo_test.rb +14 -0
- metadata +1 -1
data/analytics_goo.gemspec
CHANGED
data/lib/analytics_goo.rb
CHANGED
|
@@ -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
|
data/test/analytics_goo_test.rb
CHANGED
|
@@ -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
|