@stateloom/telemetry
v1.0.0-alpha.0
Published
Analytics hooks for state change tracking in StateLoom stores.
Readme
@stateloom/telemetry
Analytics hooks for state change tracking in StateLoom stores.
Install
pnpm add @stateloom/telemetryQuick Start
import { 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] },
);Exports
| Export | Description |
| --------------------- | ------------------------------------------------------ |
| telemetry(options?) | Create a telemetry middleware with lifecycle callbacks |
Documentation
Full documentation with API reference, callback patterns, and analytics integration: docs/api/telemetry
License
MIT
