Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 9 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ jobs:
-r osx-arm64 \
-p:CreatePackage=false \
-p:AppVersion=${{ steps.version.outputs.app_version }} \
-p:AppCommitSha=${{ steps.version.outputs.commit_sha }}
-p:AppCommitSha=${{ steps.version.outputs.commit_sha }} \
-p:SentryDsn=${{ secrets.SENTRY_DSN }}

- name: Publish macOS App (x64)
run: |
Expand All @@ -161,7 +162,8 @@ jobs:
-r osx-x64 \
-p:CreatePackage=false \
-p:AppVersion=${{ steps.version.outputs.app_version }} \
-p:AppCommitSha=${{ steps.version.outputs.commit_sha }}
-p:AppCommitSha=${{ steps.version.outputs.commit_sha }} \
-p:SentryDsn=${{ secrets.SENTRY_DSN }}

- name: Create universal binary
run: |
Expand Down Expand Up @@ -439,7 +441,8 @@ jobs:
-p:WindowsAppSDKSelfContained=true `
--self-contained true `
-p:AppVersion=${{ steps.version.outputs.app_version }} `
-p:AppCommitSha=${{ steps.version.outputs.commit_sha }}
-p:AppCommitSha=${{ steps.version.outputs.commit_sha }} `
-p:SentryDsn=${{ secrets.SENTRY_DSN }}

- name: Publish Windows App (arm64)
run: |
Expand All @@ -451,7 +454,8 @@ jobs:
-p:WindowsAppSDKSelfContained=true `
--self-contained true `
-p:AppVersion=${{ steps.version.outputs.app_version }} `
-p:AppCommitSha=${{ steps.version.outputs.commit_sha }}
-p:AppCommitSha=${{ steps.version.outputs.commit_sha }} `
-p:SentryDsn=${{ secrets.SENTRY_DSN }}

- name: Create ZIP archives
run: |
Expand Down Expand Up @@ -583,6 +587,7 @@ jobs:
--disable-build-servers \
-p:AppVersion=${{ steps.version.outputs.app_version }} \
-p:AppCommitSha=${{ steps.version.outputs.commit_sha }} \
-p:SentryDsn=${{ secrets.SENTRY_DSN }} \
-p:UseSharedCompilation=false \
-nodeReuse:false \
-maxcpucount:1 \
Expand Down
11 changes: 11 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@
<AppVersion>0.8.1</AppVersion>
<AppCommitSha>dev</AppCommitSha>
<InformationalVersion>$(AppVersion)+$(AppCommitSha)</InformationalVersion>

<!-- Sentry DSN — CI injects via -p:SentryDsn=... (pulled from a secret).
When empty, Sentry is not initialized at runtime. -->
<SentryDsn Condition="'$(SentryDsn)' == ''"></SentryDsn>
</PropertyGroup>

<!-- Bake SentryDsn into the assembly as metadata when provided. The app
reads this attribute at startup to configure Sentry without keeping
the DSN in source. -->
<ItemGroup Condition="'$(SentryDsn)' != ''">
<AssemblyMetadata Include="SentryDsn" Value="$(SentryDsn)" />
</ItemGroup>

<!-- Override vulnerable transitive System.Data.SqlClient pulled in by AzDo SDK -->
<ItemGroup>
<PackageReference Include="System.Data.SqlClient" Version="4.9.1" />
Expand Down
1 change: 1 addition & 0 deletions src/MauiSherpa.LinuxGtk/MauiSherpa.LinuxGtk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<PackageReference Condition="!Exists('$(HOME)/code/Maui.Gtk/src/Platform.Maui.Linux.Gtk4.Essentials/Platform.Maui.Linux.Gtk4.Essentials.csproj')" Include="Platform.Maui.Linux.Gtk4.Essentials" Version="0.6.0" />
<PackageReference Include="Redth.MauiDevFlow.Agent.Gtk" Version="0.23.0" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Redth.MauiDevFlow.Blazor.Gtk" Version="0.23.0" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Sentry.Maui" Version="6.4.0" />
<PackageReference Include="Shiny.Mediator.Caching.MicrosoftMemoryCache" Version="6.1.1" />
<PackageReference Include="Shiny.Mediator.Maui" Version="6.1.1" />
</ItemGroup>
Expand Down
23 changes: 23 additions & 0 deletions src/MauiSherpa.MacOS/MacOSMauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Maui.Platform.MacOS.Handlers;
using Microsoft.Maui.Essentials.MacOS;
using Shiny.Mediator;
using Sentry.Maui;
#if DEBUG
using MauiDevFlow.Agent;
using MauiDevFlow.Blazor;
Expand All @@ -33,6 +34,28 @@ public static MauiApp CreateMauiApp()
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

