Analytics hooks for state change tracking in StateLoom stores.
pnpm add @stateloom/telemetryimport { telemetry } from '@stateloom/telemetry';
import { createStore } from '@stateloom/store';
const tm = telemetry<{ count: number }>({
onStateChange: (meta) => {
analytics.track('state_change', {
changedKeys: meta.changedKeys,
duration: meta.duration,
});
},
});
const store = createStore(
(set) => ({
count: 0,
inc: () => set((s) => ({ count: s.count + 1 })),
}),
{ middleware: [tm] },
);| Export | Description |
|---|---|
telemetry(options?) |
Create a telemetry middleware with lifecycle callbacks |
Full documentation with API reference, callback patterns, and analytics integration: docs/api/telemetry
MIT