Skip to content

fix: Improve usage reporting#18

Draft
jsonbailey wants to merge 2 commits intomainfrom
devin/AIC-1636-1771538971-improve-usage-reporting
Draft

fix: Improve usage reporting#18
jsonbailey wants to merge 2 commits intomainfrom
devin/AIC-1636-1771538971-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

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

  1. Renamed usage tracking event key from $ld:ai:config:function:single to $ld:ai:usage:completion-config, matching the new unified $ld:ai:usage:* namespace. (This SDK only has the single completion config method — no judge, agent, or createChat methods — so only one key needed updating.)

  2. Added SDK info tracking on initialization ($ld:ai:sdk-info). When Client is constructed, it fires a single tracking event with SDK name, version, and language using an anonymous internal context. This satisfies spec requirement 1.2.2.1 and ensures data is captured even if the config tracker is never used. SDK identity constants are kept in a dedicated sdk_info.rb module (similar to sdkInfo.ts in JS and sdk_info.py in Python).

  3. Renamed config to completion_config to align with the updated spec method naming. The old config method is preserved as a deprecated proxy that emits a warning and delegates to completion_config.

Human review checklist

  • Verify event key string $ld:ai:usage:completion-config exactly matches the spec — a typo here would silently break reporting
  • Verify the anonymous context (LDContext.create(key: 'ld-internal-tracking', anonymous: true)) matches spec requirement 1.2.2.1
  • Confirm that INIT_TRACK_CONTEXT being created at module load time (outside class Client) is acceptable — it calls LDContext.create when the module is first loaded
  • Confirm the deprecation approach for config (emitting warn on every call) is acceptable for existing consumers — this could be noisy if callers haven't migrated yet

Additional context

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

🤖 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

@@ -203,6 +224,11 @@ def config(config_key, context, default_value = nil, variables = nil)
provider: provider_config
)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a break between methods here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a blank line between the methods.

TRACK_SDK_INFO,
INIT_TRACK_CONTEXT,
{
aiSdkName: 'launchdarkly-server-sdk-ai',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other sdk's we kept this information in an sdk info / meta type file so it could be used in other places if needed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted SDK info into a dedicated lib/server/ai/sdk_info.rb module with SDK_NAME and SDK_LANGUAGE constants (similar to sdkInfo.ts in JS and sdk_info.py in Python). The client now references those constants instead of hardcoded strings.

Co-Authored-By: jbailey@launchdarkly.com <accounts@sidewaysgravity.com>
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.

1 participant

Comments