emit_web

Crates.ioemit_web
lib.rsemit_web
version
sourcesrc
created_at2025-02-17 21:06:07.256924+00
updated_at2025-02-24 21:07:52.760304+00
descriptionInstrument Web-based applications using emit.
homepage
repositoryhttps://github.com/emit-rs/emit_web
max_upload_size
id1559349
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Ashley Mannix (KodrAus)

documentation

README

emit_web

web

Current docs

Use emit in WebAssembly applications targeting NodeJS and the browser.

Getting started

First, add emit and emit_web to your Cargo.toml:

[dependencies.emit]
version = "1"
# Important: Make sure you set `default-features = false`
default-features = false
features = ["std", "implicit_rt"]

[dependencies.emit_web]
version = "0.2.0"

Ensure you set default-features = false on emit, so it won't try compile dependencies that aren't compatible with WebAssembly.

Next, configure emit to use web APIs in its runtime:

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn setup() {
    let _ = emit::setup()
        .emit_to(emit_web::console())
        .with_clock(emit_web::date_clock())
        .with_rng(emit_web::crypto_rng())
        .try_init();
}

The name of this function doesn't matter, you'll just need to call it somewhere early in your application. You'll need to at least override the default clock and source of randomness, otherwise you'll get events without timestamps, and spans without ids.

Output

emit_web will output events to the Console API, where they'll appear in browser dev tools.

emit events written to the browser console

Commit count: 0

cargo fmt