Official Node.js SDK for FlowMyna - Process Mining Event Tracking
npm install flowmynaOfficial Node.js SDK for FlowMyna - Process Mining Event Tracking.
``bash`
npm install flowmynaor
yarn add flowmynaor
pnpm add flowmyna
`typescript
import { FlowMyna } from 'flowmyna';
const client = new FlowMyna({
apiKey: process.env.FLOWMYNA_API_KEY!
});
// Record an event
await client.recordEvent({
event: 'Order Placed',
objects: [
{ type: 'Order', id: 'ORD-123' },
{ type: 'Customer', id: 'CUST-456' }
],
properties: { total: 149.99 }
});
// Upsert an object
await client.upsertObject({
type: 'Customer',
id: 'CUST-456',
properties: {
name: 'Jane Doe',
email: 'jane@example.com'
}
});
`
- TypeScript-first - Full type definitions included
- Automatic retries - Exponential backoff for transient failures
- Rate limit handling - Respects Retry-After headers
- ESM and CommonJS - Works with both module systems
- Node.js 18+ - Uses native fetch API
`typescript`
const client = new FlowMyna({
apiKey: 'fm_live_xxx', // Required
baseUrl: 'https://...', // Optional, defaults to production
timeout: 30000, // Optional, request timeout in ms
maxRetries: 3, // Optional, max retry attempts
});
Record a single process event.
`typescript`
const result = await client.recordEvent({
event: 'Order Shipped',
objects: [
{ type: 'Order', id: 'ORD-123' },
{ type: 'Shipment', id: 'SHIP-456' }
],
timestamp: new Date(),
properties: { carrier: 'FedEx' }
});
Record multiple events in a single request (max 100).
`typescriptProcessed: ${result.processed}
const result = await client.recordEventBatch([
{ event: 'Order Created', objects: [{ type: 'Order', id: 'ORD-1' }] },
{ event: 'Order Shipped', objects: [{ type: 'Order', id: 'ORD-1' }] },
]);
console.log();`
Create or update an object with properties.
`typescriptObject ${result.created ? 'created' : 'updated'}
const result = await client.upsertObject({
type: 'Customer',
id: 'CUST-456',
properties: { name: 'Jane Doe', tier: 'gold' }
});
console.log();`
Create or update multiple objects (max 100).
`typescript`
const result = await client.upsertObjectBatch([
{ type: 'Customer', id: 'CUST-1', properties: { tier: 'gold' } },
{ type: 'Customer', id: 'CUST-2', properties: { tier: 'silver' } },
]);
Verify API key and get workspace info.
`typescriptConnected to ${health.workspaceName}
const health = await client.health();
console.log();`
`typescript
import { FlowMyna } from 'flowmyna';
import {
AuthenticationError,
ValidationError,
RateLimitError,
ServerError,
FlowMynaError
} from 'flowmyna/errors';
try {
await client.recordEvent({ ... });
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('Invalid API key');
} else if (error instanceof ValidationError) {
console.error('Invalid request:', error.message);
} else if (error instanceof RateLimitError) {
console.error(Rate limited. Retry after ${error.retryAfter}s);``
} else if (error instanceof ServerError) {
console.error('Server error:', error.message);
} else if (error instanceof FlowMynaError) {
console.error('FlowMyna error:', error.message);
}
}
Full documentation available at flowmyna.com/api/sdks/nodejs
MIT