0.2.0 • Published 4 months ago

@tailor-platform/monitoring v0.2.0

Weekly downloads
-
License
-
Repository
github
Last release
4 months ago

@tailor-platform/monitoring

This package provides tools and utilities for integrating monitoring solutions in your application. While it currently leverages Datadog using @datadog/browser-rum as the monitoring provider, it's constructed to be adaptable for future monitoring solutions.

Datadog

To make the most out of the @tailor-platform/monitoring package with Datadog, familiarize yourself with the official documentation by Datadog, available here.

Initializing Monitoring

To initialize the monitoring tool, you can use the initializeMonitoring function. This allows you to set up the monitoring with default or overridden configurations:

import { initializeMonitoring } from "@tailor-platform/monitoring";

const configOverrides = {
  site: "alternate.monitoring-provider.com",
  sessionSampleRate: 50,
};

initializeMonitoring(configOverrides);

Default Configuration

The package provides a default configuration for the Datadog RUM package:

Configuration KeyDefault Value
applicationIdvalue of the NEXT_PUBLIC_DATADOG_RUM_APPLICATION_ID environment variable
clientTokenvalue of the NEXT_PUBLIC_DATADOG_RUM_CLIENT_TOKEN environment variable
site"us3.datadoghq.com"
servicevalue of the NEXT_PUBLIC_DATADOG_RUM_SERVICE environment variable
envcomputed from the value of the NEXT_PUBLIC_VERCEL_ENV environment variable, see next section
versionvalue of the NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA environment variable
sessionSampleRate100
sessionReplaySampleRate100
defaultPrivacyLevel"mask-user-input"
trackResourcestrue
trackLongTaskstrue
trackUserInteractionstrue

As the example in the previous section shows, the default configuration values can be overridden by passing custom values when calling initializeMonitoring().

For a reference of the configuration keys and their possible values, please refer to the Datadog RUM documentation.

Environment Variables

Most of the environment variables used for the default configuration are used "as is", i.e. their values are passed along verbatim.

The exception is the env key whose value is computed from the NEXT_PUBLIC_VERCEL_ENV environment variable: if the value is production then env is set to "prod", else it is set to "dev".

Setting the User

If you wish to set a user for more detailed monitoring, you can utilize the setMonitoringUser function, which is a wrapper of datadogRum.setUser(<USER_CONFIG_OBJECT>) (doc link):

import { setMonitoringUser } from "@tailor-platform/monitoring";

const user = {
  id: "user12345",
  email: "user@example.com",
};

setMonitoringUser(user);
0.2.0

4 months ago

0.1.2

5 months ago

0.1.1

5 months ago