ahoy_matey 1.6.0 → 1.6.1

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: d545b42712d52ad3ea16cca410ad316cce728578
4
- data.tar.gz: 648e7131dd89915177c8b9f37a4640d5029bacce
3
+ metadata.gz: cb076e85628b3c486e6d80013bf0729f8d3ab142
4
+ data.tar.gz: 3413580422d7567e36a2acb5bf678637fdadf189
5
5
  SHA512:
6
- metadata.gz: 87557bbaf04bdf41dbe0e9eb72c74885d917bbe49cadd977b02fef1a46f351492a07e57e7d10e765af1dff0a9ac3ee6b310bb3ec321fbbba2b93efff42eb897c
7
- data.tar.gz: cc9b9a7dbed329de70c98b0e3f4f27927f1889e60c3adcb88eadbd4ae84f18de4ec591df98253043609a53f349cfd0b1e1e642cd8d7a0916c939d9e1648699cb
6
+ metadata.gz: ff07d818af43a63fa773cd891f08c2be04359c9c095e25bdd12e5c94e23b6164637573f82b4c7ebd265de918a7134d495f949f09be956492eb094fabcf648154
7
+ data.tar.gz: 87347e995d4145626112aa2ea8277ef3c45432c7f6f89435af8ed068dd85c5849df58740d3ffa5f6da5c583917a1894ac9bccd8c97cb142e641a7d0f81744a2a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.6.1
2
+
3
+ - Added `gin` index on properties for events
4
+ - Fixed `visitable` options when name not provided
5
+
1
6
  ## 1.6.0
2
7
 
3
8
  - Added support for Rails 5.1
data/README.md CHANGED
@@ -336,7 +336,7 @@ class ApplicationController < ActionController::Base
336
336
  protected
337
337
 
338
338
  def track_action
339
- ahoy.track "Viewed #{controller_name}##{action_name}"
339
+ ahoy.track "Viewed #{controller_path}##{action_name}", params: request.path_parameters
340
340
  end
341
341
  end
342
342
  ```
@@ -559,6 +559,10 @@ Ahoy.throttle_limit = 100
559
559
  Ahoy.throttle_period = 5.minutes
560
560
  ```
561
561
 
562
+ ## Tutorials
563
+
564
+ - [Tracking Metrics with Ahoy and Blazer](https://gorails.com/episodes/internal-metrics-with-ahoy-and-blazer)
565
+
562
566
  ## Native Apps
563
567
 
564
568
  ### Visits
@@ -638,7 +642,7 @@ remove_column :ahoy_events, :properties_json
638
642
 
639
643
  ### 1.0.0
640
644
 
641
- Add the following code to the end of `config/intializers/ahoy.rb`.
645
+ Add the following code to the end of `config/initializers/ahoy.rb`.
642
646
 
643
647
  ```ruby
644
648
  class Ahoy::Store < Ahoy::Stores::ActiveRecordTokenStore
data/lib/ahoy/model.rb CHANGED
@@ -2,8 +2,8 @@ module Ahoy
2
2
  module Model
3
3
  def visitable(name = nil, options = {})
4
4
  if name.is_a?(Hash)
5
- name = nil
6
5
  options = name
6
+ name = nil
7
7
  end
8
8
  name ||= :visit
9
9
  class_eval do
@@ -25,7 +25,9 @@ module Ahoy
25
25
  end
26
26
  end
27
27
  when /postgres|postgis/
28
- if column_type == :jsonb || column_type == :json
28
+ if column_type == :jsonb
29
+ relation = relation.where("properties @> ?", properties.to_json)
30
+ elsif column_type == :json
29
31
  properties.each do |k, v|
30
32
  relation =
31
33
  if v.nil?
@@ -11,17 +11,19 @@ module Ahoy
11
11
 
12
12
  def client
13
13
  @client ||= begin
14
- client = Kafka.new(
15
- seed_brokers: ENV["KAFKA_URL"],
14
+ Kafka.new(
15
+ seed_brokers: ENV["KAFKA_URL"] || "localhost:9092",
16
16
  logger: Rails.logger
17
17
  )
18
- at_exit { client.shutdown }
19
- client
20
18
  end
21
19
  end
22
20
 
23
21
  def producer
24
- @producer ||= client.async_producer(delivery_interval: 3)
22
+ @producer ||= begin
23
+ producer = client.async_producer(delivery_interval: 3)
24
+ at_exit { producer.shutdown }
25
+ producer
26
+ end
25
27
  end
26
28
 
27
29
  def post(topic, data)
data/lib/ahoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ahoy
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  end
data/lib/ahoy.rb CHANGED
@@ -117,12 +117,11 @@ end
117
117
 
118
118
  if defined?(Rails)
119
119
  ActiveSupport.on_load(:action_controller) do
120
- ActionController::Base.send :include, Ahoy::Controller
121
- ActionController::API.send :include, Ahoy::Controller if defined?(ActionController::API)
120
+ include Ahoy::Controller
122
121
  end
123
122
 
124
123
  ActiveSupport.on_load(:active_record) do
125
- ActiveRecord::Base.send(:extend, Ahoy::Model)
124
+ extend Ahoy::Model
126
125
  end
127
126
 
128
127
  # ensure logger silence will not be added by activerecord-session_store
@@ -15,5 +15,6 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
15
15
  add_index :ahoy_events, [:visit_id, :name]
16
16
  add_index :ahoy_events, [:user_id, :name]
17
17
  add_index :ahoy_events, [:name, :time]
18
+ <% if @database == "postgresql-jsonb" && ActiveRecord::VERSION::MAJOR >= 5 %>add_index :ahoy_events, 'properties jsonb_path_ops', using: 'gin'<% end %>
18
19
  end
19
20
  end
@@ -2,6 +2,8 @@ require_relative "../test_helper"
2
2
 
3
3
  ActiveRecord::Base.establish_connection adapter: "postgresql", database: "ahoy_test"
4
4
 
5
+ ActiveRecord::Migration.enable_extension "hstore"
6
+
5
7
  ActiveRecord::Migration.create_table :postgresql_hstore_events, force: true do |t|
6
8
  t.hstore :properties
7
9
  end
@@ -4,6 +4,7 @@ ActiveRecord::Base.establish_connection adapter: "postgresql", database: "ahoy_t
4
4
 
5
5
  ActiveRecord::Migration.create_table :postgresql_jsonb_events, force: true do |t|
6
6
  t.jsonb :properties
7
+ t.index :properties, using: 'gin'
7
8
  end
8
9
 
9
10
  class PostgresqlJsonbEvent < PostgresqlBase
@@ -208,7 +208,7 @@
208
208
  id: $target.attr("id"),
209
209
  "class": $target.attr("class"),
210
210
  page: page(),
211
- section: $target.closest("*[data-section]").data("section")
211
+ section: $target.closest("*[data-section]").attr("data-section")
212
212
  };
213
213
  }
214
214
 
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.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-01 00:00:00.000000000 Z
11
+ date: 2018-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -341,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
341
  version: '0'
342
342
  requirements: []
343
343
  rubyforge_project:
344
- rubygems_version: 2.5.1
344
+ rubygems_version: 2.6.13
345
345
  signing_key:
346
346
  specification_version: 4
347
347
  summary: Simple, powerful visit tracking for Rails