pirsch_api 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +58 -26
- data/lib/pirsch_api/objects/domain.rb +3 -0
- data/lib/pirsch_api/resources/base.rb +1 -1
- data/lib/pirsch_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b41470047653a8abd5e3eff60fe44bef1d2afb51c82279ef48879be999fc8243
|
4
|
+
data.tar.gz: fdb4e7546d50d6049f48e727781ecb2e9395b105e4149aa01e83070340c97c43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b4aa5375433d5a9196928eecddbf7d8edfcaa39161853dd84cfe51e1bf9e9bfa71e733755982ecd1014c87a52d995e34acc327911f45ce0d1fd7ea59a0e1979
|
7
|
+
data.tar.gz: 2d0763db86bbaeb91027bbdad1ef3baacb01fe8ebf91e6e80051026e8700a74f44c54b9684c5e3e62c1ee7830e1b0e960645f63d5e100885e67bcda9995768b1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,54 +4,86 @@ It's based on the [API guide](https://docs.pirsch.io/api-sdks/api/)
|
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
Add this gem to your Gemfile:
|
7
|
+
|
7
8
|
```rb
|
8
9
|
gem 'pirsch_api'
|
9
10
|
```
|
10
|
-
|
11
|
+
|
12
|
+
Now you need to initialize a Client with your `client_id` and the `client_secret`.
|
13
|
+
|
11
14
|
```rb
|
12
|
-
|
15
|
+
client = PirschApi::Client.new(client_id: '<client_id>', client_secret: '<client_secret>')
|
13
16
|
|
14
17
|
# Test if the credentials are valid
|
15
|
-
|
18
|
+
client.valid?
|
16
19
|
=> true
|
20
|
+
```
|
21
|
+
|
22
|
+
You will need a `Domain` as a parameter to all the following methods. This parameter could be either
|
23
|
+
a `PisrchApi::Domain` instance or a simple String containing the `id` of one domain.
|
17
24
|
|
25
|
+
```rb
|
18
26
|
# Get /domains
|
19
|
-
|
27
|
+
client.domains
|
20
28
|
=> [#<PirschApi::Domain id="0D3a...", user_id="0D3a...", hostname="pirsch.io", subdomain="pirsch", ... >]
|
21
|
-
c.domains.first
|
29
|
+
domain = c.domains.first
|
30
|
+
domain.hostname
|
22
31
|
=> "pirsch.io"
|
32
|
+
domain.id
|
33
|
+
=> "0D3a..."
|
34
|
+
domain.to_s
|
35
|
+
=> "0D3a..."
|
36
|
+
```
|
37
|
+
All the following methods receive a `domain` and an optional `filters` hash as a parameter. You can include any filter defined in the official documentation.
|
38
|
+
|
39
|
+
```rb
|
40
|
+
# Get /statistics/visitors
|
41
|
+
client.visitors(domain: domain)
|
42
|
+
|
43
|
+
# Get /statistics/active
|
44
|
+
client.active(domain: domain)
|
45
|
+
|
46
|
+
# Get /statistics/pages
|
47
|
+
client.pages(domain: domain)
|
23
48
|
|
24
|
-
#
|
25
|
-
|
49
|
+
# Get /statistics/referrers
|
50
|
+
client.referrers(domain: domain)
|
26
51
|
|
27
|
-
#
|
52
|
+
# Get /statistics/growth
|
53
|
+
client.growth(domain: domain)
|
28
54
|
|
29
|
-
# Get /statistics/
|
30
|
-
|
55
|
+
# Get /statistics/events
|
56
|
+
client.events(domain: domain)
|
57
|
+
|
58
|
+
# Get /statistics/utm/source
|
59
|
+
client.utm_source(domain: domain)
|
60
|
+
|
61
|
+
# Get /statistics/utm/medium
|
62
|
+
client.utm_medium(domain: domain)
|
63
|
+
|
64
|
+
# Get /statistics/utm/campaign
|
65
|
+
client.utm_campaign(domain: domain)
|
66
|
+
```
|
67
|
+
|
68
|
+
## Examples
|
69
|
+
```rb
|
70
|
+
|
71
|
+
client.visitors(domain: d)
|
31
72
|
=> [#<PirschApi::Visitor day="2021-08-30T00:00:00Z", visitors=87, views=200, sessions=125, bounces=53, bounce_rate=0.6091954022988506>, #<PirschApi::Visitor day="2021-08-31T00:00:00Z", visitors=77, views=159, sessions=113, bounces=49, bounce_rate=0.6363636363636364>, #<PirschApi::Visitor day="2021-09-01T00:00:00Z", visitors=76, views=161, sessions=110, bounces=48, bounce_rate=0.631578947368421>, #<PirschApi::Visitor day="2021-09-02T00:00:00Z", visitors=79, views=152, sessions=130, bounces=52, bounce_rate=0.6582278481012658>, #<PirschApi::Visitor day="2021-09-03T00:00:00Z", visitors=53, views=109, sessions=68, bounces=26, bounce_rate=0.49056603773584906>, #<PirschApi::Visitor day="2021-09-04T00:00:00Z", visitors=54, views=126, sessions=71, bounces=31, bounce_rate=0.5740740740740741>, #<PirschApi::Visitor day="2021-09-05T00:00:00Z", visitors=116, views=202, sessions=131, bounces=84, bounce_rate=0.7241379310344828>, #<PirschApi::Visitor day="2021-09-06T00:00:00Z", visitors=1, views=1, sessions=1, bounces=1, bounce_rate=1>]
|
32
|
-
|
33
|
-
|
34
|
-
|
73
|
+
|
74
|
+
client.visitors(domain: d, filters: { from: '2021-09-01' })
|
75
|
+
=> [#<PirschApi::Visitor day="2021-09-01T00:00:00Z", visitors=76, views=161, sessions=110, bounces=48, bounce_rate=0.631578947368421>, #<PirschApi::Visitor day="2021-09-02T00:00:00Z", visitors=79, views=152, sessions=130, bounces=52, bounce_rate=0.6582278481012658>, #<PirschApi::Visitor day="2021-09-03T00:00:00Z", visitors=53, views=109, sessions=68, bounces=26, bounce_rate=0.49056603773584906>, #<PirschApi::Visitor day="2021-09-04T00:00:00Z", visitors=54, views=126, sessions=71, bounces=31, bounce_rate=0.5740740740740741>, #<PirschApi::Visitor day="2021-09-05T00:00:00Z", visitors=116, views=202, sessions=131, bounces=84, bounce_rate=0.7241379310344828>, #<PirschApi::Visitor day="2021-09-06T00:00:00Z", visitors=1, views=1, sessions=1, bounces=1, bounce_rate=1>]
|
76
|
+
|
77
|
+
client.visitors(domain: d, filters: { from: '2021-09-01' }).first.day
|
35
78
|
=> "2021-09-01T00:00:00Z"
|
36
79
|
|
37
80
|
# Get /statistics/active
|
38
|
-
|
81
|
+
client.active(domain: d)
|
39
82
|
=> #<PirschApi::Active stats=nil, visitors=0>
|
40
|
-
|
83
|
+
client.active(domain: d).visitors
|
41
84
|
=> 0
|
42
|
-
|
43
|
-
# Other available methods (Remember that they can all receive a `filters` hash)
|
44
|
-
c.pages(domain: d)
|
45
|
-
c.referrers(domain: d)
|
46
|
-
c.active(domain: d)
|
47
|
-
c.growth(domain: d)
|
48
|
-
c.events(domain: d)
|
49
|
-
c.utm_source(domain: d)
|
50
|
-
c.utm_medium(domain: d)
|
51
|
-
c.utm_campaign(domain: d)
|
52
85
|
```
|
53
86
|
|
54
|
-
|
55
87
|
## Development
|
56
88
|
|
57
89
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/pirsch_api/version.rb
CHANGED