Getting started with Bevy

This is a guide on how to get started with Indigauge for the Bevy engine.

For more examples check out the examples in the repository or the bevy-mod-indigauge README.

Add the cargo lib

Add the package to your game project.

cargo add bevy-mod-indigauge

Add the plugin to the app

NOTE

Have the public api key available from the previous step.

Minimal example

This example initializes the plugin and starts a new session when the game is opened. The only thing that will be sent in automatically is any crash-events.

main.rs
use bevy::prelude::*;
use bevy_mod_indigauge::prelude::*;

fn main() {
  App::new()
    .add_plugins(DefaultPlugins)
    .add_plugins(
      IndigaugePlugin::<EmptySessionMeta>::new(
        "YOUR_PUBLIC_KEY",
        "My game name",
        env!("CARGO_PKG_VERSION")
      )
      // Optional: Set mode (Defaults to live). Dev mode is useful for testing and debugging and does not send events to the server.
      .mode(IndigaugeMode::Dev)
      // Optional: Set preferred log-level (Defaults to Info)
      .log_level(IndigaugeLogLevel::Info)
    )
    .add_systems(Startup, setup)
    .run();
}

fn setup(mut commands: Commands) {
  commands.spawn((Camera2d, IsDefaultUiCamera));
  commands.trigger(StartSessionEvent::new());
}

Advanced example

This example does multiple things:

  • initializes the plugin and starts a new session when the game is opened.
  • Every two seconds an event will be queued with a counter value.
  • Displays a feedback form if the user presses F on their keyboard.
  • Sends in any crash events that may occur.
main.rs
use std::time::Duration;
use bevy::{prelude::*, time::common_conditions::on_timer};
use bevy_mod_indigauge::prelude::*;

fn main() {
  App::new()
    .add_plugins(DefaultPlugins)
    .add_plugins(
      IndigaugePlugin::<EmptySessionMeta>::new(
        "YOUR_PUBLIC_KEY",
        "My game name",
        env!("CARGO_PKG_VERSION")
      )
      // Optional: Set mode (Defaults to live). Dev mode is useful for testing and debugging and does not send events to the server.
      .mode(IndigaugeMode::Dev)
      // Optional: Set preferred log-level (Defaults to Info)
      .log_level(IndigaugeLogLevel::Info)
    )
    // Optional: Customize the feedback panel styles
    .insert_resource(FeedbackPanelStyles {
      primary: Color::srgb_u8(147, 164, 255),
      primary_hover: Color::srgb_u8(124, 140, 250),
      secondary: Color::srgb_u8(147, 164, 255),
      secondary_hover: Color::srgb_u8(124, 140, 250),
      background: Color::srgb_u8(15, 23, 42),
      surface: Color::srgb_u8(30, 41, 59),
      border: Color::srgb_u8(51, 65, 85),
      text_primary: Color::srgb_u8(248, 250, 252),
      text_secondary: Color::srgb_u8(203, 213, 225),
      success: Color::srgb_u8(34, 197, 94),
      error: Color::srgb_u8(248, 113, 113),
      warning: Color::srgb_u8(250, 204, 21),
      accent: Color::srgb_u8(168, 85, 247),
    })
    .add_systems(Startup, setup)
    .add_systems(Update, (trigger_feedback_with_question, track_counter.run_if(on_timer(Duration::from_secs(2)))))
    .run();
}

fn setup(mut commands: Commands) {
  commands.spawn((Camera2d, IsDefaultUiCamera));
  commands.trigger(StartSessionEvent::new().with_platform("steam"));
}

fn trigger_feedback_with_question(
  mut commands: Commands,
  keys: Res<ButtonInput<KeyCode>>,
) {
  if keys.just_pressed(KeyCode::KeyF) {
    // This is how you manually trigger the feedback panel
    commands.insert_resource(
      FeedbackPanelProps::with_question("What did you think about level 3?", FeedbackCategory::Gameplay),
    );
  }
}

fn track_counter(mut counter: Local<u32>) {
  *counter += 1;
  ig_info!("counter.increase", { "value": *counter });
}

Tracing support

Enable the tracing feature to forward structured log events (that include an ig field) to Indigauge. This is useful for sending telemetry from existing tracing-based instrumentation.

Cargo example:

# enable tracing integration for bevy-mod-indigauge
bevy-mod-indigauge = { version = "0.3", features = ["tracing"] }

Usage example:

// any tracing-enabled location in your game
info!(ig = "counter.increase", value = counter_value);

The ig field must follow the same namespace.event rules as the ig_* macros (see the Event Naming guide).

Feature flags

  • feedback (enabled by default): provides the in-game feedback panel and related types. Requires some optional UI dependencies.
  • panic_handler (enabled by default): capture native panics/crashes as events.
  • tracing: enable tracing-layer integration.

If you need a minimal dependency set (for example for WASM builds), disable default features in Cargo.toml and opt-in to the features you need.