Having sometimes multiple console.log
s while trying to find a bug that only happens with a weird state, you kinda get lost scrolling the log up and down. Or adding a bunch of break-points and then stepping into multiple ones. In the past years this happened quite often to me, and last month I thought it needs be easier to debug / see important variables while working on your project.
Fast forward until today.
@senstate/cli
The cli acts as an hub to accept client-events (via WebSockets) and send them to the dashboard.
Current features:
Current available client libraries:
more libraries in progress:
npm install @senstate/client
contains the utils / methods, not actually sending anything to the hub
npm install @senstate/client-connection
is used to send the data to the hub. I wanted to have it separately if for example it would send to other hubs / or different protocols.
import {setSenstateConnection} from "@senstate/client-connection";
setSenstateConnection({
name: 'My Example App',
// appId: 'customShortId' optional
} /* , ws://localhost:3333 */); // custom hub-address, working locally you won't need to change the target address
Without calling setStenstateConnection
all watchers/senders won't send anything to the Dashboard.
You can create a sender and call it how often you like to push the values to the Dashboard:
Watch (for variables): Sends a value of a tag:
const watcher = createWatchSender("myTag");
watcher(yourVariableOrValueToSend) // where you need it
Log
const logger = createLogSender(LogLevel.Info, "optional log name")
logger("message to send", {optionalObject: 'can be empty :)'})
Errors
Un-caught window errors will be send to the hub with:
registerWindowErrorHandler()
(call once)
Automatically sends the value on a change to the hub
class YourClass {
@PropertyWatcher()
public watchProperty = 0;
@PropertyWatcher('otherKey')
public watchOtherProperty = 0;
}
import { SenstateOperators } from '@senstate/client';
myObservable$.pipe(
SenstateOperators.watch('Watcher Tag'), // Watcher
)
other$.pipe(
SenstateOperators.log('Log Name')
)
// Measure time between pipe-operators
const time = new TimeMeasurer(tag);
trigger$.pipe(
SenstateOperators.measureStart(time),
mergeMap(() => longerObservableExecution$),
SenstateOperators.measureStep(time)
)
The project is still WIP, but I hope it'll help you.
The Dashboard isn't that polished yet, but I'm sure it'll be better after a few iterations.
If there are any ideas / feature requests / issues, please tell me :)