Skip to content

Commit 7262292

Browse files
committed
refactor(errortracking): clarify suppress log + test-stub comment
Address two of three Greptile review notes on PR #569: 1. The "skipping autocapture" log message previously read as if the throwable's outermost class was always the matched ignoredType. A cause-chain match would report e.g. `java.lang.RuntimeException` as suppressed even when only `JavascriptException` was in the ignore list. Reworded to surface that "the throwable or a cause in its chain" matched. 2. The `ReactNativeJavascriptExceptionStub` doc comment claimed it was "named the same way" as the real RN class — it isn't; the stub's JVM name lives under the test class. Restated the actual design: the stub's own FQCN is what tests register as the ignored value, exercising the same code path without needing RN on the classpath. Greptile's third note (parameterising the new tests) is intentionally deferred — the individual test names ("skips capture when…", "still captures when…", etc.) document distinct behaviours and read more clearly than a `@ParameterizedTest` table would. Happy to revisit if the maintainer prefers the table form.
1 parent d005935 commit 7262292

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

posthog/src/main/java/com/posthog/errortracking/PostHogErrorTrackingAutoCaptureIntegration.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ public class PostHogErrorTrackingAutoCaptureIntegration : PostHogIntegration, Th
8686
postHog.captureException(PostHogThrowable(throwable, thread))
8787
postHog.flush()
8888
} else {
89+
// The match may have been against a cause anywhere in the chain,
90+
// not necessarily the outermost throwable, so we deliberately
91+
// don't pin the log to `throwable.javaClass.name` — that would
92+
// mislead anyone looking at the logs and seeing e.g. a bare
93+
// RuntimeException reported as suppressed when their ignore
94+
// list only mentions com.facebook.react.common.JavascriptException.
8995
config.logger.log(
90-
"Skipping autocapture for ignored exception type: ${throwable.javaClass.name}",
96+
"Skipping autocapture: ${throwable.javaClass.name} (or a cause in its chain) matches ignoredExceptionTypes",
9197
)
9298
}
9399
}

posthog/src/test/java/com/posthog/errortracking/PostHogErrorTrackingAutoCaptureIntegrationTest.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,12 @@ internal class PostHogErrorTrackingAutoCaptureIntegrationTest {
228228
/**
229229
* Local stand-in for `com.facebook.react.common.JavascriptException`. The real type
230230
* lives in React Native, which isn't (and shouldn't be) a test dependency of the
231-
* SDK. The ignored-exception filter is purely class-name based, so a local class
232-
* named the same way exercises the same code path without dragging in RN.
231+
* SDK. The ignored-exception filter is purely class-name based: each test that
232+
* uses this stub registers its own JVM name
233+
* (`...PostHogErrorTrackingAutoCaptureIntegrationTest$ReactNativeJavascriptExceptionStub`)
234+
* as the ignored FQCN. That exercises the matching logic without requiring RN on
235+
* the classpath. The stub name intentionally differs from the real RN class name —
236+
* the production code path is identical either way.
233237
*/
234238
private class ReactNativeJavascriptExceptionStub(message: String) : RuntimeException(message)
235239

0 commit comments

Comments
 (0)