thisdata 0.1.5 → 0.1.6

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc2ec4099c581d83cd5e0841bd29312ff6951c3d
4
- data.tar.gz: 8373e836057db6ba6ff8ccb785c3df73e7bc49a5
3
+ metadata.gz: a460e8478eb4bca5802e86c76eba3017d42c5bfa
4
+ data.tar.gz: 58af31a7fab25be9d628aa612641da581ca03009
5
5
  SHA512:
6
- metadata.gz: 613abc4d3418e3e8b09a1b11d6b2ab78636d260ca090bbf822c4141ff37c0f8f4bfb6db2879a6f86a3e28fc62486bbd3746d22389fe9bb90ec975cb80ade9597
7
- data.tar.gz: 3fb27a19aabd7750898285e206496d8a9207a52340fa63580821a89a98a265ed4c542da32797e7737d59303430f5e2fe5399f3c321bfa4837469d9fb63e04ff9
6
+ metadata.gz: 48adde7517313dcb521fbdd3c36386a5391a1b75366261b679c709c8ad5d8df62d4a3607f8908469ce910f4f317f307469b123c72257f591e7424333448b1198
7
+ data.tar.gz: 3bf8a38732da9679277ddb7770fe2ec17064985e8f37ce50d51d15a2e7d7e277dd28fa17118ca62c1f86fa6f95aee3a3d0b2a2961b9034c5ada1c281ba898f33
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.1.6
2
+
3
+ - Add support for setting the authenticated value when using `thisdata_track`.
4
+ https://github.com/thisdata/thisdata-ruby/issues/17
5
+
1
6
  # 0.1.5
2
7
 
3
8
  - Allows automatic tracking of ThisData's optional JavaScript cookie value
data/README.md CHANGED
@@ -117,7 +117,8 @@ class SessionsController < ApplicationController
117
117
  if attempted_user = User.find_by(email: params[:email])
118
118
  thisdata_track(
119
119
  verb: ThisData::Verbs::LOG_IN_DENIED,
120
- user: attempted_user
120
+ user: attempted_user,
121
+ authenticated: false
121
122
  )
122
123
  else
123
124
  # email and password were both incorrect
@@ -20,19 +20,33 @@ module ThisData
20
20
  # `current_user`.
21
21
  # The object must respond to at least
22
22
  # `ThisData.configuration.user_id_method`, which defaults to `id`.
23
+ # authenticated: (Boolean, Optional, default nil). Used to indicate
24
+ # whether a user is authenticated or not. By default we assume that if
25
+ # there is a user specified then they are authenticated, but in some
26
+ # cases (like a log-in-denied event) you might want to track the user
27
+ # but tell us that they are not authenticated.
28
+ # In these situations you should set `authenticated` to false.
23
29
  #
24
30
  # Returns the result of ThisData.track (an HTTPartyResponse)
25
- def thisdata_track(verb: ThisData::Verbs::LOG_IN, user: nil)
31
+ def thisdata_track(verb: ThisData::Verbs::LOG_IN, user: nil, authenticated: nil)
32
+ # Fetch the user unless it's been overridden
26
33
  if user.nil?
27
34
  user = send(ThisData.configuration.user_method)
28
35
  end
29
36
 
37
+ # Get a Hash of details for the user
38
+ user_details = user_details(user)
39
+
40
+ # If specified, set the authenticated state of the user
41
+ unless authenticated.nil?
42
+ user_details.merge!(authenticated: authenticated)
43
+ end
30
44
 
31
45
  event = {
32
46
  verb: verb,
33
47
  ip: request.remote_ip,
34
48
  user_agent: request.user_agent,
35
- user: user_details(user),
49
+ user: user_details,
36
50
  session: {
37
51
  td_cookie_expected: ThisData.configuration.expect_js_cookie,
38
52
  td_cookie_id: td_cookie_value,
@@ -1,3 +1,3 @@
1
1
  module ThisData
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
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.5
4
+ version: 0.1.6
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-07-18 00:00:00.000000000 Z
12
+ date: 2016-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty