ahoy_matey 1.5.3 → 1.5.4

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: 14b16720c567a2d253632b9a2a238273c1efb192
4
- data.tar.gz: fa9aa63ecb5aaa91c44c9a617c4bccfa3f37f6c1
3
+ metadata.gz: 78e1ff8eb75ded92834b341ed0319b37d784f5bd
4
+ data.tar.gz: ac76baab29e95a2f7fe69d9505b2dc08ab31cfe5
5
5
  SHA512:
6
- metadata.gz: a77b0b9f3ba3bfd134f848a531406778a46ae213b532945b80e0e2d11e81019ee22d1c55b8967e1913dd5b01aa6814d2e0b512dc500fe7a856e5f33adad35455
7
- data.tar.gz: 6f616904606aaf1af958a8defed7a2fd6ddf9297af5872a3746062ec74ce76cf8eb5c63c606ab45c10884d5119c6f3de45c1e618f892fa1495342a182b3adf28
6
+ metadata.gz: 87fecfd6cf70712efc9e7bde3e64587b86ab3f85f41b3fe68165e85a5fe37f67bff8f9d590bcf46a1b0ca6fe2312aa3253131790a2bde92acb766fbccdf39b9a
7
+ data.tar.gz: fc2abee96f713a6b072290b53b64b2dfa164f0764404b1c8d0fff708e0e1d18f586790ff65eaf1f5b6834958144fbd4b5b3f25050f7722ac28d0ef3124fb4ebf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.5.4
2
+
3
+ - Fixed issue with duplicate events
4
+ - Added support for PostGIS for `where_properties`
5
+
1
6
  ## 1.5.3
2
7
 
3
8
  - Fixed error with Rails 5 and Mongoid 6
@@ -36,6 +41,7 @@
36
41
  - Detect database for `rails g ahoy:stores:active_record` for easier installation
37
42
  - Use `safely` as default exception handler
38
43
  - Fixed issue with log silencer
44
+ - Use multi-column indexes on `ahoy_events` table creation
39
45
 
40
46
  ## 1.3.1
41
47
 
data/README.md CHANGED
@@ -6,6 +6,8 @@ Ahoy provides a solid foundation to track visits and events in Ruby, JavaScript,
6
6
 
7
7
  :postbox: To track emails, check out [Ahoy Email](https://github.com/ankane/ahoy_email).
8
8
 
9
+ :maple_leaf: For A/B testing, check out [Field Test](https://github.com/ankane/field_test).
10
+
9
11
  ## Installation
10
12
 
11
13
  Add this line to your application’s Gemfile:
@@ -303,7 +305,7 @@ class ApplicationController < ActionController::Base
303
305
  protected
304
306
 
305
307
  def track_action
306
- ahoy.track "Processed #{controller_name}##{action_name}", request.filtered_parameters
308
+ ahoy.track "Viewed #{controller_name}##{action_name}"
307
309
  end
308
310
  end
309
311
  ```
@@ -510,6 +512,22 @@ module Ahoy
510
512
  end
511
513
  ```
512
514
 
515
+ ### Throttling
516
+
517
+ By default, Ahoy uses [rack-attack](https://github.com/kickstarter/rack-attack) to throttle requests to Ahoy endpoints. Turn this off with:
518
+
519
+ ```ruby
520
+ Ahoy.throttle = false
521
+ ```
522
+
523
+ The default limit is 20 requests per minute. This can be overridden with:
524
+
525
+ ```ruby
526
+ # limit number of requests to 100 requests every 5 minutes
527
+ Ahoy.throttle_limit = 100
528
+ Ahoy.throttle_period = 5.minutes
529
+ ```
530
+
513
531
  ## Native Apps
514
532
 
515
533
  ### Visits
@@ -553,7 +571,14 @@ Ahoy.mount = false
553
571
 
554
572
  ### 1.4.0
555
573
 
556
- There’s nothing to do, but it’s worth noting the default store was changed from `ActiveRecordStore` to `ActiveRecordTokenStore` for new installations. `ActiveRecordStore` will continue to be supported.
574
+ There’s nothing mandatory to do, but it’s worth noting the default store was changed from `ActiveRecordStore` to `ActiveRecordTokenStore` for new installations. `ActiveRecordStore` will continue to be supported.
575
+
576
+ **Optional** Consider migrating `ahoy_events` table to have the following multi-column index as this *may* benefit
577
+ query performance depending on your usage:
578
+
579
+ ```ruby
580
+ add_index :ahoy_events, [:name, :time]
581
+ ```
557
582
 
558
583
  ### json -> jsonb
559
584
 
@@ -21,10 +21,10 @@ module Ahoy
21
21
  end
22
22
  else
23
23
  properties.each do |k, v|
24
- relation = relation.where("properties REGEXP ?", "[{,]#{{k.to_s => v}.to_json.sub(/\A\{/, "").sub(/\}\z/, "")}[,}]")
24
+ relation = relation.where("properties REGEXP ?", "[{,]#{{k.to_s => v}.to_json.sub(/\A\{/, "").sub(/\}\z/, "").gsub("+", "\\\\+")}[,}]")
25
25
  end
26
26
  end
27
- when /postgres/
27
+ when /postgres|postgis/
28
28
  if column_type == :jsonb || column_type == :json
29
29
  properties.each do |k, v|
30
30
  relation =
@@ -45,7 +45,7 @@ module Ahoy
45
45
  end
46
46
  else
47
47
  properties.each do |k, v|
48
- relation = relation.where("properties SIMILAR TO ?", "%[{,]#{{k.to_s => v}.to_json.sub(/\A\{/, "").sub(/\}\z/, "")}[,}]%")
48
+ relation = relation.where("properties SIMILAR TO ?", "%[{,]#{{k.to_s => v}.to_json.sub(/\A\{/, "").sub(/\}\z/, "").gsub("+", "\\\\+")}[,}]%")
49
49
  end
50
50
  end
51
51
  else
data/lib/ahoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "1.5.3"
2
+ VERSION = "1.5.4"
3
3
  end
@@ -2,7 +2,7 @@
2
2
  * Ahoy.js
3
3
  * Simple, powerful JavaScript analytics
4
4
  * https://github.com/ankane/ahoy.js
5
- * v0.1.0
5
+ * v0.2.1
6
6
  * MIT License
7
7
  */
8
8
 
@@ -327,12 +327,20 @@
327
327
  });
328
328
  };
329
329
 
330
- ahoy.trackView = function () {
330
+ ahoy.trackView = function (additionalProperties) {
331
331
  var properties = {
332
332
  url: window.location.href,
333
333
  title: document.title,
334
334
  page: page()
335
335
  };
336
+
337
+ if (additionalProperties) {
338
+ for(var propName in additionalProperties) {
339
+ if (additionalProperties.hasOwnProperty(propName)) {
340
+ properties[propName] = additionalProperties[propName];
341
+ }
342
+ }
343
+ }
336
344
  ahoy.track("$view", properties);
337
345
  };
338
346
 
@@ -367,24 +375,28 @@
367
375
  ahoy.trackChanges();
368
376
  };
369
377
 
370
- ahoy.start = function () {
371
- createVisit();
378
+ // push events from queue
379
+ try {
380
+ eventQueue = JSON.parse(getCookie("ahoy_events") || "[]");
381
+ } catch (e) {
382
+ // do nothing
383
+ }
372
384
 
373
- // push events from queue
374
- try {
375
- eventQueue = JSON.parse(getCookie("ahoy_events") || "[]");
376
- } catch (e) {
377
- // do nothing
378
- }
385
+ for (var i = 0; i < eventQueue.length; i++) {
386
+ trackEvent(eventQueue[i]);
387
+ }
379
388
 
380
- for (var i = 0; i < eventQueue.length; i++) {
381
- trackEvent(eventQueue[i]);
382
- }
389
+ ahoy.start = function () {
390
+ createVisit();
383
391
 
384
392
  ahoy.start = function () {};
385
393
  };
386
394
 
387
- if (config.startOnReady) { $(ahoy.start); }
395
+ $( function () {
396
+ if (config.startOnReady) {
397
+ ahoy.start();
398
+ }
399
+ });
388
400
 
389
401
  window.ahoy = ahoy;
390
402
  }(window));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_matey
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -335,7 +335,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
335
  version: '0'
336
336
  requirements: []
337
337
  rubyforge_project:
338
- rubygems_version: 2.5.1
338
+ rubygems_version: 2.6.8
339
339
  signing_key:
340
340
  specification_version: 4
341
341
  summary: Simple, powerful visit tracking for Rails