Giter Club home page Giter Club logo

ahoy_email's People

Contributors

12eh avatar ajb avatar ankane avatar atul9 avatar bcroesch avatar benreyn avatar chenhoward avatar dlackty avatar dorianmariecom avatar fabn avatar fluke avatar gdpelican avatar georgedrummond avatar gkampjes avatar joshdover avatar kieranklaassen avatar marzapower avatar mbreit avatar milgner avatar noahpryor avatar raulsouzalima avatar rememberlenny avatar ruslankhaertdinov avatar sbeckeriv avatar suaron avatar tonkpils avatar tyrauber avatar wflanagan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ahoy_email's Issues

Rails 5

Has this been tested with Rails 5?

Links without protocol aren't tracked

Links without http or https aren't converted by ahoy_email.

<!DOCTYPE html>
<html>
<head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"></head>
<body>
<p>Ahoy Test</p>
<p><a href="http://localhost:3000/ahoy/messages/2HvYSXaGAcPbxonICjGITEKI4MDdDJCc/click?signature=a0dc502385700e32515bf1a585a1fcfa3a82a0b8&amp;url=https%3A%2F%2Fkartikluke.com%3Futm_source%3Duser_mailer%26utm_medium%3Demail%26utm_campaign%3Dsequence_mail">Link with https</a></p>
<p><a href="http://localhost:3000/ahoy/messages/2HvYSXaGAcPbxonICjGITEKI4MDdDJCc/click?signature=ca7eb653436737ebf9bf165e0bf9c78bf0b6845c&amp;url=http%3A%2F%2Fkartikluke.com%3Futm_source%3Duser_mailer%26utm_medium%3Demail%26utm_campaign%3Dsequence_mail">Link with http</a></p>
<p><a href="kartikluke.com">Link without either</a></p>
<img alt="" src="http://localhost:3000/ahoy/messages/2HvYSXaGAcPbxonICjGITEKI4MDdDJCc/open.gif" width="1" height="1">
</body>
</html>

Comes from here: https://github.com/ankane/ahoy_email/blob/master/lib/ahoy_email/processor.rb#L153

Maybe if scheme is blank we can set it to http.

 def trackable?(uri)
    uri && uri.absolute? && %w(http https).include?(uri.scheme)
 end

Possible to store referring message id?

Hello,
First off, I've really loved working with this gem! I have a use case where it would be helpful to persist information about the referring email message (in a cookie or session variable). Essentially when a user clicks a link they are taken to an article. If a user tries to comment / interact with that article, I would like to show the login modal and have their email already filled in. This removes friction from the login process. I'm planning on monkey patching the message_controller to store the referring message id in a cookie or something, but was wondering if there is a better solution or if this is somehow built in. Thanks for any advice!

UPDATE:
This is where I'm at ... in intializers/ahoy.rb I patch the MessagesController class to store the email in the session. Then when the user attempts to comment or login, I auto populate the email as session[:login_email_suggestion] This functionality works especially well if the user hasn't visited the site in a while and doesn't remember their login email.

Ahoy::MessagesController.class_eval do
  def set_message
    @message = AhoyEmail.message_model.where(token: params[:id]).first
    session[:login_email_suggestion] = @message.try(:to)
  end
end

Different Model

Not sure what I'm doing wrong but I keep getting:
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column ahoy_messages.person_id does not exist LINE 1: ...LECT "ahoy_messages".* FROM "ahoy_messages" WHERE "ahoy_mess...

Make data store agnostic

Change Processor to Tracker and use concept of stores like Ahoy.

class AhoyEmail::Store < AhoyEmail::Stores::ActiveRecordStore
  uses_deprecated_subscribers # for easy migration

  def track_message(message, mailer, options)
    # message hooks
  end

  def track_send(token)
  end

  def track_open(token)
  end

  def track_click(token, url)
  end

  def user(message, mailer)
    @user ||= User.where(email: message.to.first).first
  end

  def report_exception(e)
    Rollbar.report_exception(e)
  end

  # for ActiveRecordStore and MongoidStore

  def message_model
    Message
  end

end

Add support for Mongoid as well.

