ScaleBun
Skip to article

Core concepts

Developer

The eight terms that appear everywhere in ScaleBun — tenancy, environment, session, identity, event, envelope, flag, and entitlement.

Updated Reviewed

Eight terms carry most of the meaning across the SDK, the API and the dashboard. Getting these straight makes the rest of the documentation much easier to read.

Tenancy#

Organization → Project → App → AppEnvironment → SdkKey

An organization is the billing and membership boundary. A project groups related apps. An app is one product. An app environment is one deployment target of that app, and it owns the credentials.

The practical consequence: you do not switch environments with a config flag. You switch by using a different environment's key.

Environment#

A named deployment target — typically development, staging and production. Each one issues its own client key and secret key, and the client key's prefix tells you which environment it belongs to (skb_test_ck_, skb_staging_ck_, skb_live_ck_).

Session#

A period of product use. It is the unit almost everything else hangs off: events, screens, replay frames, performance metrics and errors are all attributed to a session.

Sessions start automatically on both platforms. They end after an idle timeout, or when you end one explicitly.

TypeScript
ScaleBun.sessionId;   // the current session idawait ScaleBun.close(); // end the session and stop capture

A web session survives a reload and a second tab — it ends after 30 minutes idle (sessionTimeoutMs) or 24 hours absolute (sessionMaxDurationMs). There is no manual start: session.start() exists for parity with the mobile facade and is a no-op.

Identity#

Before you call identify(), activity is attributed to a device. After, it is attributed to a user, and prior device activity is linked to that user.

TypeScript
ScaleBun.identify('user_123', { plan: 'pro' });

Call it after sign-in. On sign-out, clear the identity so a shared device does not attribute one person's activity to another — ScaleBun.reset() on the web, which also mints a fresh anonymous id and drops super-properties, and clearUser() on React Native. See Identity.

Event#

A named thing that happened, with optional properties.

TypeScript
ScaleBun.track('checkout_started', { cartValue: 42.5, currency: 'USD' });

Some events are emitted for you. React Native sends first_open, app_open and session_start; the web SDK reserves a $-prefixed vocabulary instead — $pageview, $autocapture, $rageclick and others. The two sets do not overlap, so a query that matches on a literal name is platform-specific.

The rest you define, and the names you choose become your analytics schema, so choose them deliberately. See Event naming.

Envelope#

The wire format. Captured data is wrapped in an envelope, batched with others, and persisted to an on-device outbox before any network call.

That is what makes offline capture work: the envelope survives an app kill, and the outbox drains with retry and backoff when connectivity returns. You never wait on the network, and a failed request does not lose data.

Flag, rollout, experiment#

Three related things delivered by the same runtime config payload:

ConceptQuestion it answersAPI
FlagIs this capability on?ScaleBun.flags.isEnabled('new_checkout')
RolloutIs this on for this device?ScaleBun.rollouts.isOn('beta_paywall')
ExperimentWhich variant does this device get?ScaleBun.experiments.variant('checkout_cta')

All three resolve locally against cached config, so they are synchronous and safe to call during render. They return conservative defaults (false / null) before config has been fetched.

Entitlement#

What your plan permits. Entitlements are enforced twice: the SDK does not register a collector for a capability you are not entitled to, and the backend rejects data for it. The first is a cost optimisation; the second is the actual boundary.

Core concepts · Start here · ScaleBun