staccato-rack 0.4.2 → 0.4.3

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjM1N2Y2NDhhMjkzNTQ4OWU4M2EwNzc4NTM0OGJlOThiMmQ3ZTI0YQ==
4
+ Zjc5YjI0MjBkZDQ3MWNlZWZmMDNjMjQxODQzNTI3ZDczZjEwODdiOQ==
5
5
  data.tar.gz: !binary |-
6
- Y2JhMWJjNmI2NDA5ZjZmY2MwNmYzMzUzNzczNmUzZDM2YWUzMTk1Zg==
6
+ MzZlMjlmNjgzNjQxZDQ2YjEyZjAxNTg3MDVjMGU0YzliOGFmZjg5MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODUwYTExZWE5MmMyY2ZkNDU2MzkzMWU2M2IxN2I1MmNiYTMxYjJkYTMxMjBi
10
- Y2MyY2YwMzk3OTc4MGEyMDk2NzYxNTRkMmU1MzQ4OWE5ZjBiNmQ3OTdiZGY4
11
- NmJmNjhhN2JmYWI3ZDg5NjE5ZjNlODgzYTJkM2Q3MzNhNjdhZWE=
9
+ YjNjMDIxYjhhMDhkODFlMGQyZTBjNjUzYjM2Nzk1YTRmYTNiNTMwMmUxOGQ3
10
+ YTczMjg2Y2M3YTU3MTk2NjE5ZDZlZjM2YWIxZTI5MzkxZGM4YjAzY2JhZTIx
11
+ MTFjMWY2OWMxZmVmOTlhZGY0MWM0NzE0MjJhNWYzMGExNmI5NDU=
12
12
  data.tar.gz: !binary |-
13
- NGMyNzcxMDZhOWE4MTE5OWEzYWZlOWQzN2Q0ZTljYmI2MmY2MDI3ZmQwZTMy
14
- MzFiOGY1ZTEyMWY4MTdlYWEwZjZkY2M3NDc4ZTAzZTgzMjJjZjJmODIzNWI3
15
- NjQ2ZjZhMzNkNGYwZmQ2YmUxMWQ1ODNhMDQwZTU1ZDM1YzQxMmE=
13
+ NGJiMjljY2YzMmE1NmFkMmExNTc0Y2VlODAwN2RiOGU0MTkyZGZlYjBjZTU3
14
+ ZDJhMzllNDU4MzFlODdhNDk0NzU0NzU4NzllOTJhZDY4YWFmOWFmYzVkNGQ5
15
+ NDI2NDEyNjczN2NkYjUyN2QzNDdjMTJiYjNiMTgzZDMwOGMyMmM=
data/README.md CHANGED
@@ -38,6 +38,8 @@ if you want logging in rails add a initializers file with the following
38
38
  end
39
39
  ```
40
40
 
41
+ Note that all post to Google analytics are does in a separate thread to prevent holding up the rack request
42
+
41
43
  ## Development
42
44
 
43
45
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -3,7 +3,7 @@ require 'rack/request'
3
3
  require 'staccato'
4
4
 
5
5
  require 'staccato/rack/version'
6
- require 'staccato/rack/faraday_http_adapter'
6
+ require 'staccato/rack/faraday_async_http_adapter'
7
7
  require 'staccato/rack/page_view'
8
8
 
9
9
  module Staccato
@@ -19,7 +19,7 @@ module Staccato
19
19
  @tracking_id = tracking_id
20
20
  @logger = options[:logger]
21
21
  @default_tracker = Staccato.tracker(tracking_id) do |c|
22
- c.adapter = FaradayHttpAdaper.new(@logger) unless tracking_id == nil
22
+ c.adapter = FaradayAsyncHttpAdaper.new(@logger) unless tracking_id.nil?
23
23
  end
24
24
  end
25
25
 
@@ -2,8 +2,8 @@ require 'faraday'
2
2
 
3
3
  module Staccato
4
4
  module Rack
5
- # Proxy Class to do page views
6
- class FaradayHttpAdaper
5
+ # Staccato HttpAdaper to do async post
6
+ class FaradayAsyncHttpAdaper
7
7
  def initialize(logger = nil)
8
8
  @logger = logger
9
9
  @conn = Faraday.new(url: 'https://ssl.google-analytics.com') do |faraday|
@@ -13,7 +13,7 @@ module Staccato
13
13
  end
14
14
  end
15
15
 
16
- def post(data, url = '/collect')
16
+ def async_post(data, url = '/collect')
17
17
  Thread.new(data, url) do
18
18
  begin
19
19
  execute(data, url)
@@ -23,6 +23,8 @@ module Staccato
23
23
  end
24
24
  end
25
25
 
26
+ alias_method :post, :async_post # Faraday adapater expects a post method
27
+
26
28
  private
27
29
 
28
30
  def execute(post_data, post_url)
@@ -22,7 +22,7 @@ module Staccato
22
22
  page_view_params = marshal_dump
23
23
  if page_view_params[:client_id]
24
24
  tracker = Staccato.tracker(tracking_id, page_view_params[:client_id]) do |c|
25
- c.adapter = FaradayHttpAdaper.new(logger) unless tracking_id == nil
25
+ c.adapter = FaradayAsyncHttpAdaper.new(logger) unless tracking_id.nil?
26
26
  end
27
27
  else
28
28
  tracker = default_tracker
@@ -2,6 +2,6 @@
2
2
  module Staccato
3
3
  # rack module
4
4
  module Rack
5
- VERSION = '0.4.2'
5
+ VERSION = '0.4.3'
6
6
  end
7
7
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = 'Simple rack middleware using Staccato'
13
13
  spec.description = 'Rack middleware to send analytics to google using Staccato with the aim to be used for apis'
14
- spec.homepage = 'https://github.com/unboxed/staccato-rack'
14
+ spec.homepage = 'https://github.com/grantspeelman/staccato-rack'
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staccato-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Speelman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-16 00:00:00.000000000 Z
11
+ date: 2015-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -183,11 +183,11 @@ files:
183
183
  - bin/console
184
184
  - bin/setup
185
185
  - lib/staccato/rack.rb
186
- - lib/staccato/rack/faraday_http_adapter.rb
186
+ - lib/staccato/rack/faraday_async_http_adapter.rb
187
187
  - lib/staccato/rack/page_view.rb
188
188
  - lib/staccato/rack/version.rb
189
189
  - staccato-rack.gemspec
190
- homepage: https://github.com/unboxed/staccato-rack
190
+ homepage: https://github.com/grantspeelman/staccato-rack
191
191
  licenses:
192
192
  - MIT
193
193
  metadata: {}