Skip to content

Conversation

@abarker-launchdarkly
Copy link
Contributor

No description provided.

@github-actions
Copy link
Contributor

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 168949 bytes
Compressed size limit: 200000
Uncompressed size: 789074 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25024 bytes
Compressed size limit: 26000
Uncompressed size: 122509 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 17636 bytes
Compressed size limit: 20000
Uncompressed size: 90259 bytes

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 21722 bytes
Compressed size limit: 25000
Uncompressed size: 74700 bytes

Copy link

@tracisiebel tracisiebel left a comment

Choose a reason for hiding this comment

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

v minor comments on function

@tracisiebel
Copy link

Do you have an example of how someone using the Vercel AI SDK would use this wrapper? If not - no worries - we can come up with something.

@abarker-launchdarkly
Copy link
Contributor Author

Do you have an example of how someone using the Vercel AI SDK would use this wrapper? If not - no worries - we can come up with something.

const aiConfig = await aiClient.config('vercel-ai-config', context, {});
const result = await aiConfig.tracker.trackVercelAISDKGenerateTextMetrics(() =>
  generateText(aiConfig.toVercelAISDK(openai)),
);
console.log(result.text);

@abarker-launchdarkly abarker-launchdarkly marked this pull request as ready for review July 16, 2025 16:56
@abarker-launchdarkly abarker-launchdarkly requested a review from a team as a code owner July 16, 2025 16:56
@abarker-launchdarkly abarker-launchdarkly force-pushed the abarker/sdk-1219/vercel-ai-sdk-mapper branch from 5b6ef04 to a9a3c6d Compare July 16, 2025 17:00
cursor[bot]

This comment was marked as outdated.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Metrics Tracking Fails When Finish Reason Undefined

In the trackVercelAISDKStreamTextMetrics method, if result.finishReason is undefined (which is allowed by its optional type), the optional chaining ?.then() prevents any metrics from being tracked. This includes duration, success/error status, and token usage, leading to incomplete analytics and inconsistent behavior compared to other tracking methods.

packages/sdk/server-ai/src/LDAIConfigTrackerImpl.ts#L150-L193

trackVercelAISDKStreamTextMetrics<
TRes extends {
finishReason?: Promise<string>;
usage?: Promise<{
totalTokens?: number;
promptTokens?: number;
completionTokens?: number;
}>;
},
>(func: () => TRes): TRes {
const startTime = Date.now();
try {
const result = func();
result.finishReason
?.then(async (finishReason) => {
const endTime = Date.now();
this.trackDuration(endTime - startTime);
if (finishReason === 'error') {
this.trackError();
} else {
this.trackSuccess();
if (result.usage) {
try {
this.trackTokens(createVercelAISDKTokenUsage(await result.usage));
} catch {
// Intentionally squashing this error
}
}
}
})
.catch(() => {
const endTime = Date.now();
this.trackDuration(endTime - startTime);
this.trackError();
});
return result;
} catch (err) {
const endTime = Date.now();
this.trackDuration(endTime - startTime);
this.trackError();
throw err;
}
}

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@abarker-launchdarkly abarker-launchdarkly merged commit 0befee0 into main Jul 16, 2025
27 checks passed
@abarker-launchdarkly abarker-launchdarkly deleted the abarker/sdk-1219/vercel-ai-sdk-mapper branch July 16, 2025 20:10
@github-actions github-actions bot mentioned this pull request Jul 16, 2025
abarker-launchdarkly pushed a commit that referenced this pull request Jul 16, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>server-sdk-ai: 0.10.0</summary>

##
[0.10.0](server-sdk-ai-v0.9.9...server-sdk-ai-v0.10.0)
(2025-07-16)


### Features

* Adding Vercel AI SDK mapper
([#895](#895))
([0befee0](0befee0))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.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.

4 participants