NoMethodError (undefined method `ahoy' for #<Ahoy::MessagesController:0x6a21608>)

I'm getting this undefined method ahoy in line 5 below in my initializer. The database actually records the opened_at timestamp fine, so I'm good with the functionality. Just thought I'd report this error I found in my server log. Let me know if you need more information.

class EmailSubscriber

  def open(event)
    # :message and :controller keys
    ahoy = event[:controller].ahoy
    ahoy.track "Email opened", message_id: event[:message].id
  end

  def click(event)
    # same keys as above, plus :url
    ahoy = event[:controller].ahoy
    ahoy.track "Email clicked", message_id: event[:message].id, url: event[:url]
  end

end

AhoyEmail.subscribers << EmailSubscriber.new

Routes issue: Unable to access /ahoy/*

Do I need to place anything in config/routes.rb to get the gem working with Rails5?

All of the links generated by ahoy_email go to 404. Additionally, the 1px by 1px tracing image used for tracking if an email was open doesn't load.

All routes lead to root path

Here's the link that is supposed to go to our Facebook page. After clicking the link the user is just directed to our root path. Not sure what's going on exactly.

http://qa.hearingtracker.com/ahoy/messages/Knji6paAcoXzj4rk6tMn2QLrll4mLKbL/click?signature=d51042bea2a504a86573290b590910ef5dfc8ab1&url=https%253A%252F%252Fwww.facebook.com%252Fhearingtracker%252F%253Futm_campaign%253Dsignup_confirmation%2526utm_medium%253Demail%2526utm_source%253Duser_mailer

Track clicked links also in Mixpanel.

Hello,

First of all, I want to say that this gem works great I am able to track clicked links in e-mails and now I need to see these clicks also inside Mixpanel.

To make that happen I need to pass some custom params to redirect URL that is processed inside gem, so afterward I could so something like https://mixpanel.com/help/questions/articles/how-can-i-track-the-links-included-inside-my-mixpanel-email-notifications

Or maybe a way to send this click to mixpanel from messages_controller.rb, but would require some additional code to your gem.

Is there something that you could suggest?

Thanks.

Failing tests after adding gem.

Hello,

added the gem as it's written in documentation, it works fine, only thing is that now I am randomly getting this error in tests:

ActiveRecord::StatementInvalid: PG::InFailedSqlTransaction: ERROR:  current transaction is aborted, commands ignored until end of transaction block

sent_at doesn't get set sometimes

I'm using ahoy_email from quite some time and sometimes, the sent_at field doesn't get set and the email is delivered twice.. I am using sidekiq to delay the email delivery

This is the code in the mailer. Owners doesn't have duplicates

owners.map do |owner|
        if NotificationHistory.where(user_id: owner.id, notification_id: @notification.id).blank?
          NotificationHistory.create(user_id: owner.id, notification_id: @notification.id)
          track user: @model
          mail(to: owner.email, subject: "A new notification was added to #{@model}")
        end
      end

So even though I am checking that I won't send twice, it gets delivered twice and sent_at doesn't get set in the Ahoy::Message created (in both messages created, with identical attributes)

Is ahoy_email doing anything that could be relevant to this?

Problem integrating ahoy_email with mailkick

Hello, I'm trying to integrate ahoy_email with mailkick and running into a SystemStackError: stack level too deep error.

My mailer code is simple:

class AdminMailer < ApplicationMailer
  # ...
  def generated_recommendations(recommendations)                                               
    @recommendations = recommendations
    mail(subject: "Recommendations generated for #{Date.today.strftime("%Y-%m-%d")}")      
  end 
end

Before it crashes, the stack trace looks like this:

--> #0  Mailkick::Mailer.mail(headers#Hash, &block#NilClass)
      at /home/mike/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/mailkick-0.1.4/lib/mailkick/mailer.rb:4
    #1  AhoyEmail::Mailer.mail_with_ahoy(headers#Hash, &block#NilClass)
      at /home/mike/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/ahoy_email-0.3.0/lib/ahoy_email/mailer.rb:27
    #2  Mailkick::Mailer.mail(headers#Hash, &block#NilClass)
      at /home/mike/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/mailkick-0.1.4/lib/mailkick/mailer.rb:4
    #3  AhoyEmail::Mailer.mail_with_ahoy(headers#Hash, &block#NilClass)
      at /home/mike/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/ahoy_email-0.3.0/lib/ahoy_email/mailer.rb:27
    #4  Mailkick::Mailer.mail(headers#Hash, &block#NilClass)
      at /home/mike/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/mailkick-0.1.4/lib/mailkick/mailer.rb:4

...

It looks like each gem calls the mail method in the other (or mail_with_ahoy in this case). I traced through it with byebug and the relevant Mailkick code is (see line with ***)

module Mailkick                                                                                
  module Mailer                                                                                
    def mail(headers = {}, &block)                                                             
      message = super  # *** This ends up calling AhoyEmail::Mailer.mail_with_ahoy

      Mailkick::Processor.new(message).process

      message
    end
  end
end

and the relevant AhoyEmail code is (see ***)

module AhoyEmail                                                                               
  module Mailer
    def self.included(base)
      base.extend ClassMethods                                                                 
      base.class_eval do
        # ...
        alias_method_chain :mail, :ahoy                                                        
      end                                                                                      
    end                                                                                        

    module ClassMethods                                                                        
    # ...
    def mail_with_ahoy(headers = {}, &block)
      # this mimics what original method does                                                  
      return message if @_mail_was_called && headers.blank? && !block

      message = mail_without_ahoy(headers, &block)  # *** This calls Mailkick::Mailer.mail
      AhoyEmail::Processor.new(message, self).process                                          
      message
    end     
  end     
end

Has anyone run into this problem before? To me it looks like the gems conflict and I don't see an obvious workaround. I was surprised since Mailkick is referenced in the Readme, so I was thinking I may be missing something obvious.

How to get ahoy_email to work with the async deliver_later via ActiveJob?

When I call deliver_now ahoy email tracks emails and links perfectly. However, when I call deliver_later instead, it is not replacing the links with ahoy tracked links. E.g.,

class NotificationMailer < ApplicationMailer
    def new_message(user:)
        @user = user
        track user: @user
        mail(to: @user.email, subject: 'subject').deliver_later
    end
end

Is this gem an alternative to SendGrid?

Hello,

Can I use this gem as an alternative or compliment to SendGrid? I mean, will I get any information, that I don't already get from the statistics of SendGrid? Thank you.

Cheers,
Alex

Merge on nil in track_open

NoMethodError: undefined method `merge' for nil:NilClass
from /Users/becker/.rvm/gems/ruby-1.9.3-p484@project/gems/ahoy_email-0.1.5/lib/ahoy_email/processor.rb:58:in `track_open'

I will look in to this later. I am also using rails 3.2, roadie and resque_mailer. I am using the console and calling deliver! which should ignore resque_mailer. Sorry I dont have more info at this time.

Email Open callback not triggering ahoy event for email open, but works for email click

Having trouble getting the email open callback to trigger an ahoy event. The Ahoy::Message resource opened_at is being defined, the callback is working for the email click event works, but for some strange reason the email open event callback does not work. I've included my code for reference.

`class EmailSubscriber

def open(event)
	subscription = EmailSubscription.find_by_email(event[:message].to)
	admin_message = Admin::Message.find_by_message_uuid(event[:message].utm_content)
	event[:controller].ahoy.track "$emailOpen",
	                              message_id: event[:message].id,
	                              admin_message_name: (!admin_message.blank? ? admin_message.name : nil),
	                              admin_message_id: (!admin_message.blank? ? admin_message.id : nil),
	                              subscription_id: (!subscription.blank? ? subscription.id : nil )
end

def click(event)
	parsed_info = Rack::Utils.parse_query URI(event[:url]).query
	subscription = EmailSubscription.find_by_email(event[:message].to)
	admin_message = Admin::Message.find_by_message_uuid(event[:message].utm_content)
	event[:controller].ahoy.track "$emailClick",
	                              message_id: event[:message].id,
	                              url: event[:url].split('?').first,
	                              utm_campaign: parsed_info["utm_campaign"],
	                              utm_medium: parsed_info["utm_medium"],
	                              utm_source: parsed_info["utm_source"],
	                              utm_content: parsed_info["utm_content"],
	                              admin_message_name: (!admin_message.blank? ? admin_message.name : nil),
	                              admin_message_id: (!admin_message.blank? ? admin_message.id : nil),
	                              subscription_id: (!subscription.blank? ? subscription.id : nil )
end

end

AhoyEmail.subscribers << EmailSubscriber.new`

Sending Mail without Action Mailer

I'm using Campaign Monitor for email, but would like to move the tracking into Rails. Is there an easy way to use Ahoy to generate the tracking data without sending an email from Action Mailer?

ahoy_email

Hi there, I´m trying to work with this gem in openshift but it´s not working at all, on development it registers on db and send email ,but does not track anything, on openshift it does nothing at all,
can anyone help me please.

Ahoy email is corrupting emails sent in Greek and Ukranian (maybe others)

Hello. I've been looking into an issue reported by our users and have tracked it down to ahoy_email.

I'm on Version 0.3.0

The best way to summarise it, that I can come up with, is the HTML component of our outbound emails is being corrupted when there are non-latin characters being used. I'm not seeing any application exceptions.

Here is an example of what the rendered HTML component looks like when ahoy_email is enabled (broken):

��`��L���iay�fz֡��^��� ��z{Sʗ��{^�

Here is an example of what it looks like without ahoy_email (correct):

Patrick Swayze ξεκίνησε μια συζήτηση στην ομάδα Dirty Dancing Shoes:
wuthout ahoyemail


Απαντήστε άμεσα σε αυτό το ηλεκτρονικό μήνυμα ή δείτε το στο localhost.
Αλλάξτε τις προτιμήσεις του ηλεκτρονικού ταχυδρομείου σας για να διαγραφείτε από αυτά τα ηλεκτρονικά μηνύματα.

The text component of the email is not affected.

Here is the message source of broken email

Date: Fri, 15 Apr 2016 10:50:32 +1200
From: "Patrick Swayze (Loomio)" <notifications@localhost>
Reply-To: "Dirty Dancing Shoes"
 <d=326&u=778&k=2b44db7c9d2d415a5b1180ea2557d967@>
To: [email protected]
Message-ID: <326@localhost>
Subject: [Dirty Dancing Shoes] with ahoy email
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="--==_mimepart_57101eb8a8539_65933ff34883f9fc78875";
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Precedence: bulk
X-Auto-Response-Suppress: OOF
Auto-Submitted: auto-generated


----==_mimepart_57101eb8a8539_65933ff34883f9fc78875
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: base64

UGF0cmljayBTd2F5emUgzr7Otc66zq/Ovc63z4POtSDOvM65zrEgz4PPhc62
zq7PhM63z4POtyDPg8+EzrfOvSDOv868zqzOtM6xIERpcnR5IERhbmNpbmcg
U2hvZXM6Cgp3aXRoIGFob3kgZW1haWwKLS0tLS0tLS0tLS0tLQoKCgoKLS0K
zpHPgM6xzr3PhM6uz4PPhM61IM+DzrUgzrHPhc+Ez4wgz4TOvyDOt867zrXO
us+Ez4HOv869zrnOus+MIM68zq7Ovc+FzrzOsSDOsc+AzrXPhc64zrXOr86x
z4Igzq4gzrTOtc6vz4TOtSDPhM6/IM+Dz4TOvzoKbG9jYWxob3N0OgpodHRw
Oi8vbG9jYWxob3N0OjMwMDAvZC9qdW93VUFGUi93aXRoLWFob3ktZW1haWw/
dXRtX2NhbXBhaWduPXRocmVhZF9tYWlsZXImYW1wO3V0bV9tZWRpdW09ZW1h
aWwmYW1wO3V0bV9zb3VyY2U9bmV3X2Rpc2N1c3Npb24KCgrOkc67zrvOrM6+
z4TOtSDPhM65z4Igz4DPgc6/z4TOuc68zq7Pg861zrnPgiDPhM6/z4UgzrfO
u861zrrPhM+Bzr/Ovc65zrrOv8+NIM+EzrHPh8+FzrTPgc6/zrzOtc6vzr/P
hSDPg86xz4I6Cmh0dHA6Ly9sb2NhbGhvc3Q6MzAwMC9lbWFpbF9wcmVmZXJl
bmNlcz91bnN1YnNjcmliZV90b2tlbj1aUXMyUzV2VXkxTkt6SjFrVEc2dyZ1
dG1fY2FtcGFpZ249dGhyZWFkX21haWxlciZ1dG1fbWVkaXVtPWVtYWlsJnV0
bV9zb3VyY2U9bmV3X2Rpc2N1c3Npb24K

----==_mimepart_57101eb8a8539_65933ff34883f9fc78875
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: base64

DOCTYPEHTMLhtmlheadmetahttpequivContentTypeconteng==

----==_mimepart_57101eb8a8539_65933ff34883f9fc78875--

Here is message source of correct email:

Date: Fri, 15 Apr 2016 10:49:03 +1200
From: "Patrick Swayze (Loomio)" <notifications@localhost>
Reply-To: "Dirty Dancing Shoes"
 <d=325&u=779&k=f530a1139a9d6977f5454d34d18ed74d@>
To: [email protected]
Message-ID: <325@localhost>
Subject: [Dirty Dancing Shoes] wuthout ahoyemail
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="--==_mimepart_57101e5f17607_653e3fcf2a43f9e8517dc";
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Precedence: bulk
X-Auto-Response-Suppress: OOF
Auto-Submitted: auto-generated


----==_mimepart_57101e5f17607_653e3fcf2a43f9e8517dc
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: base64

UGF0cmljayBTd2F5emUgzr7Otc66zq/Ovc63z4POtSDOvM65zrEgz4PPhc62
zq7PhM63z4POtyDPg8+Ezr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3V0aG91
dC1haG95ZW1haWw/dXRtX2NhbXBhaWduPXRocmVhZF9tYWlsZXImYW1wO3V0
bV9tZWRpdW09ZW1haWwmYW1wO3V0bV9zb3VyY2U9bmV3X2Rpc2N1c3Npb24i
Ps60zrXOr8+EzrUgz4TOvyDPg8+Ezr8gbG9jYWxob3N0PC9hPi4KICAgICAg
PGJyPgogICAgICDOkc67zrvOrM6+z4TOtSA8YSBocmVmPSJodHRwOi8vbG9j
YWxob3N0OjMwMDAvZW1haWxfcHJlZmVyZW5jZXM/dW5zdWJzY3JpYmVfdG9r
ZW49VTEtMThCYTJKeHhtdl9MZVkyYUImYW1wO3V0bV9jYW1wYWlnbj10aHJl
YWRfbWFpbGVyJmFtcDt1dG1fbWVkaXVtPWVtYWlsJmFtcDt1dG1fc291cmNl
PW5ld19kaXNjdXNzaW9uIj7PhM65z4Igz4DPgc6/z4TOuc68zq7Pg861zrnP
giDPhM6/z4UgzrfOu861zrrPhM+Bzr/Ovc65zrrOv8+NIM+EzrHPh8+FzrTP
gc6/zrzOtc6vzr/PhSDPg86xz4I8L2E+IM6zzrnOsSDOvc6xIM60zrnOsc6z
z4HOsc+GzrXOr8+EzrUgzrHPgM+MIM6xz4XPhM6sIM+EzrEgzrfOu861zrrP
hM+Bzr/Ovc65zrrOrCDOvM63zr3Pjc68zrHPhM6xLgogICAgPC9wPgogIDwv
Ym9keT4KPC9odG1sPgo=

----==_mimepart_57101e5f17607_653e3fcf2a43f9e8517dc--

Best way to track a newsletter?

I have a mailer which is used to deliver a newsletter, so the mailer name is fixed while the content is dynamically sourced from a model (Newsletter). I'd like to associate sendings with said model, so I can track each newsletter individually.

With each deployment old links dont work

I am using this gem for tracking the mails and the clicks .

Issue : With each deployment the external links given in mail goes to root url

I found that the signature does not match after the deployment .
In the def click action messages_controller.rb, there is a check for the signature (secure_compare) it always gives false after deployment.

But the same action for the mails sent after deployment works fine and goes to destination link.

Is this a bug with this gem or i am missing out some configuration from my side.

Signature matching fails for mails opened on old browsers

This is happening in case of old browsers - IE and Safari 6. Exact issue being these browsers decode the '%26' as '&' in the redirection url, thus making query params out of the entire url for the original ahoy's url.

Example :
https://mydomain.com/ahoy/messages/jww7AmF2DPiz7oZeEGTs7wYJTEWKbm2d/click?signature=5296552ddad41b20b465c2764ab607caa35946cb&url=https%3A%2F%2Famazingapp.com%2Fapp%3Fend_date%3D2016-11-01%26base_date%3D2015-11-01

Above url being correct is returned as
https://mydomain.com/ahoy/messages/jww7AmF2DPiz7oZeRtTs7wYJTEWKbm2d/click?signature=5296552ddad41b20b465c2764aba57caa35946cb&url=https%3A%2F%2Famazingapp.com%2Fapp?end_date=2016-11-01&base_date=2015-11-01

How to start work on ahoy_email

I followed the same but I could able to migrate and I got table called ahoy_messages and when I send any mail then, fields in the ahoy_messages table were updated, but when I read the mail in gmail/yahoo open_at field is not updating. Can you please say me where were I went wrong

AhoyEmail.secret_token is nil causing TypeError: no implicit conversion of nil into String

Hey Andrew,

I installed ahoy_email in my rails 4.1.5 app. When I tried to send an email, I got this error:

TypeError: no implicit conversion of nil into String
from /Users/rahil/.rvm/gems/ruby-2.1.1/gems/ahoy_email-0.2.1/lib/ahoy_email/processor.rb:106:in `hexdigest'

In rails console, AhoyEmail.secret_token returns nil.

I generated a secret with rake secret and tried to put it in an initializer like AhoyEmail.secret_token = SECRET or AhoyEmail.options[:secret_token] = SECRET but neither worked.

Could this have something to do with the new rails 4.1 secrets.yml file?

Any tips? Thanks!

Tracking non-user recipients

In our use case, we're looking to track all people who opened an email, some of which may not have corresponding user accounts in our system (i.e. the billing contact address is a non-user). Is this still feasible with ahoy_email? It seems like a great gem!

Thanks.

Mails are not intercepted

Hi @ankane!

I have a problem where my mails on Heroku are not being intercepted and hence no Ahoy::Message is created everytime I send a mail. It's a Rails 4 app. (It's working on local.)

I am using sendgrid for sending my mails. Will this affect it?
I am also sending my emails as background jobs using suckerpunch.

I do see that the AhoyEmail::Interceptor has been registered:

irb(main):018:0> Mail.class_variable_get(:@@delivery_interceptors)
=> [AhoyEmail::Interceptor]

The mails actually get sent through, and there are no errors. It just seems that the interceptor is not kicking in?

Would you be able to point me in the right direction? Thank you so much!

email tracking on cc and bcc

Hey,

great gem!

how does that tracking (view and open) work with CC and BCC emails?
does it check who opened/clicked or it doesn't care?

Routing is broken:

I am using comfortable_mexican_sofa which has a catch all route in it. The Ahoy engine is being mounted by the gem after the cms has been initialized. This is causing the engine to be mounted last after the catch all route.

So basically the /ahoy is never found as the cms is trying to interrupt it. It would be great if this gem allowed for the engine to be mounted by the user to control the mount point and order it is loaded.

There is a simple work around..In your application.rb control the order in which the engines are loaded:

    config.railties_order = [AhoyEmail::Engine, :all]

This will mount the engine first which is what I needed

TypeError (can't convert nil into String)

I'm getting a TypeError (can't convert nil into String): in line 3 below. I checked to make sure that user.email is not nil, so it isn't that. The Ruby error isn't very helpful so not sure how to proceed. Is there something I need to pass into the mail method?

class UserMailer < ActionMailer::Base
  def send_welcome_email(user)
    mail(:to => user.email, :subject => "Welcome!")
  end
end

Link Tracking Performance

In running some benchmarks with ahoy_email, it looks like Link Tracking adds over 400% overhead over ActiveMailer. The feature is important, and some overhead is warranted, but I am wondering if there might be a different approach to parsing the html and augmenting the links.

I ran a bunch of different benchmarks. All benchmarks are for 100 Emails in development, with perform_deliveries = false. HTML content is generated outside of mail and passed as a body attribute.

Without ahoy_email
total: 9413.025117999496, average: 94ms

With ahoy_email

  • No content, open or click links, (Just ahoy_message creation)
    total: 10273.89198200035, average: 103ms
  • Content, no open or click links
    total: 10765.760098998726, average: 108ms
  • Content, open and no click links
    total: 11681.741282001894, average: 116ms
  • Content, open and click links
    total: 45126.064590996975, average: 451ms
  • No Content, No open, Just click links
    total: 46715.007976999914, average: 467ms

Everything else in the gem performs really well, adding marginal overhead. It were possible to design a different approach to link tracking - perhaps using regex instead of nokogiri - then it could be justified using ahoy_email in every scenario, including sending mailing lists at scale.

In the meantime, if performance is required for a specific mailer, then "track click: false" is required.

Can you reference Ahoy::Message properties from email template? i.e. token?

Sorry, this isn't much of an issue -- but I'm trying to figure out if I am able to reference some of the auto-generated items that are tracked by Ahoy in the email template.

For example, I want to include the generated Ahoy::Message.token as a link parameter as part of an invitation scheme. Are these properties accessible somehow in the email templates?

order of precedence

I am little unsure I am thinking of it incorrectly or there is an issue.

I set

AhoyEmail.track message: false, click: false 

Then in my mailer that I do want to track I call track

track user: @user 

It does not appear to track my message. If I remove the my AhoyEmail setting I get an error that I will cut a new issue for and look in to.

Should the mailer level tracking over write the AhoyEmail setting? I would think that it should. The auto tracking is nice but I really don't want to track every email.

AWS `opened_at:` and `clicked_at:` are not updated

Hey there,

I have a question concerning implementation on AWS servers. We have a rails app(3.2.13) using ruby-1.9.3. The app is currently deployed on an AWS instance, using Elastic Beanstalk.
What I have done so far:

  1. Installed gem in localhost and production.
  2. Ran rake db:migrate
  3. Added has_many :messages, class_name: "Ahoy::Message" to the User model.
  4. Added track user: user to the mail action i want to use, in this case UserMailer#welcome_email
  5. Sent a test email to my own user

After doing this, the proper record was created in the Message table:
=> #<Ahoy::Message id: 2, token: "q1TxBtUVvpI9oP6ESUdhgqMPzzFKoZYW", to: "[email protected]", user_id: 3, user_type: "User", mailer: "UserMailer#welcome_email", subject: "Welcome to....", content: "Date: Wed, 24 Feb 2016 17:35:15 +0000\r\nFrom: Test...", sent_at: "2016-02-24 17:35:15", opened_at: nil, clicked_at: nil>

As you can see the opened_at and clicked_at are nil and to be honest I have no idea how to debug this.

This is the link for the image:
https://ci4.googleusercontent.com/proxy/6X_j9-ozpgXAbnN9YgcH4VT2bytEV4IKvxNbxd6j5PXEVTnx254zQbJCNoEU6SM4XpqKBR8N4DUWug97t5S-sRbJRxKT252Y89W2vd8T67jkwhoxPuERlStlN4hesrgtpQ=s0-d-e1-ft#http://noombers.com/ahoy/messages/1ie2yMGZXVRPHvGYVD2HuWimlAwrnJ2e/open.gif

Moreover the extra params are added to the links so that should be tracked as well.

Any ideas how I can debug or what is can be causing this? Anyone already used ahoy_mail on a AWS instance?

EDIT: After playing a bit around i figured it is not tracking them because of domain inconsistency. I was testing on a staging environment which uses different domain that usual app, however the link in the email were not to the the staging but to the actual domain of the app. This caused it not to work. I hardcoded the links to the staging environment and it works.

Routing Error

Looks like I'm having a routing issue.
This happens on first install.

ActionController::RoutingError at /ahoy/messages/HqtpsWxe6CPRA37YHLY70QIhOXSWP6OF/click
Page Not Found at: "ahoy/messages/HqtpsWxe6CPRA37YHLY70QIhOXSWP6OF/click"

URL is:

http://localhost:5000/ahoy/messages/HqtpsWxe6CPRA37YHLY70QIhOXSWP6OF/click?signature=97a69fdc61216eaf20ab2e18962b2c1fa153a28f&url=http%3A%2F%2Flocalhost%3A5000%2Fusers%2Fpassword%2Fedit%3Freset_password_token%3De3doyBSQJ1Uwf1YVRyG5%26utm_campaign%3Dreset_password_instructions%26utm_medium%3Demail%26utm_source%3Ddevise%252Fmailer
$ rake routes | grep ahoy
                           ahoy_email_engine        /ahoy                                                                           AhoyEmail::Engine
 open_message GET  /messages/:id/open(.:format)  ahoy/messages#open
click_message GET  /messages/:id/click(.:format) ahoy/messages#click

Using Rails mailer previews creates entries in ahoy_messages

Has anyone else seen Rails' mailer previews creating entries in the ahoy_messages table? We're actually seeing two entries created for every preview, I believe because of the way mailers are presented in frames—one frame contains the header preview at the top, the other contains the HTML view of the email itself below.

I don't think we're doing anything custom with mailers, previewers or ahoy. And I don't see any other issues mentioning this phenomenon. Am I missing something simple?

We're running Rails 5.0.0.1 and ahoy_email 0.4.0.

Emails marked as spam because of click tracking

It appears the approach taken in ahoy emails for tracking email clicks is driving up our spam score, due to it being a phishing technique to mask and redirect to the intended target of the link.

Has anyone else experienced this?

More details on the reported issue here:
loomio/loomio#4022

mail not being intercepted

@ankane
When I test this locally, ahoy email is being intercepted however when I send a test email in the production environment, rails and/or ahoy email is not processing the interceptor.

Links getting closed out prematurely

Here is my email template:

<a class="large-button" href="<%= @link %>" style="color: #ffffff !important; font-family: Helvetica, Arial, sans-serif; text-decoration: none">
  <table style="border-collapse: collapse; border-spacing: 0; overflow: hidden; padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; text-align: left; vertical-align: top; width: 100%">
    <tr style="padding-bottom: 0; padding-left: 0; padding-right: 0; padding-top: 0; text-align: left; vertical-align: top" align="left">  
      <td style="-moz-hyphens: auto; -webkit-hyphens: auto; background-color: #2ECC71; border-bottom-color: #090; border-bottom-style: solid; border-bottom-width: 1px; border-collapse: collapse !important; border-left-color: #090; border-left-style: solid; border-left-width: 1px; border-right-color: #090; border-right-style: solid; border-right-width: 1px; border-top-color: #090; border-top-style: solid; border-top-width: 1px; color: #ffffff; display: block; font-family: Helvetica, Arial, sans-serif; font-size: 18px; font-weight: normal; hyphens: auto; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px; text-align: center; text-decoration: none; vertical-align: top; width: auto !important; word-break: break-word" align="center" bgcolor="#00acee" valign="top">
        Answer Question
      </td>
  </tr>
  </table>
</a>

Here is the generated link:

<a class="large-button" href="http://localhost:3000/ahoy/messages/PyYn4oblZUR1G3MODdw6UHO5cL6McPCR/click?signature=c5046e07c95405477cc30c4ced847bbe9d804284&amp;url=http%3A%2F%2Flocalhost%3A3000%2Fask%2Fask-what%3Fsource%3Dnotification%26utm_campaign%3Dquestion_notify%26utm_medium%3Demail%26utm_source%3Dquestion_mailer" style="color: #ffffff !important; font-family: Helvetica, Arial, sans-serif; text-decoration: none" target="_blank">
</a>

How to use Ahoy_Email links in Rspec tests

I test my emails to see if they contain specific links. Now with the ahoy_email gem the links that get generated contain all of the tracking parameters so my tests fail.

How can I generate those links with the parameters in my Rspec tests so the tests will work.

Example:

it "has a link to the quotation request show page" do

  #setup
  proofreader = create(:employee)
  quotation_request = create(:quotation_request)

  #exercise
  email = EmployeeMailer.quotation_request_notification(quotation_request, proofreader)

  #verification
  expect(email.text_part.body.to_s).to include(quotation_request_url(quotation_request))
  expect(email.html_part.body.to_s).to include(quotation_request_url(quotation_request))

end

This fails because within Rspec ahoy_email is not generating the URL with the extra parameters for tracking.

How can I get ahoy_email to work inside of Rspec tests?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.