thisdata 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: 733fd722c94d64605f71c6c1dde7651ee3637ef0
4
- data.tar.gz: c35dfe168584f381f8d7b4ec785be3d30000a22f
3
+ metadata.gz: cc2ec4099c581d83cd5e0841bd29312ff6951c3d
4
+ data.tar.gz: 8373e836057db6ba6ff8ccb785c3df73e7bc49a5
5
5
  SHA512:
6
- metadata.gz: ed4916c46d949108998764e9dec362e558fefa757bf49944512ad4ea2d6831158a7f858a34fc33ae2d2a1af05cd4ea53deacc03383243925317462e7c9260842
7
- data.tar.gz: 003187257e62124d7ab56c6f0c5b4a11f45c6721254413b21d0d55e3764e62938c1853aa9acc83cc591e5bce0a0689cc15c454ee39f8fc1578a7befe6725eb6c
6
+ metadata.gz: 613abc4d3418e3e8b09a1b11d6b2ab78636d260ca090bbf822c4141ff37c0f8f4bfb6db2879a6f86a3e28fc62486bbd3746d22389fe9bb90ec975cb80ade9597
7
+ data.tar.gz: 3fb27a19aabd7750898285e206496d8a9207a52340fa63580821a89a98a265ed4c542da32797e7737d59303430f5e2fe5399f3c321bfa4837469d9fb63e04ff9
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ before_install:
7
+ - gem install bundler
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.1.5
2
+
3
+ - Allows automatic tracking of ThisData's optional JavaScript cookie value
4
+ https://github.com/thisdata/thisdata-ruby/issues/13
5
+
1
6
  # 0.1.4
2
7
 
3
8
  - ThisData wasn't being required properly: https://github.com/thisdata/thisdata-ruby/issues/8
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ThisData Ruby
1
+ # ThisData Ruby [![Build Status](https://travis-ci.org/thisdata/thisdata-ruby.png?branch=master)](https://travis-ci.org/thisdata/thisdata-ruby)
2
2
 
3
3
  This gem allows you to use the ThisData Login Intelligence API.
4
4
 
@@ -93,7 +93,9 @@ that's the place to do it!
93
93
  `ThisData.track`.**
94
94
 
95
95
  However, we do provide a `ThisData::TrackRequest` module which, when included in
96
- an ActionController, gives you a simple way to track requests.
96
+ an ActionController, gives you a simple way to track requests. The advantage
97
+ is that this module knows how to get request details automagically, like the IP,
98
+ user agent, and ThisData's tracking cookie value (if you've turned that on).
97
99
 
98
100
  You include the module, then call `thisdata_track`. Easy!
99
101
 
@@ -53,6 +53,13 @@ ThisData.setup do |config|
53
53
  # Default: :mobile
54
54
  # config.user_mobile_method = :mobile
55
55
 
56
+
57
+ # ThisData's JS library (optional) adds a cookie.
58
+ # If you're using the library, set this to true, so that we know to expect
59
+ # a cookie value
60
+ # Default: false
61
+ # config.expect_js_cookie = true
62
+
56
63
  end
57
64
  EOS
58
65
  end
@@ -36,6 +36,10 @@ module ThisData
36
36
  # *email and/or mobile MUST be passed if you want ThisData
37
37
  # to send 'Was This You?' notifications via email and/or SMS
38
38
  # - name (Optional: String) the user's name, used in notifications
39
+ # - session (Optional: Hash) details about the user's session
40
+ # - td_cookie_expected (Optional: Boolean) whether you expect a JS cookie
41
+ # to be present
42
+ # - td_cookie_id (Optional: String) the value of the JS cookie
39
43
  def track(event)
40
44
  post_event(event)
41
45
  end
@@ -3,6 +3,9 @@ require "ostruct"
3
3
  module ThisData
4
4
  class Configuration
5
5
 
6
+ # ThisData's JS library (optional) adds a cookie with this name
7
+ JS_COOKIE_NAME = '__tdli'
8
+
6
9
  # Programatically create attr accessors for config_option
7
10
  def self.config_option(name)
8
11
  define_method(name) do
@@ -26,6 +29,11 @@ module ThisData
26
29
  # Log the events sent
27
30
  config_option :logger
28
31
 
32
+ # ThisData's JS library (optional) adds a cookie.
33
+ # If you're using the library, set this to true, so that we know to expect
34
+ # a cookie value
35
+ config_option :expect_js_cookie
36
+
29
37
  # TrackRequest config options
30
38
  # We will attempt to call this method on a Controller to get the user record
31
39
  # Default: :current_user
@@ -51,7 +59,8 @@ module ThisData
51
59
  user_id_method: :id,
52
60
  user_name_method: :name,
53
61
  user_email_method: :email,
54
- user_mobile_method: :mobile
62
+ user_mobile_method: :mobile,
63
+ expect_js_cookie: false
55
64
  })
56
65
  end
57
66
 
@@ -27,11 +27,16 @@ module ThisData
27
27
  user = send(ThisData.configuration.user_method)
28
28
  end
29
29
 
30
+
30
31
  event = {
31
32
  verb: verb,
32
33
  ip: request.remote_ip,
33
34
  user_agent: request.user_agent,
34
- user: user_details(user)
35
+ user: user_details(user),
36
+ session: {
37
+ td_cookie_expected: ThisData.configuration.expect_js_cookie,
38
+ td_cookie_id: td_cookie_value,
39
+ }
35
40
  }
36
41
 
37
42
  ThisData.track(event)
@@ -68,5 +73,13 @@ module ThisData
68
73
  end
69
74
  end
70
75
 
76
+ # When using the optional JavaScript library, a cookie is placed which
77
+ # helps us track devices.
78
+ # If the cookie is nil, then either you aren't using the JS library, or
79
+ # the user likely has an ad-blocker.
80
+ def td_cookie_value
81
+ cookies[ThisData::Configuration::JS_COOKIE_NAME] rescue nil
82
+ end
83
+
71
84
  end
72
85
  end
@@ -1,3 +1,3 @@
1
1
  module ThisData
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thisdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ThisData Ltd
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-02 00:00:00.000000000 Z
12
+ date: 2016-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -119,6 +119,7 @@ extensions: []
119
119
  extra_rdoc_files: []
120
120
  files:
121
121
  - ".gitignore"
122
+ - ".travis.yml"
122
123
  - CHANGELOG
123
124
  - Gemfile
124
125
  - LICENSE.md