Add Kafka analytics event ingestion endpoint#10
Draft
IamJasonBian wants to merge 6 commits into
Draft
Conversation
Adds POST /api/analytics that accepts single or batched event payloads, enriches them with server-side timestamps and source IP, and produces them to an Upstash Kafka topic via the Upstash REST API. Requires UPSTASH_KAFKA_REST_URL, UPSTASH_KAFKA_REST_USERNAME, UPSTASH_KAFKA_REST_PASSWORD env vars; KAFKA_TOPIC defaults to "analytics". https://claude.ai/code/session_01CXxC65zr3ZHxDuqTkxm4vH
✅ Deploy Preview for route-runtime-service ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
ANALYTICS_BACKEND env var selects "blob" (default), "kafka", or "both".
Blob backend uses Netlify Blobs with key layout {event}/{date}/{unix_ms}
enabling prefix filtering by event type and date partition. New GET
/api/analytics endpoint supports ?event, ?since, ?date, ?limit queries
against the blob store. Kafka backend unchanged (Upstash REST).
https://claude.ai/code/session_01CXxC65zr3ZHxDuqTkxm4vH
- Add unique suffix to blob keys so same-named events in a batch (or same
millisecond) no longer silently overwrite each other; published count
now matches blobs written.
- Validate event names against [A-Za-z0-9._-]{1,128}; reject slashes which
corrupted the {event}/{date}/{ts} key layout and made events unqueryable.
- Update query timestamp parsing/sort for the new {ts}-{uniq} segment.
https://claude.ai/code/session_01CXxC65zr3ZHxDuqTkxm4vH
Replace UPSTASH_KAFKA_REST_{URL,USERNAME,PASSWORD} with generic
KAFKA_REST_{URL,USERNAME,PASSWORD} so any REST-capable broker
(Upstash, Confluent, Redpanda, etc.) works without code changes.
https://claude.ai/code/session_01CXxC65zr3ZHxDuqTkxm4vH
- Add global security: [] (public by default) + BearerAuth securityScheme,
fixing all 11 security-defined errors across every operation
- Add security: [{BearerAuth: []}] on PUT /mcp-context (the only authenticated op)
- Add license + url to info block (info-license-strict warning)
- Add 405 responses to GET /health and GET /snapshots (operation-4xx-response warnings)
- Document POST/GET /api/analytics with request/response schemas
https://claude.ai/code/session_01CXxC65zr3ZHxDuqTkxm4vH
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.
$(cat <<'EOF'
Summary
POST /api/analyticsNetlify Function that accepts single or batched event payloads/api/analytics→/.netlify/functions/analyticsinnetlify.tomlConfiguration
Set these Netlify env vars before deploying:
UPSTASH_KAFKA_REST_URLhttps://<id>.upstash.ioUPSTASH_KAFKA_REST_USERNAMEUPSTASH_KAFKA_REST_PASSWORDKAFKA_TOPICanalyticsUsage
Test plan
{"ok":true,"published":1}publishedcounteventfield returns 400https://claude.ai/code/session_01CXxC65zr3ZHxDuqTkxm4vH
EOF
)
Generated by Claude Code