module MailSpy
module EmailHelper
# Support for link clicks.
def track_link(*args, &block)
@_track_count ||= 0
if block_given?
options = args.first || {}
html_options = args.second
track_link(capture(&block), options, html_options)
else
@_track_count += 1
name = args[0]
options = args[1] || {}
html_options = args[2]
html_options = convert_options_to_data_attributes(options, html_options)
url = url_for(options)
href = html_options['href']
tag_options = tag_options(html_options)
# Inject our tracking url, and pass in the redirect_url
url = url_for(:controller => "mail_spy/tracking", :action => :link, :url => url,
:n => @_track_count, :eid => @_email_id)
href_attr = "href=\"#{ERB::Util.html_escape(url)}\"" unless href
"#{ERB::Util.html_escape(name || url)}".html_safe
end
end
# Support for open tracking, client support, etc
def tracking_bug
"
".html_safe
end
end
end