-
Notifications
You must be signed in to change notification settings - Fork 66
feat: add crash reporting #417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feat/error-tracking
Are you sure you want to change the base?
Conversation
can we create an issue for this and add to the limitation section in the docs once we have one? |
do we also need to patch PLCrashReporter for this? have other folks figured this out? otherwise same as #417 (comment) |
| s.frameworks = 'Foundation' | ||
|
|
||
| # PLCrashReporter dependency (not available on watchOS) | ||
| # Using ~> 1.8 for minimum compatibility with host apps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to choose this version specifically?
|
|
||
| // Add crash metadata | ||
| if let uuidRef = report.uuidRef { | ||
| properties["$crash_report_id"] = CFUUIDCreateString(nil, uuidRef) as String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what should we do with this info? should we add this to taxonomy?
| "mach": [ | ||
| "exception": machException.type, | ||
| "code": machException.codes.first, | ||
| "subcode": machException.codes.count > 1 ? machException.codes[1] : nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets skip nil values
| // MARK: - Helpers | ||
|
|
||
| /// Format string for zero-padded 64-bit hex addresses (e.g., "0x00007fff12345678") | ||
| static let hexAddressPaddedFormat = "0x%016llx" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it private
| ] | ||
|
|
||
| private static func machExceptionName(_ type: UInt64) -> String { | ||
| machExceptionNames[type] ?? "EXC_UNKNOWN(\(type))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better with EXC_UNKNOWN_X instead of EXC_UNKNOWN(X), more readable
|
|
||
| import Foundation | ||
|
|
||
| #if os(iOS) || os(macOS) || os(tvOS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the manual capture also available for the 3 OSs?
| func install(_ postHog: PostHogSDK) throws { | ||
| try PostHogCrashReporterIntegration.integrationInstalledLock.withLock { | ||
| if PostHogCrashReporterIntegration.integrationInstalled { | ||
| throw InternalPostHogError(description: "Crash report integration already installed to another PostHogSDK instance.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can just log and bail out isntead of throwing, this would be more expensive at runtime
| /// as the debugger intercepts signals before the crash handler can process them. | ||
| /// | ||
| /// Default: false | ||
| @objc public var enableCrashHandler: Bool = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we call this just autocapture on flutter? i think we should unify naming if that makes sense
| /// - Parameters: | ||
| /// - skipBuildProperties: When true, skips buildProperties call and uses properties as-is. | ||
| /// Used by crash reporting to capture events with pre-built crash-time context. | ||
| func captureInternal( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be a public API now, how can we make this internal only for us? we should not expose this to customers
💡 Motivation and Context
Stacked on top of #404
#skip-changelog
Adds automatic crash reporting to the PostHog iOS SDK using
PLCrashReporter.Crashes are captured and sent as
$exceptionevents with level "fatal" on the next app launch.Crash Types Handled:
Implementation notes
Limitations
💚 How did you test it?
📝 Checklist