Skip to content

feat: [SDK-5059] tag crash records with whether attribution succeeded - #34

Merged
abdulraqeeb33 merged 2 commits into
mainfrom
ar/sdk-5059
Nov 17, 2026
Merged

abdulraqeeb33 merged 2 commits into
mainfrom
ar/sdk-5059

Conversation

@abdulraqeeb33

Copy link
Copy Markdown
Contributor

Summary

Adds attributed to CrashData and emits it as the typed OTLP bool ossdk.crash.attributed, alongside the existing ossdk.crash.fatal.

Motivation

Both platforms gate crash capture on proving the crash came from SDK code. On iOS that proof is not always available. Attribution relies on the stack frame's Mach-O image naming us, which only holds while the SDK ships as separate frameworks. Once it is linked into the host executable every frame reports the same image, and the symbol fallback cannot stand in: release builds strip the local symbols that name our ObjC methods and Swift functions, so dladdr returns no name. Verified by stripping a probe binary (+[OSProbe probe] resolves, then returns nil after strip -x) and by confirming an app target in Release resolves to STRIP_INSTALLED_PRODUCT = YES with STRIP_STYLE = all.

When the gate cannot work, dropping turns real crashes into silence that looks identical to no crashes at all, so the failure mode hides itself and makes crash metrics read as healthy.

Carrying the platform's verdict on the record lets a platform capture what it cannot attribute and leaves the filtering to the backend, so attribution stops being a single point of failure.

Scope

Public surface: one parameter on CrashData, defaulting to true. Android source compatibility is unchanged, and Android keeps emitting attributed = true until it opts in.

Please confirm the default is honest for Android. It is correct if the Android handler captures only crashes it attributed to the SDK; if it captures unfiltered, true would misreport and Android should pass the real verdict.

The iOS consumer is OneSignal-iOS-SDK#1811. This needs to merge and be tagged before that one can land.

Testing

:kmp:iosSimulatorArm64Test and spotlessCheck pass. New test saveCrashTagsAttributionFromCrashData asserts both polarities reach the encoded record. Reverting the production change to a hardcoded true turns it red.

Checklist

  • I reviewed my changes.
  • I added or updated tests, or explained why they are not needed.
  • I confirmed there are no unintended public API changes.

Platforms gate crash capture on proving the crash came from SDK code. On iOS that
proof is unavailable whenever the SDK shares the host's executable, so the gate
turns real crashes into silence that looks identical to no crashes at all.

Carry the platform's verdict on CrashData and emit it as the typed OTLP bool
ossdk.crash.attributed, so a platform can capture what it cannot attribute and
leave the filtering to the backend. Defaults to true, keeping Android's current
contract unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@fadi-george

Copy link
Copy Markdown
Contributor

Potential issues:

  • Non-blocking: kmp/src/commonMain/kotlin/com/onesignal/logger/CrashData.kt:19, on Android the uncaught handler saves ANR-looking throwables without running isOneSignalAtFault, so with the default those get attributed=true unproven. Worth passing the real verdict there (e.g. attributed = isOneSignalAtFault(throwable)) in the Android follow-up.
  • Nit: kmp/src/commonMain/kotlin/com/onesignal/logger/CrashData.kt:17, could move this into the class KDoc as @Property so it shows up in the Swift header for iOS callers.
  • Nit: kmp/src/commonTest/kotlin/com/onesignal/logger/LogCrashTest.kt:124, could also cover saveNonFatal for the attributed flag.

KDoc is exported to the generated Obj-C header, so the inline comment was
invisible to Swift. Move it to @Property.

Also pin the flag on saveNonFatal, which shares the same emit path.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abdulraqeeb33

Copy link
Copy Markdown
Contributor Author

Both nits in 2c051a0.

  1. @property on the class KDoc. Confirmed it reaches the generated header, so Swift callers see it; the inline comment did not.
  2. saveNonFatal covered in both directions.

On the Android default, that answers the question I left in the description, and the answer is that = true is wrong there. Rather than leave it to the follow-up, I'd drop the default so the compiler makes Android state the verdict at the one site that has to decide. It breaks the Android build at pin-bump time, which is the point, and this PR exists to stop unproven attribution passing silently. Happy to do that here if you agree, or keep the default and track the Android fix.

@abdulraqeeb33

Copy link
Copy Markdown
Contributor Author

2 and 3 are in 2c051a0.

  1. Confirmed, taking it in the Android PR. isAnr short-circuits the && at AndroidLogCrashHandler.kt:57, so an ANR-shaped throwable with no OneSignal frames saves through toCrashData and takes the attributed = true default. iOS already passes attributed: isAtFault, so until that lands the flag means something different on each platform. The ANR detector is fine, it proves fault before building.

@abdulraqeeb33
abdulraqeeb33 merged commit c0b4ad3 into main Nov 17, 2026
2 checks passed
@abdulraqeeb33
abdulraqeeb33 deleted the ar/sdk-5059 branch November 17, 2026 19:53
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.

2 participants