Skip to content

Repository files navigation

RudderStack - Customer Data Platform for Developers

Customer Data Platform for Developers


About RudderStack

RudderStack is a customer data platform for developers. Our tooling makes it easy to deploy pipelines that collect customer data from every app, website and SaaS platform, then activate it in your warehouse and business tools.

RudderStack Rust SDK

The RudderStack Rust SDK is an analytics client to track events from your Rust application. Once enabled, the event requests hit the RudderStack servers. RudderStack then transforms and routes these events to your specified destination platforms.

Questions? Start a conversation on our Slack channel.

For detailed documentation on the RudderStack Rust SDK, click here.

Getting Started with Rust SDK

Include rudderanalytics as a dependency in your Rust application Cargo.toml file:

[dependencies]
rudderanalytics = "<latest_version>"

Initializing the RudderStack Client

use rudderanalytics::client::RudderAnalytics;
use rudderanalytics::message::{Identify, Track, Page, Group, Screen, Alias, Batch, Message, BatchMessage};

let rudder_analytics = RudderAnalytics::load("YOUR_WRITE_KEY".to_string(), "YOUR_DATA_PLANE_URL".to_string());

Sending Events

Once the RudderStack client is initialized, you can use it to send your events. A sample call for track event is shown below:

use serde_json::json;

rudder_analytics.send(&Message::Track(Track {
    user_id: Some("sample_user_id".to_string()),
    event: "Test Event".to_owned(),
    properties: Some(json!({
        "some property": "some value",
        "some other property": "some other value",
    })),
    ..Default::default()
})).expect("Failed to send data to Rudderstack");

For more information on the supported calls, refer to the documentation.

Retry behavior

By default, send() retries transient delivery failures, including HTTP 429, HTTP 5xx, connection errors, and timeouts. Retries use bounded exponential backoff and honor the standard Retry-After response header when the dataplane returns one.

To customize retry behavior, configure retries when initializing the client.

use rudderanalytics::client::RudderAnalytics;
use rudderanalytics::retry::RetryConfig;
use std::time::Duration;

let retry_config = RetryConfig {
    max_retries: 1,
    max_backoff_delay: Duration::from_secs(5),
    ..Default::default()
};

let rudder_analytics = RudderAnalytics::load_with_retry_config(
    "YOUR_WRITE_KEY".to_string(),
    "YOUR_DATA_PLANE_URL".to_string(),
    retry_config,
);

Testing

Run the default test suite:

cargo test --all

Retry behavior is covered by integration tests that use a local mock RudderStack HTTP API. These tests verify HTTP 429 retries, Retry-After, retry exhaustion, terminal 4xx responses, 5xx retries, and the expected POST /v1/track request shape.

Run only the retry integration tests:

cargo test --test retry

Contribute

We would love to see you contribute to RudderStack. Get more information on how to contribute here.

Contact Us

For more information on any of the sections covered in this readme, you can contact us or start a conversation on our Slack channel.

Follow Us

About

Rust SDK for RudderStack - Open-source, warehouse-first Customer Data Pipeline and Segment-alternative. It collects and routes clickstream data and builds your customer data lake on your data warehouse.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages