Skip to content

Disable open/click tracking response (round 2) #189

Closed

Description

@chadlagore

Issue Summary

Hello!

I'm receiving some odd feedback when I attempt to disable tracking settings for internal test messages. I explicitly set the enable parameter to False, but the response suggests I haven't done so.

Here is the output of print(e.read()):

{"errors":[{"message":"The click_tracking enable parameter is required.","field":"tracking_settings.click_tracking.enable","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.tracking_settings.click_tracking.enable"},{"message":"The open_tracking enable parameter is required.","field":"tracking_settings.open_tracking.enable","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.tracking_settings.open_tracking.enable"},{"message":"The subscription_tracking enable parameter is required.","field":"tracking_settings.subscription_tracking.enable","help":"http://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html#message.tracking_settings.subscription_tracking.enable"}]}

Here is the relevant section of print(mail.get()):

'tracking_settings': {'subscription_tracking': {}, 'open_tracking': {}, 'click_tracking': {}},

I don't know if this is a bug, or if I'm improperly using the API. Thought I would bring it to your attention.

Thanks!

Steps to Reproduce

My code:

mail = Mail(from_email, subject, to_email, content)

if '@internalemailaddress.com' in email:
        tracking_settings = TrackingSettings()
        tracking_settings.set_click_tracking(ClickTracking(enable=False, False))
        tracking_settings.set_open_tracking(OpenTracking(enable=False))
        tracking_settings.set_subscription_tracking(SubscriptionTracking(enable=False))
        mail.set_tracking_settings(tracking_settings)

Technical details:

  • sendgrid-python Version: master (latest commit: d199afc)
  • Python Version: 3.5

Activity

  1. chadlagore commented on Jul 11, 2016

    @chadlagore
    Author

    I've made a workaround that is working for the time being. Helper function:

    def disable_tracking(data):
    
        tracking_disabled = {
            "subscription_tracking" : {"enable" : False},
            "open_tracking" : {"enable" : False},
            "click_tracking" : {"enable" : False}
        }
        data['tracking_settings'] = tracking_disabled
    
        return data
    

    Where data = mail.get(). Apply after you perform the personalizations using Personalization class, and before you pass to sg.client.mail.send.post(request_body = data).

  2. thinkingserious commented on Jul 11, 2016

    @thinkingserious
    Contributor

    Hello @inversquare,

    I believe you have found a bug similar to sendgrid/sendgrid-go#68

    Thanks for sharing your work around before we get it fixed!

    Please email us at dx@sendgrid.com with your T-shirt size and address so that we can send you some swag :)

  3. thinkingserious commented on Jul 11, 2016

    @thinkingserious
    Contributor
  4. kontinuity commented on Aug 3, 2016

    @kontinuity

    I am facing the same issue with sendgrid==3.1.10. The data generated only has enable_text in it and throws the above error. Sample output for reference:

     "tracking_settings": {
        "subscription_tracking": {
          "enable": false
        },
        "open_tracking": {
          "enable": false
        },
        "click_tracking": {
          "enable_text": false
        },
        "ganalytics": {
          "enable": false
        }
      },
    

    Code:

        tracking_settings = TrackingSettings()
        tracking_settings.set_click_tracking(ClickTracking(enable=tracking_enabled, enable_text=tracking_enabled))
        tracking_settings.set_open_tracking(OpenTracking(enable=tracking_enabled))
        tracking_settings.set_subscription_tracking(SubscriptionTracking(enable=False))
        tracking_settings.set_ganalytics(Ganalytics(enable=False))
        mail_obj.set_tracking_settings(tracking_settings)
    
  5. thinkingserious commented on Aug 4, 2016

    @thinkingserious
    Contributor

    Thanks for the heads up @kontinuity!

    You can follow that bug here: #202

  6. thinkingserious commented on Aug 4, 2016

    @thinkingserious
    Contributor

    @kontinuity,

    I was unable to reproduce this.

    Could you please tell me the value of tracking_enabled in your sample code?

    I used tracking_enabled = True

  7. aaron-maslim commented on Nov 23, 2016

    @aaron-maslim

    @thinkingserious The tracking_enabled is False . You missed changing the if in one of the helpers

    class ClickTracking(object):
        def __init__(self, enable=None, enable_text=None):
            self.enable = enable if enable else None # this line should be if enable != None else None
            self.enable_text = enable_text if enable_text !=None else None
    
  8. thinkingserious commented on Nov 29, 2016

    @thinkingserious
    Contributor

    Thanks for the heads up @aaron-maslim! I will take another look.

  9. changed the title [-]Disable open/click tracking response[/-] [+]Disable open/click tracking response (round 2)[/+] on Nov 30, 2016
  10. HUSSTECH commented on Mar 19, 2017

    @HUSSTECH

    Just updating that this issue is still present in 3.6.3. But there is a pretty nice workaround using the set_enable() method of the ClickTracking() object. Just do:

    tracking_settings = TrackingSettings()
    ct = ClickTracking(False, False)
    ct.set_enable(False)
    tracking_settings.set_click_tracking(ct)
    mail.set_tracking_settings(tracking_settings)
    
  11. thinkingserious commented on Mar 20, 2017

    @thinkingserious
    Contributor

    Thank you @HUSSTECH!

    I've added your vote to this issue to help increase its priority in our backlog queue.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions