Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@stateloom/telemetry

Analytics hooks for state change tracking in StateLoom stores.

Install

pnpm add @stateloom/telemetry

Quick 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