Skip to content

dsplce-co/statsig-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

We're dsplce.co, check out our work on our website: dsplce.co πŸ–€

statsig-wasm

πŸ“ˆ Wasm bindings for the Statsig JavaScript (Web) SDK.


πŸ“¦ Installation

In your project, run:

cargo add statsig-wasm

πŸ”§ Setup

Add the following script to your HTML <head> tag to make Statsig available to your Wasm module:

<script
  src="https://cdn.jsdelivr.net/npm/@statsig/js-client@3/build/statsig-js-client+session-replay+web-analytics.min.js"
  crossorigin="anonymous"
>
</script>

Bear in mind, if you're happy for Statsig to autoinitialise the client, just append ?apikey=<YOUR_CLIENT_API_KEY> to the script's src above and uninstall this crate πŸ˜‰

If you're looking to initialise the client yourself, read on.


πŸ§ͺ Usage

Set a custom user ID and initialise the client:

use statsig_wasm::{StatsigClient, StatsigUser};

let statsig = StatsigClient::new(
    env!("STATSIG_API_KEY"),
    StatsigUser {
        user_id: user_id.get(),
    },
)
.unwrap();

run_statsig_auto_capture(&statsig);

// `spawn_local` is native to Leptos, use your
// framework's equivalent to run the async method.
spawn_local(async move {
    statsig.initialize().await;
});

πŸ”’ License

MIT or Apache-2.0, at your option.


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages