ahoy_email 0.5.0 → 0.5.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
- SHA1:
3
- metadata.gz: a367225c4c07c790df8fe4267f5bf7d230921b0e
4
- data.tar.gz: 9360b86e5075df7bf02e427a689c035db77faaf7
2
+ SHA256:
3
+ metadata.gz: bc1f584255e88dbcda182347224e0e30cbd43684cf5e9bf1ba71007cd8470d25
4
+ data.tar.gz: 7143c167fa888441510b1eaa67edd74c0285efa50a1a4e6fa5b0b4770b7afcb7
5
5
  SHA512:
6
- metadata.gz: e4c94a2e17739b8400c1cfccf870f3774c131f23c46ffc062e94140156565e9b002b83ebf3fbd440f857353038274bca4139365267756dfcb7b75bdde2d4eb66
7
- data.tar.gz: da84e8725823073ae8aa5d7b636fac645786cff90484bd381b5ce8d894d0556764a9bbd2df9649265ff3d4b00ba310a3ad6dd1090fe88d86bccd7e82ea7231bd
6
+ metadata.gz: 648078aac8c79119c4caa1ecd42ff624d58e5b898cf6eb2231d14fc0aaece937a2a76020931fbc8c22f730dcdfa27068fc1fc62f9b80ea30ef766c69ea8ddffc
7
+ data.tar.gz: f529c4de18d3ffbd5b2ef4d4b2122409d521fca920d200eaad337c0bc984de31ef3b6d7c6c0642a7120446cf759055a9f84b0f9bdda44bdafb654708994cef4a
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.0
3
+ - 2.4.2
4
4
  sudo: false
5
5
  script: bundle exec rake test
6
6
  before_script:
@@ -11,5 +11,6 @@ notifications:
11
11
  on_failure: change
12
12
  gemfile:
13
13
  - Gemfile
14
+ - test/gemfiles/actionmailer51.gemfile
14
15
  - test/gemfiles/actionmailer50.gemfile
15
16
  - test/gemfiles/actionmailer42.gemfile
@@ -1,3 +1,10 @@
1
+ ## 0.5.1
2
+
3
+ - Fixed deprecation warning in Rails 5.2
4
+ - Added `unsubscribe_links` option
5
+ - Allow `message_model` to accept a proc
6
+ - Use `references` in migration
7
+
1
8
  ## 0.5.0
2
9
 
3
10
  - Added support for Rails 5.1
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in ahoy_email.gemspec
4
4
  gemspec
5
5
 
6
- gem "actionmailer", "~> 5.1.0"
6
+ gem "actionmailer", "~> 5.2.0"
data/README.md CHANGED
@@ -5,8 +5,8 @@
5
5
  You get:
6
6
 
7
7
  - A history of emails sent to each user
8
- - Open and click tracking
9
8
  - Easy UTM tagging
9
+ - Open and click tracking
10
10
 
11
11
  Works with any email service.
12
12
 
@@ -28,7 +28,7 @@ And run the generator. This creates a model to store messages.
28
28
 
29
29
  ```sh
30
30
  rails generate ahoy_email:install
31
- rake db:migrate
31
+ rails db:migrate
32
32
  ```
33
33
 
34
34
  ## How It Works
@@ -44,7 +44,7 @@ By default, Ahoy tries `User.where(email: message.to.first).first` to find the u
44
44
  You can pass a specific user with:
45
45
 
46
46
  ```ruby
47
- class UserMailer < ActionMailer::Base
47
+ class UserMailer < ApplicationMailer
48
48
  def welcome_email(user)
49
49
  # ...
50
50
  track user: user
@@ -58,8 +58,8 @@ The user association is [polymorphic](http://railscasts.com/episodes/154-polymor
58
58
  To get all messages sent to a user, add an association:
59
59
 
60
60
  ```ruby
61
- class User < ActiveRecord::Base
62
- has_many :messages, class_name: "Ahoy::Message"
61
+ class User < ApplicationRecord
62
+ has_many :messages, class_name: "Ahoy::Message", as: :user
63
63
  end
64
64
  ```
65
65
 
@@ -69,6 +69,23 @@ And run:
69
69
  user.messages
70
70
  ```
71
71
 
72
+ ### UTM Parameters
73
+
74
+ UTM parameters are added to links if they don’t already exist.
75
+
76
+ The defaults are:
77
+
78
+ - utm_medium - `email`
79
+ - utm_source - the mailer name like `user_mailer`
80
+ - utm_campaign - the mailer action like `welcome_email`
81
+
82
+ Use `track utm_params: false` to skip tagging, or skip specific links with:
83
+
84
+
85
+ ```html
86
+ <a data-skip-utm-params="true" href="...">Break it down</a>
87
+ ```
88
+
72
89
  ### Opens
73
90
 
74
91
  An invisible pixel is added right before the `</body>` tag in HTML emails.
@@ -99,23 +116,6 @@ Use `track click: false` to skip tracking, or skip specific links with:
99
116
  <a data-skip-click="true" href="...">Can't touch this</a>
