callcounter 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: 694f83b9c21262d809ab3d266ff011d8f75c2a45b8260a6a6887ede4f1c360e5
4
- data.tar.gz: 1e83328f50e2bd7e6bed1230fdee6e27cba10b6d28e7cebc8dda449835598867
3
+ metadata.gz: 99d0cc0bcdf0500c5203169c4f24174faa1e34bc0d6b51b9caabac4c798916bb
4
+ data.tar.gz: 90df76c181d3ecbb4520fe277969a1abadaefab1c7f69adc7fe0dbb4e92592c5
5
5
  SHA512:
6
- metadata.gz: 9b999f9fc145d1b6691d0ba32d1344f8396df52efaa53973d2953abf0a38d471238ad61c6b0c536a3a5bad814538bade3046a29b9569ee22cf7a9b727013a57f
7
- data.tar.gz: 285d154f5da3904ccd4bf6750254061fe26e0c6ea8b9ef7a6ace9f2513e6eefcf94145c494a483f82a69645796e4bcfd916fe1af362fd95bd56d9d6c407bd2bb
6
+ metadata.gz: a41c1476531b297327569a83c1dbbe176a96731671351ac98d23a7755aa0c4b41c0351163eddc88ac20540e7c40593b3529fdd9d3b22230b06e0e0d1ff340481
7
+ data.tar.gz: 581cae38256f5ec226ddb541cc90463b99f22f96bfea2d14f694050bf34da2321c6227de2f5b5d1e896faddaa5954267d4bd564d7df502b3da1fd53a2ab1c39c
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2021, Webindie
1
+ Copyright (c) 2021, Lint Ltd
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -1,12 +1,9 @@
1
- [![builds.sr.ht status](https://builds.sr.ht/~webindie/callcounter-gem.svg)](https://builds.sr.ht/~webindie/callcounter-gem?)
2
-
3
1
  # Callcounter Ruby integration gem
4
2
 
5
3
  This gem can be used to gather API request & response data from Rack based applications and send it to Callcounter.
6
4
 
7
- Callcounter is an API analytics platform that collect information about requests (calls) to your API using so-called
8
- integrations. Integrations come in the form of a Ruby gem, a Nuget package, a Pip module, etcetera. The integrations
9
- can send the data to Callcounter using an API, which is described at: https://callcounter.eu/pages/api
5
+ Callcounter is an API analytics platform that collect information about requests (calls) to your API using so-called integrations. Integrations come in the form of a Ruby gem, a Nuget package, a Pip module, etc. The integrations
6
+ can send the data to Callcounter using an API, which is described at: https://callcounter.io/docs/api
10
7
 
11
8
  After collection data, the web interface can then be used to view all kinds of metrics, giving you insight in the
12
9
  (mis)usage of your API.
@@ -33,12 +30,11 @@ use Callcounter::Capturer
33
30
  ## Configure what to capture
34
31
 
35
32
  Configure callcounter with the following code, this can be placed in a Rails initializer when using Ruby on Rails,
36
- for example `config/initializers/callcounter.rb`, or somewhere in your entry point file when using Sinatra or other
37
- Rack based frameworks:
33
+ for example `config/initializers/callcounter.rb`, or somewhere in your entry point file when using Sinatra or other Rack based frameworks:
38
34
 
39
35
  ```ruby
40
36
  Callcounter.configure do |config|
41
- config.project_token = '' # TODO: fill with your unique project token
37
+ config.app_token = '' # TODO: fill with your unique app token
42
38
  end
43
39
  ```
44
40
 
@@ -47,11 +43,11 @@ After deploying you should start seeing data in Callcounter. Note that this migh
47
43
  only sends data every few requests or every few minutes.
48
44
 
49
45
  If you API doesn't match with the default matching rules, you can add a lambda that will be called for every request
50
- to determine whether it was a request to your API. For example, you can custome the default lambda shown below:
46
+ to determine whether it was a request to your API. For example, you can customise the default lambda shown below:
51
47
 
52
48
  ```ruby
53
49
  Callcounter.configure do |config|
54
- config.project_token = '' # TODO: fill with your unique project token
50
+ config.app_token = '' # TODO: fill with your unique app token
55
51
  config.track = lambda { |request|
56
52
  request.hostname.start_with?('api') || request.path.start_with?('/api')
57
53
  }
@@ -60,8 +56,8 @@ end
60
56
 
61
57
  ## Bug reporting
62
58
 
63
- Bugs can be reported through the Sourcehut todo lists found at: https://todo.sr.ht/~webindie/callcounter-gem
64
- If you don't want to sign up for an account, you can also contact us through https://callcounter.eu/contact
59
+ Bugs can be reported through the Github issues.
60
+ If you don't want to sign up for an account, you can also contact us through https://callcounter.io/contact
65
61
 
66
62
  ## Releasing
67
63
 
@@ -76,5 +72,5 @@ If you don't want to sign up for an account, you can also contact us through htt
76
72
 
77
73
  ## About Callcounter
78
74
 
79
- [Callcounter](https://callcounter.eu) is a service built by [Webindie](https://webindie.nl) that
75
+ [Callcounter](https://callcounter.io) is a service, developed and maintained by Lint Ltd, that
80
76
  helps API providers with debugging and optimising the usage of their APIs.
@@ -3,7 +3,7 @@
3
3
  require 'net/http'
4
4
 
5
5
  module Callcounter
6
- # class that captures the rack requests and sends them to callcounter.eu
6
+ # class that captures the rack requests and sends them to Callcounter
7
7
  class Capturer
8
8
  attr_accessor :buffer
9
9
 
@@ -17,7 +17,7 @@ module Callcounter
17
17
  result = @app.call(env)
18
18
  finish = Time.now
19
19
 
20
- return result if project_token.nil?
20
+ return result if app_token.nil?
21
21
 
22
22
  threading do
23
23
  background_work(start, finish, env, result)
@@ -38,6 +38,10 @@ module Callcounter
38
38
  Callcounter.configuration.project_token
39
39
  end
40
40
 
41
+ def app_token
42
+ Callcounter.configuration.app_token || project_token
43
+ end
44
+
41
45
  def async?
42
46
  Callcounter.configuration.async
43
47
  end
@@ -51,12 +55,12 @@ module Callcounter
51
55
  end
52
56
 
53
57
  def send_buffer
54
- http = Net::HTTP.new('api.callcounter.eu', 443)
58
+ http = Net::HTTP.new('api.callcounter.io', 443)
55
59
  http.use_ssl = true
56
60
  track = Net::HTTP::Post.new('/api/v1/events/batch')
57
61
  track['content-type'] = 'application/json'
58
62
  track['user-agent'] = "callcounter-gem (#{Callcounter::VERSION})"
59
- track.body = { batch: { project_token: project_token, events: @buffer } }.to_json
63
+ track.body = { batch: { project_token: app_token, events: @buffer } }.to_json
60
64
 
61
65
  http.request(track)
62
66
 
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Callcounter
4
- # configuration class for callcounter middleware
4
+ # configuration class for Callcounter middleware
5
5
  class Configuration
6
- attr_accessor :debug, :project_token, :track, :async
6
+ attr_accessor :debug, :project_token, :track, :async, :app_token
7
7
 
8
8
  def initialize
9
9
  @debug = false
10
10
  @project_token = nil
11
+ @app_token = nil
11
12
  @track = lambda { |request|
12
13
  return request.hostname.start_with?('api') || request.path.start_with?('/api')
13
14
  }
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Callcounter
4
- # enable the callcounter rack middleware automatically in rails
4
+ # enable the Callcounter rack middleware automatically in rails
5
5
  class Railtie < Rails::Railtie
6
6
  initializer 'callcounter.middleware' do |app|
7
7
  app.middleware.use(Callcounter::Capturer)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Callcounter
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.4'
5
5
  end
data/lib/callcounter.rb CHANGED
@@ -5,7 +5,7 @@ require 'callcounter/configuration'
5
5
  require 'callcounter/railtie' if defined?(Rails::Railtie)
6
6
  require 'callcounter/version'
7
7
 
8
- # rack middleware that captures incoming api requests and sends them to callcounter.eu
8
+ # rack middleware that captures incoming api requests and sends them to Callcounter
9
9
  module Callcounter
10
10
  class << self
11
11
  attr_writer :configuration
metadata CHANGED
@@ -1,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: callcounter
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
- - Webindie
7
+ - George Buckley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-03 00:00:00.000000000 Z
11
+ date: 2022-01-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Callcounter is a service that helps API providers with debugging and
14
14
  optimising the usage of their APIs.
15
- email: frank@webindie.nl
15
+ email:
16
+ - george@lint.com
16
17
  executables: []
17
18
  extensions: []
18
19
  extra_rdoc_files: []
@@ -24,11 +25,9 @@ files:
24
25
  - lib/callcounter/configuration.rb
25
26
  - lib/callcounter/railtie.rb
26
27
  - lib/callcounter/version.rb
27
- homepage: https://callcounter.eu
28
- licenses:
29
- - BSD-2-Clause
30
- metadata:
31
- source_code_uri: https://git.sr.ht/~webindie/callcounter-gem
28
+ homepage: https://github.com/Callcounter/callcounter-ruby
29
+ licenses: []
30
+ metadata: {}
32
31
  post_install_message:
33
32
  rdoc_options: []
34
33
  require_paths:
@@ -37,14 +36,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: 2.5.0
39
+ version: '0'
41
40
  required_rubygems_version: !ruby/object:Gem::Requirement
42
41
  requirements:
43
42
  - - ">="
44
43
  - !ruby/object:Gem::Version
45
44
  version: '0'
46
45
  requirements: []
47
- rubygems_version: 3.2.15
46
+ rubygems_version: 3.2.32
48
47
  signing_key:
49
48
  specification_version: 4
50
49
  summary: Callcounter integration gem to gather API request statistics