simple_analytics_api 0.0.2 → 0.0.3
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/Gemfile.lock +1 -1
- data/README.md +20 -2
- data/lib/simple_analytics_api/client.rb +2 -2
- data/lib/simple_analytics_api/resource.rb +6 -2
- data/lib/simple_analytics_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b697125278b698423c8e0a8e41dd8ca7df6dd2519a51ff8c9ad58d6ef9d2f4f
|
4
|
+
data.tar.gz: c733e756e1ae71870b68ce82beac545331ba50db62083140222d514b1467388c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 153c3a70e9ca2d91f60c0eff6cac580c911e3dfabe60d65a6f1a77588523df25a3ec364735850277df819bd1039bca03e67260cf4c9cf5711f54919bb22fe835
|
7
|
+
data.tar.gz: 3529f9a7e3f94466370d84590870d5e99339897dfb399d10498df3ebb6f0537e77d7a9807125971e998fc23e6c1f0fb9aae32dab7c8af6d6de782186c8505c74
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -25,9 +25,27 @@ client.run(
|
|
25
25
|
fields: %w(pageviews visitors pages),
|
26
26
|
filters: {
|
27
27
|
start: '2021-01-01 00:00',
|
28
|
-
end: '2021-01-
|
28
|
+
end: '2021-01-05 23:59'
|
29
29
|
}
|
30
|
-
)
|
30
|
+
).pages
|
31
|
+
=> [#<OpenStruct value="/", pageviews=36, visitors=28>, #<OpenStruct value="/may-2020-all-stripe-data-explained-and-we-just-hit-6000-usd-mrr", pageviews=14, visitors=2>, #<OpenStruct value="/how-we-hit-our-30k-annual-recurring-revenue-milestone", pageviews=5, visitors=4>, #<OpenStruct value="/why-we-moved-our-servers-to-iceland", pageviews=5, visitors=2>, #<OpenStruct value="/april-2020-we-hit-400-paying-customers", pageviews=4, visitors=3>, #<OpenStruct value="/practical-privacy-tips-for-your-business", pageviews=2, visitors=2>]
|
32
|
+
```
|
33
|
+
The `run` command will also include some other helpful information, like this:
|
34
|
+
```rb
|
35
|
+
=> #<SimpleAnalyticsApi::Object ok=true, docs="https://docs.simpleanalytics.com/api", info="false", hostname="blog.simpleanalytics.com", url="https://blog.simpleanalytics.com", path="*", start="2021-01-01T00:00:00.000Z", end="2021-01-06T23:59:59.999Z", version=5, timezone="UTC", pageviews=66, visitors=41, pages=...the-content-that-you-see-above..., generated_in_ms=398>
|
36
|
+
```
|
37
|
+
|
38
|
+
You can also include a `debug` parameter if you want to see the final URL that is going
|
39
|
+
to be called, like this:
|
40
|
+
```rb
|
41
|
+
client.run(
|
42
|
+
fields: %w(pageviews visitors pages),
|
43
|
+
filters: {
|
44
|
+
start: '2021-01-01 00:00',
|
45
|
+
end: '2021-01-05 23:59'
|
46
|
+
},
|
47
|
+
debug: true
|
48
|
+
).pages
|
31
49
|
```
|
32
50
|
|
33
51
|
## Development
|
@@ -19,8 +19,8 @@ module SimpleAnalyticsApi
|
|
19
19
|
Website.new(client: self).run
|
20
20
|
end
|
21
21
|
|
22
|
-
def run(fields: [], filters: {})
|
23
|
-
Resource.new(client: self, fields: fields, filters: filters).run
|
22
|
+
def run(fields: [], filters: {}, debug: false)
|
23
|
+
Resource.new(client: self, fields: fields, filters: filters, debug: debug).run
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -3,15 +3,18 @@ module SimpleAnalyticsApi
|
|
3
3
|
|
4
4
|
BASE_URL = 'https://simpleanalytics.com'
|
5
5
|
|
6
|
-
attr_accessor :client, :fields, :filters, :domain
|
6
|
+
attr_accessor :client, :fields, :filters, :domain, :debug
|
7
7
|
|
8
|
-
def initialize(client:, domain: nil, fields: [], filters: {})
|
8
|
+
def initialize(client:, domain: nil, fields: [], filters: {}, debug: false)
|
9
9
|
@client = client
|
10
10
|
@fields = fields
|
11
11
|
@filters = filters
|
12
12
|
@domain = domain || client.domain
|
13
|
+
@debug = debug
|
13
14
|
@filters[:version] = 5 unless @filters[:version]
|
15
|
+
@filters[:info] = false unless @debug
|
14
16
|
@fields = [:pageviews] unless @fields.any?
|
17
|
+
|
15
18
|
end
|
16
19
|
|
17
20
|
def fields_and_filters
|
@@ -32,6 +35,7 @@ module SimpleAnalyticsApi
|
|
32
35
|
end
|
33
36
|
|
34
37
|
def run
|
38
|
+
puts "[SimpleAnalyticsAPI] #{url}" if debug
|
35
39
|
uri = URI.parse url
|
36
40
|
req = Net::HTTP::Get.new(uri.request_uri)
|
37
41
|
req.add_field('Content-Type', 'application/json')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_analytics_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gustavo Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A very humble wrapper for the API by simpleanalytics.io
|
14
14
|
email:
|