feat: add sendInteractions XRPC procedure for usage telemetry#33
Merged
maxine-at-forecast merged 2 commits intodevelopfrom Feb 26, 2026
Merged
Conversation
Add science.alt.dataset.sendInteractions POST endpoint that accepts batches of download, citation, and derivative interaction events. Validates AT-URIs, interaction types, and optional ISO 8601 timestamps, then fires analytics events via the existing fire-and-forget infrastructure. Also extends getEntryStats to surface per-entry interaction counts (downloads, citations, derivatives) alongside existing view/search metrics. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ord counts, use UPSERT_FNS dispatch - row_to_label() and row_to_lens() now include `did` field, consistent with row_to_entry() and row_to_schema() - Extract _fetch_record_counts() helper so query_record_counts() and query_analytics_summary() share the same implementation - Replace if/elif upsert chain in processor.py with db.UPSERT_FNS dict lookup; update test_ingestion.py to patch the dict directly - Use parse_at_uri() in frontend dataset_detail() instead of manual string splitting - Remove duplicate config fixture from test_analytics.py (conftest provides it) - Add sendInteractions edge case tests: missing key, non-dict item, boundary at max batch size Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4 tasks
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.
Summary
science.alt.dataset.sendInteractionsPOST endpoint — fire-and-forget batch reporting ofdownload,citation, andderivativeinteraction events on datasetsfire_analytics_event()infrastructuregetEntryStatsto surface per-entry interaction counts (downloads, citations, derivatives)Adversarial review (round 3):
row_to_label()/row_to_lens()missingdidfield (inconsistent with entry/schema serializers)processor.pywithUPSERT_FNSdict lookupquery_record_counts()andquery_analytics_summary()parse_at_uri()in frontenddataset_detail()instead of manual string splittingTest plan
uv run pytest— 157 tests passuv run ruff check src/ tests/— cleanPOST /xrpc/science.alt.dataset.sendInteractionsaccepts valid batches and rejects invalid inputGET /xrpc/science.alt.dataset.getEntryStatsreturns newdownloads/citations/derivativesfields🤖 Generated with Claude Code