fix(sdk): report the real SDK version in the User-Agent#186
Merged
Conversation
The published SDK reported decart-js-sdk/0.0.0-dev for every release: the build-time __PACKAGE_VERSION__ define is silently rejected by the pinned tsdown/rolldown, so VERSION always fell back to the dev placeholder. Read the version as a real module import from package.json instead, drop the dead define, and add a built-package regression guard on VERSION and the UA.
commit: |
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.
What & why
Every published release of
@decartai/sdkreported its version as0.0.0-devin the outgoing User-Agent, regardless of the actual version. This broke SDK version attribution in our observability — we couldn't tell which SDK version a customer was actually running, which slowed down a live customer debugging session.The version is now sourced reliably at build time so the User-Agent always carries the real version (e.g.
decart-js-sdk/0.1.14 …). A build-package regression check was added so a placeholder or mismatched version can never silently ship again.Note: this corrects all future releases; already-published versions keep reporting
0.0.0-devuntil a new version is cut.Note
Low Risk
Narrow build/version wiring and test coverage only; no auth, data handling, or runtime API behavior changes beyond correct version strings in headers and telemetry.
Overview
Published
@decartai/sdkbuilds were shippingVERSIONas0.0.0-devin the User-Agent and telemetry because tsdown/rolldown rejected thedefineblock and the old magic-token path silently fell back to a placeholder.VERSIONnow comes from a realpackage.jsonimport inversion.ts(tree-shaken to the version string at build time), and thedefineentry is removed fromtsdown.config.ts.built-package.mjsnow asserts the builtVERSIONmatchespackage.json, is not the dev placeholder, and thatbuildUserAgent()includesdecart-js-sdk/<real version>.Reviewed by Cursor Bugbot for commit 20cfdd8. Bugbot is set up for automated code reviews on this repo. Configure here.