keepify 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/VERSION +1 -1
- data/keepify.gemspec +2 -2
- data/lib/keepify.rb +22 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28a84b9aa992f4cc4d2f3fa7e36c80275b3cb000
|
4
|
+
data.tar.gz: dbc0ab8930c9311fed24446082d44f0276675286
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed21d69e13aedc7992ffebfa99d73c0072b095ce348ba57181a833345e925a315ace79ae775b3de2c7ef7a4cfe09e9facadf7b969fd4697ae818098510b50c61
|
7
|
+
data.tar.gz: acec326f88a15fe58cc64abf2c00e180827f8bc0bbb276ef44b8d0ee0a6366092b4c21501d9b05816f8ce6e1b19742431b04ed5dcf13e8557736e3e751fd1b39
|
data/README.md
CHANGED
@@ -9,8 +9,13 @@
|
|
9
9
|
### Initialize Keepify
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
@keepify = Keepify::Tracker.new(YOUR_KEEPIFY_API_TOKEN)
|
12
|
+
@keepify = Keepify::Tracker.new(YOUR_KEEPIFY_API_TOKEN, asynch)
|
13
13
|
```
|
14
|
+
* **async** : Boolean
|
15
|
+
|
16
|
+
*Default: false*
|
17
|
+
|
18
|
+
Built in async feature. When set to true, the http tracking requests are sent from a separate thread. This solution may become inefficient if your application generates events at a high rate. in that case, consider using a more robust solution such as using eventmachine or delegating the tracking to a background job using resque.
|
14
19
|
|
15
20
|
### Tracking events
|
16
21
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/keepify.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "keepify"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["thedecimal"]
|
12
|
-
s.date = "2013-11-
|
12
|
+
s.date = "2013-11-06"
|
13
13
|
s.description = "Keepify track events with properties directly from your backend"
|
14
14
|
s.email = "yaser@rubikal.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/keepify.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'uri'
|
3
|
+
require 'logger'
|
3
4
|
|
4
5
|
module Keepify
|
5
6
|
REQUEST_URL = 'http://analytics.keepify.com/kpy.png'
|
@@ -7,10 +8,15 @@ module Keepify
|
|
7
8
|
|
8
9
|
class Tracker
|
9
10
|
|
10
|
-
def initialize(client_id)
|
11
|
+
def initialize(client_id, async = false)
|
11
12
|
raise "client_id must be supplied" if(client_id.nil? || client_id.empty?)
|
13
|
+
if async
|
14
|
+
require 'thread'
|
15
|
+
@async = true
|
16
|
+
end
|
12
17
|
@options = {}
|
13
18
|
@options[:kpusr] = client_id
|
19
|
+
@logger = Logger.new(STDOUT)
|
14
20
|
end
|
15
21
|
|
16
22
|
def trackEvent(event_type, user_id, options = {})
|
@@ -26,11 +32,24 @@ module Keepify
|
|
26
32
|
options[:kpuid] = user_id
|
27
33
|
options[:kpet] = event_type
|
28
34
|
end
|
29
|
-
|
35
|
+
|
30
36
|
uri = URI(REQUEST_URL)
|
31
37
|
uri.query = URI.encode_www_form(options)
|
38
|
+
|
39
|
+
if(@async)
|
40
|
+
Thread.new {
|
41
|
+
send_request(uri)
|
42
|
+
}
|
43
|
+
else
|
44
|
+
send_request(uri)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def send_request(uri)
|
32
51
|
res = Net::HTTP.get_response(uri)
|
33
|
-
|
52
|
+
@logger.error res.message unless res.is_a?(Net::HTTPSuccess)
|
34
53
|
end
|
35
54
|
end
|
36
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keepify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thedecimal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|