plausible_api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 799fea9f2d094075ca64a58235d62031d0f701c62b031e7f15982bbf2595d36e
4
- data.tar.gz: 2a4de4e741a1cee1858dfe132102c5a2d937a27382134b80e6a8e4ca28fa327c
3
+ metadata.gz: 1ab7e5d90aa275223a1b9006a563093a7ac9e7ceb0be4efdb2539a511361a15b
4
+ data.tar.gz: f42c1294d5a65bb6ed07043a99c8febf4f42dc88d1b722632d86af2d845dd216
5
5
  SHA512:
6
- metadata.gz: 57f336396b61f956dc2814fb1de4f628d7e0070334789488d0aa2ec257aec09f4ad6ef93e6fecef490049aa6884cccc72c5b2a56277bd0567923ceb1bc8b4750
7
- data.tar.gz: 635da11edc92ad2c69a6bcff7b1ea4211595c180babe00ca480450195151ec9270c1c1847067ad245dd720d5e4d2bcd833a3168fc212bf40bfde82831a5c213e
6
+ metadata.gz: d85ed0990813b05c2cd277e6544859bf7bfdb8875ee68c20d6d71ce62ffef1579878b6e459b35305fc825bfa20fd868c5157d24eb9114bb100b2f7ce7e1a6601
7
+ data.tar.gz: cb29f033d91225f2bdaa6cb908308444855d734b2fd3b146345915c593257db8689556a6d227775cd440683001756a377b770a6c36b3e248b88429fece538877
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plausible_api (0.1.0)
4
+ plausible_api (0.1.1)
5
5
  faraday (~> 1.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -9,7 +9,7 @@ gem 'plausible_api'
9
9
  ```
10
10
  Then you need to initialize a Client with your `site_id` (the domain) and your `token`.
11
11
  ```rb
12
- c = PlausibleApi::Client.new(site_id: 'dailytics.com', token: '123123')
12
+ c = PlausibleApi::Client.new('dailytics.com', '123123')
13
13
  ```
14
14
 
15
15
  ### Stats > Aggregate
@@ -19,7 +19,7 @@ You have all these options to get the aggregate stats
19
19
  # Use the default parameters (3mo period + the 4 main metrics)
20
20
  c.aggregate
21
21
 
22
- # Set parameters (period, metrics, filter, date)
22
+ # Set parameters (period, metrics, filter, compare)
23
23
  c.aggregate({ period: '30d' })
24
24
  c.aggregate({ period: '30d', metrics: 'visitors,pageviews' })
25
25
  c.aggregate({ period: '30d', metrics: 'visitors,pageviews', filters: 'event:page==/order/confirmation' })
@@ -35,19 +35,21 @@ You have all these options to get the timeseries
35
35
  # Use the default parameters (3mo period)
36
36
  c.timeseries
37
37
 
38
- # Set parameters (period, metrics, filter, date)
38
+ # Set parameters (period, filters, interval)
39
39
  c.timeseries({ period: '7d' })
40
- c.timeseries({ period: '7d', filters: 'event:page==/order/confirmation', date: '2020/02/10' })
40
+ c.timeseries({ period: '7d', filters: 'event:page==/order/confirmation' })
41
41
 
42
42
  # You'll get something like this:
43
43
  => [{"date"=>"2021-01-11", "value"=>100}, {"date"=>"2021-01-12", "value"=>120}, {"date"=>"2021-01-13", "value"=>80}...]
44
44
  ```
45
45
 
46
- ### Realtime >> Visitors
46
+ ### Realtime > Visitors
47
47
 
48
- You have a uniq way to call this data
48
+ It's as simple as:
49
49
  ```rb
50
50
  c.realtime_visitors
51
+
52
+ => 13
51
53
  ```
52
54
 
53
55
 
@@ -59,7 +61,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
59
61
 
60
62
  ## Contributing
61
63
 
62
- Bug reports and pull requests are welcome on GitHub at https://github.com/dailytics/plausible_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/dailytics/plausible_api/blob/master/CODE_OF_CONDUCT.md).
64
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dailytics/plausible_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/dailytics/plausible_api/blob/main/CODE_OF_CONDUCT.md).
63
65
 
64
66
 
65
67
  ## License
@@ -68,4 +70,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
68
70
 
69
71
  ## Code of Conduct
70
72
 
71
- Everyone interacting in the PlausibleApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dailytics/plausible_api/blob/master/CODE_OF_CONDUCT.md).
73
+ Everyone interacting in the PlausibleApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/dailytics/plausible_api/blob/main/CODE_OF_CONDUCT.md).
@@ -12,7 +12,7 @@ module PlausibleApi
12
12
 
13
13
  BASE_URL = 'https://plausible.io'
14
14
 
15
- def initialize(site_id:, token:)
15
+ def initialize(site_id, token)
16
16
  @site_id = site_id.to_s
17
17
  @token = token.to_s
18
18
  end
@@ -6,24 +6,16 @@ module PlausibleApi
6
6
  def initialize(options = {})
7
7
  @period = options[:period] || '30d'
8
8
  @metrics = options[:metrics] || 'visitors,pageviews,bounce_rate,visit_duration'
9
- @filters = options[:filters]
10
- @date = options[:date]
9
+ @filters = options[:filters]
10
+ @compare = options[:compare]
11
11
  end
12
12
 
13
13
  def request_url
14
14
  url = "/api/v1/stats/aggregate?site_id=$SITE_ID"
15
- if @period
16
- url += "&period=#{@period}"
17
- end
18
- if @metrics
19
- url += "&metrics=#{@metrics}"
20
- end
21
- if @filters
22
- url += "&filters=#{CGI.escape(@filters)}"
23
- end
24
- if @date
25
- url += "&date=#{@date}"
26
- end
15
+ url += "&period=#{@period}" if @period
16
+ url += "&metrics=#{@metrics}" if @metrics
17
+ url += "&filters=#{CGI.escape(@filters)}" if @filters
18
+ url += "&compare=#{@compare}" if @compare
27
19
  url
28
20
  end
29
21
  end
@@ -4,22 +4,16 @@ module PlausibleApi
4
4
  module Stats
5
5
  class Timeseries
6
6
  def initialize(options = {})
7
- @period = options[:period] || '30d'
8
- @filters = options[:filters]
9
- @date = options[:date]
7
+ @period = options[:period] || '30d'
8
+ @filters = options[:filters]
9
+ @interval = options[:interval]
10
10
  end
11
11
 
12
12
  def request_url
13
13
  url = "/api/v1/stats/timeseries?site_id=$SITE_ID"
14
- if @period
15
- url += "&period=#{@period}"
16
- end
17
- if @filters
18
- url += "&filters=#{CGI.escape(@filters)}"
19
- end
20
- if @date
21
- url += "&date=#{@date}"
22
- end
14
+ url += "&period=#{@period}" if @period
15
+ url += "&filters=#{CGI.escape(@filters)}" if @filters
16
+ url += "&interval=#{@interval}" if @interval
23
17
  url
24
18
  end
25
19
  end
@@ -1,3 +1,3 @@
1
1
  module PlausibleApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plausible_api
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
  - Gustavo Garcia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-12 00:00:00.000000000 Z
11
+ date: 2021-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday