Repository navigation
fix: Support hour ranges, datetime windows, and hourly timeseries buckets - #69
Merged
Merged
Conversation
…kets Plausible's Stats API v2 accepts only "24h" as an hour shorthand, but the date_range schema let any "Nh" through, so "1h" reached Plausible and came back as a 400. The server now sends every "Nh" as the equivalent rolling datetime window ending now. date_range also accepts two ISO 8601 datetimes with offsets for sub-day windows, and get_timeseries accepts granularity "hour" (time:hour). Minute buckets are internal to Plausible and stay unavailable. Hourly buckets make long series reach Plausible's 10,000-row limit, which it applies without a flag. get_timeseries now fails with an actionable error at that limit instead of returning a series that ends early. Fixes PLAUSIBLE-MCP-Q Co-authored-by: Claude <claude@anthropic.com>
sergical
force-pushed
the
fix/sub-day-date-ranges
branch
from
October 26, 2026 18:50
165bd4c to
bab4cf7
Compare
Hourly buckets make long series reach the limit, which Plausible applies without a flag. Return an actionable error instead of a series that ends early. PLAUSIBLE_MAX_ROWS moves to plausible.ts so get_breakdown shares it. Co-authored-by: Claude <claude@anthropic.com>
sergical
changed the base branch from
feat/agent-friendly-errors-and-paging
to
main
October 26, 2026 18:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #66. Merge #65 and #66 first; GitHub then retargets this PR to
main.Problem
User feedback PLAUSIBLE-MCP-Q (from our own deployment, release 0.9.0):
get_breakdownwithdate_range: "1h"returnedPlausible API returned 400: #/date_range: Invalid date range "1h". The user wanted the custom events from the last ~10 minutes, andget_timeserieshad no sub-day buckets.Plausible's query schema accepts
"24h"as its only hour shorthand. OurdateRangeSchemaaccepted any\d+h, so the error reached Plausible instead of failing at our schema. The same schema also accepts two things we did not expose: a pair of ISO 8601 datetimes (date_time_range) and thetime:hourdimension.Changes
Nhworks for any N.encodeDateRangesends"Nh"as[now - N hours, now]in UTC, to second precision. This includes"24h", so all hour ranges follow one rule.date_rangeaccepts"<datetime>,<datetime>", where each datetime isYYYY-MM-DDTHH:MM:SSwithZor±HH:MM. A pair that mixes a date and a datetime is rejected, as Plausible also rejects it.get_timeseriesacceptsgranularity: "hour", which maps totime:hour.get_timeseriesnow fails at that limit and tells the caller to narrowdate_rangeor use a coarser granularity.PLAUSIBLE_MAX_ROWSmoves toplausible.ts, soget_breakdownuses the same constant.SERVER_INSTRUCTIONSand the field descriptions show the new forms. They also say that minute buckets are not available, becausetime:minuteis internal to Plausible.Tests
dateRangeSchemaaccepts and rejects each form."1h"as a rolling window under fake timers.get_timeseriesmaps"hour"totime:hour, and rejects a 10,000-row result.pnpm typecheck,pnpm buildandpnpm test(288 tests, on top of the updated #66) pass locally.Created with Claude Code