Skip to content

feat: add sendInteractions XRPC procedure for usage telemetry#33

Merged
maxine-at-forecast merged 2 commits intodevelopfrom
feature/usage-telemetry-sendinteractions-endpoint
Feb 26, 2026
Merged

feat: add sendInteractions XRPC procedure for usage telemetry#33
maxine-at-forecast merged 2 commits intodevelopfrom
feature/usage-telemetry-sendinteractions-endpoint

Conversation

@maxine-at-forecast
Copy link
Copy Markdown
Contributor

Summary

  • Add science.alt.dataset.sendInteractions POST endpoint — fire-and-forget batch reporting of download, citation, and derivative interaction events on datasets
  • Validate AT-URIs, interaction types, optional ISO 8601 timestamps; cap batch at 100
  • Record events via existing fire_analytics_event() infrastructure
  • Extend getEntryStats to surface per-entry interaction counts (downloads, citations, derivatives)

Adversarial review (round 3):

  • Fix row_to_label() / row_to_lens() missing did field (inconsistent with entry/schema serializers)
  • Replace if/elif upsert dispatch in processor.py with UPSERT_FNS dict lookup
  • Deduplicate record count logic between query_record_counts() and query_analytics_summary()
  • Use parse_at_uri() in frontend dataset_detail() instead of manual string splitting
  • Add 14 new tests (11 sendInteractions + 3 edge cases), remove duplicate fixture

Test plan

  • uv run pytest — 157 tests pass
  • uv run ruff check src/ tests/ — clean
  • Verify POST /xrpc/science.alt.dataset.sendInteractions accepts valid batches and rejects invalid input
  • Verify GET /xrpc/science.alt.dataset.getEntryStats returns new downloads/citations/derivatives fields

🤖 Generated with Claude Code

maxinelevesque and others added 2 commits February 26, 2026 00:53
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>
@maxine-at-forecast maxine-at-forecast merged commit a923e1e into develop Feb 26, 2026
9 checks passed
@maxine-at-forecast maxine-at-forecast deleted the feature/usage-telemetry-sendinteractions-endpoint branch February 26, 2026 09:56
@maxine-at-forecast maxine-at-forecast linked an issue Feb 26, 2026 that may be closed by this pull request
4 tasks
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.

Usage telemetry: sendInteractions endpoint

2 participants