Coder Social home page Coder Social logo

getsentry / sentry-xamarin Goto Github PK

View Code? Open in Web Editor NEW
44.0 7.0 11.0 4.21 MB

Sentry for Xamarin Native and Xamarin.Forms

Home Page: https://docs.sentry.io/platforms/dotnet/guides/xamarin/

C# 89.78% Shell 0.16% PowerShell 8.00% JavaScript 2.06%
xamarin xamarin-forms ios android tag-production

sentry-xamarin's Introduction

Sentry

Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us, check out our open positions.

Sentry SDK for Xamarin

build Discord Chat

Integrations Downloads NuGet Stable NuGet Preview
Sentry.Xamarin.Forms Downloads NuGet NuGet
Sentry.Xamarin Downloads NuGet NuGet

Sentry.Xamarin is the tool to go for Xamarin that enriches your errors with valuable data, like breadcrumbs, tags, issue grouping and more!.

Includes for all Platforms supported by Xamarin Essentials:

  • Automatic Navigation breacrumbs. (Xamarin.Forms)
  • Xaml warnings as breadcrumbs. (Xamarin.Forms)
  • Simulator flag.
  • Device manufacturer.
  • Device model.
  • Operational system name and version.
  • Screen information (Pixel density and resolution).
  • Connectivity status.

Additionaly, Android and IOS will include additional information:

  • Free Internal memory (Android/iOS).
  • Total RAM (Android/iOS).
  • CPU model (Android).

BEFORE

Screenshot of Sentry before applying Sentry.Xamarin

AFTER

Screenshot of Sentry after applying Sentry.Xamarin

Setup

All you need to do is to initialize Xamarin integration by calling SentryXamarin.Init, and, it's recommended to start Sentry Xamarin SDK as early as possible, for an example, the start of OnCreate on MainActivity for Android, and, the top of FinishedLaunching on AppDelegate for iOS)

SentryXamarin.Init(options =>
{
    options.Dsn = "__YOUR__DSN__";
    options.AddXamarinFormsIntegration();
});

If your app uses Xamarin.Forms you can also use the package Sentry.Xamarin.Forms and initialize the SDK with additional line options.AddXamarinFormsIntegration().

Android

On your MainActivity

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        SentryXamarin.Init(options =>
        {
            options.Dsn = "__YOUR__DSN__";
            options.AddXamarinFormsIntegration();
        });
        ...

iOS

On AppDelegate.cs

public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
    public override bool FinishedLaunching(UIApplication app, NSDictionary options)
    {
        SentryXamarin.Init(options =>
        {
            options.Dsn = "__YOUR__DSN__";
            options.AddXamarinFormsIntegration();
        });
        ...

UWP

On App.Xaml.cs

sealed partial class App : Application
{
    protected override void OnLaunched(LaunchActivatedEventArgs e)
    {
        SentryXamarin.Init(options =>
        {
            options.Dsn = "__YOUR__DSN__";
            options.AddXamarinFormsIntegration();
        });
    ...        

Compatibility

The package requires the following versions or newer:

  • Tizen 4.0 (for Tizen)
  • Xamarin.Android 11.0 (for Android)
  • Xamarin.iOS 10.14 (for iOS)
  • Universal Windows Platform 10.0.16299 (for UWP)
  • Xamarin.Forms 4.6.0.726 (for Xamarin.Forms integration)
  • Xamarin.Essentials 1.4.0
  • Sentry 4.0.3

Resources

  • Documentation
  • Forum
  • Discord Chat
  • Stack Overflow
  • Twitter Follow

sentry-xamarin's People

Contributors

bitsandfoxes avatar bruno-garcia avatar byk avatar getsentry-bot avatar lucas-zimerman avatar mattjohnsonpint avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sentry-xamarin's Issues

Screenshot feature Ideas

I created this issue to discuss some possibilities to enhance the Screenshot feature.

  • Add a user option to choose the minimum event level to attach a screenshot, where the use case is a user not wanting screenshots with debug/info/warning events but error and fatal.

  • Add a user option to choose the picture quality (could be a low/medium/high enum or a percentage from 1 to 100), the reasoning is, current device resolutions are getting too high and with that, screenshots are getting bigger.
    sample_pictures.zip <- sample pictures to compare the compression quality.
    By default, 50% seems to be a good balance between size and quality.

If you have any other ideas, feel free to comment.

Allow Xamarin projects without Forms to use the SDK

Right now the SDK is only installed if you have Xamarin Forms, blocking non Forms users from using it.

The goal is to remove the dependency of Xamarin.Forms from Android, iOS, and ideally, UWP), we might keep it for platforms without Native Integrations implemented like Tizen.

Sentry.Xamarin does not work on .Net 6.0 iOS

Environment

net6.0-ios13.0

Steps to Reproduce

Invoke SentryXamarin.Init in AppDelegate constructor.

Expected Result

The app started without crash and Sentry is initialized successfully.

Actual Result

The app crashed after start:

Unhandled managed exception: Operation is not supported on this platform. 
(System.PlatformNotSupportedException)
   at System.Net.Http.NSUrlSessionHandler.get_SupportsAutomaticDecompression()
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
--- End of stack trace from previous location ---
   at System.Net.Http.HttpClientHandler.InvokeNativeHandlerMethod(String name, Object[] parameters)
   at System.Net.Http.HttpClientHandler.GetSupportsAutomaticDecompression()
   at System.Net.Http.HttpClientHandler.get_SupportsAutomaticDecompression()
   at Sentry.Internal.Http.DefaultSentryHttpClientFactory.Create(SentryOptions options)
   at Sentry.Internal.SdkComposer.CreateTransport()
   at Sentry.Internal.SdkComposer.CreateBackgroundWorker()
   at Sentry.SentryClient..ctor(SentryOptions options, IBackgroundWorker worker)
   at Sentry.SentryClient..ctor(SentryOptions options)
   at Sentry.Internal.Hub..ctor(SentryOpti<…>

Bundle the Sentry iOS SDK

When we bundle the Sentry iOS SDK we need to take into account that Mono uses some signals to interpret NullReferenceExceptions and need special case (run before other crash reports do):

See: https://www.mono-project.com/docs/advanced/signals/#incomplete-solution
See also: dotnet/runtime#44736

This is probably something we can do in the binding project, before calling Init in the iOS SDK.

Proposed solution, based on the Mono docs:

try {
} finally {
    Mono.Runtime.RemoveSignalHandlers ();
    try {
        // Init the Sentry iOS SDK:
        SentrySDK.start(...);
    } finally {
        Mono.Runtime.InstallSignalHandlers ();
    }
}

Since Mono’s signal handlers are reinstalled and not restored, Mono will now chain to the signal handlers installed by EnableCrashReporting.

The code is executed in a finally block, so that the Mono runtime will never abort it under any circumstance.

It’s recommended to do this as early as possible when launching the process, in particular before starting any secondary threads. If any signals are raised between removing and reinstalling Mono’s signal handlers (this includes NullReferenceExceptions), the app will crash.

See: https://www.mono-project.com/docs/advanced/signals/#complete-solution

enhance sample app with use cases:

  • Register a handled exception.
  • Register an unhandled
  • exception.Register user feedback.
  • Add Sleep/Resume breadcrumbs
  • Nice looking app to simulate a real use-case.

Discuss CancelationToken on FormsApplicationListener

To not lose the comment from Matt

#108 (review)

Yikes. I see this was in the old code and you are just refactoring, but we really shouldn't completely lose this task. It should be saved somewhere. We should also register it for cancellation so it can be shut down gracefully. I'm OK if this is done in a future PR, but wanted to point it out.

On

public void Invoke() =>
//Don't lock the main Thread while waiting for the current application to be created.
Task.Run(async () =>
{
var application = await GetCurrentApplication().ConfigureAwait(false);
if (application is null)
{
_options.DiagnosticLogger?.Log(SentryLevel.Warning, "Sentry.Xamarin.Forms timeout for tracking Application.Current. Navigation tracking is going to be disabled");
return;
}
foreach(var hook in _listeners)
{
hook.Invoke(application);
}
});

Add documentation to options

Currently the options object doesn't have any XML docs:

internal bool XamarinLoggerEnabled { get; set; } = true;
internal bool NativeIntegrationEnabled { get; set; } = true;
internal bool InternalCacheEnabled { get; set; } = true;
internal IPageNavigationTracker PageTracker { get; set; }
internal string ProtocolPackageName { get; set; }
internal string ProjectName { get; set; }
internal int GetCurrentApplicationDelay { get; set; } = 500;
internal int GetCurrentApplicationMaxRetries { get; set; } = 15;

[BUG] Android caching not working

Environment

How do you use Sentry?
sentry.io

Which SDK and version?
Sentry.Xamarin.Forms 1.3.1

Steps to Reproduce

  1. I threw an null exception in MainActivity.cs
  2. I reported the exception to Sentry with SentrySdk.CaptureException(e);

Expected Result

I expected the exception to be reported to Sentry.

Actual Result

The exception was not reported and when I checked the logs it said

Error: Failed to send cached envelope: /data/user/0/se.recruto.app/files/.local/share/Sentry/02A6EA804EEE9F2AB1F3BD97BAB66F72272DC6B4/__processing/1641814777_9932__-1903654489.envelope, discarding cached envelope.
System.MissingMethodException: Method not found: System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.ReadOnlyMemory`1<byte>,System.Text.Json.JsonDocumentOptions)
  at Sentry.Protocol.Envelopes.Envelope.DeserializeHeaderAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x001a1] in /_/src/Sentry/Envelopes/Envelope.cs:186 
  at Sentry.Protocol.Envelopes.Envelope.DeserializeAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x00032] in /_/src/Sentry/Envelopes/Envelope.cs:198 
  at Sentry.Internal.Http.CachingTransport.ProcessCacheAsync (System.Threading.CancellationToken cancellationToken) [0x00111] in /_/src/Sentry/Internal/Http/CachingTransport.cs:163 
  at Sentry.Internal.Http.CachingTransport.ProcessCacheAsync (System.Threading.CancellationToken cancellationToken) [0x002cd] in /_/src/Sentry/Internal/Http/CachingTransport.cs:172   Debug: No cached file to process.
  Debug: Registering integration: 'AutoSessionTrackingIntegration'.
  Debug: Attempting to recover persisted session from file.
  Debug: A persisted session does not exist at /data/user/0/se.recruto.app/files/.local/share/Sentry/02A6EA804EEE9F2AB1F3BD97BAB66F72272DC6B4/.session.
  Debug: Created directory for installation ID file (/data/user/0/se.recruto.app/files/.local/share/Sentry/02A6EA804EEE9F2AB1F3BD97BAB66F72272DC6B4).
  Debug: Resolved installation ID '0c23f0cd-ccac-4536-bcbb-d2a136c08785'.
   Info: Started new session (SID: c71750ea3c184978949e5ccccdef11cb; DID: 0c23f0cd-ccac-4536-bcbb-d2a136c08785).

If I add the options.DisableOfflineCaching(); in the init it works. This article https://docs.sentry.io/platforms/dotnet/guides/xamarin/troubleshooting/ explains how to fix it on iOS but not on Android.

Add Performance to Xamarin Forms Sample

Add performance to the Xamarin Forms showcasing the following use-cases:

  • Time for loading Pages/Views.
  • Time for Sending/Receiving requests.
  • Time for processing a batch of Images.

Xamarin document offline caching and `InitCacheFlushTimeout`

Recently a user on Discord asked why a crash (throw null) right after SentryXamarin.Init wasn't captured on a Xamarin app.

The explanation is:

When you load the app for the first time, it inits Sentry and immediately crashes. Sentry, writes that crash data to a file (can't send it to Sentry before the app crashes). So when the app restarts, you Init Sentry again, and Sentry sees the file and tries to send. But since that's now blocking the app from launching, it only waits up to 1 second. If ti can't send it to Sentry before that, it lets the app continue to launch. But right after initing Sentry, it crashes again.
So it worked for me, but it might not work for you depending on the latency you have between the device and Sentry for example.
One way around this, is to configure how long you're OK with the SDK blocking the app lunch if it finds a crash file:

SentryXamarin.Init(options =>
{
    options.Dsn = "...";
    options.InitCacheFlushTimeout = TimeSpan.FromSeconds(10);
});

it will wait "up to 10 seconds" for a crash to be sent when the app restarts. The default is 1 second only I believe
You can also turn it off and if the app is just crashing right while opening up, it will just never capture that

Turns out this is actually documented here: https://docs.sentry.io/platforms/dotnet/configuration/options/#init-cache-flush-timeout

It could be beneficial for Xamarin particularly to get more information about this, since offline caching is on by default.

Issue with linker: System.MissingMethodException: Constructor on type 'System.Text.Json.Serialization.Converters.DictionaryOfTKeyTValueConverter

  Error: Error while processing envelope (event ID: '88e99c4ae34249ebbf05d99480580758'). #1 in queue.
info
09:20:39
Console.Write
System.MissingMethodException: Constructor on type 'System.Text.Json.Serialization.Converters.DictionaryOfTKeyTValueConverter`3[[System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String[], mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String[], mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' not found.
  at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) <0x100a67290 + 0x00640> in <25bf495f7d6b4944aa395b3ab5293479#66408fa1874fecacca7e1004891fd210>:0 
  at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) <0x100c422ec + 0x000bb> in <25bf495f7d6b4944aa395b3ab5293479#66408fa1874fecacca7e1004891fd210>:0 
  at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture) <0x100c422d8 + 0x0000b> in <25bf495f7d6b4944aa395b3ab5293479#66408fa1874fecacca7e1004891fd210>:0 
  at System.Text.Json.Serialization.Converters.IEnumerableConverterFactory.CreateConverter (System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) <0x102da7658 + 0x00203> in <cb68364b029e41c3bf425990b94c94d9#66408fa1874fecacca7e1004891fd210>:0 
  at System.Text.Json.JsonSerializerOptions.GetConverter (System.Type typeToConvert) <0x102d909b4 + 0x0034b> in <cb68364b029e41c3bf425990b94c94d9#66408fa1874fecacca7e1004891fd210>:0 
  at System.Text.Json.JsonSerializerOptions.DetermineConverter (System.Type parentClassType, System.Type runtimePropertyType, System.Reflection.MemberInfo memberInfo) <0x102d90840 + 0x000a7> in <cb68364b029e41c3bf425990b94c94d9#66408fa1874fecacca7e1004891fd210>:0 
  at System.Text.Json.JsonClassInfo.GetConverter (System.Type type, System.Type parentClassType, System.Reflection.MemberInfo memberInfo, System.Type& runtimeType, System.Text.Json.JsonSerializerOptions options) <0x102d8cc18 + 0x0005f> in <cb68364b029e41c3bf425990b94c94d9#66408fa1874fecacca7e1004891fd210>:0 
  at System.Text.Json.JsonClassInfo..ctor (System.Type type, System.Text.Json.JsonSerializerOptions options) <0x102d8b89c + 0x0008f> in <cb68364b029e41c3bf425990b94c94d9#66408fa1874fecacca7e1004891fd210>:0 
  at System.Text.Json.JsonSerializerOptions.GetOrAddClass (System.Type type) <0x102d915b8 + 0x0007b> in <cb68364b029e41c3bf425990b94c94d9#66408fa1874fecacca7e1004891fd210>:0 
  at System.Text.Json.WriteStack.Initialize (System.Type type, System.Text.Json.JsonSerializerOptions options, System.Boolean supportContinuation) <0x102d91d5c + 0x0003b> in <cb68364b029e41c3bf425990b94c94d9#66408fa1874fecacca7e1004891fd210>:0 
  at System.Text.Json.JsonSerializer.WriteCore[TValue] (System.Text.Json.Utf8JsonWriter writer, TValue& value, System.Type inputType, System.Text.Json.JsonSerializerOptions options) <0x102d8fb78 + 0x0008f> in <cb68364b029e41c3bf425990b94c94d9#66408fa1874fecacca7e1004891fd210>:0 
  at System.Text.Json.JsonSerializer.Serialize[TValue] (System.Text.Json.Utf8JsonWriter writer, TValue& value, System.Type type, System.Text.Json.JsonSerializerOptions options) <0x102d8fdd8 + 0x0005b> in <cb68364b029e41c3bf425990b94c94d9#66408fa1874fecacca7e1004891fd210>:0 
  at System.Text.Json.JsonSerializer.Serialize[TValue] (System.Text.Json.Utf8JsonWriter writer, TValue value, System.Text.Json.JsonSerializerOptions options) <0x102d8fd54 + 0x0005f> in <cb68364b029e41c3bf425990b94c94d9#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Internal.Extensions.JsonExtensions.WriteDynamicValue (System.Text.Json.Utf8JsonWriter writer, System.Object value) <0x102c6c47c + 0x00323> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Internal.Extensions.JsonExtensions.WriteDynamic (System.Text.Json.Utf8JsonWriter writer, System.String propertyName, System.Object value) <0x102c6c950 + 0x00027> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Internal.Extensions.JsonExtensions.WriteDictionaryValue (System.Text.Json.Utf8JsonWriter writer, System.Collections.Generic.IEnumerable`1[T] dic) <0x102c6bbb4 + 0x000cf> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Contexts.WriteTo (System.Text.Json.Utf8JsonWriter writer) <0x102c46058 + 0x00013> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Internal.Extensions.JsonExtensions.WriteSerializableValue (System.Text.Json.Utf8JsonWriter writer, Sentry.IJsonSerializable value) <0x102c6c3cc + 0x00043> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Internal.Extensions.JsonExtensions.WriteSerializable (System.Text.Json.Utf8JsonWriter writer, System.String propertyName, Sentry.IJsonSerializable value) <0x102c6c438 + 0x00027> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Transaction.WriteTo (System.Text.Json.Utf8JsonWriter writer) <0x102c57d80 + 0x00153> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Protocol.Envelopes.JsonSerializable.SerializeAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) <0x102c1d790 + 0x00173> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Protocol.Envelopes.JsonSerializable.SerializeAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) <0x102c1d790 + 0x0088b> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Protocol.Envelopes.EnvelopeItem.BufferPayloadAsync (System.Threading.CancellationToken cancellationToken) <0x102c787ac + 0x0017b> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Protocol.Envelopes.EnvelopeItem.SerializeAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) <0x102c1a6b0 + 0x0089b> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Protocol.Envelopes.Envelope.SerializeAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) <0x102c186b0 + 0x00727> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Internal.Http.CachingTransport.StoreToCacheAsync (Sentry.Protocol.Envelopes.Envelope envelope, System.Threading.CancellationToken cancellationToken) <0x102c10930 + 0x00903> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Internal.Http.CachingTransport.StoreToCacheAsync (Sentry.Protocol.Envelopes.Envelope envelope, System.Threading.CancellationToken cancellationToken) <0x102c10930 + 0x00e33> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Internal.Http.CachingTransport.SendEnvelopeAsync (Sentry.Protocol.Envelopes.Envelope envelope, System.Threading.CancellationToken cancellationToken) <0x102c66a48 + 0x00123> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 
  at Sentry.Internal.BackgroundWorker.WorkerAsync () <0x102c0b0b0 + 0x00da7> in <c543491de6524fd4addbd87a9ec2d93a#66408fa1874fecacca7e1004891fd210>:0 

It can be mitigated by adding the following linker rule:

	<assembly fullname="System.Text.Json">
		<type fullname="System.Text.Json.Serialization.Converters.*" preserve="all"/>
	</assembly>

Ideally we should add this to the troubleshooting session

EDIT Repro:

            SentrySdk.ConfigureScope(scope =>
            {
                scope.Contexts["New Context"] = new Dictionary<string, string[]>
                { { "Item", new[] { "1" , "2", "3 " } } };
            });
            SentrySdk.CaptureMessage("Hello World");

[BUG][PROD][Release] Screenshot are attached with 0 size in release mode

Environment

How do you use Sentry?
Sentry SaaS (sentry.io) or self-hosted/on-premise (which version?)

Which SDK and version?
sentry xamarin SDK 1.3.1

Steps to Reproduce

1- integrate sentry SDK into android xamarin app, and activate the screenshot feature.
2- generate a random error in debug mode
3- generate a random error in release mode

Expected Result

you can see screenshot in debug mode, and you can't see screenshot in release mode

Actual Result

you can see screenshot in debug mode, and you can't see screenshot in release mode

image

ExecutionEngineException throws when trying to capture any event

Any ideas why this is happening? I used it in my app , this is what happened when trying to send a message.

Environment

Which SDK and version?

Sentry.Xamarin 1.3.1
Sentry 3.9.2
System.Memory 4.5.4
System.Buffers 4.5.1

Steps to Reproduce

Just Init in my app and attempt to capture a null exception

Expected Result

Should not throw this exception

Actual Result

Debug: Reading cached envelope: <path-to-cache-envelope>
Error: Failed to send cached envelope: <path-to-cache-envelope>, discarding cached envelope.
System.ExecutionEngineException: Attempting to JIT compile method 'System.Text.Json.JsonElement Sentry.Internal.Json:Parse (byte[])' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

  at Sentry.Protocol.Envelopes.Envelope.DeserializeHeaderAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x001a1] in /_/src/Sentry/Envelopes/Envelope.cs:186 
  at Sentry.Protocol.Envelopes.Envelope.DeserializeAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x00032] in /_/src/Sentry/Envelopes/Envelope.cs:198 
  at Sentry.Internal.Http.CachingTransport.ProcessCacheAsync (System.Threading.CancellationToken cancellationToken) [0x00111] in /_/src/Sentry/Internal/Http/CachingTransport.cs:163 
  at Sentry.Internal.Http.CachingTransport.ProcessCacheAsync (System.Threading.CancellationToken cancellationToken) [0x002cd] in /_/src/Sentry/Internal/Http/CachingTransport.cs:172   Debug: Reading cached envelope: <path-to-cache-envelope>

