-
-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API for deliberately crashing an app (#1842)
* Add Java and C code * Commit binaries * Add new SentrySdk.CauseCrash API * Update samples * Update CHANGELOG.md * Update CI Build * Fix sample * Remove unobserved task (won't crash) * Add tests * Cleanup API approvals * redundant using * warning disable CS0618 * System.Obsolete in api * System.Obsolete in api Co-authored-by: Simon Cropp <simon.cropp@gmail.com>
- Loading branch information
1 parent
8760b8b
commit f474f07
Showing
56 changed files
with
547 additions
and
159 deletions.
There are no files selected for viewing
This file contains 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,32 @@ | ||
name: Build Native Dependencies | ||
runs: | ||
using: composite | ||
|
||
steps: | ||
|
||
- name: Set Environment Variables | ||
shell: bash | ||
run: echo "JAVA_HOME_11=$JAVA_HOME_11_X64" >> $GITHUB_ENV | ||
|
||
- name: Install Ninja | ||
uses: seanmiddleditch/gha-setup-ninja@master | ||
|
||
- name: Build C Project | ||
if: runner.os == 'Linux' || runner.os == 'macOS' | ||
shell: bash | ||
run: src/Sentry/Platforms/Android/C/build.sh | ||
|
||
- name: Build C Project | ||
if: runner.os == 'Windows' | ||
shell: cmd | ||
run: src\Sentry\Platforms\Android\C\build.cmd | ||
|
||
- name: Build Java Project | ||
if: runner.os == 'Linux' || runner.os == 'macOS' | ||
shell: bash | ||
run: src/Sentry/Platforms/Android/Java/build.sh | ||
|
||
- name: Build Java Project | ||
if: runner.os == 'Windows' | ||
shell: cmd | ||
run: src\Sentry\Platforms\Android\Java\build.cmd |
This file contains 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 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 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 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 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 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains 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,63 +1,61 @@ | ||
using Sentry.Samples.Android.Kotlin; | ||
#pragma warning disable CS0618 | ||
namespace Sentry.Samples.Android; | ||
|
||
namespace Sentry.Samples.Android | ||
[Activity(Label = "@string/app_name", MainLauncher = true)] | ||
public class MainActivity : Activity | ||
{ | ||
[Activity(Label = "@string/app_name", MainLauncher = true)] | ||
public class MainActivity : Activity | ||
protected override void OnCreate(Bundle? savedInstanceState) | ||
{ | ||
protected override void OnCreate(Bundle? savedInstanceState) | ||
SentrySdk.Init(this, o => | ||
{ | ||
SentrySdk.Init(this, o => | ||
{ | ||
o.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537"; | ||
o.SendDefaultPii = true; // adds the user's IP address automatically | ||
}); | ||
o.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537"; | ||
o.SendDefaultPii = true; // adds the user's IP address automatically | ||
}); | ||
|
||
// Here's an example of adding custom scope information. | ||
// This can be done at any time, and will be passed through to the Java SDK as well. | ||
SentrySdk.ConfigureScope(scope => | ||
{ | ||
scope.AddBreadcrumb("Custom Breadcrumb"); | ||
scope.SetExtra("Test", "Custom Extra Data"); | ||
scope.User = new User | ||
{ | ||
Username = "SomeUser", | ||
Email = "test@example.com", | ||
Other = | ||
{ | ||
["CustomInfo"] = "Custom User Info" | ||
} | ||
}; | ||
}); | ||
|
||
base.OnCreate(savedInstanceState); | ||
|
||
// Set our view from the "main" layout resource | ||
SetContentView(Resource.Layout.activity_main); | ||
|
||
var captureException = (Button)base.FindViewById(Resource.Id.captureException)!; | ||
captureException.Click += (s, a) => | ||
// Here's an example of adding custom scope information. | ||
// This can be done at any time, and will be passed through to the Java SDK as well. | ||
SentrySdk.ConfigureScope(scope => | ||
{ | ||
scope.AddBreadcrumb("Custom Breadcrumb"); | ||
scope.SetExtra("Test", "Custom Extra Data"); | ||
scope.User = new User | ||
{ | ||
try | ||
Username = "SomeUser", | ||
Email = "test@example.com", | ||
Other = | ||
{ | ||
throw new Exception("Try, catch"); | ||
} | ||
catch (Exception e) | ||
{ | ||
SentrySdk.CaptureException(e); | ||
["CustomInfo"] = "Custom User Info" | ||
} | ||
}; | ||
var throwUnhandledException = (Button)base.FindViewById(Resource.Id.throwUnhandledException)!; | ||
throwUnhandledException.Click += (s, a) => throw new Exception("Unhandled"); | ||
var throwKotlinException = (Button)base.FindViewById(Resource.Id.throwKotlinException)!; | ||
throwKotlinException.Click += (s, a) => Buggy.Throw(); | ||
var throwKotlinExceptionBackgroundThread = (Button)base.FindViewById(Resource.Id.throwKotlinExceptionBackgroundThread)!; | ||
throwKotlinExceptionBackgroundThread.Click += (s, a) => Buggy.ThrowOnBackgroundThread(); | ||
var crashInC = (Button)base.FindViewById(Resource.Id.crashInC)!; | ||
crashInC.Click += (s, a) => CrashInC(); | ||
} | ||
|
||
[System.Runtime.InteropServices.DllImport("libbuggy.so", EntryPoint = "crash_in_c")] | ||
private static extern void CrashInC(); | ||
}); | ||
|
||
base.OnCreate(savedInstanceState); | ||
|
||
// Set our view from the "main" layout resource | ||
SetContentView(Resource.Layout.activity_main); | ||
|
||
var captureException = (Button)base.FindViewById(Resource.Id.captureException)!; | ||
captureException.Click += (s, a) => | ||
{ | ||
try | ||
{ | ||
throw new Exception("Try, catch"); | ||
} | ||
catch (Exception e) | ||
{ | ||
SentrySdk.CaptureException(e); | ||
} | ||
}; | ||
var throwUnhandledException = (Button)base.FindViewById(Resource.Id.throwUnhandledException)!; | ||
throwUnhandledException.Click += (s, a) => throw new Exception("Unhandled"); | ||
|
||
var throwJavaException = (Button)base.FindViewById(Resource.Id.throwJavaException)!; | ||
throwJavaException.Click += (s, a) => SentrySdk.CauseCrash(CrashType.Java); | ||
|
||
var throwJavaExceptionBackgroundThread = (Button)base.FindViewById(Resource.Id.throwJavaExceptionBackgroundThread)!; | ||
throwJavaExceptionBackgroundThread.Click += (s, a) => SentrySdk.CauseCrash(CrashType.JavaBackgroundThread); | ||
|
||
var crashInC = (Button)base.FindViewById(Resource.Id.crashInC)!; | ||
crashInC.Click += (s, a) => SentrySdk.CauseCrash(CrashType.Native); | ||
} | ||
} |
This file contains 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 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 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 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 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.