poc: analytics tracking#152
Draft
omnibs wants to merge 5 commits into
Draft
Conversation
Adds an opaque (Aeson.Value -> IO ()) callback to LogHandler, propagated by mkHandler to every child handler. rootTracingSpanIO gains a new parameter for the callback; nullHandler defaults to silentTrack. Re-exports silentTrack from Platform for callers. This is a breaking change to rootTracingSpanIO and mkHandler. See the design doc at NoRedInk/event-platform/docs/2026-05-07-haskell-analytics-tracking-design.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
trackEvent opens an analytics.track child span, attaches the JSON payload as span details, and invokes the LogHandler's analytics callback. The .Internal suffix signals do-not-import from product code; consumers should wrap this in a typed entry point. Bump to 0.7.0.0 (breaking: rootTracingSpanIO signature changed in the previous commit). Bump nri-prelude upper bound to <0.8 in the sibling packages so the workspace builds, and refresh hard-coded package strings in the test-suite golden files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Initial nri-analytics package. Provides a Settings type read from
ANALYTICS_EVENTS_* env vars, an AnalyticsHandler with a sendEvent
callback that POSTs application/json to {eventsServiceUrl}/events
with bearer auth and a bounded timeout, and a silentHandler for
tests and non-tracking platforms.
The handler is sync (one outbound request per track call) and
log-and-drops on failure so analytics outages never affect the
surrounding request. Wire format is provisional pending the events
service contract.
The envelope fields required by the events service contract are added by the wire layer at sendEvent time, not by the typed Event in NoRedInk. This keeps the domain Event type pure data and removes the need to lift IO into Task in callers.
The auth token is now Log.Secret Text so accidental Show/logging doesn't leak it. buildRequest unwraps it at the HTTP-header boundary; the decoder uses Environment.secret to wrap on read. Also adds a test that sendEventIO swallows exceptions when delivery fails (unreachable URL), exercising the non-throwing contract that the surrounding request depends on. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
This is a proof of concept claude wrote for me. Don't merge it.