Skip to content

chore: minimize PostHog tracking to cut event volume - #3839

Closed
laststylebender14 wants to merge 7 commits into
mainfrom
chore/minimal-posthog-tracking
Closed

chore: minimize PostHog tracking to cut event volume#3839
laststylebender14 wants to merge 7 commits into
mainfrom
chore/minimal-posthog-tracking

Conversation

@laststylebender14

@laststylebender14 laststylebender14 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

We were getting huge PostHog bills due to over-tracking (billed per event). This PR minimizes what we send:

What PostHog receives now

  • start — once per session
  • login — once per session
  • error — error-level events only, capped at 60/min (was 1000/min)

Changes

  • Removed EventKind::Trace and the PostHogWriter log-shipping pipeline — previously every info-level log line was billed as a separate trace event, and errors were double-sent (once as error, again as trace).
  • Added PosthogErrorLayer — a tracing Layer that forwards error-level events from forge_* modules to PostHog as error events. This is now the single error pipeline: any tracing::error! anywhere in the workspace is tracked once, with no manual call-site wiring.
  • Removed EventKind::Prompt / EventKind::ToolCall — no longer send user prompt text or per-tool-call events.
  • Removed Conversation payloads from tracked events.
  • Logs always go to local rolling forge.log (forge=info when tracking is enabled, forge=debug otherwise) — previously enabling tracking meant no local log file at all.
  • Removed manual tracker::error() / error_string() helpers; kept error_blocking() for the panic hook (sync dispatch is safer during a panic).

Testing

  • cargo check --workspace — clean, no warnings
  • cargo test -p forge_tracker — all tests pass

- Ship only error-level logs to PostHog (was info-level)
- Truncate trace payloads to 1024 bytes before dispatch
@github-actions github-actions Bot added the type: chore Routine tasks like conversions, reorganization, and maintenance work. label Aug 10, 2026
…king

- Remove EventKind::Prompt and EventKind::ToolCall (and ToolCallPayload)
- Stop attaching full Conversation objects to tracked events
- Keep Start, Error, Login, and (truncated) Trace events
Traces are now error-level only, so send them in full.
@laststylebender14
laststylebender14 force-pushed the chore/minimal-posthog-tracking branch from b73aa4e to f1d08f9 Compare August 10, 2026 05:54
- Remove EventKind::Trace and the log-shipping PostHogWriter
- Logs always go to local rolling forge.log (info when tracking, debug otherwise)
- Add PosthogErrorLayer: error-level tracing events from forge_ modules are
  dispatched to PostHog as Error events (single pipeline, no double-send)
- Remove manual tracker::error()/error_string() helpers; keep error_blocking
  for the panic hook
- Lower event rate limit from 1000/min to 60/min
@laststylebender14 laststylebender14 changed the title chore: reduce PostHog tracking to error-level logs and truncated traces chore: minimize PostHog tracking to cut event volume/billing Aug 10, 2026
Newer clippy nightlies flag #[async_trait]-generated methods (which return
an already-must-use Pin<Box<dyn Future>> with an implicit #[must_use]) as
double_must_use, breaking the Lint Fix CI job on all branches. Allow the
lint workspace-wide via [workspace.lints] and opt every crate in.
@laststylebender14
laststylebender14 marked this pull request as ready for review August 10, 2026 06:18
autofix-ci Bot and others added 2 commits August 10, 2026 06:21
- Add Tracker::with_collectors test constructor for collector injection
- Add capture_events fixture that runs a closure under the layer and
  returns all dispatched (name, value) pairs
- Verify: error events dispatch with exact file:line/message/field
  rendering, non-error levels and non-forge targets are ignored, and
  multiple errors arrive as distinct ordered events
@laststylebender14 laststylebender14 changed the title chore: minimize PostHog tracking to cut event volume/billing chore: minimize PostHog tracking to cut event volume Aug 10, 2026
@tusharmath tusharmath closed this Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: chore Routine tasks like conversions, reorganization, and maintenance work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants