Use Prism logging & regions
If your app uses the Prism 10 preview, keep its existing logging and Region navigation calls. Add the corresponding adapter after initializing AppPortal in native startup. Each adapter uses that same client; it does not need another credential or runtime. Prism is an optional integration. Keep direct SDK usage for non-Prism applications and background work that has no Prism container. Native startup and the host consent policy stay separate from logging/provider registration.
Send existing Prism logs to AppPortal
For AppPortal Telemetry 3.0.384, enable NuGet.org for the AppPortal adapter and your
Prism preview source for Prism.Plugin.Logging.Abstractions 10.0.165-pre or later.
dotnet add package AppPortal.Telemetry.Prism.Logging --version "3.0.384"
Add the provider during your existing Prism container registration:
using Prism.Plugin.Logging;
containerRegistry.UsePrismLogging(logging => logging.AddAppPortal());
Prism’s Log, TrackEvent, and Report calls now send structured logs, events, and handled
exceptions to AppPortal. SetUser and ClearUser update identity; BeginScope adds properties.
Calls made before AppPortal starts are safe no-ops. Collection still follows the app’s consent.
Inject Prism’s logger into an application service or view model. For example:
using Prism.Plugin.Logging;
public sealed class CatalogActions(ILogger<CatalogActions> logger)
{
public void SignedIn(string userId) => logger.SetUser(userId);
public void SignedOut() => logger.ClearUser();
public void ItemSaved(string itemId)
{
logger.Info("Item saved", new Dictionary<string, string> { ["itemId"] = itemId });
logger.TrackEvent("item.saved", new Dictionary<string, string> { ["quantity"] = "1" });
}
public void SaveFailed(Exception error) => logger.Report(error);
}
Register CatalogActions with your Prism container. This service needs no AppPortal client,
credential, startup code, or application wrapper; its logs, events, errors and identity changes
all go through Prism. Native initialization and the host’s consent settings still run before it.
The adapter forwards your application’s user identifier unchanged; no additional profile fields or direct AppPortal identification call are required.
After normal SDK startup with consent granted, set the user through Prism before logging that
user’s work. Each record retains the identity present when it was captured. Changing or clearing
the user does not rewrite queued records, earlier events, or the session’s launch identity. The
portal associates later users with the session through subsequent events, logs, errors, and RUM;
SetUser alone does not send a sign-in record.
As edge behavior, calls made before SDK startup are discarded. Identity calls before a grant request are ignored, and granting consent does not retroactively identify quarantined records. Apply the current user again through Prism after the host’s consent policy permits identification. If native cleanup is still running, a user request immediately after the host’s grant request is ordered behind that grant. A later reset or revocation invalidates the pending request. Restriction also invalidates user/profile state in scopes flowed to other execution contexts, so an old scope cannot restore the previous user after regrant.
Report captures the SDK’s observed foreground state and occurrence time with the exception.
Startup before the first visible activity/window and background errors report wasInForeground=false.
The application does not need to pass visibility or forward lifecycle events to Prism.
The adapter automatically adds finite numeric event parameters as measurements while preserving the original string properties. For example:
logger.TrackEvent("sale.completed", new Dictionary<string, string>
{
["amount"] = "19.95",
["quantity"] = "2",
["terminalCode"] = "00042"
});
amount and quantity become measurements. Leading-zero codes remain strings. Parsing is
culture-independent; non-finite values, localized formats and unsafe integer ranges are not inferred.
Scope/global metadata and caller information are excluded. SDK property redaction also removes its
derived measurement, so no direct AppPortal event call or application wrapper is needed.
Internal SDK warnings/errors are forwarded to the other Prism logging providers with bounded buffering and recursion protection. Applications do not need a custom diagnostic sink or message cap. Each resolved logger has its own service/screen scopes. Disposing a scope removes its properties while other loggers keep their scopes. The container owns one diagnostics subscription; disposing the container disables its retained AppPortal providers without stopping the native SDK owner.
Register the provider once. If your app already captures the same handled exceptions elsewhere,
set EnableErrorTracking = false in the options passed to AddAppPortal to avoid duplicates.
Observe Prism Region navigation RUM
Use this adapter when Prism Regions own navigation. It does not cover Prism MAUI page-stack navigation, dialogs, or Avalonia-specific lifecycle and navigation.
Enable your Prism preview source for Prism.Core 10.0.195-pre or later.
dotnet add package AppPortal.Telemetry.Prism.Navigation --version "3.0.384"
After the container is built, opt in once. The adapter registers its services and the Prism
container owns the observation lifetime. A single-region app can use
containerProvider.ObserveAppPortalNavigation().
For several regions, map the names from your own app:
using Prism.Ioc;
containerProvider.ObserveAppPortalNavigation(options => options
.PrimaryRegion(RegionNames.Content)
.SecondaryRegion(RegionNames.Detail)
.OverlayRegion(RegionNames.Modal)
.IgnoreRegion(RegionNames.Chrome));
Retain the returned handle only when the observation needs to stop before the container is disposed. Region roles determine how navigation relates to the current screen:
| Role | Result |
|---|---|
| Primary | Updates the current screen and records a screen event |
| Secondary | Records navigation alongside the primary screen |
| Overlay | Records navigation without replacing the primary screen |
| Ignored | Emits no navigation telemetry |
The observer records navigation events and failures. It emits measured ScreenLoad timing
when it saw the start of the navigation; attaching midway does not invent a duration. The timing
ends at Region navigation completion, so measure deferred data loading separately.
Duplicate notifications for the same Prism navigation context are ignored. A failure during
confirmation or content loading can precede Navigating; it is retained without inventing a
start time or duration.
Observable Regions exposes a Failed notification rather than a separate cancellation result.
The current adapter records a sanitized handled failure for that notification, including when
Prism supplies no exception. This differs from Shell’s explicit cancellation signal. Navigation
breadcrumbs are buffered locally; they are not delivered with crashes. Use logs
for a visible diagnostic trail in the portal.
Keep names useful and capture each flow once
Registered view names, region names, roles, and outcomes are recorded. Navigation parameters,
query strings, URI fragments, dialog input, and exception messages are excluded. Use
options.MapTargetName to map registered view names to stable product names, or return null to
suppress a view.
For a path owned by Prism Regions, attach only the Prism observer. Observing that same path with
both Prism and the MAUI or
Uno Frame adapter would double-count it.
MAUI registers visible-page tracking automatically with UseAppPortal(). For the same primary
path, use its navigation options to ignore the page and shell surfaces; see the linked MAUI
example. A separate native navigation host can have its own observer.
Continue with meaningful events and error reporting in shared app code.