vestry-telemetry
v0.2.2
Published
Vestry Marketplace Telemetry SDK - Track session events and trade executions
Maintainers
Readme
@vestry/telemetry
Lightweight telemetry SDK for Vestry Marketplace apps. Track session events and trade executions with zero runtime dependencies.
Installation
npm install vestry-telemetryQuick Start
import { VestryTelemetry } from '@vestry/telemetry';
const telemetry = VestryTelemetry.init({
appId: 'your-app-id',
endpoint: 'https://vestryinc.com/api/telemetry/events',
});
// Track session events
telemetry.trackEvent({ type: 'session.start' });
telemetry.trackEvent({ type: 'feature.use', properties: { featureName: 'chart-view' } });
// Track trade executions
telemetry.trackExecution({
dateTime: new Date().toISOString(),
instrument: 'EUR/USD',
side: 'buy',
amount: 10000,
});
// Flush events to server
await telemetry.flush();
// Clean up
telemetry.destroy();Event Types
| Type | Description | Properties | |------|-------------|------------| | session.start | User begins a session | None | | session.end | User ends a session | None | | feature.use | User interacts with a feature | featureName | | error.occurred | An error occurred | message | | execution.report | A trade was executed | dateTime, instrument, side, amount |
API
VestryTelemetry.init(config)
Create a new telemetry instance.
config.appId(required) - Your Vestry app IDconfig.userToken(optional) - User's Vestry Connect tokenconfig.endpoint(optional) - Custom telemetry endpoint URL
instance.trackEvent(options)
Queue a universal event for sending.
options.type- Event type stringoptions.properties- Optional key-value properties
instance.trackExecution(data)
Queue a trade execution event.
data.dateTime- ISO 8601 timestampdata.instrument- Trading instrument symboldata.side- "buy" or "sell"data.amount- Numeric amount
instance.flush()
Send all queued events to the server. Returns a Promise.
instance.destroy()
Flush remaining events and clean up. Uses navigator.sendBeacon when available.
Silent Operation
The SDK never throws errors that could crash your app. Network failures are silently handled.
License
MIT
