Skip to content
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

[PS-97]: Extend RaygunEnvironmentMessage to add Maui specific information. #4

Merged
merged 23 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2debfb1
Extended RaygunEnvironmentMessage to add Maui specific information.
Hamish-taylor May 8, 2023
98973e9
Added some Android specific initialisation. Added NativeDeviceInfo class
Hamish-taylor May 8, 2023
8b0d1e9
Added Android and iOS specific device information.
Hamish-taylor May 8, 2023
5a234b6
Added Mac specific device info.
Hamish-taylor May 8, 2023
49380f9
Removed unused android imports.
Hamish-taylor May 8, 2023
d36a392
Renamed RaygunClientTest to RaygunClient.
Hamish-taylor May 9, 2023
32b4ffc
Bumped the version number.
Hamish-taylor May 9, 2023
736a7a1
Updated Readme slightly for new release information.
Hamish-taylor May 9, 2023
b73e7c1
Added Windows specific memory information.
Hamish-taylor May 9, 2023
a03b4bb
Added section to read me about device names on iOS.
Hamish-taylor May 9, 2023
9751f2c
Added conversions of apple device codes to model names.
Hamish-taylor May 10, 2023
d26ae3a
Added source
Hamish-taylor May 10, 2023
4c2c4df
Minor spelling/grammar changes
Hamish-taylor May 10, 2023
cc9db0d
Changed version number in nuget install instruction
Hamish-taylor May 10, 2023
bfa5bb1
Removed some un-nessesary imports
Hamish-taylor May 10, 2023
e40d353
Removed device id conversion as this is done on the frontend
Hamish-taylor May 10, 2023
152501c
merged RaygunClient into RaygunMauiClient
Hamish-taylor May 10, 2023
57a3bcf
Added specific information on the memory values collected.
Hamish-taylor May 10, 2023
3304552
Removed comment
Hamish-taylor May 10, 2023
3316644
Added test project
Hamish-taylor May 10, 2023
fe5da21
Minor readme updates
Hamish-taylor May 11, 2023
5837eb3
updated table
Hamish-taylor May 11, 2023
dbf3c88
Fixed table rendering
Hamish-taylor May 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Raygun's Crash Reporting provider for .NET MAUI

### Step 1 - Install Raygun4Maui

#### Nuget Package manager
#### NuGet Package manager
The best way to install Raygun is to use the NuGet package manager. Right-click on your project and select "**Manage NuGet Packages....**". Navigate to the Browse tab, then use the search box to find **Raygun4Maui** and install it.

#### .NET Cli
Expand All @@ -16,9 +16,9 @@ To install the latest version:
dotnet add package Raygun4Maui
```

Alternatively you can specify a version tag to install a specific version of the package, see [Raygun4Maui NuGet Gallery page](https://nuget.org/packages/Raygun4Maui) for information of versions.
Alternatively, you can specify a version tag to install a specific version of the package. See [Raygun4Maui NuGet Gallery page](https://nuget.org/packages/Raygun4Maui) for information on available versions.
```
dotnet add package Raygun4Maui --version 1.0.0
dotnet add package Raygun4Maui --version 1.2.1
```

### Step 2 - Add Raygun4Maui to your MauiApp builder
Expand Down Expand Up @@ -54,10 +54,10 @@ To use these additional configurations, create and initialize a new `RaygunMauiS
``` csharp
Raygun4MauiSettings raygunMauiSettings = new Raygun4MauiSettings {
ApiKey = "paste_your_api_key_here",
SendDefaultTags = true, // Default value
SendDefaultCustomData = true, // Default value
MinLogLevel = LogLevel.Debug, // Default value
MaxLogLevel = LogLevel.Critical // Default value
SendDefaultTags = true, // defaults to true
SendDefaultCustomData = true, // defaults to true
MinLogLevel = LogLevel.Debug, // defaults to true
MaxLogLevel = LogLevel.Critical // defaults to true
};
```

Expand All @@ -76,17 +76,17 @@ builder

Unhandled exceptions will be sent to Raygun automatically.

