Subscrio.AuditLog 0.5.0

dotnet add package Subscrio.AuditLog --version 0.5.0
                    
NuGet\Install-Package Subscrio.AuditLog -Version 0.5.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Subscrio.AuditLog" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Subscrio.AuditLog" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Subscrio.AuditLog" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Subscrio.AuditLog --version 0.5.0
                    
#r "nuget: Subscrio.AuditLog, 0.5.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Subscrio.AuditLog@0.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Subscrio.AuditLog&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Subscrio.AuditLog&version=0.5.0
                    
Install as a Cake Tool

Subscrio.AuditLog

First-party audit log extension for Subscrio.Core. Registers after-hooks and stores rows in Postgres for reporting.

Install

dotnet add package Subscrio.AuditLog

Depends on Subscrio.Core and PostgreSQL (Npgsql).

Usage

using Subscrio.Core;
using Subscrio.Core.Config;
using Subscrio.AuditLog;
using Subscrio.AuditLog.DTOs;

var connectionString = Environment.GetEnvironmentVariable("DATABASE_URL")!;
var subscrio = new Subscrio(new SubscrioConfig
{
    Database = new DatabaseConfig { ConnectionString = connectionString }
});
await subscrio.InstallSchemaAsync();

await using var audit = subscrio.UseAuditLog(new AuditLogOptions
{
    ConnectionString = connectionString
});
await audit.InstallSchemaAsync();

var page = await audit.ListAsync(new TransactionLogFilters
{
    CustomerKey = "acme",
    Limit = 50
});
var row = page.Data.Count > 0 ? await audit.GetAsync(page.Data[0].Id) : null;

// Dispose unsubscribes all hooks and closes the Npgsql data source

Schema

Owned by this extension (not core). Created only when you call InstallSchemaAsync().

  • Table: subscrio.transaction_logs
  • Version key in subscrio.system_config: audit_log_schema_version (current: 1.0.0)
  • VerifySchemaAsync() → version string or null
  • MigrateAsync() applies future extension-only migrations

Nullable FKs (customer_id, subscription_id) use ON DELETE SET NULL so history survives entity deletes. Business keys (customer_key, subscription_key, entity_key) are always stored for reporting.

Hooks

Registers all *.after hooks via Subscrio.Hooks.On*After:

Event family entity_type action
customer.*.after customer create / update / archive / unarchive / delete
subscription.*.after (lifecycle) subscription create / update / archive / unarchive / delete
feature override / clear subscription feature_override / clear_overrides
stripe.received.after stripe_event stripe_event

For Stripe events, the extension extracts Stripe customer/subscription IDs from the payload and looks up matching Subscrio rows (customers.external_billing_id, subscriptions.stripe_subscription_id) so customer_id / subscription_id / keys are filled when resolvable. Unresolved refs stay null.

Summary format: customer.updated: acme.

After-hook failure semantics

Audit writes run on after hooks, so the Subscrio mutation is already committed when the insert runs.

  • If the audit insert throws, the error propagates and the public API call fails.
  • The underlying customer/subscription change remains in the database.
  • Call DisposeAsync() to unsubscribe; further mutations will not write audit rows.

Query

await audit.ListAsync(new TransactionLogFilters
{
    CustomerKey = "acme",
    SubscriptionKey = "sub-1",
    EntityType = "customer",
    Source = "api",
    Action = "update",
    StripeEventId = "evt_...",
    StripeEventType = "customer.subscription.created",
    Search = "acme",
    StartDate = DateTime.Parse("2026-01-01T00:00:00.000Z").ToUniversalTime(),
    EndDate = DateTime.Parse("2026-12-31T23:59:59.999Z").ToUniversalTime(),
    SortBy = "createdAt",
    SortOrder = "desc",
    Limit = 50,
    Offset = 0,
});
// → TransactionLogPage { Data, Total }

Development

From this directory (dotnet/):

dotnet build
dotnet test

Builds and tests use published Subscrio.Core 0.5.1 by default. In the hub workspace, pass -p:UseLocalSubscrioCore=true to build against the local core checkout instead. Core tests in subscrio-dotnet do not run this suite.

Tests create a fresh Postgres database. Set TEST_DATABASE_URL, copy tests/appsettings.example.json to tests/appsettings.json, or use default localhost credentials (postgres / postgres).

Add-on, usage, and credit events

The extension records successful add-on attach/detach, usage report, credit grant, consumption and adjustment after-events, including operation keys and committed result snapshots. Timed override events include expiration metadata. Exact accounting retries do not create duplicate success events. Audit delivery is post-commit and is not a durable outbox; the core usage records and credit ledger remain authoritative.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.0 90 9/23/2026
0.4.0 94 9/20/2026
0.3.1 106 9/5/2026