-
-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathMauiProgram.cs
More file actions
45 lines (36 loc) · 1.84 KB
/
Copy pathMauiProgram.cs
File metadata and controls
45 lines (36 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using Exceptionless.Logging;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Maui.Storage;
namespace Exceptionless.SampleMaui;
public static class MauiProgram {
private const string DefaultApiKey = "LhhP1C9gijpSKCslHHCvwdSIz298twx271nTest";
private const string DefaultServerUrl = "https://ex.dev.localhost:7111";
public static MauiApp CreateMauiApp() {
var builder = MauiApp.CreateBuilder();
var exceptionlessClient = CreateExceptionlessClient();
builder
.UseMauiApp<App>();
builder.Services.AddSingleton(exceptionlessClient);
builder.Services.AddSingleton<SampleEventService>();
builder.Services.AddSingleton<SampleDogfoodRunner>();
builder.Services.AddSingleton<MainPage>();
return builder.Build();
}
private static ExceptionlessClient CreateExceptionlessClient() {
string appDataDirectory = FileSystem.Current.AppDataDirectory;
var client = new ExceptionlessClient(config => {
config.ApiKey = Environment.GetEnvironmentVariable("EXCEPTIONLESS_API_KEY") ?? DefaultApiKey;
config.ServerUrl = Environment.GetEnvironmentVariable("EXCEPTIONLESS_SERVER_URL") ?? DefaultServerUrl;
config.IncludePrivateInformation = false;
config.DefaultTags.Add("maui");
config.DefaultTags.Add("sample");
config.DefaultData["Platform"] = DeviceInfo.Current.Platform.ToString();
config.DefaultData["DeviceIdiom"] = DeviceInfo.Current.Idiom.ToString();
config.SetVersion(AppInfo.Current.VersionString);
config.UseFolderStorage(Path.Combine(appDataDirectory, "exceptionless-queue"));
config.UseFileLogger(Path.Combine(appDataDirectory, "exceptionless-client.log"), LogLevel.Info);
});
client.Startup();
return client;
}
}