Raygun4Maui stores an instance of a [Raygun4Net](https://github.com/MindscapeHQ/raygun4net/tree/master/Mindscape.Raygun4Net.NetCore). `RaygunClient` object, this can be accessed through the following code:
Raygun4Maui stores an instance of a `RaygunClient` object, this can be accessed through the following code:
``` csharp
RaygunMauiClient.Current
```

Any features supported by the Raygun4Net Client are accessible here
This client extends the Raygun4Net.NetCore `RaygunClient`, as a result any features supported by the Raygun4Net.NetCore Client are supported here.

---

### Manually sending exceptions
Raygun4Maui automatically sends unhandled exceptions. For manual sending, use Send or SendInBackground methods, as shown below:
Raygun4Maui automatically sends unhandled exceptions. For manual sending, use `Send` or `SendInBackground` methods, as shown below:

``` csharp
try {
Expand All @@ -101,26 +101,26 @@ try {
An exception needs to be thrown in order for its stack trace to be populated. If the exception is created manually no stack trace data is collected.

### Other examples
For aditional examples on how to use the Raygun4Net client object refer to its deticated instructions [here](https://github.com/MindscapeHQ/raygun4net/tree/master/Mindscape.Raygun4Net.NetCore)

For additional examples on how to use the `RaygunClient` object refer to the [Raygun4Net.NetCore documentation](https://raygun.com/documentation/language-guides/dotnet/crash-reporting/net-core/)
## ILogger logging
Raygun4Maui will automatically send any logger logs to Raygun.

To make a log entry, acquire the reference to the ILogger services that your MAUI app maintains:
To make a log entry, obtain the reference to the ILogger services that your MAUI app maintains:

``` c#
``` csharp
ILogger logger = Handler.MauiContext.Services.GetService<ILogger<MainPage>>();
```

You may now invoke the various ILogger log methods from the logger object accordingly. This uses the same `RaygunClient` object accessible from RaygunMauiClient.Current
You may now use the appropriate ILogger log method from the logger object. This uses the same `RaygunClient` object accessible from `RaygunMauiClient.Current`

```c#
```csharp
logger.LogInformation("Raygun4Maui.SampleApp.TestLoggerErrorsSent: {MethodName} @ {Timestamp}", "TestLogInformation", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
logger.LogCritical("Raygun4Maui.SampleApp.TestLoggerErrorsSent: {MethodName} @ {Timestamp}", "TestLogCritical", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
```

With this functionality, you can also manually catch-and-log exceptions as follows:
This functionality also allows you to manually catch and log exceptions as shown below:

``` c#
``` csharp
try {
// Code that throws exception
} catch (Exception e) {
Expand All @@ -130,7 +130,10 @@ try {
```

---
## Platform specific information
Raygun4Maui will automatically collect information specific to the environment the application is being run in. However, on iOS, Raygun4Maui cannot obtain the devices name. This is a privacy restriction put in place by Apple. If you would like this information to be collected and sent with crash reports you will have to [request for permission from apple](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_device-information_user-assigned-device-name?language=objc).

---
## Development Instructions

### To build a local nuget package
Expand Down
12 changes: 5 additions & 7 deletions Raygun4Maui.SampleApp/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Microsoft.Extensions.Configuration;
using Raygun4Maui;

namespace Raygun4Maui.SampleApp;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
public static MauiApp CreateMauiApp()
{
var configuration = new ConfigurationBuilder()
.AddUserSecrets<MainPage>()
.Build();
Expand All @@ -22,8 +21,7 @@ public static MauiApp CreateMauiApp()
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
}).AddRaygun4Maui(apiKey) ;

return builder.Build();
}
}).AddRaygun4Maui(apiKey);
return builder.Build();
}
}
5 changes: 4 additions & 1 deletion Raygun4Maui.SampleApp/Raygun4Maui.SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Raygun4Maui" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Raygun4Maui\Raygun4Maui.csproj" />
</ItemGroup>

</Project>
40 changes: 0 additions & 40 deletions Raygun4Maui.Tests/Raygun4Maui.Tests.csproj

This file was deleted.

12 changes: 0 additions & 12 deletions Raygun4Maui.Tests/TestRaygun4MauiSettings.cs

This file was deleted.

1 change: 0 additions & 1 deletion Raygun4Maui.Tests/Usings.cs

This file was deleted.

Loading