ahoy_email 2.1.2 → 2.2.0

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
  SHA256:
3
- metadata.gz: c5533583685af32099af8100fe872c8dd146b1b3539d373ba99c12774745c24f
4
- data.tar.gz: d4aa807926b5e0d70421c75dbc507ddd1ffeb7856c9c1706c71d4a6ff922dd38
3
+ metadata.gz: 9c664f526e52ac8f97cf3d5fe5b154ab6396e3f5c8db3d42c7c76022df9e0b35
4
+ data.tar.gz: 063f9ac13bebe763ff2e33677e68bebd75f46837c5e63b920208e2547725a2a9
5
5
  SHA512:
6
- metadata.gz: 81ce556e09096d9ffbddcecbfd512023ff86f5acee6a8327634f37fe054d9b1547706b92d7de812c8932fe79257cef380976e0a8101467085d45865dfe45f967
7
- data.tar.gz: 830f93a92a24c1d5a338bcf48555df6684e227c07da331b47b8362698f1f928b0282364d13d6533f4d8dfb46b75fa615b60f807b334e6d77c5dfab9fc05dfcd2
6
+ metadata.gz: 1d7556134bb052f06eea6755f668cdd7c4eb5355dcbe46098894ff6b5ed8735b4c20b240378bafebb9b03b9c2525cf4e7b79e9a0fa240bf1a86289b8c0eb2c2b
7
+ data.tar.gz: b576323d7768c3c0872afecbbfa35a7ce12b1d8df9a6dc9877d96e691e1d4675a60ef590e00705be8c245a543dc151249504ba511a96d6bbf37ead17afcf6666
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 2.2.0 (2023-07-02)
2
+
3
+ - Removed support for Ruby < 3 and Rails < 6.1
4
+
5
+ ## 2.1.3 (2022-06-12)
6
+
7
+ - Updated messages generator for Lockbox 1.0
8
+ - Fixed deprecation warning with Redis 4.6+
9
+
1
10
  ## 2.1.2 (2022-02-09)
2
11
 
3
12
  - Fixed external redirects with Rails 7
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2021 Andrew Kane
1
+ Copyright (c) 2014-2023 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  First-party email analytics for Rails
4
4
 