100
117
  ```
101
118
 
102
- ### UTM Parameters
103
-
104
- UTM parameters are added to links if they don’t already exist.
105
-
106
- The defaults are:
107
-
108
- - utm_medium - `email`
109
- - utm_source - the mailer name like `user_mailer`
110
- - utm_campaign - the mailer action like `welcome_email`
111
-
112
- Use `track utm_params: false` to skip tagging, or skip specific links with:
113
-
114
-
115
- ```html
116
- <a data-skip-utm-params="true" href="...">Break it down</a>
117
- ```
118
-
119
119
  ### Extra Attributes
120
120
 
121
121
  Create a migration to add extra attributes to the `ahoy_messages` table, for example:
@@ -152,7 +152,7 @@ There are 3 places to set options. Here’s the order of precedence.
152
152
  #### Action
153
153
 
154
154
  ``` ruby
155
- class UserMailer < ActionMailer::Base
155
+ class UserMailer < ApplicationMailer
156
156
  def welcome_email(user)
157
157
  # ...
158
158
  track user: user
@@ -164,7 +164,7 @@ end
164
164
  #### Mailer
165
165
 
166
166
  ```ruby
167
- class UserMailer < ActionMailer::Base
167
+ class UserMailer < ApplicationMailer
168
168
  track utm_campaign: "boom"
169
169
  end
170
170
  ```
@@ -214,7 +214,7 @@ AhoyEmail.subscribers << EmailSubscriber.new
214
214
  You can use a `Proc` for any option.
215
215
 
216
216
  ```ruby
217
- track utm_campaign: proc { |message, mailer| mailer.action_name + Time.now.year }
217
+ track utm_campaign: ->(message, mailer) { mailer.action_name + Time.now.year }
218
218
  ```
219
219
 
220
220
  Disable tracking for an email
@@ -242,6 +242,12 @@ Customize domain
242
242
  track url_options: {host: "mydomain.com"}
243
243
  ```
244
244
 
245
+ By default, unsubscribe links are excluded from tracking. To change this, use:
246
+
247
+ ```ruby
248
+ track unsubscribe_links: true
249
+ ```
250
+
245
251
  Use a different model
246
252
 
247
253
  ```ruby
@@ -9,7 +9,6 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Andrew Kane"]
10
10
  spec.email = ["andrew@chartkick.com"]
11
11
  spec.summary = "Simple, powerful email tracking for Rails"
12
- spec.description = "Simple, powerful email tracking for Rails"
13
12
  spec.homepage = "https://github.com/ankane/ahoy_email"
14
13
  spec.license = "MIT"
15
14
 
@@ -20,14 +19,17 @@ Gem::Specification.new do |spec|
20
19
 
21
20
  spec.required_ruby_version = ">= 2.0.0"
22
21
 
23
- spec.add_runtime_dependency "rails"
24
- spec.add_runtime_dependency "addressable"
22
+ spec.add_runtime_dependency "railties"
23
+ spec.add_runtime_dependency "actionmailer"
24
+ spec.add_runtime_dependency "activerecord"
25
+ spec.add_runtime_dependency "addressable", ">= 2.3.2"
25
26
  spec.add_runtime_dependency "nokogiri"
26
27
  spec.add_runtime_dependency "safely_block", ">= 0.1.1"
27
28
 
28
- spec.add_development_dependency "bundler", "~> 1.6"
29
+ spec.add_development_dependency "bundler"
29
30
  spec.add_development_dependency "rake"
30
31
  spec.add_development_dependency "minitest"
31
32
  spec.add_development_dependency "combustion"
33
+ spec.add_development_dependency "rails"
32
34
  spec.add_development_dependency "sqlite3"
33
35
  end
@@ -1,6 +1,4 @@
1
- require "ahoy_email/version"
2
- require "action_mailer"
3
- require "rails"
1
+ require "active_support"
4
2
  require "nokogiri"
5
3
  require "addressable/uri"
6
4
  require "openssl"
@@ -9,6 +7,7 @@ require "ahoy_email/processor"
9
7
  require "ahoy_email/interceptor"
10
8
  require "ahoy_email/mailer"
11
9
  require "ahoy_email/engine"
10
+ require "ahoy_email/version"
12
11
 
13
12
  module AhoyEmail
14
13
  mattr_accessor :secret_token, :options, :subscribers, :belongs_to, :invalid_redirect_url
@@ -41,9 +40,13 @@ module AhoyEmail
41
40
  end
42
41
 
43
42
  def self.message_model
44
- (defined?(@message_model) && @message_model) || ::Ahoy::Message
43
+ model = (defined?(@message_model) && @message_model) || ::Ahoy::Message
44
+ model = model.call if model.respond_to?(:call)
45
+ model
45
46
  end
46
47
  end
47
48
 
