Typescript Metrics

Learn how to setup metrics in your Typescript application.

Setup

Open the Vigilant dashboard and generate an API key.

Install

Install the Vigilant SDK in your Typescript application.

npm install vigilant-js

Initialize

Initialize the Vigilant SDK in your Typescript application.

import { initVigilant } from 'vigilant-js'

initVigilant({
  name: 'backend',
  token: 'tk_1234567890', // Use your API key from the dashboard
})

Metrics Functions

The Vigilant SDK provides a function to emit metrics.

import { metricEvent } from 'vigilant-js'

// Create a metric event
metricEvent('user_login', 1)

// Create a metric event with a custom tag
metricEvent('user_login', 1, { "env": "prod" })

Optional Setup

The Vigilant SDK exposes a few setup options when you initialize it.

import { initVigilant } from 'vigilant-js'

initVigilant({
  // Disable all functionality
  noop: true,
})