Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions js/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ import {
getSpanInstrumentationName,
INSTRUMENTATION_NAMES,
mergeSpanOriginContext,
SDK_VERSION,
type SpanOriginEnvironment,
} from "./span-origin";

Expand Down Expand Up @@ -1315,6 +1316,11 @@ class HTTPConnection {
// As far as I can tell, you cannot set the retry/backoff factor here
_reset() {
this.headers = {};
// Identifies SDK-originated traffic so the backend can attribute object
// creation to the TS SDK. Ignored by browsers (User-Agent is a forbidden
// header there), which is acceptable since the SDK is primarily used
// server-side.
this.headers["User-Agent"] = `braintrust-ts/${SDK_VERSION}`;
if (this.token) {
this.headers["Authorization"] = `Bearer ${this.token}`;
}
Expand Down
2 changes: 1 addition & 1 deletion js/src/span-origin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type InternalSpanInstrumentationName = {
[INTERNAL_SPAN_INSTRUMENTATION_NAME]?: SpanInstrumentationName;
};

const SDK_VERSION =
export const SDK_VERSION =
typeof __BRAINTRUST_SDK_VERSION__ !== "undefined"
? __BRAINTRUST_SDK_VERSION__
: "0.0.0";
Expand Down
Loading