SDK configuration
Customize how the Atono SDK functions in your application.
In most cases, initializing the SDK with an environment key is all you need. The options on this page let you customize its behavior for specific requirements.
Some options are intended primarily for testing and may not be useful in production.
Add configuration to the SDK
Pass configuration as the second argument to Atono.fromEnvironmentKey() using a JavaScript object:
const atono = Atono.fromEnvironmentKey('<your-environment-key>', {
// configuration options go here
});Atono.builder()
// call builder functions to configure the SDK.
.build("<your-environment-key>");Configuration options
API
apiBaseUrl
apiBaseUrlType: string
Overrides the base URL for the Atono API. This can be used to point the SDK to a local replica of the Atono service for resilience.
Default: https://api.atono.io
atonoBuilder.atonoBaseUrl("https://api.atono.io");Feature flags
featureFlags
featureFlagsType: object
Contains configuration options for the feature flags module.
featureFlags.autoSync
featureFlags.autoSyncType: boolean
Controls whether the SDK regularly polls Atono for updated feature flag definitions.
When disabled, the SDK still attempts to retrieve an initial set of flag configurations and retries until successful. After retrieving the initial configuration, it doesn’t check for further updates.
Default: true
// to disable autosync...
atonoBuilder.withPollingFeatureFlag(config -> config.disableAutoSync());
// to enable autoSync, set a sync interval (see below)featureFlags.publishEvaluation
featureFlags.publishEvaluationType: boolean
Controls whether the SDK publishes feature flag evaluation events to Atono. These events allow Atono to suggest slice values based on actual evaluations.
Default: true
// to disable flag evaluation reporting...
atonoBuilder.disableFeatureFlagReporting();
// to enable flag evaluation reporting...
atonoBuilder.withFeatureFlagPublisher();featureFlags.syncInterval
featureFlags.syncIntervalType: number
Sets how frequently, in milliseconds, the SDK polls Atono for updated feature flag definitions.
This option is ignored when featureFlags.autoSync is disabled.
Default: 5000 milliseconds (every 5 seconds)
atonoBuilder.withPollingFeatureFlag(config -> config.syncIntervalMs(5000))HTTP client
httpClient
httpClientType: object
Contains configuration options for the HTTP client.
httpClient.timeout
httpClient.timeoutType: number
Sets the number of milliseconds the SDK waits before timing out an HTTP request.
Default: 2000 milliseconds (2 seconds)
atonoBuilder.apiClientTimeoutMs(2000);Location
Location configuration is only available in the Web SDK and the React SDK.
location
locationType: object
Contains configuration options for the location module. Location is used when evaluating feature flags with location-based slices.
location.implementation
location.implementationType: LocationService
Sets the location service implementation.
The SDK provides the following implementations:
CachedIpBasedLocationService— the default implementation. It uses the requester’s IP address to determine location through a third-party service. It can’t be selected through configuration.NoopLocationService— disables the location service. Feature flag evaluations continue to work, but location-based slices are ignored.
location.cacheLocationTtl
location.cacheLocationTtlType: number
Sets how long, in milliseconds, cached location data remains valid when using CachedIpBasedLocationService.
Default: undefined, meaning cached location data doesn't expire.
location.ipOverride
location.ipOverrideType: string
Overrides the IP address used to retrieve location with a fixed IP address when using CachedIpBasedLocationService.
Default: undefined (no override)
Logging
Logging configuration is available in the Web SDK, the React SDK and the NodeJS (server-side) SDK
log
logType: object
Contains configuration options for the SDK logger.
log.implementation
log.implementationType: Logger
Sets the logger implementation.
The SDK provides the following implementations:
ConsoleLogger— the default implementation. It writes log events to the console.NoopLogger— doesn’t output log events, but still allows you to listen for structured log events.
log.level
log.levelType: string
Sets the minimum log level displayed by the SDK.
The following levels are available:
TRACE— granular information about SDK processesDEBUG— low-level information about SDK processesINFO— high-level information about SDK processesWARN— problems the SDK can recover from but that may affect its behavior or result in lost metric dataERROR— errors that require manual intervention. The SDK has initialized and can continue operating from its internal state, but it may behave unexpectedly and metric data may be lostFATAL— errors that require manual intervention because the SDK couldn’t initialize
Default: INFO
The SDK throws an error during initialization if the value isn’t a valid log level.
log.onLogEvent
log.onLogEventType: function
Provides a hook for listening to structured log events.
A log event listener receives a log entry and returns nothing. The log entry contains at least the following fields:
category— the source of the log within the SDKlevel— the log levelmessage— the log messagetimestamp— when the log was emitted
Default: undefined
The following example sends warnings and errors to a log collection service:
const logThreshold = ['WARN', 'ERROR', 'FATAL'];
function eventListener(logEntry) {
if (logThreshold.includes(logEntry.level)) {
fetch('https://my-log-collection.service', {
method: 'POST',
body: JSON.stringify(logEntry)
});
}
}
const atono = Atono.fromEnvironmentKey('<your-environment-key>', {
log: {
onLogEvent: eventListener
}
});Updated about 10 hours ago

