supergood 0.1.3 → 0.1.5

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: 8b55de34e8a2ab872a9d2556a4e1e8a4e544bff0536c02fcf123fb93c30fde87
4
- data.tar.gz: 974a1af1a188f5a85e77c603e9545370c360367edeb4327c009c6b12ec44a8b9
3
+ metadata.gz: a20e9c78ef66594eaed117db23b1581b3531497aaf3a087ad92466f76a8e07a8
4
+ data.tar.gz: 22e62c82c3cea5bfba10a8d5199ebf1a385bab78861c6f20efcd55921e65eee0
5
5
  SHA512:
6
- metadata.gz: c0c8f7c3b9af56109324314aa9af0220624bf9d05d2e06a8d2706b5cfac3f6d6ba2e7e8613b82803cc7365e66e6e76d85b1180c62d368ae01f55892276b730c3
7
- data.tar.gz: 5bf07755f863ca866c5381f465957689616826f6db09734beda707a15099fc55b3a1fcee4b76f5c9df6623a5b5b1d9b26cb1782924a480e5f66dc279ae353a8b
6
+ metadata.gz: da801337729a2975cd42231da0de2e773aafdcc0a391a69111b4acb55dfe1d8126e1017e72481688dcf410d23a072c51204e9885e8938d9903ed1f947de94bfc
7
+ data.tar.gz: b9848d4363bcb7b04bb19b46dc61f8adcb8bbf9b911664a3ba367721f171e2ad950c3fdcb3d236192fe5c160e4d33aa926615583647c7b3e44b0038fc4ed6c27
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- supergood (0.1.1)
4
+ supergood (0.1.3)
5
5
  rudash (~> 4.0, >= 4.0.2)
6
6
 
7
7
  GEM
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](../../getting-started.md).
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](../../getting-started.md).
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 + '/api/events')
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 + '/api/errors')
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)
@@ -11,7 +11,7 @@ Dotenv.load
11
11
 
12
12
  module Supergood
13
13
 
14
- DEFAULT_SUPERGOOD_BASE_URL = 'https://dashboard.supergood.ai'
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
- pattern = URI.parse(ignored_domain).hostname
184
- domain =~ pattern
191
+ domain.include? ignored_domain
185
192
  end
186
193
  end
187
194
  end
@@ -21,7 +21,8 @@ DEFAULT_SUPERGOOD_BYTE_LIMIT = 500000
21
21
  DEFAULT_CONFIG = {
22
22
  keysToHash: [],
23
23
  flushInterval: 1000,
24
- ignoredDomains: []
24
+ ignoredDomains: [],
25
+ allowedDomains: [],
25
26
  }
26
27
 
27
28
  # GZIP_START_BYTES = b'\x1f\x8b'
@@ -1,3 +1,3 @@
1
1
  module Supergood
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supergood
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Klarfeld