// Sentry — DSN is injected at build time via -p:SentryDsn=... (see Directory.Build.props).
// When no DSN is configured (e.g. local dev without the env var), Sentry is skipped.
var sentryDsn = SentryConfig.GetDsn();
if (!string.IsNullOrWhiteSpace(sentryDsn))
{
builder.UseSentry(options =>
{
options.Dsn = sentryDsn;
options.TracesSampleRate = 1.0;
options.EnableLogs = true;
#if DEBUG
options.Debug = true;
options.Environment = "debug";
#else
options.Environment = "release";
#endif
options.Release = typeof(MacOSMauiProgram).Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion;
});
}

// Use native sidebar for FlyoutPage
builder.ConfigureMauiHandlers(handlers =>
{
Expand Down
1 change: 1 addition & 0 deletions src/MauiSherpa.MacOS/MauiSherpa.MacOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="10.0.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="10.0.31" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.0" />
<PackageReference Include="Sentry.Maui" Version="6.4.0" />
<PackageReference Include="Shiny.Mediator.Caching.MicrosoftMemoryCache" Version="6.1.1" />
<PackageReference Include="Shiny.Mediator.Maui" Version="6.1.1" />
<PackageReference Include="Redth.MauiDevFlow.Agent" Version="0.23.0" Condition="'$(Configuration)' == 'Debug'" />
Expand Down
23 changes: 23 additions & 0 deletions src/MauiSherpa/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using MauiIcons.FontAwesome.Brand;
#endif
using Shiny.Mediator;
using Sentry.Maui;

namespace MauiSherpa;

Expand Down Expand Up @@ -53,6 +54,28 @@ public static MauiApp CreateMauiApp()
});
#endif

// Sentry — DSN is injected at build time via -p:SentryDsn=... (see Directory.Build.props).
// When no DSN is configured (e.g. local dev without the env var), Sentry is skipped.
var sentryDsn = SentryConfig.GetDsn();
if (!string.IsNullOrWhiteSpace(sentryDsn))
{
builder.UseSentry(options =>
{
options.Dsn = sentryDsn;
options.TracesSampleRate = 1.0;
options.EnableLogs = true;
#if DEBUG
options.Debug = true;
options.Environment = "debug";
#else
options.Environment = "release";
#endif
options.Release = typeof(MauiProgram).Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion;
});
}

#if LINUXGTK
builder.Services.AddBlazorWebView();
builder.Services.AddLinuxGtk4BlazorWebView();
Expand Down
1 change: 1 addition & 0 deletions src/MauiSherpa/MauiSherpa.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="10.0.0" />
<PackageReference Include="Redth.MauiDevFlow.Agent" Version="0.23.0" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Redth.MauiDevFlow.Blazor" Version="0.23.0" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Sentry.Maui" Version="6.4.0" />
<PackageReference Include="Shiny.Mediator.Caching.MicrosoftMemoryCache" Version="6.1.1" />
<PackageReference Include="Shiny.Mediator.Maui" Version="6.1.1" />
</ItemGroup>
Expand Down
27 changes: 27 additions & 0 deletions src/MauiSherpa/Services/SentryConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Reflection;

namespace MauiSherpa.Services;

/// <summary>
/// Resolves the Sentry DSN without hardcoding it in source.
/// Resolution order:
/// 1. SENTRY_DSN environment variable (useful for local development)
/// 2. Assembly metadata "SentryDsn" (baked in by CI via -p:SentryDsn=... in Directory.Build.props)
/// Returns null when neither is set, in which case Sentry should not be initialized.
/// </summary>
internal static class SentryConfig
{
public static string? GetDsn()
{
var fromEnv = Environment.GetEnvironmentVariable("SENTRY_DSN");
if (!string.IsNullOrWhiteSpace(fromEnv))
return fromEnv.Trim();

var fromAssembly = typeof(SentryConfig).Assembly
.GetCustomAttributes<AssemblyMetadataAttribute>()
.FirstOrDefault(a => string.Equals(a.Key, "SentryDsn", StringComparison.Ordinal))
?.Value;

return string.IsNullOrWhiteSpace(fromAssembly) ? null : fromAssembly.Trim();
}
}
Loading