Skip to content

fix: report package-specific library metadata - #314

Merged
marandaneto merged 2 commits into
mainfrom
fix/package-lib-identifiers
Sep 4, 2026
Merged

fix: report package-specific library metadata#314
marandaneto merged 2 commits into
mainfrom
fix/package-lib-identifiers

Conversation

@marandaneto

@marandaneto marandaneto commented Sep 3, 2026

Copy link
Copy Markdown
Member

💡 Motivation and Context

The core and ASP.NET Core packages both reported $lib as posthog-dotnet. This made ASP.NET Core events indistinguishable from events sent directly through the core package. AI events also reported the core SDK name in $ai_lib and did not include the AI package version.

This change keeps posthog-dotnet for the core package and reports posthog-aspnetcore with the ASP.NET Core package version when ASP.NET Core registration is used. The ASP.NET Core identity is used in captured events, feature flag request properties, and the HTTP User-Agent header. AI events now include $ai_lib as posthog-ai and $ai_lib_version as the AI package version while the core $lib remains posthog-dotnet.

💚 How did you test it?

  • Ran dotnet test --no-restore.
  • Ran dotnet test tests/UnitTests.AspNetCore/UnitTests.AspNetCore.csproj --no-restore after adding coverage for feature flag requests and the User-Agent header.
  • Ran dotnet build --configuration Release --no-restore --nologo.
  • Ran bin/fmt --check.
  • Ran pnpm changeset status.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Pi coding agent implemented the change in a dedicated worktree. Pi autoreview checked the latest committed branch against origin/main and reported no actionable findings. The session was run locally and has no public link.

The package names and versions are configured internally so public client configuration does not change. Each integration generates its version metadata from its project version.

@marandaneto marandaneto self-assigned this Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

posthog-dotnet Compliance Report

Date: 2026-09-03 10:12:48 UTC
Duration: 4490ms

✅ All Tests Passed!

17/17 tests passed


Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 295ms
Request Payload.Flags Request Uses V2 Query Param 135ms
Request Payload.Flags Request Hits Flags Path Not Decide 111ms
Request Payload.Flags Request Omits Authorization Header 112ms
Request Payload.Token In Flags Body Matches Init 110ms
Request Payload.Groups Round Trip 114ms
Request Payload.Groups Default To Empty Object 110ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 112ms
Request Payload.Disable Geoip Omitted Defaults To False 110ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 110ms
Request Lifecycle.No Flags Request On Init Alone 5ms
Request Lifecycle.No Flags Request On Normal Capture 117ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 215ms
Request Lifecycle.Mock Response Value Is Returned To Caller 115ms
Retry Behavior.Retries Flags On 502 1118ms
Retry Behavior.Retries Flags On 504 1114ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 216ms

@marandaneto
marandaneto marked this pull request as ready for review September 3, 2026 07:49
@marandaneto
marandaneto requested a review from a team as a code owner September 3, 2026 07:49
@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
src/PostHog/Api/CapturedEvent.cs:29-30
**Replacement events lose integration metadata**

When an ASP.NET Core `BeforeSend` callback returns a newly constructed `CapturedEvent`, this public constructor stamps `posthog-dotnet` and the core version, and the replacement is uploaded without restoring the configured metadata. The event therefore loses its ASP.NET Core identity and disagrees with the integration-specific HTTP User-Agent.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix: report package-specific library met..." | Re-trigger Greptile

Comment thread src/PostHog/Api/CapturedEvent.cs
@marandaneto
marandaneto requested a review from a team September 3, 2026 12:26
@Radu-Raicea
Radu-Raicea removed the request for review from a team September 3, 2026 18:33
@arnohillen

Copy link
Copy Markdown

builder.AddPostHog() unconditionally calls o.UseAspNetCore() at src/PostHog.AspNetCore/Registration.cs:46, setting $lib to posthog-aspnetcore, but posthog/tasks/usage_report.py:974 maps only ("posthog-dotnet", "posthog-ai") to posthog_dotnet_ai_events, so AI events from the standard ASP.NET Core registration never reach that metric.

@marandaneto
marandaneto merged commit 2f38c21 into main Sep 4, 2026
20 checks passed
@marandaneto
marandaneto deleted the fix/package-lib-identifiers branch September 4, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants