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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0cdb2377e5748a6ed76d61765fe3b15b648f397a97d6c9cdd28b592d68fd323
4
- data.tar.gz: '099acaa41f71ef93c745960d9ec046b6643f68501fd95d140a1dd7c62eec76d1'
3
+ metadata.gz: 37e6e9b772961c8468ce6b56f08b88e16f6be31e22b123ec629695da7a1d0e06
4
+ data.tar.gz: 57497dfc8b8609f8e97c063079e908db68252cce6d59bb5ff80096fee39873e2
5
5
  SHA512:
6
- metadata.gz: 2c15df0347deb5fcb0a0fdf04054595f8c4c9ef8b4da4fabc7879d6098fbe9595c507902ed6f7ccab95b47877f139d9121a1ecea885cb5f814ec86942cb37b3b
7
- data.tar.gz: 97beed9cd863cd1175756b3084601a40f53928c205b3a3583ca04931a88f6a4804041b8506dfd7277f4232ed1bb7bad3a6eaf5494fe847955dff22439e1882c7
6
+ metadata.gz: 35716cb5a956905973fb36193e13fa57527184291ee6f557d721f01dac2d7e53c139fdf924b4a2c68a568aec9dcc909cdf0ba8e40f6ac6a99945841de1685bc0
7
+ data.tar.gz: 40d19c986a555912c4e7040f4bf2d4ee57680738c3506ae6c341f771b60ed1e51fa3c8fb4f3482469f898e493e165d9b2e8bc969188f25ffb488e64ee6250bb8
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
@@ -1,50 +1,50 @@
1
- # Supergood
1
+ # Ruby
2
2
 
3
- Monitor the cost and performance of your external API's with two lines of code.
3
+ The Supergood Ruby client connects Supergood to your Ruby application. Follow these steps to integrate with the Ruby client.
4
4
 
5
- Interested in learning more? Check us out at https://supergood.ai or Reach out to alex@supergood.ai .
5
+ ## 1. Install the Supergood library
6
6
 
7
- Not built on Ruby? We've got a node client, python client and golang client as well.
7
+ ```bash
8
+ gem install supergood
9
+ ```
8
10
 
9
- ## Installation
11
+ ## 2. Initialize the Supergood Library
10
12
 
11
- Add this line to your application's Gemfile:
13
+ **Environment variables**
12
14
 
13
- ```ruby
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
- And then execute:
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
- $ bundle install
20
-
21
- Or install it yourself as:
19
+ ```ruby
20
+ require 'supergood'
22
21
 
23
- $ gem install supergood
22
+ Supergood.init()
23
+ ```
24
24
 
25
- ## Usage
25
+ **Passing keys**
26
26
 
27
- 1. Head over to https://dashboard.supergood.ai and make an account, make sure to use your work email address!
28
- 2. Click on the tab labeled "API Keys" and generate a client id and client secret.
29
- 3. Head back to your code and initialize the Supergood client one of two ways:
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(<client_id>, <client_secret>)
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
- ## Development
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
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+ ## 3. Monitor your API calls
44
42
 
45
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+ You're all set to use Supergood!
46
44
 
47
- ## Contributing
45
+ Head back to your [dashboard](https://dashboard.supergood.ai) to start monitoring your API calls and receiving reports.
48
46
 
49
- Bug reports and pull requests are welcome on GitHub at https://github.com/supergoodsystems/supergood-rb.
47
+ ## Links
50
48
 
49
+ * [Supergood RubyGems Project](https://rubygems.org/gems/supergood)
50
+ * [Supergood-rb Source Code](https://github.com/supergoodsystems/supergood-rb)
@@ -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
- pattern = URI.parse(ignored_domain).hostname
187
- domain =~ pattern
189
+ domain.include? ignored_domain
188
190
  end
189
191
  end
190
192
  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.2'.freeze
2
+ VERSION = '0.1.4'.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.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Klarfeld