TelemetryDeck Client
Client for integrating private analytics in fast and reliable libraries and apps using Rust. Supports both native Rust applications and WebAssembly.
The library provides a client for the TelemetryDeck endpoint for broadcasting signals.
Installation
Add to your Cargo.toml:
For native Rust applications (servers, CLI tools):
[]
= "0.3"
For WebAssembly applications:
[]
= { = "0.3", = ["wasm"] }
Sending a signal
Basic Usage
use TelemetryDeck;
use HashMap;
let client = new;
// Fire-and-forget signal (spawns async task, never blocks)
client.send;
// Signal with custom payload parameters
client.send;
// Signal with floating-point value
client.send;
// For error handling, use send_sync (returns Result)
match client.send_sync.await
Multi-tenant Deployments (with namespace)
For multi-tenant deployments, you can specify a namespace:
use TelemetryDeck;
use HashMap;
let client = new_with_config;
client.send;
Enhanced User Hashing (with salt)
For additional privacy, you can provide a salt that will be concatenated with user identifiers before hashing:
use TelemetryDeck;
use HashMap;
// It's recommended to use a 64-character random salt
let client = new_with_config;
client.send;
Reserved Signal Types and Parameters
The library provides constants for reserved signal types and parameters defined by other TelemetryDeck SDKs:
use TelemetryDeck;
use signals;
use params;
use HashMap;
let client = new;
client.send;
let payload = from;
client.send;
Available signal constants include:
signals::session::STARTEDsignals::navigation::PATH_CHANGEDsignals::purchase::COMPLETEDsignals::acquisition::NEW_INSTALL_DETECTED
Available parameter constants are organized by category:
params::accessibility::*- Accessibility settingsparams::device::*- Device informationparams::navigation::*- Navigation dataparams::purchase::*- Purchase informationparams::retention::*- User retention metricsparams::calendar::*- Time-based dataparams::run_context::*- Runtime environmentparams::user_preferences::*- User preferences
See the API documentation for a complete list.
Session identifier
When an instance of TelemetryDeck is created, it is assigned a session identifier. This identifier persists for all outgoing signals during the lifetime of the instance.
You can reset the session identifier without recreating the client:
client.reset_session
You can also provide your own session identifier:
client.reset_session;
Examples
This repository includes two complete examples:
WebAssembly Example (Yew)
A simple counter web application built with Yew that sends telemetry signals on button clicks.
Location: examples/yew/
Run:
Requires trunk to be installed. See examples/yew/README.md for details.
Native CLI Example
A command-line application demonstrating native Rust usage with both send() and send_sync() methods.
Location: examples/cli/
Run:
The CLI supports namespace and salt options:
See examples/cli/README.md for all options and usage details.
API Changes
Breaking Changes in 0.4.0
The send() and send_sync() methods now include an additional parameter for float_value:
// Before (0.3.x)
client.send;
// After (0.4.0)
client.send;
To migrate, add None as the fifth parameter if you don't need to send a float value:
client.send;
Migration from 0.2.x
If you're upgrading from version 0.2.x, you need to add the wasm feature flag to your Cargo.toml:
# Before (0.2.x)
[]
= "0.2"
# After (0.4.x)
[]
= { = "0.4", = ["wasm"] }
Disclaimer
This repository is not affiliated with TelemetryDeck.