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

Email: Add a dynamic API email for new fundraisers #948

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ssandino
Copy link
Member

@ssandino ssandino commented Nov 22, 2024

To-Do:
1. Decide how to handle the two variants (with or without a goal): separate emails or conditional logic.
2. Decide whether to include an unsubscribe option for this important email.

For testing, you can access the email in SendGrid using the Template ID: d-a03378d2719a4e38b6c21af18be132c4.

Summary by CodeRabbit

  • New Features
    • Introduced three new email templates for fundraising communications:
      • fundraiser-end-en.html: Acknowledges the conclusion of a fundraising campaign.
      • fundraiser-start-en.html: Initiates fundraising activities with engaging content.
      • fundraiser-thanks-contributor-en.html: Thanks contributors for their donations and highlights impact.
  • Improvements
    • Enhanced styling for compatibility across various email clients, ensuring a consistent user experience.

Copy link

vercel bot commented Nov 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
public ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 2, 2024 2:16pm

Copy link

coderabbitai bot commented Nov 22, 2024

📝 Walkthrough

Walkthrough

This pull request introduces three new HTML email templates related to fundraising activities: fundraiser-end-en.html, fundraiser-start-en.html, and fundraiser-thanks-contributor-en.html. Each file follows standard HTML structure with embedded CSS for responsive design and compatibility across various email clients. The templates include preheader sections, logos, hero messages, and calls to action, while also addressing specific rendering issues for different platforms.

Changes

File Path Change Summary
shared/emails/transactional/fundraiser-*.html Three new HTML files added for fundraising emails: fundraiser-end-en.html, fundraiser-start-en.html, and fundraiser-thanks-contributor-en.html. Each file includes structured content, responsive design, and styling for compatibility across email clients.

Possibly related PRs

  • Email: November 2024 Newsletter  #957: The fundraiser-end-en.html file and the fundraiser-start-en.html file share a common theme of fundraising emails, indicating a related context in email design for fundraising campaigns.

Suggested reviewers

  • andrashee
  • mkue
  • socialincome-dev

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ssandino
Copy link
Member Author

@coderabbitai review

Copy link

coderabbitai bot commented Nov 22, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 383c570 and 975f92f.

📒 Files selected for processing (1)
  • shared/emails/transactional/fundraiser-live-en.html (1 hunks)
🔇 Additional comments (1)
shared/emails/transactional/fundraiser-live-en.html (1)

704-718: LGTM: Proper implementation of unsubscribe functionality

The email template correctly implements unsubscribe functionality using SendGrid variables and follows email best practices by placing these options in the footer.

shared/emails/transactional/fundraiser-live-en.html Outdated Show resolved Hide resolved
shared/emails/transactional/fundraiser-live-en.html Outdated Show resolved Hide resolved
shared/emails/transactional/fundraiser-live-en.html Outdated Show resolved Hide resolved
shared/emails/transactional/fundraiser-live-en.html Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Nov 22, 2024

Visit the preview URL for this PR (updated for commit 52e60f6):

https://si-admin-staging--pr948-sandino-fundraiser-s-vdk50s37.web.app

(expires Mon, 09 Dec 2024 14:14:45 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: b7b0969384059dce6ea8fad1ee1d1737e54e6676

@ssandino ssandino added the emails Transactional emails label Nov 29, 2024
@ssandino
Copy link
Member Author

ssandino commented Dec 2, 2024

Email start of campaign: Template ID: d-a03378d2719a4e38b6c21af18be132c4
Email end of campaign: Template ID: d-bfba4830c59846f9a5443b880eb7b512
Thank you email for contributors: Template ID: d-00652bea6c6c488b92cfd0f0cabc2f4f

@andrashee of course, you should name the variables to your liking—I’ve marked them with { }. Depending on whether someone sets a goal, a conditional rule might be needed. This is a simple version of the email to start with, and we can always make it more advanced later.

Visualized:
emails

@ssandino ssandino marked this pull request as ready for review December 2, 2024 14:26
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (6)
shared/emails/transactional/fundraiser-end-en.html (3)

199-205: Consider responsive image dimensions

The logo image has fixed dimensions which might not scale well on all devices.

-width="250"
-style="display: block; width: 250px; max-width: 250px; min-width: 250px"
+width="100%"
+style="display: block; width: 100%; max-width: 250px"

450-455: Update hardcoded LinkedIn profile URL

The signature section contains a hardcoded LinkedIn profile URL. Consider making this configurable.

-<a href="https://www.linkedin.com/in/aurélie-schmiedlin/"
+<a href="{sender_linkedin_url}"

122-177: Optimize preheader length

The preheader section contains excessive whitespace characters. Consider reducing them while maintaining email client compatibility.

-<!-- Current long sequence of whitespace characters -->
+<!-- Reduce to approximately 50-100 characters for better compatibility -->
shared/emails/transactional/fundraiser-thanks-contributor-en.html (1)

359-378: Improve video thumbnail accessibility

The video thumbnail uses a GIF format which may be large and doesn't provide playback controls.

Consider:

  1. Using a static image with a play button overlay
  2. Adding aria-label for better screen reader support
  3. Including video duration in the alt text
 <img
     class="max-width"
     border="0"
+    aria-label="Click to watch testimonial video from Social Income recipients"
-    alt="Video of the impact of Social Income"
+    alt="Video testimonial about Social Income's impact (2:30)"
shared/emails/transactional/fundraiser-start-en.html (2)

535-535: Consider making support email configurable

The support email address is hardcoded. Consider making it a dynamic placeholder for easier maintenance.

- <a href="mailto:[email protected]"
+ <a href="mailto:{support_email}"

237-238: Consider using relative units for font sizes

Using pixel units for font sizes may impact accessibility. Consider using relative units (rem/em) for better scalability.

- font-size: 42px;
- line-height: 52px;
+ font-size: 2.625rem;
+ line-height: 3.25rem;

- font-size: 22px;
+ font-size: 1.375rem;

Also applies to: 371-372

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 975f92f and 52e60f6.

📒 Files selected for processing (3)
  • shared/emails/transactional/fundraiser-end-en.html (1 hunks)
  • shared/emails/transactional/fundraiser-start-en.html (1 hunks)
  • shared/emails/transactional/fundraiser-thanks-contributor-en.html (1 hunks)
🔇 Additional comments (5)
shared/emails/transactional/fundraiser-end-en.html (2)

606-618: Verify unsubscribe functionality

The template uses SendGrid's unsubscribe variables. Ensure these are properly configured in SendGrid:

  • {{{unsubscribe_preferences}}}
  • {{{unsubscribe}}}
✅ Verification successful

Unsubscribe functionality is consistently implemented

The search results show that both {{{unsubscribe_preferences}}} and {{{unsubscribe}}} variables are consistently used across all email templates in the repository, including newsletters, transactional emails, and base templates. The implementation follows the same pattern with proper target and rel attributes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for consistent unsubscribe implementation across templates
rg -A 1 '\{\{\{unsubscribe'

Length of output: 12206


244-244: Verify template variable handling

The template uses several dynamic variables that need proper fallback handling:

  • {Goal Reached! 🎉.} (line 244)
  • {amount} {currency} (line 277)
  • {fundraiser title} (line 323)

Also applies to: 277-277, 323-325

✅ Verification successful

Template variables are consistently used across email templates

The verification shows that the template variables are properly used across email templates with consistent patterns:

  • {amount} and {currency} are used together for monetary values
  • {fundraiser title} is used for campaign names
  • {Goal Reached! 🎉.} is a conditional message

The variables follow SendGrid's templating syntax and have proper fallback handling through the template engine.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for consistent variable usage across email templates
rg -A 1 '{amount}|{currency}|{fundraiser title}|{Goal Reached!'

Length of output: 194


Script:

#!/bin/bash
# Search for template variables in email templates, escaping special characters
rg -A 1 "\{amount\}|\{currency\}|\{fundraiser title\}|\{Goal Reached"

# Also search specifically in the fundraiser-end template
cat shared/emails/transactional/fundraiser-end-en.html

Length of output: 29724

shared/emails/transactional/fundraiser-thanks-contributor-en.html (2)

584-596: Verify unsubscribe functionality

The template uses SendGrid's unsubscribe variables. Ensure these are properly configured in SendGrid.


11-21: Verify font loading reliability

The custom font 'Unica77' is loaded from an S3 bucket. Ensure there's a fallback system font stack in case the custom font fails to load.

Add fallback fonts:

-font-family: 'Unica77';
+font-family: 'Unica77', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
✅ Verification successful

Let me check if there are any existing fallback fonts defined in the codebase.


Font loading is properly configured with fallbacks

The custom font 'Unica77' is already configured with appropriate system font fallbacks across email templates:

  • Font files are accessible via HTTPS
  • All font-family declarations include fallback fonts: 'Unica77', Helvetica, Arial, sans-serif
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the font URLs are accessible
curl -I https://si-fonts.s3.eu-west-1.amazonaws.com/Unica77LLWeb-Regular.woff2
curl -I https://si-fonts.s3.eu-west-1.amazonaws.com/Unica77LLSub-Medium.woff2

Length of output: 1716


Script:

#!/bin/bash
# Search for font-family declarations in HTML files
rg -t html "font-family" -B1 -A1

Length of output: 69087

shared/emails/transactional/fundraiser-start-en.html (1)

458-458: Ensure URL slug sanitization

The share URL uses a dynamic {slug} placeholder. Ensure proper sanitization to prevent URL injection.

✅ Verification successful

URL slug validation is properly implemented

The codebase has a validation pattern that ensures slugs follow a safe format using the regex /^[a-z0-9]+(?:-[a-z0-9]+)*$/, which only allows lowercase alphanumeric characters and hyphens, preventing URL injection.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for URL slug sanitization in the codebase
rg -A 5 "sanitize.*slug|slug.*sanitize" 

Length of output: 41


Script:

#!/bin/bash
# Search for slug-related code patterns
ast-grep --pattern 'slug = $_'

# Search for URL generation or validation patterns
rg -A 5 "createUrl|validateUrl|generateUrl|slugify"

# Search for campaign-related URL handling
rg -A 5 "campaign.*url|url.*campaign"

Length of output: 126


Script:

#!/bin/bash
# Look for email template handling or campaign URL generation
rg -A 5 "template.*campaign|campaign.*template"

# Search for any slug handling in JavaScript/TypeScript files
fd -e js -e ts --exec rg -A 5 "slug" {}

# Look for campaign-related functions or classes
ast-grep --pattern 'function $_(campaign|Campaign)'

Length of output: 833

Comment on lines +323 to +324
<a href="https://google.ch" target="_blank" rel="noopener noreferrer">{fundraiser title}</a> you
<span style="color: #01579b">convinced {total-contributors} to donate {amount} {currency}</span> for
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix hardcoded link in fundraiser title

The fundraiser title link points to "https://google.ch" which appears to be a placeholder.

-<a href="https://google.ch" target="_blank" rel="noopener noreferrer">{fundraiser title}</a>
+<a href="{fundraiser_url}" target="_blank" rel="noopener noreferrer">{fundraiser title}</a>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<a href="https://google.ch" target="_blank" rel="noopener noreferrer">{fundraiser title}</a> you
<span style="color: #01579b">convinced {total-contributors} to donate {amount} {currency}</span> for
<a href="{fundraiser_url}" target="_blank" rel="noopener noreferrer">{fundraiser title}</a> you
<span style="color: #01579b">convinced {total-contributors} to donate {amount} {currency}</span> for

opacity: 0;
"
>
Your donation for “{fundraiser title}” organized by {fundraiser author}. It has been received successfully. Thank
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix template variable syntax

The preheader text contains unescaped quotes around the template variable.

-Your donation for "{fundraiser title}" organized by {fundraiser author}. It has been received successfully. Thank
+Your donation for {fundraiser title} organized by {fundraiser author}. It has been received successfully. Thank
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Your donation for {fundraiser title} organized by {fundraiser author}. It has been received successfully. Thank
Your donation for {fundraiser title} organized by {fundraiser author}. It has been received successfully. Thank

Comment on lines +311 to +312
<a href="https://google.ch" target="_blank" rel="noopener noreferrer">{fundraiser title}</a> by
<span style="color: #01579b">{fundraiser author}</span> and helps bring hope to many people living in
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security: Verify URL construction

The Google URL is hardcoded. This should likely be a dynamic link to the fundraiser page.

-<a href="https://google.ch" target="_blank" rel="noopener noreferrer">{fundraiser title}</a> by
+<a href="{fundraiser_url}" target="_blank" rel="noopener noreferrer">{fundraiser title}</a> by
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<a href="https://google.ch" target="_blank" rel="noopener noreferrer">{fundraiser title}</a> by
<span style="color: #01579b">{fundraiser author}</span> and helps bring hope to many people living in
<a href="{fundraiser_url}" target="_blank" rel="noopener noreferrer">{fundraiser title}</a> by
<span style="color: #01579b">{fundraiser author}</span> and helps bring hope to many people living in

alt="Video of the impact of Social Income"
data-proportionally-constrained="true"
data-responsive="true"
src="https://cdn.mcauto-images-production.sendgrid.net/044784a789c4863a/a8cfc455-8d53-439c-9905-1887176cee83/600x338.gif"
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider optimizing the video preview GIF

Large GIF files can significantly increase email size. Consider using a static image with a play button overlay instead.

- src="https://cdn.mcauto-images-production.sendgrid.net/044784a789c4863a/a8cfc455-8d53-439c-9905-1887176cee83/600x338.gif"
+ src="https://cdn.mcauto-images-production.sendgrid.net/[static-image-path].jpg"

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +251 to +320
<tr>
<td align="center" bgcolor="#f9f8f3" style="padding: 10px">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px">
<tr>
<td
bgcolor="#FAC800"
style="
background-color: #f0e08c;
padding: 12px 15px;
border-radius: 10px;
font-family: 'Unica77', Helvetica, Arial, sans-serif;
font-size: 24px;
line-height: 32px;
text-align: center;
"
>
<p
class="feature"
style="
margin: 0;
font-family: 'Unica77', Helvetica, Arial, sans-serif;
font-weight: 400;
font-size: 18px;
line-height: 26px;
color: #59481c;
"
>
{n} days left to fundraise
</p>
</td>
</tr>
</table>
</td>
</tr>
<!-- end banner -->
<!-- start banner without goal -->
<tr>
<td align="center" bgcolor="#f9f8f3" style="padding: 10px">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px">
<tr>
<td
bgcolor="#FAC800"
style="
background-color: #f0e08c;
padding: 12px 15px;
border-radius: 10px;
font-family: 'Unica77', Helvetica, Arial, sans-serif;
font-size: 24px;
line-height: 32px;
text-align: center;
"
>
<p
class="feature"
style="
margin: 0;
font-family: 'Unica77', Helvetica, Arial, sans-serif;
font-weight: 400;
font-size: 18px;
line-height: 26px;
color: #59481c;
"
>
{n} days left to fundraise towards your goal of {currency} {amount}
</p>
</td>
</tr>
</table>
</td>
</tr>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Implement conditional rendering for banner sections

The template contains two identical banner sections - one with goal amount and one without. These should be conditionally rendered server-side to avoid potential display issues.

Implement server-side conditional rendering:

- <!-- start banner with goal -->
- <tr>
-   <td align="center" bgcolor="#f9f8f3" style="padding: 10px">
-     ...
-   </td>
- </tr>
- <!-- end banner -->
- <!-- start banner without goal -->
- <tr>
-   <td align="center" bgcolor="#f9f8f3" style="padding: 10px">
-     ...
-   </td>
- </tr>
+ {{#if hasGoal}}
+   <!-- start banner with goal -->
+   <tr>
+     <td align="center" bgcolor="#f9f8f3" style="padding: 10px">
+       ...
+     </td>
+   </tr>
+ {{else}}
+   <!-- start banner without goal -->
+   <tr>
+     <td align="center" bgcolor="#f9f8f3" style="padding: 10px">
+       ...
+     </td>
+   </tr>
+ {{/if}}

Committable suggestion skipped: line range outside the PR's diff.

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

Successfully merging this pull request may close these issues.

2 participants