FixFlow SDK
Documentation
Lightweight error capture SDK for Node.js and browser environments. Install, initialize with your project key, and optionally enable API request tracking.
01Install
Add the SDK to your app with npm (or your package manager of choice).
npm install @fixflow/sdk
02Quick start
Import the default client and call init with your project key from the FixFlow dashboard.
import fixflow from "@fixflow/sdk";
fixflow.init("PROJECT_KEY");The SDK posts to the FixFlow cloud ingest URL by default. You do not need to pass an endpoint for normal use.
After initialization, the SDK automatically captures uncaught errors and unhandled promise rejections.
03Frontend (browser)
Initialize in your client entry file (for example main.ts or index.tsx) as early as possible so startup errors are captured.
API request tracking: In Node.js, outbound HTTP monitoring uses Axios (trackAxios). In the browser you can use trackFetch, Axios, or both.
import fixflow from "@fixflow/sdk";
fixflow.init("PROJECT_KEY", {
trackFetch: true, // optional: window.fetch only (browser)
});Use captureError or capture in catch blocks for handled errors (see Manual capture below).
trackFetch instruments window.fetch only; it does not patch Node's global fetch.
04React
Prefer calling init from your entry file before createRoot(...).render(...) when the project key is available there.
If the key only exists on the client (for example a NEXT_PUBLIC_* env var), use a once-only useEffect with an empty dependency array. Do not call init in the component render body.
import { useEffect } from "react";
import fixflow from "@fixflow/sdk";
export function FixFlowInit() {
useEffect(() => {
const key = process.env.NEXT_PUBLIC_FIXFLOW_PROJECT_KEY;
if (key) {
fixflow.init(key, { trackFetch: true });
}
}, []);
return null;
}Mount that component once near the root of your tree. Next.js App Router users can wrap it in a small client component from the root layout.
05Node.js
Call init once at process startup (for example at the top of server.ts, before you listen on a port).
Do not rely on trackFetch for Node in the current SDK; use trackAxios and pass the same Axios instance your app uses.
import axios from "axios";
import fixflow from "@fixflow/sdk";
fixflow.init("PROJECT_KEY", {
trackAxios: true,
axios,
slowThreshold: 1000,
});06init options
Typical setup combines browser trackFetch with server Axios tracking. In Node, outbound HTTP monitoring uses Axios (trackAxios); in the browser you can use trackFetch, Axios, or both.
For production-style setups you can enable API tracking for fetch and Axios, and tune slow request detection.
import axios from "axios";
import fixflow from "@fixflow/sdk";
fixflow.init("PROJECT_KEY", {
trackFetch: true,
trackAxios: true,
slowThreshold: 1000,
axios,
});| Option | Type | Default | Description |
|---|---|---|---|
| trackFetch | boolean | false | Enables API tracking for window.fetch (browser). |
| trackAxios | boolean | false | Enables API tracking for Axios via interceptors. |
| slowThreshold | number | 1000 | Request duration threshold in milliseconds for slow API events. Values below 0 are clamped to 0. |
| axios | AxiosStatic | undefined | Axios instance to instrument. Recommended on the server when trackAxios is enabled. |
At startup the SDK requests GET …/sdk/config/:projectKey on the same API host as ingest. For the default cloud URL, that is https://api.fixflow.ai/sdk/config/:projectKey. It applies apiTrackingEnabled and trackInDevelopment from the project when the response is valid, and otherwise falls back to your trackFetch / trackAxios flags.
07Axios in Node.js
In Node/npm projects, @fixflow/sdk may resolve a different Axios copy than your application. Interceptors attached by the SDK would then miss requests made by your app's Axios import.
Always pass the same Axios instance your code uses:
import axios from "axios";
import fixflow from "@fixflow/sdk";
fixflow.init("PROJECT_KEY", {
trackAxios: true,
axios,
});08Manual capture
You can report errors from try/catch or other control flow with captureError:
try {
throw new Error("Something failed");
} catch (err) {
fixflow.captureError(err as Error);
}Or await the async capture method:
import fixflow from "@fixflow/sdk";
await fixflow.capture(new Error("Manual capture"));