Skip to content

Disable Tracking Settings for Email #181

Closed

Description

@LTholen

Issue Summary

It's not possible to disable tracking settings for a single email, e.g. click_tracking, because the "enabled" flag does not get serialised to JSON if it is false (default value) and the SendGrid server rejects the request as a result of that. In this example I used click_tracking, but this should also be changed for other tracking settings.

Steps to Reproduce

  1. This is how I disable click tracking for a single email
TrackingSettings trackingSettings = new TrackingSettings();

// disable click tracking
ClickTrackingSetting clickTrackingSetting = new ClickTrackingSetting();
clickTrackingSetting.setEnable(false);
clickTrackingSetting.setEnableText(false);
trackingSettings.setClickTrackingSetting(clickTrackingSetting);

this.mail.setTrackingSettings(trackingSettings); // com.sendgrid.Mail
  1. This is how I send the email
Request request = new Request();
this.mail.addPersonalization(personalization);

request.method = Method.POST;
request.endpoint = "mail/send";
request.body = mail.build(); // this is the important part
Response response = this.api(request);
  1. mail.build() does not include the click_tracking settings. Those "enable" booleans will not get serialized if they are false because of @JsonInclude(Include.NON_DEFAULT) in ClickTrackingSetting (false is the default value of boolean). mail.build() creates a JSON that looks like this: "tracking_settings":{"click_tracking":{}} when I want to disable click tracking.
    I expect it to look like this: "tracking_settings":{"click_tracking":{"enable": false, "enable_text": false}}

  2. The SendGrid server rejects the JSON created by mail.build() containing "tracking_settings":{"click_tracking":{}} but accepts my manually created JSON containing"tracking_settings":{"click_tracking":{"enable": false, "enable_text": false}}

Possible solution:

Instead of boolean(primitive) with default value false, use Boolean(object) with default value null to enable/disable settings.
Example ClickTrackingSetting.java:
@JsonProperty("enable") private Boolean enable;
instead of
@JsonProperty("enable") private boolean enable;

Technical details:

  • sendgrid-java Version: v3.1.0

Activity

  1. added
    status: help wanted
    type: bug
    on Jan 26, 2017
  2. thinkingserious commented on Jan 26, 2017

    @thinkingserious
    Contributor

    Thanks @LTholen,

    I've added this to our backlog for a fix.

  3. simon-heinen commented on Apr 24, 2017

    @simon-heinen

    @thinkingserious any update on this?

  4. thinkingserious commented on Apr 29, 2017

    @thinkingserious
    Contributor

    Hi @simon-heinen,

    I have added your vote to this issue in our backlog. For this issue to rise in our backlog, we need more participants on this thread. The fastest way for it to rise is with a PR.

    Thank you!

    Elmer

  5. hc1jcarter commented on Jun 9, 2017

    @hc1jcarter

    This is a huge blocker for us as well.

  6. thinkingserious commented on Jun 10, 2017

    @thinkingserious
    Contributor

    Thanks @hc1jcarter,

    Your vote has been added.

    While this issue is continuing to climb in our backlog, it's fairly down on the list right now. The best chance for this to be fixed shortly will be a PR. If anyone is interested, I'm happy to help with that.

    With Best Regards,

    Elmer

  7. added a commit that references this issue on Sep 19, 2017
    6d5b126
  8. removed
    difficulty: very hard
    difficulty: medium
    on Oct 27, 2017
  9. roshanail commented on Nov 27, 2017

    @roshanail

    I noticed that click tracking has been fixed. However open tracking still has the Include.NON_DEFAULT annotation in it.
    So has it only been fixed for click tracking and not the other tracking settings?

  10. thinkingserious commented on Nov 28, 2017

    @thinkingserious
    Contributor

    Hi @roshanail,

    Can you please point me to where you are seeing that? This is what I see.

    With Best Regards,

    Elmer

  11. roshanail commented on Dec 12, 2017

    @roshanail

    Looks like it came in on this merge you did 14 days ago

    22ba9e9#diff-39711246df8201ee796925f1177ea824

    It wasn't there when I looked at it.

    Thanks for the update

  12. thinkingserious commented on Dec 14, 2017

    @thinkingserious
    Contributor

    Thanks for following up @roshanail!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: help wantedtype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions