Tusk Drift is in private beta. Reach out to support@usetusk.ai for cloud access.
Prerequisites
- Node.js service (backend) where the SDK will be installed
- Tusk account with Team or Enterprise access
- Dev/staging environment for initial rollout (recommended)
Overview
Tusk Drift SDK captures real API calls from your service and deterministically replays them to detect regressions. During replay, outbound requests are intercepted and served from recorded data so results are stable, side-effect free, and fast enough for CI.Supported technologies
- HTTP/HTTPS: All versions (Node.js built-in)
- PG:
pg@8.x
,pg-pool@2.x–3.x
- Postgres:
postgres@3.x
- JSON Web Tokens:
jsonwebtoken@5.x–9.x
- JWKS RSA:
jwks-rsa@1.x–3.x
- GraphQL:
graphql@15.x–16.x
Setup
1
Install the Tusk CLI
Build the CLI locally and verify installation:
2
Set up the Tusk Drift config
Create your The wizard will generate
.tusk/config.yaml
in the root of your service using the onboarding wizard:.tusk/config.yaml
. You can also create the .tusk
directory and config file manually in your service root. See the configuration docs for details.3
Install the Drift SDK
Install the SDK in your service:
4
Obtain a Tusk Drift API key
Sign in to the Tusk web app, navigate to Settings > API Keys and click Create key. Name the key (e.g., “Tusk Drift”), copy it on creation, and store it securely.
5
Initialize and import SDK
1. For CommonJS Applications:Create a In your main server file (e.g., 2. For ESM ApplicationsESM applications require additional setup to properly intercept module imports:For ESM applications, you cannot control import order within your application code because all imports are hoisted. Instead, use the —import flag:Update your package.json scripts:
tdInit.ts
file to initialize the Tusk Drift SDK.server.ts
, index.ts
, app.ts
), import this file at the very top before any other imports. This ensures proper instrumentation of all dependencies.--import
is required because all import statements in ESM are hoisted and evaluated before any code runs, making it impossible to control import order within a file. The --import
flag ensures the SDK initialization (including loader registration) happens in a separate phase before your application code loads, guaranteeing proper module interception.6
Mark the app as ready
Once your server is listening, signal readiness so recording/replay begins only after initialization completes:
7
Configure recording policies
In
.tusk/config.yaml
, add or adjust a recording
section. These controls help enterprises manage data capture and cost:sampling_rate
: 0.0–1.0. Use lower rates for production, increase temporarily during onboarding.export_spans
: If disabled, spans are written locally under.tusk/traces
only.enable_env_var_recording
: Recommended when business logic depends on environment configuration.