Getting started

Quick start

From npm install to your first replay in about five minutes. You'll need a workspace and the project key from Settings → Projects.

1. Install the SDK

Add the browser package with your package manager of choice.

shellnpm
npm install @tracebase/browser

2. Initialize once

Call Tracebase.initas early as possible in your app's lifecycle — before your framework mounts, ideally.

app.tstypescript
import { Tracebase } from "@tracebase/browser";

Tracebase.init({
  projectKey: "tb_live_your_project_key",
  environment: "production",
});

That's the whole integration. The SDK now records navigation, interactions, console output and uncaught errors. New sessions show up in your workspace within seconds.

No build step? Use the script tag

PHP, WordPress, Rails or plain HTML — drop the standalone bundle (12 kB) before </head> and initialize the global. No bundler, no framework, same capture.

index.phphtml
<script src="/js/tracebase.min.js"></script>
<script>
  Tracebase.init({ projectKey: "tb_live_your_project_key" });
</script>

3. Identify signed-in users

After authentication, attach a stable identifier so you can search sessions by user. Keep sensitive values out of user properties.

auth.tstypescript
Tracebase.identify("user_8f31a", {
  email: "d.moreau@example.com",
  plan: "team",
});

Privacy rules

Every input is masked by default. Add selectors for anything else that should be masked or blocked entirely before capture.

app.tstypescript
Tracebase.init({
  projectKey: "tb_live_your_project_key",
  privacy: {
    maskAllInputs: true,
    maskTextSelectors: [".customer-name"],
    blockSelectors: [".payment-form", "[data-private]"],
  },
});
Rules run in the browser.Blocked content is stripped before transmission — it never reaches Tracebase in any form.

Sampling

Record a slice of routine traffic while always keeping the sessions that matter. Sampling decisions are made at session start.

app.tstypescript
Tracebase.init({
  projectKey: "tb_live_your_project_key",
  sampleRate: 0.25,
  alwaysCaptureOnError: true,
});

Error capture

Uncaught exceptions and unhandled rejections are captured automatically. Report handled errors when they matter.

checkout.tstypescript
try {
  await submitPayment();
} catch (error) {
  Tracebase.captureException(error, { area: "checkout" });
}

Stuck on something? Ask us directly.