1.0.0 • Published 2 years ago

dsr-analytics v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

DSRAnalytics Client

Client for the DSRAnalytics API.

Usage

NPM

Install the DSRAnalytics client:

npm i --save dsr-analytics

Use the client to track things:

import useDSRA from 'dsr-analytics';
const dsra = useDSRA('<WEBSITE_ID>', '<API_HOST>', { autoView: false });
dsra.sendView(location.href, document.referrer);

CDN

<script
  async
  data-id="<WEBSITE_ID>"
  data-host="<API_HOST>"
  src="https://cdn.jsdelivr.net/npm/dsr-analytics@1.0.0/dist/client.min.js"
></script>

API

Options

const options: Options = {
  autoView: false, // auto collect views
  autoVital: true, // auto collect vitals
  autoError: true, // auto collect errors
};
<script
  async
  data-id="<WEBSITE_ID>"
  data-host="<API_HOST>"
  src="https://cdn.jsdelivr.net/npm/dsr-analytics@1.0.0/dist/client.min.js"
  data-auto-view="false"
  data-auto-vital="true"
  data-auto-error="true"
></script>

Methods

/**
 * send view data
 * @param href href path from location.href etc.
 * @param title custom page title
 * @param referrer custom referrer
 */
dsra.sendView = (href: string, title?: string, referrer?: string) => {};
/**
 * send vital data
 * @param href href path from location.href etc.
 * @param value web vital partial/full data
 */
dsra.sendVital = (href: string, value: VitalData) => {};
/**
 * record error
 * @param href href path from location.href etc.
 * @param error javascript error
 */
dsra.sendError = (href: string, type: ErrorType, error: Error) => {};
1.0.0

2 years ago

0.21.0

2 years ago

0.12.0

2 years ago

0.11.0

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago