Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MailData must have dynamicTemplateData property #716

Merged
merged 3 commits into from
Oct 4, 2018
Merged

MailData must have dynamicTemplateData property #716

merged 3 commits into from
Oct 4, 2018

Conversation

dyatko
Copy link
Contributor

@dyatko dyatko commented Aug 2, 2018

The library doesn't send dynamicTemplateData added to the personalization to the SendGrid API.
dynamicTemplateData in the MailData works.

Fixes

Checklist

  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the [Contribution Guide] and my PR follows them.
  • I updated my branch with the master branch.
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation about the functionality in the appropriate .md file
  • I have added in line documentation to the code I modified

Short description of what this PR does:

If you have questions, please send an email to Sendgrid, or file a Github Issue in this repository.

The library doesn't send dynamicTemplateData added to the personalization to the SendGrid API.
dynamicTemplateData in the MailData works.
@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Aug 2, 2018
@SendGridDX
Copy link
Collaborator

SendGridDX commented Aug 2, 2018

CLA assistant check
All committers have signed the CLA.

@thinkingserious thinkingserious added type: community enhancement feature request not on Twilio's roadmap difficulty: medium fix is medium in difficulty labels Aug 4, 2018
@thinkingserious
Copy link
Contributor

Thanks @dyatko!

@Maxwell2022
Copy link

Should the dynamicTemplateData be removed from personalizations then? @mvpspl619

@@ -152,6 +152,7 @@ export interface MailData {
substitutionWrappers?: string[],

isMultiple?: boolean,
dynamicTemplateData?: { [key: string]: string },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might need to be dynamicTemplateData?: { [key: string]: any }

because you can pass objects like this:

'dynamic_template_data': {
  'subject': 'Hi!',
  'name': 'Example User',
  'location': {
    'city': 'Birmingham',
    'country': 'United Kingdom'
  }
}

@thinkingserious
Copy link
Contributor

When you have a moment, could you please provide a second set of eyes on this one for us @spartan563? Thanks!

Copy link
Contributor

@notheotherben notheotherben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks sensible to me 👍

@kyleowens10
Copy link

Any updates here? Would love to get this in and not have to use the legacy templates.

@thinkingserious thinkingserious merged commit b354b46 into sendgrid:master Oct 4, 2018
@thinkingserious
Copy link
Contributor

Hello @dyatko,

Thanks again for the PR!

We want to show our appreciation by sending you some swag. Could you please fill out this form so we can send it to you? Thanks!

Team SendGrid DX

@dyatko
Copy link
Contributor Author

dyatko commented Oct 4, 2018

@thinkingserious nice, thank you!

@edorivai
Copy link

Hi guys, I just ran into this exact issue, and am happy to find that it's already taken care of 🚀

Two questions/remarks:

  1. I just freshly installed @sendgrid/mail, and it seems this change isn't published yet. Where should I check to see when this gets out?
  2. The use case that is referenced in the original issue specifies dynamic_template_data, while the type specifies dynamicTemplateData. I dug through the source code, and as far as I can tell both should work. I suggest to at least make the types and the use case in the docs coherent.

Cheers 🙌

@kyleowens10
Copy link

Second the above, any immediate plans on pushing a release?

@thinkingserious
Copy link
Contributor

Hello @edorivai, @kyleowens10,

We publish our releases here and if you sign up for this mailing list, we'll send you an email upon release.

I'm hoping to get this out within weeks if not days with any luck.

For the long term, we are going to be thinking through a sustainable release schedule today with the goal of having more frequent and predictable release schedule

With Best Regards,

Elmer

@itaydressler
Copy link

Just wasted 4 hours on this issue ☹️.
Please deploy this to production, it's a pretty confusing issue for us Typescripters.

@dyatko dyatko deleted the patch-1 branch October 17, 2018 13:54
@ima-tech
Copy link

Do you have any plans to push a new release soon?

@kyleowens10
Copy link

@thinkingserious any idea yet on a timeline for release?

@bag-man
Copy link

bag-man commented Jan 21, 2019

@thinkingserious Adding to the list of people who had a bunch of time wasted by this not being deployed!

Could you please deploy it, your docs are updated with these typings, but the package isn't!

@robertu7
Copy link

@thinkingserious any updates?

@bag-man
Copy link

bag-man commented Jan 24, 2019

Workaround:

  // https://github.com/sendgrid/sendgrid-nodejs/pull/716
  interface MailDataFix extends MailData {
    dynamicTemplateData?: { [key: string]: any };
  }

@Mercurial
Copy link

Mercurial commented Feb 15, 2019

wasted days on this lmfao how is this very important fix still not in the npm package?

@driescroons
Copy link

driescroons commented Mar 14, 2019

Exactly what mercurial said 😄

Edit: I've fixed the issue by adding a defintion to my project

import { MailData } from '@sendgrid/helpers/classes/mail';

declare module '@sendgrid/helpers/classes/mail' {
  interface MailData {
    dynamicTemplateData?: { [key: string]: any };
  }
}

Why is this not deployed yet? @thinkingserious

@drewbietron
Copy link

drewbietron commented May 1, 2019

The types are there for me in 6.3.0 but the dynamic variables do not come across unless I send them up with a snaked case'd key.

For now I got this working by creating my own interface that extends from MailData

export interface IMailData extends MailData {
  personalizations: [
    {
      dynamic_template_data?: { [key: string]: any };
    }
  ];
}

@thinkingserious
Copy link
Contributor

Hello @drewbietron,

We have a deploy coming up that may fix this. I suggest you subscribe to our release newsletter to get the heads up. Thanks!

With Best Regards,

Elmer

@piyush-ramavat
Copy link

hello @thinkingserious ,

dynamic_template_data has to be snake case in type definitions.
if you use camelCase (dynamicTemplateData) then the sendgrid doesn't replace the values.

Would you be providing another release with typedef fixes?
Should I raise a PR with those changes in your lib?
Let me know thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: code review request requesting a community code review or review from Twilio type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.