fix: declare ai_product in the v2 gateway properties blob - #1217
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix: declare ai_product in the v2 gateway properties blob#1217posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
The v2 gateway pins only `$ai_product` (as `wizard:<program>`) and refuses a legacy product override on a scoped `phe_` token. The blob never declared the unprefixed `ai_product`, so after the cutover every wizard generation lost the label that cost and error attribution reads. Generated-By: PostHog Desktop Task-Id: 98a6a2c9-a3a9-45ef-9cdb-b0702060daaa
Contributor
Author
🧙 Wizard CIRun the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands: Test all apps:
Test all apps in a directory:
Test an individual app:
Show more apps
Test against a Context Mill branch:
Add Results will be posted here when complete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
ai_productkey: the AI Errors insight and its alert,usage_report.py,personal_spend.py, and the AI observability billing markup calculation.wizard: startedheld at 748 runs on the day the series fell.buildWizardPropertiesBlobnever declaredai_product. On the v2 path the gateway owns$ai_productonly (values likewizard:posthog-integration, sourcepinned), and it refuses a legacy product override on a scopedphe_token, so the plain key nobody sent is now absent.$ai_productwizard:<program>wizard:<program>ai_productwizardChanges
ai_product: 'wizard', so the plain key reaches every consumer again. This is the same fix warehouse-sources-admin and SherlockHog applied after the same cutover.team_id, and metadata keys are untouched.Note
This restores the label at the source. The consumer side is a separate repository:
usage_report.py,personal_spend.py,usePosthogAIBillingCalculations.ts, and the AI Errors insight should still coalesce$ai_productwithai_productand match on a prefix, because the pinned value carries a program suffix. Until they do, historical rows from the untagged window stay unattributed.Test plan
src/lib/__tests__/gateway-session.test.tsasserts the exact blob shape, so it now pinsai_product.pnpm lintreports 0 errors.buildAgentEnvandbuildGatewayHeadersonly read the blob onedition === 'v2'.LLM context
$ai_generation:src/lib/agent/aio-capture.tsposts into the user's own project behind the--capture-aiodev flag, so it is out of scope and was left alone.Created with PostHog Desktop from this inbox report.