Define the lowest supported Android version

Right now the SDK is targeting Android 10, but it would be nice if it was able to target at least Android 5.0.
Right now, in case your app doesn't target Android 10, the Native Integrations for Android are going to be disabled.

Crash error caused by package code (IHubExtensions.AddInternalBreadcrumb)

Our app seems to be crashing every now and then on multiple devices. This is the error reported by Sentry:

System.ArgumentNullException: Value cannot be null.
Parameter name: first
?, in IEnumerable<KeyValuePair<string, string>> Enumerable.Except<KeyValuePair<string, string>>(IEnumerable<KeyValuePair<string, string>> first, IEnumerable<KeyValuePair<string, string>> second)
?, in void IHubExtensions.AddInternalBreadcrumb(IHub hub, SentryXamarinOptions options, string message, string category, string type, Dictionary<string, string> data, BreadcrumbLevel level)
?, in void NativeIntegration.<get_MemoryWarning>b__12_0(?)+(NSNotification _) => { }
?, in void InternalNSNotificationHandler.Post(NSNotification s)
?, in void UIApplication.Main(string[] args, IntPtr principal, IntPtr delegate) x 2
?, in void Application.Main(string[] args)

It seems it is this code that is causing the error: (IHubExtensions.cs line: 36)

!previousBreadcrumb.Data.Except(data).Any() &&

I guess putting in a null-conditional behind .Data would solve the issue, but it might go deeper than that?

.Data?.Except

Setup Github Action for testing UWP

Right now there's a project for testing the SDK with UWP, but it's not integrated with Github Actions.

It would be great to integrate it so future Pull Requests will be checked against UWP.

update docs/sample about how to register View exceptions

XAML Exceptions don't crash the app but are often ignored.

Inform the user how to log XAML Exceptions with a sample app, but also with documentation.

    public partial class SomePage : ContentPage
    {
        public Disco()
        {
            try
            {
                InitializeComponent();
            }
            catch(Exception ex)
            {
                SentrySdk.CaptureException(ex);
            }
        }
    }

Create a sample App for WPF

The app must include the following features.

  • Handled Exceptions.
  • Unhandled Exceptions.
  • CaptureMessage.
  • user feedback.
  • Navigation.
  • Breadcrumbs.

Format Objective-C StackTrace.

Currently, Xamarin Grabs the Objective-C Exception message, stack trace, type and stores it into the C# Exception message.
By doing that, you'll not be able to Symbolicate the Exception and Grouping has the potential to mix Exceptions.

The Ideal Scenario is to Parse the Objective-C Exceptions with a new StackTraceProcessor for iOS by joining the C# StackTrace with the Native StackTrace.

