Skip to content

fix: Improve usage reporting#92

Merged
jsonbailey merged 3 commits intomainfrom
devin/AIC-1636-1771521851-improve-usage-reporting
Feb 19, 2026
Merged

fix: Improve usage reporting#92
jsonbailey merged 3 commits intomainfrom
devin/AIC-1636-1771521851-improve-usage-reporting

Conversation

@jsonbailey
Copy link
Contributor

@jsonbailey jsonbailey commented Feb 19, 2026

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Describe the solution you've provided

Updates the AI SDK's usage tracking to align with the updated spec from sdk-specs PR #132. Three categories of changes:

  1. Renamed all usage tracking event keys to use a unified $ld:ai:usage:* prefix, replacing the previous $ld:ai:config:function:*, $ld:ai:judge:function:*, and $ld:ai:agent:function:* keys. This makes it easier to filter all SDK usage events in reporting.

  2. Added SDK info tracking on initialization ($ld:ai:sdk-info). When LDAIClient is constructed, it now fires a single tracking event with the SDK name, version, and language, using an anonymous context. This ensures the data is captured even if the config tracker is never used.

  3. Extracted SDK info into a dedicated sdk_info.py module (similar to sdkInfo.ts in the JS SDK). Uses importlib.metadata to read the package name and version from installed distribution metadata at import time, which is the idiomatic Python approach. This keeps SDK identity info contained in one place and avoids hardcoded version strings.

Key mapping:

Old Key New Key
$ld:ai:config:function:single $ld:ai:usage:completion-config
$ld:ai:config:function:createChat $ld:ai:usage:create-chat
$ld:ai:judge:function:single $ld:ai:usage:judge-config
$ld:ai:judge:function:createJudge $ld:ai:usage:create-judge
$ld:ai:agent:function:single $ld:ai:usage:agent-config
$ld:ai:agent:function:multiple $ld:ai:usage:agent-configs

Human review checklist

  • Verify event key strings exactly match the spec — a typo here would silently break reporting
  • Verify the anonymous context (Context.builder('ld-internal-tracking').anonymous(True).build()) matches spec requirement 1.2.2.1
  • Confirm importlib.metadata with distribution name 'launchdarkly-server-sdk-ai' resolves correctly in all supported environments
  • _INIT_TRACK_CONTEXT and sdk_info constants are evaluated at module import time — confirm this is acceptable

Additional context


Note

Medium Risk
Primarily changes analytics/event emission paths; risk is moderate because incorrect event keys or metadata lookup failures could silently break usage reporting or introduce import-time runtime errors in some environments.

Overview
Aligns AI SDK telemetry with the updated spec by renaming all usage tracking event keys to the unified $ld:ai:usage:* namespace (completion config, judge config, create chat/judge, and single/multi agent config retrieval).

Adds one-time SDK identity reporting on LDAIClient initialization via a $ld:ai:sdk-info track event using an anonymous internal context, and introduces sdk_info.py to source SDK name/version from package metadata. Tests are updated/added to assert the new tracking behavior.

Written by Cursor Bugbot for commit 158b110. This will update automatically on new commits. Configure here.

Co-Authored-By: jbailey@launchdarkly.com <accounts@sidewaysgravity.com>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 2 commits February 19, 2026 17:31
Co-Authored-By: jbailey@launchdarkly.com <accounts@sidewaysgravity.com>
Co-Authored-By: jbailey@launchdarkly.com <accounts@sidewaysgravity.com>
@jsonbailey jsonbailey marked this pull request as ready for review February 19, 2026 17:59
@jsonbailey jsonbailey requested a review from a team as a code owner February 19, 2026 17:59
@jsonbailey jsonbailey merged commit e21eb89 into main Feb 19, 2026
37 checks passed
@jsonbailey jsonbailey deleted the devin/AIC-1636-1771521851-improve-usage-reporting branch February 19, 2026 21:59
@github-actions github-actions bot mentioned this pull request Feb 19, 2026
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.

2 participants

Comments