gosquared 1.0.3 → 2.0.0
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.
- checksums.yaml +4 -4
- data/README.md +51 -15
- data/lib/config.rb +16 -0
- data/lib/gosquared.rb +31 -25
- data/lib/gosquared/account.rb +4 -4
- data/lib/gosquared/now.rb +9 -9
- data/lib/gosquared/people.rb +6 -6
- data/lib/gosquared/tracking.rb +5 -5
- data/lib/gosquared/trends.rb +5 -5
- data/lib/rails/generators/go_squared/config/config_generator.rb +16 -0
- data/lib/rails/generators/go_squared/config/templates/go_squared.rb.erb +3 -0
- data/lib/tracker_inject/injector.rb +39 -0
- data/lib/tracker_inject/railtie.rb +8 -0
- data/spec/people_spec.rb +10 -10
- data/spec/trends_spec.rb +14 -14
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c9fe8b01e1133ea8e5a1d3a9b58dac91633cb15
|
4
|
+
data.tar.gz: 05501768ac59a9f9117e94ea6b0eff4c3af1a4a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a174baff33c17ef135723f2d80f04fa0c53b15f73ac4dffb835f7f9f6ff3846cb71a8a2e90252e3648add9d43b16ca8acc3a50df0c02ee4a39821bd0e04e6ff
|
7
|
+
data.tar.gz: f4c11daa660cca3cad03022a5db5d646dfb166a8177adf8b60f39d05e717faa7422000e4ebd5c1328490ac05b01bc56c2f3cfd7e7c73884d3ecc2c98485b4010
|
data/README.md
CHANGED
@@ -1,19 +1,34 @@
|
|
1
1
|
## GoSquared Ruby Gem
|
2
2
|
|
3
|
-
[](https://travis-ci.org/gosquared/ruby-gem)
|
4
4
|
|
5
5
|
**This is an early beta, please open an issue if you find anything not working, or to leave feedback for improvement. You can also get in touch directly: russell@gosquared.com**
|
6
6
|
|
7
|
-
This gems works with the [GoSquared API](https://www.gosquared.com/docs/api/), making it simple to integrate GoSquared with your Rails app. You can use it for both fetching metrics from your GoSquared account and also posting new events and contacts.
|
7
|
+
This gems works with the [GoSquared API](https://www.gosquared.com/docs/api/), making it simple to integrate GoSquared with your Rails app. You can use it for both fetching metrics from your GoSquared account and also posting new events and contacts.
|
8
8
|
|
9
9
|
All functions listed in the API documentation are methods you can call on the GoSquared class.
|
10
10
|
|
11
11
|
#Installation
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem install gosquared
|
14
|
+
gem install gosquared
|
15
15
|
```
|
16
16
|
|
17
|
+
Then require GoSquared in your application
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'gosquared'
|
21
|
+
```
|
22
|
+
|
23
|
+
If you’d like to quickly install your GoSquared javascript tracking code on all of your Rails’ views, you can easily run:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
rails generate go_squared:config ‘your_site_token'
|
27
|
+
```
|
28
|
+
|
29
|
+
This will insert a ```<script>``` tag automatically before the closing ```</body>``` tag on each view rendered.
|
30
|
+
|
31
|
+
|
17
32
|
#Tracking API
|
18
33
|
This is for sending data to GoSquared. It allows you to track:
|
19
34
|
* Events
|
@@ -23,9 +38,9 @@ This is for sending data to GoSquared. It allows you to track:
|
|
23
38
|
##Track Events
|
24
39
|
```ruby
|
25
40
|
|
26
|
-
gs = GoSquared.new("your_API_key","your_project_token")
|
41
|
+
gs = GoSquared::RubyLibrary.new("your_API_key","your_project_token")
|
27
42
|
|
28
|
-
gs.tracking.event({event: {name: 'event'}})
|
43
|
+
gs.tracking.event({ event: { name: 'event' } })
|
29
44
|
|
30
45
|
#builds the url to the 'GoSquared Tracking' endpoint with the "events" dimension and an event to add to the events list
|
31
46
|
|
@@ -41,9 +56,12 @@ Reponse Message: OK
|
|
41
56
|
##Track Transactions
|
42
57
|
|
43
58
|
```ruby
|
44
|
-
gs = GoSquared.new("your_API_key","your_project_token")
|
59
|
+
gs = GoSquared::RubyLibrary.new("your_API_key","your_project_token")
|
45
60
|
|
46
|
-
gs.tracking.transaction({
|
61
|
+
gs.tracking.transaction({
|
62
|
+
transaction: { id: "1", revenue: 50, quantity: 1,
|
63
|
+
previous_transaction_timestamp: Time.new }
|
64
|
+
})
|
47
65
|
|
48
66
|
gs.tracking.post
|
49
67
|
|
@@ -53,9 +71,27 @@ Reponse Message: OK
|
|
53
71
|
|
54
72
|
##Track People
|
55
73
|
```ruby
|
56
|
-
gs = GoSquared.new("your_API_key","your_project_token")
|
57
|
-
|
58
|
-
gs.tracking.identify({
|
74
|
+
gs = GoSquared::RubyLibrary.new("your_API_key","your_project_token")
|
75
|
+
|
76
|
+
gs.tracking.identify({
|
77
|
+
person_id: "email:user@test.com", # Required
|
78
|
+
|
79
|
+
# Reserved property names
|
80
|
+
properties: {
|
81
|
+
name: "Test User",
|
82
|
+
username: "testuser",
|
83
|
+
phone: "+44123456789",
|
84
|
+
created_at:"2016-06-07T15:44:20Z", # ISO 8601 formatted String
|
85
|
+
company_name:"GoSquared",
|
86
|
+
company_industry:"Customer Analytics",
|
87
|
+
company_size: 15000,
|
88
|
+
|
89
|
+
# Custom properties
|
90
|
+
custom: {
|
91
|
+
# custom_property_name: "custom property value"
|
92
|
+
}
|
93
|
+
}
|
94
|
+
})
|
59
95
|
|
60
96
|
gs.tracking.post
|
61
97
|
|
@@ -77,7 +113,7 @@ The Now API provides real-time concurrent information about your sites and apps,
|
|
77
113
|
_Now Example:_
|
78
114
|
|
79
115
|
```ruby
|
80
|
-
gs = GoSquared.new("your_API_key","your_project_token")
|
116
|
+
gs = GoSquared::RubyLibrary.new("your_API_key","your_project_token")
|
81
117
|
|
82
118
|
#instantiates new GoSquared object
|
83
119
|
|
@@ -98,7 +134,7 @@ The Trends API provides historical analytics information for any given period in
|
|
98
134
|
_Trends Example:_
|
99
135
|
|
100
136
|
```ruby
|
101
|
-
gs = GoSquared.new("your_API_key","your_project_token")
|
137
|
+
gs = GoSquared::RubyLibrary.new("your_API_key","your_project_token")
|
102
138
|
|
103
139
|
gs.trends.browser.from('2016-06-30').to('2016-07-07')
|
104
140
|
|
@@ -117,7 +153,7 @@ gs.trends.fetch
|
|
117
153
|
|
118
154
|
```ruby
|
119
155
|
|
120
|
-
gs = GoSquared.new("your_API_key","your_project_token")
|
156
|
+
gs = GoSquared::RubyLibrary.new("your_API_key","your_project_token")
|
121
157
|
|
122
158
|
gs.people.smartgroups
|
123
159
|
|
@@ -136,7 +172,7 @@ _Account Example:_
|
|
136
172
|
|
137
173
|
```ruby
|
138
174
|
|
139
|
-
gs = GoSquared.new("your_API_key","your_project_token")
|
175
|
+
gs = GoSquared::RubyLibrary.new("your_API_key","your_project_token")
|
140
176
|
|
141
177
|
gs.account.blocked.ips.ip('5.10.148.50')
|
142
178
|
|
@@ -149,7 +185,7 @@ gs.account.post
|
|
149
185
|
Reponse Message: OK
|
150
186
|
=> #<Net::HTTPOK 200 OK readbody=true>
|
151
187
|
|
152
|
-
gs.account.sites.token("
|
188
|
+
gs.account.sites.token("your_site_token")
|
153
189
|
|
154
190
|
#builds the url to the 'GoSquared Account' endpoint with the "Sites" dimension and token you want to retrieve the site by.
|
155
191
|
|
data/lib/config.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module GoSquared
|
2
|
+
|
3
|
+
class << self
|
4
|
+
attr_accessor :configuration
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.configure
|
8
|
+
self.configuration ||= Configuration.new
|
9
|
+
block_given? ? yield(configuration) : configuration
|
10
|
+
end
|
11
|
+
|
12
|
+
class Configuration
|
13
|
+
attr_accessor :site_token
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/gosquared.rb
CHANGED
@@ -1,34 +1,40 @@
|
|
1
|
-
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
1
|
+
require 'tracker_inject/railtie' if defined? (Rails)
|
2
|
+
require_relative "gosquared/trends"
|
3
|
+
require_relative "gosquared/tracking"
|
4
|
+
require_relative "gosquared/people"
|
5
|
+
require_relative "gosquared/now"
|
6
|
+
require_relative "gosquared/account"
|
7
|
+
require_relative "config"
|
6
8
|
|
7
|
-
|
9
|
+
module GoSquared
|
8
10
|
|
9
|
-
|
10
|
-
@api_key = api_key
|
11
|
-
@site_id = site_id
|
12
|
-
end
|
11
|
+
class RubyLibrary
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def initialize api_key, site_id
|
14
|
+
@api_key = api_key
|
15
|
+
@site_id = site_id
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
def trends
|
19
|
+
@trends ||= Trends.new(@api_key, @site_id)
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def tracking
|
23
|
+
@tracking ||= Tracking.new(@api_key, @site_id)
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
def people
|
27
|
+
@people ||= People.new(@api_key, @site_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def now
|
31
|
+
@now ||= Now.new(@api_key, @site_id)
|
32
|
+
end
|
33
|
+
|
34
|
+
def account
|
35
|
+
@account ||= Account.new(@api_key, @site_id)
|
36
|
+
end
|
29
37
|
|
30
|
-
def account
|
31
|
-
@account ||= Account.new(@api_key, @site_id)
|
32
38
|
end
|
33
39
|
|
34
|
-
end
|
40
|
+
end
|
data/lib/gosquared/account.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "client"
|
2
2
|
|
3
3
|
class Account
|
4
|
-
|
4
|
+
|
5
5
|
BASEURL = "https://api.gosquared.com/account/v1/"
|
6
6
|
DIMENSIONS = %w(blocked feeds reportPreferences sharedUsers sites taggedVisitors triggerTypes webhooks)
|
7
7
|
DIMENSION_FILTER = %w(token webhookID visitorID triggerType)
|
@@ -70,7 +70,7 @@ class Account
|
|
70
70
|
@visitor = "/visitors/#{id}"
|
71
71
|
self
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
def build_url(ips = @ips)
|
75
75
|
array = [""]
|
76
76
|
@url = BASEURL + @dimension + @dimension_filter + @visitor + @bots + ips +
|
@@ -80,4 +80,4 @@ class Account
|
|
80
80
|
@url = @url.concat(parameters)
|
81
81
|
end
|
82
82
|
|
83
|
-
end
|
83
|
+
end
|
data/lib/gosquared/now.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "client"
|
2
2
|
class Now
|
3
3
|
|
4
4
|
BASEURL = "https://api.gosquared.com/now/v3/"
|
5
|
-
DIMENSIONS = %w(browsers campaigns concurrents engagement geo languages notifications
|
5
|
+
DIMENSIONS = %w(browsers campaigns concurrents engagement geo languages notifications
|
6
6
|
organisations overview pages platforms sources time timeSeries visitors)
|
7
|
-
@@filters = {dateFormat: @date_format, from: @from, to: @to,
|
8
|
-
format: @format, limit: @limit, sort: @sort,
|
9
|
-
presenter: @presenter, visitors_mode: @string, href: @href,
|
7
|
+
@@filters = {dateFormat: @date_format, from: @from, to: @to,
|
8
|
+
format: @format, limit: @limit, sort: @sort,
|
9
|
+
presenter: @presenter, visitors_mode: @string, href: @href,
|
10
10
|
drill_limit: @drill_limit, sections: @sections,
|
11
11
|
minimal: @minimal, interval: @interval}
|
12
12
|
|
@@ -19,10 +19,10 @@ class Now
|
|
19
19
|
|
20
20
|
DIMENSIONS.each do |dimension|
|
21
21
|
define_method dimension do
|
22
|
-
@dimension = dimension
|
22
|
+
@dimension = dimension
|
23
23
|
self
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
26
26
|
|
27
27
|
@@filters.each do |key, value|
|
28
28
|
define_method key do |argument|
|
@@ -36,7 +36,7 @@ class Now
|
|
36
36
|
@@filters.each{|key, value| @@filters[key]=nil} if data
|
37
37
|
data
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
private
|
41
41
|
|
42
42
|
def url
|
@@ -47,4 +47,4 @@ class Now
|
|
47
47
|
@url = @url.concat(parameters)
|
48
48
|
end
|
49
49
|
|
50
|
-
end
|
50
|
+
end
|
data/lib/gosquared/people.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "client"
|
2
2
|
class People
|
3
3
|
|
4
4
|
BASEURL = "https://api.gosquared.com/people/v1/"
|
5
5
|
VERSION = %w(v1 v2 v3)
|
6
6
|
DIMENSIONS = %w(devices eventTypes people propertyTypes feed smartgroups)
|
7
|
-
@@filters = {query: @query, filters: @filters, sort: @sort,
|
7
|
+
@@filters = {query: @query, filters: @filters, sort: @sort,
|
8
8
|
format: @presenter, limit: @limit, type: @type, from: @from, to: @to}
|
9
9
|
|
10
10
|
def initialize(api_key, site_token, client =Client.new)
|
@@ -17,7 +17,7 @@ class People
|
|
17
17
|
|
18
18
|
DIMENSIONS.each do |dimension|
|
19
19
|
define_method dimension do |options = ""|
|
20
|
-
@dimension = dimension
|
20
|
+
@dimension = dimension
|
21
21
|
@data = options
|
22
22
|
self
|
23
23
|
end
|
@@ -34,7 +34,7 @@ class People
|
|
34
34
|
@person_id = "/" + object
|
35
35
|
@person_filter = "/" + filter
|
36
36
|
self
|
37
|
-
end
|
37
|
+
end
|
38
38
|
|
39
39
|
def fetch
|
40
40
|
data = @client.get(url)
|
@@ -44,11 +44,11 @@ class People
|
|
44
44
|
|
45
45
|
def url
|
46
46
|
array = [""]
|
47
|
-
url = BASEURL + @dimension + @person_id + @person_filter +
|
47
|
+
url = BASEURL + @dimension + @person_id + @person_filter +
|
48
48
|
"?api_key=#{@api_key}" + "&site_token=#{@site_token}"
|
49
49
|
@@filters.each { |key, value| array << "#{key}=#{value}" if value }
|
50
50
|
parameters=array.join('&')
|
51
51
|
url.concat(parameters)
|
52
52
|
end
|
53
53
|
|
54
|
-
end
|
54
|
+
end
|
data/lib/gosquared/tracking.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "client"
|
2
2
|
class Tracking
|
3
3
|
|
4
4
|
BASEURL = "https://api.gosquared.com/tracking/v1/"
|
5
|
-
DIMENSIONS = %w(event identify pageview ping properties timeout transaction)
|
5
|
+
DIMENSIONS = %w(event identify pageview ping properties timeout transaction)
|
6
6
|
|
7
7
|
def initialize(api_key, site_token, client=Client.new)
|
8
8
|
@site_token = site_token
|
@@ -12,7 +12,7 @@ require_relative 'client'
|
|
12
12
|
|
13
13
|
DIMENSIONS.each do |dimension|
|
14
14
|
define_method dimension do |options|
|
15
|
-
@dimension = dimension
|
15
|
+
@dimension = dimension
|
16
16
|
@data = options
|
17
17
|
self
|
18
18
|
end
|
@@ -25,7 +25,7 @@ require_relative 'client'
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def url
|
28
|
-
url = BASEURL + @dimension + "?api_key=#{@api_key}" + "&site_token=#{@site_token}"
|
28
|
+
url = BASEURL + @dimension + "?api_key=#{@api_key}" + "&site_token=#{@site_token}"
|
29
29
|
end
|
30
30
|
|
31
|
-
end
|
31
|
+
end
|
data/lib/gosquared/trends.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "client"
|
2
2
|
class Trends
|
3
3
|
|
4
4
|
BASEURL = "https://api.gosquared.com/trends/v2/"
|
5
5
|
DIMENSIONS = %w(aggregate browser category country event language organisation os page path1 product screenDimensions sources transactions)
|
6
|
-
@@filters = {date_format: @date_format, from: @from, to: @to,
|
6
|
+
@@filters = {date_format: @date_format, from: @from, to: @to,
|
7
7
|
format: @format, limit: @limit, sort: @sort, group: @group}
|
8
8
|
|
9
9
|
def initialize(api_key, site_token, client=Client.new)
|
@@ -14,10 +14,10 @@ require_relative 'client'
|
|
14
14
|
|
15
15
|
DIMENSIONS.each do |dimension|
|
16
16
|
define_method dimension do
|
17
|
-
@dimension = dimension
|
17
|
+
@dimension = dimension
|
18
18
|
self
|
19
19
|
end
|
20
|
-
end
|
20
|
+
end
|
21
21
|
|
22
22
|
@@filters.each do |key, value|
|
23
23
|
define_method key do |argument|
|
@@ -41,4 +41,4 @@ require_relative 'client'
|
|
41
41
|
parameters=array.join('&')
|
42
42
|
url.concat(parameters)
|
43
43
|
end
|
44
|
-
end
|
44
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module GoSquared
|
4
|
+
module Generators
|
5
|
+
class ConfigGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
|
8
|
+
argument :site_token
|
9
|
+
|
10
|
+
def copy_initializer_file
|
11
|
+
@site_token = site_token
|
12
|
+
template("go_squared.rb.erb", File.join("config/initializers/go_squared.rb"))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Injector
|
2
|
+
|
3
|
+
module Filter
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
append_after_filter :add_script
|
7
|
+
|
8
|
+
CLOSING_BODY_TAG = %r{</body>}
|
9
|
+
|
10
|
+
def add_script
|
11
|
+
response.body = response.body.gsub(CLOSING_BODY_TAG, "<script>
|
12
|
+
var trackingCode = function() {
|
13
|
+
|
14
|
+
!function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(
|
15
|
+
arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0];
|
16
|
+
d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';q.parentNode.
|
17
|
+
insertBefore(d,q)}(window,document,'script','_gs');
|
18
|
+
_gs('#{GoSquared.configure.site_token}'); _gs('set', 'trackLocal', true);
|
19
|
+
};
|
20
|
+
|
21
|
+
var loadTracker;
|
22
|
+
loadTracker=function(){
|
23
|
+
if(!window._gs) {
|
24
|
+
trackingCode();
|
25
|
+
} else {
|
26
|
+
delete _gs;
|
27
|
+
trackingCode();
|
28
|
+
}
|
29
|
+
};
|
30
|
+
$(document).on('page:load', loadTracker)
|
31
|
+
$(document).on('turbolinks:load', loadTracker);
|
32
|
+
</script>" + "\n </body>")
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/spec/people_spec.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
describe People do
|
2
2
|
subject(:gs) { described_class.new("demo", "GSN-106863-S") }
|
3
|
-
|
4
|
-
People::DIMENSIONS.each do |dimension|
|
5
|
-
before do
|
3
|
+
|
4
|
+
People::DIMENSIONS.each do |dimension|
|
5
|
+
before do
|
6
6
|
data = '{"a": [{"test": "response"}]}'
|
7
|
-
stub_request(:get, "https://api.gosquared.com/people/v1/#{dimension}?api_key=demo&site_token=GSN-106863-S"
|
7
|
+
stub_request(:get, "https://api.gosquared.com/people/v1/#{dimension}?api_key=demo&site_token=GSN-106863-S"
|
8
8
|
).
|
9
9
|
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
10
10
|
to_return(status: 200, body: data, headers: {})
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
People::DIMENSIONS.each do |dimension|
|
14
|
+
People::DIMENSIONS.each do |dimension|
|
15
15
|
it "fetches a request from the GoSquared People API with #{dimension} dimension" do
|
16
16
|
gs.send "#{dimension}"
|
17
17
|
expect(gs.fetch).to eq("a" => [{"test"=>"response"}])
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
before do
|
21
|
+
before do
|
22
22
|
data = '{"a": [{"test": "response"}, {"with": "params"}]}'
|
23
23
|
stub_request(:get, "https://api.gosquared.com/people/v1/people/example.email@example.com/devices?api_key=demo&site_token=GSN-106863-S").
|
24
24
|
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.gosquared.com', 'User-Agent'=>'Ruby'}).
|
@@ -31,8 +31,8 @@ describe People do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
|
34
|
-
People::DIMENSIONS.each do |dimension|
|
35
|
-
before do
|
34
|
+
People::DIMENSIONS.each do |dimension|
|
35
|
+
before do
|
36
36
|
data = '{"a": [{"test": "response"}, {"with": "params"}]}'
|
37
37
|
stub_request(:get, "https://api.gosquared.com/people/v1/#{dimension}?api_key=demo&site_token=GSN-106863-S&limit=5").
|
38
38
|
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.gosquared.com', 'User-Agent'=>'Ruby'}).
|
@@ -40,7 +40,7 @@ describe People do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
People::DIMENSIONS.each do |dimension|
|
44
44
|
it "fetches a request from the GoSquared People API with dimension and paramaters" do
|
45
45
|
gs.send("#{dimension}").limit(5)
|
46
46
|
expect(gs.fetch).to eq("a" => [{"test"=>"response"}, {"with"=>"params"}])
|
@@ -48,4 +48,4 @@ describe People do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
|
51
|
-
end
|
51
|
+
end
|
data/spec/trends_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
describe Trends do
|
1
|
+
describe Trends do
|
2
2
|
subject(:gs) { described_class.new("demo","GSN-106863-S") }
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
Trends::DIMENSIONS.each do |dimension|
|
5
|
+
before do
|
6
6
|
data = '{"a": [{"test": "response"}]}'
|
7
7
|
stub_request(:get, "https://api.gosquared.com/trends/v2/#{dimension}?api_key=demo&site_token=GSN-106863-S").
|
8
8
|
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
@@ -10,15 +10,15 @@ GoSquared::Trends::DIMENSIONS.each do |dimension|
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
Trends::DIMENSIONS.each do |dimension|
|
14
14
|
it "fetches a request from the GoSquared Trends API with #{dimension} dimension" do
|
15
15
|
gs.send "#{dimension}"
|
16
16
|
expect(gs.fetch).to eq("a" => [{"test"=>"response"}])
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
Trends::DIMENSIONS.each do |dimension|
|
21
|
+
before do
|
22
22
|
data = '{"a": [{"test": "response"}, {"with": "params"}]}'
|
23
23
|
stub_request(:get, "https://api.gosquared.com/trends/v2/#{dimension}?api_key=demo&site_token=GSN-106863-S&date_format=yyyy-mm-dd&format=json&from=2016-06-20&group=true&limit=5&site_token=GSN-106863-S&sort=visits&to=2016-06-30").
|
24
24
|
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Host'=>'api.gosquared.com', 'User-Agent'=>'Ruby'}).
|
@@ -26,12 +26,12 @@ GoSquared::Trends::DIMENSIONS.each do |dimension|
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
29
|
+
Trends::DIMENSIONS.each do |dimension|
|
30
|
+
it "fetches a request from the GoSquared Trends API with #{dimension} dimension and paramaters" do
|
31
|
+
gs.send("#{dimension}").from('2016-06-20').to('2016-06-30')
|
32
|
+
.date_format('yyyy-mm-dd').sort('visits').group(true).format('json').limit(5)
|
33
|
+
expect(gs.fetch).to eq("a" => [{"test"=>"response"}, {"with"=>"params"}])
|
34
|
+
end
|
35
|
+
end
|
36
36
|
|
37
|
-
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gosquared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Vaughan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE
|
52
52
|
- README.md
|
53
|
+
- lib/config.rb
|
53
54
|
- lib/gosquared.rb
|
54
55
|
- lib/gosquared/account.rb
|
55
56
|
- lib/gosquared/client.rb
|
@@ -57,6 +58,10 @@ files:
|
|
57
58
|
- lib/gosquared/people.rb
|
58
59
|
- lib/gosquared/tracking.rb
|
59
60
|
- lib/gosquared/trends.rb
|
61
|
+
- lib/rails/generators/go_squared/config/config_generator.rb
|
62
|
+
- lib/rails/generators/go_squared/config/templates/go_squared.rb.erb
|
63
|
+
- lib/tracker_inject/injector.rb
|
64
|
+
- lib/tracker_inject/railtie.rb
|
60
65
|
- spec/account_spec.rb
|
61
66
|
- spec/client_spec.rb
|
62
67
|
- spec/now_spec.rb
|