Skip to content

Conversation

@cemms1
Copy link
Contributor

@cemms1 cemms1 commented Dec 24, 2025

What does this change?

Adds a scheduled lambda for the new AB testing framework to notify teams of upcoming AB test expiry dates or to let them know that tests have already expired.

  • The lambda is scheduled to run at 5am every weekday for PROD but not for CODE, though in both environments it can be triggered manually
  • It fetches active AB tests (those switched "ON" in the code) and filters by those within 2 days of expiry or which have already expired
  • It then gets a unique list of AB test owners for those tests and creates three lists of tests for each owner:
    • Expired tests
    • Tests expiring today at midnight
    • Tests expiring tomorrow at midnight
  • For each owner of an AB test close to expiry, it sends an email using SES with a breakdown of their expiring tests in tabular format

Example email format

image

Tested in CODE

Why?

We want to make sure expired tests are turned off and/or removed from the codebase if no longer active. Notifying teams of this helps to keep them aware of this.

How to test

Running locally

  • Fetch AWS credentials for the frontend account
  • Add a fake test to /ab-testing/config/abTests.ts that either has an expiry less than two days in the future or an expiry in the past. Ensure your email is marked as an owner of that test
  • Run the lambda locally (run node src/run.ts from the notification-lambda directory)
  • Check that you have received an email for the expiring test

Running in CODE

  • Add a fake test to /ab-testing/config/abTests.ts that either has an expiry less than two days in the future or an expiry in the past. Ensure your email is marked as an owner of that test
  • Deploy the latest build of this branch to CODE via RiffRaff (make sure no one else is using the CODE environment at the same time by flagging this in the Semaphore chat)
  • Run the lambda from the AWS console or by using the AWS CLI
  • Check that you have received an email for the expiring test

@cemms1 cemms1 added 🥒WiP Work in Progress feature Departmental tracking: work on a new feature labels Dec 24, 2025
@cemms1 cemms1 force-pushed the cemms1/alert-for-ab-test-expiry branch from 09333a5 to b78385a Compare December 29, 2025 15:14
@github-actions
Copy link

github-actions bot commented Dec 29, 2025

@github-actions
Copy link

github-actions bot commented Dec 29, 2025

@cemms1 cemms1 force-pushed the cemms1/alert-for-ab-test-expiry branch 4 times, most recently from 90f2421 to c50a223 Compare January 5, 2026 12:10
@cemms1 cemms1 removed the 🥒WiP Work in Progress label Jan 5, 2026
@cemms1 cemms1 changed the title [WIP] Add scheduled lambda for notifying teams of AB testing expiry dates Add scheduled lambda for notifying teams of AB testing expiry dates Jan 5, 2026
@cemms1 cemms1 changed the title Add scheduled lambda for notifying teams of AB testing expiry dates Notify teams of AB tests close to expiry Jan 5, 2026
@cemms1 cemms1 force-pushed the cemms1/alert-for-ab-test-expiry branch 2 times, most recently from 338e176 to 3284aa3 Compare January 5, 2026 16:25
@cemms1 cemms1 marked this pull request as ready for review January 5, 2026 16:25
@cemms1 cemms1 requested review from a team as code owners January 5, 2026 16:25
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@cemms1 cemms1 force-pushed the cemms1/alert-for-ab-test-expiry branch from 3284aa3 to 0f44f6d Compare January 5, 2026 17:34
Copy link
Contributor

@deedeeh deedeeh left a comment

Choose a reason for hiding this comment

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

Awesome work @cemms1 👏🏼👏🏼 You've covered everything from the main functionality to testing which I particularly love about this PR ✨

It took me a bit of time to understand few things but I just had to look up for and I am glad I did!

I left just a comment just to understand your thoughts on the implementation.

@cemms1 cemms1 force-pushed the cemms1/alert-for-ab-test-expiry branch from 0f44f6d to 77c4e5f Compare January 6, 2026 11:43
@Jakeii
Copy link
Member

Jakeii commented Jan 6, 2026

This is great! Should we also notify someone else if the email failed to send to the test owner? Say if someone mistyped an email address?

@cemms1
Copy link
Contributor Author

cemms1 commented Jan 6, 2026

This is great! Should we also notify someone else if the email failed to send to the test owner? Say if someone mistyped an email address?

I did wonder that! I have set up an SNS topic for lambda failures but I haven't set up a subscription for anyone to be notified yet... Who do you think would be best to add to that?

@cemms1 cemms1 added the run_chromatic Runs chromatic when label is applied label Jan 6, 2026
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Jan 6, 2026
),
);
} catch (error) {
console.log(`Error sending email to ${recipient}`, error);
Copy link
Member

Choose a reason for hiding this comment

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

Will this catch prevent the SNS topic being notified of an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha, maybe not... I'll fix this in a follow up PR and test failures properly!

@Jakeii
Copy link
Member

Jakeii commented Jan 6, 2026

I was more thinking of a fallback email of the expired tests, perhaps to [email protected] like the expiring feature switches

But an SNS topic alert also makes sense!

@cemms1 cemms1 merged commit 6a64656 into main Jan 6, 2026
29 checks passed
@cemms1 cemms1 deleted the cemms1/alert-for-ab-test-expiry branch January 6, 2026 13:49
@gu-prout
Copy link

gu-prout bot commented Jan 6, 2026

Seen on PROD (merged by @cemms1 7 minutes and 36 seconds ago) Please check your changes!

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

Labels

ab-testing feature Departmental tracking: work on a new feature Seen-on-PROD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants