ahoy_matey 0.3.0 → 0.3.1

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: aae43abe84c855bce95234160c4e8e0a2496155c
4
- data.tar.gz: 037987022eaaf1738e0187b86683823a632639a2
3
+ metadata.gz: d9db513e48eea03c383990fb228564e252bebc5b
4
+ data.tar.gz: a05f03369e5777866a376d0e9c62989f74dfb4c0
5
5
  SHA512:
6
- metadata.gz: 7f2eae369753dc8710a6ba8c8989b2641923b741feaff09184a5d94a76432ea568b6eeea53f0351dac79a7fe4f95bc4392f264560e6a0e693b92a974b2676d20
7
- data.tar.gz: 4e1ff064b585b73a1de6225f5b606855f7aa13a620f187b02578775f2bb0c49f3bb1c87c8e1e88a2bf3dde71da0e92fb19ca2ee0dd5c1bd36e929602197a6524
6
+ metadata.gz: 9cc1490028f6f3ab3565b8214ab67b29b35d50feed74c7a2ba171de1a5c765d5be3a1c1708fa14db440a350a429fa49b18e63119b4d3a6472866cadfc02e6eda
7
+ data.tar.gz: 693ce18cd49030035611bea317a931011c9d2ffd01c2ef5d77769b040bc88a1ebe06364ed2b864a21513c276aa2db8dad95e1e27d2d610c7ae44c3138d02e9eb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.3.1
2
+
3
+ - Fixed visitor cookies when set on server
4
+ - Added `domain` option for server cookies
5
+
1
6
  ## 0.3.0
2
7
 
3
8
  - Added `current_visit_token` and `current_visitor_token` method
data/README.md CHANGED
@@ -142,18 +142,12 @@ When a user launches the app, create a visit. Send a `POST` request to `/ahoy/v
142
142
  - platform - `iOS`, `Android`, etc.
143
143
  - app_version - `1.0.0`
144
144
  - os_version - `7.0.6`
145
- - visitor_token - if you have one
145
+ - visit_token - `505f6201-8e10-44cf-ba1c-37271c8d0125`
146
+ - visitor_token - `db3b1a8f-302b-42df-9cd0-06875f549474`
146
147
 
147
- The endpoint will return a JSON response like:
148
+ Tokens must be [UUIDs](http://en.wikipedia.org/wiki/Universally_unique_identifier).
148
149
 
149
- ```json
150
- {
151
- "visit_token": "8tx2ziymkwa1WlppnkqxyaBaRlXrEQ3K",
152
- "visitor_token": "hYBIV0rBfrIUAiArWweiECt4N9pyiygN"
153
- }
154
- ```
155
-
156
- Send the visit token in the `Ahoy-Visit` header for all requests.
150
+ Send the visit and visitor tokens in the `Ahoy-Visit` and `Ahoy-Visitor` headers with all requests.
157
151
 
158
152
  After 4 hours, create another visit and use the updated visit token.
159
153
 
@@ -256,7 +250,7 @@ Turn off logging
256
250
  ahoy.debug(false);
257
251
  ```
258
252
 
259
- Debug endpoint requests in Ruby [master]
253
+ Debug endpoint requests in Ruby
260
254
 
261
255
  ```ruby
262
256
  Ahoy.quiet = false
@@ -287,7 +281,15 @@ end
287
281
 
288
282
  ## Reference
289
283
 
290
- To track visits across multiple subdomains, add this **before** the javascript files.
284
+ To track visits across multiple subdomains, you must set the domain in two places (at the moment).
285
+
286
+ Add this to the `config/initializers/ahoy.rb` initializer:
287
+
288
+ ```ruby
289
+ Ahoy.domain = "yourdomain.com"
290
+ ```
291
+
292
+ and add this **before** the javascript files:
291
293
 
292
294
  ```javascript
293
295
  var ahoy = {"domain": "yourdomain.com"};
data/lib/ahoy.rb CHANGED
@@ -60,6 +60,8 @@ module Ahoy
60
60
 
61
61
  mattr_accessor :quiet
62
62
  self.quiet = true
63
+
64
+ mattr_accessor :domain
63
65
  end
64
66
 
65
67
  ActionController::Base.send :include, Ahoy::Controller
@@ -30,7 +30,14 @@ module Ahoy
30
30
  end
31
31
 
32
32
  def set_ahoy_visitor_cookie
33
- cookies[:ahoy_visitor] = current_visitor_token if !request.headers["Ahoy-Visitor"] && !cookies[:ahoy_visitor]
33
+ if !request.headers["Ahoy-Visitor"] && !cookies[:ahoy_visitor]
34
+ cookie = {
35
+ value: current_visitor_token,
36
+ expires: 2.years.from_now
37
+ }
38
+ cookie[:domain] = Ahoy.domain if Ahoy.domain
39
+ cookies[:ahoy_visitor] = cookie
40
+ end
34
41
  end
35
42
 
36
43
  end
data/lib/ahoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_matey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane