Skip to content

feat: monthly email digest#10621

Merged
CarinaWolli merged 24 commits intocalcom:mainfrom
Pradumn27:feat/monthly-email-digest
Sep 19, 2023
Merged

feat: monthly email digest#10621
CarinaWolli merged 24 commits intocalcom:mainfrom
Pradumn27:feat/monthly-email-digest

Conversation

@Pradumn27
Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #10026
/claim #10026

Screen.Recording.2023-08-06.at.10.06.12.PM.mov
Screenshot 2023-08-06 at 10 19 09 PM

Technical Details

  • Have used a cron job which will run every day via the GitHub workflows
  • The cron job will check for which teams have completed another month today and will send an email if it has the required amount of data mainly if there were bookings for this team this month.

Type of change

  • New feature (non-breaking change which adds functionality)

How should this be tested?

  • Can test this email by visiting the link localhost:3000/api/cron/monthlyDigestEmail on your local setup
  • Make sure that you have teams that have completed 30 days, and you'll receive the email only if you are the owner of the team
  • For email testing purposes can workaround it by removing the 30 days condition in apps/web/pages/api/cron/monthlyDigestEmail

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

@vercel
Copy link
Copy Markdown

vercel bot commented Aug 6, 2023

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

Name Status Preview Comments Updated (UTC)
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 19, 2023 2:12pm

@vercel
Copy link
Copy Markdown

vercel bot commented Aug 6, 2023

@Pradumn27 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 6, 2023

Thank you for following the naming conventions! 🙏

@github-actions github-actions bot added emails area: emails, cancellation email, reschedule email, inbox, spam folder, not getting email Low priority Created by Linear-GitHub Sync ✨ feature New feature or request 💎 Bounty A bounty on Algora.io labels Aug 6, 2023
@Pradumn27 Pradumn27 changed the title Feat/monthly email digest feat: monthly email digest Aug 6, 2023
Comment on lines +39 to +42
createdAt: {
// created before last 30days
lte: date30DaysAgo,
},
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We're querying all the teams which were created more than 30 days ago

Comment on lines +59 to +72
const createdAt = team.createdAt;

// Setting both times to midnight as we will only compare the days
date30DaysAgo.setHours(0, 0, 0, 0);
createdAt.setHours(0, 0, 0, 0);

// Calculate the difference in milliseconds between createdAt and date30DaysAgo
const timeDifference = date30DaysAgo.getTime() - createdAt.getTime();

// Calculate the difference in days
const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));

// If the daysDifference is a multiple of 30
if (daysDifference % 30 === 0) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Our goal is to trigger this email every 30 days for every team, so here we're first setting the time for the createdAt date so that there are no conflicts with time and we only compare days, next we're calculating the difference between the createdAt date and the date 30 days ago if the difference is a multiple of 30 that means another month has passed for that team and thus we can trigger an email.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we do last day of a month instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just to understand you clearly you're suggesting that we trigger this email at the end of every month for every team and the team receives the updates for only that particular month right?

So in the case of a team created just 10 days before the end of a month will we provide them the updates or these updates would just be for teams created at least before or at the first of the month?

Can be done just need to be sure about the logical requirements.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 6, 2023

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@CarinaWolli CarinaWolli added the insights area: insights, analytics label Aug 9, 2023
@CarinaWolli
Copy link
Copy Markdown
Member

@PeerRich Who should this email all be sent to? And I think with that implementation it would be enabled by default and can't be disabled, what do you think about that?

@Pradumn27
Copy link
Copy Markdown
Contributor Author

any updates here @CarinaWolli @PeerRich ?

@CarinaWolli
Copy link
Copy Markdown
Member

@ciaranha is the design of the email ok? Should this be enabled by default? Should there be an option to disable the emails? Who should receive these emails, all admins/owners?

I tagged you in #10627 as well but this PR is further than #10627

@ciaranha
Copy link
Copy Markdown
Member

@ciaranha is the design of the email ok? Should this be enabled by default? Should there be an option to disable the emails? Who should receive these emails, all admins/owners?

I tagged you in #10627 as well but this PR is further than #10627

I'll attach a few suggested changes for design with a Figma shortly. Send to all admins and Owners yes. I would say turn on by default and we can have an option to turn off. Will also share in Figma where we should put that.

@ciaranha
Copy link
Copy Markdown
Member

ciaranha commented Aug 23, 2023

No objections to the circles at the top (although since they're always full not sure they offer much value) but we can left align the text, remove some copy and use fewer font sizes:

CleanShot 2023-08-23 at 21 12 40@2x

https://www.figma.com/file/xk4HOxtSI82J0F7enMxeak/Live?type=design&node-id=6645%3A10642&mode=design&t=wdff6CiG2FfyI986-1

In terms of turning it off, each person should probably have the ability to turn it off for themselves. This isn't ideal but the best place I can think of for now without having to put it under a team and let people turn it on/off for all owners/admins. The downside is of course it would turn it on/off for all teams, not just one
CleanShot 2023-08-24 at 09 31 38@2x

@Pradumn27
Copy link
Copy Markdown
Contributor Author

Thanks for the review @PeerRich , have corrected the font and also updated the configuration such that now the email will be triggered on the last day of every month and every team created on or before the first of this month will get the monthly digest. Here's a screenshot with the corrected font.

Screenshot 2023-09-07 at 6 52 01 PM

@Pradumn27
Copy link
Copy Markdown
Contributor Author

any updates here @PeerRich @CarinaWolli

Copy link
Copy Markdown
Member

@CarinaWolli CarinaWolli left a comment

Choose a reason for hiding this comment

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

Everything looks good to me, except the font still needs to be fixed in some places.

Can you make sure we use Cal Sans everywhere, that's how it looks for me right now:
Screenshot 2023-09-19 at 13 51 37

@Pradumn27
Copy link
Copy Markdown
Contributor Author

Thanks for the review @CarinaWolli have fixed the font, and now it's cal sans everywhere, here's how it looks in the mail

Screenshot 2023-09-19 at 5 57 47 PM

@CarinaWolli
Copy link
Copy Markdown
Member

@Pradumn27 Can you also make sure everything looks as in the Figma design?

Some issue I see is bold fonts where it shouldn't and the line should be gray

@Pradumn27
Copy link
Copy Markdown
Contributor Author

Resolved @CarinaWolli

Screenshot 2023-09-19 at 7 38 26 PM

Copy link
Copy Markdown
Member

@CarinaWolli CarinaWolli left a comment

Choose a reason for hiding this comment

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

Everything looks good now! Thank you for responding that quickly to my feedback 🙏

@CarinaWolli CarinaWolli merged commit 786c1c2 into calcom:main Sep 19, 2023
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a side note here @Pradumn27 @CarinaWolli we shouldn't allow nameless migrations for the next time 🙏🏽

@PeerRich PeerRich mentioned this pull request Sep 23, 2023
6 tasks
ashwintelmore pushed a commit to ashwintelmore/cal.com that referenced this pull request Sep 24, 2023
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
aar2dee2 pushed a commit to rkreddy99/cal.com that referenced this pull request Sep 27, 2023
Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peer@cal.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💎 Bounty A bounty on Algora.io emails area: emails, cancellation email, reschedule email, inbox, spam folder, not getting email ✨ feature New feature or request insights area: insights, analytics Low priority Created by Linear-GitHub Sync ❗️ migrations contains migration files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-2127] feature: 30 day email digest

6 participants