Skip to main content

Getting Started

Add SDK observability to your SDK in about 15 minutes. By the end of this guide you will have initialization rates, method call counts, and error frequencies flowing into your SDK Garden dashboard.

What you need​

  • An SDK Garden account at app.sdkgarden.com
  • An API key from Settings → API Keys
  • Your published SDK (JavaScript/TypeScript or Python)

Step 1 — Create an account and get an API key​

  1. Sign up at app.sdkgarden.com.
  2. After signup your first SDK is created automatically.
  3. Go to Settings → API Keys and copy your key — it starts with sgk_.

Keep the key handy; you will paste it into the SDK initializer in the next step.


Step 2 — Install the client library​

npm install sdk-garden-js

The package ships both ESM (.mjs) and CommonJS (.js) builds with full TypeScript type declarations. No peer dependencies are required.


Step 3 — Initialize the client inside your SDK​

Add the initializer to the entry point of your SDK — the file users import when they install your package. Call it once at startup, not on every method call.

import SdkGarden from 'sdk-garden-js';

// Call once when your SDK loads
SdkGarden.init({
apiKey: 'sgk_YOUR_KEY_HERE',
sdkName: 'my-payments-sdk', // the name of YOUR sdk
sdkVersion: '1.2.3', // YOUR sdk's current version
});

sdk_initialized is automatically enqueued on init and will appear in your dashboard within a few seconds of your first user running the SDK.


Step 4 — Wrap key methods with telemetry​

trackMethod / track_method is the fastest way to get method-level analytics. It records every call, its duration, and whether it succeeded or raised an error — with zero changes to your method's signature or behavior.

class PaymentsSDK {
@SdkGarden.trackMethod('processPayment')
processPayment(amount: number): Receipt {
// your existing implementation — no changes needed here
}
}

For standalone functions, use the wrapper form instead:

function processPayment(amount: number): Receipt { ... }
export const tracked = SdkGarden.trackMethod('processPayment', processPayment);

Each wrapped method automatically emits:

  • method_called — on every invocation
  • method_success — when it returns successfully, including duration
  • sdk_error — when it raises an exception (the exception is re-raised to your caller)

Step 5 — Track errors from try/catch blocks​

For errors caught in your own try/catch blocks, call trackError directly:

try {
await connectToService(config);
} catch (err) {
SdkGarden.trackError(err as Error, { context: 'connection-setup' });
throw err; // re-raise — SDK Garden never swallows your errors
}

Error messages are automatically scrubbed for email addresses before being sent. See Event Schema for the full payload.


Step 6 — Verify events are arriving​

  1. Open your SDK Garden dashboard at app.sdkgarden.com.
  2. Run your SDK locally (or run its test suite without disabled: true).
  3. Within a few seconds the Funnel panel should show an sdk_initialized event.

If nothing appears after 30 seconds, enable debug logging:

SdkGarden.init({ apiKey: '...', sdkName: '...', sdkVersion: '...', debug: true });
// Console will print: [SDK Garden] Initialised { ... }
// Console will print: [SDK Garden] Flushing events 1

Disabling in test environments​

Pass disabled: true / disabled=True to suppress all events and network calls during testing:

SdkGarden.init({
apiKey: 'sgk_test',
sdkName: 'my-sdk',
sdkVersion: '0.0.0',
disabled: process.env.NODE_ENV === 'test',
});

When disabled, no thread is spawned (Python) and no flush interval is started (JavaScript). All methods become no-ops.


Next steps​