-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for enabling sendgrid click tracking (#618)
Resolve #596 Adds support for enabling click_tracking for sendgrid emails. The commit sets both `enabled` and `enabled_text` for HTML and text-only emails. Consider Sendgrid's message for click tracking: > It's important to consider the privacy implications of enabling Click and Open tracking before enabling the feature. Depending on the country where your recipient resides, using this feature to track engagement may require the unambiguous consent of the recipient. References: https://docs.sendgrid.com/ui/account-and-settings/tracking https://docs.sendgrid.com/api-reference/settings-tracking/update-click-tracking-settings
- Loading branch information
1 parent
75569aa
commit 0104d71
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -335,6 +335,38 @@ defmodule Bamboo.SendGridAdapterTest do | |
assert params["tracking_settings"]["ganalytics"]["utm_content"] == "content" | ||
end | ||
|
||
test "deliver/2 correctly handles when with_click_tracking is enabled" do | ||
email = | ||
new_email( | ||
from: {"From", "[email protected]"}, | ||
subject: "My Subject" | ||
) | ||
|
||
|> Bamboo.SendGridHelper.with_click_tracking(true) | ||
|> SendGridAdapter.deliver(@config) | ||
|
||
assert_receive {:fake_sendgrid, %{params: params}} | ||
assert params["tracking_settings"]["click_tracking"]["enabled"] == true | ||
assert params["tracking_settings"]["click_tracking"]["enable_text"] == true | ||
end | ||
|
||
test "deliver/2 correctly handles when with_click_tracking is disabled" do | ||
email = | ||
new_email( | ||
from: {"From", "[email protected]"}, | ||
subject: "My Subject" | ||
) | ||
|
||
|> Bamboo.SendGridHelper.with_click_tracking(false) | ||
|> SendGridAdapter.deliver(@config) | ||
|
||
assert_receive {:fake_sendgrid, %{params: params}} | ||
assert params["tracking_settings"]["click_tracking"]["enabled"] == false | ||
assert params["tracking_settings"]["click_tracking"]["enable_text"] == false | ||
end | ||
|
||
test "deliver/2 correctly handles a sendgrid_send_at timestamp" do | ||
email = | ||
new_email( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters