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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad37e11e9775b0df35b8576f8ed0f3152ba4a363434a11b348297dca6f11ada8
4
- data.tar.gz: c685fb99c7350ae58d7bf8771ff12f55d0b56931de1383e679b206b31afd643e
3
+ metadata.gz: 8b697125278b698423c8e0a8e41dd8ca7df6dd2519a51ff8c9ad58d6ef9d2f4f
4
+ data.tar.gz: c733e756e1ae71870b68ce82beac545331ba50db62083140222d514b1467388c
5
5
  SHA512:
6
- metadata.gz: e4713798681903cf286e1779b66726f4ffb2873a64d13528ec98571ca29008e69c16f6859173d86238488eda3e792f1e340964324e553c1b09b022776328be7a
7
- data.tar.gz: d1c6c6fe3a52a510426072daca08361604c2371158cc0dbca879dde91e36e3a2061451a3eeacc83cea1611000936a680c9b59aa1c2c1c76725f9fd6ca3c2dca8
6
+ metadata.gz: 153c3a70e9ca2d91f60c0eff6cac580c911e3dfabe60d65a6f1a77588523df25a3ec364735850277df819bd1039bca03e67260cf4c9cf5711f54919bb22fe835
7
+ data.tar.gz: 3529f9a7e3f94466370d84590870d5e99339897dfb399d10498df3ebb6f0537e77d7a9807125971e998fc23e6c1f0fb9aae32dab7c8af6d6de782186c8505c74
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_analytics_api (0.0.2)
4
+ simple_analytics_api (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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-31 23:59'
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')
@@ -1,3 +1,3 @@
1
1
  module SimpleAnalyticsApi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-16 00:00:00.000000000 Z
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: