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
|
-
|
|
4
|
+
Zjc5YjI0MjBkZDQ3MWNlZWZmMDNjMjQxODQzNTI3ZDczZjEwODdiOQ==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
MzZlMjlmNjgzNjQxZDQ2YjEyZjAxNTg3MDVjMGU0YzliOGFmZjg5MA==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
YjNjMDIxYjhhMDhkODFlMGQyZTBjNjUzYjM2Nzk1YTRmYTNiNTMwMmUxOGQ3
|
|
10
|
+
YTczMjg2Y2M3YTU3MTk2NjE5ZDZlZjM2YWIxZTI5MzkxZGM4YjAzY2JhZTIx
|
|
11
|
+
MTFjMWY2OWMxZmVmOTlhZGY0MWM0NzE0MjJhNWYzMGExNmI5NDU=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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.
|
data/lib/staccato/rack.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'rack/request'
|
|
|
3
3
|
require 'staccato'
|
|
4
4
|
|
|
5
5
|
require 'staccato/rack/version'
|
|
6
|
-
require 'staccato/rack/
|
|
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 =
|
|
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
|
-
#
|
|
6
|
-
class
|
|
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
|
|
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 =
|
|
25
|
+
c.adapter = FaradayAsyncHttpAdaper.new(logger) unless tracking_id.nil?
|
|
26
26
|
end
|
|
27
27
|
else
|
|
28
28
|
tracker = default_tracker
|
data/staccato-rack.gemspec
CHANGED
|
@@ -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/
|
|
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.
|
|
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
|
|
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/
|
|
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/
|
|
190
|
+
homepage: https://github.com/grantspeelman/staccato-rack
|
|
191
191
|
licenses:
|
|
192
192
|
- MIT
|
|
193
193
|
metadata: {}
|