Skip to main content

Event Schema

Every event sent by an SDK Garden client library is a JSON object POSTed to the ingest endpoint as part of a batch. This page documents the exact shape of each event type.


Wire format​

Each HTTP POST to /track contains a JSON body with this structure:

{
"api_key": "sgk_live_abc123",
"events": [
{ /* event object */ },
{ /* event object */ }
]
}

Event object​

All events share these top-level fields:

FieldTypeDescription
eventstringEvent type name. See event types below.
sdkobjectIdentifies the SDK being observed.
sdk.namestringThe sdkName / sdk_name passed to init().
sdk.versionstringThe sdkVersion / sdk_version passed to init().
session_idstringUUID4 generated once per client instance. Groups events from the same SDK session.
timestampnumberUnix timestamp in milliseconds at the moment the event was enqueued.
propertiesobjectEvent-specific payload. See each event type below.
metaobjectRuntime context collected at enqueue time. See Meta fields.

Event types​

sdk_initialized​

Emitted automatically by SdkGarden.init() / SdkGarden(...).start() immediately after the client is configured.

The environment fields are runtime-specific — each client sends only what is meaningful for its runtime. A server-side client (Python, Java, C#, etc.) will never include browser fields like screen dimensions or viewport size. The example below shows a browser JavaScript payload; see the per-runtime tables beneath it for what each runtime actually sends.

{
"event": "sdk_initialized",
"sdk": { "name": "acme-payments", "version": "2.1.0" },
"session_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"timestamp": 1716163200000,
"properties": {
"environment": {
"runtime": "browser",
"screen_width": 1920,
"screen_height": 1080,
"viewport_width": 1440,
"viewport_height": 900,
"color_depth": 24,
"pixel_ratio": 2,
"timezone": "America/New_York",
"language": "en-US"
}
},
"meta": {
"url": "https://example.com/dashboard",
"referrer": "https://example.com/"
}
}

Properties — JavaScript (browser):

FieldTypeDescription
environment.runtime"browser"Always "browser" in browser environments.
environment.screen_widthnumberscreen.width in pixels.
environment.screen_heightnumberscreen.height in pixels.
environment.viewport_widthnumberwindow.innerWidth in pixels.
environment.viewport_heightnumberwindow.innerHeight in pixels.
environment.color_depthnumberscreen.colorDepth.
environment.pixel_rationumberwindow.devicePixelRatio.
environment.timezonestringIANA timezone from Intl.DateTimeFormat.
environment.languagestringnavigator.language.

Properties — JavaScript (Node.js):

FieldTypeDescription
environment.runtime"node"Always "node" in Node.js.

Properties — Python:

FieldTypeDescription
environment.runtime"cpython"Always "cpython".
environment.python_versionstringPython version string, e.g. "3.11.4".

method_called​

Emitted at the start of every call to a wrapped method, before the function runs.

{
"event": "method_called",
"sdk": { "name": "acme-payments", "version": "2.1.0" },
"session_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"timestamp": 1716163201234,
"properties": {
"method": "processPayment",
"args_count": 2
},
"meta": {}
}
FieldTypeDescription
properties.methodstringThe methodName passed to trackMethod / track_method.
properties.args_countnumberNumber of positional arguments the function was called with.

method_success​

Emitted when a wrapped method returns successfully. For async functions (JavaScript), emitted when the returned promise resolves.

{
"event": "method_success",
"sdk": { "name": "acme-payments", "version": "2.1.0" },
"session_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"timestamp": 1716163201456,
"properties": {
"method": "processPayment",
"duration_ms": 222,
"is_async": false,
"args_count": 2
},
"meta": {}
}
FieldTypeDescription
properties.methodstringThe method name.
properties.duration_msnumberWall-clock time from call start to return, in milliseconds.
properties.is_asyncbooleantrue if the function returned a Promise. JavaScript only.
properties.args_countnumberNumber of positional arguments. JavaScript only.

sdk_error​

Emitted when a wrapped method throws (or its promise rejects), or when trackError / track_error is called directly.

{
"event": "sdk_error",
"sdk": { "name": "acme-payments", "version": "2.1.0" },
"session_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"timestamp": 1716163202789,
"properties": {
"error_message": "Connection refused to postgres://db.internal:5432",
"error_type": "ConnectionError",
"method": "connectToDatabase",
"duration_ms": 2003
},
"meta": {}
}
FieldTypeDescription
properties.error_messagestringerror.message (JS) or str(error) (Python), with email addresses replaced by [REDACTED].
properties.error_typestringerror.name (JS) or type(error).__name__ (Python).
properties.methodstringPresent when the error came from a wrapped method. The method name.
properties.duration_msnumberPresent when the error came from a wrapped method. Time until the exception.
properties.is_asyncbooleanPresent in JavaScript when the error came from a wrapped async function.
(any key)anyAdditional fields from the context argument passed to trackError / track_error.

PII scrubbing: Before enqueueing, both clients replace any string matching /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/ with [REDACTED] in error_message. No other scrubbing is applied — avoid putting PII in error messages.


Custom events​

Any string passed as the first argument to SdkGarden.track() / sg.track() becomes a custom event. The properties payload is whatever you pass as the second argument.

{
"event": "feature_used",
"sdk": { "name": "acme-payments", "version": "2.1.0" },
"session_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"timestamp": 1716163203000,
"properties": {
"feature": "streaming",
"model": "gpt-4"
},
"meta": {}
}

Properties can be any JSON-serializable key/value pairs. Nested objects are supported.


Meta fields​

The meta object is populated by the client at enqueue time with runtime context. In browser environments it includes URL and referrer. In Node.js and Python it is typically empty ({}).

FieldSourceDescription
meta.urlBrowser onlywindow.location.href at the time the event was enqueued.
meta.referrerBrowser onlydocument.referrer.