-
Notifications
You must be signed in to change notification settings - Fork 67
feat: add iOS native exception capture support #331
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4fd0635
feat: add iOS native exception capture support
marandaneto d60819a
fix example
marandaneto 3d459df
ios symbols
marandaneto 188dc70
fix
marandaneto 22a9f58
chore: address review feedback
marandaneto c73ff74
chore: add changeset entry
marandaneto 11ef2a1
chore: extract native crash to separate class for minification testing
marandaneto d70b807
chore: use custom exception type for native crash testing
marandaneto 0a4906f
chore: move thread to triggerCrash method
marandaneto 6f93647
chore: extract native crash to NativeCrashHelper class for iOS and macOS
marandaneto d37c9d3
chore: add NativeCrashHelper.swift to Xcode projects
marandaneto 8d1eb16
fix
marandaneto 33f9f40
Merge branch 'main' into feat/ios-native-exception-capture
marandaneto 0fc1ce4
fix
marandaneto d0af3d7
Merge branch 'main' into feat/ios-native-exception-capture
marandaneto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'posthog_flutter': minor | ||
| --- | ||
|
|
||
| Add native exception capture support for Apple platforms (iOS, macOS, tvOS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 17 additions & 1 deletion
18
example/android/app/src/main/kotlin/com/example/flutter/MainActivity.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,21 @@ | ||
| package com.example.flutter | ||
|
|
||
| import io.flutter.embedding.android.FlutterActivity | ||
| import io.flutter.embedding.engine.FlutterEngine | ||
| import io.flutter.plugin.common.MethodChannel | ||
|
|
||
| class MainActivity : FlutterActivity() | ||
| class MainActivity : FlutterActivity() { | ||
| override fun configureFlutterEngine(flutterEngine: FlutterEngine) { | ||
| super.configureFlutterEngine(flutterEngine) | ||
|
|
||
| MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "posthog_flutter_example") | ||
| .setMethodCallHandler { call, result -> | ||
| if (call.method == "triggerNativeCrash") { | ||
| NativeCrashHelper().triggerCrash() | ||
| result.success(null) | ||
| } else { | ||
| result.notImplemented() | ||
| } | ||
| } | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
example/android/app/src/main/kotlin/com/example/flutter/NativeCrashHelper.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.example.flutter | ||
|
|
||
| /** | ||
| * Custom exception type for testing error tracking symbolication. | ||
| * This class will be minified by R8/ProGuard in release builds, | ||
| * allowing us to verify that symbolication (ProGuard mapping upload) works correctly. | ||
| */ | ||
| class PostHogExampleException(message: String) : Exception(message) | ||
|
|
||
| /** | ||
| * Helper class to trigger a native crash for testing error tracking. | ||
| * This class and its methods will be minified by R8/ProGuard in release builds, | ||
| * allowing us to verify that symbolication (ProGuard mapping upload) works correctly. | ||
| */ | ||
| class NativeCrashHelper { | ||
| fun triggerCrash() { | ||
| // Crash on a background thread because Flutter wraps and | ||
| // swallows exceptions from the method channel handler as | ||
| // a PlatformException, preventing the app from actually crashing. | ||
| Thread { | ||
| throw PostHogExampleException("Test native crash from PostHog Flutter example") | ||
| }.start() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.