For this to be possible, getsentry/sentry-dotnet#744 needs to be merged in order to filter the Instruction Addresses from the Native Exception.

##Notes

Regex Rule for filtering the StackTrace:
=> "(?<id>\\d+)\\s+(?<method>[a-zA-Z\\.-_?]+)\\s+(?<offset>0x[0-9a-fA-F]+)\\s+(?<function>.+?(?=\\s\\+))\\s+\\+\\s+(?<line>\\d+)";

Feat: New Image for the readme page.

During the Microsoft Xamarin Community Standup they presented this repository. It felt like the README could do a better job explaining what this SDK does and what Sentry is.

The idea is to show on a simple image What's Sentry and what it does once you use it with your code.

The SDK supports automatic navigation breadcrumbs and also device context information.
With that, I present you with this mockup
image

Sadly, I lack the skills for making this fancy so it would be nice if anyone could help to give this Paint image some Sentry image quality touch :D

System.AggregateException from Sentry assembly in Xamarin.Droid app

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?
Sentry.Xamarin 1.4.0

Steps to Reproduce

  1. Install Sentry.Xamarin in our Xamarin.Droid app
  2. Serve tens of thousands of users
  3. See random crashes coming out of Sentry.Xamarin itself

Expected Result

No crash should come from Sentry.Xamarin assemblies.

