Get started

Quickstart

Create a product, install the SDK for your platform and see your first event arrive, in about five minutes.

Markdown

This page takes you from nothing to a first event. Choose your platform in the Language menu in the sidebar; the steps below change to match it.

  1. Create a product

    Sign in and open Setup. Add a product: one app, site or service you want to measure. Setup gives it an id (prd_…) and asks which platform it runs on.

  2. Get a key

    Setup creates the key your platform needs and shows its secret once:

    • Browser and mobile apps use a public project key (ahl_pub_…). It only accepts events from the origins you allow, so it is safe to ship in client code.
    • Servers use a secret server key (ahl_live_…). Keep it in an environment variable, never in client code or git.

    Keys and environments explains scopes, rotation and staging versus production.

  3. Install the SDK

    Install the package and add the starter code for your platform. This is the same code Setup and npx @sansavision/apphelm init give you, with your own ids filled in.

    Next.js

    Install:

    npm install @sansavision/apphelm

    Environment:

    NEXT_PUBLIC_APPHELM_KEY=<your browser key, ahl_pub_…>
    APPHELM_API_KEY=<your server key, ahl_live_…>
    • NEXT_PUBLIC_APPHELM_KEY: Browser key. Public by design: it only sends events from the origins you allowed for it.

    • APPHELM_API_KEY: Server key. Keep it secret: server environment only, never in browser code, an app binary or git.

    A client component that starts the browser SDK. The browser SDK sends nothing until the visitor gives analytics consent: call setConsent({ analytics: true }) from your consent banner (or pass consent in the options when you have it already).

    app/apphelm-provider.tsx
    "use client";
    import { ApphelmProvider } from "@sansavision/apphelm/react";
    
    export function AppHelm({ children }: { children: React.ReactNode }) {
      return (
        <ApphelmProvider options={{
          key: process.env.NEXT_PUBLIC_APPHELM_KEY!,
          workspaceId: "org_…",
          productId: "prd_…",
        }}>
          {children}
        </ApphelmProvider>
      );
    }

    Wrap the app in the provider (merge into your existing root layout).

    app/layout.tsx
    import { AppHelm } from "./apphelm-provider";
    
    export default function RootLayout({ children }: { children: React.ReactNode }) {
      return <html lang="en"><body><AppHelm>{children}</AppHelm></body></html>;
    }

    Server-side events (route handlers, server actions). Reads the server key from the environment; never import this file from a client component.

    lib/apphelm.ts
    // Server only: never import this file from a client component.
    import { Apphelm } from "@sansavision/apphelm";
    
    export const apphelm = new Apphelm({
      apiKey: process.env.APPHELM_API_KEY!,
      workspaceId: "org_…",
      productId: "prd_…",
    });
    
    // await apphelm.capture({ distinctId: user.id, event: "signup_completed" });

    Check: Load a page (or run the code) once, then press Check connection: the first event appears within a few seconds.

    React

    Install:

    npm install @sansavision/apphelm

    Environment:

    VITE_APPHELM_KEY=<your browser key, ahl_pub_…>
    • VITE_APPHELM_KEY: Browser key. Public by design: it only sends events from the origins you allowed for it.

    Wrap your app in the provider (merge into your entry file). With Create React App use process.env.REACT_APP_APPHELM_KEY instead. The browser SDK sends nothing until the visitor gives analytics consent: call setConsent({ analytics: true }) from your consent banner (or pass consent in the options when you have it already).

    src/main.tsx
    import { createRoot } from "react-dom/client";
    import { ApphelmProvider } from "@sansavision/apphelm/react";
    import App from "./App";
    
    createRoot(document.getElementById("root")!).render(
      <ApphelmProvider options={{
        key: import.meta.env.VITE_APPHELM_KEY,
        workspaceId: "org_…",
        productId: "prd_…",
      }}>
        <App />
      </ApphelmProvider>,
    );

    Check: Load a page (or run the code) once, then press Check connection: the first event appears within a few seconds.

    Vue / Nuxt

    Install:

    npm install @sansavision/apphelm

    Environment:

    VITE_APPHELM_KEY=<your browser key, ahl_pub_…>
    • VITE_APPHELM_KEY: Browser key. Public by design: it only sends events from the origins you allowed for it.

    Import it once from src/main.ts (Nuxt: a client-only plugin, plugins/apphelm.client.ts, reading useRuntimeConfig().public.apphelmKey). The browser SDK sends nothing until the visitor gives analytics consent: call setConsent({ analytics: true }) from your consent banner (or pass consent in the options when you have it already).

    src/apphelm.ts
    import { createBrowserSdk } from "@sansavision/apphelm/browser";
    
    export const apphelm = createBrowserSdk({
      key: import.meta.env.VITE_APPHELM_KEY,
      workspaceId: "org_…",
      productId: "prd_…",
    });
    
    // From your consent banner:
    // apphelm.setConsent({ analytics: true });
    // apphelm.track({ name: "signup_completed" });

    Check: Load a page (or run the code) once, then press Check connection: the first event appears within a few seconds.

    Svelte / SvelteKit

    Install:

    npm install @sansavision/apphelm

    Environment:

    VITE_APPHELM_KEY=<your browser key, ahl_pub_…>
    • VITE_APPHELM_KEY: Browser key. Public by design: it only sends events from the origins you allowed for it.

    Import it once from your root layout in the browser only (SvelteKit: src/routes/+layout.svelte inside onMount, reading PUBLIC_APPHELM_KEY from $env/static/public). The browser SDK sends nothing until the visitor gives analytics consent: call setConsent({ analytics: true }) from your consent banner (or pass consent in the options when you have it already).

    src/lib/apphelm.ts
    import { createBrowserSdk } from "@sansavision/apphelm/browser";
    
    export const apphelm = createBrowserSdk({
      key: import.meta.env.VITE_APPHELM_KEY,
      workspaceId: "org_…",
      productId: "prd_…",
    });
    
    // From your consent banner:
    // apphelm.setConsent({ analytics: true });
    // apphelm.track({ name: "signup_completed" });

    Check: Load a page (or run the code) once, then press Check connection: the first event appears within a few seconds.

    Plain HTML

    Paste before on every page. The browser key is public, so it can sit in the page. The browser SDK sends nothing until the visitor gives analytics consent: call setConsent({ analytics: true }) from your consent banner (or pass consent in the options when you have it already).

    index.html
    <script type="module">
      import { createBrowserSdk } from "https://cdn.jsdelivr.net/npm/@sansavision/apphelm/dist/browser.js";
      window.apphelm = createBrowserSdk({
        key: "<your browser key, ahl_pub_…>",
        workspaceId: "org_…",
        productId: "prd_…",
      });
      // From your consent banner: window.apphelm.setConsent({ analytics: true });
    </script>

    Check: Load a page (or run the code) once, then press Check connection: the first event appears within a few seconds.

    Node.js

    Install:

    npm install @sansavision/apphelm

    Environment:

    APPHELM_API_KEY=<your server key, ahl_live_…>
    • APPHELM_API_KEY: Server key. Keep it secret: server environment only, never in browser code, an app binary or git.

    Server-side events. Use your user id as distinctId so server and browser events join.

    src/apphelm.ts
    import { Apphelm } from "@sansavision/apphelm";
    
    export const apphelm = new Apphelm({
      apiKey: process.env.APPHELM_API_KEY!,
      workspaceId: "org_…",
      productId: "prd_…",
    });
    
    // await apphelm.capture({ distinctId: user.id, event: "signup_completed" });

    Check: Run the code once (for example with a capture call at startup), then press Check connection.

    React Native / Expo

    Install:

    npm install @sansavision/apphelm @react-native-async-storage/async-storage

    Environment:

    EXPO_PUBLIC_APPHELM_KEY=<an events:write-only key, ahl_live_…>
    • EXPO_PUBLIC_APPHELM_KEY: Ships inside the app, so anyone can extract it: create a key with the events:write scope only (Settings → API keys).

    Create the client once and import it where you track. Without Expo, pass the key from your config library instead of process.env.

    apphelm.ts
    import AsyncStorage from "@react-native-async-storage/async-storage";
    import { AppState } from "react-native";
    import { createReactNativeSdk } from "@sansavision/apphelm/react-native";
    
    export const apphelm = createReactNativeSdk({
      apiKey: process.env.EXPO_PUBLIC_APPHELM_KEY!,
      workspaceId: "org_…",
      productId: "prd_…",
      storage: AsyncStorage,
      appState: AppState,
    });
    
    // apphelm.screen("Home");

    Check: Open the app once, then press Check connection: $app_opened arrives first.

    iOS (Swift)

    Install:

    .package(url: "https://github.com/Sansa-Organisation/apphelm-swift.git", from: "0.8.1")

    Add the package in Xcode (File → Add Package Dependencies) with the URL above, product Apphelm. The key ships inside the app: give it the events:write scope only.

    AppHelm.swift
    import Apphelm
    
    let apphelm = ApphelmClient(options: ApphelmOptions(
      apiKey: "<an events:write-only key, ahl_live_…>",
      workspaceId: "org_…",
      productId: "prd_…"
    ))
    
    // apphelm.track("signup_completed")

    Check: Launch the app once, then press Check connection: lifecycle events arrive on their own.

    Android (Kotlin)

    Install:

    implementation("com.sansavision:apphelm-android:0.8.1")

    Environment:

    APPHELM_API_KEY=<an events:write-only key, ahl_live_…>
    • APPHELM_API_KEY: Read at build time into BuildConfig. It ships inside the app: give it the events:write scope only.

    Add to the android block so the key reaches BuildConfig, and the dependency above to dependencies.

    app/build.gradle.kts
    android {
        buildFeatures { buildConfig = true }
        defaultConfig {
            buildConfigField("String", "APPHELM_API_KEY", "\"${System.getenv("APPHELM_API_KEY") ?: ""}\"")
        }
    }

    Set up once from your Application class (register it in AndroidManifest.xml with android:name).

    app/src/main/kotlin/App.kt
    import android.app.Application
    import apphelm.android.Apphelm
    import apphelm.android.ApphelmConfig
    
    class App : Application() {
        override fun onCreate() {
            super.onCreate()
            Apphelm.setup(this, ApphelmConfig(BuildConfig.APPHELM_API_KEY, "org_\u2026", "prd_\u2026"))
        }
    }

    Check: Launch the app once, then press Check connection: $app_opened arrives first.

    Python

    Install:

    pip install apphelm

    Environment:

    APPHELM_API_KEY=<your server key, ahl_live_…>
    • APPHELM_API_KEY: Server key. Keep it secret: server environment only, never in browser code, an app binary or git.

    Server-side events. Python 3.10 or later, standard library only.

    apphelm_client.py
    import os
    from apphelm import Apphelm
    
    apphelm = Apphelm(api_key=os.environ["APPHELM_API_KEY"])
    WORKSPACE_ID = "org_…"
    PRODUCT_ID = "prd_…"
    
    # apphelm.capture(WORKSPACE_ID, PRODUCT_ID, distinct_id=user.id, event_name="signup_completed")

    Check: Run a capture call once, then press Check connection.

    Java / Kotlin (JVM)

    Install:

    implementation("com.sansavision:apphelm:0.8.1")

    Environment:

    APPHELM_API_KEY=<your server key, ahl_live_…>
    • APPHELM_API_KEY: Server key. Keep it secret: server environment only, never in browser code, an app binary or git.

    Server-side events from a JVM service (Kotlin or Java 17+). Share one client and close() it on shutdown.

    src/main/kotlin/Apphelm.kt
    import apphelm.ApphelmClient
    import apphelm.ApphelmOptions
    
    val apphelm = ApphelmClient(ApphelmOptions(
        apiKey = System.getenv("APPHELM_API_KEY"),
        workspaceId = "org_\u2026",
        productId = "prd_\u2026",
    ))
    
    // apphelm.track("report_exported")

    Check: Run a track call once, then press Check connection.

    Go

    Install:

    go get apphelm.dev/go@v0.8.1

    Environment:

    APPHELM_API_KEY=<your server key, ahl_live_…>
    • APPHELM_API_KEY: Server key. Keep it secret: server environment only, never in browser code, an app binary or git.

    Server-side events, Go 1.21 or later, standard library only. Change the package name to put it elsewhere. If your network cannot reach the public Go proxy, set GOPROXY=https://apphelm.dev/packages/go,https://proxy.golang.org,direct (and GONOSUMDB=apphelm.dev/go if the checksum database is unreachable too).

    apphelm.go
    package main
    
    import (
    	"os"
    
    	apphelm "apphelm.dev/go"
    )
    
    // newApphelm creates the one client the app shares. In main:
    //
    //	client, err := newApphelm()
    //	if err != nil {
    //		log.Fatal(err)
    //	}
    //	defer client.Close() // sends what is still queued
    //
    //	client.Capture(apphelm.Capture{DistinctID: user.ID, Event: "signup_completed"})
    func newApphelm() (*apphelm.Client, error) {
    	return apphelm.New(apphelm.Config{
    		APIKey:      os.Getenv("APPHELM_API_KEY"),
    		WorkspaceID: "org_\u2026",
    		ProductID:   "prd_\u2026",
    	})
    }

    Check: Run a Capture call once, then press Check connection.

    Ruby

    Add the package source first:

    Add to your Gemfile, then run the install command. The source block makes Bundler take apphelm from apphelm.dev only, never from another source. Without Bundler: gem install apphelm --source https://apphelm.dev/packages/ruby

    Gemfile
    source "https://apphelm.dev/packages/ruby" do
      gem "apphelm", "~> 0.8"
    end

    Install:

    bundle install

    Environment:

    APPHELM_API_KEY=<your server key, ahl_live_…>
    • APPHELM_API_KEY: Server key. Keep it secret: server environment only, never in browser code, an app binary or git.

    Server-side events, Ruby 3.1 or later. Rails loads config/initializers on boot; elsewhere, require this file once at startup. Thread-safe and fork-safe.

    config/initializers/apphelm.rb
    require "apphelm"
    
    APPHELM = Apphelm::Client.new(
      api_key: ENV.fetch("APPHELM_API_KEY"),
      workspace_id: "org_\u{2026}",
      product_id: "prd_\u{2026}"
    )
    at_exit { APPHELM.shutdown } # sends what is still queued
    
    # APPHELM.capture(distinct_id: user.id, event: "signup_completed")

    Check: Run a capture call once, then press Check connection.

    PHP

    Install:

    composer config repositories.apphelm composer https://apphelm.dev/packages/composer
    composer require sansavision/apphelm

    Environment:

    APPHELM_API_KEY=<your server key, ahl_live_…>
    • APPHELM_API_KEY: Server key. Keep it secret: server environment only, never in browser code, an app binary or git.

    Server-side events, PHP 8.1 or later. Load Composer's vendor/autoload.php first (Laravel and Symfony already do). Each event is sent during the call that makes it; in a long-running worker (Octane, RoadRunner, Swoole) call $apphelm->flush() after each job or request.

    apphelm.php
    <?php
    
    use Apphelm\Client;
    
    $apphelm = new Client(
        apiKey: getenv('APPHELM_API_KEY'),
        workspaceId: 'org_…',
        productId: 'prd_…',
    );
    
    // $apphelm->capture(distinctId: (string) $user->id, event: 'signup_completed');

    Check: Run a capture call once, then press Check connection.

    Flutter

    Install:

    flutter pub add apphelm_flutter --hosted-url https://apphelm.dev/packages/pub

    Environment:

    APPHELM_KEY=<an events:write-only key, ahl_live_…>
    • APPHELM_KEY: Passed at build time: flutter run --dart-define=APPHELM_KEY=… (the same for flutter build). It ships inside the app, so anyone can extract it: give it the events:write scope only.

    Set up once before runApp (merge into your main.dart). Pure Dart, so the same code runs on iOS, Android, web and desktop. Its dependencies (http, shared_preferences) still come from pub.dev.

    lib/main.dart
    import 'package:flutter/material.dart';
    import 'package:apphelm_flutter/apphelm_flutter.dart';
    
    Future<void> main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await Apphelm.setup(ApphelmConfig(
        apiKey: const String.fromEnvironment('APPHELM_KEY'), // events:write only
        workspaceId: 'org_\u{2026}',
        productId: 'prd_\u{2026}',
      ));
      runApp(const MyApp()); // add ApphelmObserver() to your MaterialApp's navigatorObservers for screen views
    }
    
    // Apphelm.instance.track('signup_completed');

    Check: Launch the app once, then press Check connection: $app_opened arrives first.

    .NET

    Install:

    dotnet new nugetconfig    # only if the solution has no nuget.config yet
    dotnet nuget add source https://apphelm.dev/packages/nuget/index.json --name apphelm --configfile nuget.config
    dotnet add package SansaVision.Apphelm

    Environment:

    APPHELM_API_KEY=<your server key, ahl_live_…>
    • APPHELM_API_KEY: Server key. Keep it secret: server environment only, never in browser code, an app binary or git.

    Server-side events, .NET 8 or .NET Standard 2.0. Keep nuget.org in nuget.config too: the package depends on Microsoft packages from there. In ASP.NET Core, add SansaVision.Apphelm.AspNetCore and call builder.Services.AddApphelm(…) instead, which registers one client and flushes it when the host stops.

    Program.cs
    using Apphelm;
    
    // One client for the whole app. Disposing it sends what is still queued.
    await using var apphelm = new ApphelmClient(new ApphelmOptions
    {
        ApiKey = Environment.GetEnvironmentVariable("APPHELM_API_KEY")!,
        WorkspaceId = "org_\u2026",
        ProductId = "prd_\u2026",
    });
    
    // apphelm.Capture(user.Id, "signup_completed");

    Check: Run a Capture call once, then press Check connection.

    Elixir

    Add the package source first:

    Add to your deps. The repository must be named apphelm; its key fingerprint (mix hex.repo list) is SHA256:jokXz/stsZM7KS9JSjA27c12iygbBwVqIh7587t3NEs. jason and plug still come from hex.pm.

    mix.exs
    def deps do
      [{:apphelm, "~> 0.8.1", repo: "apphelm"}]
    end

    Install:

    curl -fsSo apphelm_hex.pem https://apphelm.dev/packages/hex/public_key
    mix hex.repo add apphelm https://apphelm.dev/packages/hex --public-key apphelm_hex.pem
    mix deps.get

    Environment:

    APPHELM_API_KEY=<your server key, ahl_live_…>
    • APPHELM_API_KEY: Server key. Keep it secret: server environment only, never in browser code, an app binary or git.

    Server-side events, Elixir 1.14 or later. Merge into config/runtime.exs: with :api_key set, the :apphelm application starts the client itself. Add the repository in CI too, before mix deps.get.

    config/runtime.exs
    import Config
    
    config :apphelm,
      api_key: System.fetch_env!("APPHELM_API_KEY"),
      workspace_id: "org_\u{2026}",
      product_id: "prd_\u{2026}"
    
    # Apphelm.capture(user.id, "signup_completed")

    Check: Start the app, run Apphelm.capture once, then press Check connection.

    Rust

    Add the package source first:

    Names the apphelm.dev registry, in your project (or ~/.cargo/config.toml). Then the install command adds apphelm = { version = "0.8", registry = "apphelm" } to Cargo.toml; add features = ["async"] for tokio applications.

    .cargo/config.toml
    [registries.apphelm]
    index = "sparse+https://apphelm.dev/packages/cargo/"

    Install:

    cargo add apphelm --registry apphelm

    Environment:

    APPHELM_API_KEY=<your server key, ahl_live_…>
    • APPHELM_API_KEY: Server key. Keep it secret: server environment only, never in browser code, an app binary or git.

    Server-side events, Rust 1.82 or later. Add mod apphelm_client; to main.rs, create the client at startup and clone it where you capture (clones share one queue).

    src/apphelm_client.rs
    use apphelm::{Client, Options};
    
    /// The one client the app shares. Call `shutdown()` before the process exits: it sends what is still queued.
    pub fn connect() -> Result<Client, Box<dyn std::error::Error>> {
        let options = Options::new(std::env::var("APPHELM_API_KEY")?)
            .workspace_id("org_\u{2026}")
            .product_id("prd_\u{2026}");
        Ok(Client::new(options)?)
    }
    
    // apphelm.capture(apphelm::Event::new(&user.id, "signup_completed"))?;

    Check: Run a capture call once, then press Check connection.

    HTTP

    No SDK is needed to send events. Post them to the ingest API with a server key:

    curl -X POST https://apphelm.dev/api/v1/events \
      -H "Authorization: Bearer $APPHELM_API_KEY" \
      -H "Content-Type: application/json" \
      --data '{"workspaceId":"org_…","productId":"prd_…","eventName":"signup_completed","properties":{"distinct_id":"user-123"}}'
  4. Check that it arrived

    Use your app once (load a page, open a screen, or run the capture call), then press Check connection in Setup. It confirms the key, the environment, consent, masking and identity, and shows the first events as they land, usually within seconds.

  5. Choose an outcome

    Pick one event that means a user got value, such as signup_completed or order_paid. AppHelm measures funnels, experiments and insights against it.

#Next steps