Skip to main content

Sampling

What is sampling?

Sampling allows you to collect metrics and profiles from a subset of your users, instead of all your users. This is useful if you have a large number of users (>1M monthly active users) and you only want to collect metrics from a subset of them.

Why sample?

After a certain point, collecting metrics from all users becomes expensive and the value of each additional metric diminishes. You should consider sampling if your app has more than 1M monthly active users.

How to sample

The first step of sampling is determining your sampling rate. To ensure Palette's metrics are accurate and reliable, you should decide your sampling rate with the following criteria:

  • If you have more than 1M monthly active users, we recommend sampling 1% of your users.
  • If you have less than 1M monthly active users, we recommend sampling 100% of your users.

Here is an example of sampling 1% of all sessions:

index.js
import { init } from "@palette.dev/browser";

init({
// ...
// Conditionally sample by enabling Palette a certain percentage of the time
enabled: Math.random() < 0.01,
});

Low Sample Sizes

The accuracy of Palette's metrics is directly related to the number of samples collected. Metrics will be less accurate and reliable when the sample size is slow.

Palette warns you about low sample sizes with a Not Enough Data indicator if the number of metrics your project is collecting is far below the number of recommended metrics.

© 2024 Redraw, Inc.