woopra_rails 1.0.2 → 1.0.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.
- data/README.md +5 -1
- data/lib/woopra_rails/api.rb +3 -1
- data/lib/woopra_rails/version.rb +1 -1
- data/lib/woopra_rails.rb +3 -6
- metadata +2 -4
- data/lib/woopra_rails/session.rb +0 -30
data/README.md
CHANGED
@@ -30,6 +30,9 @@ Or install it yourself as:
|
|
30
30
|
dryrun: false
|
31
31
|
|
32
32
|
At this point, Woopra should initialize on app load and be ready for usage.
|
33
|
+
The last step is to extend your application controller with the ActiveSupport::Concerns functionality to allow for user identity tracking for anonymous users. Add the following to your application_controller.rb
|
34
|
+
|
35
|
+
include WoopraRails::Session
|
33
36
|
|
34
37
|
## Usage
|
35
38
|
All API actions return a WoopraRails::Response object. To check for success, assign the return to a variable, e.g. response, and call success? for a boolean return
|
@@ -38,8 +41,9 @@ Or install it yourself as:
|
|
38
41
|
response.success? #returns true
|
39
42
|
|
40
43
|
Identify the current user:
|
44
|
+
We use the Rails session_id for user cookie management. This session id is not sent over the wire, and is done with MD5 digest.
|
41
45
|
|
42
|
-
response = WoopraRails.identify("me@kevinlhopkins.com")
|
46
|
+
response = WoopraRails.identify("Kevin Hopkins", "me@kevinlhopkins.com", session[:session_id])
|
43
47
|
|
44
48
|
Log a pageview:
|
45
49
|
|
data/lib/woopra_rails/api.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module WoopraRails
|
2
2
|
class << self
|
3
|
-
def identify(name=nil, email=nil)
|
3
|
+
def identify(name=nil, email=nil, session=nil)
|
4
|
+
@session = Digest::MD5.hexdigest(session)
|
5
|
+
set_base
|
4
6
|
@base_params += "&cv_name=#{URI::encode name}&cv_email=#{URI::encode email}"
|
5
7
|
issue_request
|
6
8
|
end
|
data/lib/woopra_rails/version.rb
CHANGED
data/lib/woopra_rails.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "woopra_rails/version"
|
2
|
-
require "woopra_rails/engine"
|
3
1
|
require 'uri'
|
4
2
|
require 'socket'
|
5
3
|
require 'net/http'
|
@@ -10,15 +8,15 @@ require 'fileutils'
|
|
10
8
|
'engine',
|
11
9
|
'error',
|
12
10
|
'response',
|
13
|
-
'session',
|
14
11
|
'api'
|
15
12
|
].each{ |f| require "woopra_rails/#{f}" }
|
16
13
|
|
17
14
|
module WoopraRails
|
18
|
-
@endpoint = '
|
15
|
+
@endpoint = 'https://www.woopra.com/track/ce/'
|
19
16
|
@dryrun = false
|
20
17
|
@config = {}
|
21
18
|
@env = "development"
|
19
|
+
@session = ""
|
22
20
|
|
23
21
|
class << self
|
24
22
|
def config=(config)
|
@@ -39,8 +37,7 @@ module WoopraRails
|
|
39
37
|
end
|
40
38
|
|
41
39
|
def set_base
|
42
|
-
@
|
43
|
-
@base_params = "#{@host}#{@endpoint}?host=#{account}&response=json&cookie=#{WoopraRails::Session.user_id}&timeout=300000"
|
40
|
+
@base_params = "#{@endpoint}?host=#{account}&response=json&cookie=#{@session}&timeout=300000"
|
44
41
|
end
|
45
42
|
|
46
43
|
def account
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: woopra_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -60,7 +60,6 @@ files:
|
|
60
60
|
- lib/woopra_rails/engine.rb
|
61
61
|
- lib/woopra_rails/error.rb
|
62
62
|
- lib/woopra_rails/response.rb
|
63
|
-
- lib/woopra_rails/session.rb
|
64
63
|
- lib/woopra_rails/version.rb
|
65
64
|
- spec/TestApp/.gitignore
|
66
65
|
- spec/TestApp/Gemfile
|
@@ -187,4 +186,3 @@ test_files:
|
|
187
186
|
- spec/TestApp/vendor/assets/javascripts/.gitkeep
|
188
187
|
- spec/TestApp/vendor/assets/stylesheets/.gitkeep
|
189
188
|
- spec/TestApp/vendor/plugins/.gitkeep
|
190
|
-
has_rdoc:
|
data/lib/woopra_rails/session.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module WoopraRails::Session
|
2
|
-
extend ActiveSupport::Concern
|
3
|
-
included do
|
4
|
-
before_filter :set_or_use_woopra_cookie
|
5
|
-
|
6
|
-
def set_or_use_woopra_cookie
|
7
|
-
session[:woopra_user_id] = SecureRandom.hex(16) unless !session || session[:woopra_user_id]
|
8
|
-
end
|
9
|
-
|
10
|
-
def clear_woopra_session
|
11
|
-
session[:woopra_user_id] = nil
|
12
|
-
end
|
13
|
-
helper_method :clear_woopra_session
|
14
|
-
end
|
15
|
-
|
16
|
-
class << self
|
17
|
-
def user_id
|
18
|
-
begin
|
19
|
-
session[:woopra_user_id]
|
20
|
-
rescue
|
21
|
-
""
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def page_path
|
26
|
-
request.url
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|