48
- ActionMailer::Base.send :include, AhoyEmail::Mailer
49
- ActionMailer::Base.register_interceptor AhoyEmail::Interceptor
49
+ ActiveSupport.on_load(:action_mailer) do
50
+ include AhoyEmail::Mailer
51
+ register_interceptor AhoyEmail::Interceptor
52
+ end
@@ -1,8 +1,14 @@
1
+ require "rails/engine"
2
+
1
3
  module AhoyEmail
2
4
  class Engine < ::Rails::Engine
3
5
  initializer "ahoy_email" do |app|
4
- secrets = app.respond_to?(:secrets) ? app.secrets : app.config
5
- AhoyEmail.secret_token ||= secrets.respond_to?(:secret_key_base) ? secrets.secret_key_base : secrets.secret_token
6
+ # default to secrets to keep backward compatible
7
+ ActiveSupport::Deprecation.silence do
8
+ secrets = app.respond_to?(:secrets) ? app.secrets : app.config
9
+ AhoyEmail.secret_token ||= secrets.respond_to?(:secret_key_base) ? secrets.secret_key_base : secrets.secret_token
10
+ end
11
+
6
12
  AhoyEmail.belongs_to = {optional: true} if Rails::VERSION::MAJOR >= 5
7
13
  end
8
14
  end
@@ -140,7 +140,7 @@ module AhoyEmail
140
140
  # remove it
141
141
  link.remove_attribute(attribute)
142
142
  true
143
- elsif link["href"].to_s =~ /unsubscribe/i
143
+ elsif link["href"].to_s =~ /unsubscribe/i && !options[:unsubscribe_links]
144
144
  # try to avoid unsubscribe links
145
145
  true
146
146
  else
@@ -1,3 +1,3 @@
1
1
  module AhoyEmail
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -5,8 +5,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
5
5
 
6
6
  # user
7
7
  t.text :to
8
- t.integer :user_id
9
- t.string :user_type
8
+ t.references :user, polymorphic: true
10
9
 
11
10
  # optional - feel free to remove
12
11
  t.string :mailer
@@ -27,6 +26,5 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
27
26
  end
28
27
 
29
28
  add_index :ahoy_messages, [:token]
30
- add_index :ahoy_messages, [:user_id, :user_type]
31
29
  end
32
30
  end
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ahoy_email.gemspec
4
+ gemspec path: "../../"
5
+
6
+ gem "actionmailer", "~> 5.1.0"
@@ -7,7 +7,11 @@ require "combustion"
7
7
  Minitest::Test = Minitest::Unit::TestCase unless defined?(Minitest::Test)
8
8
 
9
9
  Combustion.path = "test/internal"
10
- Combustion.initialize! :all
10
+ Combustion.initialize! :all do
11
+ if config.active_record.sqlite3.respond_to?(:represent_boolean_as_integer)
12
+ config.active_record.sqlite3.represent_boolean_as_integer = true
13
+ end
14
+ end
11
15
 
12
16
  ActionMailer::Base.delivery_method = :test
13
17
 
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.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-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: addressable
28
+ name: actionmailer
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activerecord
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: addressable
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.3.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.3.2
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: nokogiri
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -70,16 +98,16 @@ dependencies:
70
98
  name: bundler
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
- - - "~>"
101
+ - - ">="
74
102
  - !ruby/object:Gem::Version
75
- version: '1.6'
103
+ version: '0'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
- - - "~>"
108
+ - - ">="
81
109
  - !ruby/object:Gem::Version
82
- version: '1.6'
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: rake
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +150,20 @@ dependencies:
122
150
  - - ">="
123
151
  - !ruby/object:Gem::Version
124
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rails
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
125
167
  - !ruby/object:Gem::Dependency
126
168
  name: sqlite3
127
169
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +178,7 @@ dependencies:
136
178
  - - ">="
137
179
  - !ruby/object:Gem::Version
138
180
  version: '0'
139
- description: Simple, powerful email tracking for Rails
181
+ description:
140
182
  email:
141
183
  - andrew@chartkick.com
142
184
  executables: []
@@ -164,6 +206,7 @@ files:
164
206
  - lib/generators/ahoy_email/templates/install.rb
165
207
  - test/gemfiles/actionmailer42.gemfile
166
208
  - test/gemfiles/actionmailer50.gemfile
209
+ - test/gemfiles/actionmailer51.gemfile
167
210
  - test/internal/config/database.yml
168
211
  - test/internal/config/routes.rb
169
212
  - test/internal/db/schema.rb
@@ -189,13 +232,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
232
  version: '0'
190
233
  requirements: []
191
234
  rubyforge_project:
192
- rubygems_version: 2.5.1
235
+ rubygems_version: 2.7.6
193
236
  signing_key:
194
237
  specification_version: 4
195
238
  summary: Simple, powerful email tracking for Rails
196
239
  test_files:
197
240
  - test/gemfiles/actionmailer42.gemfile
198
241
  - test/gemfiles/actionmailer50.gemfile
242
+ - test/gemfiles/actionmailer51.gemfile
199
243
  - test/internal/config/database.yml
200
244
  - test/internal/config/routes.rb
201
245
  - test/internal/db/schema.rb