ahoy_email 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -2
- data/lib/ahoy_email/redis_subscriber.rb +22 -10
- data/lib/ahoy_email/version.rb +1 -1
- data/lib/generators/ahoy/messages/activerecord_generator.rb +9 -1
- data/lib/generators/ahoy/messages/mongoid_generator.rb +9 -1
- data/lib/generators/ahoy/messages/templates/model_lockbox.rb.tt +1 -1
- data/lib/generators/ahoy/messages/templates/mongoid_lockbox.rb.tt +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b465af2a0497b6b85237fa5246c4c722d594978e07710f66ec96a9260fb44c98
|
4
|
+
data.tar.gz: 3f5e353adebbc67fbea887d9a8e36f01ba237a04d16431947855c81fc8be1bcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ead0edcbeda702bd605ea00562addfb65cb321e6797a2fb0e8c1fed640511d8bb5bb2b34a4acfa3bde12447bb0401d0975548661bc867cc7e5c1b5585db01425
|
7
|
+
data.tar.gz: c903baeebe4fbd700a58d9e193094648ccf0a3205e70fd78fb20a84cf09dfaee3f642ef45d78e4a50eb86d287b9d0974e8d33075528eef03702fe311175aa5e1
|
data/CHANGELOG.md
CHANGED
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
|
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
|
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
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
66
|
-
sends =
|
67
|
-
clicks =
|
68
|
-
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
|
data/lib/ahoy_email/version.rb
CHANGED
@@ -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
|
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.
|
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-
|
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.
|
126
|
+
rubygems_version: 3.3.7
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: First-party email analytics for Rails
|