Skip to content

chore: Drop unnecessary createTracker non-null assertions in getting-started examples#1380

Merged
jsonbailey merged 1 commit into
mainfrom
jb/aic-2383/modernize-server-ai-examples
May 14, 2026
Merged

chore: Drop unnecessary createTracker non-null assertions in getting-started examples#1380
jsonbailey merged 1 commit into
mainfrom
jb/aic-2383/modernize-server-ai-examples

Conversation

@jsonbailey

@jsonbailey jsonbailey commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

LDAIConfig.createTracker is declared non-optional in packages/sdk/server-ai/src/api/config/types.ts, so the ! non-null assertion is unnecessary. Drop it across the three getting-started/ examples that still had it.

Affected files:

  • packages/sdk/server-ai/examples/getting-started/bedrock/converse/src/index.ts
  • packages/sdk/server-ai/examples/getting-started/openai/chat-completions/src/index.ts
  • packages/sdk/server-ai/examples/getting-started/vercel-ai/generate-text/src/index.ts

Background

This PR was originally scoped against the pre-#1379 examples layout (with examples/openai/, examples/bedrock/, examples/openai-observability/, examples/direct-judge/, etc.). PR #1379 ("Align server-ai examples with EXAM-SDK-example spec") restructured the examples into features/ and getting-started/ subdirectories and absorbed most of the issues this PR originally targeted — including the OpenAIProvider class removal, aiConfig.tracker property usage, LDAIMetrics(usage:) literal, and trackSuccess({...}) arg bug. Three createTracker!() occurrences remain in the new getting-started/ examples; those are what this PR now fixes.

Refs AIC-2383. This PR is part of the AI Configs docs/example modernization sweep tracked in `python-agent-work/all-docs-review.md`.

Test plan

  • Final grep sweep returns zero hits for `createTracker!()` under `packages/sdk/server-ai/examples/`
  • `yarn workspaces foreach -pR --topological-dev --from '@launchdarkly/server-sdk-ai' run build` succeeds with the three affected example workspaces
  • Spot-run the three examples to confirm no runtime change

🤖 Generated with Claude Code


Note

Low Risk
Low risk: changes are limited to TypeScript getting-started examples and only remove ! non-null assertions from aiConfig.createTracker, with no runtime behavior change expected.

Overview
Cleans up the server-ai getting-started examples to call aiConfig.createTracker() directly (without the ! non-null assertion) in the Bedrock converse, OpenAI chat-completions, and Vercel AI generate-text samples.

This aligns the examples with the SDK typings where createTracker is non-optional and avoids masking potential type issues.

Reviewed by Cursor Bugbot for commit c2ff6ba. Bugbot is set up for automated code reviews on this repo. Configure here.

LDAIConfig.createTracker is declared non-optional in src/api/config/types.ts,
so the `!` is unnecessary across the three getting-started examples.

Refs AIC-2383

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jsonbailey jsonbailey force-pushed the jb/aic-2383/modernize-server-ai-examples branch from 7df2ac8 to c2ff6ba Compare May 14, 2026 14:28
@jsonbailey jsonbailey changed the title fix: Modernize server-ai examples to current SDK surface fix: Drop unnecessary createTracker non-null assertions in getting-started examples May 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 26208 bytes
Compressed size limit: 29000
Uncompressed size: 128789 bytes

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 31906 bytes
Compressed size limit: 34000
Uncompressed size: 113658 bytes

@github-actions

Copy link
Copy Markdown
Contributor

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

@jsonbailey jsonbailey marked this pull request as ready for review May 14, 2026 16:35
@jsonbailey jsonbailey requested a review from a team as a code owner May 14, 2026 16:35
@jsonbailey jsonbailey changed the title fix: Drop unnecessary createTracker non-null assertions in getting-started examples chore: Drop unnecessary createTracker non-null assertions in getting-started examples May 14, 2026
@jsonbailey jsonbailey merged commit bb8f861 into main May 14, 2026
45 checks passed
@jsonbailey jsonbailey deleted the jb/aic-2383/modernize-server-ai-examples branch May 14, 2026 17:01
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