From 25845ba559a9f0ddc4d243d938f44d569fa4014b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Schultz=20Madsen?= Date: Wed, 30 Sep 2026 14:11:56 +0200 Subject: [PATCH] chore: declare the Sentry DSN as assembly metadata The API host is getting one host-owned Sentry hub that continues the frontend trace and routes each plugin's error events to the plugin's own Sentry project. It finds that project through the SentryDsn assembly metadata on the plugin assembly. Declare the existing DSN as AssemblyMetadata in the csproj and let the plugin's own SentrySdk.Init read it from there, so the value lives in one place. No behaviour change: same DSN, same options, Init stays. If the metadata is missing the plugin skips its Init rather than failing at startup. closes #1438 Co-Authored-By: Claude Opus 5.5 --- .../Workflow.Pn/EformWorkflowPlugin.cs | 48 +++++++++++-------- .../Workflow.Pn/Workflow.Pn.csproj | 4 ++ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn/EformWorkflowPlugin.cs b/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn/EformWorkflowPlugin.cs index 2ec7d43..c2b19c5 100644 --- a/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn/EformWorkflowPlugin.cs +++ b/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn/EformWorkflowPlugin.cs @@ -100,28 +100,38 @@ public void ConfigureOptionsServices(IServiceCollection services, IConfiguration configuration.GetSection("WorkflowBaseSettings")); } + // Declared once, as in the csproj: the API host reads the + // same assembly metadata to route this plugin's events to its own Sentry project. + private static string SentryDsn => + typeof(EformWorkflowPlugin).Assembly + .GetCustomAttributes() + .FirstOrDefault(x => x.Key == "SentryDsn")?.Value; + public void ConfigureDbContext(IServiceCollection services, string connectionString) { - SentrySdk.Init(options => + if (!string.IsNullOrWhiteSpace(SentryDsn)) { - // A Sentry Data Source Name (DSN) is required. - // See https://docs.sentry.io/product/sentry-basics/dsn-explainer/ - // You can set it in the SENTRY_DSN environment variable, or you can set it in code here. - options.Dsn = "https://80b935299e69fe24c21043140b62f2ab@o4506241219428352.ingest.us.sentry.io/4508266849501184"; - - // When debug is enabled, the Sentry client will emit detailed debugging information to the console. - // This might be helpful, or might interfere with the normal operation of your application. - // We enable it here for demonstration purposes when first trying Sentry. - // You shouldn't do this in your applications unless you're troubleshooting issues with Sentry. - options.Debug = false; - - // This option is recommended. It enables Sentry's "Release Health" feature. - options.AutoSessionTracking = true; - - // This option is recommended for client applications only. It ensures all threads use the same global scope. - // If you're writing a background service of any kind, you should remove this. - options.IsGlobalModeEnabled = true; - }); + SentrySdk.Init(options => + { + // A Sentry Data Source Name (DSN) is required. + // See https://docs.sentry.io/product/sentry-basics/dsn-explainer/ + // You can set it in the SENTRY_DSN environment variable, or you can set it in code here. + options.Dsn = SentryDsn; + + // When debug is enabled, the Sentry client will emit detailed debugging information to the console. + // This might be helpful, or might interfere with the normal operation of your application. + // We enable it here for demonstration purposes when first trying Sentry. + // You shouldn't do this in your applications unless you're troubleshooting issues with Sentry. + options.Debug = false; + + // This option is recommended. It enables Sentry's "Release Health" feature. + options.AutoSessionTracking = true; + + // This option is recommended for client applications only. It ensures all threads use the same global scope. + // If you're writing a background service of any kind, you should remove this. + options.IsGlobalModeEnabled = true; + }); + } var pattern = @"Database=(\d+)_eform-angular-workflow-plugin;"; var match = Regex.Match(connectionString!, pattern); diff --git a/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn/Workflow.Pn.csproj b/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn/Workflow.Pn.csproj index 4754f6a..77d1456 100644 --- a/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn/Workflow.Pn.csproj +++ b/eFormAPI/Plugins/Workflow.Pn/Workflow.Pn/Workflow.Pn.csproj @@ -17,6 +17,10 @@ true + + + +