supergood 0.1.2 → 0.1.4
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 +28 -28
- data/lib/supergood/client.rb +7 -5
- data/lib/supergood/constants.rb +2 -1
- data/lib/supergood/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: 37e6e9b772961c8468ce6b56f08b88e16f6be31e22b123ec629695da7a1d0e06
|
4
|
+
data.tar.gz: 57497dfc8b8609f8e97c063079e908db68252cce6d59bb5ff80096fee39873e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35716cb5a956905973fb36193e13fa57527184291ee6f557d721f01dac2d7e53c139fdf924b4a2c68a568aec9dcc909cdf0ba8e40f6ac6a99945841de1685bc0
|
7
|
+
data.tar.gz: 40d19c986a555912c4e7040f4bf2d4ee57680738c3506ae6c341f771b60ed1e51fa3c8fb4f3482469f898e493e165d9b2e8bc969188f25ffb488e64ee6250bb8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,50 +1,50 @@
|
|
1
|
-
#
|
1
|
+
# Ruby
|
2
2
|
|
3
|
-
|
3
|
+
The Supergood Ruby client connects Supergood to your Ruby application. Follow these steps to integrate with the Ruby client.
|
4
4
|
|
5
|
-
|
5
|
+
## 1. Install the Supergood library
|
6
6
|
|
7
|
-
|
7
|
+
```bash
|
8
|
+
gem install supergood
|
9
|
+
```
|
8
10
|
|
9
|
-
##
|
11
|
+
## 2. Initialize the Supergood Library
|
10
12
|
|
11
|
-
|
13
|
+
**Environment variables**
|
12
14
|
|
13
|
-
|
14
|
-
gem 'supergood'
|
15
|
-
```
|
15
|
+
Set the environment variables `SUPERGOOD_CLIENT_ID` and `SUPERGOOD_CLIENT_SECRET` using the API keys generated in the [getting started instructions](../../getting-started.md).
|
16
16
|
|
17
|
-
|
17
|
+
Initialize the Supergood client at the root of your application, or anywhere you're making API calls with the following code:
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
Or install it yourself as:
|
19
|
+
```ruby
|
20
|
+
require 'supergood'
|
22
21
|
|
23
|
-
|
22
|
+
Supergood.init()
|
23
|
+
```
|
24
24
|
|
25
|
-
|
25
|
+
**Passing keys**
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
You can also pass the API keys in manually without setting environment variables.\
|
28
|
+
\
|
29
|
+
Replace `<CLIENT_ID>` and `<CLIENT_SECRET>` with the API keys you generated in the [getting started instructions](../../getting-started.md).
|
30
30
|
|
31
|
-
```
|
31
|
+
```ruby
|
32
32
|
require 'supergood'
|
33
33
|
|
34
|
-
Supergood.init(
|
34
|
+
Supergood.init({ client_id: "<CLIENT_ID>", client_secret: "<CLIENT_SECRET>" })
|
35
35
|
```
|
36
|
-
OR
|
37
|
-
|
38
|
-
set `SUPERGOOD_CLIENT_ID` and `SUPERGOOD_CLIENT_SECRET` as environment variables and leave the init function as `Supergood.init`
|
39
36
|
|
37
|
+
#### Local development
|
40
38
|
|
41
|
-
|
39
|
+
Setting the `CLIENT_ID` and `CLIENT_SECRET_ID` to `local-client-id` and `local-client-secret`, respectively, will disable making API calls to the supergood.ai server and instead log the payloads to the local console.
|
42
40
|
|
43
|
-
|
41
|
+
## 3. Monitor your API calls
|
44
42
|
|
45
|
-
|
43
|
+
You're all set to use Supergood!
|
46
44
|
|
47
|
-
|
45
|
+
Head back to your [dashboard](https://dashboard.supergood.ai) to start monitoring your API calls and receiving reports.
|
48
46
|
|
49
|
-
|
47
|
+
## Links
|
50
48
|
|
49
|
+
* [Supergood RubyGems Project](https://rubygems.org/gems/supergood)
|
50
|
+
* [Supergood-rb Source Code](https://github.com/supergoodsystems/supergood-rb)
|
data/lib/supergood/client.rb
CHANGED
@@ -29,6 +29,7 @@ module Supergood
|
|
29
29
|
@api = Supergood::Api.new(supergood_client_id, supergood_client_secret, @base_url)
|
30
30
|
@config = Supergood::Utils.make_config(config)
|
31
31
|
|
32
|
+
@allowed_domains = @config[:allowedDomains]
|
32
33
|
@ignored_domains = @config[:ignoredDomains]
|
33
34
|
@keys_to_hash = @config[:keysToHash]
|
34
35
|
@logger = Supergood::Logger.new(@api, @config, @api.header_options)
|
@@ -59,6 +60,7 @@ module Supergood
|
|
59
60
|
|
60
61
|
def flush_cache(force = false)
|
61
62
|
# If there's notthing in the response cache, and we're not forcing a flush, then return
|
63
|
+
|
62
64
|
if @response_cache.empty? && !force
|
63
65
|
return
|
64
66
|
elsif force && @response_cache.empty? && @request_cache.empty?
|
@@ -75,7 +77,6 @@ module Supergood
|
|
75
77
|
api.post_events(data)
|
76
78
|
rescue => e
|
77
79
|
log.error(data, e, e.message)
|
78
|
-
cleanup()
|
79
80
|
ensure
|
80
81
|
@response_cache.clear
|
81
82
|
@request_cache.clear if force
|
@@ -147,7 +148,6 @@ module Supergood
|
|
147
148
|
}
|
148
149
|
rescue => e
|
149
150
|
log.error({ request: request }, e, ERRORS[:CACHING_REQUEST])
|
150
|
-
cleanup()
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
@@ -173,7 +173,6 @@ module Supergood
|
|
173
173
|
{ request: request_payload, response: response_payload },
|
174
174
|
e, ERRORS[:CACHING_RESPONSE]
|
175
175
|
)
|
176
|
-
cleanup()
|
177
176
|
end
|
178
177
|
end
|
179
178
|
|
@@ -181,10 +180,13 @@ module Supergood
|
|
181
180
|
base_domain = URI.parse(@base_url).hostname
|
182
181
|
if domain == base_domain
|
183
182
|
return true
|
183
|
+
elsif @allowed_domains.any?
|
184
|
+
@allowed_domains.all? do |allowed_domain|
|
185
|
+
!domain.include? allowed_domain
|
186
|
+
end
|
184
187
|
else
|
185
188
|
@ignored_domains.any? do |ignored_domain|
|
186
|
-
|
187
|
-
domain =~ pattern
|
189
|
+
domain.include? ignored_domain
|
188
190
|
end
|
189
191
|
end
|
190
192
|
end
|
data/lib/supergood/constants.rb
CHANGED
data/lib/supergood/version.rb
CHANGED