ahoy_email 2.1.2 → 2.1.3

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
  SHA256:
3
- metadata.gz: c5533583685af32099af8100fe872c8dd146b1b3539d373ba99c12774745c24f
4
- data.tar.gz: d4aa807926b5e0d70421c75dbc507ddd1ffeb7856c9c1706c71d4a6ff922dd38
3
+ metadata.gz: b465af2a0497b6b85237fa5246c4c722d594978e07710f66ec96a9260fb44c98
4
+ data.tar.gz: 3f5e353adebbc67fbea887d9a8e36f01ba237a04d16431947855c81fc8be1bcd
5
5
  SHA512:
6
- metadata.gz: 81ce556e09096d9ffbddcecbfd512023ff86f5acee6a8327634f37fe054d9b1547706b92d7de812c8932fe79257cef380976e0a8101467085d45865dfe45f967
7
- data.tar.gz: 830f93a92a24c1d5a338bcf48555df6684e227c07da331b47b8362698f1f928b0282364d13d6533f4d8dfb46b75fa615b60f807b334e6d77c5dfab9fc05dfcd2
6
+ metadata.gz: ead0edcbeda702bd605ea00562addfb65cb321e6797a2fb0e8c1fed640511d8bb5bb2b34a4acfa3bde12447bb0401d0975548661bc867cc7e5c1b5585db01425
7
+ data.tar.gz: c903baeebe4fbd700a58d9e193094648ccf0a3205e70fd78fb20a84cf09dfaee3f642ef45d78e4a50eb86d287b9d0974e8d33075528eef03702fe311175aa5e1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 2.1.3 (2022-06-12)
2
+
3
+ - Updated messages generator for Lockbox 1.0
4
+ - Fixed deprecation warning with Redis 4.6+
5
+
1
6
  ## 2.1.2 (2022-02-09)
2
7
 
3
8
  - Fixed external redirects with Rails 7
data/README.md CHANGED
@@ -15,7 +15,7 @@ First-party email analytics for Rails
15
15
  Add this line to your application’s Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'ahoy_email'
18
+ gem "ahoy_email"
19
19
  ```
20
20
 
21
21
  ## Getting Started
@@ -230,7 +230,7 @@ AhoyEmail.api = true
230
230
  Add this line to your application’s Gemfile:
231
231
 
232
232
  ```ruby
233
- gem 'redis'
233
+ gem "redis"
234
234
  ```
235
235
 
236
236
  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.1.3"
3
3
  end
@@ -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.1.3
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: 2022-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.3.3
126
+ rubygems_version: 3.3.7
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: First-party email analytics for Rails