supergood 0.1.3 → 0.1.5
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 +2 -2
- data/lib/supergood/api.rb +2 -2
- data/lib/supergood/client.rb +10 -3
- 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: a20e9c78ef66594eaed117db23b1581b3531497aaf3a087ad92466f76a8e07a8
|
4
|
+
data.tar.gz: 22e62c82c3cea5bfba10a8d5199ebf1a385bab78861c6f20efcd55921e65eee0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da801337729a2975cd42231da0de2e773aafdcc0a391a69111b4acb55dfe1d8126e1017e72481688dcf410d23a072c51204e9885e8938d9903ed1f947de94bfc
|
7
|
+
data.tar.gz: b9848d4363bcb7b04bb19b46dc61f8adcb8bbf9b911664a3ba367721f171e2ad950c3fdcb3d236192fe5c160e4d33aa926615583647c7b3e44b0038fc4ed6c27
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ gem install supergood
|
|
12
12
|
|
13
13
|
**Environment variables**
|
14
14
|
|
15
|
-
Set the environment variables `SUPERGOOD_CLIENT_ID` and `SUPERGOOD_CLIENT_SECRET` using the API keys generated in the [getting started instructions](
|
15
|
+
Set the environment variables `SUPERGOOD_CLIENT_ID` and `SUPERGOOD_CLIENT_SECRET` using the API keys generated in the [getting started instructions](https://github.com/supergoodsystems/docs/blob/main/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
|
|
@@ -26,7 +26,7 @@ Supergood.init()
|
|
26
26
|
|
27
27
|
You can also pass the API keys in manually without setting environment variables.\
|
28
28
|
\
|
29
|
-
Replace `<CLIENT_ID>` and `<CLIENT_SECRET>` with the API keys you generated in the [getting started instructions](
|
29
|
+
Replace `<CLIENT_ID>` and `<CLIENT_SECRET>` with the API keys you generated in the [getting started instructions](https://github.com/supergoodsystems/docs/blob/main/getting-started.md).
|
30
30
|
|
31
31
|
```ruby
|
32
32
|
require 'supergood'
|
data/lib/supergood/api.rb
CHANGED
@@ -29,7 +29,7 @@ module Supergood
|
|
29
29
|
if @local_only
|
30
30
|
@log.debug(payload)
|
31
31
|
else
|
32
|
-
uri = URI(@base_url + '/
|
32
|
+
uri = URI(@base_url + '/events')
|
33
33
|
response = Net::HTTP.post(uri, payload.to_json, @header_options)
|
34
34
|
if response.code == '200'
|
35
35
|
return JSON.parse(response.body, symbolize_names: true)
|
@@ -45,7 +45,7 @@ module Supergood
|
|
45
45
|
if @local_only
|
46
46
|
@log.debug(payload)
|
47
47
|
else
|
48
|
-
uri = URI(@base_url + '/
|
48
|
+
uri = URI(@base_url + '/errors')
|
49
49
|
response = Net::HTTP.post(uri, payload.to_json, @header_options)
|
50
50
|
if response.code == '200'
|
51
51
|
return JSON.parse(response.body, symbolize_names: true)
|
data/lib/supergood/client.rb
CHANGED
@@ -11,7 +11,7 @@ Dotenv.load
|
|
11
11
|
|
12
12
|
module Supergood
|
13
13
|
|
14
|
-
DEFAULT_SUPERGOOD_BASE_URL = 'https://
|
14
|
+
DEFAULT_SUPERGOOD_BASE_URL = 'https://api.supergood.ai'
|
15
15
|
class << self
|
16
16
|
def init(config={})
|
17
17
|
supergood_client_id = config[:client_id] || ENV['SUPERGOOD_CLIENT_ID']
|
@@ -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?
|
@@ -118,11 +120,13 @@ module Supergood
|
|
118
120
|
request_id = SecureRandom.uuid
|
119
121
|
requested_at = Time.now
|
120
122
|
if !ignored?(request[:domain])
|
123
|
+
puts "Caching Request"
|
121
124
|
cache_request(request_id, requested_at, request)
|
122
125
|
end
|
123
126
|
|
124
127
|
response = yield
|
125
128
|
if !ignored?(request[:domain]) && defined?(response)
|
129
|
+
puts "Caching Response"
|
126
130
|
cache_response(request_id, requested_at, response)
|
127
131
|
end
|
128
132
|
|
@@ -178,10 +182,13 @@ module Supergood
|
|
178
182
|
base_domain = URI.parse(@base_url).hostname
|
179
183
|
if domain == base_domain
|
180
184
|
return true
|
185
|
+
elsif @allowed_domains.any?
|
186
|
+
@allowed_domains.all? do |allowed_domain|
|
187
|
+
!domain.include? allowed_domain
|
188
|
+
end
|
181
189
|
else
|
182
190
|
@ignored_domains.any? do |ignored_domain|
|
183
|
-
|
184
|
-
domain =~ pattern
|
191
|
+
domain.include? ignored_domain
|
185
192
|
end
|
186
193
|
end
|
187
194
|
end
|
data/lib/supergood/constants.rb
CHANGED
data/lib/supergood/version.rb
CHANGED