Actual Result

We're seeing this crash being reported in Sentry in our Xamarin.Droid app:

System.AggregateException
A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (No such host is known)
System.Net.Sockets.SocketException: No such host is known
  ?, in async ValueTask<ValueTuple<Socket, Stream>> ConnectHelper.ConnectAsync(string host, int port, CancellationToken cancellationToken)
System.Net.Http.HttpRequestException: No such host is known
  ?, in async ValueTask<ValueTuple<Socket, Stream>> ConnectHelper.ConnectAsync(string host, int port, CancellationToken cancellationToken)
  ?, in async ValueTask<ValueTuple<HttpConnection, HttpResponseMessage>> HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
  ?, in async ValueTask<ValueTuple<HttpConnection, HttpResponseMessage>> HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask<ValueTuple<HttpConnection, HttpResponseMessage>> creationTask)
  ?, in async Task<HttpResponseMessage> HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, bool doRequestAuth, CancellationToken cancellationToken)
  ?, in async Task<HttpResponseMessage> RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
  ?, in async Task<HttpResponseMessage> DecompressionHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
  ?, in async Task<HttpResponseMessage> GzipBufferedRequestBodyHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
  ?, in async Task<HttpResponseMessage> RetryAfterHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
  ?, in async Task<HttpResponseMessage> HttpClient.FinishSendAsyncBuffered(Task<HttpResponseMessage> sendTask, HttpRequestMessage request, CancellationTokenSource cts, bool disposeCts)
  ?, in async Task HttpTransport.SendEnvelopeAsync(Envelope envelope, CancellationToken cancellationToken)
  ?, in async Task CachingTransport.InnerProcessCacheAsync(string file, CancellationToken cancellation) x 2
  ?, in async Task CachingTransport.ProcessCacheAsync(CancellationToken cancellation)
  ?, in async Task CachingTransport.FlushAsync(CancellationToken cancellationToken)

Additionally we get this assembly information: Assembly:Sentry Version:3.16.0.0 Culture:neutral PublicKeyToken:fba2ec45388e2af0

Connectivity status

on my app I was registering the following tags:

  • connection.wifi [true/empty]
  • connection.bluetooth [true/empty]
  • connection.cellular [true/empty]
  • connection.ethernet [true/empty]
  • connection.unknown [true/empty]

@bruno-garcia should I add something like that to Sentry Xamarin?

Sentry.Xamarin.Forms not sending exception when application restarted on android

Environment

How do you use Sentry?
sentry.io

Which SDK and version?
Sentry.Xamarin.Forms 1.3.1

Steps to Reproduce

  1. Install Sentry.Xamarin.Forms to Android and core project
  2. Init in MainActivity.OnCreate
  3. Throw some dummy exception in one of the page.
  4. Application will crash
  5. Reopen the app

Expected Result

Exception should be sent to sentry when application restarted

Actual Result

Exception not sent to Sentry. I attach the stacktrace so it can help. My device Xiaomi Redmi 5A (API 27)
stacktrace.txt

Define custom page types to be ignored

I'm using a custom NavigationPage in my app. This means that Sentry logs my navigation page as a breadcrumb. I see that it is coded to ignore NavigationPage. It would be nice if I could specify other page types to ignore in the breadcrumb logging.

