Skip to content

Commit

Permalink
chore: update essentials and logging docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Oct 15, 2024
1 parent d01eabf commit 023ce30
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"cSpell.words": [
"MVVM"
"MVVM",
"Xunit"
]
}
47 changes: 47 additions & 0 deletions docs/plugins/essentials/appcontext.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,50 @@ uid: Plugins.Essentials.AppContext
---

# AppContext

The default implementation of the `IAppContext` interface is available by registering Prism Essentials or by specifically Registering the AppContext.

```cs
containerRegistry.UsePrismEssentials();

// OR Specifically
containerRegistry.RegisterAppContext();
```

## API

```cs
public interface IAppContext
{
string PackageName { get; }

string Name { get; }

string VersionString { get; }

Version Version { get; }

string BuildString { get; }

void ShowSettingsUI();

AppTheme RequestedTheme { get; }

AppPackagingModel PackagingModel { get; }

LayoutDirection RequestedLayoutDirection { get; }
}
```

## Read the app information

The IAppContext interface exposes the following properties:

- Name — The application name.
- PackageName — The package name or application identifier, such as com.prismlibrary.myapp.
- VersionString — The application version, such as 1.0.0.
- Version — The application version, as a Version object.
- BuildString — The build number of the version, such as 1000.
- RequestedTheme — The detected theme of the system or application.
- PackagingModel — The packaging model of the application.
- RequestedLayoutDirection — The requested layout direction of the system or application.
5 changes: 5 additions & 0 deletions docs/plugins/essentials/battery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
uid: Plugins.Essentials.Battery
---

# Battery
13 changes: 13 additions & 0 deletions docs/plugins/essentials/connectivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ uid: Plugins.Essentials.Connectivity
---

# Connectivity

## API

```cs
public interface IConnectivity
{
IEnumerable<ConnectionProfile> ConnectionProfiles { get; }

NetworkAccess NetworkAccess { get; }

IObservable<ConnectionState> State();
}
```
25 changes: 22 additions & 3 deletions docs/plugins/essentials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,26 @@ Prism.Plugin.Essentials is built around the idea that you should be able to have

The API is generally inspired by a combination of Xamarin/.NET MAUI Essentials and in the case of the [Stores](xref:Plugins.Essentials.Stores) is inspired by one of our favorite libraries [Shiny.NET](https://shinylib.net).

# [.NET MAUI](#tab/maui)
## [Xamarin.Forms](#tab/forms)

Be sure to install `Prism.Plugin.Essentials.Forms`

In PrismApplication be sure to add the following registration.

```cs
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.UsePrismEssentials();
}
```

For Android be sure to add the following to the native Android Application

```cs
Prism.Plugin.Essentials.Platform.CurrentActivity.Init(this);
```

## [.NET MAUI](#tab/maui)

Be sure to install `Prism.Plugin.Essentials.Maui`

Expand All @@ -17,7 +36,7 @@ builder.UseMauiApp<App>()
.UsePrism(prism => prism.UsePrismEssentials())
```

# [WPF](#tab/wpf)
## [WPF](#tab/wpf)

Be sure to install `Prism.Plugin.Essentials.Wpf`

Expand All @@ -28,7 +47,7 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
}
```

# [Uno Platform](#tab/uno-platform)
## [Uno Platform](#tab/uno-platform)

Be sure to install `Prism.Plugin.Essentials.Uno.WinUI`

Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/essentials/permissions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
uid: Plugins.Essentials.MainThread
uid: Plugins.Essentials.Permissions
---

# App Permissions
Expand Down
10 changes: 5 additions & 5 deletions docs/plugins/logging/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
uid: Plugins.Logging
---

# Prism.Plugin.Logging

Available now to Commercial Plus license holders on the Prism NuGet feed.
Expand Down Expand Up @@ -160,11 +164,7 @@ For more information see the [Microsoft.Extensions.Logging Interoperability docs

### Raygun

```cs
containerRegistry.UsePrismLogging(logging => {
logging.AddRaygun("RaygunApiKey");
});
```
For more information see the [Prism Logging docs for Raygun](xref:Plugins.Logging.Raygun).

### Sentry

Expand Down
4 changes: 4 additions & 0 deletions docs/plugins/logging/microsoft.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
uid: Plugins.Logging.Microsoft
---

# Microsoft.Extensions.Logging Interop

We recognize that your apps (particularly .NET MAUI and Uno Platform), may have logging that occurs internally using Microsoft.Extensions.Logging. For this reason we've taken the time to put together a logging adapter that allows the logging output from the Microsoft.Extensions.Logging.ILogger to be passed through to the configured Prism Logging Providers that you have in your application. While the exact code may vary
Expand Down
55 changes: 55 additions & 0 deletions docs/plugins/logging/raygun.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
uid: Plugins.Logging.Raygun
---

# Prism Logging with Raygun

Raygun is a platform that offers analytics about managed and unmanaged exceptions within your app as well as user tracking.

```cs
containerRegistry.UsePrismLogging(logging => {
logging.AddRaygun("RaygunApiKey");
});
```

## Local Development &amp; Debugging

Raygun offers a free Open Source version for Crash Detection that can be run in a local environment. For more information see the [Raygun Documentation](https://raygun.com/documentation/product-guides/crash-reporting/local-docker-setup/).

To get started you can copy the following docker compose sample. You can set the localpath for the volumes to persist the crash data over time and ensure that the downloaded Ollama models are persisted and do not need to be downloaded again.

```docker
version: '3.8'
services:
raygun-aspire-portal:
image: raygunowner/raygun-aspire-portal:latest
container_name: raygun_local_dev
environment:
- ConnectionStrings__Ollama=http://ollama-service:11434
ports:
- "8080:8080"
restart: always
volumes:
- /localpath/raygun/errors:/app/raygun/errors
depends_on:
- ollama-service # Ensure Ollama service starts before this container
ollama-service:
image: ollama/ollama:latest
container_name: ollama_local_aier
restart: always
volumes:
- /localpath/ollama:/root/.ollama # Mount local directory to container for data persistence
```

To use Raygun for local development with your Docker image, you can use the special extension as shown below:

```cs
container.UsePrismLogging(logging =>
logging.AddLocalRaygun("http://192.168.1.11:8080/Ingestion/Entries"));
```

## Prism.Essentials Integration

The Raygun Implementation of the Logger makes reference to the [Prism.Plugin.Essentials](xref:Plugins.Essentials.GettingStarted) library. This allows us to dynamically check if various Essentials interfaces have been registered. If they have we automatically tailor the Logger to include offline support with request caching. Additionally we will automatically update the configuration to make use of the [Application Context](xref:Plugins.Essentials.AppContext) from Essentials.
2 changes: 1 addition & 1 deletion docs/plugins/logging/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
- name: Microsoft Extensions
href: microsoft.md
- name: Unit Testing
href: unit-testing.md
href: testing.md

0 comments on commit 023ce30

Please sign in to comment.