Repository navigation
feat(calls): call analytics and call record export (Client.calls) - #281
Conversation
Add Client.calls (team and project clients) covering the Platform call analytics routes at monorepo commit 4b755348 (branch t3code/calls-analytics): - stats() -> GET /platform/calls/stats (CallStats with groups and heatmap) - list() -> GET /platform/calls as CursorPage<CallRecord> - export() -> GET /platform/calls/export, one CSV or NDJSON page with the Polymorfa-Next-Cursor header as nextCursor - exportAll() walks export pages and drops repeated CSV header rows HttpTransport gains requestText() and keeps polymorfa-next-cursor in response metadata. Re-sync both contract snapshots to 4b755348, which also fixes the event-stream frame discriminator (streamProjectEvents fingerprint) and adds the bansafe.health_changed and bansafe.risk_changed webhook events, now typed.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (19)
Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour. 📝 WalkthroughWalkthroughThe TypeScript SDK now exposes ChangesCalls analytics resource
API contract snapshot reconciliation
Priority: ⚪ Not assessed Estimated code review effort: 4 (Complex) | ~45 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Client as Client.calls
participant Resource as PlatformCallsResource
participant Transport as HttpTransport
participant API as Calls API
Client->>Resource: exportAll(params)
Resource->>Transport: requestText for export page
Transport->>API: send export request
API-->>Transport: export body and next-cursor header
Transport-->>Resource: text response and metadata
Resource-->>Client: yield page body
Merge Risk: ⚪ Minimal · up to This adds a new SDK surface for call statistics, call-record listing, and CSV/NDJSON exports. It does not change existing API behavior. No concrete defects were found in validation, pagination, or the contract metadata updates. The change looks ready to merge once normal CI passes. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 8 files. (10 skipped: 10 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Comment |
…a1486 The stats 503 now has its own CallStatsTooSlow response instead of reusing PropagationPending, whose description was about stored settings. Repin the snapshots, source hashes, ledger and coverage gates to the branch head of polymorfa/polymorfa#234. Coverage is unchanged: 427 operations, 311 covered, 0 missing, 0 changed fingerprints.
|
@coderabbitai review |
|
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cdea6fa785
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| return value.toISOString(); | ||
| } | ||
| if (typeof value !== "string" || Number.isNaN(Date.parse(value))) { |
There was a problem hiding this comment.
Validate timestamp strings as ISO date-times
Date.parse accepts many strings that are not ISO 8601 date-times—for example, Node accepts "1" and date-only values such as "2026-09-01"—and the function then sends the original string unchanged. Consequently, since or until values that should raise PolymorfaConfigurationError instead reach an endpoint whose contract requires date-time and fail as an API validation error; validate the string syntax and calendar value strictly before returning it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 240ca82. String since/until values must now be RFC 3339 date-times with Z or an offset and a real calendar date. "1" and date-only values raise PolymorfaConfigurationError. Date values are unchanged.
Date.parse accepted strings such as "1" and date-only values, which the API then refused. since/until strings must now be full date-times with Z or an offset and a real calendar date; Date values are unchanged.
|
Codex review follow-up (240ca82):
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 240ca821c9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (body.length > 0) yield body; | ||
| if (data.nextCursor === null) return; | ||
| if (seen.has(data.nextCursor)) { |
There was a problem hiding this comment.
Check repeated cursors before yielding the page
When the export API repeats a cursor, this generator yields that repeated page before the seen check runs. A consumer that streams chunks directly to a file therefore writes duplicate records and only receives the error on its next iteration; move the repeated-cursor check ahead of the yield so the advertised protection prevents corrupt output.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c9598aa. exportAll now checks the next cursor against every cursor it has requested (including the starting cursor) before yielding the page, so a replayed page is never yielded. Tests cover both cases.
exportAll yielded a page whose next cursor had already been requested and only threw on the next iteration, so a consumer streaming to a file wrote the replayed records. The check now runs before the yield, and the starting cursor counts as already requested.
Preserve strict dates and repeated-cursor safeguards. BanSafe typed alignment remains dependent on SDK #282; its error-body and webhook catalog tests remain failing until integration.
# Conflicts: # CHANGELOG.md # contracts/README.md # packages/typescript/test/coverage.test.ts
# Conflicts: # CHANGELOG.md # README.md # contracts/README.md # packages/typescript/README.md # packages/typescript/src/client.ts # packages/typescript/test/coverage.test.ts
# Conflicts: # contracts/README.md # contracts/coverage.json # packages/typescript/test/coverage.test.ts
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ca84549e5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const ISO_DATE_TIME = | ||
| /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,9})?(?:Z|[+-](\d{2}):(\d{2}))$/; |
There was a problem hiding this comment.
Accept lowercase RFC 3339 separators
The Calls parameters are declared as OpenAPI date-time values, so valid RFC 3339 strings may use lowercase t and z; however, this case-sensitive regex rejects inputs such as 2026-09-01t00:00:00z with PolymorfaConfigurationError before sending the request. Make the separator and UTC designator matching case-insensitive while retaining the strict calendar validation.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34ff27b2c6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| day <= daysInMonth && | ||
| hour <= 23 && | ||
| minute <= 59 && | ||
| second <= 59 && |
There was a problem hiding this comment.
Accept valid RFC 3339 leap-second timestamps
When callers supply a timestamp at a declared leap second, such as 1990-12-31T23:59:60Z, this check rejects it before making the request even though RFC 3339 permits 60 for leap seconds and the Calls parameters are documented as RFC 3339/OpenAPI date-time values. Validate :60 against the RFC 3339 leap-second rules rather than rejecting it unconditionally.
Useful? React with 👍 / 👎.
|
The two current-head Codex suggestions about lowercase |
|
Merge gate on exact head |
Adds typed
Client.callsanalytics and call-record methods to@polymorfa/sdkfor team and project server clients withsessions:readauthority.calls.stats(params?)GET /platform/calls/statscalls.list(params?)GET /platform/callscalls.export(params?)GET /platform/calls/exportcalls.exportAll(params?)The client validates filters, pagination, time strings, and project scope before sending. Export reads text only when the successful response has the expected content type; HTML or missing/wrong content type fails safely. Repeated export cursors are rejected before yielding a duplicate page. The methods retain SDK error classes and response metadata.
Contract and verification
Messaging and Platform snapshots are byte-identical to authoritative, merged monorepo
devcommit9c876c16c60b74370d934e1275f23ef6096bee12.contracts/source.jsonmarks that source published. Current SDKdevat8ce8f7bis normally merged, including retention, Campaigns, and Functions. The strict ledger reports 456 operations: 345 covered, 111 excluded, 0 missing or changed. Calls analytics route objects are unchanged from the earlier API analytics merge. If monorepo #228 merges before this SDK PR, the shared error catalog and exact source snapshot must be refreshed before merging.Node 20 and 22 each pass all 1,142 tests across 107 files. Formatting, lint (no errors; two existing directive warnings), typecheck, coverage, Functions/name checks, workspace builds, and SDK package dry run pass. Live requests to a deployed API were not exercised. Fresh current-head CI and reviews are pending.
API, SDK, CLI, docs, feature, and Admin assessment
devat the exact source commit above; no handler or scope change is proposed here.sessions:read; this SDK change adds no flag, enrollment, entitlement, rollout, or deployment action.Summary by CodeRabbit