Function: createConfig()
Prefactor TypeScript SDK / @prefactor/core / createConfig
Function: createConfig()
Section titled “Function: createConfig()”createConfig(
options?):object
Defined in: packages/core/src/config.ts:135
Creates a validated configuration object by merging provided options with environment variables and defaults.
Parameters
Section titled “Parameters”options?
Section titled “options?”Partial<{ transportType: "http"; sampleRate: number; captureInputs: boolean; captureOutputs: boolean; maxInputLength: number; maxOutputLength: number; httpConfig?: { apiUrl: string; apiToken: string; agentId?: string; agentIdentifier?: string; agentName?: string; agentDescription?: string; agentSchema?: Record<string, unknown>; requestTimeout?: number; maxRetries?: number; initialRetryDelay?: number; maxRetryDelay?: number; retryMultiplier?: number; retryOnStatusCodes?: number[]; }; failureHandling?: { onFatalError?: (error) => void; }; }>
Partial configuration options
Returns
Section titled “Returns”Validated configuration object
transportType
Section titled “transportType”transportType:
"http"
Transport type to use for span emission
sampleRate
Section titled “sampleRate”sampleRate:
number
Sampling rate (0.0 to 1.0)
captureInputs
Section titled “captureInputs”captureInputs:
boolean
Whether to capture span inputs
captureOutputs
Section titled “captureOutputs”captureOutputs:
boolean
Whether to capture span outputs
maxInputLength
Section titled “maxInputLength”maxInputLength:
number
Maximum length for input strings
maxOutputLength
Section titled “maxOutputLength”maxOutputLength:
number
Maximum length for output strings
httpConfig?
Section titled “httpConfig?”
optionalhttpConfig:object
HTTP transport configuration (required if transportType is ‘http’)
httpConfig.apiUrl
Section titled “httpConfig.apiUrl”apiUrl:
string
httpConfig.apiToken
Section titled “httpConfig.apiToken”apiToken:
string
httpConfig.agentId?
Section titled “httpConfig.agentId?”
optionalagentId:string
httpConfig.agentIdentifier?
Section titled “httpConfig.agentIdentifier?”
optionalagentIdentifier:string
httpConfig.agentName?
Section titled “httpConfig.agentName?”
optionalagentName:string
httpConfig.agentDescription?
Section titled “httpConfig.agentDescription?”
optionalagentDescription:string
httpConfig.agentSchema?
Section titled “httpConfig.agentSchema?”
optionalagentSchema:Record<string,unknown>
httpConfig.requestTimeout?
Section titled “httpConfig.requestTimeout?”
optionalrequestTimeout:number
httpConfig.maxRetries?
Section titled “httpConfig.maxRetries?”
optionalmaxRetries:number
httpConfig.initialRetryDelay?
Section titled “httpConfig.initialRetryDelay?”
optionalinitialRetryDelay:number
httpConfig.maxRetryDelay?
Section titled “httpConfig.maxRetryDelay?”
optionalmaxRetryDelay:number
httpConfig.retryMultiplier?
Section titled “httpConfig.retryMultiplier?”
optionalretryMultiplier:number
httpConfig.retryOnStatusCodes?
Section titled “httpConfig.retryOnStatusCodes?”
optionalretryOnStatusCodes:number[]
failureHandling?
Section titled “failureHandling?”
optionalfailureHandling:object
Optional failure handling callbacks.
failureHandling.onFatalError()?
Section titled “failureHandling.onFatalError()?”
optionalonFatalError: (error) =>void
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Throws
Section titled “Throws”If configuration is invalid
Example
Section titled “Example”const config = createConfig({ transportType: 'http', httpConfig: { apiUrl: 'https://app.prefactorai.com', apiToken: process.env.PREFACTOR_API_TOKEN!, }});