ENS Holiday Awards Date Range Environment Variables#1279
Conversation
🦋 Changeset detectedLatest 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
lightwalker-eth
left a comment
There was a problem hiding this comment.
@Goader Hey nice work here 💪 Shared some small feedback. Please take the lead to merge this as soon as you're ready 👍
docker-compose.yml
Outdated
| # 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 |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
For debugging purposes, perhaps good to include the start and end timestamps in the log messages. wdyt?
tk-o
left a comment
There was a problem hiding this comment.
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.
| 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); | ||
| }); |
There was a problem hiding this comment.
Feel free to use ISO 8601 format for defining datetime values in configuration. You can use an existing schema to parse such format:
| 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)); |
| ensHolidayAwardsStart: DateStringToUnixTimestampSchema.default(ENS_HOLIDAY_AWARDS_START_DATE), | ||
| ensHolidayAwardsEnd: DateStringToUnixTimestampSchema.default(ENS_HOLIDAY_AWARDS_END_DATE), |
There was a problem hiding this comment.
@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 😅
| @@ -0,0 +1,6 @@ | |||
| --- | |||
| "@ensnode/ensapi": minor | |||
There was a problem hiding this comment.
| "@ensnode/ensapi": minor | |
| "ensapi": minor |
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:
ENS_HOLIDAY_AWARDS_STARTandENS_HOLIDAY_AWARDS_ENDto ENSApi@namehash/ens-referralspackage ("Dec 1, 2025 00:00:00 UTC" and "Dec 31, 2025 23:59:59 UTC")invariant_ensHolidayAwardsEndAfterStartcheck to ensure end date is after or equal to start dateDateStringToUnixTimestampSchemato convert date strings to Unix timestamps with validationaggregatedReferrerSnapshotCacheMiddlewareto use configurable dates instead of hardcoded constantsSDK additions:
EnsHolidayAwardsEnvironmentinterface for environment type definitions