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
base: next
Are you sure you want to change the base?
feat: Pass customData asm parameters to SendGrid #5403
Conversation
👷 Deploy request for dev-web-novu pending review.Visit the deploys page to approve it
|
❌ Deploy Preview for novu-design failed. Why did it fail? →
|
type ASMConfig = { | ||
groupId: number; | ||
groupsToDisplay: number[]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type ASMConfig = { | |
groupId: number; | |
groupsToDisplay: number[]; | |
}; | |
type ASMConfig = { | |
groupId: number | string; | |
groupsToDisplay: Array<number | string>; | |
}; |
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 | ||
} |
There was a problem hiding this comment.
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);
What change does this PR introduce?
Looks for an optional
asm
parameter incustomData
that is passed through to the SendGrid API.Why was this change needed?
Addresses #5402