Going one step farther, it would be nice to specify a logging handler for the custom page types for further customization.

Offline caching prevents error reports from iOS app

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

SDK
Sentry.Xamarin 1.1.0

Device
iPhone 8, iOS 14.4.2

Steps to Reproduce

  1. Initialize SentryXamarin with the following options:
SentryXamarin.Init(o =>
{
    o.Dsn = AppSettings.Instance.SentryDsn;
    o.SendDefaultPii = false;
    o.AttachStacktrace = true;
    o.Debug = true;
};
  1. Throw nullexception in iOS app to verify Sentry has been initilalized.

Expected Result

Application crashes and an exception report is sent to Sentry.io console.

Actual Result

Application crashes but no exception report is sent to Sentry.io console.

Stacktrace

2021-06-23 10:14:20.495 Application.iOS[18946:3360565]    Info: Capturing event.
2021-06-23 10:14:20.506 Application.iOS[18946:3360565]   Debug: Running processor on exception: Sentry test ios
2021-06-23 10:14:20.511 Application.iOS[18946:3360565]   Debug: Creating SentryStackTrace. isCurrentStackTrace: False.
Loaded assembly: /private/var/containers/Bundle/Application/7564202E-DA49-4955-AA15-13553B0D241E/Application.iOS.app/System.Threading.Tasks.Extensions.dll
2021-06-23 10:14:20.538 Application.iOS[18946:3360565]   Debug: Running main event processor on: Event 2b66ec3e32584a4cb768e6fc88b670a6
2021-06-23 10:14:20.551 Application.iOS[18946:3360565]   Debug: Envelope queued up.
2021-06-23 10:14:20.551 Application.iOS[18946:3360565]    Info: Disposing the Hub.
2021-06-23 10:14:20.552 Application.iOS[18946:3360565]   Debug: Disposing SentryClient.
2021-06-23 10:14:20.552 Application.iOS[18946:3360565]   Debug: Disposing BackgroundWorker.
2021-06-23 10:14:20.554 Application.iOS[18946:3360622]   Debug: Storing file /var/mobile/Containers/Data/Application/C12643CF-4CE8-45C4-A3B0-BBACFDF281EC/Documents/Sentry/28CE05E461034F7F5AAEDE4C9F962FF60F06F79A/1624436060_-2717_2b66ec3e32584a4cb768e6fc88b670a6_-588163899.envelope.
2021-06-23 10:14:20.589 Application.iOS[18946:3360622]   Debug: Envelope 2b66ec3e32584a4cb768e6fc88b670a6 handed off to transport. #1 in queue.
2021-06-23 10:14:20.602 Application.iOS[18946:3360635]   Debug: Flushing cached envelopes.
2021-06-23 10:14:20.602 Application.iOS[18946:3360630]   Debug: Shutdown scheduled. Stopping by: 00:00:02. #0 in queue.
2021-06-23 10:14:20.602 Application.iOS[18946:3360630]    Info: Exiting the worker with an empty queue.
2021-06-23 10:14:20.604 Application.iOS[18946:3360635]   Debug: Reading cached envelope: /var/mobile/Containers/Data/Application/C12643CF-4CE8-45C4-A3B0-BBACFDF281EC/Documents/Sentry/28CE05E461034F7F5AAEDE4C9F962FF60F06F79A/__processing/1624436060_-2717_2b66ec3e32584a4cb768e6fc88b670a6_-588163899.envelope
2021-06-23 10:14:20.607 Application.iOS[18946:3360635]   Error: Failed to send cached envelope: System.Threading.Tasks.TaskCanceledException: A task was canceled.
  at Sentry.Internal.Extensions.StreamExtensions+<ReadAllBytesAsync>d__0.MoveNext () [0x000b7] in /_/src/Sentry/Internal/Extensions/StreamExtensions.cs:18 
  at Sentry.Internal.Extensions.StreamExtensions+<ReadAllBytesAsync>d__0.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult (System.Int16 token) <0x108b132e0 + 0x0005f> in <21de525d6d944e1892c9b758d850e8d6#f76cceb590763b94e6fe78680461b832>:0 
  at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:818 
  at Sentry.Protocol.Envelopes.Envelope.DeserializeHeaderAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x000a0] in /_/src/Sentry/Envelopes/Envelope.cs:140 
  at Sentry.Protocol.Envelopes.Envelope.DeserializeHeaderAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x0016b] in /_/src/Sentry/Envelopes/Envelope.cs:140 
  at Sentry.Protocol.Envelopes.Envelope.DeserializeAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x00032] in /_/src/Sentry/Envelopes/Envelope.cs:164 
  at Sentry.Internal.Http.CachingTransport.ProcessCacheAsync (System.Threading.CancellationToken cancellationToken) [0x0012c] in /_/src/Sentry/Internal/Http/CachingTransport.cs:176 
  at Sentry.Internal.Http.CachingTransport.ProcessCacheAsync (System.Threading.CancellationToken cancellationToken) [0x002e8] in /_/src/Sentry/Internal/Http/CachingTransport.cs:186 , retrying after a delay.
