Skip to content

Conversation

@dustinbyrne
Copy link
Contributor

💡 Motivation and Context

This change adds captureException to the server-side SDK and captureExceptionStateless to core for error tracking capabilities. It does not implement auto-capture, as unhandled exceptions are typically already caught (or generally handled) by a server-side framework.

Resolves #308

💚 How did you test it?

Added additional unit tests, updated the Java sample, and tested locally.

📝 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.

@dustinbyrne dustinbyrne requested a review from a team as a code owner October 30, 2025 20:53
import com.posthog.PostHogInternal

@PostHogInternal
public class ThrowableCoercer {
Copy link
Contributor Author

@dustinbyrne dustinbyrne Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instance of ThrowableCoercer that was in PostHog moved to PostHogStateless. Due to it being a protected variable, this scope has changed.

@dustinbyrne dustinbyrne force-pushed the feat/exception-capture branch from 23e5be7 to 55408ef Compare October 30, 2025 21:02
@dmarticus dmarticus self-assigned this Oct 31, 2025
Copy link
Contributor

@dmarticus dmarticus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved but pls address my comment.

properties: Map<String, Any>?,
distinctId: String?,
) {
shared.captureExceptionStateless(throwable, properties)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this include the distinctId? e.g.

shared.captureExceptionStateless(throwable, properties, distinctId)

Feels like you should have a test for this too, if one doesn't already exist.

override fun captureException(
exception: Throwable,
properties: Map<String, Any>?,
distinctId: String?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also have similar params that a regular capture() call does? e.g userProperties, userPropertiesSetOnce and groups?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python does not have either


## Exception Tracking

PostHog provides automatic exception tracking to help you monitor and debug errors in your application.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PostHog provides automatic exception tracking to help you monitor and debug errors in your application.
PostHog provides manual exception tracking to help you monitor and debug errors in your application.

usually we say 'automatic' when we have autocapture support

Comment on lines +137 to +138
properties: Map<String, Any>?,
distinctId: String?,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
properties: Map<String, Any>?,
distinctId: String?,
distinctId: String?,
properties: Map<String, Any>?,

just a nit, so it matches the capture method param ordering


var id = distinctId
if (id.isNullOrBlank()) {
exceptionProperties.set("\$process_person_profile", false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we call hasPersonProcessing here instead?

Copy link
Member

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few comments/questions otherwise LGTM

@dustinbyrne dustinbyrne force-pushed the fix!/group-properties-structure branch from 3bb5b82 to 886d3a2 Compare November 4, 2025 00:35
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.

5 participants