stackpilot-sdk-satej
v1.2.1
Published
Browser error logging SDK for StackPilot.
Maintainers
Readme
StackPilot SDK
Browser error logging SDK for StackPilot.
Package: stackpilot-sdk-satej
Default endpoint: https://stackpilot-oiys.onrender.com/api/v1/logsInstall
npm install stackpilot-sdk-satejpnpm add stackpilot-sdk-satejQuick Start (one line)
import { init } from "stackpilot-sdk-satej";
init("YOUR_PROJECT_KEY");That's it. The SDK automatically:
- connects to the StackPilot API
- captures uncaught browser errors (
window.onerror) - captures unhandled promise rejections
Script Tag (zero JS code)
Drop this into any HTML page — no bundler needed:
<script
src="https://unpkg.com/stackpilot-sdk-satej"
data-project-key="YOUR_PROJECT_KEY"
></script>Optional attributes: data-endpoint="...", data-debug="true".
Auto-Init (framework-friendly)
Add a meta tag or global variable, then import the auto module:
<meta name="stackpilot-key" content="YOUR_PROJECT_KEY" />import "stackpilot-sdk-satej/auto";Or set the global before importing:
window.__STACKPILOT_PROJECT_KEY__ = "YOUR_PROJECT_KEY";
import "stackpilot-sdk-satej/auto";Next.js Setup
Add your project key to .env.local:
NEXT_PUBLIC_STACKPILOT_PROJECT_KEY=your_project_keyCreate a small client component:
"use client";
import { useEffect } from "react";
import { init } from "stackpilot-sdk-satej";
export function StackPilotProvider() {
useEffect(() => {
return init(process.env.NEXT_PUBLIC_STACKPILOT_PROJECT_KEY!);
}, []);
return null;
}Render <StackPilotProvider /> once near your app root.
Manual Logging
import { captureError, logError } from "stackpilot-sdk-satej";
try {
// app code
} catch (error) {
logError(error);
}
captureError(new Error("Checkout failed"));Full Options
For advanced use, initLogger gives you full control:
import { initLogger } from "stackpilot-sdk-satej";
initLogger({
projectKey: "YOUR_PROJECT_KEY",
endpoint: "https://your-custom-endpoint.com/api/v1/logs",
enabled: true,
debug: true,
});| Option | Type | Default | Description |
| ------------ | --------- | --------------------------- | --------------------------------------------- |
| projectKey | string | required | Project key from the StackPilot dashboard |
| endpoint | string? | https://stackpilot-oiys.onrender.com/api/v1/logs | Log ingestion endpoint |
| enabled | boolean?| true | Set false to disable without removing code |
| debug | boolean?| false | Print SDK warnings in the browser console |
Cleanup
Both init and initLogger return a cleanup function:
const cleanup = init("YOUR_PROJECT_KEY");
cleanup();Or call resetLogger() directly:
import { resetLogger } from "stackpilot-sdk-satej";
resetLogger();Test It
After setup, trigger a test error in the browser:
throw new Error("StackPilot test error");Then open your StackPilot dashboard and check the selected project.
Troubleshooting
If logs do not appear:
- confirm the project key exists in your StackPilot dashboard
- confirm your app runs the SDK in browser/client code
- enable
debug: trueand check the browser console - if using a custom endpoint, confirm it matches your API
