Reference/SDK/TypeScript/Classes

Class: BraintrustState

Constructors

constructor

new BraintrustState(loginParams): BraintrustState

Parameters

NameType
loginParamsLoginOptions

Returns

BraintrustState

Methods

apiConn

apiConn(): HTTPConnection

Returns

HTTPConnection


appConn

appConn(): HTTPConnection

Returns

HTTPConnection


bgLogger

bgLogger(): BackgroundLogger

Returns

BackgroundLogger


copyLoginInfo

copyLoginInfo(other): void

Parameters

NameType
otherBraintrustState

Returns

void


login

login(loginParams): Promise<void>

Parameters

NameType
loginParamsLoginOptions & { forceLogin?: boolean }

Returns

Promise<void>


loginReplaceApiConn

loginReplaceApiConn(apiConn): void

Parameters

NameType
apiConnHTTPConnection

Returns

void


proxyConn

proxyConn(): HTTPConnection

Returns

HTTPConnection


resetLoginInfo

resetLoginInfo(): void

Returns

void


serialize

serialize(): Object

Returns

Object

NameType
apiUrlstring
appPublicUrlstring
appUrlstring
gitMetadataSettings?null | { collect: "some" | "none" | "all" ; fields?: ("dirty" | "tag" | "commit" | "branch" | "author_name" | "author_email" | "commit_message" | "commit_time" | "git_diff")[] }
loginTokenstring
orgId?null | string
orgNamestring
proxyUrlstring

setFetch

setFetch(fetch): void

Parameters

NameType
fetch(input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response>

Returns

void


deserialize

deserialize(serialized, opts?): BraintrustState

Parameters

NameType
serializedunknown
opts?LoginOptions

Returns

BraintrustState

Properties

apiUrl

apiUrl: null | string = null


appPublicUrl

appPublicUrl: null | string = null


appUrl

appUrl: null | string = null


currentExperiment

currentExperiment: undefined | Experiment


currentLogger

currentLogger: undefined | Logger<false>


currentSpan

currentSpan: IsoAsyncLocalStorage<Span>


fetch

fetch: (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>(input: string | URL | Request, init?: RequestInit) => Promise<Response> = globalThis.fetch

Type declaration

▸ (input, init?): Promise<Response>

MDN Reference

Parameters
NameType
inputURL | RequestInfo
init?RequestInit
Returns

Promise<Response>

▸ (input, init?): Promise<Response>

Parameters
NameType
inputstring | URL | Request
init?RequestInit
Returns

Promise<Response>


gitMetadataSettings

Optional gitMetadataSettings: Object

Type declaration

NameType
collect"some" | "none" | "all"
fields?("dirty" | "tag" | "commit" | "branch" | "author_name" | "author_email" | "commit_message" | "commit_time" | "git_diff")[]

id

id: string


loggedIn

loggedIn: boolean = false


loginToken

loginToken: null | string = null


orgId

orgId: null | string = null


orgName

orgName: null | string = null


proxyUrl

proxyUrl: null | string = null