Skip to content

ENS Holiday Awards Date Range Environment Variables#1279

Merged
Goader merged 15 commits intomainfrom
feat/ensanalytics-date-range-env
Nov 19, 2025
Merged

ENS Holiday Awards Date Range Environment Variables#1279
Goader merged 15 commits intomainfrom
feat/ensanalytics-date-range-env

Conversation

@Goader
Copy link
Copy Markdown
Contributor

@Goader Goader commented Nov 18, 2025

closes: #1264

This PR introduces configurable date range environment variables for ENSAnalytics ENS Holiday Awards campaign, allowing the date range to be customized for testing purposes before the Dec 1st launch.

Changes:

  • Environment variables: Added ENS_HOLIDAY_AWARDS_START and ENS_HOLIDAY_AWARDS_END to ENSApi
  • Default values: If not set, defaults to hardcoded values from @namehash/ens-referrals package ("Dec 1, 2025 00:00:00 UTC" and "Dec 31, 2025 23:59:59 UTC")
  • Validation: Added invariant_ensHolidayAwardsEndAfterStart check to ensure end date is after or equal to start date
  • Date parsing: Implemented DateStringToUnixTimestampSchema to convert date strings to Unix timestamps with validation
  • Cache integration: Updated aggregatedReferrerSnapshotCacheMiddleware to use configurable dates instead of hardcoded constants

SDK additions:

  • EnsHolidayAwardsEnvironment interface for environment type definitions

@Goader Goader self-assigned this Nov 18, 2025
@Goader Goader requested a review from a team as a code owner November 18, 2025 23:18
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Nov 18, 2025

🦋 Changeset detected

Latest commit: 400ff96

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Nov 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
admin.ensnode.io Ready Ready Preview Comment Nov 19, 2025 2:30pm
ensnode.io Ready Ready Preview Comment Nov 19, 2025 2:30pm
ensrainbow.io Ready Ready Preview Comment Nov 19, 2025 2:30pm

Copy link
Copy Markdown
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@Goader Hey nice work here 💪 Shared some small feedback. Please take the lead to merge this as soon as you're ready 👍

# Override environment variables to point to docker instances
DATABASE_URL: postgresql://postgres:password@postgres:5432/postgres
ENSINDEXER_URL: http://ensindexer:42069
# Optional: Define ENSAnalytics date range for ENS Holiday Awards
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.

I think we can revert the updates to this file as these can be configured through the .env.local file

config.ensHolidayAwardsEnd,
subregistryId,
);
logger.info("Successfully built aggregated referrer snapshot");
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.

For debugging purposes, perhaps good to include the start and end timestamps in the log messages. wdyt?

Copy link
Copy Markdown
Contributor

@tk-o tk-o left a comment

Choose a reason for hiding this comment

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

Nice updates, thank you 🙃 I think we are pretty close here to be ready to ship. One change request is about the particular timestamp values we use for start date and end date of ENS Holiday Awards.

Comment on lines +54 to +72
const DateStringToUnixTimestampSchema = z
.string()
.refine(
(dateStr) => {
try {
const date = new Date(dateStr);
return !Number.isNaN(date.getTime());
} catch {
return false;
}
},
{
error: "Invalid date string. Expected a valid date format (e.g., 'Dec 1, 2025 00:00:00 UTC')",
},
)
.transform((dateStr) => {
const timestamp = getUnixTime(new Date(dateStr));
return makeUnixTimestampSchema().parse(timestamp);
});
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.

Feel free to use ISO 8601 format for defining datetime values in configuration. You can use an existing schema to parse such format:

Suggested change
const DateStringToUnixTimestampSchema = z
.string()
.refine(
(dateStr) => {
try {
const date = new Date(dateStr);
return !Number.isNaN(date.getTime());
} catch {
return false;
}
},
{
error: "Invalid date string. Expected a valid date format (e.g., 'Dec 1, 2025 00:00:00 UTC')",
},
)
.transform((dateStr) => {
const timestamp = getUnixTime(new Date(dateStr));
return makeUnixTimestampSchema().parse(timestamp);
});
// you can import `makeDatetimeSchema` from `@ensnode/ensnode-sdk/internal`
const DateStringToUnixTimestampSchema = z.coerce
.string()
.pipe(makeDatetimeSchema())
.transform((date) => getUnixTime(date));

Comment on lines +84 to +85
ensHolidayAwardsStart: DateStringToUnixTimestampSchema.default(ENS_HOLIDAY_AWARDS_START_DATE),
ensHolidayAwardsEnd: DateStringToUnixTimestampSchema.default(ENS_HOLIDAY_AWARDS_END_DATE),
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.

@Goader, I have suggested wrong int values for ENS_HOLIDAY_AWARDS_START_DATE and ENS_HOLIDAY_AWARDS_END_DATE during previous PR review, sorry about that. I think the ones suggested, for some reason are for year of 2024.

Please update these values to reflect correct unix timestamps. This time I'll skip on suggesting the values 😅

Copy link
Copy Markdown
Contributor

@tk-o tk-o left a comment

Choose a reason for hiding this comment

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

Great updates, go live 🚀

@Goader Goader merged commit 11b8372 into main Nov 19, 2025
10 checks passed
@Goader Goader deleted the feat/ensanalytics-date-range-env branch November 19, 2025 15:27
@@ -0,0 +1,6 @@
---
"@ensnode/ensapi": minor
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.

Suggested change
"@ensnode/ensapi": minor
"ensapi": minor

@github-actions github-actions bot mentioned this pull request Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENSAwards date range environment variables

3 participants