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

feat: Pass customData asm parameters to SendGrid #5403

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

dmgarland
Copy link
Contributor

What change does this PR introduce?

Looks for an optional asm parameter in customData that is passed through to the SendGrid API.

Why was this change needed?

Addresses #5402

Copy link

netlify bot commented Apr 12, 2024

👷 Deploy request for dev-web-novu pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit bfce795

Copy link

netlify bot commented Apr 12, 2024

Deploy Preview for novu-design failed. Why did it fail? →

Name Link
🔨 Latest commit bfce795
🔍 Latest deploy log https://app.netlify.com/sites/novu-design/deploys/661e40be5403850008324d14

Comment on lines +16 to +19
type ASMConfig = {
groupId: number;
groupsToDisplay: number[];
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
type ASMConfig = {
groupId: number;
groupsToDisplay: number[];
};
type ASMConfig = {
groupId: number | string;
groupsToDisplay: Array<number | string>;
};

Comment on lines +77 to +85
const asm = options.customData?.asm as ASMConfig;
if (asm?.groupId) {
asm.groupId = parseInt(asm.groupId as any); // Sendgrid expects groupId to be a number
}
if (asm?.groupsToDisplay) {
asm.groupsToDisplay = asm.groupsToDisplay.map((group) =>
parseInt(group as any)
); // Sendgrid expects groupsToDisplay to be an array of numbers
}
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: if we would like to allow passing the string or number for both fields, please create a mapper function that will create a new object with appropriate value types like:

  private mapAsmOptions(asm: ASMConfig): MailDataRequired['asm'] {
    return {
      groupId: parseInt(`${asm.groupId}`),
      groupsToDisplay: asm.groupsToDisplay.map((group) => parseInt(`${group}`)),
    };
  }
...

const asm = this.mapAsmOptions(options.customData?.asm);

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

Successfully merging this pull request may close these issues.

None yet

3 participants