2021-06-23 10:14:20.607 Application.iOS[18946:3360635]   Debug: Background worker of CachingTransport has shutdown.
2021-06-23 10:14:20.607 Application.iOS[18946:3360565]   Debug: Disposing scope.
2021-06-23 10:14:20.607 Application.iOS[18946:3360565]   Debug: Disposing SentryScopeManager.

Workaround

Disable offline caching for iOS.

NullReferenceException in SentryXamarinFormsIntegration with slow Xamarin.Forms StartUp

Environment

Which SDK and version?
Sentry 3.0.7
Sentry.Xamarin.Forms 1.0.2

Steps to Reproduce

  1. Starting Xamarin.Forms uwp app
  2. Initalizing Xamarin.Forms takes a long time.
  3. Runs into NullReferenceException (see screenshot)
  4. App crashes

Forcing via Thread.Sleep for easy reproducing:

		protected override void OnLaunched(LaunchActivatedEventArgs e)
		{
			SentryXamarin.Init(options =>
			{
				options.Dsn = SENTRY_DSN;
				options.Release = Version.Major + "." + Version.Minor;
				options.SendDefaultPii = true;
				options.AddXamarinFormsIntegration();

			});

			System.Threading.Thread.Sleep(3000);

Expected Result

No Exception should be raised

Actual Result

See Exception screenshot:
error

Register() Method tries to call DiagnosticLogger, which is null, which causes the exception.

application is null, because start takes longer than 3000 ms in SentryXamarinFormsIntegration.cs:

        private async Task<Application> GetCurrentApplication()
        {
            for (int i = 0; i < 10 && Application.Current is null; i++)
            {
                await Task.Delay(300).ConfigureAwait(false);
            }
            return Application.Current;
        }

Possible Solutions:

  1. Run App on a faster computer ;-)

  2. Add a Timeout / loop setting for application start. maybe reduce delay and increase loop times.

  3. Add null check for call "options.DiagnosticLogger.Log()"

Workaround

Add options to Init:

	public class SentryLogger : IDiagnosticLogger
	{
		public bool IsEnabled(SentryLevel level)
		{
			return true;
		}

		public void Log(SentryLevel logLevel, string message, Exception exception = null, params object[] args)
		{
			Debug.WriteLine(message, args);
		}
	}


...
			SentryXamarin.Init(options =>
			{
				options.DiagnosticLogger = new SentryLogger();
				options.Debug = true;


...
			});

[BUG] The package is not compatible

Environment

How do you use Sentry?
sentry.io

Which SDK and version?
Sentry.Xamarin.Forms 1.3.1

Steps to Reproduce

  1. I went to the nuget store
  2. Clicked install on Sentry.Xamarin.Forms

Expected Result

The nuget package should be installed.

Actual Result

This works for Xamarin.Droid and Xamarin.iOS but when I try to do it in Portable it doesn't work. It gives me the error

Severity Code Description Project File Line Suppression State
Error NU1202 Package Sentry.Xamarin.Forms 1.3.1 is not compatible with portable45-net45+win8+wp8+wpa81 (.NETPortable,Version=v4.5,Profile=Profile259) / win10-arm-aot. Package Sentry.Xamarin.Forms 1.3.1 supports: netstandard2.0 (.NETStandard,Version=v2.0) RecrutoStaff C:\Recruto Projects\recruto-staff\RecrutoStaff\RecrutoStaff.csproj 1

What am I doing wrong?

MissingMethodException throws when Capture any event

Any ideas why this is happening? If i tried sentry on a completely new app, it's not an issue, but when i used it in my app , this is what happened when trying to send a message

Environment

Which SDK and version?
Sentry.Xamarin 1.0.3
Refit 5.2.4 (i don't know if this is related but this package have a reference to System.Text.Json as well)

Steps to Reproduce

Just Init in my app and attempt to send a message

Expected Result

Should not throw this excpetion

Actual Result

Error: Failed to send cached envelope: System.MissingMethodException: Method not found: System.Text.Json.JsonDocument System.Text.Json.JsonDocument.Parse(System.ReadOnlyMemory`1,System.Text.Json.JsonDocumentOptions)
at Sentry.Protocol.Envelopes.Envelope.DeserializeHeaderAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x001a1] in //src/Sentry/Envelopes/Envelope.cs:152
at Sentry.Protocol.Envelopes.Envelope.DeserializeAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken) [0x00032] in /
/src/Sentry/Envelopes/Envelope.cs:164
at Sentry.Internal.Http.CachingTransport.ProcessCacheAsync (System.Threading.CancellationToken cancellationToken) [0x00117] in /_/src/Sentry/Internal/Http/CachingTransport.cs:173 , discarding cached envelope.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.