dsr-analytics
v1.0.0
Published
Client for the DSRAnalytics API.
Downloads
1
Readme
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/[email protected]/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/[email protected]/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) => {};