Skip to content

feat(server): expose error tracking config and captureException options - #670

Draft
cat-ph wants to merge 2 commits into
cat/java-et-coercerfrom
cat/java-et-server-config
Draft

feat(server): expose error tracking config and captureException options#670
cat-ph wants to merge 2 commits into
cat/java-et-coercerfrom
cat/java-et-server-config

Conversation

@cat-ph

@cat-ph cat-ph commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Second PR in the 4-PR JVM error-tracking stack. It exposes the error-tracking configuration surface on the server SDK and adds the missing captureException overloads.

Contains two commits:

  1. fix(error-tracking): pass releaseIdentifier through stateless exception capture — the stateless capture path (captureExceptionStateless, which is what posthog-server uses) never forwarded PostHogConfig.releaseIdentifier to the frame serializer, so $exception_list frames were missing map_id and could not be symbolicated. The stateful captureException path already did this; this restores parity. (Verified still missing on main as of this PR.)
  2. feat(server): expose error tracking config and captureException options:
    • PostHogConfig.inAppIncludes / inAppExcludes control in_app classification of captured frames (class-name prefix match; excludes always win). inAppExcludes defaults to a new PostHogConfig.DEFAULT_IN_APP_EXCLUDES list of common JVM/framework prefixes (JDK, Kotlin, Spring, Netty, servlet containers, HTTP clients, the PostHog SDK itself) so zero-config users get a sensible your-code vs framework split. Assigning your own list replaces the defaults.
    • PostHogConfig.releaseIdentifier stamps every frame with map_id, tying events to a ProGuard/R8 mapping uploaded via posthog-cli.
    • All three are available on the config Builder.
    • New captureException(exception, distinctId, options) / captureException(exception, options) overloads take PostHogCaptureOptions with the same merging semantics as capture(..., options): custom properties, $groups, $set/$set_once, timestamp, and feature-flag enrichment via a pre-evaluated flags snapshot or appendFeatureFlags. Reserved exception properties (e.g. $exception_level, $exception_fingerprint) can be overridden through options properties. Request-context distinct-id resolution and personless fallback behave exactly like the existing overloads.

💚 How did you test it?

  • 15 new tests across posthog-server's PostHogConfigTest and PostHogTest (defaults and overrides for the new config, exclude-beats-include classification, map_id stamping, and each new captureException overload including options merging and reserved-property overrides), plus 1 new core test in PostHogStatelessTest for the releaseIdentifier parity fix.
  • ./gradlew :posthog:test :posthog-server:test :posthog:apiCheck :posthog-server:apiCheck pass; spotlessCheck clean. API dumps regenerated; both diffs are additive only.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file
  • Added the "release" label to the PR to indicate we're publishing new versions for the affected packages

🔗 Stacked PR

Position 2 of 4. Base: cat/java-et-coercer (PR #669).

  1. PR feat(error-tracking): complete exception chain metadata and in-app classification #669 — core exception chain metadata + in-app classification
  2. this PR — server error-tracking config and captureException options
  3. cat/java-et-uncaught — opt-in server uncaught-exception capture
  4. cat/java-et-logback — new posthog-server-logback appender module

Review after its parent; the diff shown here is only this PR's own commits once the parent merges.

cat-ph added 2 commits August 4, 2026 01:58
…on capture

The stateful captureException path forwards config.releaseIdentifier to the
frame serializer (map_id per frame for ProGuard symbolication) but the
stateless path used by posthog-server omitted it, so server-side frames could
never carry map_id. Forward it for parity.
- PostHogConfig.inAppIncludes/inAppExcludes control in_app frame
  classification (prefix match, excludes win); inAppExcludes defaults to
  DEFAULT_IN_APP_EXCLUDES (JDK/Kotlin/framework noise) so zero-config
  users get a your-code vs framework split out of the box.
- PostHogConfig.releaseIdentifier stamps frames with map_id, tying
  events to an uploaded ProGuard/R8 mapping for symbolication.
- New captureException(exception[, distinctId], options) overloads with
  the same option-merging semantics as capture(..., options): custom
  props, $groups, $set/$set_once, timestamp, and flag enrichment via
  snapshot or appendFeatureFlags; reserved props ($exception_level, ...)
  overridable via options properties; request-context resolution and
  personless fallback unchanged.
@cat-ph
cat-ph force-pushed the cat/java-et-server-config branch from b4e866a to ffe3132 Compare August 3, 2026 23:03
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.

1 participant