supapulsedocs
Core packageConfiguration

Configuration

Every option init() accepts in @supapulse/core, with defaults, and how to set them per environment.

supapulse.init({
  apiToken: 'pub_your_token', // required
  endpoint: 'https://supapulse.app/api/ingest',
  fingerprintEndpoint: 'https://supapulse.app/api/fingerprint',
  autoPageviews: true,
  debug: false,
  maxRetries: 10,
  retryBackoff: 1000,
  autoOutbound: false,
  autoDownloads: false,
  autoForms: false,
  engagement: false,
});

These are all the options. The values shown are the defaults.

OptionTypeDefaultWhat it does
apiTokenstringnoneThe site's public token. Required.
endpointstringhttps://supapulse.app/api/ingestWhere events are sent.
fingerprintEndpointstringendpoint with /ingest replaced by /fingerprintWhere getVisitorFingerprint() asks for the visitor fingerprint.
autoPageviewsbooleantrueSend a pageview on init and on every History API navigation.
debugbooleanfalseLog initialization, sends, retries and drops to the console with a [Supapulse] prefix.
maxRetriesnumber10Attempts per event before it's dropped.
retryBackoffnumber1000Base delay in milliseconds. It doubles after each failed attempt, up to 30 seconds.
autoOutboundbooleanfalseSend Outbound Link: Click for clicks on links to other hosts. See Automatic events.
autoDownloadsboolean | string[]falseSend File Download for links to files. A list replaces the default extensions.
autoFormsbooleanfalseSend Form: Submission for form submits, without field values.
engagementbooleanfalseMeasure scroll depth and time on page. See Automatic events.

apiToken

The public token from the site's settings. It starts with pub_. Never put the secret token (sec_…) in browser code.

endpoint

Leave it unset unless you proxy requests through your own domain. A proxy must:

  • forward the request body unchanged, including its text/plain content type (that's how sendBeacon sends JSON);
  • pass the visitor's IP address in X-Forwarded-For and keep the User-Agent header, because the visitor hash and the country come from them;
  • keep the Origin header, or send one that matches the site's domain.

autoPageviews

With true, the tracker sends a pageview when it initializes and patches history.pushState and history.replaceState and listens to popstate to send one per navigation. With false, nothing is sent until you call pageview(). See SPA support.

debug

supapulse.init({ apiToken: 'pub_your_token', debug: true });

Logs lines like [Supapulse] Initialized, [Supapulse] Event sent, [Supapulse] Send failed and [Supapulse] Dropped after 10 attempts. Turn it off in production.

maxRetries and retryBackoff

The tracker sends with navigator.sendBeacon first. If the browser queues the beacon, the send counts as done. If not, it uses fetch. A failed fetch is retried after retryBackoff × 2^(attempt − 1) milliseconds, capped at 30 seconds. A 429 waits for the Retry-After header instead. After maxRetries attempts the event is dropped.

Pending retries live in memory. When the page is hidden or closed, the tracker tries to send them once more.

Script tag options

The script tag reads data-token, data-endpoint, data-debug="true" and data-auto, a comma list of outbound, downloads, forms and engagement. The other options keep their defaults. For anything else, install from npm.

Per environment

Read the token from your build's environment so development and production can use different sites:

supapulse.init({
  apiToken: import.meta.env.VITE_SUPAPULSE_TOKEN,
  debug: import.meta.env.DEV,
});
ToolVariable must start with
ViteVITE_
Next.jsNEXT_PUBLIC_
Create React AppREACT_APP_

To skip tracking in development, don't call init() when the token is missing:

const token = import.meta.env.VITE_SUPAPULSE_TOKEN;
if (token) {
  supapulse.init({ apiToken: token });
}

Calls to pageview() and event() on an uninitialized tracker log [Supapulse] Not initialized and do nothing.