pub struct ClientOptionsBuilder { /* private fields */ }Expand description
Builder for ClientOptions.
Implementations§
Source§impl ClientOptionsBuilder
impl ClientOptionsBuilder
Sourcepub fn host<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
pub fn host<VALUE: Into<String>>(&mut self, value: VALUE) -> &mut Self
Host URL for the PostHog API. Defaults to the US ingestion endpoint.
App hosts such as https://eu.posthog.com are normalized to ingestion
hosts before requests are sent.
Sourcepub fn api_key(&mut self, value: String) -> &mut Self
pub fn api_key(&mut self, value: String) -> &mut Self
PostHog project API key (project token). If missing or blank, the client is disabled.
Sourcepub fn request_timeout_seconds(&mut self, value: u64) -> &mut Self
pub fn request_timeout_seconds(&mut self, value: u64) -> &mut Self
Request timeout in seconds for capture, batch, and local evaluation
definition requests. Defaults to 30.
Sourcepub fn personal_api_key<VALUE: Into<String>>(
&mut self,
value: VALUE,
) -> &mut Self
pub fn personal_api_key<VALUE: Into<String>>( &mut self, value: VALUE, ) -> &mut Self
Personal API key for fetching flag definitions. Required when
enable_local_evaluation is true.
Sourcepub fn enable_local_evaluation(&mut self, value: bool) -> &mut Self
pub fn enable_local_evaluation(&mut self, value: bool) -> &mut Self
Enable local evaluation of feature flags using a background definitions poller.
Sourcepub fn poll_interval_seconds(&mut self, value: u64) -> &mut Self
pub fn poll_interval_seconds(&mut self, value: u64) -> &mut Self
Interval for polling flag definitions, in seconds. Defaults to 30.
Sourcepub fn disabled(&mut self, value: bool) -> &mut Self
pub fn disabled(&mut self, value: bool) -> &mut Self
Disable tracking and remote flag requests. Useful for development and tests.
Sourcepub fn disable_geoip(&mut self, value: bool) -> &mut Self
pub fn disable_geoip(&mut self, value: bool) -> &mut Self
Disable automatic GeoIP enrichment for capture and flag requests.
Sourcepub fn is_server(&mut self, value: bool) -> &mut Self
pub fn is_server(&mut self, value: bool) -> &mut Self
Whether events originate from a server-side runtime. Defaults to true,
which stamps $is_server: true so PostHog won’t attribute the host OS to
the user. Set false for client/CLI use (the property is then omitted).
Sourcepub fn feature_flags_request_timeout_seconds(&mut self, value: u64) -> &mut Self
pub fn feature_flags_request_timeout_seconds(&mut self, value: u64) -> &mut Self
Timeout in seconds for remote /flags requests. Defaults to 3.
Sourcepub fn error_tracking(&mut self, value: ErrorTrackingOptions) -> &mut Self
pub fn error_tracking(&mut self, value: ErrorTrackingOptions) -> &mut Self
Error tracking stacktrace and frame classification options
Sourcepub fn local_evaluation_only(&mut self, value: bool) -> &mut Self
pub fn local_evaluation_only(&mut self, value: bool) -> &mut Self
When true, never fall back to the remote API for flag evaluation. If local
evaluation is inconclusive (flag not cached or missing properties), the SDK
returns Ok(None) instead of making a network call. Only meaningful when
enable_local_evaluation is also true.
Sourcepub fn max_capture_attempts(&mut self, value: u32) -> &mut Self
pub fn max_capture_attempts(&mut self, value: u32) -> &mut Self
Maximum number of attempts for V1 capture requests (default: 3).
Includes the initial attempt, so 3 means 1 initial + 2 retries.
Sourcepub fn retry_initial_backoff_ms(&mut self, value: u64) -> &mut Self
pub fn retry_initial_backoff_ms(&mut self, value: u64) -> &mut Self
Initial retry backoff duration in milliseconds (default: 200)
Sourcepub fn retry_max_backoff_ms(&mut self, value: u64) -> &mut Self
pub fn retry_max_backoff_ms(&mut self, value: u64) -> &mut Self
Maximum retry backoff duration in milliseconds (default: 30000)
Sourcepub fn capture_compression(&mut self, value: CaptureCompression) -> &mut Self
pub fn capture_compression(&mut self, value: CaptureCompression) -> &mut Self
Optional request-body compression. When None (default), bodies are
sent uncompressed. The V0 pipeline supports Gzip only; V1 supports all
variants.
Source§impl ClientOptionsBuilder
impl ClientOptionsBuilder
Sourcepub fn before_send<F>(&mut self, hook: F) -> &mut Self
pub fn before_send<F>(&mut self, hook: F) -> &mut Self
Add a hook that can modify or discard events before they are sent.
Hooks should avoid panicking. Panics are caught and drop the current event, but any mutable state captured by the hook may be left partially updated and will be reused on subsequent calls.
Sourcepub fn build(&self) -> Result<ClientOptions, ClientOptionsBuilderError>
pub fn build(&self) -> Result<ClientOptions, ClientOptionsBuilderError>
Build sanitized ClientOptions.
Missing or whitespace-only API keys are allowed and disable the client so SDK initialization remains infallible while avoiding requests with an empty API key.
§Errors
Returns ClientOptionsBuilderError if a required builder value is
invalid according to the generated builder.
Trait Implementations§
Source§impl Clone for ClientOptionsBuilder
impl Clone for ClientOptionsBuilder
Source§fn clone(&self) -> ClientOptionsBuilder
fn clone(&self) -> ClientOptionsBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more