API

Frontend API

UserMetrics API Documentation

Overview

The UserMetrics class provides methods to log events and measure metrics for user interactions. This documentation covers the usage of the UserMetrics class.

Initializing the API

new UserMetrics(config)

Creates an instance of the UserMetrics class.

new UserMetrics({ apikey: 'xxxxx-apikey-xxxxx' });

Logging an event

UserMetrics.log("some log");

Writes to the log. The log tail can be viewed in the LOG section

Adding a metric

UserMetrics.metric(#tag, #value, #jsondata);

Adds a metric for viewing in Graph, Dashboard

UserMetrics.metric("item", 1.2, {some:"data"});

Spans

UserMetrics.beginSpan(tag);

Begins measurement of a named time

UserMetrics.endSpan(tag);

Ends measurement of a named time

UserMetrics.lapSpan(tag);

Appends measurement of a named time

Errors

UserMetrics.error(tag);

Logs an error

REPLAY® (Pro Feature)

Record user sessions for playback in the Replay player. Replay is useful for debugging user interaction or providing support.

UserMetrics.startReplay();

For session recording you must call startReplay on every new page load. Replay actions are added to the current session until UserMetrics.stopReplay() or UserMetrics.newSession()

Replay can be enabled for:

This is set up at API generation in the API generator