5.7.1 • Published 3 years ago

@asayerio/tracker-fetch v5.7.1

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Asayer Tracker Fetch plugin

Tracker plugin to support tracking of the fetch requests payload. Additionally it populates the requests with sessionID header for backend logging.

Installation

npm i @asayerio/tracker-fetch

Usage

Initialize the @asayerio/tracker package as usual and load the plugin into it. Then you can use the provided fetch method from the plugin instead of built-in.

import Tracker from '@asayerio/tracker';
import trackerFetch from '@asayerio/tracker-fetch';

const tracker = new Tracker({
  projectID: PROJECT_ID,
});
tracker.start();

export const fetch = tracker.use(trackerFetch({
  sessionTokenHeader: 'X-Session-ID', // optional
  failuresOnly: true //optional
}));

fetch('https://api.asayer.io/').then(response => console.log(response.json()));

In case you use Asayer integrations (sentry, bugsnag or others), you can use sessionTokenHeader option to specify the header name. This header will be appended automatically to the each fetch request and will contain Asayer session identificator value.

Set failuresOnly option to true if you want to record only requests with the status code >= 400.