Configuration and Environment Variables
Prefactor TypeScript SDK / configuration
Configuration and Environment Variables
Section titled “Configuration and Environment Variables”SDK configuration can be provided in code, through environment variables, or as a combination of both. Programmatic values take precedence, while environment variables provide deployment-friendly defaults. This pattern allows local development and production deployments to share the same initialization path with minimal branching.
Core runtime controls include:
PREFACTOR_TRANSPORT: selects the transport implementation used by SDKinit/config creation logic (currentlyhttpfrom the transport selection path). Default ishttpwhen unset. If you providetransportTypeprogrammatically, that value takes precedence overPREFACTOR_TRANSPORT.PREFACTOR_SAMPLE_RATE: sets trace sampling from0to1.PREFACTOR_CAPTURE_INPUTSandPREFACTOR_CAPTURE_OUTPUTS: control whether input and output payloads are recorded.PREFACTOR_MAX_INPUT_LENGTHandPREFACTOR_MAX_OUTPUT_LENGTH: limit serialized payload sizes to keep telemetry bounded.PREFACTOR_LOG_LEVEL: controls SDK log verbosity (debug,info,warn,error) as consumed by the logger configuration. Default isinfowhen unset or invalid. Unlike tracing config fields, log level is not part of the mainConfigobject, so there is noinitconfig override for it; it is driven by logging configuration/environment handling.PREFACTOR_API_URLandPREFACTOR_API_TOKEN: configure HTTP transport connection, with optional identifiers such asPREFACTOR_AGENT_ID,PREFACTOR_AGENT_NAME, andPREFACTOR_AGENT_IDENTIFIERto label agent instances.
Retry behavior can also be tuned for network conditions through HTTP config fields like maxRetries, initialRetryDelay, maxRetryDelay, and retryMultiplier, or via PREFACTOR_RETRY_ON_STATUS_CODES for status-code matching. In most applications, the default retry profile is sufficient, so the best practice is to begin with defaults, observe behavior, and only adjust values when operational data shows a clear need.