5
- **Ahoy Email 2.0 was recently released** - see [how to upgrade](#upgrading)
6
-
7
5
  :fire: For web and native app analytics, check out [Ahoy](https://github.com/ankane/ahoy)
8
6
 
9
7
  :bullettrain_side: To manage unsubscribes, check out [Mailkick](https://github.com/ankane/mailkick)
@@ -15,7 +13,7 @@ First-party email analytics for Rails
15
13
  Add this line to your application’s Gemfile:
16
14
 
17
15
  ```ruby
18
- gem 'ahoy_email'
16
+ gem "ahoy_email"
19
17
  ```
20
18
 
21
19
  ## Getting Started
@@ -108,7 +106,7 @@ user.messages
108
106
  Add extra data to messages. Create a migration like:
109
107
 
110
108
  ```ruby
111
- class AddCouponIdToAhoyMessages < ActiveRecord::Migration[6.1]
109
+ class AddCouponIdToAhoyMessages < ActiveRecord::Migration[7.0]
112
110
  def change
113
111
  add_column :ahoy_messages, :coupon_id, :integer
114
112
  end
@@ -230,7 +228,7 @@ AhoyEmail.api = true
230
228
  Add this line to your application’s Gemfile:
231
229
 
232
230
  ```ruby
233
- gem 'redis'
231
+ gem "redis"
234
232
  ```
235
233
 
236
234
  And create `config/initializers/ahoy_email.rb` with:
@@ -9,17 +9,17 @@ module AhoyEmail
9
9
 
10
10
  def track_send(event)
11
11
  campaign_prefix = campaign_key(event[:campaign])
12
- redis.pipelined do
13
- redis.incr("#{campaign_prefix}:sends")
14
- redis.sadd(campaigns_key, event[:campaign])
12
+ pipelined do |pipeline|
13
+ pipeline.incr("#{campaign_prefix}:sends")
14
+ pipeline.sadd(campaigns_key, event[:campaign])
15
15
  end
16
16
  end
17
17
 
18
18
  def track_click(event)
19
19
  campaign_prefix = campaign_key(event[:campaign])
20
- redis.pipelined do
21
- redis.incr("#{campaign_prefix}:clicks")
22
- redis.pfadd("#{campaign_prefix}:unique_clicks", event[:token])
20
+ pipelined do |pipeline|
21
+ pipeline.incr("#{campaign_prefix}:clicks")
22
+ pipeline.pfadd("#{campaign_prefix}:unique_clicks", event[:token])
23
23
  end
24
24
  end
25
25
 
@@ -62,10 +62,10 @@ module AhoyEmail
62
62
  unique_clicks = nil
63
63
 
64
64
  campaign_prefix = campaign_key(campaign)
65
- redis.pipelined do
66
- sends = redis.get("#{campaign_prefix}:sends")
67
- clicks = redis.get("#{campaign_prefix}:clicks")
68
- unique_clicks = redis.pfcount("#{campaign_prefix}:unique_clicks")
65
+ pipelined do |pipeline|
66
+ sends = pipeline.get("#{campaign_prefix}:sends")
67
+ clicks = pipeline.get("#{campaign_prefix}:clicks")
68
+ unique_clicks = pipeline.pfcount("#{campaign_prefix}:unique_clicks")
69
69
  end
70
70
 
71
71
  {
@@ -75,5 +75,17 @@ module AhoyEmail
75
75
  ctr: 100 * unique_clicks.value / sends.value.to_f
76
76
  }
77
77
  end
78
+
79
+ def pipelined
80
+ if Redis::VERSION.to_f >= 4.6
81
+ redis.pipelined do |pipeline|
82
+ yield pipeline
83
+ end
84
+ else
85
+ redis.pipelined do
86
+ yield redis
87
+ end
88
+ end
89
+ end
78
90
  end
79
91
  end
@@ -1,3 +1,3 @@
1
1
  module AhoyEmail
2
- VERSION = "2.1.2"
2
+ VERSION = "2.2.0"
3
3
  end
data/lib/ahoy_email.rb CHANGED
@@ -8,20 +8,20 @@ require "safely/core"
8
8
  require "openssl"
9
9
 
10
10
  # modules
11
- require "ahoy_email/processor"
12
- require "ahoy_email/tracker"
13
- require "ahoy_email/observer"
14
- require "ahoy_email/mailer"
15
- require "ahoy_email/utils"
16
- require "ahoy_email/version"
11
+ require_relative "ahoy_email/processor"
12
+ require_relative "ahoy_email/tracker"
13
+ require_relative "ahoy_email/observer"
14
+ require_relative "ahoy_email/mailer"
15
+ require_relative "ahoy_email/utils"
16
+ require_relative "ahoy_email/version"
17
17
 
18
18
  # subscribers
19
- require "ahoy_email/database_subscriber"
20
- require "ahoy_email/message_subscriber"
21
- require "ahoy_email/redis_subscriber"
19
+ require_relative "ahoy_email/database_subscriber"
20
+ require_relative "ahoy_email/message_subscriber"
21
+ require_relative "ahoy_email/redis_subscriber"
22
22
 
23
23
  # integrations
24
- require "ahoy_email/engine" if defined?(Rails)
24
+ require_relative "ahoy_email/engine" if defined?(Rails)
25
25
 
26
26
  module AhoyEmail
27
27
  mattr_accessor :secret_token, :default_options, :subscribers, :invalid_redirect_url, :track_method, :api, :preserve_callbacks, :save_token
@@ -19,7 +19,7 @@ module Ahoy
19
19
  def copy_template
20
20
  case encryption
21
21
  when "lockbox"
22
- template "model_lockbox.rb", "app/models/ahoy/message.rb"
22
+ template "model_lockbox.rb", "app/models/ahoy/message.rb", lockbox_method: lockbox_method
23
23
  when "activerecord"
24
24
  template "model_activerecord.rb", "app/models/ahoy/message.rb"
25
25
  end
@@ -55,6 +55,14 @@ module Ahoy
55
55
  abort "Error: encryption must be lockbox, activerecord, or none"
56
56
  end
57
57
  end
58
+
59
+ def lockbox_method
60
+ if defined?(Lockbox::VERSION) && Lockbox::VERSION.to_i < 1
61
+ "encrypts"
62
+ else
63
+ "has_encrypted"
64
+ end
65
+ end
58
66
  end
59
67
  end
60
68
  end
@@ -13,7 +13,7 @@ module Ahoy
13
13
  def copy_templates
14
14
  case encryption
15
15
  when "lockbox"
16
- template "mongoid_lockbox.rb", "app/models/ahoy/message.rb"
16
+ template "mongoid_lockbox.rb", "app/models/ahoy/message.rb", lockbox_method: lockbox_method
17
17
  else
18
18
  template "mongoid.rb", "app/models/ahoy/message.rb"
19
19
  end
@@ -35,6 +35,14 @@ module Ahoy
35
35
  abort "Error: encryption must be lockbox or none"
36
36
  end
37
37
  end
38
+
39
+ def lockbox_method
40
+ if defined?(Lockbox::VERSION) && Lockbox::VERSION.to_i < 1
41
+ "encrypts"
42
+ else
43
+ "has_encrypted"
44
+ end
45
+ end
38
46
  end
39
47
  end
40
48
  end
@@ -3,6 +3,6 @@ class Ahoy::Message < ActiveRecord::Base
3
3
 
4
4
  belongs_to :user, polymorphic: true, optional: true
5
5
 
6
- encrypts :to
6
+ <%= lockbox_method %> :to
7
7
  blind_index :to
8
8
  end
@@ -11,6 +11,6 @@ class Ahoy::Message
11
11
 
12
12
  index({to_bidx: 1})
13
13
 
14
- encrypts :to
14
+ <%= lockbox_method %> :to
15
15
  blind_index :to
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-10 00:00:00.000000000 Z
11
+ date: 2023-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '6.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5'
26
+ version: '6.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.1
61
+ version: '0.4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.1
68
+ version: '0.4'
69
69
  description:
70
70
  email: andrew@ankane.org
71
71
  executables: []
@@ -116,14 +116,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: '2.6'
119
+ version: '3'
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.3.3
126
+ rubygems_version: 3.4.10
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: First-party email analytics for Rails