/javascript-integration

Integrate your javascript based application with micro stat

Primary LanguageJavaScriptMIT LicenseMIT

micro-stat :: JavaScript SDK

  • This integration is designed for NodeJS and javascript applications
  • Please make sure to register an account to get your unique DSN (Data source name)
  • Learn more at https://www.help.micro-stat.com

Steps

  1. Install the integration in your app with npm or yarn
yarn add micro-stat
  1. Configure your connection (You must do this before publishing metrics)
import { Connection } from 'micro-stat';

Connection.connect("YOUR_DSN");
  1. Publish your first metric
import { Counter } from 'micro-stat';

const myFirstCounter = new Counter('Count Page Hits');

myFirstCounter.increment();

myFirstCounter.publish();
  1. Alternatively use short hand syntax
import { HitCounter } from 'micro-stat';

new HitCounter('Website Visited').publish();
  1. Optionally customise your experience by providing options when connecting
import { Connection } from 'micro-stat';

const options = {
  captureWebVitals: false,
  disablePublication: true
}

Connection.connect("YOUR_DSN", options);

Supported Options

Option Default Description
captureWebVitals true When true - web vitals are automatically collected and published
disablePublication false When true - metrics are only output to the console, not published to micro-stat